Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc

Issue 2798403003: Hooked up Opus CBR support when configured manually or through an SdpAudioFormat. (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 AudioEncoderOpus::Config AudioEncoderOpus::CreateConfig( 249 AudioEncoderOpus::Config AudioEncoderOpus::CreateConfig(
250 int payload_type, 250 int payload_type,
251 const SdpAudioFormat& format) { 251 const SdpAudioFormat& format) {
252 AudioEncoderOpus::Config config; 252 AudioEncoderOpus::Config config;
253 253
254 config.num_channels = GetChannelCount(format); 254 config.num_channels = GetChannelCount(format);
255 config.frame_size_ms = GetFrameSizeMs(format); 255 config.frame_size_ms = GetFrameSizeMs(format);
256 config.max_playback_rate_hz = GetMaxPlaybackRate(format); 256 config.max_playback_rate_hz = GetMaxPlaybackRate(format);
257 config.fec_enabled = (GetFormatParameter(format, "useinbandfec") == "1"); 257 config.fec_enabled = (GetFormatParameter(format, "useinbandfec") == "1");
258 config.dtx_enabled = (GetFormatParameter(format, "usedtx") == "1"); 258 config.dtx_enabled = (GetFormatParameter(format, "usedtx") == "1");
259 config.cbr_enabled = (GetFormatParameter(format, "cbr") == "1");
259 config.bitrate_bps = rtc::Optional<int>( 260 config.bitrate_bps = rtc::Optional<int>(
260 CalculateBitrate(config.max_playback_rate_hz, config.num_channels, 261 CalculateBitrate(config.max_playback_rate_hz, config.num_channels,
261 GetFormatParameter(format, "maxaveragebitrate"))); 262 GetFormatParameter(format, "maxaveragebitrate")));
262 config.payload_type = payload_type; 263 config.payload_type = payload_type;
263 config.application = config.num_channels == 1 ? AudioEncoderOpus::kVoip 264 config.application = config.num_channels == 1 ? AudioEncoderOpus::kVoip
264 : AudioEncoderOpus::kAudio; 265 : AudioEncoderOpus::kAudio;
265 #if WEBRTC_OPUS_VARIABLE_COMPLEXITY 266 #if WEBRTC_OPUS_VARIABLE_COMPLEXITY
266 config.low_rate_complexity = 9; 267 config.low_rate_complexity = 9;
267 #endif 268 #endif
268 269
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 complexity_ = config.GetNewComplexity().value_or(config.complexity); 647 complexity_ = config.GetNewComplexity().value_or(config.complexity);
647 RTC_CHECK_EQ(0, WebRtcOpus_SetComplexity(inst_, complexity_)); 648 RTC_CHECK_EQ(0, WebRtcOpus_SetComplexity(inst_, complexity_));
648 if (config.dtx_enabled) { 649 if (config.dtx_enabled) {
649 RTC_CHECK_EQ(0, WebRtcOpus_EnableDtx(inst_)); 650 RTC_CHECK_EQ(0, WebRtcOpus_EnableDtx(inst_));
650 } else { 651 } else {
651 RTC_CHECK_EQ(0, WebRtcOpus_DisableDtx(inst_)); 652 RTC_CHECK_EQ(0, WebRtcOpus_DisableDtx(inst_));
652 } 653 }
653 RTC_CHECK_EQ(0, 654 RTC_CHECK_EQ(0,
654 WebRtcOpus_SetPacketLossRate( 655 WebRtcOpus_SetPacketLossRate(
655 inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5))); 656 inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5)));
656 657 if (config.cbr_enabled) {
658 RTC_CHECK_EQ(0, WebRtcOpus_EnableCbr(inst_));
659 } else {
660 RTC_CHECK_EQ(0, WebRtcOpus_DisableCbr(inst_));
661 }
657 num_channels_to_encode_ = NumChannels(); 662 num_channels_to_encode_ = NumChannels();
658 next_frame_length_ms_ = config_.frame_size_ms; 663 next_frame_length_ms_ = config_.frame_size_ms;
659 return true; 664 return true;
660 } 665 }
661 666
662 void AudioEncoderOpus::SetFrameLength(int frame_length_ms) { 667 void AudioEncoderOpus::SetFrameLength(int frame_length_ms) {
663 next_frame_length_ms_ = frame_length_ms; 668 next_frame_length_ms_ = frame_length_ms;
664 } 669 }
665 670
666 void AudioEncoderOpus::SetNumChannelsToEncode(size_t num_channels_to_encode) { 671 void AudioEncoderOpus::SetNumChannelsToEncode(size_t num_channels_to_encode) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 config_.uplink_bandwidth_update_interval_ms) { 742 config_.uplink_bandwidth_update_interval_ms) {
738 rtc::Optional<float> smoothed_bitrate = bitrate_smoother_->GetAverage(); 743 rtc::Optional<float> smoothed_bitrate = bitrate_smoother_->GetAverage();
739 if (smoothed_bitrate) 744 if (smoothed_bitrate)
740 audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate); 745 audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate);
741 bitrate_smoother_last_update_time_ = rtc::Optional<int64_t>(now_ms); 746 bitrate_smoother_last_update_time_ = rtc::Optional<int64_t>(now_ms);
742 } 747 }
743 } 748 }
744 } 749 }
745 750
746 } // namespace webrtc 751 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698