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 12 matching lines...) Expand all Loading... |
23 #include "webrtc/base/basictypes.h" | 23 #include "webrtc/base/basictypes.h" |
24 #include "webrtc/base/checks.h" | 24 #include "webrtc/base/checks.h" |
25 #include "webrtc/base/constructormagic.h" | 25 #include "webrtc/base/constructormagic.h" |
26 #include "webrtc/base/logging.h" | 26 #include "webrtc/base/logging.h" |
27 #include "webrtc/base/task_queue.h" | 27 #include "webrtc/base/task_queue.h" |
28 #include "webrtc/base/thread_annotations.h" | 28 #include "webrtc/base/thread_annotations.h" |
29 #include "webrtc/base/thread_checker.h" | 29 #include "webrtc/base/thread_checker.h" |
30 #include "webrtc/base/trace_event.h" | 30 #include "webrtc/base/trace_event.h" |
31 #include "webrtc/call/bitrate_allocator.h" | 31 #include "webrtc/call/bitrate_allocator.h" |
32 #include "webrtc/call/call.h" | 32 #include "webrtc/call/call.h" |
33 #include "webrtc/call/flexfec_receive_stream.h" | 33 #include "webrtc/call/flexfec_receive_stream_impl.h" |
34 #include "webrtc/config.h" | 34 #include "webrtc/config.h" |
35 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 35 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
36 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 36 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
37 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 37 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
38 #include "webrtc/modules/pacing/paced_sender.h" | 38 #include "webrtc/modules/pacing/paced_sender.h" |
39 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" | 39 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" |
40 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 40 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
41 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 41 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
42 #include "webrtc/modules/utility/include/process_thread.h" | 42 #include "webrtc/modules/utility/include/process_thread.h" |
43 #include "webrtc/system_wrappers/include/clock.h" | 43 #include "webrtc/system_wrappers/include/clock.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 webrtc::VideoSendStream* CreateVideoSendStream( | 84 webrtc::VideoSendStream* CreateVideoSendStream( |
85 webrtc::VideoSendStream::Config config, | 85 webrtc::VideoSendStream::Config config, |
86 VideoEncoderConfig encoder_config) override; | 86 VideoEncoderConfig encoder_config) override; |
87 void DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) override; | 87 void DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) override; |
88 | 88 |
89 webrtc::VideoReceiveStream* CreateVideoReceiveStream( | 89 webrtc::VideoReceiveStream* CreateVideoReceiveStream( |
90 webrtc::VideoReceiveStream::Config configuration) override; | 90 webrtc::VideoReceiveStream::Config configuration) override; |
91 void DestroyVideoReceiveStream( | 91 void DestroyVideoReceiveStream( |
92 webrtc::VideoReceiveStream* receive_stream) override; | 92 webrtc::VideoReceiveStream* receive_stream) override; |
93 | 93 |
94 webrtc::FlexfecReceiveStream* CreateFlexfecReceiveStream( | 94 FlexfecReceiveStream* CreateFlexfecReceiveStream( |
95 const webrtc::FlexfecReceiveStream::Config& config) override; | 95 const FlexfecReceiveStream::Config& config) override; |
96 void DestroyFlexfecReceiveStream( | 96 void DestroyFlexfecReceiveStream( |
97 webrtc::FlexfecReceiveStream* receive_stream) override; | 97 FlexfecReceiveStream* receive_stream) override; |
98 | 98 |
99 Stats GetStats() const override; | 99 Stats GetStats() const override; |
100 | 100 |
101 // Implements PacketReceiver. | 101 // Implements PacketReceiver. |
102 DeliveryStatus DeliverPacket(MediaType media_type, | 102 DeliveryStatus DeliverPacket(MediaType media_type, |
103 const uint8_t* packet, | 103 const uint8_t* packet, |
104 size_t length, | 104 size_t length, |
105 const PacketTime& packet_time) override; | 105 const PacketTime& packet_time) override; |
106 | 106 |
107 // Implements RecoveredPacketReceiver. | 107 // Implements RecoveredPacketReceiver. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Audio, Video, and FlexFEC receive streams are owned by the client that | 176 // Audio, Video, and FlexFEC receive streams are owned by the client that |
177 // creates them. | 177 // creates them. |
178 std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_ | 178 std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_ |
179 GUARDED_BY(receive_crit_); | 179 GUARDED_BY(receive_crit_); |
180 std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_ | 180 std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_ |
181 GUARDED_BY(receive_crit_); | 181 GUARDED_BY(receive_crit_); |
182 std::set<VideoReceiveStream*> video_receive_streams_ | 182 std::set<VideoReceiveStream*> video_receive_streams_ |
183 GUARDED_BY(receive_crit_); | 183 GUARDED_BY(receive_crit_); |
184 // Each media stream could conceivably be protected by multiple FlexFEC | 184 // Each media stream could conceivably be protected by multiple FlexFEC |
185 // streams. | 185 // streams. |
186 std::multimap<uint32_t, FlexfecReceiveStream*> flexfec_receive_ssrcs_media_ | 186 std::multimap<uint32_t, FlexfecReceiveStreamImpl*> |
187 GUARDED_BY(receive_crit_); | 187 flexfec_receive_ssrcs_media_ GUARDED_BY(receive_crit_); |
188 std::map<uint32_t, FlexfecReceiveStream*> flexfec_receive_ssrcs_protection_ | 188 std::map<uint32_t, FlexfecReceiveStreamImpl*> |
189 GUARDED_BY(receive_crit_); | 189 flexfec_receive_ssrcs_protection_ GUARDED_BY(receive_crit_); |
190 std::set<FlexfecReceiveStream*> flexfec_receive_streams_ | 190 std::set<FlexfecReceiveStreamImpl*> flexfec_receive_streams_ |
191 GUARDED_BY(receive_crit_); | 191 GUARDED_BY(receive_crit_); |
192 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ | 192 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ |
193 GUARDED_BY(receive_crit_); | 193 GUARDED_BY(receive_crit_); |
194 | 194 |
195 std::unique_ptr<RWLockWrapper> send_crit_; | 195 std::unique_ptr<RWLockWrapper> send_crit_; |
196 // Audio and Video send streams are owned by the client that creates them. | 196 // Audio and Video send streams are owned by the client that creates them. |
197 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); | 197 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); |
198 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); | 198 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
199 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); | 199 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
200 | 200 |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 } | 648 } |
649 } | 649 } |
650 video_receive_streams_.erase(receive_stream_impl); | 650 video_receive_streams_.erase(receive_stream_impl); |
651 RTC_CHECK(receive_stream_impl != nullptr); | 651 RTC_CHECK(receive_stream_impl != nullptr); |
652 ConfigureSync(receive_stream_impl->config().sync_group); | 652 ConfigureSync(receive_stream_impl->config().sync_group); |
653 } | 653 } |
654 UpdateAggregateNetworkState(); | 654 UpdateAggregateNetworkState(); |
655 delete receive_stream_impl; | 655 delete receive_stream_impl; |
656 } | 656 } |
657 | 657 |
658 webrtc::FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( | 658 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( |
659 const webrtc::FlexfecReceiveStream::Config& config) { | 659 const FlexfecReceiveStream::Config& config) { |
660 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); | 660 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); |
661 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 661 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
662 FlexfecReceiveStream* receive_stream = new FlexfecReceiveStream(config, this); | 662 FlexfecReceiveStreamImpl* receive_stream = |
| 663 new FlexfecReceiveStreamImpl(config, this); |
663 | 664 |
664 { | 665 { |
665 WriteLockScoped write_lock(*receive_crit_); | 666 WriteLockScoped write_lock(*receive_crit_); |
666 for (auto ssrc : config.protected_media_ssrcs) | 667 for (auto ssrc : config.protected_media_ssrcs) |
667 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); | 668 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); |
668 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == | 669 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == |
669 flexfec_receive_ssrcs_protection_.end()); | 670 flexfec_receive_ssrcs_protection_.end()); |
670 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; | 671 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; |
671 flexfec_receive_streams_.insert(receive_stream); | 672 flexfec_receive_streams_.insert(receive_stream); |
672 } | 673 } |
673 // TODO(brandtr): Store config in RtcEventLog here. | 674 // TODO(brandtr): Store config in RtcEventLog here. |
674 return receive_stream; | 675 return receive_stream; |
675 } | 676 } |
676 | 677 |
677 void Call::DestroyFlexfecReceiveStream( | 678 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { |
678 webrtc::FlexfecReceiveStream* receive_stream) { | |
679 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); | 679 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); |
680 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 680 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
681 RTC_DCHECK(receive_stream != nullptr); | 681 RTC_DCHECK(receive_stream != nullptr); |
682 // There exist no other derived classes of webrtc::FlexfecReceiveStream, | 682 // There exist no other derived classes of FlexfecReceiveStream, |
683 // so this downcast is safe. | 683 // so this downcast is safe. |
684 FlexfecReceiveStream* receive_stream_impl = | 684 FlexfecReceiveStreamImpl* receive_stream_impl = |
685 static_cast<FlexfecReceiveStream*>(receive_stream); | 685 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); |
686 { | 686 { |
687 WriteLockScoped write_lock(*receive_crit_); | 687 WriteLockScoped write_lock(*receive_crit_); |
688 // Remove all SSRCs pointing to the FlexfecReceiveStream to be destroyed. | 688 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be |
| 689 // destroyed. |
689 auto media_it = flexfec_receive_ssrcs_media_.begin(); | 690 auto media_it = flexfec_receive_ssrcs_media_.begin(); |
690 while (media_it != flexfec_receive_ssrcs_media_.end()) { | 691 while (media_it != flexfec_receive_ssrcs_media_.end()) { |
691 if (media_it->second == receive_stream_impl) | 692 if (media_it->second == receive_stream_impl) |
692 media_it = flexfec_receive_ssrcs_media_.erase(media_it); | 693 media_it = flexfec_receive_ssrcs_media_.erase(media_it); |
693 else | 694 else |
694 ++media_it; | 695 ++media_it; |
695 } | 696 } |
696 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); | 697 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); |
697 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { | 698 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { |
698 if (prot_it->second == receive_stream_impl) | 699 if (prot_it->second == receive_stream_impl) |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1123 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
1123 ReadLockScoped read_lock(*receive_crit_); | 1124 ReadLockScoped read_lock(*receive_crit_); |
1124 auto it = video_receive_ssrcs_.find(ssrc); | 1125 auto it = video_receive_ssrcs_.find(ssrc); |
1125 if (it == video_receive_ssrcs_.end()) | 1126 if (it == video_receive_ssrcs_.end()) |
1126 return false; | 1127 return false; |
1127 return it->second->OnRecoveredPacket(packet, length); | 1128 return it->second->OnRecoveredPacket(packet, length); |
1128 } | 1129 } |
1129 | 1130 |
1130 } // namespace internal | 1131 } // namespace internal |
1131 } // namespace webrtc | 1132 } // namespace webrtc |
OLD | NEW |