| 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 18 matching lines...) Expand all Loading... |
| 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/config.h" | 36 #include "webrtc/config.h" |
| 37 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 37 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 38 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 38 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 39 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 39 #include "webrtc/modules/congestion_controller/include/receive_side_congestion_c
ontroller.h" |
| 40 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont
roller.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" |
| 46 #include "webrtc/modules/utility/include/process_thread.h" | 47 #include "webrtc/modules/utility/include/process_thread.h" |
| 47 #include "webrtc/system_wrappers/include/clock.h" | 48 #include "webrtc/system_wrappers/include/clock.h" |
| 48 #include "webrtc/system_wrappers/include/cpu_info.h" | 49 #include "webrtc/system_wrappers/include/cpu_info.h" |
| 49 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 50 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 return UseSendSideBwe(config.rtp_header_extensions, config.transport_cc); | 88 return UseSendSideBwe(config.rtp_header_extensions, config.transport_cc); |
| 88 } | 89 } |
| 89 | 90 |
| 90 } // namespace | 91 } // namespace |
| 91 | 92 |
| 92 namespace internal { | 93 namespace internal { |
| 93 | 94 |
| 94 class Call : public webrtc::Call, | 95 class Call : public webrtc::Call, |
| 95 public PacketReceiver, | 96 public PacketReceiver, |
| 96 public RecoveredPacketReceiver, | 97 public RecoveredPacketReceiver, |
| 97 public CongestionController::Observer, | 98 public SendSideCongestionController::Observer, |
| 98 public BitrateAllocator::LimitObserver { | 99 public BitrateAllocator::LimitObserver { |
| 99 public: | 100 public: |
| 100 explicit Call(const Call::Config& config); | 101 explicit Call(const Call::Config& config); |
| 101 virtual ~Call(); | 102 virtual ~Call(); |
| 102 | 103 |
| 103 // Implements webrtc::Call. | 104 // Implements webrtc::Call. |
| 104 PacketReceiver* Receiver() override; | 105 PacketReceiver* Receiver() override; |
| 105 | 106 |
| 106 webrtc::AudioSendStream* CreateAudioSendStream( | 107 webrtc::AudioSendStream* CreateAudioSendStream( |
| 107 const webrtc::AudioSendStream::Config& config) override; | 108 const webrtc::AudioSendStream::Config& config) override; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 rtc::CriticalSection bitrate_crit_; | 267 rtc::CriticalSection bitrate_crit_; |
| 267 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); | 268 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); |
| 268 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); | 269 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); |
| 269 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); | 270 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); |
| 270 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); | 271 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); |
| 271 | 272 |
| 272 std::map<std::string, rtc::NetworkRoute> network_routes_; | 273 std::map<std::string, rtc::NetworkRoute> network_routes_; |
| 273 | 274 |
| 274 VieRemb remb_; | 275 VieRemb remb_; |
| 275 PacketRouter packet_router_; | 276 PacketRouter packet_router_; |
| 276 // TODO(nisse): Could be a direct member, except for constness | 277 SendSideCongestionController send_side_congestion_controller_; |
| 277 // issues with GetRemoteBitrateEstimator (and maybe others). | 278 ReceiveSideCongestionController receive_side_congestion_controller_; |
| 278 const std::unique_ptr<CongestionController> congestion_controller_; | |
| 279 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; | 279 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; |
| 280 const int64_t start_ms_; | 280 const int64_t start_ms_; |
| 281 // TODO(perkj): |worker_queue_| is supposed to replace | 281 // TODO(perkj): |worker_queue_| is supposed to replace |
| 282 // |module_process_thread_|. | 282 // |module_process_thread_|. |
| 283 // |worker_queue| is defined last to ensure all pending tasks are cancelled | 283 // |worker_queue| is defined last to ensure all pending tasks are cancelled |
| 284 // and deleted before any other members. | 284 // and deleted before any other members. |
| 285 rtc::TaskQueue worker_queue_; | 285 rtc::TaskQueue worker_queue_; |
| 286 | 286 |
| 287 RTC_DISALLOW_COPY_AND_ASSIGN(Call); | 287 RTC_DISALLOW_COPY_AND_ASSIGN(Call); |
| 288 }; | 288 }; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 first_packet_sent_ms_(-1), | 322 first_packet_sent_ms_(-1), |
| 323 received_bytes_per_second_counter_(clock_, nullptr, true), | 323 received_bytes_per_second_counter_(clock_, nullptr, true), |
| 324 received_audio_bytes_per_second_counter_(clock_, nullptr, true), | 324 received_audio_bytes_per_second_counter_(clock_, nullptr, true), |
| 325 received_video_bytes_per_second_counter_(clock_, nullptr, true), | 325 received_video_bytes_per_second_counter_(clock_, nullptr, true), |
| 326 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), | 326 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), |
| 327 min_allocated_send_bitrate_bps_(0), | 327 min_allocated_send_bitrate_bps_(0), |
| 328 configured_max_padding_bitrate_bps_(0), | 328 configured_max_padding_bitrate_bps_(0), |
| 329 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), | 329 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), |
| 330 pacer_bitrate_kbps_counter_(clock_, nullptr, true), | 330 pacer_bitrate_kbps_counter_(clock_, nullptr, true), |
| 331 remb_(clock_), | 331 remb_(clock_), |
| 332 congestion_controller_(new CongestionController(clock_, | 332 send_side_congestion_controller_(clock_, |
| 333 this, | 333 this, |
| 334 &remb_, | 334 event_log_, |
| 335 event_log_, | 335 &packet_router_), |
| 336 &packet_router_)), | 336 receive_side_congestion_controller_(clock_, &remb_, &packet_router_), |
| 337 video_send_delay_stats_(new SendDelayStats(clock_)), | 337 video_send_delay_stats_(new SendDelayStats(clock_)), |
| 338 start_ms_(clock_->TimeInMilliseconds()), | 338 start_ms_(clock_->TimeInMilliseconds()), |
| 339 worker_queue_("call_worker_queue") { | 339 worker_queue_("call_worker_queue") { |
| 340 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 340 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 341 RTC_DCHECK(config.event_log != nullptr); | 341 RTC_DCHECK(config.event_log != nullptr); |
| 342 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 342 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
| 343 RTC_DCHECK_GT(config.bitrate_config.start_bitrate_bps, | 343 RTC_DCHECK_GT(config.bitrate_config.start_bitrate_bps, |
| 344 config.bitrate_config.min_bitrate_bps); | 344 config.bitrate_config.min_bitrate_bps); |
| 345 if (config.bitrate_config.max_bitrate_bps != -1) { | 345 if (config.bitrate_config.max_bitrate_bps != -1) { |
| 346 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 346 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
| 347 config.bitrate_config.start_bitrate_bps); | 347 config.bitrate_config.start_bitrate_bps); |
| 348 } | 348 } |
| 349 Trace::CreateTrace(); | 349 Trace::CreateTrace(); |
| 350 call_stats_->RegisterStatsObserver(congestion_controller_.get()); | 350 call_stats_->RegisterStatsObserver(&send_side_congestion_controller_); |
| 351 | 351 |
| 352 congestion_controller_->SignalNetworkState(kNetworkDown); | 352 send_side_congestion_controller_.SignalNetworkState(kNetworkDown); |
| 353 congestion_controller_->SetBweBitrates( | 353 send_side_congestion_controller_.SetBweBitrates( |
| 354 config_.bitrate_config.min_bitrate_bps, | 354 config_.bitrate_config.min_bitrate_bps, |
| 355 config_.bitrate_config.start_bitrate_bps, | 355 config_.bitrate_config.start_bitrate_bps, |
| 356 config_.bitrate_config.max_bitrate_bps); | 356 config_.bitrate_config.max_bitrate_bps); |
| 357 | 357 |
| 358 module_process_thread_->Start(); | 358 module_process_thread_->Start(); |
| 359 module_process_thread_->RegisterModule(call_stats_.get(), RTC_FROM_HERE); | 359 module_process_thread_->RegisterModule(call_stats_.get(), RTC_FROM_HERE); |
| 360 module_process_thread_->RegisterModule(congestion_controller_.get(), | 360 module_process_thread_->RegisterModule(&send_side_congestion_controller_, |
| 361 RTC_FROM_HERE); | 361 RTC_FROM_HERE); |
| 362 pacer_thread_->RegisterModule(congestion_controller_->pacer(), RTC_FROM_HERE); | 362 module_process_thread_->RegisterModule(&receive_side_congestion_controller_, |
| 363 RTC_FROM_HERE); |
| 364 pacer_thread_->RegisterModule(send_side_congestion_controller_.pacer(), |
| 365 RTC_FROM_HERE); |
| 363 pacer_thread_->RegisterModule( | 366 pacer_thread_->RegisterModule( |
| 364 congestion_controller_->GetRemoteBitrateEstimator(true), RTC_FROM_HERE); | 367 receive_side_congestion_controller_.GetRemoteBitrateEstimator(true), |
| 368 RTC_FROM_HERE); |
| 365 pacer_thread_->Start(); | 369 pacer_thread_->Start(); |
| 366 } | 370 } |
| 367 | 371 |
| 368 Call::~Call() { | 372 Call::~Call() { |
| 369 RTC_DCHECK(!remb_.InUse()); | 373 RTC_DCHECK(!remb_.InUse()); |
| 370 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 374 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 371 | 375 |
| 372 RTC_CHECK(audio_send_ssrcs_.empty()); | 376 RTC_CHECK(audio_send_ssrcs_.empty()); |
| 373 RTC_CHECK(video_send_ssrcs_.empty()); | 377 RTC_CHECK(video_send_ssrcs_.empty()); |
| 374 RTC_CHECK(video_send_streams_.empty()); | 378 RTC_CHECK(video_send_streams_.empty()); |
| 375 RTC_CHECK(audio_receive_ssrcs_.empty()); | 379 RTC_CHECK(audio_receive_ssrcs_.empty()); |
| 376 RTC_CHECK(video_receive_ssrcs_.empty()); | 380 RTC_CHECK(video_receive_ssrcs_.empty()); |
| 377 RTC_CHECK(video_receive_streams_.empty()); | 381 RTC_CHECK(video_receive_streams_.empty()); |
| 378 | 382 |
| 379 pacer_thread_->Stop(); | 383 pacer_thread_->Stop(); |
| 380 pacer_thread_->DeRegisterModule(congestion_controller_->pacer()); | 384 pacer_thread_->DeRegisterModule(send_side_congestion_controller_.pacer()); |
| 381 pacer_thread_->DeRegisterModule( | 385 pacer_thread_->DeRegisterModule( |
| 382 congestion_controller_->GetRemoteBitrateEstimator(true)); | 386 receive_side_congestion_controller_.GetRemoteBitrateEstimator(true)); |
| 383 module_process_thread_->DeRegisterModule(congestion_controller_.get()); | 387 module_process_thread_->DeRegisterModule(&send_side_congestion_controller_); |
| 388 module_process_thread_->DeRegisterModule( |
| 389 &receive_side_congestion_controller_); |
| 384 module_process_thread_->DeRegisterModule(call_stats_.get()); | 390 module_process_thread_->DeRegisterModule(call_stats_.get()); |
| 385 module_process_thread_->Stop(); | 391 module_process_thread_->Stop(); |
| 386 call_stats_->DeregisterStatsObserver(congestion_controller_.get()); | 392 call_stats_->DeregisterStatsObserver(&send_side_congestion_controller_); |
| 387 | 393 |
| 388 // Only update histograms after process threads have been shut down, so that | 394 // Only update histograms after process threads have been shut down, so that |
| 389 // they won't try to concurrently update stats. | 395 // they won't try to concurrently update stats. |
| 390 { | 396 { |
| 391 rtc::CritScope lock(&bitrate_crit_); | 397 rtc::CritScope lock(&bitrate_crit_); |
| 392 UpdateSendHistograms(); | 398 UpdateSendHistograms(); |
| 393 } | 399 } |
| 394 UpdateReceiveHistograms(); | 400 UpdateReceiveHistograms(); |
| 395 UpdateHistograms(); | 401 UpdateHistograms(); |
| 396 | 402 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 return this; | 501 return this; |
| 496 } | 502 } |
| 497 | 503 |
| 498 webrtc::AudioSendStream* Call::CreateAudioSendStream( | 504 webrtc::AudioSendStream* Call::CreateAudioSendStream( |
| 499 const webrtc::AudioSendStream::Config& config) { | 505 const webrtc::AudioSendStream::Config& config) { |
| 500 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); | 506 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); |
| 501 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 507 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 502 event_log_->LogAudioSendStreamConfig(config); | 508 event_log_->LogAudioSendStreamConfig(config); |
| 503 AudioSendStream* send_stream = new AudioSendStream( | 509 AudioSendStream* send_stream = new AudioSendStream( |
| 504 config, config_.audio_state, &worker_queue_, &packet_router_, | 510 config, config_.audio_state, &worker_queue_, &packet_router_, |
| 505 congestion_controller_.get(), bitrate_allocator_.get(), event_log_, | 511 &send_side_congestion_controller_, bitrate_allocator_.get(), event_log_, |
| 506 call_stats_->rtcp_rtt_stats()); | 512 call_stats_->rtcp_rtt_stats()); |
| 507 { | 513 { |
| 508 WriteLockScoped write_lock(*send_crit_); | 514 WriteLockScoped write_lock(*send_crit_); |
| 509 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == | 515 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == |
| 510 audio_send_ssrcs_.end()); | 516 audio_send_ssrcs_.end()); |
| 511 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; | 517 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; |
| 512 } | 518 } |
| 513 { | 519 { |
| 514 ReadLockScoped read_lock(*receive_crit_); | 520 ReadLockScoped read_lock(*receive_crit_); |
| 515 for (const auto& kv : audio_receive_ssrcs_) { | 521 for (const auto& kv : audio_receive_ssrcs_) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 webrtc::AudioReceiveStream* receive_stream) { | 590 webrtc::AudioReceiveStream* receive_stream) { |
| 585 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); | 591 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); |
| 586 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 592 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 587 RTC_DCHECK(receive_stream != nullptr); | 593 RTC_DCHECK(receive_stream != nullptr); |
| 588 webrtc::internal::AudioReceiveStream* audio_receive_stream = | 594 webrtc::internal::AudioReceiveStream* audio_receive_stream = |
| 589 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); | 595 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); |
| 590 { | 596 { |
| 591 WriteLockScoped write_lock(*receive_crit_); | 597 WriteLockScoped write_lock(*receive_crit_); |
| 592 const AudioReceiveStream::Config& config = audio_receive_stream->config(); | 598 const AudioReceiveStream::Config& config = audio_receive_stream->config(); |
| 593 uint32_t ssrc = config.rtp.remote_ssrc; | 599 uint32_t ssrc = config.rtp.remote_ssrc; |
| 594 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 600 receive_side_congestion_controller_ |
| 601 .GetRemoteBitrateEstimator(UseSendSideBwe(config)) |
| 595 ->RemoveStream(ssrc); | 602 ->RemoveStream(ssrc); |
| 596 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); | 603 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); |
| 597 RTC_DCHECK(num_deleted == 1); | 604 RTC_DCHECK(num_deleted == 1); |
| 598 const std::string& sync_group = audio_receive_stream->config().sync_group; | 605 const std::string& sync_group = audio_receive_stream->config().sync_group; |
| 599 const auto it = sync_stream_mapping_.find(sync_group); | 606 const auto it = sync_stream_mapping_.find(sync_group); |
| 600 if (it != sync_stream_mapping_.end() && | 607 if (it != sync_stream_mapping_.end() && |
| 601 it->second == audio_receive_stream) { | 608 it->second == audio_receive_stream) { |
| 602 sync_stream_mapping_.erase(it); | 609 sync_stream_mapping_.erase(it); |
| 603 ConfigureSync(sync_group); | 610 ConfigureSync(sync_group); |
| 604 } | 611 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 616 | 623 |
| 617 video_send_delay_stats_->AddSsrcs(config); | 624 video_send_delay_stats_->AddSsrcs(config); |
| 618 event_log_->LogVideoSendStreamConfig(config); | 625 event_log_->LogVideoSendStreamConfig(config); |
| 619 | 626 |
| 620 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if | 627 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if |
| 621 // the call has already started. | 628 // the call has already started. |
| 622 // Copy ssrcs from |config| since |config| is moved. | 629 // Copy ssrcs from |config| since |config| is moved. |
| 623 std::vector<uint32_t> ssrcs = config.rtp.ssrcs; | 630 std::vector<uint32_t> ssrcs = config.rtp.ssrcs; |
| 624 VideoSendStream* send_stream = new VideoSendStream( | 631 VideoSendStream* send_stream = new VideoSendStream( |
| 625 num_cpu_cores_, module_process_thread_.get(), &worker_queue_, | 632 num_cpu_cores_, module_process_thread_.get(), &worker_queue_, |
| 626 call_stats_.get(), congestion_controller_.get(), &packet_router_, | 633 call_stats_.get(), &send_side_congestion_controller_, &packet_router_, |
| 627 bitrate_allocator_.get(), video_send_delay_stats_.get(), &remb_, | 634 bitrate_allocator_.get(), video_send_delay_stats_.get(), &remb_, |
| 628 event_log_, std::move(config), std::move(encoder_config), | 635 event_log_, std::move(config), std::move(encoder_config), |
| 629 suspended_video_send_ssrcs_); | 636 suspended_video_send_ssrcs_); |
| 630 | 637 |
| 631 { | 638 { |
| 632 WriteLockScoped write_lock(*send_crit_); | 639 WriteLockScoped write_lock(*send_crit_); |
| 633 for (uint32_t ssrc : ssrcs) { | 640 for (uint32_t ssrc : ssrcs) { |
| 634 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 641 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
| 635 video_send_ssrcs_[ssrc] = send_stream; | 642 video_send_ssrcs_[ssrc] = send_stream; |
| 636 } | 643 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 } else { | 740 } else { |
| 734 ++it; | 741 ++it; |
| 735 } | 742 } |
| 736 } | 743 } |
| 737 video_receive_streams_.erase(receive_stream_impl); | 744 video_receive_streams_.erase(receive_stream_impl); |
| 738 RTC_CHECK(receive_stream_impl != nullptr); | 745 RTC_CHECK(receive_stream_impl != nullptr); |
| 739 ConfigureSync(receive_stream_impl->config().sync_group); | 746 ConfigureSync(receive_stream_impl->config().sync_group); |
| 740 } | 747 } |
| 741 const VideoReceiveStream::Config& config = receive_stream_impl->config(); | 748 const VideoReceiveStream::Config& config = receive_stream_impl->config(); |
| 742 | 749 |
| 743 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 750 receive_side_congestion_controller_ |
| 751 .GetRemoteBitrateEstimator(UseSendSideBwe(config)) |
| 744 ->RemoveStream(config.rtp.remote_ssrc); | 752 ->RemoveStream(config.rtp.remote_ssrc); |
| 745 | 753 |
| 746 UpdateAggregateNetworkState(); | 754 UpdateAggregateNetworkState(); |
| 747 delete receive_stream_impl; | 755 delete receive_stream_impl; |
| 748 } | 756 } |
| 749 | 757 |
| 750 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( | 758 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( |
| 751 const FlexfecReceiveStream::Config& config) { | 759 const FlexfecReceiveStream::Config& config) { |
| 752 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); | 760 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); |
| 753 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 761 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 ++prot_it; | 817 ++prot_it; |
| 810 } | 818 } |
| 811 auto media_it = flexfec_receive_ssrcs_media_.begin(); | 819 auto media_it = flexfec_receive_ssrcs_media_.begin(); |
| 812 while (media_it != flexfec_receive_ssrcs_media_.end()) { | 820 while (media_it != flexfec_receive_ssrcs_media_.end()) { |
| 813 if (media_it->second == receive_stream_impl) | 821 if (media_it->second == receive_stream_impl) |
| 814 media_it = flexfec_receive_ssrcs_media_.erase(media_it); | 822 media_it = flexfec_receive_ssrcs_media_.erase(media_it); |
| 815 else | 823 else |
| 816 ++media_it; | 824 ++media_it; |
| 817 } | 825 } |
| 818 | 826 |
| 819 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 827 receive_side_congestion_controller_ |
| 828 .GetRemoteBitrateEstimator(UseSendSideBwe(config)) |
| 820 ->RemoveStream(ssrc); | 829 ->RemoveStream(ssrc); |
| 821 | 830 |
| 822 flexfec_receive_streams_.erase(receive_stream_impl); | 831 flexfec_receive_streams_.erase(receive_stream_impl); |
| 823 } | 832 } |
| 824 | 833 |
| 825 delete receive_stream_impl; | 834 delete receive_stream_impl; |
| 826 } | 835 } |
| 827 | 836 |
| 828 Call::Stats Call::GetStats() const { | 837 Call::Stats Call::GetStats() const { |
| 829 // TODO(solenberg): Some test cases in EndToEndTest use this from a different | 838 // TODO(solenberg): Some test cases in EndToEndTest use this from a different |
| 830 // thread. Re-enable once that is fixed. | 839 // thread. Re-enable once that is fixed. |
| 831 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 840 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 832 Stats stats; | 841 Stats stats; |
| 833 // Fetch available send/receive bitrates. | 842 // Fetch available send/receive bitrates. |
| 834 uint32_t send_bandwidth = 0; | 843 uint32_t send_bandwidth = 0; |
| 835 congestion_controller_->GetBitrateController()->AvailableBandwidth( | 844 send_side_congestion_controller_.GetBitrateController()->AvailableBandwidth( |
| 836 &send_bandwidth); | 845 &send_bandwidth); |
| 837 std::vector<unsigned int> ssrcs; | 846 std::vector<unsigned int> ssrcs; |
| 838 uint32_t recv_bandwidth = 0; | 847 uint32_t recv_bandwidth = 0; |
| 839 congestion_controller_->GetRemoteBitrateEstimator(false)->LatestEstimate( | 848 receive_side_congestion_controller_.GetRemoteBitrateEstimator(false) |
| 840 &ssrcs, &recv_bandwidth); | 849 ->LatestEstimate(&ssrcs, &recv_bandwidth); |
| 841 stats.send_bandwidth_bps = send_bandwidth; | 850 stats.send_bandwidth_bps = send_bandwidth; |
| 842 stats.recv_bandwidth_bps = recv_bandwidth; | 851 stats.recv_bandwidth_bps = recv_bandwidth; |
| 843 stats.pacer_delay_ms = congestion_controller_->GetPacerQueuingDelayMs(); | 852 stats.pacer_delay_ms = |
| 853 send_side_congestion_controller_.GetPacerQueuingDelayMs(); |
| 844 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); | 854 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); |
| 845 { | 855 { |
| 846 rtc::CritScope cs(&bitrate_crit_); | 856 rtc::CritScope cs(&bitrate_crit_); |
| 847 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_; | 857 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_; |
| 848 } | 858 } |
| 849 return stats; | 859 return stats; |
| 850 } | 860 } |
| 851 | 861 |
| 852 void Call::SetBitrateConfig( | 862 void Call::SetBitrateConfig( |
| 853 const webrtc::Call::Config::BitrateConfig& bitrate_config) { | 863 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. | 876 // Nothing new to set, early abort to avoid encoder reconfigurations. |
| 867 return; | 877 return; |
| 868 } | 878 } |
| 869 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps; | 879 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 | 880 // Start bitrate of -1 means we should keep the old bitrate, which there is |
| 871 // no point in remembering for the future. | 881 // no point in remembering for the future. |
| 872 if (bitrate_config.start_bitrate_bps > 0) | 882 if (bitrate_config.start_bitrate_bps > 0) |
| 873 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps; | 883 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps; |
| 874 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps; | 884 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps; |
| 875 RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0); | 885 RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0); |
| 876 congestion_controller_->SetBweBitrates(bitrate_config.min_bitrate_bps, | 886 send_side_congestion_controller_.SetBweBitrates( |
| 877 bitrate_config.start_bitrate_bps, | 887 bitrate_config.min_bitrate_bps, bitrate_config.start_bitrate_bps, |
| 878 bitrate_config.max_bitrate_bps); | 888 bitrate_config.max_bitrate_bps); |
| 879 } | 889 } |
| 880 | 890 |
| 881 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { | 891 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { |
| 882 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 892 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 883 switch (media) { | 893 switch (media) { |
| 884 case MediaType::AUDIO: | 894 case MediaType::AUDIO: |
| 885 audio_network_state_ = state; | 895 audio_network_state_ = state; |
| 886 break; | 896 break; |
| 887 case MediaType::VIDEO: | 897 case MediaType::VIDEO: |
| 888 video_network_state_ = state; | 898 video_network_state_ = state; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 kv->second = network_route; | 973 kv->second = network_route; |
| 964 LOG(LS_INFO) << "Network route changed on transport " << transport_name | 974 LOG(LS_INFO) << "Network route changed on transport " << transport_name |
| 965 << ": new local network id " << network_route.local_network_id | 975 << ": new local network id " << network_route.local_network_id |
| 966 << " new remote network id " << network_route.remote_network_id | 976 << " new remote network id " << network_route.remote_network_id |
| 967 << " Reset bitrates to min: " | 977 << " Reset bitrates to min: " |
| 968 << config_.bitrate_config.min_bitrate_bps | 978 << config_.bitrate_config.min_bitrate_bps |
| 969 << " bps, start: " << config_.bitrate_config.start_bitrate_bps | 979 << " bps, start: " << config_.bitrate_config.start_bitrate_bps |
| 970 << " bps, max: " << config_.bitrate_config.start_bitrate_bps | 980 << " bps, max: " << config_.bitrate_config.start_bitrate_bps |
| 971 << " bps."; | 981 << " bps."; |
| 972 RTC_DCHECK_GT(config_.bitrate_config.start_bitrate_bps, 0); | 982 RTC_DCHECK_GT(config_.bitrate_config.start_bitrate_bps, 0); |
| 973 congestion_controller_->OnNetworkRouteChanged( | 983 send_side_congestion_controller_.OnNetworkRouteChanged( |
| 974 network_route, config_.bitrate_config.start_bitrate_bps, | 984 network_route, config_.bitrate_config.start_bitrate_bps, |
| 975 config_.bitrate_config.min_bitrate_bps, | 985 config_.bitrate_config.min_bitrate_bps, |
| 976 config_.bitrate_config.max_bitrate_bps); | 986 config_.bitrate_config.max_bitrate_bps); |
| 977 } | 987 } |
| 978 } | 988 } |
| 979 | 989 |
| 980 void Call::UpdateAggregateNetworkState() { | 990 void Call::UpdateAggregateNetworkState() { |
| 981 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 991 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 982 | 992 |
| 983 bool have_audio = false; | 993 bool have_audio = false; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 999 | 1009 |
| 1000 NetworkState aggregate_state = kNetworkDown; | 1010 NetworkState aggregate_state = kNetworkDown; |
| 1001 if ((have_video && video_network_state_ == kNetworkUp) || | 1011 if ((have_video && video_network_state_ == kNetworkUp) || |
| 1002 (have_audio && audio_network_state_ == kNetworkUp)) { | 1012 (have_audio && audio_network_state_ == kNetworkUp)) { |
| 1003 aggregate_state = kNetworkUp; | 1013 aggregate_state = kNetworkUp; |
| 1004 } | 1014 } |
| 1005 | 1015 |
| 1006 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state=" | 1016 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state=" |
| 1007 << (aggregate_state == kNetworkUp ? "up" : "down"); | 1017 << (aggregate_state == kNetworkUp ? "up" : "down"); |
| 1008 | 1018 |
| 1009 congestion_controller_->SignalNetworkState(aggregate_state); | 1019 send_side_congestion_controller_.SignalNetworkState(aggregate_state); |
| 1010 } | 1020 } |
| 1011 | 1021 |
| 1012 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { | 1022 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { |
| 1013 if (first_packet_sent_ms_ == -1) | 1023 if (first_packet_sent_ms_ == -1) |
| 1014 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); | 1024 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); |
| 1015 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, | 1025 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, |
| 1016 clock_->TimeInMilliseconds()); | 1026 clock_->TimeInMilliseconds()); |
| 1017 congestion_controller_->OnSentPacket(sent_packet); | 1027 send_side_congestion_controller_.OnSentPacket(sent_packet); |
| 1018 } | 1028 } |
| 1019 | 1029 |
| 1020 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, | 1030 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, |
| 1021 uint8_t fraction_loss, | 1031 uint8_t fraction_loss, |
| 1022 int64_t rtt_ms, | 1032 int64_t rtt_ms, |
| 1023 int64_t probing_interval_ms) { | 1033 int64_t probing_interval_ms) { |
| 1024 // TODO(perkj): Consider making sure CongestionController operates on | 1034 // TODO(perkj): Consider making sure CongestionController operates on |
| 1025 // |worker_queue_|. | 1035 // |worker_queue_|. |
| 1026 if (!worker_queue_.IsCurrent()) { | 1036 if (!worker_queue_.IsCurrent()) { |
| 1027 worker_queue_.PostTask( | 1037 worker_queue_.PostTask( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1058 } | 1068 } |
| 1059 estimated_send_bitrate_kbps_counter_.Add(target_bitrate_bps / 1000); | 1069 estimated_send_bitrate_kbps_counter_.Add(target_bitrate_bps / 1000); |
| 1060 // Pacer bitrate may be higher than bitrate estimate if enforcing min bitrate. | 1070 // Pacer bitrate may be higher than bitrate estimate if enforcing min bitrate. |
| 1061 uint32_t pacer_bitrate_bps = | 1071 uint32_t pacer_bitrate_bps = |
| 1062 std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_); | 1072 std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_); |
| 1063 pacer_bitrate_kbps_counter_.Add(pacer_bitrate_bps / 1000); | 1073 pacer_bitrate_kbps_counter_.Add(pacer_bitrate_bps / 1000); |
| 1064 } | 1074 } |
| 1065 | 1075 |
| 1066 void Call::OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps, | 1076 void Call::OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps, |
| 1067 uint32_t max_padding_bitrate_bps) { | 1077 uint32_t max_padding_bitrate_bps) { |
| 1068 congestion_controller_->SetAllocatedSendBitrateLimits( | 1078 send_side_congestion_controller_.SetAllocatedSendBitrateLimits( |
| 1069 min_send_bitrate_bps, max_padding_bitrate_bps); | 1079 min_send_bitrate_bps, max_padding_bitrate_bps); |
| 1070 rtc::CritScope lock(&bitrate_crit_); | 1080 rtc::CritScope lock(&bitrate_crit_); |
| 1071 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; | 1081 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; |
| 1072 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; | 1082 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; |
| 1073 } | 1083 } |
| 1074 | 1084 |
| 1075 void Call::ConfigureSync(const std::string& sync_group) { | 1085 void Call::ConfigureSync(const std::string& sync_group) { |
| 1076 // Set sync only if there was no previous one. | 1086 // Set sync only if there was no previous one. |
| 1077 if (sync_group.empty()) | 1087 if (sync_group.empty()) |
| 1078 return; | 1088 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 | 1281 // module in the case that some, but not all, have RTCP feedback |
| 1272 // enabled. | 1282 // enabled. |
| 1273 return; | 1283 return; |
| 1274 } | 1284 } |
| 1275 // For audio, we only support send side BWE. | 1285 // For audio, we only support send side BWE. |
| 1276 // TODO(nisse): Tests passes MediaType::ANY, see | 1286 // TODO(nisse): Tests passes MediaType::ANY, see |
| 1277 // FakeNetworkPipe::Process. We need to treat that as video. Tests | 1287 // FakeNetworkPipe::Process. We need to treat that as video. Tests |
| 1278 // should be fixed to use the same MediaType as the production code. | 1288 // should be fixed to use the same MediaType as the production code. |
| 1279 if (media_type != MediaType::AUDIO || | 1289 if (media_type != MediaType::AUDIO || |
| 1280 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { | 1290 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { |
| 1281 congestion_controller_->OnReceivedPacket( | 1291 receive_side_congestion_controller_.OnReceivedPacket( |
| 1282 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), | 1292 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), |
| 1283 header); | 1293 header); |
| 1284 } | 1294 } |
| 1285 } | 1295 } |
| 1286 | 1296 |
| 1287 } // namespace internal | 1297 } // namespace internal |
| 1288 } // namespace webrtc | 1298 } // namespace webrtc |
| OLD | NEW |