OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 const uint8_t* packet, | 205 const uint8_t* packet, |
205 size_t length, | 206 size_t length, |
206 const PacketTime& packet_time); | 207 const PacketTime& packet_time); |
207 void ConfigureSync(const std::string& sync_group) | 208 void ConfigureSync(const std::string& sync_group) |
208 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); | 209 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
209 | 210 |
210 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, | 211 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, |
211 MediaType media_type) | 212 MediaType media_type) |
212 SHARED_LOCKS_REQUIRED(receive_crit_); | 213 SHARED_LOCKS_REQUIRED(receive_crit_); |
213 | 214 |
214 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, | |
215 size_t length, | |
216 const PacketTime& packet_time) | |
217 SHARED_LOCKS_REQUIRED(receive_crit_); | |
218 | |
219 void UpdateSendHistograms(int64_t first_sent_packet_ms) | 215 void UpdateSendHistograms(int64_t first_sent_packet_ms) |
220 EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); | 216 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 |
292 // from the destructor, and therefore doesn't need any explicit | 259 // from the destructor, and therefore doesn't need any explicit |
293 // synchronization. | 260 // synchronization. |
294 RateCounter received_bytes_per_second_counter_; | 261 RateCounter received_bytes_per_second_counter_; |
295 RateCounter received_audio_bytes_per_second_counter_; | 262 RateCounter received_audio_bytes_per_second_counter_; |
296 RateCounter received_video_bytes_per_second_counter_; | 263 RateCounter received_video_bytes_per_second_counter_; |
297 RateCounter received_rtcp_bytes_per_second_counter_; | 264 RateCounter received_rtcp_bytes_per_second_counter_; |
298 | 265 |
299 // TODO(holmer): Remove this lock once BitrateController no longer calls | 266 // TODO(holmer): Remove this lock once BitrateController no longer calls |
300 // OnNetworkChanged from multiple threads. | 267 // OnNetworkChanged from multiple threads. |
301 rtc::CriticalSection bitrate_crit_; | 268 rtc::CriticalSection bitrate_crit_; |
302 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); | 269 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); |
303 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); | 270 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); |
304 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); | 271 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); |
305 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); | 272 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); |
306 | 273 |
307 std::map<std::string, rtc::NetworkRoute> network_routes_; | 274 std::map<std::string, rtc::NetworkRoute> network_routes_; |
308 | 275 |
309 std::unique_ptr<RtpTransportControllerSendInterface> transport_send_; | 276 std::unique_ptr<RtpTransportControllerSendInterface> transport_send_; |
310 ReceiveSideCongestionController receive_side_cc_; | 277 ReceiveSideCongestionController receive_side_cc_; |
| 278 // TODO(nisse): Currently we always use separate demuxers. These |
| 279 // should be created and owned outside of Call, passing pointers |
| 280 // when Call is created. Then we should have two separate objects in |
| 281 // the unbundled case, and two pointers to the same object in the |
| 282 // bundled case. |
| 283 std::unique_ptr<RtpTransportControllerReceiveInterface> |
| 284 rtp_transport_receive_audio_ GUARDED_BY(receive_crit_); |
| 285 std::unique_ptr<RtpTransportControllerReceiveInterface> |
| 286 rtp_transport_receive_video_ GUARDED_BY(receive_crit_); |
311 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; | 287 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; |
312 const int64_t start_ms_; | 288 const int64_t start_ms_; |
313 // TODO(perkj): |worker_queue_| is supposed to replace | 289 // TODO(perkj): |worker_queue_| is supposed to replace |
314 // |module_process_thread_|. | 290 // |module_process_thread_|. |
315 // |worker_queue| is defined last to ensure all pending tasks are cancelled | 291 // |worker_queue| is defined last to ensure all pending tasks are cancelled |
316 // and deleted before any other members. | 292 // and deleted before any other members. |
317 rtc::TaskQueue worker_queue_; | 293 rtc::TaskQueue worker_queue_; |
318 | 294 |
319 RTC_DISALLOW_COPY_AND_ASSIGN(Call); | 295 RTC_DISALLOW_COPY_AND_ASSIGN(Call); |
320 }; | 296 }; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 event_log_(config.event_log), | 333 event_log_(config.event_log), |
358 received_bytes_per_second_counter_(clock_, nullptr, true), | 334 received_bytes_per_second_counter_(clock_, nullptr, true), |
359 received_audio_bytes_per_second_counter_(clock_, nullptr, true), | 335 received_audio_bytes_per_second_counter_(clock_, nullptr, true), |
360 received_video_bytes_per_second_counter_(clock_, nullptr, true), | 336 received_video_bytes_per_second_counter_(clock_, nullptr, true), |
361 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), | 337 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), |
362 min_allocated_send_bitrate_bps_(0), | 338 min_allocated_send_bitrate_bps_(0), |
363 configured_max_padding_bitrate_bps_(0), | 339 configured_max_padding_bitrate_bps_(0), |
364 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), | 340 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), |
365 pacer_bitrate_kbps_counter_(clock_, nullptr, true), | 341 pacer_bitrate_kbps_counter_(clock_, nullptr, true), |
366 receive_side_cc_(clock_, transport_send->packet_router()), | 342 receive_side_cc_(clock_, transport_send->packet_router()), |
| 343 rtp_transport_receive_audio_( |
| 344 RtpTransportControllerReceiveInterface::Create( |
| 345 &receive_side_cc_, |
| 346 false /* enable_receive_side_bwe */)), |
| 347 rtp_transport_receive_video_( |
| 348 RtpTransportControllerReceiveInterface::Create( |
| 349 &receive_side_cc_, |
| 350 true /* enable_receive_side_bwe */)), |
367 video_send_delay_stats_(new SendDelayStats(clock_)), | 351 video_send_delay_stats_(new SendDelayStats(clock_)), |
368 start_ms_(clock_->TimeInMilliseconds()), | 352 start_ms_(clock_->TimeInMilliseconds()), |
369 worker_queue_("call_worker_queue") { | 353 worker_queue_("call_worker_queue") { |
370 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 354 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
371 RTC_DCHECK(config.event_log != nullptr); | 355 RTC_DCHECK(config.event_log != nullptr); |
372 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 356 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
373 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 357 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
374 config.bitrate_config.min_bitrate_bps); | 358 config.bitrate_config.min_bitrate_bps); |
375 if (config.bitrate_config.max_bitrate_bps != -1) { | 359 if (config.bitrate_config.max_bitrate_bps != -1) { |
376 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 360 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
(...skipping 22 matching lines...) Expand all Loading... |
399 | 383 |
400 pacer_thread_->Start(); | 384 pacer_thread_->Start(); |
401 } | 385 } |
402 | 386 |
403 Call::~Call() { | 387 Call::~Call() { |
404 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 388 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
405 | 389 |
406 RTC_CHECK(audio_send_ssrcs_.empty()); | 390 RTC_CHECK(audio_send_ssrcs_.empty()); |
407 RTC_CHECK(video_send_ssrcs_.empty()); | 391 RTC_CHECK(video_send_ssrcs_.empty()); |
408 RTC_CHECK(video_send_streams_.empty()); | 392 RTC_CHECK(video_send_streams_.empty()); |
409 RTC_CHECK(audio_receive_ssrcs_.empty()); | |
410 RTC_CHECK(video_receive_ssrcs_.empty()); | |
411 RTC_CHECK(video_receive_streams_.empty()); | |
412 | 393 |
413 pacer_thread_->Stop(); | 394 pacer_thread_->Stop(); |
414 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer()); | 395 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer()); |
415 pacer_thread_->DeRegisterModule( | 396 pacer_thread_->DeRegisterModule( |
416 receive_side_cc_.GetRemoteBitrateEstimator(true)); | 397 receive_side_cc_.GetRemoteBitrateEstimator(true)); |
417 module_process_thread_->DeRegisterModule(transport_send_->send_side_cc()); | 398 module_process_thread_->DeRegisterModule(transport_send_->send_side_cc()); |
418 module_process_thread_->DeRegisterModule(&receive_side_cc_); | 399 module_process_thread_->DeRegisterModule(&receive_side_cc_); |
419 module_process_thread_->DeRegisterModule(call_stats_.get()); | 400 module_process_thread_->DeRegisterModule(call_stats_.get()); |
420 module_process_thread_->Stop(); | 401 module_process_thread_->Stop(); |
421 call_stats_->DeregisterStatsObserver(&receive_side_cc_); | 402 call_stats_->DeregisterStatsObserver(&receive_side_cc_); |
422 call_stats_->DeregisterStatsObserver(transport_send_->send_side_cc()); | 403 call_stats_->DeregisterStatsObserver(transport_send_->send_side_cc()); |
423 | 404 |
424 int64_t first_sent_packet_ms = | 405 int64_t first_sent_packet_ms = |
425 transport_send_->send_side_cc()->GetFirstPacketTimeMs(); | 406 transport_send_->send_side_cc()->GetFirstPacketTimeMs(); |
426 // Only update histograms after process threads have been shut down, so that | 407 // Only update histograms after process threads have been shut down, so that |
427 // they won't try to concurrently update stats. | 408 // they won't try to concurrently update stats. |
428 { | 409 { |
429 rtc::CritScope lock(&bitrate_crit_); | 410 rtc::CritScope lock(&bitrate_crit_); |
430 UpdateSendHistograms(first_sent_packet_ms); | 411 UpdateSendHistograms(first_sent_packet_ms); |
431 } | 412 } |
432 UpdateReceiveHistograms(); | 413 UpdateReceiveHistograms(); |
433 UpdateHistograms(); | 414 UpdateHistograms(); |
434 | 415 |
435 Trace::ReturnTrace(); | 416 Trace::ReturnTrace(); |
436 } | 417 } |
437 | 418 |
438 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( | |
439 const uint8_t* packet, | |
440 size_t length, | |
441 const PacketTime& packet_time) { | |
442 RtpPacketReceived parsed_packet; | |
443 if (!parsed_packet.Parse(packet, length)) | |
444 return rtc::Optional<RtpPacketReceived>(); | |
445 | |
446 auto it = receive_rtp_config_.find(parsed_packet.Ssrc()); | |
447 if (it != receive_rtp_config_.end()) | |
448 parsed_packet.IdentifyExtensions(it->second.extensions); | |
449 | |
450 int64_t arrival_time_ms; | |
451 if (packet_time.timestamp != -1) { | |
452 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | |
453 } else { | |
454 arrival_time_ms = clock_->TimeInMilliseconds(); | |
455 } | |
456 parsed_packet.set_arrival_time_ms(arrival_time_ms); | |
457 | |
458 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); | |
459 } | |
460 | |
461 void Call::UpdateHistograms() { | 419 void Call::UpdateHistograms() { |
462 RTC_HISTOGRAM_COUNTS_100000( | 420 RTC_HISTOGRAM_COUNTS_100000( |
463 "WebRTC.Call.LifetimeInSeconds", | 421 "WebRTC.Call.LifetimeInSeconds", |
464 (clock_->TimeInMilliseconds() - start_ms_) / 1000); | 422 (clock_->TimeInMilliseconds() - start_ms_) / 1000); |
465 } | 423 } |
466 | 424 |
467 void Call::UpdateSendHistograms(int64_t first_sent_packet_ms) { | 425 void Call::UpdateSendHistograms(int64_t first_sent_packet_ms) { |
468 if (first_sent_packet_ms == -1) | 426 if (first_sent_packet_ms == -1) |
469 return; | 427 return; |
470 int64_t elapsed_sec = | 428 int64_t elapsed_sec = |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 } | 546 } |
589 | 547 |
590 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 548 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
591 const webrtc::AudioReceiveStream::Config& config) { | 549 const webrtc::AudioReceiveStream::Config& config) { |
592 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 550 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
593 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 551 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
594 event_log_->LogAudioReceiveStreamConfig(config); | 552 event_log_->LogAudioReceiveStreamConfig(config); |
595 AudioReceiveStream* receive_stream = | 553 AudioReceiveStream* receive_stream = |
596 new AudioReceiveStream(transport_send_->packet_router(), config, | 554 new AudioReceiveStream(transport_send_->packet_router(), config, |
597 config_.audio_state, event_log_); | 555 config_.audio_state, event_log_); |
| 556 RtpTransportControllerReceiveInterface::Config receive_config; |
| 557 receive_config.use_send_side_bwe = UseSendSideBwe(config); |
| 558 |
598 { | 559 { |
599 WriteLockScoped write_lock(*receive_crit_); | 560 WriteLockScoped write_lock(*receive_crit_); |
600 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 561 rtp_transport_receive_audio_->AddReceiver( |
601 audio_receive_ssrcs_.end()); | 562 config.rtp.remote_ssrc, receive_config, receive_stream); |
| 563 |
602 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 564 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
603 receive_rtp_config_[config.rtp.remote_ssrc] = | |
604 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config)); | |
605 | |
606 ConfigureSync(config.sync_group); | 565 ConfigureSync(config.sync_group); |
607 } | 566 } |
608 { | 567 { |
609 ReadLockScoped read_lock(*send_crit_); | 568 ReadLockScoped read_lock(*send_crit_); |
610 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); | 569 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); |
611 if (it != audio_send_ssrcs_.end()) { | 570 if (it != audio_send_ssrcs_.end()) { |
612 receive_stream->AssociateSendStream(it->second); | 571 receive_stream->AssociateSendStream(it->second); |
613 } | 572 } |
614 } | 573 } |
615 receive_stream->SignalNetworkState(audio_network_state_); | 574 receive_stream->SignalNetworkState(audio_network_state_); |
616 UpdateAggregateNetworkState(); | 575 UpdateAggregateNetworkState(); |
617 return receive_stream; | 576 return receive_stream; |
618 } | 577 } |
619 | 578 |
620 void Call::DestroyAudioReceiveStream( | 579 void Call::DestroyAudioReceiveStream( |
621 webrtc::AudioReceiveStream* receive_stream) { | 580 webrtc::AudioReceiveStream* receive_stream) { |
622 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); | 581 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); |
623 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 582 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
624 RTC_DCHECK(receive_stream != nullptr); | 583 RTC_DCHECK(receive_stream != nullptr); |
625 webrtc::internal::AudioReceiveStream* audio_receive_stream = | 584 webrtc::internal::AudioReceiveStream* audio_receive_stream = |
626 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); | 585 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); |
627 { | 586 { |
628 WriteLockScoped write_lock(*receive_crit_); | 587 WriteLockScoped write_lock(*receive_crit_); |
| 588 rtp_transport_receive_audio_->RemoveReceiver(audio_receive_stream); |
| 589 |
629 const AudioReceiveStream::Config& config = audio_receive_stream->config(); | 590 const AudioReceiveStream::Config& config = audio_receive_stream->config(); |
630 uint32_t ssrc = config.rtp.remote_ssrc; | 591 uint32_t ssrc = config.rtp.remote_ssrc; |
631 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) | |
632 ->RemoveStream(ssrc); | |
633 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); | 592 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); |
634 RTC_DCHECK(num_deleted == 1); | 593 RTC_DCHECK(num_deleted == 1); |
635 const std::string& sync_group = audio_receive_stream->config().sync_group; | 594 const std::string& sync_group = audio_receive_stream->config().sync_group; |
636 const auto it = sync_stream_mapping_.find(sync_group); | 595 const auto it = sync_stream_mapping_.find(sync_group); |
637 if (it != sync_stream_mapping_.end() && | 596 if (it != sync_stream_mapping_.end() && |
638 it->second == audio_receive_stream) { | 597 it->second == audio_receive_stream) { |
639 sync_stream_mapping_.erase(it); | 598 sync_stream_mapping_.erase(it); |
640 ConfigureSync(sync_group); | 599 ConfigureSync(sync_group); |
641 } | 600 } |
642 receive_rtp_config_.erase(ssrc); | |
643 } | 601 } |
644 UpdateAggregateNetworkState(); | 602 UpdateAggregateNetworkState(); |
645 delete audio_receive_stream; | 603 delete audio_receive_stream; |
646 } | 604 } |
647 | 605 |
648 webrtc::VideoSendStream* Call::CreateVideoSendStream( | 606 webrtc::VideoSendStream* Call::CreateVideoSendStream( |
649 webrtc::VideoSendStream::Config config, | 607 webrtc::VideoSendStream::Config config, |
650 VideoEncoderConfig encoder_config) { | 608 VideoEncoderConfig encoder_config) { |
651 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); | 609 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); |
652 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 610 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 webrtc::VideoReceiveStream::Config configuration) { | 675 webrtc::VideoReceiveStream::Config configuration) { |
718 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 676 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
719 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 677 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
720 | 678 |
721 VideoReceiveStream* receive_stream = | 679 VideoReceiveStream* receive_stream = |
722 new VideoReceiveStream(num_cpu_cores_, transport_send_->packet_router(), | 680 new VideoReceiveStream(num_cpu_cores_, transport_send_->packet_router(), |
723 std::move(configuration), | 681 std::move(configuration), |
724 module_process_thread_.get(), call_stats_.get()); | 682 module_process_thread_.get(), call_stats_.get()); |
725 | 683 |
726 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 684 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
727 ReceiveRtpConfig receive_config(config.rtp.extensions, | 685 RtpTransportControllerReceiveInterface::Config receive_config; |
728 UseSendSideBwe(config)); | 686 receive_config.use_send_side_bwe = UseSendSideBwe(config); |
| 687 |
729 { | 688 { |
730 WriteLockScoped write_lock(*receive_crit_); | 689 WriteLockScoped write_lock(*receive_crit_); |
731 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 690 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
732 video_receive_ssrcs_.end()); | 691 video_receive_ssrcs_.end()); |
733 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 692 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
| 693 rtp_transport_receive_video_->AddReceiver( |
| 694 config.rtp.remote_ssrc, receive_config, receive_stream); |
| 695 |
734 if (config.rtp.rtx_ssrc) { | 696 if (config.rtp.rtx_ssrc) { |
735 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; | 697 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; |
736 // We record identical config for the rtx stream as for the main | 698 // We record identical config for the rtx stream as for the main |
737 // stream. Since the transport_send_cc negotiation is per payload | 699 // stream. Since the transport_send_cc negotiation is per payload |
738 // type, we may get an incorrect value for the rtx stream, but | 700 // type, we may get an incorrect value for the rtx stream, but |
739 // that is unlikely to matter in practice. | 701 // that is unlikely to matter in practice. |
740 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config; | 702 rtp_transport_receive_video_->AddReceiver( |
| 703 config.rtp.rtx_ssrc, receive_config, receive_stream); |
741 } | 704 } |
742 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config; | |
743 video_receive_streams_.insert(receive_stream); | 705 video_receive_streams_.insert(receive_stream); |
744 ConfigureSync(config.sync_group); | 706 ConfigureSync(config.sync_group); |
745 } | 707 } |
746 receive_stream->SignalNetworkState(video_network_state_); | 708 receive_stream->SignalNetworkState(video_network_state_); |
747 UpdateAggregateNetworkState(); | 709 UpdateAggregateNetworkState(); |
748 event_log_->LogVideoReceiveStreamConfig(config); | 710 event_log_->LogVideoReceiveStreamConfig(config); |
749 return receive_stream; | 711 return receive_stream; |
750 } | 712 } |
751 | 713 |
752 void Call::DestroyVideoReceiveStream( | 714 void Call::DestroyVideoReceiveStream( |
753 webrtc::VideoReceiveStream* receive_stream) { | 715 webrtc::VideoReceiveStream* receive_stream) { |
754 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 716 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
755 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 717 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
756 RTC_DCHECK(receive_stream != nullptr); | 718 RTC_DCHECK(receive_stream != nullptr); |
757 VideoReceiveStream* receive_stream_impl = nullptr; | 719 VideoReceiveStream* receive_stream_impl = nullptr; |
758 { | 720 { |
759 WriteLockScoped write_lock(*receive_crit_); | 721 WriteLockScoped write_lock(*receive_crit_); |
760 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a | 722 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a |
761 // separate SSRC there can be either one or two. | 723 // separate SSRC there can be either one or two. |
762 auto it = video_receive_ssrcs_.begin(); | 724 auto it = video_receive_ssrcs_.begin(); |
763 while (it != video_receive_ssrcs_.end()) { | 725 while (it != video_receive_ssrcs_.end()) { |
764 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { | 726 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { |
765 if (receive_stream_impl != nullptr) | 727 if (receive_stream_impl != nullptr) |
766 RTC_DCHECK(receive_stream_impl == it->second); | 728 RTC_DCHECK(receive_stream_impl == it->second); |
767 receive_stream_impl = it->second; | 729 receive_stream_impl = it->second; |
768 receive_rtp_config_.erase(it->first); | |
769 it = video_receive_ssrcs_.erase(it); | 730 it = video_receive_ssrcs_.erase(it); |
770 } else { | 731 } else { |
771 ++it; | 732 ++it; |
772 } | 733 } |
773 } | 734 } |
774 video_receive_streams_.erase(receive_stream_impl); | 735 video_receive_streams_.erase(receive_stream_impl); |
775 RTC_CHECK(receive_stream_impl != nullptr); | 736 RTC_CHECK(receive_stream_impl != nullptr); |
776 ConfigureSync(receive_stream_impl->config().sync_group); | 737 ConfigureSync(receive_stream_impl->config().sync_group); |
| 738 rtp_transport_receive_video_->RemoveReceiver(receive_stream_impl); |
777 } | 739 } |
778 const VideoReceiveStream::Config& config = receive_stream_impl->config(); | |
779 | |
780 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) | |
781 ->RemoveStream(config.rtp.remote_ssrc); | |
782 | 740 |
783 UpdateAggregateNetworkState(); | 741 UpdateAggregateNetworkState(); |
784 delete receive_stream_impl; | 742 delete receive_stream_impl; |
785 } | 743 } |
786 | 744 |
787 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( | 745 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( |
788 const FlexfecReceiveStream::Config& config) { | 746 const FlexfecReceiveStream::Config& config) { |
789 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); | 747 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); |
790 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 748 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
791 | 749 |
792 RecoveredPacketReceiver* recovered_packet_receiver = this; | 750 RecoveredPacketReceiver* recovered_packet_receiver = this; |
793 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl( | 751 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl( |
794 config, recovered_packet_receiver, call_stats_->rtcp_rtt_stats(), | 752 config, recovered_packet_receiver, call_stats_->rtcp_rtt_stats(), |
795 module_process_thread_.get()); | 753 module_process_thread_.get()); |
796 | 754 |
| 755 RtpTransportControllerReceiveInterface::Config receive_config; |
| 756 receive_config.use_send_side_bwe = UseSendSideBwe(config); |
| 757 |
797 { | 758 { |
798 WriteLockScoped write_lock(*receive_crit_); | 759 WriteLockScoped write_lock(*receive_crit_); |
| 760 rtp_transport_receive_video_->AddReceiver(config.remote_ssrc, |
| 761 receive_config, receive_stream); |
799 | 762 |
800 RTC_DCHECK(flexfec_receive_streams_.find(receive_stream) == | 763 for (auto ssrc : config.protected_media_ssrcs) { |
801 flexfec_receive_streams_.end()); | 764 rtp_transport_receive_video_->AddSink(ssrc, receive_stream); |
802 flexfec_receive_streams_.insert(receive_stream); | 765 } |
803 | |
804 for (auto ssrc : config.protected_media_ssrcs) | |
805 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); | |
806 | |
807 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == | |
808 flexfec_receive_ssrcs_protection_.end()); | |
809 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; | |
810 | |
811 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) == | |
812 receive_rtp_config_.end()); | |
813 receive_rtp_config_[config.remote_ssrc] = | |
814 ReceiveRtpConfig(config.rtp_header_extensions, UseSendSideBwe(config)); | |
815 } | 766 } |
816 | 767 |
817 // TODO(brandtr): Store config in RtcEventLog here. | 768 // TODO(brandtr): Store config in RtcEventLog here. |
818 | 769 |
819 return receive_stream; | 770 return receive_stream; |
820 } | 771 } |
821 | 772 |
822 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { | 773 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { |
823 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); | 774 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); |
824 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 775 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
825 | 776 |
826 RTC_DCHECK(receive_stream != nullptr); | 777 RTC_DCHECK(receive_stream != nullptr); |
827 // There exist no other derived classes of FlexfecReceiveStream, | 778 // There exist no other derived classes of FlexfecReceiveStream, |
828 // so this downcast is safe. | 779 // so this downcast is safe. |
829 FlexfecReceiveStreamImpl* receive_stream_impl = | 780 FlexfecReceiveStreamImpl* receive_stream_impl = |
830 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); | 781 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); |
831 { | 782 { |
832 WriteLockScoped write_lock(*receive_crit_); | 783 WriteLockScoped write_lock(*receive_crit_); |
833 | 784 rtp_transport_receive_video_->RemoveSink(receive_stream_impl); |
834 const FlexfecReceiveStream::Config& config = | 785 rtp_transport_receive_video_->RemoveReceiver(receive_stream_impl); |
835 receive_stream_impl->GetConfig(); | |
836 uint32_t ssrc = config.remote_ssrc; | |
837 receive_rtp_config_.erase(ssrc); | |
838 | |
839 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be | |
840 // destroyed. | |
841 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); | |
842 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { | |
843 if (prot_it->second == receive_stream_impl) | |
844 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); | |
845 else | |
846 ++prot_it; | |
847 } | |
848 auto media_it = flexfec_receive_ssrcs_media_.begin(); | |
849 while (media_it != flexfec_receive_ssrcs_media_.end()) { | |
850 if (media_it->second == receive_stream_impl) | |
851 media_it = flexfec_receive_ssrcs_media_.erase(media_it); | |
852 else | |
853 ++media_it; | |
854 } | |
855 | |
856 receive_side_cc_.GetRemoteBitrateEstimator(UseSendSideBwe(config)) | |
857 ->RemoveStream(ssrc); | |
858 | |
859 flexfec_receive_streams_.erase(receive_stream_impl); | |
860 } | 786 } |
861 | 787 |
862 delete receive_stream_impl; | 788 delete receive_stream_impl; |
863 } | 789 } |
864 | 790 |
865 Call::Stats Call::GetStats() const { | 791 Call::Stats Call::GetStats() const { |
866 // TODO(solenberg): Some test cases in EndToEndTest use this from a different | 792 // TODO(solenberg): Some test cases in EndToEndTest use this from a different |
867 // thread. Re-enable once that is fixed. | 793 // thread. Re-enable once that is fixed. |
868 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 794 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
869 Stats stats; | 795 Stats stats; |
870 // Fetch available send/receive bitrates. | 796 // Fetch available send/receive bitrates. |
871 uint32_t send_bandwidth = 0; | 797 uint32_t send_bandwidth = 0; |
872 transport_send_->send_side_cc()->GetBitrateController()->AvailableBandwidth( | 798 transport_send_->send_side_cc()->GetBitrateController()->AvailableBandwidth( |
873 &send_bandwidth); | 799 &send_bandwidth); |
874 std::vector<unsigned int> ssrcs; | 800 std::vector<unsigned int> ssrcs; |
875 uint32_t recv_bandwidth = 0; | 801 uint32_t recv_bandwidth = 0; |
| 802 |
| 803 // TODO(nisse): Is this thread safe? Most access to |receive_side_cc_| is done |
| 804 // via |rtp_transport_receive_|, and protected by |receive_crit_|. |
876 receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate( | 805 receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate( |
877 &ssrcs, &recv_bandwidth); | 806 &ssrcs, &recv_bandwidth); |
| 807 |
878 stats.send_bandwidth_bps = send_bandwidth; | 808 stats.send_bandwidth_bps = send_bandwidth; |
879 stats.recv_bandwidth_bps = recv_bandwidth; | 809 stats.recv_bandwidth_bps = recv_bandwidth; |
880 stats.pacer_delay_ms = | 810 stats.pacer_delay_ms = |
881 transport_send_->send_side_cc()->GetPacerQueuingDelayMs(); | 811 transport_send_->send_side_cc()->GetPacerQueuingDelayMs(); |
882 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); | 812 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); |
883 { | 813 { |
884 rtc::CritScope cs(&bitrate_crit_); | 814 rtc::CritScope cs(&bitrate_crit_); |
885 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_; | 815 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_; |
886 } | 816 } |
887 return stats; | 817 return stats; |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 } | 1137 } |
1208 | 1138 |
1209 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, | 1139 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, |
1210 const uint8_t* packet, | 1140 const uint8_t* packet, |
1211 size_t length, | 1141 size_t length, |
1212 const PacketTime& packet_time) { | 1142 const PacketTime& packet_time) { |
1213 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); | 1143 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); |
1214 | 1144 |
1215 RTC_DCHECK(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO); | 1145 RTC_DCHECK(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO); |
1216 | 1146 |
| 1147 int64_t arrival_time_ms; |
| 1148 if (packet_time.timestamp != -1) { |
| 1149 arrival_time_ms = (packet_time.timestamp + 500) / 1000; |
| 1150 } else { |
| 1151 arrival_time_ms = clock_->TimeInMilliseconds(); |
| 1152 } |
| 1153 |
1217 ReadLockScoped read_lock(*receive_crit_); | 1154 ReadLockScoped read_lock(*receive_crit_); |
1218 // TODO(nisse): We should parse the RTP header only here, and pass | |
1219 // on parsed_packet to the receive streams. | |
1220 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1221 ParseRtpPacket(packet, length, packet_time); | |
1222 | 1155 |
1223 if (!parsed_packet) | 1156 received_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1224 return DELIVERY_PACKET_ERROR; | |
1225 | |
1226 NotifyBweOfReceivedPacket(*parsed_packet, media_type); | |
1227 | |
1228 uint32_t ssrc = parsed_packet->Ssrc(); | |
1229 | |
1230 if (media_type == MediaType::AUDIO) { | 1157 if (media_type == MediaType::AUDIO) { |
1231 auto it = audio_receive_ssrcs_.find(ssrc); | 1158 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1232 if (it != audio_receive_ssrcs_.end()) { | 1159 return rtp_transport_receive_audio_->OnRtpPacket( |
1233 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1160 arrival_time_ms, rtc::ArrayView<const uint8_t>(packet, length)); |
1234 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1161 } else if (media_type == MediaType::VIDEO) { |
1235 it->second->OnRtpPacket(*parsed_packet); | 1162 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1236 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1163 return rtp_transport_receive_video_->OnRtpPacket( |
1237 return DELIVERY_OK; | 1164 arrival_time_ms, rtc::ArrayView<const uint8_t>(packet, length)); |
1238 } | |
1239 } | 1165 } |
1240 if (media_type == MediaType::VIDEO) { | 1166 RTC_NOTREACHED(); |
1241 auto it = video_receive_ssrcs_.find(ssrc); | 1167 return PacketReceiver::DELIVERY_PACKET_ERROR; |
1242 if (it != video_receive_ssrcs_.end()) { | |
1243 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | |
1244 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); | |
1245 it->second->OnRtpPacket(*parsed_packet); | |
1246 | |
1247 // Deliver media packets to FlexFEC subsystem. | |
1248 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); | |
1249 for (auto it = it_bounds.first; it != it_bounds.second; ++it) | |
1250 it->second->OnRtpPacket(*parsed_packet); | |
1251 | |
1252 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | |
1253 return DELIVERY_OK; | |
1254 } | |
1255 } | |
1256 if (media_type == MediaType::VIDEO) { | |
1257 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | |
1258 // TODO(brandtr): Update here when FlexFEC supports protecting audio. | |
1259 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); | |
1260 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); | |
1261 if (it != flexfec_receive_ssrcs_protection_.end()) { | |
1262 it->second->OnRtpPacket(*parsed_packet); | |
1263 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | |
1264 return DELIVERY_OK; | |
1265 } | |
1266 } | |
1267 return DELIVERY_UNKNOWN_SSRC; | |
1268 } | 1168 } |
1269 | 1169 |
1270 PacketReceiver::DeliveryStatus Call::DeliverPacket( | 1170 PacketReceiver::DeliveryStatus Call::DeliverPacket( |
1271 MediaType media_type, | 1171 MediaType media_type, |
1272 const uint8_t* packet, | 1172 const uint8_t* packet, |
1273 size_t length, | 1173 size_t length, |
1274 const PacketTime& packet_time) { | 1174 const PacketTime& packet_time) { |
1275 // TODO(solenberg): Tests call this function on a network thread, libjingle | 1175 // TODO(solenberg): Tests call this function on a network thread, libjingle |
1276 // calls on the worker thread. We should move towards always using a network | 1176 // calls on the worker thread. We should move towards always using a network |
1277 // thread. Then this check can be enabled. | 1177 // thread. Then this check can be enabled. |
1278 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 1178 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
1279 if (RtpHeaderParser::IsRtcp(packet, length)) | 1179 if (RtpHeaderParser::IsRtcp(packet, length)) |
1280 return DeliverRtcp(media_type, packet, length); | 1180 return DeliverRtcp(media_type, packet, length); |
1281 | 1181 |
1282 return DeliverRtp(media_type, packet, length, packet_time); | 1182 return DeliverRtp(media_type, packet, length, packet_time); |
1283 } | 1183 } |
1284 | 1184 |
1285 // TODO(brandtr): Update this member function when we support protecting | 1185 // TODO(brandtr): Update this member function when we support protecting |
1286 // audio packets with FlexFEC. | 1186 // audio packets with FlexFEC. |
| 1187 |
| 1188 // TODO(nisse): Add a recovered flag to RtpParsedPacket, if needed for stats, |
| 1189 // and demux recovered packets in the same way as ordinary packets. |
1287 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { | 1190 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { |
1288 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1191 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
1289 ReadLockScoped read_lock(*receive_crit_); | 1192 ReadLockScoped read_lock(*receive_crit_); |
1290 auto it = video_receive_ssrcs_.find(ssrc); | 1193 auto it = video_receive_ssrcs_.find(ssrc); |
1291 if (it == video_receive_ssrcs_.end()) | 1194 if (it == video_receive_ssrcs_.end()) |
1292 return false; | 1195 return false; |
1293 return it->second->OnRecoveredPacket(packet, length); | 1196 return it->second->OnRecoveredPacket(packet, length); |
1294 } | 1197 } |
1295 | 1198 |
1296 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, | |
1297 MediaType media_type) { | |
1298 auto it = receive_rtp_config_.find(packet.Ssrc()); | |
1299 bool use_send_side_bwe = | |
1300 (it != receive_rtp_config_.end()) && it->second.use_send_side_bwe; | |
1301 | |
1302 RTPHeader header; | |
1303 packet.GetHeader(&header); | |
1304 | |
1305 if (!use_send_side_bwe && header.extension.hasTransportSequenceNumber) { | |
1306 // Inconsistent configuration of send side BWE. Do nothing. | |
1307 // TODO(nisse): Without this check, we may produce RTCP feedback | |
1308 // packets even when not negotiated. But it would be cleaner to | |
1309 // move the check down to RTCPSender::SendFeedbackPacket, which | |
1310 // would also help the PacketRouter to select an appropriate rtp | |
1311 // module in the case that some, but not all, have RTCP feedback | |
1312 // enabled. | |
1313 return; | |
1314 } | |
1315 // For audio, we only support send side BWE. | |
1316 if (media_type == MediaType::VIDEO || | |
1317 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { | |
1318 receive_side_cc_.OnReceivedPacket( | |
1319 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), | |
1320 header); | |
1321 } | |
1322 } | |
1323 | |
1324 } // namespace internal | 1199 } // namespace internal |
1325 | 1200 |
1326 } // namespace webrtc | 1201 } // namespace webrtc |
OLD | NEW |