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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 2775483004: Set max bitrate for audio send stream based on RtpParameters. (Closed)
Patch Set: Created 3 years, 9 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 | no next file » | 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) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 1381
1382 void RecreateAudioSendStream() { 1382 void RecreateAudioSendStream() {
1383 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1383 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1384 if (stream_) { 1384 if (stream_) {
1385 call_->DestroyAudioSendStream(stream_); 1385 call_->DestroyAudioSendStream(stream_);
1386 stream_ = nullptr; 1386 stream_ = nullptr;
1387 } 1387 }
1388 RTC_DCHECK(!stream_); 1388 RTC_DCHECK(!stream_);
1389 if (webrtc::field_trial::IsEnabled("WebRTC-Audio-SendSideBwe")) { 1389 if (webrtc::field_trial::IsEnabled("WebRTC-Audio-SendSideBwe")) {
1390 config_.min_bitrate_bps = kOpusMinBitrateBps; 1390 config_.min_bitrate_bps = kOpusMinBitrateBps;
1391 config_.max_bitrate_bps = kOpusBitrateFbBps; 1391
1392 // This means that when RtpParameters is reset, we may change the
1393 // encoder's bit rate immediately (through call_->CreateAudioSendStream),
1394 // meanwhile change the cap to the output of BWE.
1395 // TODO(minyue): remove dependency on RtpParameters when the signaling to
1396 // BWE is done through a dedicated API.
stefan-webrtc 2017/03/24 15:09:14 I think this is something that should be here even
minyue-webrtc 2017/03/24 21:13:59 right, I will remove this todo now.
1397 config_.max_bitrate_bps = rtp_parameters_.encodings[0].max_bitrate_bps ?
1398 *rtp_parameters_.encodings[0].max_bitrate_bps : kOpusBitrateFbBps;
1392 // TODO(mflodman): Keep testing this and set proper values. 1399 // TODO(mflodman): Keep testing this and set proper values.
1393 // Note: This is an early experiment currently only supported by Opus. 1400 // Note: This is an early experiment currently only supported by Opus.
1394 if (send_side_bwe_with_overhead_) { 1401 if (send_side_bwe_with_overhead_) {
1395 auto packet_sizes_ms = WebRtcVoiceCodecs::GetPacketSizesMs( 1402 auto packet_sizes_ms = WebRtcVoiceCodecs::GetPacketSizesMs(
1396 config_.send_codec_spec.codec_inst); 1403 config_.send_codec_spec.codec_inst);
1397 if (!packet_sizes_ms.empty()) { 1404 if (!packet_sizes_ms.empty()) {
1398 int max_packet_size_ms = 1405 int max_packet_size_ms =
1399 *std::max_element(packet_sizes_ms.begin(), packet_sizes_ms.end()); 1406 *std::max_element(packet_sizes_ms.begin(), packet_sizes_ms.end());
1400 int min_packet_size_ms = 1407 int min_packet_size_ms =
1401 *std::min_element(packet_sizes_ms.begin(), packet_sizes_ms.end()); 1408 *std::min_element(packet_sizes_ms.begin(), packet_sizes_ms.end());
(...skipping 12 matching lines...) Expand all
1414 1421
1415 // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) 1422 // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12)
1416 constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12; 1423 constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12;
1417 1424
1418 int min_overhead_bps = 1425 int min_overhead_bps =
1419 kOverheadPerPacket * 8 * 1000 / max_packet_size_ms; 1426 kOverheadPerPacket * 8 * 1000 / max_packet_size_ms;
1420 1427
1421 int max_overhead_bps = 1428 int max_overhead_bps =
1422 kOverheadPerPacket * 8 * 1000 / min_packet_size_ms; 1429 kOverheadPerPacket * 8 * 1000 / min_packet_size_ms;
1423 1430
1424 config_.min_bitrate_bps = kOpusMinBitrateBps + min_overhead_bps; 1431 config_.min_bitrate_bps += min_overhead_bps;
1425 config_.max_bitrate_bps = kOpusBitrateFbBps + max_overhead_bps; 1432 config_.max_bitrate_bps += max_overhead_bps;
minyue-webrtc 2017/03/24 21:13:59 I see a problem here. To make sure that the payloa
stefan-webrtc 2017/03/27 12:11:46 Sounds good to me. As long as the max BWE is set h
1426 } 1433 }
1427 } 1434 }
1428 } 1435 }
1429 stream_ = call_->CreateAudioSendStream(config_); 1436 stream_ = call_->CreateAudioSendStream(config_);
1430 RTC_CHECK(stream_); 1437 RTC_CHECK(stream_);
1431 UpdateSendState(); 1438 UpdateSendState();
1432 } 1439 }
1433 1440
1434 rtc::ThreadChecker worker_thread_checker_; 1441 rtc::ThreadChecker worker_thread_checker_;
1435 rtc::RaceChecker audio_capture_race_checker_; 1442 rtc::RaceChecker audio_capture_race_checker_;
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2654 ssrc); 2661 ssrc);
2655 if (it != unsignaled_recv_ssrcs_.end()) { 2662 if (it != unsignaled_recv_ssrcs_.end()) {
2656 unsignaled_recv_ssrcs_.erase(it); 2663 unsignaled_recv_ssrcs_.erase(it);
2657 return true; 2664 return true;
2658 } 2665 }
2659 return false; 2666 return false;
2660 } 2667 }
2661 } // namespace cricket 2668 } // namespace cricket
2662 2669
2663 #endif // HAVE_WEBRTC_VOICE 2670 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698