<settings>
<param name="use-vbr" value="1"/>
<param name="complexity" value="10"/>
+
+ <!--
+ maxaveragebitrate: the maximum average codec bitrate (values: 6000 to 510000 in bps) 0 is not considered
+ maxplaybackrate: the maximum codec internal frequency (values: 8000, 12000, 16000, 24000, 48000 in Hz) 0 is not considered
+ This will set the local encoder and instruct the remote encoder trough specific "fmtp" attibute in the SDP.
+
+ Example: if you receive "maxaveragebitrate=20000" from SDP and you have set "maxaveragebitrate=24000" in this configuration
+ the lowest will prevail in this case "20000" is set on the encoder and the corresponding fmtp attribute will be set
+ to instruct the remote encoder to do the same.
+ -->
+ <param name="maxaveragebitrate" value="0"/>
+ <param name="maxplaybackrate" value="0"/>
+
</settings>
</configuration>
struct {
int use_vbr;
int complexity;
+ int maxaveragebitrate;
+ int maxplaybackrate;
switch_mutex_t *mutex;
} opus_prefs;
memset(&codec_fmtp, '\0', sizeof(struct switch_codec_fmtp));
codec_fmtp.private_info = &opus_codec_settings;
switch_opus_fmtp_parse(codec->fmtp_in, &codec_fmtp);
+
+ /* Verify if the local or remote configuration are lowering maxaveragebitrate and/or maxplaybackrate */
+ if ( opus_prefs.maxaveragebitrate && (opus_prefs.maxaveragebitrate < opus_codec_settings.maxaveragebitrate || !opus_codec_settings.maxaveragebitrate) ) {
+ opus_codec_settings.maxaveragebitrate = opus_prefs.maxaveragebitrate;
+ }
+ if ( opus_prefs.maxplaybackrate && (opus_prefs.maxplaybackrate < opus_codec_settings.maxplaybackrate || !opus_codec_settings.maxplaybackrate) ) {
+ opus_codec_settings.maxplaybackrate = opus_prefs.maxplaybackrate;
+ }
+
codec->fmtp_out = gen_fmtp(&opus_codec_settings, codec->memory_pool);
if (encoding) {
}
-
-
/* Setting documented in "RTP Payload Format for Opus Speech and Audio Codec" draft-spittka-payload-rtp-opus-03 */
if( opus_codec_settings.maxaveragebitrate ) { /* Remote codec settings found in SDP "fmtp", we accept to tune the Encoder */
opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(opus_codec_settings.maxaveragebitrate));
opus_prefs.use_vbr = atoi(val);
} else if (!strcasecmp(key, "complexity")) {
opus_prefs.complexity = atoi(val);
+ } else if (!strcasecmp(key, "maxaveragebitrate")) {
+ opus_prefs.maxaveragebitrate = atoi(val);
+ if ( opus_prefs.maxaveragebitrate < 6000 || opus_prefs.maxaveragebitrate > 510000 ) {
+ opus_prefs.maxaveragebitrate = 0; /* values outside the range between 6000 and 510000 SHOULD be ignored */
+ }
+ } else if (!strcasecmp(key, "maxplaybackrate")) {
+ opus_prefs.maxplaybackrate = atoi(val);
+ if ( opus_prefs.maxplaybackrate != 8000 && opus_prefs.maxplaybackrate != 12000 && opus_prefs.maxplaybackrate != 16000
+ && opus_prefs.maxplaybackrate != 24000 && opus_prefs.maxplaybackrate != 48000) {
+ opus_prefs.maxplaybackrate = 0; /* value not supported */
+ }
}
}
}