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