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 14 matching lines...) Expand all Loading... | |
| 25 #include "webrtc/base/constructormagic.h" | 25 #include "webrtc/base/constructormagic.h" |
| 26 #include "webrtc/base/logging.h" | 26 #include "webrtc/base/logging.h" |
| 27 #include "webrtc/base/optional.h" | 27 #include "webrtc/base/optional.h" |
| 28 #include "webrtc/base/task_queue.h" | 28 #include "webrtc/base/task_queue.h" |
| 29 #include "webrtc/base/thread_annotations.h" | 29 #include "webrtc/base/thread_annotations.h" |
| 30 #include "webrtc/base/thread_checker.h" | 30 #include "webrtc/base/thread_checker.h" |
| 31 #include "webrtc/base/trace_event.h" | 31 #include "webrtc/base/trace_event.h" |
| 32 #include "webrtc/call/bitrate_allocator.h" | 32 #include "webrtc/call/bitrate_allocator.h" |
| 33 #include "webrtc/call/call.h" | 33 #include "webrtc/call/call.h" |
| 34 #include "webrtc/call/flexfec_receive_stream_impl.h" | 34 #include "webrtc/call/flexfec_receive_stream_impl.h" |
| 35 #include "webrtc/call/rtp_transport_controller.h" | |
| 35 #include "webrtc/config.h" | 36 #include "webrtc/config.h" |
| 36 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 37 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 37 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 38 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 38 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 39 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
| 39 #include "webrtc/modules/pacing/paced_sender.h" | 40 #include "webrtc/modules/pacing/paced_sender.h" |
| 40 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" | 41 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" |
| 41 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 42 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
| 42 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 43 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 43 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | 44 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
| 44 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | 45 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 bool UseSendSideBwe(const AudioReceiveStream::Config& config) { | 82 bool UseSendSideBwe(const AudioReceiveStream::Config& config) { |
| 82 return UseSendSideBwe(config.rtp.extensions, config.rtp.transport_cc); | 83 return UseSendSideBwe(config.rtp.extensions, config.rtp.transport_cc); |
| 83 } | 84 } |
| 84 | 85 |
| 85 bool UseSendSideBwe(const FlexfecReceiveStream::Config& config) { | 86 bool UseSendSideBwe(const FlexfecReceiveStream::Config& config) { |
| 86 return UseSendSideBwe(config.rtp_header_extensions, config.transport_cc); | 87 return UseSendSideBwe(config.rtp_header_extensions, config.transport_cc); |
| 87 } | 88 } |
| 88 | 89 |
| 89 } // namespace | 90 } // namespace |
| 90 | 91 |
| 91 namespace internal { | 92 namespace internal { |
|
danilchap
2017/02/09 09:04:04
just merge this with unnamed namespace.
namespace
| |
| 92 | 93 |
| 94 class RtpTransportController : public RtpTransportControllerSenderInterface { | |
| 95 public: | |
| 96 void InitCongestionControl(CongestionController::Observer* observer); | |
| 97 VieRemb* remb() override { return &remb_; } | |
| 98 PacketRouter* packet_router() override { return &packet_router_; } | |
| 99 CongestionController* congestion_controller() override { | |
| 100 return congestion_controller_.get(); | |
| 101 } | |
| 102 static std::unique_ptr<RtpTransportController> Create( | |
|
danilchap
2017/02/09 09:04:04
why have an extra Create method?
This class alread
nisse-webrtc
2017/02/09 12:56:43
Only to conveniently get a unique_ptr.
| |
| 103 Clock* clock, | |
| 104 webrtc::RtcEventLog* event_log); | |
| 105 | |
| 106 private: | |
| 107 RtpTransportController(Clock* clock, webrtc::RtcEventLog* event_log); | |
| 108 | |
| 109 Clock* const clock_; | |
| 110 webrtc::RtcEventLog* const event_log_; | |
| 111 VieRemb remb_; | |
| 112 PacketRouter packet_router_; | |
| 113 // Construction delayed until InitCongestionControl, since the | |
| 114 // CongestionController wants its observer as a construction time | |
| 115 // argument, and setting it later seems no-trivial. | |
| 116 std::unique_ptr<CongestionController> congestion_controller_; | |
| 117 }; | |
| 118 | |
| 119 RtpTransportController::RtpTransportController(Clock* clock, | |
| 120 webrtc::RtcEventLog* event_log) | |
| 121 : clock_(clock), event_log_(event_log), remb_(clock) {} | |
| 122 | |
| 123 // static | |
| 124 std::unique_ptr<RtpTransportController> RtpTransportController::Create( | |
| 125 Clock* clock, | |
| 126 webrtc::RtcEventLog* event_log) { | |
| 127 return std::unique_ptr<RtpTransportController>( | |
| 128 new RtpTransportController(clock, event_log)); | |
| 129 } | |
| 130 | |
| 131 void RtpTransportController::InitCongestionControl( | |
| 132 CongestionController::Observer* observer) { | |
| 133 // Must be called only once. | |
| 134 RTC_CHECK(!congestion_controller_); | |
| 135 congestion_controller_.reset(new CongestionController( | |
| 136 clock_, observer, &remb_, event_log_, &packet_router_)); | |
| 137 } | |
| 138 | |
| 93 class Call : public webrtc::Call, | 139 class Call : public webrtc::Call, |
| 94 public PacketReceiver, | 140 public PacketReceiver, |
| 95 public RecoveredPacketReceiver, | 141 public RecoveredPacketReceiver, |
| 96 public CongestionController::Observer, | 142 public CongestionController::Observer, |
| 97 public BitrateAllocator::LimitObserver { | 143 public BitrateAllocator::LimitObserver { |
| 98 public: | 144 public: |
| 99 explicit Call(const Call::Config& config); | 145 Call(const Call::Config& config, |
| 146 std::unique_ptr<RtpTransportController> transport); | |
| 100 virtual ~Call(); | 147 virtual ~Call(); |
| 101 | 148 |
| 102 // Implements webrtc::Call. | 149 // Implements webrtc::Call. |
| 103 PacketReceiver* Receiver() override; | 150 PacketReceiver* Receiver() override; |
| 104 | 151 |
| 105 webrtc::AudioSendStream* CreateAudioSendStream( | 152 webrtc::AudioSendStream* CreateAudioSendStream( |
| 106 const webrtc::AudioSendStream::Config& config) override; | 153 const webrtc::AudioSendStream::Config& config) override; |
| 107 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override; | 154 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override; |
| 108 | 155 |
| 109 webrtc::AudioReceiveStream* CreateAudioReceiveStream( | 156 webrtc::AudioReceiveStream* CreateAudioReceiveStream( |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 // TODO(holmer): Remove this lock once BitrateController no longer calls | 310 // TODO(holmer): Remove this lock once BitrateController no longer calls |
| 264 // OnNetworkChanged from multiple threads. | 311 // OnNetworkChanged from multiple threads. |
| 265 rtc::CriticalSection bitrate_crit_; | 312 rtc::CriticalSection bitrate_crit_; |
| 266 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); | 313 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); |
| 267 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); | 314 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); |
| 268 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); | 315 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); |
| 269 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); | 316 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); |
| 270 | 317 |
| 271 std::map<std::string, rtc::NetworkRoute> network_routes_; | 318 std::map<std::string, rtc::NetworkRoute> network_routes_; |
| 272 | 319 |
| 273 VieRemb remb_; | 320 std::unique_ptr<RtpTransportControllerSenderInterface> transport_; |
| 274 PacketRouter packet_router_; | |
| 275 // TODO(nisse): Could be a direct member, except for constness | |
| 276 // issues with GetRemoteBitrateEstimator (and maybe others). | |
| 277 const std::unique_ptr<CongestionController> congestion_controller_; | |
| 278 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; | 321 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; |
| 279 const int64_t start_ms_; | 322 const int64_t start_ms_; |
| 280 // TODO(perkj): |worker_queue_| is supposed to replace | 323 // TODO(perkj): |worker_queue_| is supposed to replace |
| 281 // |module_process_thread_|. | 324 // |module_process_thread_|. |
| 282 // |worker_queue| is defined last to ensure all pending tasks are cancelled | 325 // |worker_queue| is defined last to ensure all pending tasks are cancelled |
| 283 // and deleted before any other members. | 326 // and deleted before any other members. |
| 284 rtc::TaskQueue worker_queue_; | 327 rtc::TaskQueue worker_queue_; |
| 285 | 328 |
| 286 RTC_DISALLOW_COPY_AND_ASSIGN(Call); | 329 RTC_DISALLOW_COPY_AND_ASSIGN(Call); |
| 287 }; | 330 }; |
| 288 } // namespace internal | 331 } // namespace internal |
| 289 | 332 |
| 290 std::string Call::Stats::ToString(int64_t time_ms) const { | 333 std::string Call::Stats::ToString(int64_t time_ms) const { |
| 291 std::stringstream ss; | 334 std::stringstream ss; |
| 292 ss << "Call stats: " << time_ms << ", {"; | 335 ss << "Call stats: " << time_ms << ", {"; |
| 293 ss << "send_bw_bps: " << send_bandwidth_bps << ", "; | 336 ss << "send_bw_bps: " << send_bandwidth_bps << ", "; |
| 294 ss << "recv_bw_bps: " << recv_bandwidth_bps << ", "; | 337 ss << "recv_bw_bps: " << recv_bandwidth_bps << ", "; |
| 295 ss << "max_pad_bps: " << max_padding_bitrate_bps << ", "; | 338 ss << "max_pad_bps: " << max_padding_bitrate_bps << ", "; |
| 296 ss << "pacer_delay_ms: " << pacer_delay_ms << ", "; | 339 ss << "pacer_delay_ms: " << pacer_delay_ms << ", "; |
| 297 ss << "rtt_ms: " << rtt_ms; | 340 ss << "rtt_ms: " << rtt_ms; |
| 298 ss << '}'; | 341 ss << '}'; |
| 299 return ss.str(); | 342 return ss.str(); |
| 300 } | 343 } |
| 301 | 344 |
| 302 Call* Call::Create(const Call::Config& config) { | 345 Call* Call::Create(const Call::Config& config) { |
| 303 return new internal::Call(config); | 346 return new internal::Call(config, |
| 347 internal::RtpTransportController::Create( | |
| 348 Clock::GetRealTimeClock(), config.event_log)); | |
| 304 } | 349 } |
| 305 | 350 |
| 306 namespace internal { | 351 namespace internal { |
| 307 | 352 |
| 308 Call::Call(const Call::Config& config) | 353 Call::Call(const Call::Config& config, |
| 354 std::unique_ptr<RtpTransportController> transport) | |
| 309 : clock_(Clock::GetRealTimeClock()), | 355 : clock_(Clock::GetRealTimeClock()), |
| 310 num_cpu_cores_(CpuInfo::DetectNumberOfCores()), | 356 num_cpu_cores_(CpuInfo::DetectNumberOfCores()), |
| 311 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), | 357 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), |
| 312 pacer_thread_(ProcessThread::Create("PacerThread")), | 358 pacer_thread_(ProcessThread::Create("PacerThread")), |
| 313 call_stats_(new CallStats(clock_)), | 359 call_stats_(new CallStats(clock_)), |
| 314 bitrate_allocator_(new BitrateAllocator(this)), | 360 bitrate_allocator_(new BitrateAllocator(this)), |
| 315 config_(config), | 361 config_(config), |
| 316 audio_network_state_(kNetworkDown), | 362 audio_network_state_(kNetworkDown), |
| 317 video_network_state_(kNetworkDown), | 363 video_network_state_(kNetworkDown), |
| 318 receive_crit_(RWLockWrapper::CreateRWLock()), | 364 receive_crit_(RWLockWrapper::CreateRWLock()), |
| 319 send_crit_(RWLockWrapper::CreateRWLock()), | 365 send_crit_(RWLockWrapper::CreateRWLock()), |
| 320 event_log_(config.event_log), | 366 event_log_(config.event_log), |
| 321 first_packet_sent_ms_(-1), | 367 first_packet_sent_ms_(-1), |
| 322 received_bytes_per_second_counter_(clock_, nullptr, true), | 368 received_bytes_per_second_counter_(clock_, nullptr, true), |
| 323 received_audio_bytes_per_second_counter_(clock_, nullptr, true), | 369 received_audio_bytes_per_second_counter_(clock_, nullptr, true), |
| 324 received_video_bytes_per_second_counter_(clock_, nullptr, true), | 370 received_video_bytes_per_second_counter_(clock_, nullptr, true), |
| 325 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), | 371 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), |
| 326 min_allocated_send_bitrate_bps_(0), | 372 min_allocated_send_bitrate_bps_(0), |
| 327 configured_max_padding_bitrate_bps_(0), | 373 configured_max_padding_bitrate_bps_(0), |
| 328 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), | 374 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), |
| 329 pacer_bitrate_kbps_counter_(clock_, nullptr, true), | 375 pacer_bitrate_kbps_counter_(clock_, nullptr, true), |
| 330 remb_(clock_), | 376 transport_(std::move(transport)), |
| 331 congestion_controller_(new CongestionController(clock_, | |
| 332 this, | |
| 333 &remb_, | |
| 334 event_log_, | |
| 335 &packet_router_)), | |
| 336 video_send_delay_stats_(new SendDelayStats(clock_)), | 377 video_send_delay_stats_(new SendDelayStats(clock_)), |
| 337 start_ms_(clock_->TimeInMilliseconds()), | 378 start_ms_(clock_->TimeInMilliseconds()), |
| 338 worker_queue_("call_worker_queue") { | 379 worker_queue_("call_worker_queue") { |
| 339 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 380 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 340 RTC_DCHECK(config.event_log != nullptr); | 381 RTC_DCHECK(config.event_log != nullptr); |
| 341 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 382 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
| 342 RTC_DCHECK_GT(config.bitrate_config.start_bitrate_bps, | 383 RTC_DCHECK_GT(config.bitrate_config.start_bitrate_bps, |
| 343 config.bitrate_config.min_bitrate_bps); | 384 config.bitrate_config.min_bitrate_bps); |
| 344 if (config.bitrate_config.max_bitrate_bps != -1) { | 385 if (config.bitrate_config.max_bitrate_bps != -1) { |
| 345 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 386 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
| 346 config.bitrate_config.start_bitrate_bps); | 387 config.bitrate_config.start_bitrate_bps); |
| 347 } | 388 } |
| 348 Trace::CreateTrace(); | 389 Trace::CreateTrace(); |
| 349 call_stats_->RegisterStatsObserver(congestion_controller_.get()); | 390 call_stats_->RegisterStatsObserver(transport_->congestion_controller()); |
| 350 | 391 transport->InitCongestionControl(this); |
| 351 congestion_controller_->SignalNetworkState(kNetworkDown); | 392 transport->congestion_controller()->SignalNetworkState(kNetworkDown); |
| 352 congestion_controller_->SetBweBitrates( | 393 transport->congestion_controller()->SetBweBitrates( |
| 353 config_.bitrate_config.min_bitrate_bps, | 394 config_.bitrate_config.min_bitrate_bps, |
| 354 config_.bitrate_config.start_bitrate_bps, | 395 config_.bitrate_config.start_bitrate_bps, |
| 355 config_.bitrate_config.max_bitrate_bps); | 396 config_.bitrate_config.max_bitrate_bps); |
| 356 | 397 |
| 357 module_process_thread_->Start(); | 398 module_process_thread_->Start(); |
| 358 module_process_thread_->RegisterModule(call_stats_.get()); | 399 module_process_thread_->RegisterModule(call_stats_.get()); |
| 359 module_process_thread_->RegisterModule(congestion_controller_.get()); | 400 module_process_thread_->RegisterModule(transport_->congestion_controller()); |
| 360 pacer_thread_->RegisterModule(congestion_controller_->pacer()); | 401 pacer_thread_->RegisterModule(transport_->congestion_controller()->pacer()); |
| 361 pacer_thread_->RegisterModule( | 402 pacer_thread_->RegisterModule( |
| 362 congestion_controller_->GetRemoteBitrateEstimator(true)); | 403 transport_->congestion_controller()->GetRemoteBitrateEstimator(true)); |
| 363 pacer_thread_->Start(); | 404 pacer_thread_->Start(); |
| 364 } | 405 } |
| 365 | 406 |
| 366 Call::~Call() { | 407 Call::~Call() { |
| 367 RTC_DCHECK(!remb_.InUse()); | 408 RTC_DCHECK(!transport_->remb()->InUse()); |
| 368 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 409 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 369 | 410 |
| 370 RTC_CHECK(audio_send_ssrcs_.empty()); | 411 RTC_CHECK(audio_send_ssrcs_.empty()); |
| 371 RTC_CHECK(video_send_ssrcs_.empty()); | 412 RTC_CHECK(video_send_ssrcs_.empty()); |
| 372 RTC_CHECK(video_send_streams_.empty()); | 413 RTC_CHECK(video_send_streams_.empty()); |
| 373 RTC_CHECK(audio_receive_ssrcs_.empty()); | 414 RTC_CHECK(audio_receive_ssrcs_.empty()); |
| 374 RTC_CHECK(video_receive_ssrcs_.empty()); | 415 RTC_CHECK(video_receive_ssrcs_.empty()); |
| 375 RTC_CHECK(video_receive_streams_.empty()); | 416 RTC_CHECK(video_receive_streams_.empty()); |
| 376 | 417 |
| 377 pacer_thread_->Stop(); | 418 pacer_thread_->Stop(); |
| 378 pacer_thread_->DeRegisterModule(congestion_controller_->pacer()); | 419 pacer_thread_->DeRegisterModule(transport_->congestion_controller()->pacer()); |
| 379 pacer_thread_->DeRegisterModule( | 420 pacer_thread_->DeRegisterModule( |
| 380 congestion_controller_->GetRemoteBitrateEstimator(true)); | 421 transport_->congestion_controller()->GetRemoteBitrateEstimator(true)); |
| 381 module_process_thread_->DeRegisterModule(congestion_controller_.get()); | 422 module_process_thread_->DeRegisterModule(transport_->congestion_controller()); |
| 382 module_process_thread_->DeRegisterModule(call_stats_.get()); | 423 module_process_thread_->DeRegisterModule(call_stats_.get()); |
| 383 module_process_thread_->Stop(); | 424 module_process_thread_->Stop(); |
| 384 call_stats_->DeregisterStatsObserver(congestion_controller_.get()); | 425 call_stats_->DeregisterStatsObserver(transport_->congestion_controller()); |
| 385 | 426 |
| 386 // Only update histograms after process threads have been shut down, so that | 427 // Only update histograms after process threads have been shut down, so that |
| 387 // they won't try to concurrently update stats. | 428 // they won't try to concurrently update stats. |
| 388 { | 429 { |
| 389 rtc::CritScope lock(&bitrate_crit_); | 430 rtc::CritScope lock(&bitrate_crit_); |
| 390 UpdateSendHistograms(); | 431 UpdateSendHistograms(); |
| 391 } | 432 } |
| 392 UpdateReceiveHistograms(); | 433 UpdateReceiveHistograms(); |
| 393 UpdateHistograms(); | 434 UpdateHistograms(); |
| 394 | 435 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 533 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 493 return this; | 534 return this; |
| 494 } | 535 } |
| 495 | 536 |
| 496 webrtc::AudioSendStream* Call::CreateAudioSendStream( | 537 webrtc::AudioSendStream* Call::CreateAudioSendStream( |
| 497 const webrtc::AudioSendStream::Config& config) { | 538 const webrtc::AudioSendStream::Config& config) { |
| 498 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); | 539 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); |
| 499 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 540 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 500 event_log_->LogAudioSendStreamConfig(config); | 541 event_log_->LogAudioSendStreamConfig(config); |
| 501 AudioSendStream* send_stream = new AudioSendStream( | 542 AudioSendStream* send_stream = new AudioSendStream( |
| 502 config, config_.audio_state, &worker_queue_, &packet_router_, | 543 config, config_.audio_state, &worker_queue_, transport_.get(), |
| 503 congestion_controller_.get(), bitrate_allocator_.get(), event_log_, | 544 bitrate_allocator_.get(), event_log_, call_stats_->rtcp_rtt_stats()); |
| 504 call_stats_->rtcp_rtt_stats()); | |
| 505 { | 545 { |
| 506 WriteLockScoped write_lock(*send_crit_); | 546 WriteLockScoped write_lock(*send_crit_); |
| 507 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == | 547 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == |
| 508 audio_send_ssrcs_.end()); | 548 audio_send_ssrcs_.end()); |
| 509 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; | 549 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; |
| 510 } | 550 } |
| 511 { | 551 { |
| 512 ReadLockScoped read_lock(*receive_crit_); | 552 ReadLockScoped read_lock(*receive_crit_); |
| 513 for (const auto& kv : audio_receive_ssrcs_) { | 553 for (const auto& kv : audio_receive_ssrcs_) { |
| 514 if (kv.second->config().rtp.local_ssrc == config.rtp.ssrc) { | 554 if (kv.second->config().rtp.local_ssrc == config.rtp.ssrc) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 UpdateAggregateNetworkState(); | 587 UpdateAggregateNetworkState(); |
| 548 delete audio_send_stream; | 588 delete audio_send_stream; |
| 549 } | 589 } |
| 550 | 590 |
| 551 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 591 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
| 552 const webrtc::AudioReceiveStream::Config& config) { | 592 const webrtc::AudioReceiveStream::Config& config) { |
| 553 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 593 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
| 554 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 594 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 555 event_log_->LogAudioReceiveStreamConfig(config); | 595 event_log_->LogAudioReceiveStreamConfig(config); |
| 556 AudioReceiveStream* receive_stream = new AudioReceiveStream( | 596 AudioReceiveStream* receive_stream = new AudioReceiveStream( |
| 557 &packet_router_, config, | 597 transport_->packet_router(), config, config_.audio_state, event_log_); |
| 558 config_.audio_state, event_log_); | |
| 559 { | 598 { |
| 560 WriteLockScoped write_lock(*receive_crit_); | 599 WriteLockScoped write_lock(*receive_crit_); |
| 561 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 600 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
| 562 audio_receive_ssrcs_.end()); | 601 audio_receive_ssrcs_.end()); |
| 563 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 602 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
| 564 receive_rtp_config_[config.rtp.remote_ssrc] = | 603 receive_rtp_config_[config.rtp.remote_ssrc] = |
| 565 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config)); | 604 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config)); |
| 566 | 605 |
| 567 ConfigureSync(config.sync_group); | 606 ConfigureSync(config.sync_group); |
| 568 } | 607 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 582 webrtc::AudioReceiveStream* receive_stream) { | 621 webrtc::AudioReceiveStream* receive_stream) { |
| 583 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); | 622 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); |
| 584 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 623 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 585 RTC_DCHECK(receive_stream != nullptr); | 624 RTC_DCHECK(receive_stream != nullptr); |
| 586 webrtc::internal::AudioReceiveStream* audio_receive_stream = | 625 webrtc::internal::AudioReceiveStream* audio_receive_stream = |
| 587 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); | 626 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); |
| 588 { | 627 { |
| 589 WriteLockScoped write_lock(*receive_crit_); | 628 WriteLockScoped write_lock(*receive_crit_); |
| 590 const AudioReceiveStream::Config& config = audio_receive_stream->config(); | 629 const AudioReceiveStream::Config& config = audio_receive_stream->config(); |
| 591 uint32_t ssrc = config.rtp.remote_ssrc; | 630 uint32_t ssrc = config.rtp.remote_ssrc; |
| 592 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 631 transport_->congestion_controller() |
| 632 ->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | |
| 593 ->RemoveStream(ssrc); | 633 ->RemoveStream(ssrc); |
| 594 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); | 634 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); |
| 595 RTC_DCHECK(num_deleted == 1); | 635 RTC_DCHECK(num_deleted == 1); |
| 596 const std::string& sync_group = audio_receive_stream->config().sync_group; | 636 const std::string& sync_group = audio_receive_stream->config().sync_group; |
| 597 const auto it = sync_stream_mapping_.find(sync_group); | 637 const auto it = sync_stream_mapping_.find(sync_group); |
| 598 if (it != sync_stream_mapping_.end() && | 638 if (it != sync_stream_mapping_.end() && |
| 599 it->second == audio_receive_stream) { | 639 it->second == audio_receive_stream) { |
| 600 sync_stream_mapping_.erase(it); | 640 sync_stream_mapping_.erase(it); |
| 601 ConfigureSync(sync_group); | 641 ConfigureSync(sync_group); |
| 602 } | 642 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 614 | 654 |
| 615 video_send_delay_stats_->AddSsrcs(config); | 655 video_send_delay_stats_->AddSsrcs(config); |
| 616 event_log_->LogVideoSendStreamConfig(config); | 656 event_log_->LogVideoSendStreamConfig(config); |
| 617 | 657 |
| 618 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if | 658 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if |
| 619 // the call has already started. | 659 // the call has already started. |
| 620 // Copy ssrcs from |config| since |config| is moved. | 660 // Copy ssrcs from |config| since |config| is moved. |
| 621 std::vector<uint32_t> ssrcs = config.rtp.ssrcs; | 661 std::vector<uint32_t> ssrcs = config.rtp.ssrcs; |
| 622 VideoSendStream* send_stream = new VideoSendStream( | 662 VideoSendStream* send_stream = new VideoSendStream( |
| 623 num_cpu_cores_, module_process_thread_.get(), &worker_queue_, | 663 num_cpu_cores_, module_process_thread_.get(), &worker_queue_, |
| 624 call_stats_.get(), congestion_controller_.get(), &packet_router_, | 664 call_stats_.get(), transport_.get(), bitrate_allocator_.get(), |
| 625 bitrate_allocator_.get(), video_send_delay_stats_.get(), &remb_, | 665 video_send_delay_stats_.get(), event_log_, std::move(config), |
| 626 event_log_, std::move(config), std::move(encoder_config), | 666 std::move(encoder_config), suspended_video_send_ssrcs_); |
| 627 suspended_video_send_ssrcs_); | |
| 628 | 667 |
| 629 { | 668 { |
| 630 WriteLockScoped write_lock(*send_crit_); | 669 WriteLockScoped write_lock(*send_crit_); |
| 631 for (uint32_t ssrc : ssrcs) { | 670 for (uint32_t ssrc : ssrcs) { |
| 632 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 671 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
| 633 video_send_ssrcs_[ssrc] = send_stream; | 672 video_send_ssrcs_[ssrc] = send_stream; |
| 634 } | 673 } |
| 635 video_send_streams_.insert(send_stream); | 674 video_send_streams_.insert(send_stream); |
| 636 } | 675 } |
| 637 send_stream->SignalNetworkState(video_network_state_); | 676 send_stream->SignalNetworkState(video_network_state_); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 720 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 682 | 721 |
| 683 bool protected_by_flexfec = false; | 722 bool protected_by_flexfec = false; |
| 684 { | 723 { |
| 685 ReadLockScoped read_lock(*receive_crit_); | 724 ReadLockScoped read_lock(*receive_crit_); |
| 686 protected_by_flexfec = | 725 protected_by_flexfec = |
| 687 flexfec_receive_ssrcs_media_.find(configuration.rtp.remote_ssrc) != | 726 flexfec_receive_ssrcs_media_.find(configuration.rtp.remote_ssrc) != |
| 688 flexfec_receive_ssrcs_media_.end(); | 727 flexfec_receive_ssrcs_media_.end(); |
| 689 } | 728 } |
| 690 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 729 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
| 691 num_cpu_cores_, protected_by_flexfec, | 730 num_cpu_cores_, protected_by_flexfec, transport_->packet_router(), |
| 692 &packet_router_, std::move(configuration), module_process_thread_.get(), | 731 std::move(configuration), module_process_thread_.get(), call_stats_.get(), |
| 693 call_stats_.get(), &remb_); | 732 transport_->remb()); |
| 694 | 733 |
| 695 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 734 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
| 696 ReceiveRtpConfig receive_config(config.rtp.extensions, | 735 ReceiveRtpConfig receive_config(config.rtp.extensions, |
| 697 UseSendSideBwe(config)); | 736 UseSendSideBwe(config)); |
| 698 { | 737 { |
| 699 WriteLockScoped write_lock(*receive_crit_); | 738 WriteLockScoped write_lock(*receive_crit_); |
| 700 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 739 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
| 701 video_receive_ssrcs_.end()); | 740 video_receive_ssrcs_.end()); |
| 702 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 741 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
| 703 if (config.rtp.rtx_ssrc) { | 742 if (config.rtp.rtx_ssrc) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 } else { | 778 } else { |
| 740 ++it; | 779 ++it; |
| 741 } | 780 } |
| 742 } | 781 } |
| 743 video_receive_streams_.erase(receive_stream_impl); | 782 video_receive_streams_.erase(receive_stream_impl); |
| 744 RTC_CHECK(receive_stream_impl != nullptr); | 783 RTC_CHECK(receive_stream_impl != nullptr); |
| 745 ConfigureSync(receive_stream_impl->config().sync_group); | 784 ConfigureSync(receive_stream_impl->config().sync_group); |
| 746 } | 785 } |
| 747 const VideoReceiveStream::Config& config = receive_stream_impl->config(); | 786 const VideoReceiveStream::Config& config = receive_stream_impl->config(); |
| 748 | 787 |
| 749 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 788 transport_->congestion_controller() |
| 789 ->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | |
| 750 ->RemoveStream(config.rtp.remote_ssrc); | 790 ->RemoveStream(config.rtp.remote_ssrc); |
| 751 | 791 |
| 752 UpdateAggregateNetworkState(); | 792 UpdateAggregateNetworkState(); |
| 753 delete receive_stream_impl; | 793 delete receive_stream_impl; |
| 754 } | 794 } |
| 755 | 795 |
| 756 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( | 796 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( |
| 757 const FlexfecReceiveStream::Config& config) { | 797 const FlexfecReceiveStream::Config& config) { |
| 758 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); | 798 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); |
| 759 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 799 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 ++prot_it; | 855 ++prot_it; |
| 816 } | 856 } |
| 817 auto media_it = flexfec_receive_ssrcs_media_.begin(); | 857 auto media_it = flexfec_receive_ssrcs_media_.begin(); |
| 818 while (media_it != flexfec_receive_ssrcs_media_.end()) { | 858 while (media_it != flexfec_receive_ssrcs_media_.end()) { |
| 819 if (media_it->second == receive_stream_impl) | 859 if (media_it->second == receive_stream_impl) |
| 820 media_it = flexfec_receive_ssrcs_media_.erase(media_it); | 860 media_it = flexfec_receive_ssrcs_media_.erase(media_it); |
| 821 else | 861 else |
| 822 ++media_it; | 862 ++media_it; |
| 823 } | 863 } |
| 824 | 864 |
| 825 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 865 transport_->congestion_controller() |
| 866 ->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | |
| 826 ->RemoveStream(ssrc); | 867 ->RemoveStream(ssrc); |
| 827 | 868 |
| 828 flexfec_receive_streams_.erase(receive_stream_impl); | 869 flexfec_receive_streams_.erase(receive_stream_impl); |
| 829 } | 870 } |
| 830 | 871 |
| 831 delete receive_stream_impl; | 872 delete receive_stream_impl; |
| 832 } | 873 } |
| 833 | 874 |
| 834 Call::Stats Call::GetStats() const { | 875 Call::Stats Call::GetStats() const { |
| 835 // TODO(solenberg): Some test cases in EndToEndTest use this from a different | 876 // TODO(solenberg): Some test cases in EndToEndTest use this from a different |
| 836 // thread. Re-enable once that is fixed. | 877 // thread. Re-enable once that is fixed. |
| 837 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 878 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 838 Stats stats; | 879 Stats stats; |
| 839 // Fetch available send/receive bitrates. | 880 // Fetch available send/receive bitrates. |
| 840 uint32_t send_bandwidth = 0; | 881 uint32_t send_bandwidth = 0; |
| 841 congestion_controller_->GetBitrateController()->AvailableBandwidth( | 882 transport_->congestion_controller() |
| 842 &send_bandwidth); | 883 ->GetBitrateController() |
| 884 ->AvailableBandwidth(&send_bandwidth); | |
| 843 std::vector<unsigned int> ssrcs; | 885 std::vector<unsigned int> ssrcs; |
| 844 uint32_t recv_bandwidth = 0; | 886 uint32_t recv_bandwidth = 0; |
| 845 congestion_controller_->GetRemoteBitrateEstimator(false)->LatestEstimate( | 887 transport_->congestion_controller() |
| 846 &ssrcs, &recv_bandwidth); | 888 ->GetRemoteBitrateEstimator(false) |
| 889 ->LatestEstimate(&ssrcs, &recv_bandwidth); | |
| 847 stats.send_bandwidth_bps = send_bandwidth; | 890 stats.send_bandwidth_bps = send_bandwidth; |
| 848 stats.recv_bandwidth_bps = recv_bandwidth; | 891 stats.recv_bandwidth_bps = recv_bandwidth; |
| 849 stats.pacer_delay_ms = congestion_controller_->GetPacerQueuingDelayMs(); | 892 stats.pacer_delay_ms = |
| 893 transport_->congestion_controller()->GetPacerQueuingDelayMs(); | |
| 850 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); | 894 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); |
| 851 { | 895 { |
| 852 rtc::CritScope cs(&bitrate_crit_); | 896 rtc::CritScope cs(&bitrate_crit_); |
| 853 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_; | 897 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_; |
| 854 } | 898 } |
| 855 return stats; | 899 return stats; |
| 856 } | 900 } |
| 857 | 901 |
| 858 void Call::SetBitrateConfig( | 902 void Call::SetBitrateConfig( |
| 859 const webrtc::Call::Config::BitrateConfig& bitrate_config) { | 903 const webrtc::Call::Config::BitrateConfig& bitrate_config) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 872 // Nothing new to set, early abort to avoid encoder reconfigurations. | 916 // Nothing new to set, early abort to avoid encoder reconfigurations. |
| 873 return; | 917 return; |
| 874 } | 918 } |
| 875 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps; | 919 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps; |
| 876 // Start bitrate of -1 means we should keep the old bitrate, which there is | 920 // Start bitrate of -1 means we should keep the old bitrate, which there is |
| 877 // no point in remembering for the future. | 921 // no point in remembering for the future. |
| 878 if (bitrate_config.start_bitrate_bps > 0) | 922 if (bitrate_config.start_bitrate_bps > 0) |
| 879 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps; | 923 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps; |
| 880 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps; | 924 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps; |
| 881 RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0); | 925 RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0); |
| 882 congestion_controller_->SetBweBitrates(bitrate_config.min_bitrate_bps, | 926 transport_->congestion_controller()->SetBweBitrates( |
| 883 bitrate_config.start_bitrate_bps, | 927 bitrate_config.min_bitrate_bps, bitrate_config.start_bitrate_bps, |
| 884 bitrate_config.max_bitrate_bps); | 928 bitrate_config.max_bitrate_bps); |
| 885 } | 929 } |
| 886 | 930 |
| 887 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { | 931 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { |
| 888 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 932 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 889 switch (media) { | 933 switch (media) { |
| 890 case MediaType::AUDIO: | 934 case MediaType::AUDIO: |
| 891 audio_network_state_ = state; | 935 audio_network_state_ = state; |
| 892 break; | 936 break; |
| 893 case MediaType::VIDEO: | 937 case MediaType::VIDEO: |
| 894 video_network_state_ = state; | 938 video_network_state_ = state; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 969 kv->second = network_route; | 1013 kv->second = network_route; |
| 970 LOG(LS_INFO) << "Network route changed on transport " << transport_name | 1014 LOG(LS_INFO) << "Network route changed on transport " << transport_name |
| 971 << ": new local network id " << network_route.local_network_id | 1015 << ": new local network id " << network_route.local_network_id |
| 972 << " new remote network id " << network_route.remote_network_id | 1016 << " new remote network id " << network_route.remote_network_id |
| 973 << " Reset bitrates to min: " | 1017 << " Reset bitrates to min: " |
| 974 << config_.bitrate_config.min_bitrate_bps | 1018 << config_.bitrate_config.min_bitrate_bps |
| 975 << " bps, start: " << config_.bitrate_config.start_bitrate_bps | 1019 << " bps, start: " << config_.bitrate_config.start_bitrate_bps |
| 976 << " bps, max: " << config_.bitrate_config.start_bitrate_bps | 1020 << " bps, max: " << config_.bitrate_config.start_bitrate_bps |
| 977 << " bps."; | 1021 << " bps."; |
| 978 RTC_DCHECK_GT(config_.bitrate_config.start_bitrate_bps, 0); | 1022 RTC_DCHECK_GT(config_.bitrate_config.start_bitrate_bps, 0); |
| 979 congestion_controller_->ResetBweAndBitrates( | 1023 transport_->congestion_controller()->ResetBweAndBitrates( |
| 980 config_.bitrate_config.start_bitrate_bps, | 1024 config_.bitrate_config.start_bitrate_bps, |
| 981 config_.bitrate_config.min_bitrate_bps, | 1025 config_.bitrate_config.min_bitrate_bps, |
| 982 config_.bitrate_config.max_bitrate_bps); | 1026 config_.bitrate_config.max_bitrate_bps); |
| 983 } | 1027 } |
| 984 } | 1028 } |
| 985 | 1029 |
| 986 void Call::UpdateAggregateNetworkState() { | 1030 void Call::UpdateAggregateNetworkState() { |
| 987 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 1031 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 988 | 1032 |
| 989 bool have_audio = false; | 1033 bool have_audio = false; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1005 | 1049 |
| 1006 NetworkState aggregate_state = kNetworkDown; | 1050 NetworkState aggregate_state = kNetworkDown; |
| 1007 if ((have_video && video_network_state_ == kNetworkUp) || | 1051 if ((have_video && video_network_state_ == kNetworkUp) || |
| 1008 (have_audio && audio_network_state_ == kNetworkUp)) { | 1052 (have_audio && audio_network_state_ == kNetworkUp)) { |
| 1009 aggregate_state = kNetworkUp; | 1053 aggregate_state = kNetworkUp; |
| 1010 } | 1054 } |
| 1011 | 1055 |
| 1012 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state=" | 1056 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state=" |
| 1013 << (aggregate_state == kNetworkUp ? "up" : "down"); | 1057 << (aggregate_state == kNetworkUp ? "up" : "down"); |
| 1014 | 1058 |
| 1015 congestion_controller_->SignalNetworkState(aggregate_state); | 1059 transport_->congestion_controller()->SignalNetworkState(aggregate_state); |
| 1016 } | 1060 } |
| 1017 | 1061 |
| 1018 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { | 1062 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { |
| 1019 if (first_packet_sent_ms_ == -1) | 1063 if (first_packet_sent_ms_ == -1) |
| 1020 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); | 1064 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); |
| 1021 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, | 1065 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, |
| 1022 clock_->TimeInMilliseconds()); | 1066 clock_->TimeInMilliseconds()); |
| 1023 congestion_controller_->OnSentPacket(sent_packet); | 1067 transport_->congestion_controller()->OnSentPacket(sent_packet); |
| 1024 } | 1068 } |
| 1025 | 1069 |
| 1026 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, | 1070 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, |
| 1027 uint8_t fraction_loss, | 1071 uint8_t fraction_loss, |
| 1028 int64_t rtt_ms, | 1072 int64_t rtt_ms, |
| 1029 int64_t probing_interval_ms) { | 1073 int64_t probing_interval_ms) { |
| 1030 // TODO(perkj): Consider making sure CongestionController operates on | 1074 // TODO(perkj): Consider making sure CongestionController operates on |
| 1031 // |worker_queue_|. | 1075 // |worker_queue_|. |
| 1032 if (!worker_queue_.IsCurrent()) { | 1076 if (!worker_queue_.IsCurrent()) { |
| 1033 worker_queue_.PostTask( | 1077 worker_queue_.PostTask( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1064 } | 1108 } |
| 1065 estimated_send_bitrate_kbps_counter_.Add(target_bitrate_bps / 1000); | 1109 estimated_send_bitrate_kbps_counter_.Add(target_bitrate_bps / 1000); |
| 1066 // Pacer bitrate may be higher than bitrate estimate if enforcing min bitrate. | 1110 // Pacer bitrate may be higher than bitrate estimate if enforcing min bitrate. |
| 1067 uint32_t pacer_bitrate_bps = | 1111 uint32_t pacer_bitrate_bps = |
| 1068 std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_); | 1112 std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_); |
| 1069 pacer_bitrate_kbps_counter_.Add(pacer_bitrate_bps / 1000); | 1113 pacer_bitrate_kbps_counter_.Add(pacer_bitrate_bps / 1000); |
| 1070 } | 1114 } |
| 1071 | 1115 |
| 1072 void Call::OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps, | 1116 void Call::OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps, |
| 1073 uint32_t max_padding_bitrate_bps) { | 1117 uint32_t max_padding_bitrate_bps) { |
| 1074 congestion_controller_->SetAllocatedSendBitrateLimits( | 1118 transport_->congestion_controller()->SetAllocatedSendBitrateLimits( |
| 1075 min_send_bitrate_bps, max_padding_bitrate_bps); | 1119 min_send_bitrate_bps, max_padding_bitrate_bps); |
| 1076 rtc::CritScope lock(&bitrate_crit_); | 1120 rtc::CritScope lock(&bitrate_crit_); |
| 1077 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; | 1121 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; |
| 1078 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; | 1122 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; |
| 1079 } | 1123 } |
| 1080 | 1124 |
| 1081 void Call::ConfigureSync(const std::string& sync_group) { | 1125 void Call::ConfigureSync(const std::string& sync_group) { |
| 1082 // Set sync only if there was no previous one. | 1126 // Set sync only if there was no previous one. |
| 1083 if (sync_group.empty()) | 1127 if (sync_group.empty()) |
| 1084 return; | 1128 return; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1289 // module in the case that some, but not all, have RTCP feedback | 1333 // module in the case that some, but not all, have RTCP feedback |
| 1290 // enabled. | 1334 // enabled. |
| 1291 return; | 1335 return; |
| 1292 } | 1336 } |
| 1293 // For audio, we only support send side BWE. | 1337 // For audio, we only support send side BWE. |
| 1294 // TODO(nisse): Tests passes MediaType::ANY, see | 1338 // TODO(nisse): Tests passes MediaType::ANY, see |
| 1295 // FakeNetworkPipe::Process. We need to treat that as video. Tests | 1339 // FakeNetworkPipe::Process. We need to treat that as video. Tests |
| 1296 // should be fixed to use the same MediaType as the production code. | 1340 // should be fixed to use the same MediaType as the production code. |
| 1297 if (media_type != MediaType::AUDIO || | 1341 if (media_type != MediaType::AUDIO || |
| 1298 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { | 1342 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { |
| 1299 congestion_controller_->OnReceivedPacket( | 1343 transport_->congestion_controller()->OnReceivedPacket( |
| 1300 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), | 1344 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), |
| 1301 header); | 1345 header); |
| 1302 } | 1346 } |
| 1303 } | 1347 } |
| 1304 | 1348 |
| 1305 } // namespace internal | 1349 } // namespace internal |
| 1350 | |
| 1306 } // namespace webrtc | 1351 } // namespace webrtc |
| OLD | NEW |