From 90811d66d4a548fcf257aa61c0e8fd7465f7cf25 Mon Sep 17 00:00:00 2001 From: sauwming Date: Thu, 11 Jul 2024 11:07:57 +0800 Subject: [PATCH] Fixed Opus decoder PLC setting --- pjmedia/src/pjmedia-codec/opus.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pjmedia/src/pjmedia-codec/opus.c b/pjmedia/src/pjmedia-codec/opus.c index 7841792fc4..1264a41ec2 100644 --- a/pjmedia/src/pjmedia-codec/opus.c +++ b/pjmedia/src/pjmedia-codec/opus.c @@ -641,6 +641,7 @@ static pj_status_t codec_open( pjmedia_codec *codec, struct opus_data *opus_data = (struct opus_data *)codec->codec_data; int idx, err; pj_bool_t auto_bit_rate = PJ_TRUE; + pj_bool_t enc_use_plc = PJ_FALSE; PJ_ASSERT_RETURN(codec && attr && opus_data, PJ_EINVAL); @@ -697,7 +698,10 @@ static pj_status_t codec_open( pjmedia_codec *codec, if (idx >= 0) { unsigned plc; plc = (unsigned) pj_strtoul(&attr->setting.enc_fmtp.param[idx].val); - attr->setting.plc = plc > 0? PJ_TRUE: PJ_FALSE; + if (plc > 0) + enc_use_plc = PJ_TRUE; + /* Do not modify local PLC setting as it's used for decoding. */ + // attr->setting.plc = plc > 0? PJ_TRUE: PJ_FALSE } /* Check vad */ @@ -750,7 +754,7 @@ static pj_status_t codec_open( pjmedia_codec *codec, opus_encoder_ctl(opus_data->enc, OPUS_SET_DTX(attr->setting.vad ? 1 : 0)); /* Set PLC */ opus_encoder_ctl(opus_data->enc, - OPUS_SET_INBAND_FEC(attr->setting.plc ? 1 : 0)); + OPUS_SET_INBAND_FEC(enc_use_plc)); /* Set bandwidth */ opus_encoder_ctl(opus_data->enc, OPUS_SET_MAX_BANDWIDTH(get_opus_bw_constant(