Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 static int MaxBitrateBps(const webrtc::CodecInst& codec) { | 392 static int MaxBitrateBps(const webrtc::CodecInst& codec) { |
| 393 for (size_t i = 0; i < arraysize(kCodecPrefs); ++i) { | 393 for (size_t i = 0; i < arraysize(kCodecPrefs); ++i) { |
| 394 if (IsCodec(codec, kCodecPrefs[i].name) && | 394 if (IsCodec(codec, kCodecPrefs[i].name) && |
| 395 kCodecPrefs[i].clockrate == codec.plfreq) { | 395 kCodecPrefs[i].clockrate == codec.plfreq) { |
| 396 return kCodecPrefs[i].max_bitrate_bps; | 396 return kCodecPrefs[i].max_bitrate_bps; |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 return 0; | 399 return 0; |
| 400 } | 400 } |
| 401 | 401 |
| 402 static rtc::ArrayView<const int> GetPacketSizesMs( | |
| 403 const webrtc::CodecInst& codec) { | |
| 404 for (size_t i = 0; i < arraysize(kCodecPrefs); ++i) { | |
| 405 if (IsCodec(codec, kCodecPrefs[i].name)) { | |
| 406 size_t num_packet_sizes = kMaxNumPacketSize; | |
| 407 for (int index = 0; index < kMaxNumPacketSize; index++) { | |
| 408 if (kCodecPrefs[i].packet_sizes_ms[index] == 0) { | |
| 409 num_packet_sizes = index; | |
| 410 break; | |
| 411 } | |
| 412 } | |
| 413 return rtc::ArrayView<const int>(kCodecPrefs[i].packet_sizes_ms, | |
| 414 num_packet_sizes); | |
| 415 } | |
| 416 } | |
| 417 return rtc::ArrayView<const int>(); | |
| 418 } | |
| 419 | |
| 402 // If the AudioCodec param kCodecParamPTime is set, then we will set it to | 420 // If the AudioCodec param kCodecParamPTime is set, then we will set it to |
| 403 // codec pacsize if it's valid, or we will pick the next smallest value we | 421 // codec pacsize if it's valid, or we will pick the next smallest value we |
| 404 // support. | 422 // support. |
| 405 // TODO(Brave): Query supported packet sizes from ACM when the API is ready. | 423 // TODO(Brave): Query supported packet sizes from ACM when the API is ready. |
| 406 static bool SetPTimeAsPacketSize(webrtc::CodecInst* codec, int ptime_ms) { | 424 static bool SetPTimeAsPacketSize(webrtc::CodecInst* codec, int ptime_ms) { |
| 407 for (const CodecPref& codec_pref : kCodecPrefs) { | 425 for (const CodecPref& codec_pref : kCodecPrefs) { |
| 408 if ((IsCodec(*codec, codec_pref.name) && | 426 if ((IsCodec(*codec, codec_pref.name) && |
| 409 codec_pref.clockrate == codec->plfreq) || | 427 codec_pref.clockrate == codec->plfreq) || |
| 410 IsCodec(*codec, kG722CodecName)) { | 428 IsCodec(*codec, kG722CodecName)) { |
| 411 int packet_size_ms = SelectPacketSize(codec_pref, ptime_ms); | 429 int packet_size_ms = SelectPacketSize(codec_pref, ptime_ms); |
| (...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1413 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1431 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1414 if (stream_) { | 1432 if (stream_) { |
| 1415 call_->DestroyAudioSendStream(stream_); | 1433 call_->DestroyAudioSendStream(stream_); |
| 1416 stream_ = nullptr; | 1434 stream_ = nullptr; |
| 1417 } | 1435 } |
| 1418 RTC_DCHECK(!stream_); | 1436 RTC_DCHECK(!stream_); |
| 1419 if (webrtc::field_trial::FindFullName("WebRTC-Audio-SendSideBwe") == | 1437 if (webrtc::field_trial::FindFullName("WebRTC-Audio-SendSideBwe") == |
| 1420 "Enabled") { | 1438 "Enabled") { |
| 1421 // TODO(mflodman): Keep testing this and set proper values. | 1439 // TODO(mflodman): Keep testing this and set proper values. |
| 1422 // Note: This is an early experiment currently only supported by Opus. | 1440 // Note: This is an early experiment currently only supported by Opus. |
| 1423 config_.min_bitrate_bps = kOpusMinBitrateBps; | 1441 if (webrtc::field_trial::FindFullName( |
| 1424 config_.max_bitrate_bps = kOpusBitrateFbBps; | 1442 "WebRTC-SendSideBwe-WithOverhead") == "Enabled") { |
| 1443 auto packet_sizes_ms = WebRtcVoiceCodecs::GetPacketSizesMs( | |
| 1444 config_.send_codec_spec.codec_inst); | |
| 1445 if (packet_sizes_ms.size() > 0) { | |
|
stefan-webrtc
2017/01/11 14:23:26
!packet_sizes_ms.empty() instead
michaelt
2017/01/11 15:30:51
Done.
| |
| 1446 int max_packet_size_ms = | |
| 1447 *std::max_element(packet_sizes_ms.begin(), packet_sizes_ms.end()); | |
| 1448 int min_packet_size_ms = | |
| 1449 *std::min_element(packet_sizes_ms.begin(), packet_sizes_ms.end()); | |
| 1450 | |
| 1451 if (config_.audio_network_adaptor_config && | |
| 1452 IsCodec(config_.send_codec_spec.codec_inst, kOpusCodecName)) { | |
|
stefan-webrtc
2017/01/11 14:23:26
I still think we should have a comment here. To so
michaelt
2017/01/11 15:30:51
Done.
| |
| 1453 max_packet_size_ms = 60; | |
| 1454 min_packet_size_ms = 20; | |
| 1455 } | |
| 1456 | |
| 1457 // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) | |
| 1458 constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12; | |
| 1459 | |
| 1460 int min_overhead_bps = | |
| 1461 kOverheadPerPacket * 8 * 1000 / max_packet_size_ms; | |
| 1462 | |
| 1463 int max_overhead_bps = | |
| 1464 kOverheadPerPacket * 8 * 1000 / min_packet_size_ms; | |
| 1465 | |
| 1466 config_.min_bitrate_bps = kOpusMinBitrateBps + min_overhead_bps; | |
| 1467 config_.max_bitrate_bps = kOpusBitrateFbBps + max_overhead_bps; | |
| 1468 } | |
| 1469 } else { | |
| 1470 config_.min_bitrate_bps = kOpusMinBitrateBps; | |
| 1471 config_.max_bitrate_bps = kOpusBitrateFbBps; | |
| 1472 } | |
| 1425 } | 1473 } |
| 1426 stream_ = call_->CreateAudioSendStream(config_); | 1474 stream_ = call_->CreateAudioSendStream(config_); |
| 1427 RTC_CHECK(stream_); | 1475 RTC_CHECK(stream_); |
| 1428 UpdateSendState(); | 1476 UpdateSendState(); |
| 1429 } | 1477 } |
| 1430 | 1478 |
| 1431 rtc::ThreadChecker worker_thread_checker_; | 1479 rtc::ThreadChecker worker_thread_checker_; |
| 1432 rtc::RaceChecker audio_capture_race_checker_; | 1480 rtc::RaceChecker audio_capture_race_checker_; |
| 1433 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; | 1481 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; |
| 1434 webrtc::Call* call_ = nullptr; | 1482 webrtc::Call* call_ = nullptr; |
| (...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2638 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2686 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 2639 const auto it = send_streams_.find(ssrc); | 2687 const auto it = send_streams_.find(ssrc); |
| 2640 if (it != send_streams_.end()) { | 2688 if (it != send_streams_.end()) { |
| 2641 return it->second->channel(); | 2689 return it->second->channel(); |
| 2642 } | 2690 } |
| 2643 return -1; | 2691 return -1; |
| 2644 } | 2692 } |
| 2645 } // namespace cricket | 2693 } // namespace cricket |
| 2646 | 2694 |
| 2647 #endif // HAVE_WEBRTC_VOICE | 2695 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |