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

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

Issue 2553863003: Parse FlexFEC RTP headers in Call and add integration with BWE. (Closed)
Patch Set: philipel comments 1 + danilchap comments 2. LACKING TESTS. Created 4 years 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
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.h" 34 #include "webrtc/call/flexfec_receive_stream.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_header_extensions.h"
45 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
42 #include "webrtc/modules/utility/include/process_thread.h" 46 #include "webrtc/modules/utility/include/process_thread.h"
43 #include "webrtc/system_wrappers/include/clock.h" 47 #include "webrtc/system_wrappers/include/clock.h"
44 #include "webrtc/system_wrappers/include/cpu_info.h" 48 #include "webrtc/system_wrappers/include/cpu_info.h"
45 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 49 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
46 #include "webrtc/system_wrappers/include/metrics.h" 50 #include "webrtc/system_wrappers/include/metrics.h"
47 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" 51 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h"
48 #include "webrtc/system_wrappers/include/trace.h" 52 #include "webrtc/system_wrappers/include/trace.h"
49 #include "webrtc/video/call_stats.h" 53 #include "webrtc/video/call_stats.h"
50 #include "webrtc/video/send_delay_stats.h" 54 #include "webrtc/video/send_delay_stats.h"
51 #include "webrtc/video/stats_counter.h" 55 #include "webrtc/video/stats_counter.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 104
101 // Implements PacketReceiver. 105 // Implements PacketReceiver.
102 DeliveryStatus DeliverPacket(MediaType media_type, 106 DeliveryStatus DeliverPacket(MediaType media_type,
103 const uint8_t* packet, 107 const uint8_t* packet,
104 size_t length, 108 size_t length,
105 const PacketTime& packet_time) override; 109 const PacketTime& packet_time) override;
106 110
107 // Implements RecoveredPacketReceiver. 111 // Implements RecoveredPacketReceiver.
108 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; 112 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override;
109 113
114 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet);
115
110 void SetBitrateConfig( 116 void SetBitrateConfig(
111 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; 117 const webrtc::Call::Config::BitrateConfig& bitrate_config) override;
112 118
113 void SignalChannelNetworkState(MediaType media, NetworkState state) override; 119 void SignalChannelNetworkState(MediaType media, NetworkState state) override;
114 120
115 void OnTransportOverheadChanged(MediaType media, 121 void OnTransportOverheadChanged(MediaType media,
116 int transport_overhead_per_packet) override; 122 int transport_overhead_per_packet) override;
117 123
118 void OnNetworkRouteChanged(const std::string& transport_name, 124 void OnNetworkRouteChanged(const std::string& transport_name,
119 const rtc::NetworkRoute& network_route) override; 125 const rtc::NetworkRoute& network_route) override;
(...skipping 27 matching lines...) Expand all
147 153
148 VoiceEngine* voice_engine() { 154 VoiceEngine* voice_engine() {
149 internal::AudioState* audio_state = 155 internal::AudioState* audio_state =
150 static_cast<internal::AudioState*>(config_.audio_state.get()); 156 static_cast<internal::AudioState*>(config_.audio_state.get());
151 if (audio_state) 157 if (audio_state)
152 return audio_state->voice_engine(); 158 return audio_state->voice_engine();
153 else 159 else
154 return nullptr; 160 return nullptr;
155 } 161 }
156 162
163 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet,
164 size_t length,
165 const PacketTime& packet_time)
166 SHARED_LOCKS_REQUIRED(receive_crit_);
167
157 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); 168 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_);
158 void UpdateReceiveHistograms(); 169 void UpdateReceiveHistograms();
159 void UpdateHistograms(); 170 void UpdateHistograms();
160 void UpdateAggregateNetworkState(); 171 void UpdateAggregateNetworkState();
161 172
162 Clock* const clock_; 173 Clock* const clock_;
163 174
164 const int num_cpu_cores_; 175 const int num_cpu_cores_;
165 const std::unique_ptr<ProcessThread> module_process_thread_; 176 const std::unique_ptr<ProcessThread> module_process_thread_;
166 const std::unique_ptr<ProcessThread> pacer_thread_; 177 const std::unique_ptr<ProcessThread> pacer_thread_;
(...skipping 18 matching lines...) Expand all
185 // streams. 196 // streams.
186 std::multimap<uint32_t, FlexfecReceiveStream*> flexfec_receive_ssrcs_media_ 197 std::multimap<uint32_t, FlexfecReceiveStream*> flexfec_receive_ssrcs_media_
187 GUARDED_BY(receive_crit_); 198 GUARDED_BY(receive_crit_);
188 std::map<uint32_t, FlexfecReceiveStream*> flexfec_receive_ssrcs_protection_ 199 std::map<uint32_t, FlexfecReceiveStream*> flexfec_receive_ssrcs_protection_
189 GUARDED_BY(receive_crit_); 200 GUARDED_BY(receive_crit_);
190 std::set<FlexfecReceiveStream*> flexfec_receive_streams_ 201 std::set<FlexfecReceiveStream*> flexfec_receive_streams_
191 GUARDED_BY(receive_crit_); 202 GUARDED_BY(receive_crit_);
192 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ 203 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_
193 GUARDED_BY(receive_crit_); 204 GUARDED_BY(receive_crit_);
194 205
206 // Registered RTP header extensions for each stream.
207 // Note that RTP header extensions are negotiated per track ("m= line") in the
208 // SDP, but we have no notion of tracks at the Call level. We therefore store
209 // the RTP header extensions per SSRC instead, which leads to some storage
210 // overhead.
211 std::map<uint32_t, RtpHeaderExtensionMap> received_rtp_header_extensions_
212 GUARDED_BY(receive_crit_);
213
195 std::unique_ptr<RWLockWrapper> send_crit_; 214 std::unique_ptr<RWLockWrapper> send_crit_;
196 // Audio and Video send streams are owned by the client that creates them. 215 // 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_); 216 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_); 217 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_);
199 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); 218 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_);
200 219
201 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; 220 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
202 webrtc::RtcEventLog* event_log_; 221 webrtc::RtcEventLog* event_log_;
203 222
204 // The following members are only accessed (exclusively) from one thread and 223 // The following members are only accessed (exclusively) from one thread and
(...skipping 14 matching lines...) Expand all
219 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); 238 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_);
220 239
221 std::map<std::string, rtc::NetworkRoute> network_routes_; 240 std::map<std::string, rtc::NetworkRoute> network_routes_;
222 241
223 VieRemb remb_; 242 VieRemb remb_;
224 PacketRouter packet_router_; 243 PacketRouter packet_router_;
225 // TODO(nisse): Could be a direct member, except for constness 244 // TODO(nisse): Could be a direct member, except for constness
226 // issues with GetRemoteBitrateEstimator (and maybe others). 245 // issues with GetRemoteBitrateEstimator (and maybe others).
227 const std::unique_ptr<CongestionController> congestion_controller_; 246 const std::unique_ptr<CongestionController> congestion_controller_;
228 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; 247 const std::unique_ptr<SendDelayStats> video_send_delay_stats_;
248 // Cached results from congestion_controller_->GetRemoteBitrateEstimator.
249 // Currently only used by FlexFEC in ParseRtpPacket.
250 RemoteBitrateEstimator* const remote_bitrate_estimator_;
251 RemoteBitrateEstimator* const remote_estimator_proxy_; // Send-side BWE.
229 const int64_t start_ms_; 252 const int64_t start_ms_;
230 // TODO(perkj): |worker_queue_| is supposed to replace 253 // TODO(perkj): |worker_queue_| is supposed to replace
231 // |module_process_thread_|. 254 // |module_process_thread_|.
232 // |worker_queue| is defined last to ensure all pending tasks are cancelled 255 // |worker_queue| is defined last to ensure all pending tasks are cancelled
233 // and deleted before any other members. 256 // and deleted before any other members.
234 rtc::TaskQueue worker_queue_; 257 rtc::TaskQueue worker_queue_;
235 258
236 RTC_DISALLOW_COPY_AND_ASSIGN(Call); 259 RTC_DISALLOW_COPY_AND_ASSIGN(Call);
237 }; 260 };
238 } // namespace internal 261 } // namespace internal
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 configured_max_padding_bitrate_bps_(0), 300 configured_max_padding_bitrate_bps_(0),
278 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), 301 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true),
279 pacer_bitrate_kbps_counter_(clock_, nullptr, true), 302 pacer_bitrate_kbps_counter_(clock_, nullptr, true),
280 remb_(clock_), 303 remb_(clock_),
281 congestion_controller_(new CongestionController(clock_, 304 congestion_controller_(new CongestionController(clock_,
282 this, 305 this,
283 &remb_, 306 &remb_,
284 event_log_, 307 event_log_,
285 &packet_router_)), 308 &packet_router_)),
286 video_send_delay_stats_(new SendDelayStats(clock_)), 309 video_send_delay_stats_(new SendDelayStats(clock_)),
310 remote_bitrate_estimator_(
311 congestion_controller_->GetRemoteBitrateEstimator(false)),
312 remote_estimator_proxy_(
313 congestion_controller_->GetRemoteBitrateEstimator(true)),
287 start_ms_(clock_->TimeInMilliseconds()), 314 start_ms_(clock_->TimeInMilliseconds()),
288 worker_queue_("call_worker_queue") { 315 worker_queue_("call_worker_queue") {
289 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 316 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
290 RTC_DCHECK(config.event_log != nullptr); 317 RTC_DCHECK(config.event_log != nullptr);
291 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); 318 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
292 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, 319 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps,
293 config.bitrate_config.min_bitrate_bps); 320 config.bitrate_config.min_bitrate_bps);
294 if (config.bitrate_config.max_bitrate_bps != -1) { 321 if (config.bitrate_config.max_bitrate_bps != -1) {
295 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, 322 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
296 config.bitrate_config.start_bitrate_bps); 323 config.bitrate_config.start_bitrate_bps);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 { 365 {
339 rtc::CritScope lock(&bitrate_crit_); 366 rtc::CritScope lock(&bitrate_crit_);
340 UpdateSendHistograms(); 367 UpdateSendHistograms();
341 } 368 }
342 UpdateReceiveHistograms(); 369 UpdateReceiveHistograms();
343 UpdateHistograms(); 370 UpdateHistograms();
344 371
345 Trace::ReturnTrace(); 372 Trace::ReturnTrace();
346 } 373 }
347 374
375 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket(
376 const uint8_t* packet,
377 size_t length,
378 const PacketTime& packet_time) {
379 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]);
danilchap 2016/12/14 13:39:02 there is no need to hacky-extract ssrc before pars
brandtr 2016/12/14 14:08:31 Great! Then I don't need all the stuff with the po
380
381 std::unique_ptr<RtpPacketReceived> parsed_packet;
382 auto it = received_rtp_header_extensions_.find(ssrc);
383 if (it != received_rtp_header_extensions_.end()) {
384 // The existence of |it->second| is guaranteed during the lifetime of
danilchap 2016/12/14 13:39:02 if it is a problem, file a bug and assign it to me
brandtr 2016/12/14 14:08:31 Shouldn't be a problem right now, due to the lock
385 // |parsed_packet| and its copies, due to us holding the
386 // |receive_crit_| lock in the DeliverRtp method.
387 parsed_packet =
388 std::unique_ptr<RtpPacketReceived>(new RtpPacketReceived(&it->second));
389 } else {
390 parsed_packet =
391 std::unique_ptr<RtpPacketReceived>(new RtpPacketReceived(nullptr));
392 }
393
394 if (!parsed_packet->Parse(packet, length))
395 return rtc::Optional<RtpPacketReceived>();
396
397 int64_t arrival_time_ms;
398 if (packet_time.timestamp != -1) {
399 arrival_time_ms = (packet_time.timestamp + 500) / 1000;
400 } else {
401 arrival_time_ms = clock_->TimeInMilliseconds();
402 }
403 parsed_packet->set_arrival_time_ms(arrival_time_ms);
404
405 return rtc::Optional<RtpPacketReceived>(*parsed_packet);
406 }
407
348 void Call::UpdateHistograms() { 408 void Call::UpdateHistograms() {
349 RTC_HISTOGRAM_COUNTS_100000( 409 RTC_HISTOGRAM_COUNTS_100000(
350 "WebRTC.Call.LifetimeInSeconds", 410 "WebRTC.Call.LifetimeInSeconds",
351 (clock_->TimeInMilliseconds() - start_ms_) / 1000); 411 (clock_->TimeInMilliseconds() - start_ms_) / 1000);
352 } 412 }
353 413
354 void Call::UpdateSendHistograms() { 414 void Call::UpdateSendHistograms() {
355 if (first_packet_sent_ms_ == -1) 415 if (first_packet_sent_ms_ == -1)
356 return; 416 return;
357 int64_t elapsed_sec = 417 int64_t elapsed_sec =
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 ConfigureSync(receive_stream_impl->config().sync_group); 712 ConfigureSync(receive_stream_impl->config().sync_group);
653 } 713 }
654 UpdateAggregateNetworkState(); 714 UpdateAggregateNetworkState();
655 delete receive_stream_impl; 715 delete receive_stream_impl;
656 } 716 }
657 717
658 webrtc::FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( 718 webrtc::FlexfecReceiveStream* Call::CreateFlexfecReceiveStream(
659 const webrtc::FlexfecReceiveStream::Config& config) { 719 const webrtc::FlexfecReceiveStream::Config& config) {
660 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); 720 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream");
661 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 721 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
662 FlexfecReceiveStream* receive_stream = new FlexfecReceiveStream(config, this); 722
723 RecoveredPacketReceiver* recovered_packet_receiver = this;
724 FlexfecReceiveStream* receive_stream =
725 new FlexfecReceiveStream(config, recovered_packet_receiver);
663 726
664 { 727 {
665 WriteLockScoped write_lock(*receive_crit_); 728 WriteLockScoped write_lock(*receive_crit_);
729
730 RTC_DCHECK(flexfec_receive_streams_.find(receive_stream) ==
731 flexfec_receive_streams_.end());
732 flexfec_receive_streams_.insert(receive_stream);
733
666 for (auto ssrc : config.protected_media_ssrcs) 734 for (auto ssrc : config.protected_media_ssrcs)
667 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); 735 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream));
736
668 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == 737 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) ==
669 flexfec_receive_ssrcs_protection_.end()); 738 flexfec_receive_ssrcs_protection_.end());
670 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; 739 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream;
671 flexfec_receive_streams_.insert(receive_stream); 740
741 RTC_DCHECK(received_rtp_header_extensions_.find(config.remote_ssrc) ==
742 received_rtp_header_extensions_.end());
743 RtpHeaderExtensionMap rtp_header_extensions(config.rtp_header_extensions);
744 received_rtp_header_extensions_[config.remote_ssrc] = rtp_header_extensions;
672 } 745 }
746
673 // TODO(brandtr): Store config in RtcEventLog here. 747 // TODO(brandtr): Store config in RtcEventLog here.
748
674 return receive_stream; 749 return receive_stream;
675 } 750 }
676 751
677 void Call::DestroyFlexfecReceiveStream( 752 void Call::DestroyFlexfecReceiveStream(
678 webrtc::FlexfecReceiveStream* receive_stream) { 753 webrtc::FlexfecReceiveStream* receive_stream) {
679 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); 754 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream");
680 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 755 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
756
681 RTC_DCHECK(receive_stream != nullptr); 757 RTC_DCHECK(receive_stream != nullptr);
758
682 // There exist no other derived classes of webrtc::FlexfecReceiveStream, 759 // There exist no other derived classes of webrtc::FlexfecReceiveStream,
683 // so this downcast is safe. 760 // so this downcast is safe.
684 FlexfecReceiveStream* receive_stream_impl = 761 FlexfecReceiveStream* receive_stream_impl =
685 static_cast<FlexfecReceiveStream*>(receive_stream); 762 static_cast<FlexfecReceiveStream*>(receive_stream);
763
686 { 764 {
687 WriteLockScoped write_lock(*receive_crit_); 765 WriteLockScoped write_lock(*receive_crit_);
766
767 uint32_t ssrc = receive_stream_impl->GetConfig().remote_ssrc;
768 received_rtp_header_extensions_.erase(ssrc);
769
688 // Remove all SSRCs pointing to the FlexfecReceiveStream to be destroyed. 770 // Remove all SSRCs pointing to the FlexfecReceiveStream to be destroyed.
689 auto media_it = flexfec_receive_ssrcs_media_.begin();
690 while (media_it != flexfec_receive_ssrcs_media_.end()) {
691 if (media_it->second == receive_stream_impl)
692 media_it = flexfec_receive_ssrcs_media_.erase(media_it);
693 else
694 ++media_it;
695 }
696 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); 771 auto prot_it = flexfec_receive_ssrcs_protection_.begin();
697 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { 772 while (prot_it != flexfec_receive_ssrcs_protection_.end()) {
698 if (prot_it->second == receive_stream_impl) 773 if (prot_it->second == receive_stream_impl)
699 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); 774 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it);
700 else 775 else
701 ++prot_it; 776 ++prot_it;
702 } 777 }
778 auto media_it = flexfec_receive_ssrcs_media_.begin();
779 while (media_it != flexfec_receive_ssrcs_media_.end()) {
780 if (media_it->second == receive_stream_impl)
781 media_it = flexfec_receive_ssrcs_media_.erase(media_it);
782 else
783 ++media_it;
784 }
785
703 flexfec_receive_streams_.erase(receive_stream_impl); 786 flexfec_receive_streams_.erase(receive_stream_impl);
704 } 787 }
788
705 delete receive_stream_impl; 789 delete receive_stream_impl;
706 } 790 }
707 791
708 Call::Stats Call::GetStats() const { 792 Call::Stats Call::GetStats() const {
709 // TODO(solenberg): Some test cases in EndToEndTest use this from a different 793 // TODO(solenberg): Some test cases in EndToEndTest use this from a different
710 // thread. Re-enable once that is fixed. 794 // thread. Re-enable once that is fixed.
711 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 795 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
712 Stats stats; 796 Stats stats;
713 // Fetch available send/receive bitrates. 797 // Fetch available send/receive bitrates.
714 uint32_t send_bandwidth = 0; 798 uint32_t send_bandwidth = 0;
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 if (status == DELIVERY_OK) 1152 if (status == DELIVERY_OK)
1069 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); 1153 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
1070 return status; 1154 return status;
1071 } 1155 }
1072 } 1156 }
1073 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { 1157 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
1074 auto it = video_receive_ssrcs_.find(ssrc); 1158 auto it = video_receive_ssrcs_.find(ssrc);
1075 if (it != video_receive_ssrcs_.end()) { 1159 if (it != video_receive_ssrcs_.end()) {
1076 received_bytes_per_second_counter_.Add(static_cast<int>(length)); 1160 received_bytes_per_second_counter_.Add(static_cast<int>(length));
1077 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); 1161 received_video_bytes_per_second_counter_.Add(static_cast<int>(length));
1162 // TODO(brandtr): Notify the BWE of received media packets here.
1078 auto status = it->second->DeliverRtp(packet, length, packet_time) 1163 auto status = it->second->DeliverRtp(packet, length, packet_time)
1079 ? DELIVERY_OK 1164 ? DELIVERY_OK
1080 : DELIVERY_PACKET_ERROR; 1165 : DELIVERY_PACKET_ERROR;
1081 // Deliver media packets to FlexFEC subsystem. 1166 // Deliver media packets to FlexFEC subsystem. RTP header extensions need
1082 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); 1167 // not be parsed, as FlexFEC is oblivious to the semantic meaning of the
1083 for (auto it = it_bounds.first; it != it_bounds.second; ++it) 1168 // packet contents beyond the 12 byte RTP base header. The BWE is fed
1084 it->second->AddAndProcessReceivedPacket(packet, length); 1169 // information about these media packets from the regular media pipeline.
1170 rtc::Optional<RtpPacketReceived> parsed_packet =
1171 ParseRtpPacket(packet, length, packet_time);
1172 if (parsed_packet) {
1173 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc);
1174 for (auto it = it_bounds.first; it != it_bounds.second; ++it)
1175 it->second->AddAndProcessReceivedPacket(*parsed_packet);
1176 }
1085 if (status == DELIVERY_OK) 1177 if (status == DELIVERY_OK)
1086 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); 1178 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
1087 return status; 1179 return status;
1088 } 1180 }
1089 } 1181 }
1090 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { 1182 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
1091 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); 1183 auto it = flexfec_receive_ssrcs_protection_.find(ssrc);
1092 if (it != flexfec_receive_ssrcs_protection_.end()) { 1184 if (it != flexfec_receive_ssrcs_protection_.end()) {
1093 auto status = it->second->AddAndProcessReceivedPacket(packet, length) 1185 rtc::Optional<RtpPacketReceived> parsed_packet =
1094 ? DELIVERY_OK 1186 ParseRtpPacket(packet, length, packet_time);
1095 : DELIVERY_PACKET_ERROR; 1187 if (parsed_packet) {
1096 if (status == DELIVERY_OK) 1188 NotifyBweOfReceivedPacket(*parsed_packet);
1097 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); 1189 auto status = it->second->AddAndProcessReceivedPacket(*parsed_packet)
1098 return status; 1190 ? DELIVERY_OK
1191 : DELIVERY_PACKET_ERROR;
1192 if (status == DELIVERY_OK)
1193 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
1194 return status;
1195 }
1099 } 1196 }
1100 } 1197 }
1101 return DELIVERY_UNKNOWN_SSRC; 1198 return DELIVERY_UNKNOWN_SSRC;
1102 } 1199 }
1103 1200
1104 PacketReceiver::DeliveryStatus Call::DeliverPacket( 1201 PacketReceiver::DeliveryStatus Call::DeliverPacket(
1105 MediaType media_type, 1202 MediaType media_type,
1106 const uint8_t* packet, 1203 const uint8_t* packet,
1107 size_t length, 1204 size_t length,
1108 const PacketTime& packet_time) { 1205 const PacketTime& packet_time) {
(...skipping 11 matching lines...) Expand all
1120 // audio packets with FlexFEC. 1217 // audio packets with FlexFEC.
1121 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { 1218 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) {
1122 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); 1219 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]);
1123 ReadLockScoped read_lock(*receive_crit_); 1220 ReadLockScoped read_lock(*receive_crit_);
1124 auto it = video_receive_ssrcs_.find(ssrc); 1221 auto it = video_receive_ssrcs_.find(ssrc);
1125 if (it == video_receive_ssrcs_.end()) 1222 if (it == video_receive_ssrcs_.end())
1126 return false; 1223 return false;
1127 return it->second->OnRecoveredPacket(packet, length); 1224 return it->second->OnRecoveredPacket(packet, length);
1128 } 1225 }
1129 1226
1227 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) {
1228 const bool transport_wide = packet.HasExtension<TransportSequenceNumber>();
1229 const bool abs_send_time = packet.HasExtension<AbsoluteSendTime>();
1230 const bool t_offset = packet.HasExtension<TransmissionOffset>();
1231
1232 // At least one of the header extensions is needed for the BWE.
1233 if (!transport_wide && !abs_send_time && !t_offset)
1234 return;
1235
1236 RTPHeader header;
1237 packet.GetHeader(&header);
1238
1239 // Send-side BWE?
1240 if (remote_estimator_proxy_ && transport_wide) {
1241 remote_estimator_proxy_->IncomingPacket(packet.arrival_time_ms(),
1242 packet.payload_size(), header);
1243 return;
1244 }
1245
1246 // Other BWE.
danilchap 2016/12/14 13:39:02 may be 'Receive-side' instead of 'Other'
brandtr 2016/12/14 14:08:31 Done.
1247 if (remote_bitrate_estimator_) {
1248 remote_bitrate_estimator_->IncomingPacket(packet.arrival_time_ms(),
1249 packet.payload_size(), header);
1250 }
1251 }
1252
1130 } // namespace internal 1253 } // namespace internal
1131 } // namespace webrtc 1254 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698