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