Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 29 matching lines...) Expand all Loading... | |
| 40 #include "webrtc/system_wrappers/include/trace.h" | 40 #include "webrtc/system_wrappers/include/trace.h" |
| 41 #include "webrtc/video/call_stats.h" | 41 #include "webrtc/video/call_stats.h" |
| 42 #include "webrtc/video/video_receive_stream.h" | 42 #include "webrtc/video/video_receive_stream.h" |
| 43 #include "webrtc/video/video_send_stream.h" | 43 #include "webrtc/video/video_send_stream.h" |
| 44 #include "webrtc/video/vie_remb.h" | 44 #include "webrtc/video/vie_remb.h" |
| 45 #include "webrtc/voice_engine/include/voe_codec.h" | 45 #include "webrtc/voice_engine/include/voe_codec.h" |
| 46 | 46 |
| 47 namespace webrtc { | 47 namespace webrtc { |
| 48 | 48 |
| 49 const int Call::Config::kDefaultStartBitrateBps = 300000; | 49 const int Call::Config::kDefaultStartBitrateBps = 300000; |
| 50 // Indicates to the bandwidth estimator that there is no upper cap on the | |
| 51 // estimated bitrate. | |
| 52 static const int kBitrateUnlimited = -1; | |
| 50 | 53 |
| 51 namespace internal { | 54 namespace internal { |
| 52 | 55 |
| 53 class Call : public webrtc::Call, public PacketReceiver, | 56 class Call : public webrtc::Call, public PacketReceiver, |
| 54 public BitrateObserver { | 57 public BitrateObserver { |
| 55 public: | 58 public: |
| 56 explicit Call(const Call::Config& config); | 59 explicit Call(const Call::Config& config); |
| 57 virtual ~Call(); | 60 virtual ~Call(); |
| 58 | 61 |
| 59 PacketReceiver* Receiver() override; | 62 PacketReceiver* Receiver() override; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 first_packet_sent_ms_(-1), | 203 first_packet_sent_ms_(-1), |
| 201 estimated_send_bitrate_sum_kbits_(0), | 204 estimated_send_bitrate_sum_kbits_(0), |
| 202 pacer_bitrate_sum_kbits_(0), | 205 pacer_bitrate_sum_kbits_(0), |
| 203 num_bitrate_updates_(0), | 206 num_bitrate_updates_(0), |
| 204 remb_(clock_), | 207 remb_(clock_), |
| 205 congestion_controller_(new CongestionController(clock_, this, &remb_)) { | 208 congestion_controller_(new CongestionController(clock_, this, &remb_)) { |
| 206 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 209 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 207 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 210 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
| 208 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 211 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
| 209 config.bitrate_config.min_bitrate_bps); | 212 config.bitrate_config.min_bitrate_bps); |
| 210 if (config.bitrate_config.max_bitrate_bps != -1) { | 213 if (config.bitrate_config.max_bitrate_bps) { |
| 211 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 214 RTC_DCHECK_GT(*config.bitrate_config.max_bitrate_bps, 0); |
|
Taylor Brandstetter
2016/03/29 02:26:58
Is a max of 0 not allowed?
skvlad
2016/03/30 19:40:44
No. The bitrate limit must be positive or unset. T
| |
| 215 RTC_DCHECK_GE(*config.bitrate_config.max_bitrate_bps, | |
| 212 config.bitrate_config.start_bitrate_bps); | 216 config.bitrate_config.start_bitrate_bps); |
| 213 } | 217 } |
| 214 if (config.audio_state.get()) { | 218 if (config.audio_state.get()) { |
| 215 ScopedVoEInterface<VoECodec> voe_codec(voice_engine()); | 219 ScopedVoEInterface<VoECodec> voe_codec(voice_engine()); |
| 216 event_log_ = voe_codec->GetEventLog(); | 220 event_log_ = voe_codec->GetEventLog(); |
| 217 } | 221 } |
| 218 | 222 |
| 219 Trace::CreateTrace(); | 223 Trace::CreateTrace(); |
| 220 call_stats_->RegisterStatsObserver(congestion_controller_.get()); | 224 call_stats_->RegisterStatsObserver(congestion_controller_.get()); |
| 221 | 225 |
| 226 // The congestion controller uses -1 to represent unlimited bitrate. | |
| 227 // TODO(skvlad): Remove this conversion when congestion controller code | |
| 228 // is updated to use rtc::Optional. | |
| 229 int bwe_max_bitrate = | |
| 230 config_.bitrate_config.max_bitrate_bps.value_or(kBitrateUnlimited); | |
| 222 congestion_controller_->SetBweBitrates( | 231 congestion_controller_->SetBweBitrates( |
| 223 config_.bitrate_config.min_bitrate_bps, | 232 config_.bitrate_config.min_bitrate_bps, |
| 224 config_.bitrate_config.start_bitrate_bps, | 233 config_.bitrate_config.start_bitrate_bps, bwe_max_bitrate); |
| 225 config_.bitrate_config.max_bitrate_bps); | |
| 226 congestion_controller_->GetBitrateController()->SetEventLog(event_log_); | 234 congestion_controller_->GetBitrateController()->SetEventLog(event_log_); |
| 227 | 235 |
| 228 module_process_thread_->Start(); | 236 module_process_thread_->Start(); |
| 229 module_process_thread_->RegisterModule(call_stats_.get()); | 237 module_process_thread_->RegisterModule(call_stats_.get()); |
| 230 module_process_thread_->RegisterModule(congestion_controller_.get()); | 238 module_process_thread_->RegisterModule(congestion_controller_.get()); |
| 231 pacer_thread_->RegisterModule(congestion_controller_->pacer()); | 239 pacer_thread_->RegisterModule(congestion_controller_->pacer()); |
| 232 pacer_thread_->RegisterModule( | 240 pacer_thread_->RegisterModule( |
| 233 congestion_controller_->GetRemoteBitrateEstimator(true)); | 241 congestion_controller_->GetRemoteBitrateEstimator(true)); |
| 234 pacer_thread_->Start(); | 242 pacer_thread_->Start(); |
| 235 } | 243 } |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 stats.pacer_delay_ms = congestion_controller_->GetPacerQueuingDelayMs(); | 532 stats.pacer_delay_ms = congestion_controller_->GetPacerQueuingDelayMs(); |
| 525 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); | 533 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); |
| 526 return stats; | 534 return stats; |
| 527 } | 535 } |
| 528 | 536 |
| 529 void Call::SetBitrateConfig( | 537 void Call::SetBitrateConfig( |
| 530 const webrtc::Call::Config::BitrateConfig& bitrate_config) { | 538 const webrtc::Call::Config::BitrateConfig& bitrate_config) { |
| 531 TRACE_EVENT0("webrtc", "Call::SetBitrateConfig"); | 539 TRACE_EVENT0("webrtc", "Call::SetBitrateConfig"); |
| 532 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 540 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 533 RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0); | 541 RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0); |
| 534 if (bitrate_config.max_bitrate_bps != -1) | 542 if (bitrate_config.max_bitrate_bps) |
|
Taylor Brandstetter
2016/03/29 02:26:58
nit: as long as you're modifying this line, might
skvlad
2016/03/30 19:40:44
Done.
| |
| 535 RTC_DCHECK_GT(bitrate_config.max_bitrate_bps, 0); | 543 RTC_DCHECK_GT(*bitrate_config.max_bitrate_bps, 0); |
| 536 if (config_.bitrate_config.min_bitrate_bps == | 544 if (config_.bitrate_config.min_bitrate_bps == |
| 537 bitrate_config.min_bitrate_bps && | 545 bitrate_config.min_bitrate_bps && |
| 538 (bitrate_config.start_bitrate_bps <= 0 || | 546 (bitrate_config.start_bitrate_bps <= 0 || |
| 539 config_.bitrate_config.start_bitrate_bps == | 547 config_.bitrate_config.start_bitrate_bps == |
| 540 bitrate_config.start_bitrate_bps) && | 548 bitrate_config.start_bitrate_bps) && |
| 541 config_.bitrate_config.max_bitrate_bps == | 549 config_.bitrate_config.max_bitrate_bps == |
| 542 bitrate_config.max_bitrate_bps) { | 550 bitrate_config.max_bitrate_bps) { |
| 543 // Nothing new to set, early abort to avoid encoder reconfigurations. | 551 // Nothing new to set, early abort to avoid encoder reconfigurations. |
| 544 return; | 552 return; |
| 545 } | 553 } |
| 546 config_.bitrate_config = bitrate_config; | 554 config_.bitrate_config = bitrate_config; |
| 555 // The congestion controller uses -1 to represent unlimited bitrate. | |
| 556 // TODO(skvlad): Remove this conversion when congestion controller code | |
| 557 // is updated to use rtc::Optional. | |
| 558 int bwe_max_bitrate = | |
| 559 bitrate_config.max_bitrate_bps.value_or(kBitrateUnlimited); | |
| 547 congestion_controller_->SetBweBitrates(bitrate_config.min_bitrate_bps, | 560 congestion_controller_->SetBweBitrates(bitrate_config.min_bitrate_bps, |
| 548 bitrate_config.start_bitrate_bps, | 561 bitrate_config.start_bitrate_bps, |
| 549 bitrate_config.max_bitrate_bps); | 562 bwe_max_bitrate); |
| 550 } | 563 } |
| 551 | 564 |
| 552 void Call::SignalNetworkState(NetworkState state) { | 565 void Call::SignalNetworkState(NetworkState state) { |
| 553 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 566 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 554 network_enabled_ = state == kNetworkUp; | 567 network_enabled_ = state == kNetworkUp; |
| 555 congestion_controller_->SignalNetworkState(state); | 568 congestion_controller_->SignalNetworkState(state); |
| 556 { | 569 { |
| 557 ReadLockScoped write_lock(*send_crit_); | 570 ReadLockScoped write_lock(*send_crit_); |
| 558 for (auto& kv : audio_send_ssrcs_) { | 571 for (auto& kv : audio_send_ssrcs_) { |
| 559 kv.second->SignalNetworkState(state); | 572 kv.second->SignalNetworkState(state); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 // thread. Then this check can be enabled. | 758 // thread. Then this check can be enabled. |
| 746 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 759 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
| 747 if (RtpHeaderParser::IsRtcp(packet, length)) | 760 if (RtpHeaderParser::IsRtcp(packet, length)) |
| 748 return DeliverRtcp(media_type, packet, length); | 761 return DeliverRtcp(media_type, packet, length); |
| 749 | 762 |
| 750 return DeliverRtp(media_type, packet, length, packet_time); | 763 return DeliverRtp(media_type, packet, length, packet_time); |
| 751 } | 764 } |
| 752 | 765 |
| 753 } // namespace internal | 766 } // namespace internal |
| 754 } // namespace webrtc | 767 } // namespace webrtc |
| OLD | NEW |