Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: webrtc/call/call.cc

Issue 2880323002: Move ownership of RtpTransportControllerSendInterface from Call to PeerConnection.
Patch Set: Delete shadowing member variables in BitrateEstimatorTest. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/call/call.h ('k') | webrtc/call/call_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } // namespace 148 } // namespace
149 149
150 namespace internal { 150 namespace internal {
151 151
152 class Call : public webrtc::Call, 152 class Call : public webrtc::Call,
153 public PacketReceiver, 153 public PacketReceiver,
154 public RecoveredPacketReceiver, 154 public RecoveredPacketReceiver,
155 public SendSideCongestionController::Observer, 155 public SendSideCongestionController::Observer,
156 public BitrateAllocator::LimitObserver { 156 public BitrateAllocator::LimitObserver {
157 public: 157 public:
158 Call(const Call::Config& config, 158 explicit Call(const Call::Config& config);
159 std::unique_ptr<RtpTransportControllerSendInterface> transport_send);
160 virtual ~Call(); 159 virtual ~Call();
161 160
162 // Implements webrtc::Call. 161 // Implements webrtc::Call.
163 PacketReceiver* Receiver() override; 162 PacketReceiver* Receiver() override;
164 163
165 webrtc::AudioSendStream* CreateAudioSendStream( 164 webrtc::AudioSendStream* CreateAudioSendStream(
166 const webrtc::AudioSendStream::Config& config) override; 165 const webrtc::AudioSendStream::Config& config) override;
167 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override; 166 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override;
168 167
169 webrtc::AudioReceiveStream* CreateAudioReceiveStream( 168 webrtc::AudioReceiveStream* CreateAudioReceiveStream(
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // TODO(holmer): Remove this lock once BitrateController no longer calls 323 // TODO(holmer): Remove this lock once BitrateController no longer calls
325 // OnNetworkChanged from multiple threads. 324 // OnNetworkChanged from multiple threads.
326 rtc::CriticalSection bitrate_crit_; 325 rtc::CriticalSection bitrate_crit_;
327 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); 326 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
328 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); 327 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
329 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); 328 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_);
330 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); 329 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_);
331 330
332 std::map<std::string, rtc::NetworkRoute> network_routes_; 331 std::map<std::string, rtc::NetworkRoute> network_routes_;
333 332
334 std::unique_ptr<RtpTransportControllerSendInterface> transport_send_;
335 ReceiveSideCongestionController receive_side_cc_; 333 ReceiveSideCongestionController receive_side_cc_;
336 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; 334 const std::unique_ptr<SendDelayStats> video_send_delay_stats_;
337 const int64_t start_ms_; 335 const int64_t start_ms_;
338 // TODO(perkj): |worker_queue_| is supposed to replace 336 // TODO(perkj): |worker_queue_| is supposed to replace
339 // |module_process_thread_|. 337 // |module_process_thread_|.
340 // |worker_queue| is defined last to ensure all pending tasks are cancelled 338 // |worker_queue| is defined last to ensure all pending tasks are cancelled
341 // and deleted before any other members. 339 // and deleted before any other members.
342 rtc::TaskQueue worker_queue_; 340 rtc::TaskQueue worker_queue_;
343 341
344 RTC_DISALLOW_COPY_AND_ASSIGN(Call); 342 RTC_DISALLOW_COPY_AND_ASSIGN(Call);
345 }; 343 };
346 } // namespace internal 344 } // namespace internal
347 345
348 std::string Call::Stats::ToString(int64_t time_ms) const { 346 std::string Call::Stats::ToString(int64_t time_ms) const {
349 std::stringstream ss; 347 std::stringstream ss;
350 ss << "Call stats: " << time_ms << ", {"; 348 ss << "Call stats: " << time_ms << ", {";
351 ss << "send_bw_bps: " << send_bandwidth_bps << ", "; 349 ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
352 ss << "recv_bw_bps: " << recv_bandwidth_bps << ", "; 350 ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
353 ss << "max_pad_bps: " << max_padding_bitrate_bps << ", "; 351 ss << "max_pad_bps: " << max_padding_bitrate_bps << ", ";
354 ss << "pacer_delay_ms: " << pacer_delay_ms << ", "; 352 ss << "pacer_delay_ms: " << pacer_delay_ms << ", ";
355 ss << "rtt_ms: " << rtt_ms; 353 ss << "rtt_ms: " << rtt_ms;
356 ss << '}'; 354 ss << '}';
357 return ss.str(); 355 return ss.str();
358 } 356 }
359 357
360 Call* Call::Create(const Call::Config& config) { 358 Call* Call::Create(const Call::Config& config) {
361 return new internal::Call(config, 359 return new internal::Call(config);
362 rtc::MakeUnique<RtpTransportControllerSend>(
363 Clock::GetRealTimeClock(), config.event_log));
364 }
365
366 Call* Call::Create(
367 const Call::Config& config,
368 std::unique_ptr<RtpTransportControllerSendInterface> transport_send) {
369 return new internal::Call(config, std::move(transport_send));
370 } 360 }
371 361
372 namespace internal { 362 namespace internal {
373 363
374 Call::Call(const Call::Config& config, 364 Call::Call(const Call::Config& config)
375 std::unique_ptr<RtpTransportControllerSendInterface> transport_send)
376 : clock_(Clock::GetRealTimeClock()), 365 : clock_(Clock::GetRealTimeClock()),
377 num_cpu_cores_(CpuInfo::DetectNumberOfCores()), 366 num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
378 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), 367 module_process_thread_(ProcessThread::Create("ModuleProcessThread")),
379 pacer_thread_(ProcessThread::Create("PacerThread")), 368 pacer_thread_(ProcessThread::Create("PacerThread")),
380 call_stats_(new CallStats(clock_)), 369 call_stats_(new CallStats(clock_)),
381 bitrate_allocator_(new BitrateAllocator(this)), 370 bitrate_allocator_(new BitrateAllocator(this)),
382 config_(config), 371 config_(config),
383 audio_network_state_(kNetworkDown), 372 audio_network_state_(kNetworkDown),
384 video_network_state_(kNetworkDown), 373 video_network_state_(kNetworkDown),
385 receive_crit_(RWLockWrapper::CreateRWLock()), 374 receive_crit_(RWLockWrapper::CreateRWLock()),
386 send_crit_(RWLockWrapper::CreateRWLock()), 375 send_crit_(RWLockWrapper::CreateRWLock()),
387 event_log_(config.event_log), 376 event_log_(config.event_log),
388 received_bytes_per_second_counter_(clock_, nullptr, true), 377 received_bytes_per_second_counter_(clock_, nullptr, true),
389 received_audio_bytes_per_second_counter_(clock_, nullptr, true), 378 received_audio_bytes_per_second_counter_(clock_, nullptr, true),
390 received_video_bytes_per_second_counter_(clock_, nullptr, true), 379 received_video_bytes_per_second_counter_(clock_, nullptr, true),
391 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), 380 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true),
392 min_allocated_send_bitrate_bps_(0), 381 min_allocated_send_bitrate_bps_(0),
393 configured_max_padding_bitrate_bps_(0), 382 configured_max_padding_bitrate_bps_(0),
394 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), 383 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true),
395 pacer_bitrate_kbps_counter_(clock_, nullptr, true), 384 pacer_bitrate_kbps_counter_(clock_, nullptr, true),
396 receive_side_cc_(clock_, transport_send->packet_router()), 385 // TODO(nisse): Always uses the video transport for now.
386 // receive_side_cc_ ownership should be moved to the
387 // corresponding RtpTransportControllerReceiveInterface.
388 receive_side_cc_(clock_,
389 config.video_rtp_transport_send->packet_router()),
397 video_send_delay_stats_(new SendDelayStats(clock_)), 390 video_send_delay_stats_(new SendDelayStats(clock_)),
398 start_ms_(clock_->TimeInMilliseconds()), 391 start_ms_(clock_->TimeInMilliseconds()),
399 worker_queue_("call_worker_queue") { 392 worker_queue_("call_worker_queue") {
400 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 393 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
401 RTC_DCHECK(config.event_log != nullptr); 394 RTC_DCHECK(config.event_log != nullptr);
402 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); 395 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
403 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, 396 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps,
404 config.bitrate_config.min_bitrate_bps); 397 config.bitrate_config.min_bitrate_bps);
405 if (config.bitrate_config.max_bitrate_bps != -1) { 398 if (config.bitrate_config.max_bitrate_bps != -1) {
406 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, 399 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
407 config.bitrate_config.start_bitrate_bps); 400 config.bitrate_config.start_bitrate_bps);
408 } 401 }
409 Trace::CreateTrace(); 402 Trace::CreateTrace();
410 transport_send->send_side_cc()->RegisterNetworkObserver(this); 403 config.send_side_cc->RegisterNetworkObserver(this);
411 transport_send_ = std::move(transport_send); 404 config.send_side_cc->SignalNetworkState(kNetworkDown);
412 transport_send_->send_side_cc()->SignalNetworkState(kNetworkDown); 405 // TODO(nisse): Move this to caller.
413 transport_send_->send_side_cc()->SetBweBitrates( 406 config.send_side_cc->SetBweBitrates(
414 config_.bitrate_config.min_bitrate_bps, 407 config.bitrate_config.min_bitrate_bps,
415 config_.bitrate_config.start_bitrate_bps, 408 config.bitrate_config.start_bitrate_bps,
416 config_.bitrate_config.max_bitrate_bps); 409 config.bitrate_config.max_bitrate_bps);
417 call_stats_->RegisterStatsObserver(&receive_side_cc_); 410 call_stats_->RegisterStatsObserver(&receive_side_cc_);
418 call_stats_->RegisterStatsObserver(transport_send_->send_side_cc()); 411 call_stats_->RegisterStatsObserver(config.send_side_cc);
419 412
420 module_process_thread_->Start(); 413 module_process_thread_->Start();
421 module_process_thread_->RegisterModule(call_stats_.get(), RTC_FROM_HERE); 414 module_process_thread_->RegisterModule(call_stats_.get(), RTC_FROM_HERE);
422 module_process_thread_->RegisterModule(&receive_side_cc_, RTC_FROM_HERE); 415 module_process_thread_->RegisterModule(&receive_side_cc_, RTC_FROM_HERE);
423 module_process_thread_->RegisterModule(transport_send_->send_side_cc(), 416 module_process_thread_->RegisterModule(config.send_side_cc, RTC_FROM_HERE);
424 RTC_FROM_HERE); 417 pacer_thread_->RegisterModule(config.send_side_cc->pacer(), RTC_FROM_HERE);
425 pacer_thread_->RegisterModule(transport_send_->send_side_cc()->pacer(),
426 RTC_FROM_HERE);
427 pacer_thread_->RegisterModule( 418 pacer_thread_->RegisterModule(
428 receive_side_cc_.GetRemoteBitrateEstimator(true), RTC_FROM_HERE); 419 receive_side_cc_.GetRemoteBitrateEstimator(true), RTC_FROM_HERE);
429 420
430 pacer_thread_->Start(); 421 pacer_thread_->Start();
431 } 422 }
432 423
433 Call::~Call() { 424 Call::~Call() {
434 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 425 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
435 426
436 RTC_CHECK(audio_send_ssrcs_.empty()); 427 RTC_CHECK(audio_send_ssrcs_.empty());
437 RTC_CHECK(video_send_ssrcs_.empty()); 428 RTC_CHECK(video_send_ssrcs_.empty());
438 RTC_CHECK(video_send_streams_.empty()); 429 RTC_CHECK(video_send_streams_.empty());
439 RTC_CHECK(audio_receive_streams_.empty()); 430 RTC_CHECK(audio_receive_streams_.empty());
440 RTC_CHECK(video_receive_streams_.empty()); 431 RTC_CHECK(video_receive_streams_.empty());
441 432
442 pacer_thread_->Stop(); 433 pacer_thread_->Stop();
443 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer()); 434 pacer_thread_->DeRegisterModule(config_.send_side_cc->pacer());
444 pacer_thread_->DeRegisterModule( 435 pacer_thread_->DeRegisterModule(
445 receive_side_cc_.GetRemoteBitrateEstimator(true)); 436 receive_side_cc_.GetRemoteBitrateEstimator(true));
446 module_process_thread_->DeRegisterModule(transport_send_->send_side_cc()); 437 module_process_thread_->DeRegisterModule(config_.send_side_cc);
447 module_process_thread_->DeRegisterModule(&receive_side_cc_); 438 module_process_thread_->DeRegisterModule(&receive_side_cc_);
448 module_process_thread_->DeRegisterModule(call_stats_.get()); 439 module_process_thread_->DeRegisterModule(call_stats_.get());
449 module_process_thread_->Stop(); 440 module_process_thread_->Stop();
450 call_stats_->DeregisterStatsObserver(&receive_side_cc_); 441 call_stats_->DeregisterStatsObserver(&receive_side_cc_);
451 call_stats_->DeregisterStatsObserver(transport_send_->send_side_cc()); 442 call_stats_->DeregisterStatsObserver(config_.send_side_cc);
452 443
453 int64_t first_sent_packet_ms = 444 int64_t first_sent_packet_ms =
454 transport_send_->send_side_cc()->GetFirstPacketTimeMs(); 445 config_.send_side_cc->GetFirstPacketTimeMs();
455 // Only update histograms after process threads have been shut down, so that 446 // Only update histograms after process threads have been shut down, so that
456 // they won't try to concurrently update stats. 447 // they won't try to concurrently update stats.
457 { 448 {
458 rtc::CritScope lock(&bitrate_crit_); 449 rtc::CritScope lock(&bitrate_crit_);
459 UpdateSendHistograms(first_sent_packet_ms); 450 UpdateSendHistograms(first_sent_packet_ms);
460 } 451 }
461 UpdateReceiveHistograms(); 452 UpdateReceiveHistograms();
462 UpdateHistograms(); 453 UpdateHistograms();
463 454
464 Trace::ReturnTrace(); 455 Trace::ReturnTrace();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 561
571 rtc::Optional<RtpState> suspended_rtp_state; 562 rtc::Optional<RtpState> suspended_rtp_state;
572 { 563 {
573 const auto& iter = suspended_audio_send_ssrcs_.find(config.rtp.ssrc); 564 const auto& iter = suspended_audio_send_ssrcs_.find(config.rtp.ssrc);
574 if (iter != suspended_audio_send_ssrcs_.end()) { 565 if (iter != suspended_audio_send_ssrcs_.end()) {
575 suspended_rtp_state.emplace(iter->second); 566 suspended_rtp_state.emplace(iter->second);
576 } 567 }
577 } 568 }
578 569
579 AudioSendStream* send_stream = new AudioSendStream( 570 AudioSendStream* send_stream = new AudioSendStream(
580 config, config_.audio_state, &worker_queue_, transport_send_.get(), 571 config, config_.audio_state, &worker_queue_,
572 config_.audio_rtp_transport_send,
581 bitrate_allocator_.get(), event_log_, call_stats_->rtcp_rtt_stats(), 573 bitrate_allocator_.get(), event_log_, call_stats_->rtcp_rtt_stats(),
582 suspended_rtp_state); 574 suspended_rtp_state);
583 { 575 {
584 WriteLockScoped write_lock(*send_crit_); 576 WriteLockScoped write_lock(*send_crit_);
585 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == 577 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) ==
586 audio_send_ssrcs_.end()); 578 audio_send_ssrcs_.end());
587 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; 579 audio_send_ssrcs_[config.rtp.ssrc] = send_stream;
588 } 580 }
589 { 581 {
590 ReadLockScoped read_lock(*receive_crit_); 582 ReadLockScoped read_lock(*receive_crit_);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 UpdateAggregateNetworkState(); 618 UpdateAggregateNetworkState();
627 delete audio_send_stream; 619 delete audio_send_stream;
628 } 620 }
629 621
630 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( 622 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
631 const webrtc::AudioReceiveStream::Config& config) { 623 const webrtc::AudioReceiveStream::Config& config) {
632 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); 624 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
633 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 625 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
634 event_log_->LogAudioReceiveStreamConfig(CreateRtcLogStreamConfig(config)); 626 event_log_->LogAudioReceiveStreamConfig(CreateRtcLogStreamConfig(config));
635 AudioReceiveStream* receive_stream = 627 AudioReceiveStream* receive_stream =
636 new AudioReceiveStream(transport_send_->packet_router(), config, 628 new AudioReceiveStream(config_.audio_rtp_transport_send->packet_router(),
629 config,
637 config_.audio_state, event_log_); 630 config_.audio_state, event_log_);
638 { 631 {
639 WriteLockScoped write_lock(*receive_crit_); 632 WriteLockScoped write_lock(*receive_crit_);
640 audio_rtp_demuxer_.AddSink(config.rtp.remote_ssrc, receive_stream); 633 audio_rtp_demuxer_.AddSink(config.rtp.remote_ssrc, receive_stream);
641 receive_rtp_config_[config.rtp.remote_ssrc] = 634 receive_rtp_config_[config.rtp.remote_ssrc] =
642 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config)); 635 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config));
643 audio_receive_streams_.insert(receive_stream); 636 audio_receive_streams_.insert(receive_stream);
644 637
645 ConfigureSync(config.sync_group); 638 ConfigureSync(config.sync_group);
646 } 639 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 event_log_->LogVideoSendStreamConfig( 690 event_log_->LogVideoSendStreamConfig(
698 CreateRtcLogStreamConfig(config, ssrc_index)); 691 CreateRtcLogStreamConfig(config, ssrc_index));
699 } 692 }
700 693
701 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if 694 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
702 // the call has already started. 695 // the call has already started.
703 // Copy ssrcs from |config| since |config| is moved. 696 // Copy ssrcs from |config| since |config| is moved.
704 std::vector<uint32_t> ssrcs = config.rtp.ssrcs; 697 std::vector<uint32_t> ssrcs = config.rtp.ssrcs;
705 VideoSendStream* send_stream = new VideoSendStream( 698 VideoSendStream* send_stream = new VideoSendStream(
706 num_cpu_cores_, module_process_thread_.get(), &worker_queue_, 699 num_cpu_cores_, module_process_thread_.get(), &worker_queue_,
707 call_stats_.get(), transport_send_.get(), bitrate_allocator_.get(), 700 call_stats_.get(), config_.video_rtp_transport_send,
701 bitrate_allocator_.get(),
708 video_send_delay_stats_.get(), event_log_, std::move(config), 702 video_send_delay_stats_.get(), event_log_, std::move(config),
709 std::move(encoder_config), suspended_video_send_ssrcs_); 703 std::move(encoder_config), suspended_video_send_ssrcs_);
710 704
711 { 705 {
712 WriteLockScoped write_lock(*send_crit_); 706 WriteLockScoped write_lock(*send_crit_);
713 for (uint32_t ssrc : ssrcs) { 707 for (uint32_t ssrc : ssrcs) {
714 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); 708 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
715 video_send_ssrcs_[ssrc] = send_stream; 709 video_send_ssrcs_[ssrc] = send_stream;
716 } 710 }
717 video_send_streams_.insert(send_stream); 711 video_send_streams_.insert(send_stream);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 UpdateAggregateNetworkState(); 750 UpdateAggregateNetworkState();
757 delete send_stream_impl; 751 delete send_stream_impl;
758 } 752 }
759 753
760 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( 754 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream(
761 webrtc::VideoReceiveStream::Config configuration) { 755 webrtc::VideoReceiveStream::Config configuration) {
762 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); 756 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream");
763 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 757 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
764 758
765 VideoReceiveStream* receive_stream = 759 VideoReceiveStream* receive_stream =
766 new VideoReceiveStream(num_cpu_cores_, transport_send_->packet_router(), 760 new VideoReceiveStream(num_cpu_cores_,
761 config_.video_rtp_transport_send->packet_router(),
767 std::move(configuration), 762 std::move(configuration),
768 module_process_thread_.get(), call_stats_.get()); 763 module_process_thread_.get(), call_stats_.get());
769 764
770 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); 765 const webrtc::VideoReceiveStream::Config& config = receive_stream->config();
771 ReceiveRtpConfig receive_config(config.rtp.extensions, 766 ReceiveRtpConfig receive_config(config.rtp.extensions,
772 UseSendSideBwe(config)); 767 UseSendSideBwe(config));
773 { 768 {
774 WriteLockScoped write_lock(*receive_crit_); 769 WriteLockScoped write_lock(*receive_crit_);
775 video_rtp_demuxer_.AddSink(config.rtp.remote_ssrc, receive_stream); 770 video_rtp_demuxer_.AddSink(config.rtp.remote_ssrc, receive_stream);
776 if (config.rtp.rtx_ssrc) { 771 if (config.rtp.rtx_ssrc) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 delete receive_stream_impl; 870 delete receive_stream_impl;
876 } 871 }
877 872
878 Call::Stats Call::GetStats() const { 873 Call::Stats Call::GetStats() const {
879 // TODO(solenberg): Some test cases in EndToEndTest use this from a different 874 // TODO(solenberg): Some test cases in EndToEndTest use this from a different
880 // thread. Re-enable once that is fixed. 875 // thread. Re-enable once that is fixed.
881 // RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 876 // RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
882 Stats stats; 877 Stats stats;
883 // Fetch available send/receive bitrates. 878 // Fetch available send/receive bitrates.
884 uint32_t send_bandwidth = 0; 879 uint32_t send_bandwidth = 0;
885 transport_send_->send_side_cc()->GetBitrateController()->AvailableBandwidth( 880 config_.send_side_cc->GetBitrateController()->AvailableBandwidth(
886 &send_bandwidth); 881 &send_bandwidth);
887 std::vector<unsigned int> ssrcs; 882 std::vector<unsigned int> ssrcs;
888 uint32_t recv_bandwidth = 0; 883 uint32_t recv_bandwidth = 0;
889 receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate( 884 receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate(
890 &ssrcs, &recv_bandwidth); 885 &ssrcs, &recv_bandwidth);
891 stats.send_bandwidth_bps = send_bandwidth; 886 stats.send_bandwidth_bps = send_bandwidth;
892 stats.recv_bandwidth_bps = recv_bandwidth; 887 stats.recv_bandwidth_bps = recv_bandwidth;
893 stats.pacer_delay_ms = 888 stats.pacer_delay_ms =
894 transport_send_->send_side_cc()->GetPacerQueuingDelayMs(); 889 config_.send_side_cc->GetPacerQueuingDelayMs();
895 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); 890 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt();
896 { 891 {
897 rtc::CritScope cs(&bitrate_crit_); 892 rtc::CritScope cs(&bitrate_crit_);
898 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_; 893 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_;
899 } 894 }
900 return stats; 895 return stats;
901 } 896 }
902 897
903 void Call::SetBitrateConfig( 898 void Call::SetBitrateConfig(
904 const webrtc::Call::Config::BitrateConfig& bitrate_config) { 899 const webrtc::Call::Config::BitrateConfig& bitrate_config) {
(...skipping 12 matching lines...) Expand all
917 // Nothing new to set, early abort to avoid encoder reconfigurations. 912 // Nothing new to set, early abort to avoid encoder reconfigurations.
918 return; 913 return;
919 } 914 }
920 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps; 915 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps;
921 // Start bitrate of -1 means we should keep the old bitrate, which there is 916 // Start bitrate of -1 means we should keep the old bitrate, which there is
922 // no point in remembering for the future. 917 // no point in remembering for the future.
923 if (bitrate_config.start_bitrate_bps > 0) 918 if (bitrate_config.start_bitrate_bps > 0)
924 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps; 919 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps;
925 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps; 920 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps;
926 RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0); 921 RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0);
927 transport_send_->send_side_cc()->SetBweBitrates( 922 config_.send_side_cc->SetBweBitrates(
928 bitrate_config.min_bitrate_bps, bitrate_config.start_bitrate_bps, 923 bitrate_config.min_bitrate_bps, bitrate_config.start_bitrate_bps,
929 bitrate_config.max_bitrate_bps); 924 bitrate_config.max_bitrate_bps);
930 } 925 }
931 926
932 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { 927 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) {
933 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 928 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
934 switch (media) { 929 switch (media) {
935 case MediaType::AUDIO: 930 case MediaType::AUDIO:
936 audio_network_state_ = state; 931 audio_network_state_ = state;
937 break; 932 break;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 kv->second = network_route; 1009 kv->second = network_route;
1015 LOG(LS_INFO) << "Network route changed on transport " << transport_name 1010 LOG(LS_INFO) << "Network route changed on transport " << transport_name
1016 << ": new local network id " << network_route.local_network_id 1011 << ": new local network id " << network_route.local_network_id
1017 << " new remote network id " << network_route.remote_network_id 1012 << " new remote network id " << network_route.remote_network_id
1018 << " Reset bitrates to min: " 1013 << " Reset bitrates to min: "
1019 << config_.bitrate_config.min_bitrate_bps 1014 << config_.bitrate_config.min_bitrate_bps
1020 << " bps, start: " << config_.bitrate_config.start_bitrate_bps 1015 << " bps, start: " << config_.bitrate_config.start_bitrate_bps
1021 << " bps, max: " << config_.bitrate_config.start_bitrate_bps 1016 << " bps, max: " << config_.bitrate_config.start_bitrate_bps
1022 << " bps."; 1017 << " bps.";
1023 RTC_DCHECK_GT(config_.bitrate_config.start_bitrate_bps, 0); 1018 RTC_DCHECK_GT(config_.bitrate_config.start_bitrate_bps, 0);
1024 transport_send_->send_side_cc()->OnNetworkRouteChanged( 1019 config_.send_side_cc->OnNetworkRouteChanged(
1025 network_route, config_.bitrate_config.start_bitrate_bps, 1020 network_route, config_.bitrate_config.start_bitrate_bps,
1026 config_.bitrate_config.min_bitrate_bps, 1021 config_.bitrate_config.min_bitrate_bps,
1027 config_.bitrate_config.max_bitrate_bps); 1022 config_.bitrate_config.max_bitrate_bps);
1028 } 1023 }
1029 } 1024 }
1030 1025
1031 void Call::UpdateAggregateNetworkState() { 1026 void Call::UpdateAggregateNetworkState() {
1032 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 1027 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
1033 1028
1034 bool have_audio = false; 1029 bool have_audio = false;
(...skipping 15 matching lines...) Expand all
1050 1045
1051 NetworkState aggregate_state = kNetworkDown; 1046 NetworkState aggregate_state = kNetworkDown;
1052 if ((have_video && video_network_state_ == kNetworkUp) || 1047 if ((have_video && video_network_state_ == kNetworkUp) ||
1053 (have_audio && audio_network_state_ == kNetworkUp)) { 1048 (have_audio && audio_network_state_ == kNetworkUp)) {
1054 aggregate_state = kNetworkUp; 1049 aggregate_state = kNetworkUp;
1055 } 1050 }
1056 1051
1057 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state=" 1052 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state="
1058 << (aggregate_state == kNetworkUp ? "up" : "down"); 1053 << (aggregate_state == kNetworkUp ? "up" : "down");
1059 1054
1060 transport_send_->send_side_cc()->SignalNetworkState(aggregate_state); 1055 config_.send_side_cc->SignalNetworkState(aggregate_state);
1061 } 1056 }
1062 1057
1063 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { 1058 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) {
1064 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, 1059 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id,
1065 clock_->TimeInMilliseconds()); 1060 clock_->TimeInMilliseconds());
1066 transport_send_->send_side_cc()->OnSentPacket(sent_packet); 1061 config_.send_side_cc->OnSentPacket(sent_packet);
1067 } 1062 }
1068 1063
1069 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, 1064 void Call::OnNetworkChanged(uint32_t target_bitrate_bps,
1070 uint8_t fraction_loss, 1065 uint8_t fraction_loss,
1071 int64_t rtt_ms, 1066 int64_t rtt_ms,
1072 int64_t probing_interval_ms) { 1067 int64_t probing_interval_ms) {
1073 // TODO(perkj): Consider making sure CongestionController operates on 1068 // TODO(perkj): Consider making sure CongestionController operates on
1074 // |worker_queue_|. 1069 // |worker_queue_|.
1075 if (!worker_queue_.IsCurrent()) { 1070 if (!worker_queue_.IsCurrent()) {
1076 worker_queue_.PostTask( 1071 worker_queue_.PostTask(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 } 1104 }
1110 estimated_send_bitrate_kbps_counter_.Add(target_bitrate_bps / 1000); 1105 estimated_send_bitrate_kbps_counter_.Add(target_bitrate_bps / 1000);
1111 // Pacer bitrate may be higher than bitrate estimate if enforcing min bitrate. 1106 // Pacer bitrate may be higher than bitrate estimate if enforcing min bitrate.
1112 uint32_t pacer_bitrate_bps = 1107 uint32_t pacer_bitrate_bps =
1113 std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_); 1108 std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_);
1114 pacer_bitrate_kbps_counter_.Add(pacer_bitrate_bps / 1000); 1109 pacer_bitrate_kbps_counter_.Add(pacer_bitrate_bps / 1000);
1115 } 1110 }
1116 1111
1117 void Call::OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps, 1112 void Call::OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps,
1118 uint32_t max_padding_bitrate_bps) { 1113 uint32_t max_padding_bitrate_bps) {
1119 transport_send_->send_side_cc()->SetAllocatedSendBitrateLimits( 1114 config_.send_side_cc->SetAllocatedSendBitrateLimits(
1120 min_send_bitrate_bps, max_padding_bitrate_bps); 1115 min_send_bitrate_bps, max_padding_bitrate_bps);
1121 rtc::CritScope lock(&bitrate_crit_); 1116 rtc::CritScope lock(&bitrate_crit_);
1122 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; 1117 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps;
1123 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; 1118 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps;
1124 } 1119 }
1125 1120
1126 void Call::ConfigureSync(const std::string& sync_group) { 1121 void Call::ConfigureSync(const std::string& sync_group) {
1127 // Set sync only if there was no previous one. 1122 // Set sync only if there was no previous one.
1128 if (sync_group.empty()) 1123 if (sync_group.empty())
1129 return; 1124 return;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { 1304 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) {
1310 receive_side_cc_.OnReceivedPacket( 1305 receive_side_cc_.OnReceivedPacket(
1311 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), 1306 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(),
1312 header); 1307 header);
1313 } 1308 }
1314 } 1309 }
1315 1310
1316 } // namespace internal 1311 } // namespace internal
1317 1312
1318 } // namespace webrtc 1313 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/call.h ('k') | webrtc/call/call_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698