]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7819: mod_opus: restore bitrate after increase (if there's no more packet loss...
authorDragos Oancea <droancea@yahoo.com>
Thu, 9 Jul 2015 11:22:19 +0000 (07:22 -0400)
committerDragos Oancea <droancea@yahoo.com>
Fri, 10 Jul 2015 15:35:27 +0000 (11:35 -0400)
src/mod/codecs/mod_opus/mod_opus.c

index 02287e49959bb4c55631be69a2e9078fef22c70b..49914ee0613b5436b264f65a3bcaedbb4f8a44b8 100644 (file)
@@ -634,10 +634,14 @@ static switch_status_t switch_opus_keep_fec_enabled(switch_codec_t *codec)
        opus_int32 a32,b32; 
        uint32_t fs = context->enc_frame_size * 1000 / (codec->implementation->microseconds_per_packet / 1000);
        float frame_rate = 1000 / (codec->implementation->microseconds_per_packet / 1000);
-       uint32_t step = 8000 / (codec->implementation->microseconds_per_packet / 1000); /* this works for 10 ms, 20 ms and 40 ms frame sizes. not for 60 ms*/
+       uint32_t step = (codec->implementation->microseconds_per_packet / 1000) != 60 ? 8000 / (codec->implementation->microseconds_per_packet / 1000 ) : 134 ;
 
        opus_encoder_ctl(context->encoder_object, OPUS_GET_BITRATE(&current_bitrate));
        opus_encoder_ctl(context->encoder_object, OPUS_GET_PACKET_LOSS_PERC(&current_loss));
+       if ( current_loss == 0  ){
+               opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(opus_prefs.maxaveragebitrate));
+               return SWITCH_STATUS_SUCCESS;
+       }
        if( fs == 8000 ) {
                LBRR_rate_thres_bps = 12000; /*LBRR_NB_MIN_RATE_BPS*/
        } else if( fs == 12000 ) {