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

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

Issue 2709723003: Initial implementation of RtpTransportControllerReceive and related interfaces.
Patch Set: Fix audio. Created 3 years, 8 months 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
(...skipping 15 matching lines...) Expand all
26 #include "webrtc/base/location.h" 26 #include "webrtc/base/location.h"
27 #include "webrtc/base/logging.h" 27 #include "webrtc/base/logging.h"
28 #include "webrtc/base/optional.h" 28 #include "webrtc/base/optional.h"
29 #include "webrtc/base/task_queue.h" 29 #include "webrtc/base/task_queue.h"
30 #include "webrtc/base/thread_annotations.h" 30 #include "webrtc/base/thread_annotations.h"
31 #include "webrtc/base/thread_checker.h" 31 #include "webrtc/base/thread_checker.h"
32 #include "webrtc/base/trace_event.h" 32 #include "webrtc/base/trace_event.h"
33 #include "webrtc/call/bitrate_allocator.h" 33 #include "webrtc/call/bitrate_allocator.h"
34 #include "webrtc/call/call.h" 34 #include "webrtc/call/call.h"
35 #include "webrtc/call/flexfec_receive_stream_impl.h" 35 #include "webrtc/call/flexfec_receive_stream_impl.h"
36 #include "webrtc/call/rtp_transport_controller_receive.h"
36 #include "webrtc/call/rtp_transport_controller_send.h" 37 #include "webrtc/call/rtp_transport_controller_send.h"
37 #include "webrtc/config.h" 38 #include "webrtc/config.h"
38 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 39 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
39 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 40 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
40 #include "webrtc/modules/congestion_controller/include/receive_side_congestion_c ontroller.h" 41 #include "webrtc/modules/congestion_controller/include/receive_side_congestion_c ontroller.h"
41 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h" 42 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h"
42 #include "webrtc/modules/pacing/paced_sender.h" 43 #include "webrtc/modules/pacing/paced_sender.h"
43 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" 44 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h"
44 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 45 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
45 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 46 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 const uint8_t* packet, 206 const uint8_t* packet,
206 size_t length, 207 size_t length,
207 const PacketTime& packet_time); 208 const PacketTime& packet_time);
208 void ConfigureSync(const std::string& sync_group) 209 void ConfigureSync(const std::string& sync_group)
209 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); 210 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_);
210 211
211 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, 212 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet,
212 MediaType media_type) 213 MediaType media_type)
213 SHARED_LOCKS_REQUIRED(receive_crit_); 214 SHARED_LOCKS_REQUIRED(receive_crit_);
214 215
215 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet,
216 size_t length,
217 const PacketTime& packet_time)
218 SHARED_LOCKS_REQUIRED(receive_crit_);
219
220 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); 216 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_);
221 void UpdateReceiveHistograms(); 217 void UpdateReceiveHistograms();
222 void UpdateHistograms(); 218 void UpdateHistograms();
223 void UpdateAggregateNetworkState(); 219 void UpdateAggregateNetworkState();
224 220
225 Clock* const clock_; 221 Clock* const clock_;
226 222
227 const int num_cpu_cores_; 223 const int num_cpu_cores_;
228 const std::unique_ptr<ProcessThread> module_process_thread_; 224 const std::unique_ptr<ProcessThread> module_process_thread_;
229 const std::unique_ptr<ProcessThread> pacer_thread_; 225 const std::unique_ptr<ProcessThread> pacer_thread_;
230 const std::unique_ptr<CallStats> call_stats_; 226 const std::unique_ptr<CallStats> call_stats_;
231 const std::unique_ptr<BitrateAllocator> bitrate_allocator_; 227 const std::unique_ptr<BitrateAllocator> bitrate_allocator_;
232 Call::Config config_; 228 Call::Config config_;
233 rtc::ThreadChecker configuration_thread_checker_; 229 rtc::ThreadChecker configuration_thread_checker_;
234 230
235 NetworkState audio_network_state_; 231 NetworkState audio_network_state_;
236 NetworkState video_network_state_; 232 NetworkState video_network_state_;
237 233
238 std::unique_ptr<RWLockWrapper> receive_crit_; 234 std::unique_ptr<RWLockWrapper> receive_crit_;
239 // Audio, Video, and FlexFEC receive streams are owned by the client that 235 // Audio, Video, and FlexFEC receive streams are owned by the client that
240 // creates them. 236 // creates them.
237 // TODO(nisse): Try to eliminate these additional mappings. Two of
238 // the users are DeliverRTCP and OnRecoveredPacket.
241 std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_ 239 std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_
242 GUARDED_BY(receive_crit_); 240 GUARDED_BY(receive_crit_);
243 std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_ 241 std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_
244 GUARDED_BY(receive_crit_); 242 GUARDED_BY(receive_crit_);
245 std::set<VideoReceiveStream*> video_receive_streams_ 243 std::set<VideoReceiveStream*> video_receive_streams_
246 GUARDED_BY(receive_crit_); 244 GUARDED_BY(receive_crit_);
247 // Each media stream could conceivably be protected by multiple FlexFEC 245
248 // streams.
249 std::multimap<uint32_t, FlexfecReceiveStreamImpl*>
250 flexfec_receive_ssrcs_media_ GUARDED_BY(receive_crit_);
251 std::map<uint32_t, FlexfecReceiveStreamImpl*>
252 flexfec_receive_ssrcs_protection_ GUARDED_BY(receive_crit_);
253 std::set<FlexfecReceiveStreamImpl*> flexfec_receive_streams_
254 GUARDED_BY(receive_crit_);
255 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ 246 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_
256 GUARDED_BY(receive_crit_); 247 GUARDED_BY(receive_crit_);
257 248
258 // This extra map is used for receive processing which is
259 // independent of media type.
260
261 // TODO(nisse): In the RTP transport refactoring, we should have a
262 // single mapping from ssrc to a more abstract receive stream, with
263 // accessor methods for all configuration we need at this level.
264 struct ReceiveRtpConfig {
265 ReceiveRtpConfig() = default; // Needed by std::map
266 ReceiveRtpConfig(const std::vector<RtpExtension>& extensions,
267 bool use_send_side_bwe)
268 : extensions(extensions), use_send_side_bwe(use_send_side_bwe) {}
269
270 // Registered RTP header extensions for each stream. Note that RTP header
271 // extensions are negotiated per track ("m= line") in the SDP, but we have
272 // no notion of tracks at the Call level. We therefore store the RTP header
273 // extensions per SSRC instead, which leads to some storage overhead.
274 RtpHeaderExtensionMap extensions;
275 // Set if both RTP extension the RTCP feedback message needed for
276 // send side BWE are negotiated.
277 bool use_send_side_bwe = false;
278 };
279 std::map<uint32_t, ReceiveRtpConfig> receive_rtp_config_
280 GUARDED_BY(receive_crit_);
281
282 std::unique_ptr<RWLockWrapper> send_crit_; 249 std::unique_ptr<RWLockWrapper> send_crit_;
283 // Audio and Video send streams are owned by the client that creates them. 250 // Audio and Video send streams are owned by the client that creates them.
284 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); 251 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_);
285 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); 252 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_);
286 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); 253 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_);
287 254
288 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; 255 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
289 webrtc::RtcEventLog* event_log_; 256 webrtc::RtcEventLog* event_log_;
290 257
291 // The following members are only accessed (exclusively) from one thread and 258 // The following members are only accessed (exclusively) from one thread and
(...skipping 11 matching lines...) Expand all
303 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); 270 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
304 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); 271 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
305 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); 272 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_);
306 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); 273 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_);
307 274
308 std::map<std::string, rtc::NetworkRoute> network_routes_; 275 std::map<std::string, rtc::NetworkRoute> network_routes_;
309 276
310 std::unique_ptr<RtpTransportControllerSendInterface> transport_send_; 277 std::unique_ptr<RtpTransportControllerSendInterface> transport_send_;
311 VieRemb remb_; 278 VieRemb remb_;
312 ReceiveSideCongestionController receive_side_cc_; 279 ReceiveSideCongestionController receive_side_cc_;
280 // TODO(nisse): Currently we always use separate demuxers. These
281 // should be created and owned outside of Call, passing pointers
282 // when Call is created. Then we should have two separate objects in
283 // the unbundled case, and two pointers to the same object in the
284 // bundled case.
285 std::unique_ptr<RtpTransportControllerReceiveInterface>
286 rtp_transport_receive_audio_ GUARDED_BY(receive_crit_);
287 std::unique_ptr<RtpTransportControllerReceiveInterface>
288 rtp_transport_receive_video_ GUARDED_BY(receive_crit_);
313 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; 289 const std::unique_ptr<SendDelayStats> video_send_delay_stats_;
314 const int64_t start_ms_; 290 const int64_t start_ms_;
315 // TODO(perkj): |worker_queue_| is supposed to replace 291 // TODO(perkj): |worker_queue_| is supposed to replace
316 // |module_process_thread_|. 292 // |module_process_thread_|.
317 // |worker_queue| is defined last to ensure all pending tasks are cancelled 293 // |worker_queue| is defined last to ensure all pending tasks are cancelled
318 // and deleted before any other members. 294 // and deleted before any other members.
319 rtc::TaskQueue worker_queue_; 295 rtc::TaskQueue worker_queue_;
320 296
321 RTC_DISALLOW_COPY_AND_ASSIGN(Call); 297 RTC_DISALLOW_COPY_AND_ASSIGN(Call);
322 }; 298 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 received_bytes_per_second_counter_(clock_, nullptr, true), 337 received_bytes_per_second_counter_(clock_, nullptr, true),
362 received_audio_bytes_per_second_counter_(clock_, nullptr, true), 338 received_audio_bytes_per_second_counter_(clock_, nullptr, true),
363 received_video_bytes_per_second_counter_(clock_, nullptr, true), 339 received_video_bytes_per_second_counter_(clock_, nullptr, true),
364 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), 340 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true),
365 min_allocated_send_bitrate_bps_(0), 341 min_allocated_send_bitrate_bps_(0),
366 configured_max_padding_bitrate_bps_(0), 342 configured_max_padding_bitrate_bps_(0),
367 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), 343 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true),
368 pacer_bitrate_kbps_counter_(clock_, nullptr, true), 344 pacer_bitrate_kbps_counter_(clock_, nullptr, true),
369 remb_(clock_), 345 remb_(clock_),
370 receive_side_cc_(clock_, &remb_, transport_send->packet_router()), 346 receive_side_cc_(clock_, &remb_, transport_send->packet_router()),
347 rtp_transport_receive_audio_(
348 RtpTransportControllerReceiveInterface::Create(
349 &receive_side_cc_,
350 false /* enable_receive_side_bwe */)),
351 rtp_transport_receive_video_(
352 RtpTransportControllerReceiveInterface::Create(
353 &receive_side_cc_,
354 true /* enable_receive_side_bwe */)),
371 video_send_delay_stats_(new SendDelayStats(clock_)), 355 video_send_delay_stats_(new SendDelayStats(clock_)),
372 start_ms_(clock_->TimeInMilliseconds()), 356 start_ms_(clock_->TimeInMilliseconds()),
373 worker_queue_("call_worker_queue") { 357 worker_queue_("call_worker_queue") {
374 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 358 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
375 RTC_DCHECK(config.event_log != nullptr); 359 RTC_DCHECK(config.event_log != nullptr);
376 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); 360 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
377 RTC_DCHECK_GT(config.bitrate_config.start_bitrate_bps, 361 RTC_DCHECK_GT(config.bitrate_config.start_bitrate_bps,
378 config.bitrate_config.min_bitrate_bps); 362 config.bitrate_config.min_bitrate_bps);
379 if (config.bitrate_config.max_bitrate_bps != -1) { 363 if (config.bitrate_config.max_bitrate_bps != -1) {
380 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, 364 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
(...skipping 23 matching lines...) Expand all
404 pacer_thread_->Start(); 388 pacer_thread_->Start();
405 } 389 }
406 390
407 Call::~Call() { 391 Call::~Call() {
408 RTC_DCHECK(!remb_.InUse()); 392 RTC_DCHECK(!remb_.InUse());
409 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 393 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
410 394
411 RTC_CHECK(audio_send_ssrcs_.empty()); 395 RTC_CHECK(audio_send_ssrcs_.empty());
412 RTC_CHECK(video_send_ssrcs_.empty()); 396 RTC_CHECK(video_send_ssrcs_.empty());
413 RTC_CHECK(video_send_streams_.empty()); 397 RTC_CHECK(video_send_streams_.empty());
414 RTC_CHECK(audio_receive_ssrcs_.empty());
415 RTC_CHECK(video_receive_ssrcs_.empty());
416 RTC_CHECK(video_receive_streams_.empty());
417 398
418 pacer_thread_->Stop(); 399 pacer_thread_->Stop();
419 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer()); 400 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer());
420 pacer_thread_->DeRegisterModule( 401 pacer_thread_->DeRegisterModule(
421 receive_side_cc_.GetRemoteBitrateEstimator(true)); 402 receive_side_cc_.GetRemoteBitrateEstimator(true));
422 module_process_thread_->DeRegisterModule(transport_send_->send_side_cc()); 403 module_process_thread_->DeRegisterModule(transport_send_->send_side_cc());
423 module_process_thread_->DeRegisterModule(&receive_side_cc_); 404 module_process_thread_->DeRegisterModule(&receive_side_cc_);
424 module_process_thread_->DeRegisterModule(call_stats_.get()); 405 module_process_thread_->DeRegisterModule(call_stats_.get());
425 module_process_thread_->Stop(); 406 module_process_thread_->Stop();
426 call_stats_->DeregisterStatsObserver(&receive_side_cc_); 407 call_stats_->DeregisterStatsObserver(&receive_side_cc_);
427 call_stats_->DeregisterStatsObserver(transport_send_->send_side_cc()); 408 call_stats_->DeregisterStatsObserver(transport_send_->send_side_cc());
428 409
429 // Only update histograms after process threads have been shut down, so that 410 // Only update histograms after process threads have been shut down, so that
430 // they won't try to concurrently update stats. 411 // they won't try to concurrently update stats.
431 { 412 {
432 rtc::CritScope lock(&bitrate_crit_); 413 rtc::CritScope lock(&bitrate_crit_);
433 UpdateSendHistograms(); 414 UpdateSendHistograms();
434 } 415 }
435 UpdateReceiveHistograms(); 416 UpdateReceiveHistograms();
436 UpdateHistograms(); 417 UpdateHistograms();
437 418
438 Trace::ReturnTrace(); 419 Trace::ReturnTrace();
439 } 420 }
440 421
441 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket(
442 const uint8_t* packet,
443 size_t length,
444 const PacketTime& packet_time) {
445 RtpPacketReceived parsed_packet;
446 if (!parsed_packet.Parse(packet, length))
447 return rtc::Optional<RtpPacketReceived>();
448
449 auto it = receive_rtp_config_.find(parsed_packet.Ssrc());
450 if (it != receive_rtp_config_.end())
451 parsed_packet.IdentifyExtensions(it->second.extensions);
452
453 int64_t arrival_time_ms;
454 if (packet_time.timestamp != -1) {
455 arrival_time_ms = (packet_time.timestamp + 500) / 1000;
456 } else {
457 arrival_time_ms = clock_->TimeInMilliseconds();
458 }
459 parsed_packet.set_arrival_time_ms(arrival_time_ms);
460
461 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet));
462 }
463
464 void Call::UpdateHistograms() { 422 void Call::UpdateHistograms() {
465 RTC_HISTOGRAM_COUNTS_100000( 423 RTC_HISTOGRAM_COUNTS_100000(
466 "WebRTC.Call.LifetimeInSeconds", 424 "WebRTC.Call.LifetimeInSeconds",
467 (clock_->TimeInMilliseconds() - start_ms_) / 1000); 425 (clock_->TimeInMilliseconds() - start_ms_) / 1000);
468 } 426 }
469 427
470 void Call::UpdateSendHistograms() { 428 void Call::UpdateSendHistograms() {
471 if (first_packet_sent_ms_ == -1) 429 if (first_packet_sent_ms_ == -1)
472 return; 430 return;
473 int64_t elapsed_sec = 431 int64_t elapsed_sec =
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 } 549 }
592 550
593 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( 551 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
594 const webrtc::AudioReceiveStream::Config& config) { 552 const webrtc::AudioReceiveStream::Config& config) {
595 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); 553 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
596 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 554 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
597 event_log_->LogAudioReceiveStreamConfig(config); 555 event_log_->LogAudioReceiveStreamConfig(config);
598 AudioReceiveStream* receive_stream = 556 AudioReceiveStream* receive_stream =
599 new AudioReceiveStream(transport_send_->packet_router(), config, 557 new AudioReceiveStream(transport_send_->packet_router(), config,
600 config_.audio_state, event_log_); 558 config_.audio_state, event_log_);
559 RtpTransportControllerReceiveInterface::Config receive_config;
560 receive_config.use_send_side_bwe = UseSendSideBwe(config);
561
601 { 562 {
602 WriteLockScoped write_lock(*receive_crit_); 563 WriteLockScoped write_lock(*receive_crit_);
603 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == 564 bool success = rtp_transport_receive_audio_->AddReceiver(
604 audio_receive_ssrcs_.end()); 565 config.rtp.remote_ssrc, receive_config, receive_stream);
566 // TODO(nisse): Log and return nullptr on failure. Typical failure
567 // reason is ssrc collisions due to misconfiguration.
the sun 2017/04/18 09:59:00 Should that really be checked at this level? Call
nisse-webrtc 2017/04/19 08:35:43 I would make things simpler to drop the DCHECK, dr
568 RTC_DCHECK(success);
605 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; 569 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream;
606 receive_rtp_config_[config.rtp.remote_ssrc] =
607 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config));
608
609 ConfigureSync(config.sync_group); 570 ConfigureSync(config.sync_group);
610 } 571 }
611 { 572 {
612 ReadLockScoped read_lock(*send_crit_); 573 ReadLockScoped read_lock(*send_crit_);
613 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); 574 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc);
614 if (it != audio_send_ssrcs_.end()) { 575 if (it != audio_send_ssrcs_.end()) {
615 receive_stream->AssociateSendStream(it->second); 576 receive_stream->AssociateSendStream(it->second);
616 } 577 }
617 } 578 }
618 receive_stream->SignalNetworkState(audio_network_state_); 579 receive_stream->SignalNetworkState(audio_network_state_);
619 UpdateAggregateNetworkState(); 580 UpdateAggregateNetworkState();
620 return receive_stream; 581 return receive_stream;
621 } 582 }
622 583
623 void Call::DestroyAudioReceiveStream( 584 void Call::DestroyAudioReceiveStream(
624 webrtc::AudioReceiveStream* receive_stream) { 585 webrtc::AudioReceiveStream* receive_stream) {
625 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); 586 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream");
626 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 587 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
627 RTC_DCHECK(receive_stream != nullptr); 588 RTC_DCHECK(receive_stream != nullptr);
628 webrtc::internal::AudioReceiveStream* audio_receive_stream = 589 webrtc::internal::AudioReceiveStream* audio_receive_stream =
629 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); 590 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream);
630 { 591 {
631 WriteLockScoped write_lock(*receive_crit_); 592 WriteLockScoped write_lock(*receive_crit_);
593 bool success =
594 rtp_transport_receive_audio_->RemoveReceiver(audio_receive_stream);
595 RTC_DCHECK(success);
596
632 const AudioReceiveStream::Config& config = audio_receive_stream->config(); 597 const AudioReceiveStream::Config& config = audio_receive_stream->config();
633 uint32_t ssrc = config.rtp.remote_ssrc; 598 uint32_t ssrc = config.rtp.remote_ssrc;
634 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config))
635 ->RemoveStream(ssrc);
636 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); 599 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc);
637 RTC_DCHECK(num_deleted == 1); 600 RTC_DCHECK(num_deleted == 1);
638 const std::string& sync_group = audio_receive_stream->config().sync_group; 601 const std::string& sync_group = audio_receive_stream->config().sync_group;
639 const auto it = sync_stream_mapping_.find(sync_group); 602 const auto it = sync_stream_mapping_.find(sync_group);
640 if (it != sync_stream_mapping_.end() && 603 if (it != sync_stream_mapping_.end() &&
641 it->second == audio_receive_stream) { 604 it->second == audio_receive_stream) {
642 sync_stream_mapping_.erase(it); 605 sync_stream_mapping_.erase(it);
643 ConfigureSync(sync_group); 606 ConfigureSync(sync_group);
644 } 607 }
645 receive_rtp_config_.erase(ssrc);
646 } 608 }
647 UpdateAggregateNetworkState(); 609 UpdateAggregateNetworkState();
648 delete audio_receive_stream; 610 delete audio_receive_stream;
649 } 611 }
650 612
651 webrtc::VideoSendStream* Call::CreateVideoSendStream( 613 webrtc::VideoSendStream* Call::CreateVideoSendStream(
652 webrtc::VideoSendStream::Config config, 614 webrtc::VideoSendStream::Config config,
653 VideoEncoderConfig encoder_config) { 615 VideoEncoderConfig encoder_config) {
654 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); 616 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream");
655 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 617 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 webrtc::VideoReceiveStream::Config configuration) { 682 webrtc::VideoReceiveStream::Config configuration) {
721 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); 683 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream");
722 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 684 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
723 685
724 VideoReceiveStream* receive_stream = new VideoReceiveStream( 686 VideoReceiveStream* receive_stream = new VideoReceiveStream(
725 num_cpu_cores_, transport_send_->packet_router(), 687 num_cpu_cores_, transport_send_->packet_router(),
726 std::move(configuration), module_process_thread_.get(), call_stats_.get(), 688 std::move(configuration), module_process_thread_.get(), call_stats_.get(),
727 &remb_); 689 &remb_);
728 690
729 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); 691 const webrtc::VideoReceiveStream::Config& config = receive_stream->config();
730 ReceiveRtpConfig receive_config(config.rtp.extensions, 692 RtpTransportControllerReceiveInterface::Config receive_config;
731 UseSendSideBwe(config)); 693 receive_config.use_send_side_bwe = UseSendSideBwe(config);
694
732 { 695 {
733 WriteLockScoped write_lock(*receive_crit_); 696 WriteLockScoped write_lock(*receive_crit_);
734 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == 697 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
735 video_receive_ssrcs_.end()); 698 video_receive_ssrcs_.end());
736 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; 699 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream;
700 bool success = rtp_transport_receive_video_->AddReceiver(
701 config.rtp.remote_ssrc, receive_config, receive_stream);
702 RTC_DCHECK(success);
737 if (config.rtp.rtx_ssrc) { 703 if (config.rtp.rtx_ssrc) {
738 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; 704 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream;
739 // We record identical config for the rtx stream as for the main 705 // We record identical config for the rtx stream as for the main
740 // stream. Since the transport_send_cc negotiation is per payload 706 // stream. Since the transport_send_cc negotiation is per payload
741 // type, we may get an incorrect value for the rtx stream, but 707 // type, we may get an incorrect value for the rtx stream, but
742 // that is unlikely to matter in practice. 708 // that is unlikely to matter in practice.
743 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config; 709 bool success = rtp_transport_receive_video_->AddReceiver(
710 config.rtp.rtx_ssrc, receive_config, receive_stream);
711
712 RTC_DCHECK(success);
744 } 713 }
745 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config;
746 video_receive_streams_.insert(receive_stream); 714 video_receive_streams_.insert(receive_stream);
747 ConfigureSync(config.sync_group); 715 ConfigureSync(config.sync_group);
748 } 716 }
749 receive_stream->SignalNetworkState(video_network_state_); 717 receive_stream->SignalNetworkState(video_network_state_);
750 UpdateAggregateNetworkState(); 718 UpdateAggregateNetworkState();
751 event_log_->LogVideoReceiveStreamConfig(config); 719 event_log_->LogVideoReceiveStreamConfig(config);
752 return receive_stream; 720 return receive_stream;
753 } 721 }
754 722
755 void Call::DestroyVideoReceiveStream( 723 void Call::DestroyVideoReceiveStream(
756 webrtc::VideoReceiveStream* receive_stream) { 724 webrtc::VideoReceiveStream* receive_stream) {
757 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); 725 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream");
758 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 726 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
759 RTC_DCHECK(receive_stream != nullptr); 727 RTC_DCHECK(receive_stream != nullptr);
760 VideoReceiveStream* receive_stream_impl = nullptr; 728 VideoReceiveStream* receive_stream_impl = nullptr;
761 { 729 {
762 WriteLockScoped write_lock(*receive_crit_); 730 WriteLockScoped write_lock(*receive_crit_);
763 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a 731 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a
764 // separate SSRC there can be either one or two. 732 // separate SSRC there can be either one or two.
765 auto it = video_receive_ssrcs_.begin(); 733 auto it = video_receive_ssrcs_.begin();
766 while (it != video_receive_ssrcs_.end()) { 734 while (it != video_receive_ssrcs_.end()) {
767 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { 735 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) {
768 if (receive_stream_impl != nullptr) 736 if (receive_stream_impl != nullptr)
769 RTC_DCHECK(receive_stream_impl == it->second); 737 RTC_DCHECK(receive_stream_impl == it->second);
770 receive_stream_impl = it->second; 738 receive_stream_impl = it->second;
771 receive_rtp_config_.erase(it->first);
772 it = video_receive_ssrcs_.erase(it); 739 it = video_receive_ssrcs_.erase(it);
773 } else { 740 } else {
774 ++it; 741 ++it;
775 } 742 }
776 } 743 }
777 video_receive_streams_.erase(receive_stream_impl); 744 video_receive_streams_.erase(receive_stream_impl);
778 RTC_CHECK(receive_stream_impl != nullptr); 745 RTC_CHECK(receive_stream_impl != nullptr);
779 ConfigureSync(receive_stream_impl->config().sync_group); 746 ConfigureSync(receive_stream_impl->config().sync_group);
747 rtp_transport_receive_video_->RemoveReceiver(receive_stream_impl);
780 } 748 }
781 const VideoReceiveStream::Config& config = receive_stream_impl->config();
782
783 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config))
784 ->RemoveStream(config.rtp.remote_ssrc);
785 749
786 UpdateAggregateNetworkState(); 750 UpdateAggregateNetworkState();
787 delete receive_stream_impl; 751 delete receive_stream_impl;
788 } 752 }
789 753
790 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( 754 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream(
791 const FlexfecReceiveStream::Config& config) { 755 const FlexfecReceiveStream::Config& config) {
792 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); 756 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream");
793 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 757 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
794 758
795 RecoveredPacketReceiver* recovered_packet_receiver = this; 759 RecoveredPacketReceiver* recovered_packet_receiver = this;
796 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl( 760 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl(
797 config, recovered_packet_receiver, call_stats_->rtcp_rtt_stats(), 761 config, recovered_packet_receiver, call_stats_->rtcp_rtt_stats(),
798 module_process_thread_.get()); 762 module_process_thread_.get());
799 763
764 RtpTransportControllerReceiveInterface::Config receive_config;
765 receive_config.use_send_side_bwe = UseSendSideBwe(config);
766
800 { 767 {
801 WriteLockScoped write_lock(*receive_crit_); 768 WriteLockScoped write_lock(*receive_crit_);
769 rtp_transport_receive_video_->AddReceiver(config.remote_ssrc,
770 receive_config, receive_stream);
802 771
803 RTC_DCHECK(flexfec_receive_streams_.find(receive_stream) == 772 for (auto ssrc : config.protected_media_ssrcs) {
804 flexfec_receive_streams_.end()); 773 rtp_transport_receive_video_->AddSink(ssrc, receive_stream);
805 flexfec_receive_streams_.insert(receive_stream); 774 }
806
807 for (auto ssrc : config.protected_media_ssrcs)
808 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream));
809
810 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) ==
811 flexfec_receive_ssrcs_protection_.end());
812 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream;
813
814 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) ==
815 receive_rtp_config_.end());
816 receive_rtp_config_[config.remote_ssrc] =
817 ReceiveRtpConfig(config.rtp_header_extensions, UseSendSideBwe(config));
818 } 775 }
819 776
820 // TODO(brandtr): Store config in RtcEventLog here. 777 // TODO(brandtr): Store config in RtcEventLog here.
821 778
822 return receive_stream; 779 return receive_stream;
823 } 780 }
824 781
825 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { 782 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) {
826 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); 783 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream");
827 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 784 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
828 785
829 RTC_DCHECK(receive_stream != nullptr); 786 RTC_DCHECK(receive_stream != nullptr);
830 // There exist no other derived classes of FlexfecReceiveStream, 787 // There exist no other derived classes of FlexfecReceiveStream,
831 // so this downcast is safe. 788 // so this downcast is safe.
832 FlexfecReceiveStreamImpl* receive_stream_impl = 789 FlexfecReceiveStreamImpl* receive_stream_impl =
833 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); 790 static_cast<FlexfecReceiveStreamImpl*>(receive_stream);
834 { 791 {
835 WriteLockScoped write_lock(*receive_crit_); 792 WriteLockScoped write_lock(*receive_crit_);
836 793 rtp_transport_receive_video_->RemoveSink(receive_stream_impl);
837 const FlexfecReceiveStream::Config& config = 794 rtp_transport_receive_video_->RemoveReceiver(receive_stream_impl);
838 receive_stream_impl->GetConfig();
839 uint32_t ssrc = config.remote_ssrc;
840 receive_rtp_config_.erase(ssrc);
841
842 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be
843 // destroyed.
844 auto prot_it = flexfec_receive_ssrcs_protection_.begin();
845 while (prot_it != flexfec_receive_ssrcs_protection_.end()) {
846 if (prot_it->second == receive_stream_impl)
847 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it);
848 else
849 ++prot_it;
850 }
851 auto media_it = flexfec_receive_ssrcs_media_.begin();
852 while (media_it != flexfec_receive_ssrcs_media_.end()) {
853 if (media_it->second == receive_stream_impl)
854 media_it = flexfec_receive_ssrcs_media_.erase(media_it);
855 else
856 ++media_it;
857 }
858
859 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config))
860 ->RemoveStream(ssrc);
861
862 flexfec_receive_streams_.erase(receive_stream_impl);
863 } 795 }
864 796
865 delete receive_stream_impl; 797 delete receive_stream_impl;
866 } 798 }
867 799
868 Call::Stats Call::GetStats() const { 800 Call::Stats Call::GetStats() const {
869 // TODO(solenberg): Some test cases in EndToEndTest use this from a different 801 // TODO(solenberg): Some test cases in EndToEndTest use this from a different
870 // thread. Re-enable once that is fixed. 802 // thread. Re-enable once that is fixed.
871 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 803 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
872 Stats stats; 804 Stats stats;
873 // Fetch available send/receive bitrates. 805 // Fetch available send/receive bitrates.
874 uint32_t send_bandwidth = 0; 806 uint32_t send_bandwidth = 0;
875 transport_send_->send_side_cc()->GetBitrateController()->AvailableBandwidth( 807 transport_send_->send_side_cc()->GetBitrateController()->AvailableBandwidth(
876 &send_bandwidth); 808 &send_bandwidth);
877 std::vector<unsigned int> ssrcs; 809 std::vector<unsigned int> ssrcs;
878 uint32_t recv_bandwidth = 0; 810 uint32_t recv_bandwidth = 0;
811
812 // TODO(nisse): Is this thread safe? Most access to |receive_side_cc_| is done
813 // via |rtp_transport_receive_|, and protected by |receive_crit_|.
879 receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate( 814 receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate(
880 &ssrcs, &recv_bandwidth); 815 &ssrcs, &recv_bandwidth);
816
881 stats.send_bandwidth_bps = send_bandwidth; 817 stats.send_bandwidth_bps = send_bandwidth;
882 stats.recv_bandwidth_bps = recv_bandwidth; 818 stats.recv_bandwidth_bps = recv_bandwidth;
883 stats.pacer_delay_ms = 819 stats.pacer_delay_ms =
884 transport_send_->send_side_cc()->GetPacerQueuingDelayMs(); 820 transport_send_->send_side_cc()->GetPacerQueuingDelayMs();
885 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); 821 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt();
886 { 822 {
887 rtc::CritScope cs(&bitrate_crit_); 823 rtc::CritScope cs(&bitrate_crit_);
888 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_; 824 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_;
889 } 825 }
890 return stats; 826 return stats;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 } 1148 }
1213 1149
1214 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, 1150 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type,
1215 const uint8_t* packet, 1151 const uint8_t* packet,
1216 size_t length, 1152 size_t length,
1217 const PacketTime& packet_time) { 1153 const PacketTime& packet_time) {
1218 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); 1154 TRACE_EVENT0("webrtc", "Call::DeliverRtp");
1219 1155
1220 RTC_DCHECK(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO); 1156 RTC_DCHECK(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO);
1221 1157
1158 int64_t arrival_time_ms;
1159 if (packet_time.timestamp != -1) {
1160 arrival_time_ms = (packet_time.timestamp + 500) / 1000;
1161 } else {
1162 arrival_time_ms = clock_->TimeInMilliseconds();
1163 }
1164
1222 ReadLockScoped read_lock(*receive_crit_); 1165 ReadLockScoped read_lock(*receive_crit_);
1223 // TODO(nisse): We should parse the RTP header only here, and pass
1224 // on parsed_packet to the receive streams.
1225 rtc::Optional<RtpPacketReceived> parsed_packet =
1226 ParseRtpPacket(packet, length, packet_time);
1227 1166
1228 if (!parsed_packet) 1167 received_bytes_per_second_counter_.Add(static_cast<int>(length));
1229 return DELIVERY_PACKET_ERROR;
1230
1231 NotifyBweOfReceivedPacket(*parsed_packet, media_type);
1232
1233 uint32_t ssrc = parsed_packet->Ssrc();
1234
1235 if (media_type == MediaType::AUDIO) { 1168 if (media_type == MediaType::AUDIO) {
1236 auto it = audio_receive_ssrcs_.find(ssrc); 1169 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length));
1237 if (it != audio_receive_ssrcs_.end()) { 1170 return rtp_transport_receive_audio_->OnRtpPacket(
1238 received_bytes_per_second_counter_.Add(static_cast<int>(length)); 1171 arrival_time_ms, rtc::ArrayView<const uint8_t>(packet, length));
1239 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); 1172 } else if (media_type == MediaType::VIDEO) {
1240 it->second->OnRtpPacket(*parsed_packet); 1173 received_video_bytes_per_second_counter_.Add(static_cast<int>(length));
1241 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); 1174 return rtp_transport_receive_video_->OnRtpPacket(
1242 return DELIVERY_OK; 1175 arrival_time_ms, rtc::ArrayView<const uint8_t>(packet, length));
1243 }
1244 } 1176 }
1245 if (media_type == MediaType::VIDEO) { 1177 RTC_NOTREACHED();
1246 auto it = video_receive_ssrcs_.find(ssrc);
1247 if (it != video_receive_ssrcs_.end()) {
1248 received_bytes_per_second_counter_.Add(static_cast<int>(length));
1249 received_video_bytes_per_second_counter_.Add(static_cast<int>(length));
1250 it->second->OnRtpPacket(*parsed_packet);
1251
1252 // Deliver media packets to FlexFEC subsystem.
1253 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc);
1254 for (auto it = it_bounds.first; it != it_bounds.second; ++it)
1255 it->second->OnRtpPacket(*parsed_packet);
1256
1257 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
1258 return DELIVERY_OK;
1259 }
1260 }
1261 if (media_type == MediaType::VIDEO) {
1262 received_bytes_per_second_counter_.Add(static_cast<int>(length));
1263 // TODO(brandtr): Update here when FlexFEC supports protecting audio.
1264 received_video_bytes_per_second_counter_.Add(static_cast<int>(length));
1265 auto it = flexfec_receive_ssrcs_protection_.find(ssrc);
1266 if (it != flexfec_receive_ssrcs_protection_.end()) {
1267 it->second->OnRtpPacket(*parsed_packet);
1268 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
1269 return DELIVERY_OK;
1270 }
1271 }
1272 return DELIVERY_UNKNOWN_SSRC;
1273 } 1178 }
1274 1179
1275 PacketReceiver::DeliveryStatus Call::DeliverPacket( 1180 PacketReceiver::DeliveryStatus Call::DeliverPacket(
1276 MediaType media_type, 1181 MediaType media_type,
1277 const uint8_t* packet, 1182 const uint8_t* packet,
1278 size_t length, 1183 size_t length,
1279 const PacketTime& packet_time) { 1184 const PacketTime& packet_time) {
1280 // TODO(solenberg): Tests call this function on a network thread, libjingle 1185 // TODO(solenberg): Tests call this function on a network thread, libjingle
1281 // calls on the worker thread. We should move towards always using a network 1186 // calls on the worker thread. We should move towards always using a network
1282 // thread. Then this check can be enabled. 1187 // thread. Then this check can be enabled.
1283 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); 1188 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread());
1284 if (RtpHeaderParser::IsRtcp(packet, length)) 1189 if (RtpHeaderParser::IsRtcp(packet, length))
1285 return DeliverRtcp(media_type, packet, length); 1190 return DeliverRtcp(media_type, packet, length);
1286 1191
1287 return DeliverRtp(media_type, packet, length, packet_time); 1192 return DeliverRtp(media_type, packet, length, packet_time);
1288 } 1193 }
1289 1194
1290 // TODO(brandtr): Update this member function when we support protecting 1195 // TODO(brandtr): Update this member function when we support protecting
1291 // audio packets with FlexFEC. 1196 // audio packets with FlexFEC.
1197
1198 // TODO(nisse): Add a recovered flag to RtpParsedPacket, if needed for stats,
1199 // and demux recovered packets in the same way as ordinary packets.
1292 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { 1200 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) {
1293 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); 1201 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]);
1294 ReadLockScoped read_lock(*receive_crit_); 1202 ReadLockScoped read_lock(*receive_crit_);
1295 auto it = video_receive_ssrcs_.find(ssrc); 1203 auto it = video_receive_ssrcs_.find(ssrc);
1296 if (it == video_receive_ssrcs_.end()) 1204 if (it == video_receive_ssrcs_.end())
1297 return false; 1205 return false;
1298 return it->second->OnRecoveredPacket(packet, length); 1206 return it->second->OnRecoveredPacket(packet, length);
1299 } 1207 }
1300 1208
1301 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet,
1302 MediaType media_type) {
1303 auto it = receive_rtp_config_.find(packet.Ssrc());
1304 bool use_send_side_bwe =
1305 (it != receive_rtp_config_.end()) && it->second.use_send_side_bwe;
1306
1307 RTPHeader header;
1308 packet.GetHeader(&header);
1309
1310 if (!use_send_side_bwe && header.extension.hasTransportSequenceNumber) {
1311 // Inconsistent configuration of send side BWE. Do nothing.
1312 // TODO(nisse): Without this check, we may produce RTCP feedback
1313 // packets even when not negotiated. But it would be cleaner to
1314 // move the check down to RTCPSender::SendFeedbackPacket, which
1315 // would also help the PacketRouter to select an appropriate rtp
1316 // module in the case that some, but not all, have RTCP feedback
1317 // enabled.
1318 return;
1319 }
1320 // For audio, we only support send side BWE.
1321 if (media_type == MediaType::VIDEO ||
1322 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) {
1323 receive_side_cc_.OnReceivedPacket(
1324 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(),
1325 header);
1326 }
1327 }
1328
1329 } // namespace internal 1209 } // namespace internal
1330 1210
1331 } // namespace webrtc 1211 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698