Add extra receive buffering and decode Opus FEC on loss
A new Extra buffering setting (Network page) holds more playback delay than the jitter buffer measures it needs, so late packets still make it in time on a bad connection. A lost frame is now rebuilt from the FEC copy in the next packet when that one is already held, and the Connection Info shows how many were recovered. Held packets' arrival marks now move with the timeline when the delay changes; libspeex leaves them, which made a multi-frame jump count twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -74,10 +74,13 @@ Java_com_ts3client_android_audio_NativeOpus_decoderCreate(JNIEnv *env, jclass, j
|
||||
return reinterpret_cast<jlong>(created);
|
||||
}
|
||||
|
||||
/** Decodes {@code packet}, or conceals {@code frameSize} samples when it is null. */
|
||||
/**
|
||||
* Decodes {@code packet}, or conceals {@code frameSize} samples when it is null; with {@code fec},
|
||||
* rebuilds the packet before {@code packet} from its error correction copy.
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_ts3client_android_audio_NativeOpus_decode(JNIEnv *env, jclass, jlong handle, jbyteArray packet,
|
||||
jfloatArray out, jint frameSize) {
|
||||
jfloatArray out, jint frameSize, jboolean fec) {
|
||||
std::vector<unsigned char> data;
|
||||
if (packet != nullptr) {
|
||||
data.resize(static_cast<size_t>(env->GetArrayLength(packet)));
|
||||
@@ -85,7 +88,7 @@ Java_com_ts3client_android_audio_NativeOpus_decode(JNIEnv *env, jclass, jlong ha
|
||||
}
|
||||
jfloat *samples = env->GetFloatArrayElements(out, nullptr);
|
||||
int decoded = opus_decode_float(decoder(handle), packet != nullptr ? data.data() : nullptr,
|
||||
static_cast<opus_int32>(data.size()), samples, frameSize, 0);
|
||||
static_cast<opus_int32>(data.size()), samples, frameSize, fec ? 1 : 0);
|
||||
env->ReleaseFloatArrayElements(out, samples, decoded < 0 ? JNI_ABORT : 0);
|
||||
if (decoded < 0) throwOpus(env, "opus_decode_float", decoded);
|
||||
return decoded;
|
||||
|
||||
Reference in New Issue
Block a user