diff options
author | buildbot@webrtc.org <buildbot@webrtc.org> | 2014-10-30 07:50:13 +0000 |
---|---|---|
committer | buildbot@webrtc.org <buildbot@webrtc.org> | 2014-10-30 07:50:13 +0000 |
commit | 197555775796b87dab3bb6d05db36dad5bb4fb9c (patch) | |
tree | 604c3fa948e8457ac169cdc53e9c0bd114306eff | |
parent | 00421721419518277402c17466408025e0eb9ffe (diff) | |
download | talk-197555775796b87dab3bb6d05db36dad5bb4fb9c.tar.gz |
(Auto)update libjingle 78822708-> 78823675
git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@7567 4adac7df-926f-26a2-2b94-8c16560cd09d
-rw-r--r-- | media/webrtc/webrtcvoiceengine.cc | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/media/webrtc/webrtcvoiceengine.cc b/media/webrtc/webrtcvoiceengine.cc index cf3a56f..95e16e4 100644 --- a/media/webrtc/webrtcvoiceengine.cc +++ b/media/webrtc/webrtcvoiceengine.cc @@ -117,6 +117,15 @@ static const int kNackMaxPackets = 250; // Codec parameters for Opus. // draft-spittka-payload-rtp-opus-03 + +// Recommended bitrates: +// 8-12 kb/s for NB speech, +// 16-20 kb/s for WB speech, +// 28-40 kb/s for FB speech, +// 48-64 kb/s for FB mono music, and +// 64-128 kb/s for FB stereo music. +// The current implementation applies the following values to mono signals, +// and multiplies them by 2 for stereo. static const int kOpusBitrateNb = 12000; static const int kOpusBitrateWb = 20000; static const int kOpusBitrateFb = 32000; @@ -413,7 +422,7 @@ static bool IsOpusStereoEnabled(const AudioCodec& codec) { // otherwise. If the value (either from params or codec.bitrate) <=0, use the // default configuration. If the value is beyond feasible bit rate of Opus, // clamp it. Returns the Opus bit rate for operation. -static int GetOpusBitrate(const AudioCodec& codec) { +static int GetOpusBitrate(const AudioCodec& codec, int max_playback_rate) { int bitrate = 0; bool use_param = true; if (!codec.GetParam(kCodecParamMaxAverageBitrate, &bitrate)) { @@ -421,8 +430,17 @@ static int GetOpusBitrate(const AudioCodec& codec) { use_param = false; } if (bitrate <= 0) { - bitrate = IsOpusStereoEnabled(codec) ? kOpusStereoBitrate : - kOpusMonoBitrate; + if (max_playback_rate <= 8000) { + bitrate = kOpusBitrateNb; + } else if (max_playback_rate <= 16000) { + bitrate = kOpusBitrateWb; + } else { + bitrate = kOpusBitrateFb; + } + + if (IsOpusStereoEnabled(codec)) { + bitrate *= 2; + } } else if (bitrate < kOpusMinBitrate || bitrate > kOpusMaxBitrate) { bitrate = (bitrate < kOpusMinBitrate) ? kOpusMinBitrate : kOpusMaxBitrate; std::string rate_source = @@ -463,11 +481,8 @@ static void GetOpusConfig(const AudioCodec& codec, webrtc::CodecInst* voe_codec, // the bitrate is not specified, i.e. is <= zero, we set it to the // appropriate default value for mono or stereo Opus. - // TODO(minyue): The determination of bit rate might take the maximum playback - // rate into account. - voe_codec->channels = IsOpusStereoEnabled(codec) ? 2 : 1; - voe_codec->rate = GetOpusBitrate(codec); + voe_codec->rate = GetOpusBitrate(codec, *max_playback_rate); } void WebRtcVoiceEngine::ConstructCodecs() { |