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

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

Issue 2886993005: Introduce RtpStreamReceiver and RtpStreamReceiverControllerInterface. (Closed)
Patch Set: Protect construction of FlexfecReceiveStreamImpl. 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
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 16 matching lines...) Expand all
27 #include "webrtc/base/logging.h" 27 #include "webrtc/base/logging.h"
28 #include "webrtc/base/optional.h" 28 #include "webrtc/base/optional.h"
29 #include "webrtc/base/ptr_util.h" 29 #include "webrtc/base/ptr_util.h"
30 #include "webrtc/base/task_queue.h" 30 #include "webrtc/base/task_queue.h"
31 #include "webrtc/base/thread_annotations.h" 31 #include "webrtc/base/thread_annotations.h"
32 #include "webrtc/base/thread_checker.h" 32 #include "webrtc/base/thread_checker.h"
33 #include "webrtc/base/trace_event.h" 33 #include "webrtc/base/trace_event.h"
34 #include "webrtc/call/bitrate_allocator.h" 34 #include "webrtc/call/bitrate_allocator.h"
35 #include "webrtc/call/call.h" 35 #include "webrtc/call/call.h"
36 #include "webrtc/call/flexfec_receive_stream_impl.h" 36 #include "webrtc/call/flexfec_receive_stream_impl.h"
37 #include "webrtc/call/rtp_demuxer.h" 37 #include "webrtc/call/rtp_stream_receiver_controller.h"
38 #include "webrtc/call/rtp_transport_controller_send.h" 38 #include "webrtc/call/rtp_transport_controller_send.h"
39 #include "webrtc/config.h" 39 #include "webrtc/config.h"
40 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 40 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
41 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 41 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
42 #include "webrtc/modules/congestion_controller/include/receive_side_congestion_c ontroller.h" 42 #include "webrtc/modules/congestion_controller/include/receive_side_congestion_c ontroller.h"
43 #include "webrtc/modules/pacing/paced_sender.h" 43 #include "webrtc/modules/pacing/paced_sender.h"
44 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" 44 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h"
45 #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h" 45 #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h"
46 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 46 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
47 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 47 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // Audio, Video, and FlexFEC receive streams are owned by the client that 268 // Audio, Video, and FlexFEC receive streams are owned by the client that
269 // creates them. 269 // creates them.
270 std::set<AudioReceiveStream*> audio_receive_streams_ 270 std::set<AudioReceiveStream*> audio_receive_streams_
271 GUARDED_BY(receive_crit_); 271 GUARDED_BY(receive_crit_);
272 std::set<VideoReceiveStream*> video_receive_streams_ 272 std::set<VideoReceiveStream*> video_receive_streams_
273 GUARDED_BY(receive_crit_); 273 GUARDED_BY(receive_crit_);
274 274
275 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ 275 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_
276 GUARDED_BY(receive_crit_); 276 GUARDED_BY(receive_crit_);
277 277
278 // TODO(nisse): Should eventually be part of injected 278 // TODO(nisse): Should eventually be injected at creation,
279 // RtpTransportControllerReceive, with a single demuxer in the bundled case. 279 // with a single object in the bundled case.
280 RtpDemuxer audio_rtp_demuxer_ GUARDED_BY(receive_crit_); 280 RtpStreamReceiverController audio_receiver_controller;
281 RtpDemuxer video_rtp_demuxer_ GUARDED_BY(receive_crit_); 281 RtpStreamReceiverController video_receiver_controller;
282 282
283 // This extra map is used for receive processing which is 283 // This extra map is used for receive processing which is
284 // independent of media type. 284 // independent of media type.
285 285
286 // TODO(nisse): In the RTP transport refactoring, we should have a 286 // TODO(nisse): In the RTP transport refactoring, we should have a
287 // single mapping from ssrc to a more abstract receive stream, with 287 // single mapping from ssrc to a more abstract receive stream, with
288 // accessor methods for all configuration we need at this level. 288 // accessor methods for all configuration we need at this level.
289 struct ReceiveRtpConfig { 289 struct ReceiveRtpConfig {
290 ReceiveRtpConfig() = default; // Needed by std::map 290 ReceiveRtpConfig() = default; // Needed by std::map
291 ReceiveRtpConfig(const std::vector<RtpExtension>& extensions, 291 ReceiveRtpConfig(const std::vector<RtpExtension>& extensions,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 479 }
480 480
481 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( 481 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket(
482 const uint8_t* packet, 482 const uint8_t* packet,
483 size_t length, 483 size_t length,
484 const PacketTime* packet_time) { 484 const PacketTime* packet_time) {
485 RtpPacketReceived parsed_packet; 485 RtpPacketReceived parsed_packet;
486 if (!parsed_packet.Parse(packet, length)) 486 if (!parsed_packet.Parse(packet, length))
487 return rtc::Optional<RtpPacketReceived>(); 487 return rtc::Optional<RtpPacketReceived>();
488 488
489 auto it = receive_rtp_config_.find(parsed_packet.Ssrc());
490 if (it != receive_rtp_config_.end())
491 parsed_packet.IdentifyExtensions(it->second.extensions);
492
493 int64_t arrival_time_ms; 489 int64_t arrival_time_ms;
494 if (packet_time && packet_time->timestamp != -1) { 490 if (packet_time && packet_time->timestamp != -1) {
495 arrival_time_ms = (packet_time->timestamp + 500) / 1000; 491 arrival_time_ms = (packet_time->timestamp + 500) / 1000;
496 } else { 492 } else {
497 arrival_time_ms = clock_->TimeInMilliseconds(); 493 arrival_time_ms = clock_->TimeInMilliseconds();
498 } 494 }
499 parsed_packet.set_arrival_time_ms(arrival_time_ms); 495 parsed_packet.set_arrival_time_ms(arrival_time_ms);
500 496
501 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); 497 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet));
502 } 498 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 } 635 }
640 UpdateAggregateNetworkState(); 636 UpdateAggregateNetworkState();
641 delete audio_send_stream; 637 delete audio_send_stream;
642 } 638 }
643 639
644 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( 640 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
645 const webrtc::AudioReceiveStream::Config& config) { 641 const webrtc::AudioReceiveStream::Config& config) {
646 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); 642 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
647 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 643 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
648 event_log_->LogAudioReceiveStreamConfig(CreateRtcLogStreamConfig(config)); 644 event_log_->LogAudioReceiveStreamConfig(CreateRtcLogStreamConfig(config));
649 AudioReceiveStream* receive_stream = 645 AudioReceiveStream* receive_stream = new AudioReceiveStream(
650 new AudioReceiveStream(transport_send_->packet_router(), config, 646 &audio_receiver_controller, transport_send_->packet_router(), config,
651 config_.audio_state, event_log_); 647 config_.audio_state, event_log_);
652 { 648 {
653 WriteLockScoped write_lock(*receive_crit_); 649 WriteLockScoped write_lock(*receive_crit_);
654 audio_rtp_demuxer_.AddSink(config.rtp.remote_ssrc, receive_stream);
655 receive_rtp_config_[config.rtp.remote_ssrc] = 650 receive_rtp_config_[config.rtp.remote_ssrc] =
656 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config)); 651 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config));
657 audio_receive_streams_.insert(receive_stream); 652 audio_receive_streams_.insert(receive_stream);
658 653
659 ConfigureSync(config.sync_group); 654 ConfigureSync(config.sync_group);
660 } 655 }
661 { 656 {
662 ReadLockScoped read_lock(*send_crit_); 657 ReadLockScoped read_lock(*send_crit_);
663 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); 658 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc);
664 if (it != audio_send_ssrcs_.end()) { 659 if (it != audio_send_ssrcs_.end()) {
(...skipping 11 matching lines...) Expand all
676 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 671 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
677 RTC_DCHECK(receive_stream != nullptr); 672 RTC_DCHECK(receive_stream != nullptr);
678 webrtc::internal::AudioReceiveStream* audio_receive_stream = 673 webrtc::internal::AudioReceiveStream* audio_receive_stream =
679 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); 674 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream);
680 { 675 {
681 WriteLockScoped write_lock(*receive_crit_); 676 WriteLockScoped write_lock(*receive_crit_);
682 const AudioReceiveStream::Config& config = audio_receive_stream->config(); 677 const AudioReceiveStream::Config& config = audio_receive_stream->config();
683 uint32_t ssrc = config.rtp.remote_ssrc; 678 uint32_t ssrc = config.rtp.remote_ssrc;
684 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) 679 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config))
685 ->RemoveStream(ssrc); 680 ->RemoveStream(ssrc);
686 size_t num_deleted = audio_rtp_demuxer_.RemoveSink(audio_receive_stream);
687 RTC_DCHECK(num_deleted == 1);
688 audio_receive_streams_.erase(audio_receive_stream); 681 audio_receive_streams_.erase(audio_receive_stream);
689 const std::string& sync_group = audio_receive_stream->config().sync_group; 682 const std::string& sync_group = audio_receive_stream->config().sync_group;
690 const auto it = sync_stream_mapping_.find(sync_group); 683 const auto it = sync_stream_mapping_.find(sync_group);
691 if (it != sync_stream_mapping_.end() && 684 if (it != sync_stream_mapping_.end() &&
692 it->second == audio_receive_stream) { 685 it->second == audio_receive_stream) {
693 sync_stream_mapping_.erase(it); 686 sync_stream_mapping_.erase(it);
694 ConfigureSync(sync_group); 687 ConfigureSync(sync_group);
695 } 688 }
696 receive_rtp_config_.erase(ssrc); 689 receive_rtp_config_.erase(ssrc);
697 } 690 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 762
770 UpdateAggregateNetworkState(); 763 UpdateAggregateNetworkState();
771 delete send_stream_impl; 764 delete send_stream_impl;
772 } 765 }
773 766
774 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( 767 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream(
775 webrtc::VideoReceiveStream::Config configuration) { 768 webrtc::VideoReceiveStream::Config configuration) {
776 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); 769 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream");
777 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 770 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
778 771
779 VideoReceiveStream* receive_stream = 772 VideoReceiveStream* receive_stream = new VideoReceiveStream(
780 new VideoReceiveStream(num_cpu_cores_, transport_send_->packet_router(), 773 &video_receiver_controller, num_cpu_cores_,
781 std::move(configuration), 774 transport_send_->packet_router(), std::move(configuration),
782 module_process_thread_.get(), call_stats_.get()); 775 module_process_thread_.get(), call_stats_.get());
783 776
784 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); 777 const webrtc::VideoReceiveStream::Config& config = receive_stream->config();
785 ReceiveRtpConfig receive_config(config.rtp.extensions, 778 ReceiveRtpConfig receive_config(config.rtp.extensions,
786 UseSendSideBwe(config)); 779 UseSendSideBwe(config));
787 { 780 {
788 WriteLockScoped write_lock(*receive_crit_); 781 WriteLockScoped write_lock(*receive_crit_);
789 video_rtp_demuxer_.AddSink(config.rtp.remote_ssrc, receive_stream);
790 if (config.rtp.rtx_ssrc) { 782 if (config.rtp.rtx_ssrc) {
791 video_rtp_demuxer_.AddSink(config.rtp.rtx_ssrc, receive_stream);
792 // We record identical config for the rtx stream as for the main 783 // We record identical config for the rtx stream as for the main
793 // stream. Since the transport_send_cc negotiation is per payload 784 // stream. Since the transport_send_cc negotiation is per payload
794 // type, we may get an incorrect value for the rtx stream, but 785 // type, we may get an incorrect value for the rtx stream, but
795 // that is unlikely to matter in practice. 786 // that is unlikely to matter in practice.
796 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config; 787 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config;
797 } 788 }
798 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config; 789 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config;
799 video_receive_streams_.insert(receive_stream); 790 video_receive_streams_.insert(receive_stream);
800 ConfigureSync(config.sync_group); 791 ConfigureSync(config.sync_group);
801 } 792 }
802 receive_stream->SignalNetworkState(video_network_state_); 793 receive_stream->SignalNetworkState(video_network_state_);
803 UpdateAggregateNetworkState(); 794 UpdateAggregateNetworkState();
804 event_log_->LogVideoReceiveStreamConfig(CreateRtcLogStreamConfig(config)); 795 event_log_->LogVideoReceiveStreamConfig(CreateRtcLogStreamConfig(config));
805 return receive_stream; 796 return receive_stream;
806 } 797 }
807 798
808 void Call::DestroyVideoReceiveStream( 799 void Call::DestroyVideoReceiveStream(
809 webrtc::VideoReceiveStream* receive_stream) { 800 webrtc::VideoReceiveStream* receive_stream) {
810 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); 801 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream");
811 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 802 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
812 RTC_DCHECK(receive_stream != nullptr); 803 RTC_DCHECK(receive_stream != nullptr);
813 VideoReceiveStream* receive_stream_impl = 804 VideoReceiveStream* receive_stream_impl =
814 static_cast<VideoReceiveStream*>(receive_stream); 805 static_cast<VideoReceiveStream*>(receive_stream);
815 const VideoReceiveStream::Config& config = receive_stream_impl->config(); 806 const VideoReceiveStream::Config& config = receive_stream_impl->config();
816 { 807 {
817 WriteLockScoped write_lock(*receive_crit_); 808 WriteLockScoped write_lock(*receive_crit_);
818 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a 809 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a
819 // separate SSRC there can be either one or two. 810 // separate SSRC there can be either one or two.
820 size_t num_deleted = video_rtp_demuxer_.RemoveSink(receive_stream_impl);
821 RTC_DCHECK_GE(num_deleted, 1);
822 receive_rtp_config_.erase(config.rtp.remote_ssrc); 811 receive_rtp_config_.erase(config.rtp.remote_ssrc);
823 if (config.rtp.rtx_ssrc) { 812 if (config.rtp.rtx_ssrc) {
824 receive_rtp_config_.erase(config.rtp.rtx_ssrc); 813 receive_rtp_config_.erase(config.rtp.rtx_ssrc);
825 } 814 }
826 video_receive_streams_.erase(receive_stream_impl); 815 video_receive_streams_.erase(receive_stream_impl);
827 ConfigureSync(config.sync_group); 816 ConfigureSync(config.sync_group);
828 } 817 }
829 818
830 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) 819 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config))
831 ->RemoveStream(config.rtp.remote_ssrc); 820 ->RemoveStream(config.rtp.remote_ssrc);
832 821
833 UpdateAggregateNetworkState(); 822 UpdateAggregateNetworkState();
834 delete receive_stream_impl; 823 delete receive_stream_impl;
835 } 824 }
836 825
837 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( 826 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream(
838 const FlexfecReceiveStream::Config& config) { 827 const FlexfecReceiveStream::Config& config) {
839 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); 828 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream");
840 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); 829 RTC_DCHECK_RUN_ON(&configuration_thread_checker_);
841 830
842 RecoveredPacketReceiver* recovered_packet_receiver = this; 831 RecoveredPacketReceiver* recovered_packet_receiver = this;
843 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl(
844 config, recovered_packet_receiver, call_stats_->rtcp_rtt_stats(),
845 module_process_thread_.get());
846 832
833 FlexfecReceiveStreamImpl* receive_stream;
847 { 834 {
848 WriteLockScoped write_lock(*receive_crit_); 835 WriteLockScoped write_lock(*receive_crit_);
849 video_rtp_demuxer_.AddSink(config.remote_ssrc, receive_stream); 836 // Unlike the video and audio receive streams,
850 837 // FlexfecReceiveStream implements RtpPacketSinkInterface itself,
851 for (auto ssrc : config.protected_media_ssrcs) 838 // and hence its constructor passes its |this| pointer to
852 video_rtp_demuxer_.AddSink(ssrc, receive_stream); 839 // video_receiver_controller->CreateStream(). Calling the
840 // constructor while holding |receive_crit_| ensures that we don't
841 // call OnRtpPacket until the constructor is finished and the
842 // object is in a valid state.
843 // TODO(nisse): Fix constructor so that it can be moved outside of
844 // this locked scope.
845 receive_stream = new FlexfecReceiveStreamImpl(
846 &video_receiver_controller, config, recovered_packet_receiver,
847 call_stats_->rtcp_rtt_stats(), module_process_thread_.get());
853 848
854 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) == 849 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) ==
855 receive_rtp_config_.end()); 850 receive_rtp_config_.end());
856 receive_rtp_config_[config.remote_ssrc] = 851 receive_rtp_config_[config.remote_ssrc] =
857 ReceiveRtpConfig(config.rtp_header_extensions, UseSendSideBwe(config)); 852 ReceiveRtpConfig(config.rtp_header_extensions, UseSendSideBwe(config));
858 } 853 }
859 854
860 // TODO(brandtr): Store config in RtcEventLog here. 855 // TODO(brandtr): Store config in RtcEventLog here.
861 856
862 return receive_stream; 857 return receive_stream;
(...skipping 11 matching lines...) Expand all
874 { 869 {
875 WriteLockScoped write_lock(*receive_crit_); 870 WriteLockScoped write_lock(*receive_crit_);
876 871
877 const FlexfecReceiveStream::Config& config = 872 const FlexfecReceiveStream::Config& config =
878 receive_stream_impl->GetConfig(); 873 receive_stream_impl->GetConfig();
879 uint32_t ssrc = config.remote_ssrc; 874 uint32_t ssrc = config.remote_ssrc;
880 receive_rtp_config_.erase(ssrc); 875 receive_rtp_config_.erase(ssrc);
881 876
882 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be 877 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be
883 // destroyed. 878 // destroyed.
884 video_rtp_demuxer_.RemoveSink(receive_stream_impl);
885 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) 879 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config))
886 ->RemoveStream(ssrc); 880 ->RemoveStream(ssrc);
887 } 881 }
888 882
889 delete receive_stream_impl; 883 delete receive_stream_impl;
890 } 884 }
891 885
892 Call::Stats Call::GetStats() const { 886 Call::Stats Call::GetStats() const {
893 // TODO(solenberg): Some test cases in EndToEndTest use this from a different 887 // TODO(solenberg): Some test cases in EndToEndTest use this from a different
894 // thread. Re-enable once that is fixed. 888 // thread. Re-enable once that is fixed.
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 1289
1296 ReadLockScoped read_lock(*receive_crit_); 1290 ReadLockScoped read_lock(*receive_crit_);
1297 // TODO(nisse): We should parse the RTP header only here, and pass 1291 // TODO(nisse): We should parse the RTP header only here, and pass
1298 // on parsed_packet to the receive streams. 1292 // on parsed_packet to the receive streams.
1299 rtc::Optional<RtpPacketReceived> parsed_packet = 1293 rtc::Optional<RtpPacketReceived> parsed_packet =
1300 ParseRtpPacket(packet, length, &packet_time); 1294 ParseRtpPacket(packet, length, &packet_time);
1301 1295
1302 if (!parsed_packet) 1296 if (!parsed_packet)
1303 return DELIVERY_PACKET_ERROR; 1297 return DELIVERY_PACKET_ERROR;
1304 1298
1299 auto it = receive_rtp_config_.find(parsed_packet->Ssrc());
1300 if (it == receive_rtp_config_.end()) {
1301 LOG(LS_ERROR) << "receive_rtp_config_ lookup failed for ssrc "
1302 << parsed_packet->Ssrc();
1303 // Destruction of the receive stream, including deregistering from the
1304 // RtpDemuxer, is not protected by the |receive_crit_| lock. But
1305 // deregistering in the |receive_rtp_config_| map is protected by that lock.
1306 // So by not passing the packet on to demuxing in this case, we prevent
1307 // incoming packets to be passed on via the demuxer to a receive stream
1308 // which is being torned down.
1309 return DELIVERY_UNKNOWN_SSRC;
1310 }
1311 parsed_packet->IdentifyExtensions(it->second.extensions);
1312
1305 NotifyBweOfReceivedPacket(*parsed_packet, media_type); 1313 NotifyBweOfReceivedPacket(*parsed_packet, media_type);
1306 1314
1307 if (media_type == MediaType::AUDIO) { 1315 if (media_type == MediaType::AUDIO) {
1308 if (audio_rtp_demuxer_.OnRtpPacket(*parsed_packet)) { 1316 if (audio_receiver_controller.OnRtpPacket(*parsed_packet)) {
1309 received_bytes_per_second_counter_.Add(static_cast<int>(length)); 1317 received_bytes_per_second_counter_.Add(static_cast<int>(length));
1310 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); 1318 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length));
1311 event_log_->LogRtpHeader(kIncomingPacket, packet, length); 1319 event_log_->LogRtpHeader(kIncomingPacket, packet, length);
1312 return DELIVERY_OK; 1320 return DELIVERY_OK;
1313 } 1321 }
1314 } else if (media_type == MediaType::VIDEO) { 1322 } else if (media_type == MediaType::VIDEO) {
1315 if (video_rtp_demuxer_.OnRtpPacket(*parsed_packet)) { 1323 if (video_receiver_controller.OnRtpPacket(*parsed_packet)) {
1316 received_bytes_per_second_counter_.Add(static_cast<int>(length)); 1324 received_bytes_per_second_counter_.Add(static_cast<int>(length));
1317 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); 1325 received_video_bytes_per_second_counter_.Add(static_cast<int>(length));
1318 event_log_->LogRtpHeader(kIncomingPacket, packet, length); 1326 event_log_->LogRtpHeader(kIncomingPacket, packet, length);
1319 return DELIVERY_OK; 1327 return DELIVERY_OK;
1320 } 1328 }
1321 } 1329 }
1322 return DELIVERY_UNKNOWN_SSRC; 1330 return DELIVERY_UNKNOWN_SSRC;
1323 } 1331 }
1324 1332
1325 PacketReceiver::DeliveryStatus Call::DeliverPacket( 1333 PacketReceiver::DeliveryStatus Call::DeliverPacket(
(...skipping 15 matching lines...) Expand all
1341 // audio packets with FlexFEC. 1349 // audio packets with FlexFEC.
1342 void Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { 1350 void Call::OnRecoveredPacket(const uint8_t* packet, size_t length) {
1343 ReadLockScoped read_lock(*receive_crit_); 1351 ReadLockScoped read_lock(*receive_crit_);
1344 rtc::Optional<RtpPacketReceived> parsed_packet = 1352 rtc::Optional<RtpPacketReceived> parsed_packet =
1345 ParseRtpPacket(packet, length, nullptr); 1353 ParseRtpPacket(packet, length, nullptr);
1346 if (!parsed_packet) 1354 if (!parsed_packet)
1347 return; 1355 return;
1348 1356
1349 parsed_packet->set_recovered(true); 1357 parsed_packet->set_recovered(true);
1350 1358
1351 video_rtp_demuxer_.OnRtpPacket(*parsed_packet); 1359 video_receiver_controller.OnRtpPacket(*parsed_packet);
1352 } 1360 }
1353 1361
1354 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, 1362 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet,
1355 MediaType media_type) { 1363 MediaType media_type) {
1356 auto it = receive_rtp_config_.find(packet.Ssrc()); 1364 auto it = receive_rtp_config_.find(packet.Ssrc());
1357 bool use_send_side_bwe = 1365 bool use_send_side_bwe =
1358 (it != receive_rtp_config_.end()) && it->second.use_send_side_bwe; 1366 (it != receive_rtp_config_.end()) && it->second.use_send_side_bwe;
1359 1367
1360 RTPHeader header; 1368 RTPHeader header;
1361 packet.GetHeader(&header); 1369 packet.GetHeader(&header);
(...skipping 13 matching lines...) Expand all
1375 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { 1383 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) {
1376 receive_side_cc_.OnReceivedPacket( 1384 receive_side_cc_.OnReceivedPacket(
1377 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), 1385 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(),
1378 header); 1386 header);
1379 } 1387 }
1380 } 1388 }
1381 1389
1382 } // namespace internal 1390 } // namespace internal
1383 1391
1384 } // namespace webrtc 1392 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698