| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 first_packet_sent_ms_(-1), | 207 first_packet_sent_ms_(-1), |
| 205 estimated_send_bitrate_sum_kbits_(0), | 208 estimated_send_bitrate_sum_kbits_(0), |
| 206 pacer_bitrate_sum_kbits_(0), | 209 pacer_bitrate_sum_kbits_(0), |
| 207 num_bitrate_updates_(0), | 210 num_bitrate_updates_(0), |
| 208 remb_(clock_), | 211 remb_(clock_), |
| 209 congestion_controller_(new CongestionController(clock_, this, &remb_)) { | 212 congestion_controller_(new CongestionController(clock_, this, &remb_)) { |
| 210 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 213 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 211 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 214 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
| 212 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 215 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
| 213 config.bitrate_config.min_bitrate_bps); | 216 config.bitrate_config.min_bitrate_bps); |
| 214 if (config.bitrate_config.max_bitrate_bps != -1) { | 217 if (config.bitrate_config.max_bitrate_bps) { |
| 215 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 218 RTC_DCHECK_GT(*config.bitrate_config.max_bitrate_bps, 0); |
| 219 RTC_DCHECK_GE(*config.bitrate_config.max_bitrate_bps, |
| 216 config.bitrate_config.start_bitrate_bps); | 220 config.bitrate_config.start_bitrate_bps); |
| 217 } | 221 } |
| 218 if (config.audio_state.get()) { | 222 if (config.audio_state.get()) { |
| 219 ScopedVoEInterface<VoECodec> voe_codec(voice_engine()); | 223 ScopedVoEInterface<VoECodec> voe_codec(voice_engine()); |
| 220 event_log_ = voe_codec->GetEventLog(); | 224 event_log_ = voe_codec->GetEventLog(); |
| 221 } | 225 } |
| 222 | 226 |
| 223 Trace::CreateTrace(); | 227 Trace::CreateTrace(); |
| 224 call_stats_->RegisterStatsObserver(congestion_controller_.get()); | 228 call_stats_->RegisterStatsObserver(congestion_controller_.get()); |
| 225 | 229 |
| 230 // The congestion controller uses -1 to represent unlimited bitrate. |
| 231 // TODO(skvlad): Remove this conversion when congestion controller code |
| 232 // is updated to use rtc::Optional. |
| 233 int bwe_max_bitrate = |
| 234 config_.bitrate_config.max_bitrate_bps.value_or(kBitrateUnlimited); |
| 226 congestion_controller_->SetBweBitrates( | 235 congestion_controller_->SetBweBitrates( |
| 227 config_.bitrate_config.min_bitrate_bps, | 236 config_.bitrate_config.min_bitrate_bps, |
| 228 config_.bitrate_config.start_bitrate_bps, | 237 config_.bitrate_config.start_bitrate_bps, bwe_max_bitrate); |
| 229 config_.bitrate_config.max_bitrate_bps); | |
| 230 congestion_controller_->GetBitrateController()->SetEventLog(event_log_); | 238 congestion_controller_->GetBitrateController()->SetEventLog(event_log_); |
| 231 | 239 |
| 232 module_process_thread_->Start(); | 240 module_process_thread_->Start(); |
| 233 module_process_thread_->RegisterModule(call_stats_.get()); | 241 module_process_thread_->RegisterModule(call_stats_.get()); |
| 234 module_process_thread_->RegisterModule(congestion_controller_.get()); | 242 module_process_thread_->RegisterModule(congestion_controller_.get()); |
| 235 pacer_thread_->RegisterModule(congestion_controller_->pacer()); | 243 pacer_thread_->RegisterModule(congestion_controller_->pacer()); |
| 236 pacer_thread_->RegisterModule( | 244 pacer_thread_->RegisterModule( |
| 237 congestion_controller_->GetRemoteBitrateEstimator(true)); | 245 congestion_controller_->GetRemoteBitrateEstimator(true)); |
| 238 pacer_thread_->Start(); | 246 pacer_thread_->Start(); |
| 239 } | 247 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 stats.pacer_delay_ms = congestion_controller_->GetPacerQueuingDelayMs(); | 538 stats.pacer_delay_ms = congestion_controller_->GetPacerQueuingDelayMs(); |
| 531 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); | 539 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); |
| 532 return stats; | 540 return stats; |
| 533 } | 541 } |
| 534 | 542 |
| 535 void Call::SetBitrateConfig( | 543 void Call::SetBitrateConfig( |
| 536 const webrtc::Call::Config::BitrateConfig& bitrate_config) { | 544 const webrtc::Call::Config::BitrateConfig& bitrate_config) { |
| 537 TRACE_EVENT0("webrtc", "Call::SetBitrateConfig"); | 545 TRACE_EVENT0("webrtc", "Call::SetBitrateConfig"); |
| 538 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 546 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 539 RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0); | 547 RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0); |
| 540 if (bitrate_config.max_bitrate_bps != -1) | 548 if (bitrate_config.max_bitrate_bps) { |
| 541 RTC_DCHECK_GT(bitrate_config.max_bitrate_bps, 0); | 549 RTC_DCHECK_GT(*bitrate_config.max_bitrate_bps, 0); |
| 550 } |
| 542 if (config_.bitrate_config.min_bitrate_bps == | 551 if (config_.bitrate_config.min_bitrate_bps == |
| 543 bitrate_config.min_bitrate_bps && | 552 bitrate_config.min_bitrate_bps && |
| 544 (bitrate_config.start_bitrate_bps <= 0 || | 553 (bitrate_config.start_bitrate_bps <= 0 || |
| 545 config_.bitrate_config.start_bitrate_bps == | 554 config_.bitrate_config.start_bitrate_bps == |
| 546 bitrate_config.start_bitrate_bps) && | 555 bitrate_config.start_bitrate_bps) && |
| 547 config_.bitrate_config.max_bitrate_bps == | 556 config_.bitrate_config.max_bitrate_bps == |
| 548 bitrate_config.max_bitrate_bps) { | 557 bitrate_config.max_bitrate_bps) { |
| 549 // Nothing new to set, early abort to avoid encoder reconfigurations. | 558 // Nothing new to set, early abort to avoid encoder reconfigurations. |
| 550 return; | 559 return; |
| 551 } | 560 } |
| 552 config_.bitrate_config = bitrate_config; | 561 config_.bitrate_config = bitrate_config; |
| 562 // The congestion controller uses -1 to represent unlimited bitrate. |
| 563 // TODO(skvlad): Remove this conversion when congestion controller code |
| 564 // is updated to use rtc::Optional. |
| 565 int bwe_max_bitrate = |
| 566 bitrate_config.max_bitrate_bps.value_or(kBitrateUnlimited); |
| 553 congestion_controller_->SetBweBitrates(bitrate_config.min_bitrate_bps, | 567 congestion_controller_->SetBweBitrates(bitrate_config.min_bitrate_bps, |
| 554 bitrate_config.start_bitrate_bps, | 568 bitrate_config.start_bitrate_bps, |
| 555 bitrate_config.max_bitrate_bps); | 569 bwe_max_bitrate); |
| 556 } | 570 } |
| 557 | 571 |
| 558 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { | 572 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { |
| 559 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 573 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 560 switch (media) { | 574 switch (media) { |
| 561 case MediaType::AUDIO: | 575 case MediaType::AUDIO: |
| 562 audio_network_state_ = state; | 576 audio_network_state_ = state; |
| 563 break; | 577 break; |
| 564 case MediaType::VIDEO: | 578 case MediaType::VIDEO: |
| 565 video_network_state_ = state; | 579 video_network_state_ = state; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 // thread. Then this check can be enabled. | 812 // thread. Then this check can be enabled. |
| 799 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 813 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
| 800 if (RtpHeaderParser::IsRtcp(packet, length)) | 814 if (RtpHeaderParser::IsRtcp(packet, length)) |
| 801 return DeliverRtcp(media_type, packet, length); | 815 return DeliverRtcp(media_type, packet, length); |
| 802 | 816 |
| 803 return DeliverRtp(media_type, packet, length, packet_time); | 817 return DeliverRtp(media_type, packet, length, packet_time); |
| 804 } | 818 } |
| 805 | 819 |
| 806 } // namespace internal | 820 } // namespace internal |
| 807 } // namespace webrtc | 821 } // namespace webrtc |
| OLD | NEW |