]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7601 allow setting the packet loss percentage on the encoder from the opus.conf...
authorBrian <brian@freeswitch.org>
Thu, 4 Jun 2015 20:57:33 +0000 (15:57 -0500)
committerBrian <brian@freeswitch.org>
Thu, 4 Jun 2015 20:57:33 +0000 (15:57 -0500)
conf/vanilla/autoload_configs/opus.conf.xml
src/mod/codecs/mod_opus/mod_opus.c

index 2ac3f66f8620b1a6efff59341c1652cc848f94e9..f6c529476057d94f500788e10edfc264aec45111 100644 (file)
@@ -2,6 +2,8 @@
     <settings>
         <param name="use-vbr" value="1"/>
         <param name="complexity" value="10"/>
+       <!-- Packet Loss Percent, Default 0 -->
+        <!--<param name="packet-loss-percent" value="20"/>-->
 
         <!--
            maxaveragebitrate: the maximum average codec bitrate (values: 6000 to 510000 in bps) 0 is not considered
index 84753983bd03a05090733b7e5b4343ac5d5dd4f9..f36725e2edd380cc592e55de627b598b1b316424 100644 (file)
@@ -82,6 +82,7 @@ struct {
     int complexity;
     int maxaveragebitrate;
     int maxplaybackrate;
+       int plpct;
     switch_mutex_t *mutex;
 } opus_prefs;
 
@@ -261,6 +262,7 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag
                int bitrate_bps = OPUS_AUTO;
                int use_vbr = opus_prefs.use_vbr;
                int complexity = opus_prefs.complexity;
+               int plpct = opus_prefs.plpct;
                int err;
                int samplerate = opus_codec_settings.samplerate ? opus_codec_settings.samplerate : codec->implementation->actual_samples_per_second;
         
@@ -313,6 +315,10 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag
                        opus_encoder_ctl(context->encoder_object, OPUS_SET_COMPLEXITY(complexity));
         }
 
+               if (plpct) {
+                       opus_encoder_ctl(context->encoder_object, OPUS_SET_PACKET_LOSS_PERC(plpct));
+               }
+               
                if (opus_codec_settings.useinbandfec) {
                        opus_encoder_ctl(context->encoder_object, OPUS_SET_INBAND_FEC(opus_codec_settings.useinbandfec));
                }
@@ -480,6 +486,8 @@ static switch_status_t opus_load_config(switch_bool_t reload)
                                opus_prefs.use_vbr = atoi(val);
                        } else if (!strcasecmp(key, "complexity")) {
                                opus_prefs.complexity = atoi(val);
+                       } else if (!strcasecmp(key, "packet-loss-percent")) {
+                               opus_prefs.plpct = atoi(val);
                        } else if (!strcasecmp(key, "maxaveragebitrate")) {
                                opus_prefs.maxaveragebitrate = atoi(val);
                                if ( opus_prefs.maxaveragebitrate < 6000 || opus_prefs.maxaveragebitrate > 510000 ) {