提交 22335d21 authored 作者: Brian's avatar Brian

FS-7601 allow setting the packet loss percentage on the encoder from the opus.conf.xml file

上级 28e0dcdc
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
<settings> <settings>
<param name="use-vbr" value="1"/> <param name="use-vbr" value="1"/>
<param name="complexity" value="10"/> <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 maxaveragebitrate: the maximum average codec bitrate (values: 6000 to 510000 in bps) 0 is not considered
......
...@@ -82,6 +82,7 @@ struct { ...@@ -82,6 +82,7 @@ struct {
int complexity; int complexity;
int maxaveragebitrate; int maxaveragebitrate;
int maxplaybackrate; int maxplaybackrate;
int plpct;
switch_mutex_t *mutex; switch_mutex_t *mutex;
} opus_prefs; } opus_prefs;
...@@ -261,6 +262,7 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag ...@@ -261,6 +262,7 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag
int bitrate_bps = OPUS_AUTO; int bitrate_bps = OPUS_AUTO;
int use_vbr = opus_prefs.use_vbr; int use_vbr = opus_prefs.use_vbr;
int complexity = opus_prefs.complexity; int complexity = opus_prefs.complexity;
int plpct = opus_prefs.plpct;
int err; int err;
int samplerate = opus_codec_settings.samplerate ? opus_codec_settings.samplerate : codec->implementation->actual_samples_per_second; 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 ...@@ -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)); 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) { if (opus_codec_settings.useinbandfec) {
opus_encoder_ctl(context->encoder_object, OPUS_SET_INBAND_FEC(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) ...@@ -480,6 +486,8 @@ static switch_status_t opus_load_config(switch_bool_t reload)
opus_prefs.use_vbr = atoi(val); opus_prefs.use_vbr = atoi(val);
} else if (!strcasecmp(key, "complexity")) { } else if (!strcasecmp(key, "complexity")) {
opus_prefs.complexity = atoi(val); opus_prefs.complexity = atoi(val);
} else if (!strcasecmp(key, "packet-loss-percent")) {
opus_prefs.plpct = atoi(val);
} else if (!strcasecmp(key, "maxaveragebitrate")) { } else if (!strcasecmp(key, "maxaveragebitrate")) {
opus_prefs.maxaveragebitrate = atoi(val); opus_prefs.maxaveragebitrate = atoi(val);
if ( opus_prefs.maxaveragebitrate < 6000 || opus_prefs.maxaveragebitrate > 510000 ) { if ( opus_prefs.maxaveragebitrate < 6000 || opus_prefs.maxaveragebitrate > 510000 ) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论