From f3a5e1e5b661c266edfb89bf9ce8925d459002da Mon Sep 17 00:00:00 2001 From: pangbo5 Date: Tue, 13 Jan 2026 18:28:22 +0800 Subject: [PATCH] multistream: Add DRED duration CTL support Forward OPUS_SET_DRED_DURATION_REQUEST and OPUS_GET_DRED_DURATION_REQUEST to all underlying encoders in the multistream encoder, enabling DRED (Deep Redundancy) configuration when using libopusenc or other multistream-based workflows. This allows applications using the Ogg Opus encoding pipeline to benefit from the packet loss resilience features introduced in Opus 1.5. Signed-off-by: Waterforest Pang --- src/opus_multistream_encoder.c | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/opus_multistream_encoder.c b/src/opus_multistream_encoder.c index 79c0d3b7d..43619a23d 100644 --- a/src/opus_multistream_encoder.c +++ b/src/opus_multistream_encoder.c @@ -1316,6 +1316,51 @@ int opus_multistream_encoder_ctl_va_list(OpusMSEncoder *st, int request, *value = st->variable_duration; } break; +#ifdef ENABLE_DRED + case OPUS_SET_DRED_DURATION_REQUEST: + { + int s; + opus_int32 value = va_arg(ap, opus_int32); + for (s=0;slayout.nb_streams;s++) + { + OpusEncoder *enc; + enc = (OpusEncoder*)ptr; + if (s < st->layout.nb_coupled_streams) + ptr += align(coupled_size); + else + ptr += align(mono_size); + ret = opus_encoder_ctl(enc, OPUS_SET_DRED_DURATION(value)); + if (ret != OPUS_OK) + break; + } + } + break; + case OPUS_GET_DRED_DURATION_REQUEST: + { + int s; + opus_int32 *value = va_arg(ap, opus_int32*); + if (!value) + { + goto bad_arg; + } + for (s=0;slayout.nb_streams;s++) + { + opus_int32 tmp; + OpusEncoder *enc; + enc = (OpusEncoder*)ptr; + if (s < st->layout.nb_coupled_streams) + ptr += align(coupled_size); + else + ptr += align(mono_size); + ret = opus_encoder_ctl(enc, OPUS_GET_DRED_DURATION(&tmp)); + if (ret != OPUS_OK) + break; + if (s == 0) + *value = tmp; + } + } + break; +#endif case OPUS_RESET_STATE: { int s;