mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-28 05:04:13 +00:00
FS-7801: mod_opus: added support to set CBR mode
This commit is contained in:
parent
2b099c9260
commit
be6e6ea5fb
@ -146,6 +146,10 @@ static switch_status_t switch_opus_fmtp_parse(const char *fmtp, switch_codec_fmt
|
|||||||
codec_settings->usedtx = switch_true(arg);
|
codec_settings->usedtx = switch_true(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcasecmp(data, "cbr")) {
|
||||||
|
codec_settings->cbr = switch_true(arg);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcasecmp(data, "sprop-maxcapturerate")) {
|
if (!strcasecmp(data, "sprop-maxcapturerate")) {
|
||||||
codec_settings->sprop_maxcapturerate = atoi(arg);
|
codec_settings->sprop_maxcapturerate = atoi(arg);
|
||||||
}
|
}
|
||||||
@ -214,6 +218,10 @@ static char *gen_fmtp(opus_codec_settings_t *settings, switch_memory_pool_t *poo
|
|||||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "usedtx=1; ");
|
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "usedtx=1; ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings->cbr) {
|
||||||
|
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "cbr=1; ");
|
||||||
|
}
|
||||||
|
|
||||||
if (settings->maxaveragebitrate) {
|
if (settings->maxaveragebitrate) {
|
||||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "maxaveragebitrate=%d; ", settings->maxaveragebitrate);
|
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "maxaveragebitrate=%d; ", settings->maxaveragebitrate);
|
||||||
}
|
}
|
||||||
@ -337,12 +345,14 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag
|
|||||||
opus_codec_settings.sprop_maxcapturerate = opus_codec_settings_remote.sprop_maxcapturerate;
|
opus_codec_settings.sprop_maxcapturerate = opus_codec_settings_remote.sprop_maxcapturerate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opus_codec_settings.cbr = !opus_prefs.use_vbr;
|
||||||
|
|
||||||
codec->fmtp_out = gen_fmtp(&opus_codec_settings, codec->memory_pool);
|
codec->fmtp_out = gen_fmtp(&opus_codec_settings, codec->memory_pool);
|
||||||
|
|
||||||
if (encoding) {
|
if (encoding) {
|
||||||
/* come up with a way to specify these */
|
/* come up with a way to specify these */
|
||||||
int bitrate_bps = OPUS_AUTO;
|
int bitrate_bps = OPUS_AUTO;
|
||||||
int use_vbr = opus_prefs.use_vbr;
|
int use_vbr = opus_codec_settings.cbr ? !opus_codec_settings.cbr : opus_prefs.use_vbr ;
|
||||||
int complexity = opus_prefs.complexity;
|
int complexity = opus_prefs.complexity;
|
||||||
int plpct = opus_prefs.plpct;
|
int plpct = opus_prefs.plpct;
|
||||||
int err;
|
int err;
|
||||||
@ -410,7 +420,11 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (use_vbr) {
|
if (use_vbr) {
|
||||||
|
/* VBR is default*/
|
||||||
opus_encoder_ctl(context->encoder_object, OPUS_SET_VBR(use_vbr));
|
opus_encoder_ctl(context->encoder_object, OPUS_SET_VBR(use_vbr));
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: CBR mode enabled\n");
|
||||||
|
opus_encoder_ctl(context->encoder_object, OPUS_SET_VBR(0));
|
||||||
}
|
}
|
||||||
if (complexity) {
|
if (complexity) {
|
||||||
opus_encoder_ctl(context->encoder_object, OPUS_SET_COMPLEXITY(complexity));
|
opus_encoder_ctl(context->encoder_object, OPUS_SET_COMPLEXITY(complexity));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user