From 78885f327d9ba1874d31908837ae046dbc45d958 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Thu, 4 Jun 2015 11:29:47 +0300 Subject: modules/opus: use configured or received sending rate determine sending rate as follows: - if opus_bitrate is configured and maxaveragebitrate is received, use minimum of the two - if one is missing, use the one that is given - if both are missing, use the default (OPUS_AUTO) --- modules/opus/encode.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules/opus') diff --git a/modules/opus/encode.c b/modules/opus/encode.c index 3272490..aea944f 100644 --- a/modules/opus/encode.c +++ b/modules/opus/encode.c @@ -70,8 +70,10 @@ int opus_encode_update(struct auenc_state **aesp, const struct aucodec *ac, struct auenc_param *param, const char *fmtp) { struct auenc_state *aes; - struct opus_param prm; + struct opus_param prm, conf_prm; opus_int32 fch, vbr; + const struct aucodec *auc = aucodec_find("opus", 48000, 2); + (void)param; if (!aesp || !ac || !ac->ch) @@ -114,6 +116,14 @@ int opus_encode_update(struct auenc_state **aesp, const struct aucodec *ac, opus_decode_fmtp(&prm, fmtp); + conf_prm.bitrate = OPUS_AUTO; + opus_decode_fmtp(&conf_prm, auc->fmtp); + + if ((prm.bitrate == OPUS_AUTO) || + ((conf_prm.bitrate != OPUS_AUTO) && + (conf_prm.bitrate < prm.bitrate))) + prm.bitrate = conf_prm.bitrate; + fch = prm.stereo ? OPUS_AUTO : 1; vbr = prm.cbr ? 0 : 1; -- cgit v1.2.3