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

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

Issue 2887733002: Store/restore RTP state for audio streams with same SSRC within a call (Closed)
Patch Set: Rebasement Jaxx Created 3 years, 7 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/BUILD.gn ('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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 }; 298 };
299 std::map<uint32_t, ReceiveRtpConfig> receive_rtp_config_ 299 std::map<uint32_t, ReceiveRtpConfig> receive_rtp_config_
300 GUARDED_BY(receive_crit_); 300 GUARDED_BY(receive_crit_);
301 301
302 std::unique_ptr<RWLockWrapper> send_crit_; 302 std::unique_ptr<RWLockWrapper> send_crit_;
303 // Audio and Video send streams are owned by the client that creates them. 303 // Audio and Video send streams are owned by the client that creates them.
304 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); 304 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_);
305 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); 305 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_);
306 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); 306 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_);
307 307
308 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; 308 using RtpStateMap = std::map<uint32_t, RtpState>;
309 RtpStateMap suspended_audio_send_ssrcs_
310 GUARDED_BY(configuration_thread_checker_);
311 RtpStateMap suspended_video_send_ssrcs_
312 GUARDED_BY(configuration_thread_checker_);
313
309 webrtc::RtcEventLog* event_log_; 314 webrtc::RtcEventLog* event_log_;
310 315
311 // The following members are only accessed (exclusively) from one thread and 316 // The following members are only accessed (exclusively) from one thread and
312 // from the destructor, and therefore doesn't need any explicit 317 // from the destructor, and therefore doesn't need any explicit
313 // synchronization. 318 // synchronization.
314 RateCounter received_bytes_per_second_counter_; 319 RateCounter received_bytes_per_second_counter_;
315 RateCounter received_audio_bytes_per_second_counter_; 320 RateCounter received_audio_bytes_per_second_counter_;
316 RateCounter received_video_bytes_per_second_counter_; 321 RateCounter received_video_bytes_per_second_counter_;
317 RateCounter received_rtcp_bytes_per_second_counter_; 322 RateCounter received_rtcp_bytes_per_second_counter_;
318 323
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 received_video_bytes_per_second_counter_(clock_, nullptr, true), 390 received_video_bytes_per_second_counter_(clock_, nullptr, true),
386 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), 391 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true),
387 min_allocated_send_bitrate_bps_(0), 392 min_allocated_send_bitrate_bps_(0),
388 configured_max_padding_bitrate_bps_(0), 393 configured_max_padding_bitrate_bps_(0),
389 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), 394 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true),
390 pacer_bitrate_kbps_counter_(clock_, nullptr, true), 395 pacer_bitrate_kbps_counter_(clock_, nullptr, true),
391 receive_side_cc_(clock_, transport_send->packet_router()), 396 receive_side_cc_(clock_, transport_send->packet_router()),
392 video_send_delay_stats_(new SendDelayStats(clock_)), 397 video_send_delay_stats_(new SendDelayStats(clock_)),
393 start_ms_(clock_->TimeInMilliseconds()), 398 start_ms_(clock_->TimeInMilliseconds()),
394 worker_queue_("call_worker_queue") { 399 worker_queue_("call_worker_queue") {
395 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 400 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
396 RTC_DCHECK(config.event_log != nullptr); 401 RTC_DCHECK(config.event_log != nullptr);
397 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); 402 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
398 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, 403 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps,
399 config.bitrate_config.min_bitrate_bps); 404 config.bitrate_config.min_bitrate_bps);
400 if (config.bitrate_config.max_bitrate_bps != -1) { 405 if (config.bitrate_config.max_bitrate_bps != -1) {
401 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, 406 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
402 config.bitrate_config.start_bitrate_bps); 407 config.bitrate_config.start_bitrate_bps);
403 } 408 }
404 Trace::CreateTrace(); 409 Trace::CreateTrace();
405 transport_send->send_side_cc()->RegisterNetworkObserver(this); 410 transport_send->send_side_cc()->RegisterNetworkObserver(this);
(...skipping 13 matching lines...) Expand all
419 RTC_FROM_HERE); 424 RTC_FROM_HERE);
420 pacer_thread_->RegisterModule(transport_send_->send_side_cc()->pacer(), 425 pacer_thread_->RegisterModule(transport_send_->send_side_cc()->pacer(),
421 RTC_FROM_HERE); 426 RTC_FROM_HERE);
422 pacer_thread_->RegisterModule( 427 pacer_thread_->RegisterModule(
423 receive_side_cc_.GetRemoteBitrateEstimator(true), RTC_FROM_HERE); 428 receive_side_cc_.GetRemoteBitrateEstimator(true), RTC_FROM_HERE);
424 429
425 pacer_thread_->Start(); 430 pacer_thread_->Start();
426 } 431 }
427 432
428 Call::~Call() { 433 Call::~Call() {
429 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 434 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
430 435
431 RTC_CHECK(audio_send_ssrcs_.empty()); 436 RTC_CHECK(audio_send_ssrcs_.empty());
432 RTC_CHECK(video_send_ssrcs_.empty()); 437 RTC_CHECK(video_send_ssrcs_.empty());
433 RTC_CHECK(video_send_streams_.empty()); 438 RTC_CHECK(video_send_streams_.empty());
434 RTC_CHECK(audio_receive_streams_.empty()); 439 RTC_CHECK(audio_receive_streams_.empty());
435 RTC_CHECK(video_receive_streams_.empty()); 440 RTC_CHECK(video_receive_streams_.empty());
436 441
437 pacer_thread_->Stop(); 442 pacer_thread_->Stop();
438 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer()); 443 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer());
439 pacer_thread_->DeRegisterModule( 444 pacer_thread_->DeRegisterModule(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Call.BitrateReceivedInKbps", 551 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Call.BitrateReceivedInKbps",
547 recv_bytes_per_sec.average * 8 / 1000); 552 recv_bytes_per_sec.average * 8 / 1000);
548 LOG(LS_INFO) << "WebRTC.Call.BitrateReceivedInBps, " 553 LOG(LS_INFO) << "WebRTC.Call.BitrateReceivedInBps, "
549 << recv_bytes_per_sec.ToStringWithMultiplier(8); 554 << recv_bytes_per_sec.ToStringWithMultiplier(8);
550 } 555 }
551 } 556 }
552 557
553 PacketReceiver* Call::Receiver() { 558 PacketReceiver* Call::Receiver() {
554 // TODO(solenberg): Some test cases in EndToEndTest use this from a different 559 // TODO(solenberg): Some test cases in EndToEndTest use this from a different
555 // thread. Re-enable once that is fixed. 560 // thread. Re-enable once that is fixed.
556 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 561 // RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
557 return this; 562 return this;
558 } 563 }
559 564
560 webrtc::AudioSendStream* Call::CreateAudioSendStream( 565 webrtc::AudioSendStream* Call::CreateAudioSendStream(
561 const webrtc::AudioSendStream::Config& config) { 566 const webrtc::AudioSendStream::Config& config) {
562 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); 567 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream");
563 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 568 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
564 event_log_->LogAudioSendStreamConfig(CreateRtcLogStreamConfig(config)); 569 event_log_->LogAudioSendStreamConfig(CreateRtcLogStreamConfig(config));
570
571 rtc::Optional<RtpState> suspended_rtp_state;
572 {
573 const auto& iter = suspended_audio_send_ssrcs_.find(config.rtp.ssrc);
574 if (iter != suspended_audio_send_ssrcs_.end()) {
575 suspended_rtp_state.emplace(iter->second);
576 }
577 }
578
565 AudioSendStream* send_stream = new AudioSendStream( 579 AudioSendStream* send_stream = new AudioSendStream(
566 config, config_.audio_state, &worker_queue_, transport_send_.get(), 580 config, config_.audio_state, &worker_queue_, transport_send_.get(),
567 bitrate_allocator_.get(), event_log_, call_stats_->rtcp_rtt_stats()); 581 bitrate_allocator_.get(), event_log_, call_stats_->rtcp_rtt_stats(),
582 suspended_rtp_state);
568 { 583 {
569 WriteLockScoped write_lock(*send_crit_); 584 WriteLockScoped write_lock(*send_crit_);
570 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == 585 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) ==
571 audio_send_ssrcs_.end()); 586 audio_send_ssrcs_.end());
572 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; 587 audio_send_ssrcs_[config.rtp.ssrc] = send_stream;
573 } 588 }
574 { 589 {
575 ReadLockScoped read_lock(*receive_crit_); 590 ReadLockScoped read_lock(*receive_crit_);
576 for (AudioReceiveStream* stream : audio_receive_streams_) { 591 for (AudioReceiveStream* stream : audio_receive_streams_) {
577 if (stream->config().rtp.local_ssrc == config.rtp.ssrc) { 592 if (stream->config().rtp.local_ssrc == config.rtp.ssrc) {
578 stream->AssociateSendStream(send_stream); 593 stream->AssociateSendStream(send_stream);
579 } 594 }
580 } 595 }
581 } 596 }
582 send_stream->SignalNetworkState(audio_network_state_); 597 send_stream->SignalNetworkState(audio_network_state_);
583 UpdateAggregateNetworkState(); 598 UpdateAggregateNetworkState();
584 return send_stream; 599 return send_stream;
585 } 600 }
586 601
587 void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { 602 void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) {
588 TRACE_EVENT0("webrtc", "Call::DestroyAudioSendStream"); 603 TRACE_EVENT0("webrtc", "Call::DestroyAudioSendStream");
589 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 604 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
590 RTC_DCHECK(send_stream != nullptr); 605 RTC_DCHECK(send_stream != nullptr);
591 606
592 send_stream->Stop(); 607 send_stream->Stop();
593 608
594 webrtc::internal::AudioSendStream* audio_send_stream = 609 webrtc::internal::AudioSendStream* audio_send_stream =
595 static_cast<webrtc::internal::AudioSendStream*>(send_stream); 610 static_cast<webrtc::internal::AudioSendStream*>(send_stream);
596 uint32_t ssrc = audio_send_stream->config().rtp.ssrc; 611 const uint32_t ssrc = audio_send_stream->config().rtp.ssrc;
612 suspended_audio_send_ssrcs_[ssrc] = audio_send_stream->GetRtpState();
597 { 613 {
598 WriteLockScoped write_lock(*send_crit_); 614 WriteLockScoped write_lock(*send_crit_);
599 size_t num_deleted = audio_send_ssrcs_.erase(ssrc); 615 size_t num_deleted = audio_send_ssrcs_.erase(ssrc);
600 RTC_DCHECK_EQ(1, num_deleted); 616 RTC_DCHECK_EQ(1, num_deleted);
601 } 617 }
602 { 618 {
603 ReadLockScoped read_lock(*receive_crit_); 619 ReadLockScoped read_lock(*receive_crit_);
604 for (AudioReceiveStream* stream : audio_receive_streams_) { 620 for (AudioReceiveStream* stream : audio_receive_streams_) {
605 if (stream->config().rtp.local_ssrc == ssrc) { 621 if (stream->config().rtp.local_ssrc == ssrc) {
606 stream->AssociateSendStream(nullptr); 622 stream->AssociateSendStream(nullptr);
607 } 623 }
608 } 624 }
609 } 625 }
610 UpdateAggregateNetworkState(); 626 UpdateAggregateNetworkState();
611 delete audio_send_stream; 627 delete audio_send_stream;
612 } 628 }
613 629
614 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( 630 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
615 const webrtc::AudioReceiveStream::Config& config) { 631 const webrtc::AudioReceiveStream::Config& config) {
616 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); 632 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
617 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 633 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
618 event_log_->LogAudioReceiveStreamConfig(CreateRtcLogStreamConfig(config)); 634 event_log_->LogAudioReceiveStreamConfig(CreateRtcLogStreamConfig(config));
619 AudioReceiveStream* receive_stream = 635 AudioReceiveStream* receive_stream =
620 new AudioReceiveStream(transport_send_->packet_router(), config, 636 new AudioReceiveStream(transport_send_->packet_router(), config,
621 config_.audio_state, event_log_); 637 config_.audio_state, event_log_);
622 { 638 {
623 WriteLockScoped write_lock(*receive_crit_); 639 WriteLockScoped write_lock(*receive_crit_);
624 audio_rtp_demuxer_.AddSink(config.rtp.remote_ssrc, receive_stream); 640 audio_rtp_demuxer_.AddSink(config.rtp.remote_ssrc, receive_stream);
625 receive_rtp_config_[config.rtp.remote_ssrc] = 641 receive_rtp_config_[config.rtp.remote_ssrc] =
626 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config)); 642 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config));
627 audio_receive_streams_.insert(receive_stream); 643 audio_receive_streams_.insert(receive_stream);
628 644
629 ConfigureSync(config.sync_group); 645 ConfigureSync(config.sync_group);
630 } 646 }
631 { 647 {
632 ReadLockScoped read_lock(*send_crit_); 648 ReadLockScoped read_lock(*send_crit_);
633 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); 649 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc);
634 if (it != audio_send_ssrcs_.end()) { 650 if (it != audio_send_ssrcs_.end()) {
635 receive_stream->AssociateSendStream(it->second); 651 receive_stream->AssociateSendStream(it->second);
636 } 652 }
637 } 653 }
638 receive_stream->SignalNetworkState(audio_network_state_); 654 receive_stream->SignalNetworkState(audio_network_state_);
639 UpdateAggregateNetworkState(); 655 UpdateAggregateNetworkState();
640 return receive_stream; 656 return receive_stream;
641 } 657 }
642 658
643 void Call::DestroyAudioReceiveStream( 659 void Call::DestroyAudioReceiveStream(
644 webrtc::AudioReceiveStream* receive_stream) { 660 webrtc::AudioReceiveStream* receive_stream) {
645 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); 661 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream");
646 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 662 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
647 RTC_DCHECK(receive_stream != nullptr); 663 RTC_DCHECK(receive_stream != nullptr);
648 webrtc::internal::AudioReceiveStream* audio_receive_stream = 664 webrtc::internal::AudioReceiveStream* audio_receive_stream =
649 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); 665 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream);
650 { 666 {
651 WriteLockScoped write_lock(*receive_crit_); 667 WriteLockScoped write_lock(*receive_crit_);
652 const AudioReceiveStream::Config& config = audio_receive_stream->config(); 668 const AudioReceiveStream::Config& config = audio_receive_stream->config();
653 uint32_t ssrc = config.rtp.remote_ssrc; 669 uint32_t ssrc = config.rtp.remote_ssrc;
654 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) 670 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config))
655 ->RemoveStream(ssrc); 671 ->RemoveStream(ssrc);
656 size_t num_deleted = audio_rtp_demuxer_.RemoveSink(audio_receive_stream); 672 size_t num_deleted = audio_rtp_demuxer_.RemoveSink(audio_receive_stream);
657 RTC_DCHECK(num_deleted == 1); 673 RTC_DCHECK(num_deleted == 1);
658 audio_receive_streams_.erase(audio_receive_stream); 674 audio_receive_streams_.erase(audio_receive_stream);
659 const std::string& sync_group = audio_receive_stream->config().sync_group; 675 const std::string& sync_group = audio_receive_stream->config().sync_group;
660 const auto it = sync_stream_mapping_.find(sync_group); 676 const auto it = sync_stream_mapping_.find(sync_group);
661 if (it != sync_stream_mapping_.end() && 677 if (it != sync_stream_mapping_.end() &&
662 it->second == audio_receive_stream) { 678 it->second == audio_receive_stream) {
663 sync_stream_mapping_.erase(it); 679 sync_stream_mapping_.erase(it);
664 ConfigureSync(sync_group); 680 ConfigureSync(sync_group);
665 } 681 }
666 receive_rtp_config_.erase(ssrc); 682 receive_rtp_config_.erase(ssrc);
667 } 683 }
668 UpdateAggregateNetworkState(); 684 UpdateAggregateNetworkState();
669 delete audio_receive_stream; 685 delete audio_receive_stream;
670 } 686 }
671 687
672 webrtc::VideoSendStream* Call::CreateVideoSendStream( 688 webrtc::VideoSendStream* Call::CreateVideoSendStream(
673 webrtc::VideoSendStream::Config config, 689 webrtc::VideoSendStream::Config config,
674 VideoEncoderConfig encoder_config) { 690 VideoEncoderConfig encoder_config) {
675 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); 691 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream");
676 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 692 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
677 693
678 video_send_delay_stats_->AddSsrcs(config); 694 video_send_delay_stats_->AddSsrcs(config);
679 for (size_t ssrc_index = 0; ssrc_index < config.rtp.ssrcs.size(); 695 for (size_t ssrc_index = 0; ssrc_index < config.rtp.ssrcs.size();
680 ++ssrc_index) { 696 ++ssrc_index) {
681 event_log_->LogVideoSendStreamConfig( 697 event_log_->LogVideoSendStreamConfig(
682 CreateRtcLogStreamConfig(config, ssrc_index)); 698 CreateRtcLogStreamConfig(config, ssrc_index));
683 } 699 }
684 700
685 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if 701 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
686 // the call has already started. 702 // the call has already started.
(...skipping 15 matching lines...) Expand all
702 } 718 }
703 send_stream->SignalNetworkState(video_network_state_); 719 send_stream->SignalNetworkState(video_network_state_);
704 UpdateAggregateNetworkState(); 720 UpdateAggregateNetworkState();
705 721
706 return send_stream; 722 return send_stream;
707 } 723 }
708 724
709 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { 725 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
710 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); 726 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream");
711 RTC_DCHECK(send_stream != nullptr); 727 RTC_DCHECK(send_stream != nullptr);
712 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 728 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
713 729
714 send_stream->Stop(); 730 send_stream->Stop();
715 731
716 VideoSendStream* send_stream_impl = nullptr; 732 VideoSendStream* send_stream_impl = nullptr;
717 { 733 {
718 WriteLockScoped write_lock(*send_crit_); 734 WriteLockScoped write_lock(*send_crit_);
719 auto it = video_send_ssrcs_.begin(); 735 auto it = video_send_ssrcs_.begin();
720 while (it != video_send_ssrcs_.end()) { 736 while (it != video_send_ssrcs_.end()) {
721 if (it->second == static_cast<VideoSendStream*>(send_stream)) { 737 if (it->second == static_cast<VideoSendStream*>(send_stream)) {
722 send_stream_impl = it->second; 738 send_stream_impl = it->second;
(...skipping 14 matching lines...) Expand all
737 suspended_video_send_ssrcs_[it->first] = it->second; 753 suspended_video_send_ssrcs_[it->first] = it->second;
738 } 754 }
739 755
740 UpdateAggregateNetworkState(); 756 UpdateAggregateNetworkState();
741 delete send_stream_impl; 757 delete send_stream_impl;
742 } 758 }
743 759
744 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( 760 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream(
745 webrtc::VideoReceiveStream::Config configuration) { 761 webrtc::VideoReceiveStream::Config configuration) {
746 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); 762 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream");
747 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 763 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
748 764
749 VideoReceiveStream* receive_stream = 765 VideoReceiveStream* receive_stream =
750 new VideoReceiveStream(num_cpu_cores_, transport_send_->packet_router(), 766 new VideoReceiveStream(num_cpu_cores_, transport_send_->packet_router(),
751 std::move(configuration), 767 std::move(configuration),
752 module_process_thread_.get(), call_stats_.get()); 768 module_process_thread_.get(), call_stats_.get());
753 769
754 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); 770 const webrtc::VideoReceiveStream::Config& config = receive_stream->config();
755 ReceiveRtpConfig receive_config(config.rtp.extensions, 771 ReceiveRtpConfig receive_config(config.rtp.extensions,
756 UseSendSideBwe(config)); 772 UseSendSideBwe(config));
757 { 773 {
(...skipping 13 matching lines...) Expand all
771 } 787 }
772 receive_stream->SignalNetworkState(video_network_state_); 788 receive_stream->SignalNetworkState(video_network_state_);
773 UpdateAggregateNetworkState(); 789 UpdateAggregateNetworkState();
774 event_log_->LogVideoReceiveStreamConfig(CreateRtcLogStreamConfig(config)); 790 event_log_->LogVideoReceiveStreamConfig(CreateRtcLogStreamConfig(config));
775 return receive_stream; 791 return receive_stream;
776 } 792 }
777 793
778 void Call::DestroyVideoReceiveStream( 794 void Call::DestroyVideoReceiveStream(
779 webrtc::VideoReceiveStream* receive_stream) { 795 webrtc::VideoReceiveStream* receive_stream) {
780 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); 796 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream");
781 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 797 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
782 RTC_DCHECK(receive_stream != nullptr); 798 RTC_DCHECK(receive_stream != nullptr);
783 VideoReceiveStream* receive_stream_impl = 799 VideoReceiveStream* receive_stream_impl =
784 static_cast<VideoReceiveStream*>(receive_stream); 800 static_cast<VideoReceiveStream*>(receive_stream);
785 const VideoReceiveStream::Config& config = receive_stream_impl->config(); 801 const VideoReceiveStream::Config& config = receive_stream_impl->config();
786 { 802 {
787 WriteLockScoped write_lock(*receive_crit_); 803 WriteLockScoped write_lock(*receive_crit_);
788 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a 804 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a
789 // separate SSRC there can be either one or two. 805 // separate SSRC there can be either one or two.
790 size_t num_deleted = video_rtp_demuxer_.RemoveSink(receive_stream_impl); 806 size_t num_deleted = video_rtp_demuxer_.RemoveSink(receive_stream_impl);
791 RTC_DCHECK_GE(num_deleted, 1); 807 RTC_DCHECK_GE(num_deleted, 1);
792 receive_rtp_config_.erase(config.rtp.remote_ssrc); 808 receive_rtp_config_.erase(config.rtp.remote_ssrc);
793 if (config.rtp.rtx_ssrc) { 809 if (config.rtp.rtx_ssrc) {
794 receive_rtp_config_.erase(config.rtp.rtx_ssrc); 810 receive_rtp_config_.erase(config.rtp.rtx_ssrc);
795 } 811 }
796 video_receive_streams_.erase(receive_stream_impl); 812 video_receive_streams_.erase(receive_stream_impl);
797 ConfigureSync(config.sync_group); 813 ConfigureSync(config.sync_group);
798 } 814 }
799 815
800 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) 816 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config))
801 ->RemoveStream(config.rtp.remote_ssrc); 817 ->RemoveStream(config.rtp.remote_ssrc);
802 818
803 UpdateAggregateNetworkState(); 819 UpdateAggregateNetworkState();
804 delete receive_stream_impl; 820 delete receive_stream_impl;
805 } 821 }
806 822
807 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( 823 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream(
808 const FlexfecReceiveStream::Config& config) { 824 const FlexfecReceiveStream::Config& config) {
809 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); 825 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream");
810 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 826 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
811 827
812 RecoveredPacketReceiver* recovered_packet_receiver = this; 828 RecoveredPacketReceiver* recovered_packet_receiver = this;
813 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl( 829 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl(
814 config, recovered_packet_receiver, call_stats_->rtcp_rtt_stats(), 830 config, recovered_packet_receiver, call_stats_->rtcp_rtt_stats(),
815 module_process_thread_.get()); 831 module_process_thread_.get());
816 832
817 { 833 {
818 WriteLockScoped write_lock(*receive_crit_); 834 WriteLockScoped write_lock(*receive_crit_);
819 video_rtp_demuxer_.AddSink(config.remote_ssrc, receive_stream); 835 video_rtp_demuxer_.AddSink(config.remote_ssrc, receive_stream);
820 836
821 for (auto ssrc : config.protected_media_ssrcs) 837 for (auto ssrc : config.protected_media_ssrcs)
822 video_rtp_demuxer_.AddSink(ssrc, receive_stream); 838 video_rtp_demuxer_.AddSink(ssrc, receive_stream);
823 839
824 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) == 840 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) ==
825 receive_rtp_config_.end()); 841 receive_rtp_config_.end());
826 receive_rtp_config_[config.remote_ssrc] = 842 receive_rtp_config_[config.remote_ssrc] =
827 ReceiveRtpConfig(config.rtp_header_extensions, UseSendSideBwe(config)); 843 ReceiveRtpConfig(config.rtp_header_extensions, UseSendSideBwe(config));
828 } 844 }
829 845
830 // TODO(brandtr): Store config in RtcEventLog here. 846 // TODO(brandtr): Store config in RtcEventLog here.
831 847
832 return receive_stream; 848 return receive_stream;
833 } 849 }
834 850
835 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { 851 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) {
836 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); 852 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream");
837 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 853 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
838 854
839 RTC_DCHECK(receive_stream != nullptr); 855 RTC_DCHECK(receive_stream != nullptr);
840 // There exist no other derived classes of FlexfecReceiveStream, 856 // There exist no other derived classes of FlexfecReceiveStream,
841 // so this downcast is safe. 857 // so this downcast is safe.
842 FlexfecReceiveStreamImpl* receive_stream_impl = 858 FlexfecReceiveStreamImpl* receive_stream_impl =
843 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); 859 static_cast<FlexfecReceiveStreamImpl*>(receive_stream);
844 { 860 {
845 WriteLockScoped write_lock(*receive_crit_); 861 WriteLockScoped write_lock(*receive_crit_);
846 862
847 const FlexfecReceiveStream::Config& config = 863 const FlexfecReceiveStream::Config& config =
848 receive_stream_impl->GetConfig(); 864 receive_stream_impl->GetConfig();
849 uint32_t ssrc = config.remote_ssrc; 865 uint32_t ssrc = config.remote_ssrc;
850 receive_rtp_config_.erase(ssrc); 866 receive_rtp_config_.erase(ssrc);
851 867
852 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be 868 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be
853 // destroyed. 869 // destroyed.
854 video_rtp_demuxer_.RemoveSink(receive_stream_impl); 870 video_rtp_demuxer_.RemoveSink(receive_stream_impl);
855 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) 871 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config))
856 ->RemoveStream(ssrc); 872 ->RemoveStream(ssrc);
857 } 873 }
858 874
859 delete receive_stream_impl; 875 delete receive_stream_impl;
860 } 876 }
861 877
862 Call::Stats Call::GetStats() const { 878 Call::Stats Call::GetStats() const {
863 // TODO(solenberg): Some test cases in EndToEndTest use this from a different 879 // TODO(solenberg): Some test cases in EndToEndTest use this from a different
864 // thread. Re-enable once that is fixed. 880 // thread. Re-enable once that is fixed.
865 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 881 // RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
866 Stats stats; 882 Stats stats;
867 // Fetch available send/receive bitrates. 883 // Fetch available send/receive bitrates.
868 uint32_t send_bandwidth = 0; 884 uint32_t send_bandwidth = 0;
869 transport_send_->send_side_cc()->GetBitrateController()->AvailableBandwidth( 885 transport_send_->send_side_cc()->GetBitrateController()->AvailableBandwidth(
870 &send_bandwidth); 886 &send_bandwidth);
871 std::vector<unsigned int> ssrcs; 887 std::vector<unsigned int> ssrcs;
872 uint32_t recv_bandwidth = 0; 888 uint32_t recv_bandwidth = 0;
873 receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate( 889 receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate(
874 &ssrcs, &recv_bandwidth); 890 &ssrcs, &recv_bandwidth);
875 stats.send_bandwidth_bps = send_bandwidth; 891 stats.send_bandwidth_bps = send_bandwidth;
876 stats.recv_bandwidth_bps = recv_bandwidth; 892 stats.recv_bandwidth_bps = recv_bandwidth;
877 stats.pacer_delay_ms = 893 stats.pacer_delay_ms =
878 transport_send_->send_side_cc()->GetPacerQueuingDelayMs(); 894 transport_send_->send_side_cc()->GetPacerQueuingDelayMs();
879 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); 895 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt();
880 { 896 {
881 rtc::CritScope cs(&bitrate_crit_); 897 rtc::CritScope cs(&bitrate_crit_);
882 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_; 898 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_;
883 } 899 }
884 return stats; 900 return stats;
885 } 901 }
886 902
887 void Call::SetBitrateConfig( 903 void Call::SetBitrateConfig(
888 const webrtc::Call::Config::BitrateConfig& bitrate_config) { 904 const webrtc::Call::Config::BitrateConfig& bitrate_config) {
889 TRACE_EVENT0("webrtc", "Call::SetBitrateConfig"); 905 TRACE_EVENT0("webrtc", "Call::SetBitrateConfig");
890 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 906 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
891 RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0); 907 RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0);
892 if (bitrate_config.max_bitrate_bps != -1) 908 if (bitrate_config.max_bitrate_bps != -1)
893 RTC_DCHECK_GT(bitrate_config.max_bitrate_bps, 0); 909 RTC_DCHECK_GT(bitrate_config.max_bitrate_bps, 0);
894 if (config_.bitrate_config.min_bitrate_bps == 910 if (config_.bitrate_config.min_bitrate_bps ==
895 bitrate_config.min_bitrate_bps && 911 bitrate_config.min_bitrate_bps &&
896 (bitrate_config.start_bitrate_bps <= 0 || 912 (bitrate_config.start_bitrate_bps <= 0 ||
897 config_.bitrate_config.start_bitrate_bps == 913 config_.bitrate_config.start_bitrate_bps ==
898 bitrate_config.start_bitrate_bps) && 914 bitrate_config.start_bitrate_bps) &&
899 config_.bitrate_config.max_bitrate_bps == 915 config_.bitrate_config.max_bitrate_bps ==
900 bitrate_config.max_bitrate_bps) { 916 bitrate_config.max_bitrate_bps) {
901 // Nothing new to set, early abort to avoid encoder reconfigurations. 917 // Nothing new to set, early abort to avoid encoder reconfigurations.
902 return; 918 return;
903 } 919 }
904 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps; 920 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps;
905 // Start bitrate of -1 means we should keep the old bitrate, which there is 921 // Start bitrate of -1 means we should keep the old bitrate, which there is
906 // no point in remembering for the future. 922 // no point in remembering for the future.
907 if (bitrate_config.start_bitrate_bps > 0) 923 if (bitrate_config.start_bitrate_bps > 0)
908 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps; 924 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps;
909 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps; 925 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps;
910 RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0); 926 RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0);
911 transport_send_->send_side_cc()->SetBweBitrates( 927 transport_send_->send_side_cc()->SetBweBitrates(
912 bitrate_config.min_bitrate_bps, bitrate_config.start_bitrate_bps, 928 bitrate_config.min_bitrate_bps, bitrate_config.start_bitrate_bps,
913 bitrate_config.max_bitrate_bps); 929 bitrate_config.max_bitrate_bps);
914 } 930 }
915 931
916 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { 932 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) {
917 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 933 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
918 switch (media) { 934 switch (media) {
919 case MediaType::AUDIO: 935 case MediaType::AUDIO:
920 audio_network_state_ = state; 936 audio_network_state_ = state;
921 break; 937 break;
922 case MediaType::VIDEO: 938 case MediaType::VIDEO:
923 video_network_state_ = state; 939 video_network_state_ = state;
924 break; 940 break;
925 case MediaType::ANY: 941 case MediaType::ANY:
926 case MediaType::DATA: 942 case MediaType::DATA:
927 RTC_NOTREACHED(); 943 RTC_NOTREACHED();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 case MediaType::ANY: 985 case MediaType::ANY:
970 case MediaType::DATA: 986 case MediaType::DATA:
971 RTC_NOTREACHED(); 987 RTC_NOTREACHED();
972 break; 988 break;
973 } 989 }
974 } 990 }
975 991
976 // TODO(honghaiz): Add tests for this method. 992 // TODO(honghaiz): Add tests for this method.
977 void Call::OnNetworkRouteChanged(const std::string& transport_name, 993 void Call::OnNetworkRouteChanged(const std::string& transport_name,
978 const rtc::NetworkRoute& network_route) { 994 const rtc::NetworkRoute& network_route) {
979 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 995 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
980 // Check if the network route is connected. 996 // Check if the network route is connected.
981 if (!network_route.connected) { 997 if (!network_route.connected) {
982 LOG(LS_INFO) << "Transport " << transport_name << " is disconnected"; 998 LOG(LS_INFO) << "Transport " << transport_name << " is disconnected";
983 // TODO(honghaiz): Perhaps handle this in SignalChannelNetworkState and 999 // TODO(honghaiz): Perhaps handle this in SignalChannelNetworkState and
984 // consider merging these two methods. 1000 // consider merging these two methods.
985 return; 1001 return;
986 } 1002 }
987 1003
988 // Check whether the network route has changed on each transport. 1004 // Check whether the network route has changed on each transport.
989 auto result = 1005 auto result =
(...skipping 16 matching lines...) Expand all
1006 << " bps."; 1022 << " bps.";
1007 RTC_DCHECK_GT(config_.bitrate_config.start_bitrate_bps, 0); 1023 RTC_DCHECK_GT(config_.bitrate_config.start_bitrate_bps, 0);
1008 transport_send_->send_side_cc()->OnNetworkRouteChanged( 1024 transport_send_->send_side_cc()->OnNetworkRouteChanged(
1009 network_route, config_.bitrate_config.start_bitrate_bps, 1025 network_route, config_.bitrate_config.start_bitrate_bps,
1010 config_.bitrate_config.min_bitrate_bps, 1026 config_.bitrate_config.min_bitrate_bps,
1011 config_.bitrate_config.max_bitrate_bps); 1027 config_.bitrate_config.max_bitrate_bps);
1012 } 1028 }
1013 } 1029 }
1014 1030
1015 void Call::UpdateAggregateNetworkState() { 1031 void Call::UpdateAggregateNetworkState() {
1016 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 1032 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
1017 1033
1018 bool have_audio = false; 1034 bool have_audio = false;
1019 bool have_video = false; 1035 bool have_video = false;
1020 { 1036 {
1021 ReadLockScoped read_lock(*send_crit_); 1037 ReadLockScoped read_lock(*send_crit_);
1022 if (audio_send_ssrcs_.size() > 0) 1038 if (audio_send_ssrcs_.size() > 0)
1023 have_audio = true; 1039 have_audio = true;
1024 if (video_send_ssrcs_.size() > 0) 1040 if (video_send_ssrcs_.size() > 0)
1025 have_video = true; 1041 have_video = true;
1026 } 1042 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { 1309 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) {
1294 receive_side_cc_.OnReceivedPacket( 1310 receive_side_cc_.OnReceivedPacket(
1295 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), 1311 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(),
1296 header); 1312 header);
1297 } 1313 }
1298 } 1314 }
1299 1315
1300 } // namespace internal 1316 } // namespace internal
1301 1317
1302 } // namespace webrtc 1318 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/BUILD.gn ('k') | webrtc/call/call_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698