OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
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_parser.h" | 45 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
46 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 46 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
47 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | 47 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // Audio, Video, and FlexFEC receive streams are owned by the client that | 270 // Audio, Video, and FlexFEC receive streams are owned by the client that |
271 // creates them. | 271 // creates them. |
272 std::set<AudioReceiveStream*> audio_receive_streams_ | 272 std::set<AudioReceiveStream*> audio_receive_streams_ |
273 GUARDED_BY(receive_crit_); | 273 GUARDED_BY(receive_crit_); |
274 std::set<VideoReceiveStream*> video_receive_streams_ | 274 std::set<VideoReceiveStream*> video_receive_streams_ |
275 GUARDED_BY(receive_crit_); | 275 GUARDED_BY(receive_crit_); |
276 | 276 |
277 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ | 277 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ |
278 GUARDED_BY(receive_crit_); | 278 GUARDED_BY(receive_crit_); |
279 | 279 |
280 // TODO(nisse): Should eventually be part of injected | 280 // TODO(nisse): Should eventually be injected at creation, |
281 // RtpTransportControllerReceive, with a single demuxer in the bundled case. | 281 // with a single object in the bundled case. |
282 RtpDemuxer audio_rtp_demuxer_ GUARDED_BY(receive_crit_); | 282 RtpStreamReceiverController audio_receiver_controller; |
283 RtpDemuxer video_rtp_demuxer_ GUARDED_BY(receive_crit_); | 283 RtpStreamReceiverController video_receiver_controller; |
284 | 284 |
285 // This extra map is used for receive processing which is | 285 // This extra map is used for receive processing which is |
286 // independent of media type. | 286 // independent of media type. |
287 | 287 |
288 // TODO(nisse): In the RTP transport refactoring, we should have a | 288 // TODO(nisse): In the RTP transport refactoring, we should have a |
289 // single mapping from ssrc to a more abstract receive stream, with | 289 // single mapping from ssrc to a more abstract receive stream, with |
290 // accessor methods for all configuration we need at this level. | 290 // accessor methods for all configuration we need at this level. |
291 struct ReceiveRtpConfig { | 291 struct ReceiveRtpConfig { |
292 ReceiveRtpConfig() = default; // Needed by std::map | 292 ReceiveRtpConfig() = default; // Needed by std::map |
293 ReceiveRtpConfig(const std::vector<RtpExtension>& extensions, | 293 ReceiveRtpConfig(const std::vector<RtpExtension>& extensions, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 } | 481 } |
482 | 482 |
483 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( | 483 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( |
484 const uint8_t* packet, | 484 const uint8_t* packet, |
485 size_t length, | 485 size_t length, |
486 const PacketTime* packet_time) { | 486 const PacketTime* packet_time) { |
487 RtpPacketReceived parsed_packet; | 487 RtpPacketReceived parsed_packet; |
488 if (!parsed_packet.Parse(packet, length)) | 488 if (!parsed_packet.Parse(packet, length)) |
489 return rtc::Optional<RtpPacketReceived>(); | 489 return rtc::Optional<RtpPacketReceived>(); |
490 | 490 |
491 auto it = receive_rtp_config_.find(parsed_packet.Ssrc()); | |
492 if (it != receive_rtp_config_.end()) | |
493 parsed_packet.IdentifyExtensions(it->second.extensions); | |
494 | |
495 int64_t arrival_time_ms; | 491 int64_t arrival_time_ms; |
496 if (packet_time && packet_time->timestamp != -1) { | 492 if (packet_time && packet_time->timestamp != -1) { |
497 arrival_time_ms = (packet_time->timestamp + 500) / 1000; | 493 arrival_time_ms = (packet_time->timestamp + 500) / 1000; |
498 } else { | 494 } else { |
499 arrival_time_ms = clock_->TimeInMilliseconds(); | 495 arrival_time_ms = clock_->TimeInMilliseconds(); |
500 } | 496 } |
501 parsed_packet.set_arrival_time_ms(arrival_time_ms); | 497 parsed_packet.set_arrival_time_ms(arrival_time_ms); |
502 | 498 |
503 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); | 499 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); |
504 } | 500 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 } | 637 } |
642 UpdateAggregateNetworkState(); | 638 UpdateAggregateNetworkState(); |
643 delete audio_send_stream; | 639 delete audio_send_stream; |
644 } | 640 } |
645 | 641 |
646 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 642 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
647 const webrtc::AudioReceiveStream::Config& config) { | 643 const webrtc::AudioReceiveStream::Config& config) { |
648 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 644 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
649 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); | 645 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); |
650 event_log_->LogAudioReceiveStreamConfig(CreateRtcLogStreamConfig(config)); | 646 event_log_->LogAudioReceiveStreamConfig(CreateRtcLogStreamConfig(config)); |
651 AudioReceiveStream* receive_stream = | 647 AudioReceiveStream* receive_stream = new AudioReceiveStream( |
652 new AudioReceiveStream(transport_send_->packet_router(), config, | 648 &audio_receiver_controller, transport_send_->packet_router(), config, |
653 config_.audio_state, event_log_); | 649 config_.audio_state, event_log_); |
654 { | 650 { |
655 WriteLockScoped write_lock(*receive_crit_); | 651 WriteLockScoped write_lock(*receive_crit_); |
656 audio_rtp_demuxer_.AddSink(config.rtp.remote_ssrc, receive_stream); | |
657 receive_rtp_config_[config.rtp.remote_ssrc] = | 652 receive_rtp_config_[config.rtp.remote_ssrc] = |
658 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config)); | 653 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config)); |
659 audio_receive_streams_.insert(receive_stream); | 654 audio_receive_streams_.insert(receive_stream); |
660 | 655 |
661 ConfigureSync(config.sync_group); | 656 ConfigureSync(config.sync_group); |
662 } | 657 } |
663 { | 658 { |
664 ReadLockScoped read_lock(*send_crit_); | 659 ReadLockScoped read_lock(*send_crit_); |
665 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); | 660 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); |
666 if (it != audio_send_ssrcs_.end()) { | 661 if (it != audio_send_ssrcs_.end()) { |
(...skipping 11 matching lines...) Expand all Loading... |
678 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); | 673 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); |
679 RTC_DCHECK(receive_stream != nullptr); | 674 RTC_DCHECK(receive_stream != nullptr); |
680 webrtc::internal::AudioReceiveStream* audio_receive_stream = | 675 webrtc::internal::AudioReceiveStream* audio_receive_stream = |
681 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); | 676 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); |
682 { | 677 { |
683 WriteLockScoped write_lock(*receive_crit_); | 678 WriteLockScoped write_lock(*receive_crit_); |
684 const AudioReceiveStream::Config& config = audio_receive_stream->config(); | 679 const AudioReceiveStream::Config& config = audio_receive_stream->config(); |
685 uint32_t ssrc = config.rtp.remote_ssrc; | 680 uint32_t ssrc = config.rtp.remote_ssrc; |
686 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 681 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) |
687 ->RemoveStream(ssrc); | 682 ->RemoveStream(ssrc); |
688 size_t num_deleted = audio_rtp_demuxer_.RemoveSink(audio_receive_stream); | |
689 RTC_DCHECK(num_deleted == 1); | |
690 audio_receive_streams_.erase(audio_receive_stream); | 683 audio_receive_streams_.erase(audio_receive_stream); |
691 const std::string& sync_group = audio_receive_stream->config().sync_group; | 684 const std::string& sync_group = audio_receive_stream->config().sync_group; |
692 const auto it = sync_stream_mapping_.find(sync_group); | 685 const auto it = sync_stream_mapping_.find(sync_group); |
693 if (it != sync_stream_mapping_.end() && | 686 if (it != sync_stream_mapping_.end() && |
694 it->second == audio_receive_stream) { | 687 it->second == audio_receive_stream) { |
695 sync_stream_mapping_.erase(it); | 688 sync_stream_mapping_.erase(it); |
696 ConfigureSync(sync_group); | 689 ConfigureSync(sync_group); |
697 } | 690 } |
698 receive_rtp_config_.erase(ssrc); | 691 receive_rtp_config_.erase(ssrc); |
699 } | 692 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 | 764 |
772 UpdateAggregateNetworkState(); | 765 UpdateAggregateNetworkState(); |
773 delete send_stream_impl; | 766 delete send_stream_impl; |
774 } | 767 } |
775 | 768 |
776 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 769 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
777 webrtc::VideoReceiveStream::Config configuration) { | 770 webrtc::VideoReceiveStream::Config configuration) { |
778 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 771 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
779 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); | 772 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); |
780 | 773 |
781 VideoReceiveStream* receive_stream = | 774 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
782 new VideoReceiveStream(num_cpu_cores_, transport_send_->packet_router(), | 775 &video_receiver_controller, num_cpu_cores_, |
783 std::move(configuration), | 776 transport_send_->packet_router(), std::move(configuration), |
784 module_process_thread_.get(), call_stats_.get()); | 777 module_process_thread_.get(), call_stats_.get()); |
785 | 778 |
786 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 779 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
787 ReceiveRtpConfig receive_config(config.rtp.extensions, | 780 ReceiveRtpConfig receive_config(config.rtp.extensions, |
788 UseSendSideBwe(config)); | 781 UseSendSideBwe(config)); |
789 { | 782 { |
790 WriteLockScoped write_lock(*receive_crit_); | 783 WriteLockScoped write_lock(*receive_crit_); |
791 video_rtp_demuxer_.AddSink(config.rtp.remote_ssrc, receive_stream); | |
792 if (config.rtp.rtx_ssrc) { | 784 if (config.rtp.rtx_ssrc) { |
793 video_rtp_demuxer_.AddSink(config.rtp.rtx_ssrc, receive_stream); | |
794 // We record identical config for the rtx stream as for the main | 785 // We record identical config for the rtx stream as for the main |
795 // stream. Since the transport_send_cc negotiation is per payload | 786 // stream. Since the transport_send_cc negotiation is per payload |
796 // type, we may get an incorrect value for the rtx stream, but | 787 // type, we may get an incorrect value for the rtx stream, but |
797 // that is unlikely to matter in practice. | 788 // that is unlikely to matter in practice. |
798 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config; | 789 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config; |
799 } | 790 } |
800 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config; | 791 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config; |
801 video_receive_streams_.insert(receive_stream); | 792 video_receive_streams_.insert(receive_stream); |
802 ConfigureSync(config.sync_group); | 793 ConfigureSync(config.sync_group); |
803 } | 794 } |
804 receive_stream->SignalNetworkState(video_network_state_); | 795 receive_stream->SignalNetworkState(video_network_state_); |
805 UpdateAggregateNetworkState(); | 796 UpdateAggregateNetworkState(); |
806 event_log_->LogVideoReceiveStreamConfig(CreateRtcLogStreamConfig(config)); | 797 event_log_->LogVideoReceiveStreamConfig(CreateRtcLogStreamConfig(config)); |
807 return receive_stream; | 798 return receive_stream; |
808 } | 799 } |
809 | 800 |
810 void Call::DestroyVideoReceiveStream( | 801 void Call::DestroyVideoReceiveStream( |
811 webrtc::VideoReceiveStream* receive_stream) { | 802 webrtc::VideoReceiveStream* receive_stream) { |
812 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 803 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
813 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); | 804 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); |
814 RTC_DCHECK(receive_stream != nullptr); | 805 RTC_DCHECK(receive_stream != nullptr); |
815 VideoReceiveStream* receive_stream_impl = | 806 VideoReceiveStream* receive_stream_impl = |
816 static_cast<VideoReceiveStream*>(receive_stream); | 807 static_cast<VideoReceiveStream*>(receive_stream); |
817 const VideoReceiveStream::Config& config = receive_stream_impl->config(); | 808 const VideoReceiveStream::Config& config = receive_stream_impl->config(); |
818 { | 809 { |
819 WriteLockScoped write_lock(*receive_crit_); | 810 WriteLockScoped write_lock(*receive_crit_); |
820 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a | 811 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a |
821 // separate SSRC there can be either one or two. | 812 // separate SSRC there can be either one or two. |
822 size_t num_deleted = video_rtp_demuxer_.RemoveSink(receive_stream_impl); | |
823 RTC_DCHECK_GE(num_deleted, 1); | |
824 receive_rtp_config_.erase(config.rtp.remote_ssrc); | 813 receive_rtp_config_.erase(config.rtp.remote_ssrc); |
825 if (config.rtp.rtx_ssrc) { | 814 if (config.rtp.rtx_ssrc) { |
826 receive_rtp_config_.erase(config.rtp.rtx_ssrc); | 815 receive_rtp_config_.erase(config.rtp.rtx_ssrc); |
827 } | 816 } |
828 video_receive_streams_.erase(receive_stream_impl); | 817 video_receive_streams_.erase(receive_stream_impl); |
829 ConfigureSync(config.sync_group); | 818 ConfigureSync(config.sync_group); |
830 } | 819 } |
831 | 820 |
832 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 821 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) |
833 ->RemoveStream(config.rtp.remote_ssrc); | 822 ->RemoveStream(config.rtp.remote_ssrc); |
834 | 823 |
835 UpdateAggregateNetworkState(); | 824 UpdateAggregateNetworkState(); |
836 delete receive_stream_impl; | 825 delete receive_stream_impl; |
837 } | 826 } |
838 | 827 |
839 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( | 828 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( |
840 const FlexfecReceiveStream::Config& config) { | 829 const FlexfecReceiveStream::Config& config) { |
841 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); | 830 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); |
842 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); | 831 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); |
843 | 832 |
844 RecoveredPacketReceiver* recovered_packet_receiver = this; | 833 RecoveredPacketReceiver* recovered_packet_receiver = this; |
| 834 |
845 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl( | 835 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl( |
846 config, recovered_packet_receiver, call_stats_->rtcp_rtt_stats(), | 836 &video_receiver_controller, config, recovered_packet_receiver, |
847 module_process_thread_.get()); | 837 call_stats_->rtcp_rtt_stats(), module_process_thread_.get()); |
848 | |
849 { | 838 { |
850 WriteLockScoped write_lock(*receive_crit_); | 839 WriteLockScoped write_lock(*receive_crit_); |
851 video_rtp_demuxer_.AddSink(config.remote_ssrc, receive_stream); | |
852 | |
853 for (auto ssrc : config.protected_media_ssrcs) | |
854 video_rtp_demuxer_.AddSink(ssrc, receive_stream); | |
855 | |
856 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) == | 840 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) == |
857 receive_rtp_config_.end()); | 841 receive_rtp_config_.end()); |
858 receive_rtp_config_[config.remote_ssrc] = | 842 receive_rtp_config_[config.remote_ssrc] = |
859 ReceiveRtpConfig(config.rtp_header_extensions, UseSendSideBwe(config)); | 843 ReceiveRtpConfig(config.rtp_header_extensions, UseSendSideBwe(config)); |
860 } | 844 } |
861 | 845 |
862 // TODO(brandtr): Store config in RtcEventLog here. | 846 // TODO(brandtr): Store config in RtcEventLog here. |
863 | 847 |
864 return receive_stream; | 848 return receive_stream; |
865 } | 849 } |
(...skipping 10 matching lines...) Expand all Loading... |
876 { | 860 { |
877 WriteLockScoped write_lock(*receive_crit_); | 861 WriteLockScoped write_lock(*receive_crit_); |
878 | 862 |
879 const FlexfecReceiveStream::Config& config = | 863 const FlexfecReceiveStream::Config& config = |
880 receive_stream_impl->GetConfig(); | 864 receive_stream_impl->GetConfig(); |
881 uint32_t ssrc = config.remote_ssrc; | 865 uint32_t ssrc = config.remote_ssrc; |
882 receive_rtp_config_.erase(ssrc); | 866 receive_rtp_config_.erase(ssrc); |
883 | 867 |
884 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be | 868 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be |
885 // destroyed. | 869 // destroyed. |
886 video_rtp_demuxer_.RemoveSink(receive_stream_impl); | |
887 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 870 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) |
888 ->RemoveStream(ssrc); | 871 ->RemoveStream(ssrc); |
889 } | 872 } |
890 | 873 |
891 delete receive_stream_impl; | 874 delete receive_stream_impl; |
892 } | 875 } |
893 | 876 |
894 Call::Stats Call::GetStats() const { | 877 Call::Stats Call::GetStats() const { |
895 // TODO(solenberg): Some test cases in EndToEndTest use this from a different | 878 // TODO(solenberg): Some test cases in EndToEndTest use this from a different |
896 // thread. Re-enable once that is fixed. | 879 // thread. Re-enable once that is fixed. |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 | 1294 |
1312 ReadLockScoped read_lock(*receive_crit_); | 1295 ReadLockScoped read_lock(*receive_crit_); |
1313 // TODO(nisse): We should parse the RTP header only here, and pass | 1296 // TODO(nisse): We should parse the RTP header only here, and pass |
1314 // on parsed_packet to the receive streams. | 1297 // on parsed_packet to the receive streams. |
1315 rtc::Optional<RtpPacketReceived> parsed_packet = | 1298 rtc::Optional<RtpPacketReceived> parsed_packet = |
1316 ParseRtpPacket(packet, length, &packet_time); | 1299 ParseRtpPacket(packet, length, &packet_time); |
1317 | 1300 |
1318 if (!parsed_packet) | 1301 if (!parsed_packet) |
1319 return DELIVERY_PACKET_ERROR; | 1302 return DELIVERY_PACKET_ERROR; |
1320 | 1303 |
| 1304 auto it = receive_rtp_config_.find(parsed_packet->Ssrc()); |
| 1305 if (it == receive_rtp_config_.end()) { |
| 1306 LOG(LS_ERROR) << "receive_rtp_config_ lookup failed for ssrc " |
| 1307 << parsed_packet->Ssrc(); |
| 1308 // Destruction of the receive stream, including deregistering from the |
| 1309 // RtpDemuxer, is not protected by the |receive_crit_| lock. But |
| 1310 // deregistering in the |receive_rtp_config_| map is protected by that lock. |
| 1311 // So by not passing the packet on to demuxing in this case, we prevent |
| 1312 // incoming packets to be passed on via the demuxer to a receive stream |
| 1313 // which is being torned down. |
| 1314 return DELIVERY_UNKNOWN_SSRC; |
| 1315 } |
| 1316 parsed_packet->IdentifyExtensions(it->second.extensions); |
| 1317 |
1321 NotifyBweOfReceivedPacket(*parsed_packet, media_type); | 1318 NotifyBweOfReceivedPacket(*parsed_packet, media_type); |
1322 | 1319 |
1323 if (media_type == MediaType::AUDIO) { | 1320 if (media_type == MediaType::AUDIO) { |
1324 if (audio_rtp_demuxer_.OnRtpPacket(*parsed_packet)) { | 1321 if (audio_receiver_controller.OnRtpPacket(*parsed_packet)) { |
1325 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1322 received_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1326 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1323 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1327 event_log_->LogRtpHeader(kIncomingPacket, packet, length); | 1324 event_log_->LogRtpHeader(kIncomingPacket, packet, length); |
1328 return DELIVERY_OK; | 1325 return DELIVERY_OK; |
1329 } | 1326 } |
1330 } else if (media_type == MediaType::VIDEO) { | 1327 } else if (media_type == MediaType::VIDEO) { |
1331 if (video_rtp_demuxer_.OnRtpPacket(*parsed_packet)) { | 1328 if (video_receiver_controller.OnRtpPacket(*parsed_packet)) { |
1332 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1329 received_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1333 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1330 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1334 event_log_->LogRtpHeader(kIncomingPacket, packet, length); | 1331 event_log_->LogRtpHeader(kIncomingPacket, packet, length); |
1335 return DELIVERY_OK; | 1332 return DELIVERY_OK; |
1336 } | 1333 } |
1337 } | 1334 } |
1338 return DELIVERY_UNKNOWN_SSRC; | 1335 return DELIVERY_UNKNOWN_SSRC; |
1339 } | 1336 } |
1340 | 1337 |
1341 PacketReceiver::DeliveryStatus Call::DeliverPacket( | 1338 PacketReceiver::DeliveryStatus Call::DeliverPacket( |
(...skipping 15 matching lines...) Expand all Loading... |
1357 // audio packets with FlexFEC. | 1354 // audio packets with FlexFEC. |
1358 void Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { | 1355 void Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { |
1359 ReadLockScoped read_lock(*receive_crit_); | 1356 ReadLockScoped read_lock(*receive_crit_); |
1360 rtc::Optional<RtpPacketReceived> parsed_packet = | 1357 rtc::Optional<RtpPacketReceived> parsed_packet = |
1361 ParseRtpPacket(packet, length, nullptr); | 1358 ParseRtpPacket(packet, length, nullptr); |
1362 if (!parsed_packet) | 1359 if (!parsed_packet) |
1363 return; | 1360 return; |
1364 | 1361 |
1365 parsed_packet->set_recovered(true); | 1362 parsed_packet->set_recovered(true); |
1366 | 1363 |
1367 video_rtp_demuxer_.OnRtpPacket(*parsed_packet); | 1364 video_receiver_controller.OnRtpPacket(*parsed_packet); |
1368 } | 1365 } |
1369 | 1366 |
1370 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, | 1367 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, |
1371 MediaType media_type) { | 1368 MediaType media_type) { |
1372 auto it = receive_rtp_config_.find(packet.Ssrc()); | 1369 auto it = receive_rtp_config_.find(packet.Ssrc()); |
1373 bool use_send_side_bwe = | 1370 bool use_send_side_bwe = |
1374 (it != receive_rtp_config_.end()) && it->second.use_send_side_bwe; | 1371 (it != receive_rtp_config_.end()) && it->second.use_send_side_bwe; |
1375 | 1372 |
1376 RTPHeader header; | 1373 RTPHeader header; |
1377 packet.GetHeader(&header); | 1374 packet.GetHeader(&header); |
(...skipping 13 matching lines...) Expand all Loading... |
1391 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { | 1388 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { |
1392 receive_side_cc_.OnReceivedPacket( | 1389 receive_side_cc_.OnReceivedPacket( |
1393 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), | 1390 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), |
1394 header); | 1391 header); |
1395 } | 1392 } |
1396 } | 1393 } |
1397 | 1394 |
1398 } // namespace internal | 1395 } // namespace internal |
1399 | 1396 |
1400 } // namespace webrtc | 1397 } // namespace webrtc |
OLD | NEW |