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 |
11 #include <string.h> | 11 #include <string.h> |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <map> | 13 #include <map> |
14 #include <memory> | 14 #include <memory> |
15 #include <set> | 15 #include <set> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/audio/audio_receive_stream.h" | 19 #include "webrtc/audio/audio_receive_stream.h" |
20 #include "webrtc/audio/audio_send_stream.h" | 20 #include "webrtc/audio/audio_send_stream.h" |
21 #include "webrtc/audio/audio_state.h" | 21 #include "webrtc/audio/audio_state.h" |
22 #include "webrtc/audio/scoped_voe_interface.h" | 22 #include "webrtc/audio/scoped_voe_interface.h" |
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/optional.h" | |
28 #include "webrtc/base/task_queue.h" | 27 #include "webrtc/base/task_queue.h" |
29 #include "webrtc/base/thread_annotations.h" | 28 #include "webrtc/base/thread_annotations.h" |
30 #include "webrtc/base/thread_checker.h" | 29 #include "webrtc/base/thread_checker.h" |
31 #include "webrtc/base/trace_event.h" | 30 #include "webrtc/base/trace_event.h" |
32 #include "webrtc/call/bitrate_allocator.h" | 31 #include "webrtc/call/bitrate_allocator.h" |
33 #include "webrtc/call/call.h" | 32 #include "webrtc/call/call.h" |
34 #include "webrtc/call/flexfec_receive_stream_impl.h" | 33 #include "webrtc/call/flexfec_receive_stream_impl.h" |
35 #include "webrtc/config.h" | 34 #include "webrtc/config.h" |
36 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 35 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
37 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 36 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
38 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 37 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
39 #include "webrtc/modules/pacing/paced_sender.h" | 38 #include "webrtc/modules/pacing/paced_sender.h" |
40 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" | 39 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" |
41 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 40 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
42 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 41 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
43 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | |
44 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | |
45 #include "webrtc/modules/utility/include/process_thread.h" | 42 #include "webrtc/modules/utility/include/process_thread.h" |
46 #include "webrtc/system_wrappers/include/clock.h" | 43 #include "webrtc/system_wrappers/include/clock.h" |
47 #include "webrtc/system_wrappers/include/cpu_info.h" | 44 #include "webrtc/system_wrappers/include/cpu_info.h" |
48 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 45 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
49 #include "webrtc/system_wrappers/include/metrics.h" | 46 #include "webrtc/system_wrappers/include/metrics.h" |
50 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" | 47 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" |
51 #include "webrtc/system_wrappers/include/trace.h" | 48 #include "webrtc/system_wrappers/include/trace.h" |
52 #include "webrtc/video/call_stats.h" | 49 #include "webrtc/video/call_stats.h" |
53 #include "webrtc/video/send_delay_stats.h" | 50 #include "webrtc/video/send_delay_stats.h" |
54 #include "webrtc/video/stats_counter.h" | 51 #include "webrtc/video/stats_counter.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 100 |
104 // Implements PacketReceiver. | 101 // Implements PacketReceiver. |
105 DeliveryStatus DeliverPacket(MediaType media_type, | 102 DeliveryStatus DeliverPacket(MediaType media_type, |
106 const uint8_t* packet, | 103 const uint8_t* packet, |
107 size_t length, | 104 size_t length, |
108 const PacketTime& packet_time) override; | 105 const PacketTime& packet_time) override; |
109 | 106 |
110 // Implements RecoveredPacketReceiver. | 107 // Implements RecoveredPacketReceiver. |
111 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; | 108 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; |
112 | 109 |
113 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet); | |
114 | |
115 void SetBitrateConfig( | 110 void SetBitrateConfig( |
116 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; | 111 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; |
117 | 112 |
118 void SignalChannelNetworkState(MediaType media, NetworkState state) override; | 113 void SignalChannelNetworkState(MediaType media, NetworkState state) override; |
119 | 114 |
120 void OnTransportOverheadChanged(MediaType media, | 115 void OnTransportOverheadChanged(MediaType media, |
121 int transport_overhead_per_packet) override; | 116 int transport_overhead_per_packet) override; |
122 | 117 |
123 void OnNetworkRouteChanged(const std::string& transport_name, | 118 void OnNetworkRouteChanged(const std::string& transport_name, |
124 const rtc::NetworkRoute& network_route) override; | 119 const rtc::NetworkRoute& network_route) override; |
(...skipping 27 matching lines...) Expand all Loading... |
152 | 147 |
153 VoiceEngine* voice_engine() { | 148 VoiceEngine* voice_engine() { |
154 internal::AudioState* audio_state = | 149 internal::AudioState* audio_state = |
155 static_cast<internal::AudioState*>(config_.audio_state.get()); | 150 static_cast<internal::AudioState*>(config_.audio_state.get()); |
156 if (audio_state) | 151 if (audio_state) |
157 return audio_state->voice_engine(); | 152 return audio_state->voice_engine(); |
158 else | 153 else |
159 return nullptr; | 154 return nullptr; |
160 } | 155 } |
161 | 156 |
162 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, | |
163 size_t length, | |
164 const PacketTime& packet_time) | |
165 SHARED_LOCKS_REQUIRED(receive_crit_); | |
166 | |
167 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); | 157 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); |
168 void UpdateReceiveHistograms(); | 158 void UpdateReceiveHistograms(); |
169 void UpdateHistograms(); | 159 void UpdateHistograms(); |
170 void UpdateAggregateNetworkState(); | 160 void UpdateAggregateNetworkState(); |
171 | 161 |
172 Clock* const clock_; | 162 Clock* const clock_; |
173 | 163 |
174 const int num_cpu_cores_; | 164 const int num_cpu_cores_; |
175 const std::unique_ptr<ProcessThread> module_process_thread_; | 165 const std::unique_ptr<ProcessThread> module_process_thread_; |
176 const std::unique_ptr<ProcessThread> pacer_thread_; | 166 const std::unique_ptr<ProcessThread> pacer_thread_; |
(...skipping 18 matching lines...) Expand all Loading... |
195 // streams. | 185 // streams. |
196 std::multimap<uint32_t, FlexfecReceiveStreamImpl*> | 186 std::multimap<uint32_t, FlexfecReceiveStreamImpl*> |
197 flexfec_receive_ssrcs_media_ GUARDED_BY(receive_crit_); | 187 flexfec_receive_ssrcs_media_ GUARDED_BY(receive_crit_); |
198 std::map<uint32_t, FlexfecReceiveStreamImpl*> | 188 std::map<uint32_t, FlexfecReceiveStreamImpl*> |
199 flexfec_receive_ssrcs_protection_ GUARDED_BY(receive_crit_); | 189 flexfec_receive_ssrcs_protection_ GUARDED_BY(receive_crit_); |
200 std::set<FlexfecReceiveStreamImpl*> flexfec_receive_streams_ | 190 std::set<FlexfecReceiveStreamImpl*> flexfec_receive_streams_ |
201 GUARDED_BY(receive_crit_); | 191 GUARDED_BY(receive_crit_); |
202 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ | 192 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ |
203 GUARDED_BY(receive_crit_); | 193 GUARDED_BY(receive_crit_); |
204 | 194 |
205 // Registered RTP header extensions for each stream. | |
206 // Note that RTP header extensions are negotiated per track ("m= line") in the | |
207 // SDP, but we have no notion of tracks at the Call level. We therefore store | |
208 // the RTP header extensions per SSRC instead, which leads to some storage | |
209 // overhead. | |
210 std::map<uint32_t, RtpHeaderExtensionMap> received_rtp_header_extensions_ | |
211 GUARDED_BY(receive_crit_); | |
212 | |
213 std::unique_ptr<RWLockWrapper> send_crit_; | 195 std::unique_ptr<RWLockWrapper> send_crit_; |
214 // 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. |
215 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_); |
216 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_); |
217 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); | 199 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
218 | 200 |
219 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; | 201 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; |
220 webrtc::RtcEventLog* event_log_; | 202 webrtc::RtcEventLog* event_log_; |
221 | 203 |
222 // The following members are only accessed (exclusively) from one thread and | 204 // The following members are only accessed (exclusively) from one thread and |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 { | 338 { |
357 rtc::CritScope lock(&bitrate_crit_); | 339 rtc::CritScope lock(&bitrate_crit_); |
358 UpdateSendHistograms(); | 340 UpdateSendHistograms(); |
359 } | 341 } |
360 UpdateReceiveHistograms(); | 342 UpdateReceiveHistograms(); |
361 UpdateHistograms(); | 343 UpdateHistograms(); |
362 | 344 |
363 Trace::ReturnTrace(); | 345 Trace::ReturnTrace(); |
364 } | 346 } |
365 | 347 |
366 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( | |
367 const uint8_t* packet, | |
368 size_t length, | |
369 const PacketTime& packet_time) { | |
370 RtpPacketReceived parsed_packet; | |
371 if (!parsed_packet.Parse(packet, length)) | |
372 return rtc::Optional<RtpPacketReceived>(); | |
373 | |
374 auto it = received_rtp_header_extensions_.find(parsed_packet.Ssrc()); | |
375 if (it != received_rtp_header_extensions_.end()) | |
376 parsed_packet.IdentifyExtensions(it->second); | |
377 | |
378 int64_t arrival_time_ms; | |
379 if (packet_time.timestamp != -1) { | |
380 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | |
381 } else { | |
382 arrival_time_ms = clock_->TimeInMilliseconds(); | |
383 } | |
384 parsed_packet.set_arrival_time_ms(arrival_time_ms); | |
385 | |
386 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); | |
387 } | |
388 | |
389 void Call::UpdateHistograms() { | 348 void Call::UpdateHistograms() { |
390 RTC_HISTOGRAM_COUNTS_100000( | 349 RTC_HISTOGRAM_COUNTS_100000( |
391 "WebRTC.Call.LifetimeInSeconds", | 350 "WebRTC.Call.LifetimeInSeconds", |
392 (clock_->TimeInMilliseconds() - start_ms_) / 1000); | 351 (clock_->TimeInMilliseconds() - start_ms_) / 1000); |
393 } | 352 } |
394 | 353 |
395 void Call::UpdateSendHistograms() { | 354 void Call::UpdateSendHistograms() { |
396 if (first_packet_sent_ms_ == -1) | 355 if (first_packet_sent_ms_ == -1) |
397 return; | 356 return; |
398 int64_t elapsed_sec = | 357 int64_t elapsed_sec = |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 ConfigureSync(receive_stream_impl->config().sync_group); | 652 ConfigureSync(receive_stream_impl->config().sync_group); |
694 } | 653 } |
695 UpdateAggregateNetworkState(); | 654 UpdateAggregateNetworkState(); |
696 delete receive_stream_impl; | 655 delete receive_stream_impl; |
697 } | 656 } |
698 | 657 |
699 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( | 658 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( |
700 const FlexfecReceiveStream::Config& config) { | 659 const FlexfecReceiveStream::Config& config) { |
701 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); | 660 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); |
702 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 661 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
703 | |
704 RecoveredPacketReceiver* recovered_packet_receiver = this; | |
705 FlexfecReceiveStreamImpl* receive_stream = | 662 FlexfecReceiveStreamImpl* receive_stream = |
706 new FlexfecReceiveStreamImpl(config, recovered_packet_receiver); | 663 new FlexfecReceiveStreamImpl(config, this); |
707 | 664 |
708 { | 665 { |
709 WriteLockScoped write_lock(*receive_crit_); | 666 WriteLockScoped write_lock(*receive_crit_); |
710 | |
711 RTC_DCHECK(flexfec_receive_streams_.find(receive_stream) == | |
712 flexfec_receive_streams_.end()); | |
713 flexfec_receive_streams_.insert(receive_stream); | |
714 | |
715 for (auto ssrc : config.protected_media_ssrcs) | 667 for (auto ssrc : config.protected_media_ssrcs) |
716 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); | 668 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); |
717 | |
718 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == | 669 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == |
719 flexfec_receive_ssrcs_protection_.end()); | 670 flexfec_receive_ssrcs_protection_.end()); |
720 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; | 671 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; |
721 | 672 flexfec_receive_streams_.insert(receive_stream); |
722 RTC_DCHECK(received_rtp_header_extensions_.find(config.remote_ssrc) == | |
723 received_rtp_header_extensions_.end()); | |
724 RtpHeaderExtensionMap rtp_header_extensions(config.rtp_header_extensions); | |
725 received_rtp_header_extensions_[config.remote_ssrc] = rtp_header_extensions; | |
726 } | 673 } |
727 | |
728 // TODO(brandtr): Store config in RtcEventLog here. | 674 // TODO(brandtr): Store config in RtcEventLog here. |
729 | |
730 return receive_stream; | 675 return receive_stream; |
731 } | 676 } |
732 | 677 |
733 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { | 678 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { |
734 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); | 679 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); |
735 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 680 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
736 | |
737 RTC_DCHECK(receive_stream != nullptr); | 681 RTC_DCHECK(receive_stream != nullptr); |
738 // There exist no other derived classes of FlexfecReceiveStream, | 682 // There exist no other derived classes of FlexfecReceiveStream, |
739 // so this downcast is safe. | 683 // so this downcast is safe. |
740 FlexfecReceiveStreamImpl* receive_stream_impl = | 684 FlexfecReceiveStreamImpl* receive_stream_impl = |
741 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); | 685 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); |
742 { | 686 { |
743 WriteLockScoped write_lock(*receive_crit_); | 687 WriteLockScoped write_lock(*receive_crit_); |
744 | |
745 uint32_t ssrc = receive_stream_impl->GetConfig().remote_ssrc; | |
746 received_rtp_header_extensions_.erase(ssrc); | |
747 | |
748 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be | 688 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be |
749 // destroyed. | 689 // destroyed. |
| 690 auto media_it = flexfec_receive_ssrcs_media_.begin(); |
| 691 while (media_it != flexfec_receive_ssrcs_media_.end()) { |
| 692 if (media_it->second == receive_stream_impl) |
| 693 media_it = flexfec_receive_ssrcs_media_.erase(media_it); |
| 694 else |
| 695 ++media_it; |
| 696 } |
750 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); | 697 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); |
751 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { | 698 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { |
752 if (prot_it->second == receive_stream_impl) | 699 if (prot_it->second == receive_stream_impl) |
753 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); | 700 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); |
754 else | 701 else |
755 ++prot_it; | 702 ++prot_it; |
756 } | 703 } |
757 auto media_it = flexfec_receive_ssrcs_media_.begin(); | |
758 while (media_it != flexfec_receive_ssrcs_media_.end()) { | |
759 if (media_it->second == receive_stream_impl) | |
760 media_it = flexfec_receive_ssrcs_media_.erase(media_it); | |
761 else | |
762 ++media_it; | |
763 } | |
764 | |
765 flexfec_receive_streams_.erase(receive_stream_impl); | 704 flexfec_receive_streams_.erase(receive_stream_impl); |
766 } | 705 } |
767 | |
768 delete receive_stream_impl; | 706 delete receive_stream_impl; |
769 } | 707 } |
770 | 708 |
771 Call::Stats Call::GetStats() const { | 709 Call::Stats Call::GetStats() const { |
772 // TODO(solenberg): Some test cases in EndToEndTest use this from a different | 710 // TODO(solenberg): Some test cases in EndToEndTest use this from a different |
773 // thread. Re-enable once that is fixed. | 711 // thread. Re-enable once that is fixed. |
774 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 712 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
775 Stats stats; | 713 Stats stats; |
776 // Fetch available send/receive bitrates. | 714 // Fetch available send/receive bitrates. |
777 uint32_t send_bandwidth = 0; | 715 uint32_t send_bandwidth = 0; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 if (status == DELIVERY_OK) | 1069 if (status == DELIVERY_OK) |
1132 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1070 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1133 return status; | 1071 return status; |
1134 } | 1072 } |
1135 } | 1073 } |
1136 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 1074 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
1137 auto it = video_receive_ssrcs_.find(ssrc); | 1075 auto it = video_receive_ssrcs_.find(ssrc); |
1138 if (it != video_receive_ssrcs_.end()) { | 1076 if (it != video_receive_ssrcs_.end()) { |
1139 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1077 received_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1140 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1078 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1141 // TODO(brandtr): Notify the BWE of received media packets here. | |
1142 auto status = it->second->DeliverRtp(packet, length, packet_time) | 1079 auto status = it->second->DeliverRtp(packet, length, packet_time) |
1143 ? DELIVERY_OK | 1080 ? DELIVERY_OK |
1144 : DELIVERY_PACKET_ERROR; | 1081 : DELIVERY_PACKET_ERROR; |
1145 // Deliver media packets to FlexFEC subsystem. RTP header extensions need | 1082 // Deliver media packets to FlexFEC subsystem. |
1146 // not be parsed, as FlexFEC is oblivious to the semantic meaning of the | 1083 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); |
1147 // packet contents beyond the 12 byte RTP base header. The BWE is fed | 1084 for (auto it = it_bounds.first; it != it_bounds.second; ++it) |
1148 // information about these media packets from the regular media pipeline. | 1085 it->second->AddAndProcessReceivedPacket(packet, length); |
1149 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1150 ParseRtpPacket(packet, length, packet_time); | |
1151 if (parsed_packet) { | |
1152 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); | |
1153 for (auto it = it_bounds.first; it != it_bounds.second; ++it) | |
1154 it->second->AddAndProcessReceivedPacket(*parsed_packet); | |
1155 } | |
1156 if (status == DELIVERY_OK) | 1086 if (status == DELIVERY_OK) |
1157 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1087 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1158 return status; | 1088 return status; |
1159 } | 1089 } |
1160 } | 1090 } |
1161 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 1091 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
1162 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); | 1092 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); |
1163 if (it != flexfec_receive_ssrcs_protection_.end()) { | 1093 if (it != flexfec_receive_ssrcs_protection_.end()) { |
1164 rtc::Optional<RtpPacketReceived> parsed_packet = | 1094 auto status = it->second->AddAndProcessReceivedPacket(packet, length) |
1165 ParseRtpPacket(packet, length, packet_time); | 1095 ? DELIVERY_OK |
1166 if (parsed_packet) { | 1096 : DELIVERY_PACKET_ERROR; |
1167 NotifyBweOfReceivedPacket(*parsed_packet); | 1097 if (status == DELIVERY_OK) |
1168 auto status = | 1098 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1169 it->second->AddAndProcessReceivedPacket(std::move(*parsed_packet)) | 1099 return status; |
1170 ? DELIVERY_OK | |
1171 : DELIVERY_PACKET_ERROR; | |
1172 if (status == DELIVERY_OK) | |
1173 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | |
1174 return status; | |
1175 } | |
1176 } | 1100 } |
1177 } | 1101 } |
1178 return DELIVERY_UNKNOWN_SSRC; | 1102 return DELIVERY_UNKNOWN_SSRC; |
1179 } | 1103 } |
1180 | 1104 |
1181 PacketReceiver::DeliveryStatus Call::DeliverPacket( | 1105 PacketReceiver::DeliveryStatus Call::DeliverPacket( |
1182 MediaType media_type, | 1106 MediaType media_type, |
1183 const uint8_t* packet, | 1107 const uint8_t* packet, |
1184 size_t length, | 1108 size_t length, |
1185 const PacketTime& packet_time) { | 1109 const PacketTime& packet_time) { |
(...skipping 11 matching lines...) Expand all Loading... |
1197 // audio packets with FlexFEC. | 1121 // audio packets with FlexFEC. |
1198 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { | 1122 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { |
1199 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1123 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
1200 ReadLockScoped read_lock(*receive_crit_); | 1124 ReadLockScoped read_lock(*receive_crit_); |
1201 auto it = video_receive_ssrcs_.find(ssrc); | 1125 auto it = video_receive_ssrcs_.find(ssrc); |
1202 if (it == video_receive_ssrcs_.end()) | 1126 if (it == video_receive_ssrcs_.end()) |
1203 return false; | 1127 return false; |
1204 return it->second->OnRecoveredPacket(packet, length); | 1128 return it->second->OnRecoveredPacket(packet, length); |
1205 } | 1129 } |
1206 | 1130 |
1207 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { | |
1208 RTPHeader header; | |
1209 packet.GetHeader(&header); | |
1210 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), | |
1211 packet.payload_size(), header); | |
1212 } | |
1213 | |
1214 } // namespace internal | 1131 } // namespace internal |
1215 } // namespace webrtc | 1132 } // namespace webrtc |
OLD | NEW |