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/config.h" | 37 #include "webrtc/config.h" |
37 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 38 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
38 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 39 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
39 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 40 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
40 #include "webrtc/modules/pacing/paced_sender.h" | 41 #include "webrtc/modules/pacing/paced_sender.h" |
41 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" | 42 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" |
42 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 43 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
43 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 44 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
44 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | 45 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
45 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | 46 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 86 |
86 bool UseSendSideBwe(const FlexfecReceiveStream::Config& config) { | 87 bool UseSendSideBwe(const FlexfecReceiveStream::Config& config) { |
87 return UseSendSideBwe(config.rtp_header_extensions, config.transport_cc); | 88 return UseSendSideBwe(config.rtp_header_extensions, config.transport_cc); |
88 } | 89 } |
89 | 90 |
90 } // namespace | 91 } // namespace |
91 | 92 |
92 namespace internal { | 93 namespace internal { |
93 | 94 |
94 class Call : public webrtc::Call, | 95 class Call : public webrtc::Call, |
| 96 public RtpPacketObserverInterface, |
95 public PacketReceiver, | 97 public PacketReceiver, |
96 public RecoveredPacketReceiver, | 98 public RecoveredPacketReceiver, |
97 public CongestionController::Observer, | 99 public CongestionController::Observer, |
98 public BitrateAllocator::LimitObserver { | 100 public BitrateAllocator::LimitObserver { |
99 public: | 101 public: |
100 explicit Call(const Call::Config& config); | 102 explicit Call(const Call::Config& config); |
101 virtual ~Call(); | 103 virtual ~Call(); |
102 | 104 |
103 // Implements webrtc::Call. | 105 // Implements webrtc::Call. |
104 PacketReceiver* Receiver() override; | 106 PacketReceiver* Receiver() override; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // Implements BitrateObserver. | 157 // Implements BitrateObserver. |
156 void OnNetworkChanged(uint32_t bitrate_bps, | 158 void OnNetworkChanged(uint32_t bitrate_bps, |
157 uint8_t fraction_loss, | 159 uint8_t fraction_loss, |
158 int64_t rtt_ms, | 160 int64_t rtt_ms, |
159 int64_t probing_interval_ms) override; | 161 int64_t probing_interval_ms) override; |
160 | 162 |
161 // Implements BitrateAllocator::LimitObserver. | 163 // Implements BitrateAllocator::LimitObserver. |
162 void OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps, | 164 void OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps, |
163 uint32_t max_padding_bitrate_bps) override; | 165 uint32_t max_padding_bitrate_bps) override; |
164 | 166 |
| 167 // Implements RtpPacketObserverInterface. |
| 168 void OnRtpPacket(MediaType media_type, |
| 169 const RtpTransportControllerReceiveInterface::Config config, |
| 170 const RtpPacketReceived& packet) override; |
| 171 |
165 private: | 172 private: |
166 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, | 173 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, |
167 size_t length); | 174 size_t length); |
168 DeliveryStatus DeliverRtp(MediaType media_type, | 175 DeliveryStatus DeliverRtp(MediaType media_type, |
169 const uint8_t* packet, | 176 const uint8_t* packet, |
170 size_t length, | 177 size_t length, |
171 const PacketTime& packet_time); | 178 const PacketTime& packet_time); |
172 void ConfigureSync(const std::string& sync_group) | 179 void ConfigureSync(const std::string& sync_group) |
173 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); | 180 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
174 | 181 |
175 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, | 182 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, |
176 MediaType media_type) | 183 MediaType media_type) |
177 SHARED_LOCKS_REQUIRED(receive_crit_); | 184 SHARED_LOCKS_REQUIRED(receive_crit_); |
178 | 185 |
179 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, | |
180 size_t length, | |
181 const PacketTime& packet_time) | |
182 SHARED_LOCKS_REQUIRED(receive_crit_); | |
183 | |
184 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); | 186 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); |
185 void UpdateReceiveHistograms(); | 187 void UpdateReceiveHistograms(); |
186 void UpdateHistograms(); | 188 void UpdateHistograms(); |
187 void UpdateAggregateNetworkState(); | 189 void UpdateAggregateNetworkState(); |
188 | 190 |
189 Clock* const clock_; | 191 Clock* const clock_; |
190 | 192 |
191 const int num_cpu_cores_; | 193 const int num_cpu_cores_; |
192 const std::unique_ptr<ProcessThread> module_process_thread_; | 194 const std::unique_ptr<ProcessThread> module_process_thread_; |
193 const std::unique_ptr<ProcessThread> pacer_thread_; | 195 const std::unique_ptr<ProcessThread> pacer_thread_; |
194 const std::unique_ptr<CallStats> call_stats_; | 196 const std::unique_ptr<CallStats> call_stats_; |
195 const std::unique_ptr<BitrateAllocator> bitrate_allocator_; | 197 const std::unique_ptr<BitrateAllocator> bitrate_allocator_; |
196 Call::Config config_; | 198 Call::Config config_; |
197 rtc::ThreadChecker configuration_thread_checker_; | 199 rtc::ThreadChecker configuration_thread_checker_; |
198 | 200 |
199 NetworkState audio_network_state_; | 201 NetworkState audio_network_state_; |
200 NetworkState video_network_state_; | 202 NetworkState video_network_state_; |
201 | 203 |
202 std::unique_ptr<RWLockWrapper> receive_crit_; | 204 std::unique_ptr<RWLockWrapper> receive_crit_; |
203 // Audio, Video, and FlexFEC receive streams are owned by the client that | 205 // Audio, Video, and FlexFEC receive streams are owned by the client that |
204 // creates them. | 206 // creates them. |
| 207 std::unique_ptr<RtpTransportControllerReceiveInterface> rtp_transport_receive_ |
| 208 GUARDED_BY(receive_crit_); |
| 209 |
| 210 // TODO(nisse): Try to eliminate these additional mappings. Two of |
| 211 // the users are DeliverRTCP and OnRecoveredPacket. |
205 std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_ | 212 std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_ |
206 GUARDED_BY(receive_crit_); | 213 GUARDED_BY(receive_crit_); |
207 std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_ | 214 std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_ |
208 GUARDED_BY(receive_crit_); | 215 GUARDED_BY(receive_crit_); |
209 std::set<VideoReceiveStream*> video_receive_streams_ | 216 std::set<VideoReceiveStream*> video_receive_streams_ |
210 GUARDED_BY(receive_crit_); | 217 GUARDED_BY(receive_crit_); |
211 // Each media stream could conceivably be protected by multiple FlexFEC | 218 |
212 // streams. | |
213 std::multimap<uint32_t, FlexfecReceiveStreamImpl*> | |
214 flexfec_receive_ssrcs_media_ GUARDED_BY(receive_crit_); | |
215 std::map<uint32_t, FlexfecReceiveStreamImpl*> | |
216 flexfec_receive_ssrcs_protection_ GUARDED_BY(receive_crit_); | |
217 std::set<FlexfecReceiveStreamImpl*> flexfec_receive_streams_ | |
218 GUARDED_BY(receive_crit_); | |
219 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ | 219 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ |
220 GUARDED_BY(receive_crit_); | 220 GUARDED_BY(receive_crit_); |
221 | 221 |
222 // This extra map is used for receive processing which is | |
223 // independent of media type. | |
224 | |
225 // TODO(nisse): In the RTP transport refactoring, we should have a | |
226 // single mapping from ssrc to a more abstract receive stream, with | |
227 // accessor methods for all configuration we need at this level. | |
228 struct ReceiveRtpConfig { | |
229 ReceiveRtpConfig() = default; // Needed by std::map | |
230 ReceiveRtpConfig(const std::vector<RtpExtension>& extensions, | |
231 bool use_send_side_bwe) | |
232 : extensions(extensions), use_send_side_bwe(use_send_side_bwe) {} | |
233 | |
234 // Registered RTP header extensions for each stream. Note that RTP header | |
235 // extensions are negotiated per track ("m= line") in the SDP, but we have | |
236 // no notion of tracks at the Call level. We therefore store the RTP header | |
237 // extensions per SSRC instead, which leads to some storage overhead. | |
238 RtpHeaderExtensionMap extensions; | |
239 // Set if both RTP extension the RTCP feedback message needed for | |
240 // send side BWE are negotiated. | |
241 bool use_send_side_bwe = false; | |
242 }; | |
243 std::map<uint32_t, ReceiveRtpConfig> receive_rtp_config_ | |
244 GUARDED_BY(receive_crit_); | |
245 | |
246 std::unique_ptr<RWLockWrapper> send_crit_; | 222 std::unique_ptr<RWLockWrapper> send_crit_; |
247 // Audio and Video send streams are owned by the client that creates them. | 223 // Audio and Video send streams are owned by the client that creates them. |
248 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); | 224 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); |
249 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); | 225 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
250 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); | 226 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
251 | 227 |
252 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; | 228 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; |
253 webrtc::RtcEventLog* event_log_; | 229 webrtc::RtcEventLog* event_log_; |
254 | 230 |
255 // The following members are only accessed (exclusively) from one thread and | 231 // The following members are only accessed (exclusively) from one thread and |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 : clock_(Clock::GetRealTimeClock()), | 286 : clock_(Clock::GetRealTimeClock()), |
311 num_cpu_cores_(CpuInfo::DetectNumberOfCores()), | 287 num_cpu_cores_(CpuInfo::DetectNumberOfCores()), |
312 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), | 288 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), |
313 pacer_thread_(ProcessThread::Create("PacerThread")), | 289 pacer_thread_(ProcessThread::Create("PacerThread")), |
314 call_stats_(new CallStats(clock_)), | 290 call_stats_(new CallStats(clock_)), |
315 bitrate_allocator_(new BitrateAllocator(this)), | 291 bitrate_allocator_(new BitrateAllocator(this)), |
316 config_(config), | 292 config_(config), |
317 audio_network_state_(kNetworkDown), | 293 audio_network_state_(kNetworkDown), |
318 video_network_state_(kNetworkDown), | 294 video_network_state_(kNetworkDown), |
319 receive_crit_(RWLockWrapper::CreateRWLock()), | 295 receive_crit_(RWLockWrapper::CreateRWLock()), |
| 296 rtp_transport_receive_( |
| 297 RtpTransportControllerReceiveInterface::Create(this)), |
320 send_crit_(RWLockWrapper::CreateRWLock()), | 298 send_crit_(RWLockWrapper::CreateRWLock()), |
321 event_log_(config.event_log), | 299 event_log_(config.event_log), |
322 first_packet_sent_ms_(-1), | 300 first_packet_sent_ms_(-1), |
323 received_bytes_per_second_counter_(clock_, nullptr, true), | 301 received_bytes_per_second_counter_(clock_, nullptr, true), |
324 received_audio_bytes_per_second_counter_(clock_, nullptr, true), | 302 received_audio_bytes_per_second_counter_(clock_, nullptr, true), |
325 received_video_bytes_per_second_counter_(clock_, nullptr, true), | 303 received_video_bytes_per_second_counter_(clock_, nullptr, true), |
326 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), | 304 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), |
327 min_allocated_send_bitrate_bps_(0), | 305 min_allocated_send_bitrate_bps_(0), |
328 configured_max_padding_bitrate_bps_(0), | 306 configured_max_padding_bitrate_bps_(0), |
329 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), | 307 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 pacer_thread_->Start(); | 343 pacer_thread_->Start(); |
366 } | 344 } |
367 | 345 |
368 Call::~Call() { | 346 Call::~Call() { |
369 RTC_DCHECK(!remb_.InUse()); | 347 RTC_DCHECK(!remb_.InUse()); |
370 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 348 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
371 | 349 |
372 RTC_CHECK(audio_send_ssrcs_.empty()); | 350 RTC_CHECK(audio_send_ssrcs_.empty()); |
373 RTC_CHECK(video_send_ssrcs_.empty()); | 351 RTC_CHECK(video_send_ssrcs_.empty()); |
374 RTC_CHECK(video_send_streams_.empty()); | 352 RTC_CHECK(video_send_streams_.empty()); |
375 RTC_CHECK(audio_receive_ssrcs_.empty()); | |
376 RTC_CHECK(video_receive_ssrcs_.empty()); | |
377 RTC_CHECK(video_receive_streams_.empty()); | |
378 | 353 |
379 pacer_thread_->Stop(); | 354 pacer_thread_->Stop(); |
380 pacer_thread_->DeRegisterModule(congestion_controller_->pacer()); | 355 pacer_thread_->DeRegisterModule(congestion_controller_->pacer()); |
381 pacer_thread_->DeRegisterModule( | 356 pacer_thread_->DeRegisterModule( |
382 congestion_controller_->GetRemoteBitrateEstimator(true)); | 357 congestion_controller_->GetRemoteBitrateEstimator(true)); |
383 module_process_thread_->DeRegisterModule(congestion_controller_.get()); | 358 module_process_thread_->DeRegisterModule(congestion_controller_.get()); |
384 module_process_thread_->DeRegisterModule(call_stats_.get()); | 359 module_process_thread_->DeRegisterModule(call_stats_.get()); |
385 module_process_thread_->Stop(); | 360 module_process_thread_->Stop(); |
386 call_stats_->DeregisterStatsObserver(congestion_controller_.get()); | 361 call_stats_->DeregisterStatsObserver(congestion_controller_.get()); |
387 | 362 |
388 // Only update histograms after process threads have been shut down, so that | 363 // Only update histograms after process threads have been shut down, so that |
389 // they won't try to concurrently update stats. | 364 // they won't try to concurrently update stats. |
390 { | 365 { |
391 rtc::CritScope lock(&bitrate_crit_); | 366 rtc::CritScope lock(&bitrate_crit_); |
392 UpdateSendHistograms(); | 367 UpdateSendHistograms(); |
393 } | 368 } |
394 UpdateReceiveHistograms(); | 369 UpdateReceiveHistograms(); |
395 UpdateHistograms(); | 370 UpdateHistograms(); |
396 | 371 |
397 Trace::ReturnTrace(); | 372 Trace::ReturnTrace(); |
398 } | 373 } |
399 | 374 |
400 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( | |
401 const uint8_t* packet, | |
402 size_t length, | |
403 const PacketTime& packet_time) { | |
404 RtpPacketReceived parsed_packet; | |
405 if (!parsed_packet.Parse(packet, length)) | |
406 return rtc::Optional<RtpPacketReceived>(); | |
407 | |
408 auto it = receive_rtp_config_.find(parsed_packet.Ssrc()); | |
409 if (it != receive_rtp_config_.end()) | |
410 parsed_packet.IdentifyExtensions(it->second.extensions); | |
411 | |
412 int64_t arrival_time_ms; | |
413 if (packet_time.timestamp != -1) { | |
414 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | |
415 } else { | |
416 arrival_time_ms = clock_->TimeInMilliseconds(); | |
417 } | |
418 parsed_packet.set_arrival_time_ms(arrival_time_ms); | |
419 | |
420 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); | |
421 } | |
422 | |
423 void Call::UpdateHistograms() { | 375 void Call::UpdateHistograms() { |
424 RTC_HISTOGRAM_COUNTS_100000( | 376 RTC_HISTOGRAM_COUNTS_100000( |
425 "WebRTC.Call.LifetimeInSeconds", | 377 "WebRTC.Call.LifetimeInSeconds", |
426 (clock_->TimeInMilliseconds() - start_ms_) / 1000); | 378 (clock_->TimeInMilliseconds() - start_ms_) / 1000); |
427 } | 379 } |
428 | 380 |
429 void Call::UpdateSendHistograms() { | 381 void Call::UpdateSendHistograms() { |
430 if (first_packet_sent_ms_ == -1) | 382 if (first_packet_sent_ms_ == -1) |
431 return; | 383 return; |
432 int64_t elapsed_sec = | 384 int64_t elapsed_sec = |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 } | 503 } |
552 | 504 |
553 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 505 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
554 const webrtc::AudioReceiveStream::Config& config) { | 506 const webrtc::AudioReceiveStream::Config& config) { |
555 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 507 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
556 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 508 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
557 event_log_->LogAudioReceiveStreamConfig(config); | 509 event_log_->LogAudioReceiveStreamConfig(config); |
558 AudioReceiveStream* receive_stream = new AudioReceiveStream( | 510 AudioReceiveStream* receive_stream = new AudioReceiveStream( |
559 &packet_router_, config, | 511 &packet_router_, config, |
560 config_.audio_state, event_log_); | 512 config_.audio_state, event_log_); |
| 513 |
| 514 RtpTransportControllerReceiveInterface::Config receive_config; |
| 515 receive_config.use_send_side_bwe = UseSendSideBwe(config); |
| 516 |
561 { | 517 { |
562 WriteLockScoped write_lock(*receive_crit_); | 518 WriteLockScoped write_lock(*receive_crit_); |
563 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 519 bool success = rtp_transport_receive_->AddReceiver( |
564 audio_receive_ssrcs_.end()); | 520 config.rtp.remote_ssrc, MediaType::AUDIO, receive_config, |
| 521 receive_stream); |
| 522 RTC_DCHECK(success); |
565 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 523 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
566 receive_rtp_config_[config.rtp.remote_ssrc] = | |
567 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config)); | |
568 | |
569 ConfigureSync(config.sync_group); | 524 ConfigureSync(config.sync_group); |
570 } | 525 } |
571 { | 526 { |
572 ReadLockScoped read_lock(*send_crit_); | 527 ReadLockScoped read_lock(*send_crit_); |
573 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); | 528 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); |
574 if (it != audio_send_ssrcs_.end()) { | 529 if (it != audio_send_ssrcs_.end()) { |
575 receive_stream->AssociateSendStream(it->second); | 530 receive_stream->AssociateSendStream(it->second); |
576 } | 531 } |
577 } | 532 } |
578 receive_stream->SignalNetworkState(audio_network_state_); | 533 receive_stream->SignalNetworkState(audio_network_state_); |
579 UpdateAggregateNetworkState(); | 534 UpdateAggregateNetworkState(); |
580 return receive_stream; | 535 return receive_stream; |
581 } | 536 } |
582 | 537 |
583 void Call::DestroyAudioReceiveStream( | 538 void Call::DestroyAudioReceiveStream( |
584 webrtc::AudioReceiveStream* receive_stream) { | 539 webrtc::AudioReceiveStream* receive_stream) { |
585 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); | 540 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); |
586 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 541 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
587 RTC_DCHECK(receive_stream != nullptr); | 542 RTC_DCHECK(receive_stream != nullptr); |
588 webrtc::internal::AudioReceiveStream* audio_receive_stream = | 543 webrtc::internal::AudioReceiveStream* audio_receive_stream = |
589 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); | 544 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); |
590 { | 545 { |
591 WriteLockScoped write_lock(*receive_crit_); | 546 WriteLockScoped write_lock(*receive_crit_); |
| 547 bool success = rtp_transport_receive_->RemoveReceiver(audio_receive_stream); |
| 548 RTC_DCHECK(success); |
| 549 |
592 const AudioReceiveStream::Config& config = audio_receive_stream->config(); | 550 const AudioReceiveStream::Config& config = audio_receive_stream->config(); |
593 uint32_t ssrc = config.rtp.remote_ssrc; | 551 uint32_t ssrc = config.rtp.remote_ssrc; |
594 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 552 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) |
595 ->RemoveStream(ssrc); | 553 ->RemoveStream(ssrc); |
596 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); | 554 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); |
597 RTC_DCHECK(num_deleted == 1); | 555 RTC_DCHECK(num_deleted == 1); |
598 const std::string& sync_group = audio_receive_stream->config().sync_group; | 556 const std::string& sync_group = audio_receive_stream->config().sync_group; |
599 const auto it = sync_stream_mapping_.find(sync_group); | 557 const auto it = sync_stream_mapping_.find(sync_group); |
600 if (it != sync_stream_mapping_.end() && | 558 if (it != sync_stream_mapping_.end() && |
601 it->second == audio_receive_stream) { | 559 it->second == audio_receive_stream) { |
602 sync_stream_mapping_.erase(it); | 560 sync_stream_mapping_.erase(it); |
603 ConfigureSync(sync_group); | 561 ConfigureSync(sync_group); |
604 } | 562 } |
605 receive_rtp_config_.erase(ssrc); | |
606 } | 563 } |
607 UpdateAggregateNetworkState(); | 564 UpdateAggregateNetworkState(); |
608 delete audio_receive_stream; | 565 delete audio_receive_stream; |
609 } | 566 } |
610 | 567 |
611 webrtc::VideoSendStream* Call::CreateVideoSendStream( | 568 webrtc::VideoSendStream* Call::CreateVideoSendStream( |
612 webrtc::VideoSendStream::Config config, | 569 webrtc::VideoSendStream::Config config, |
613 VideoEncoderConfig encoder_config) { | 570 VideoEncoderConfig encoder_config) { |
614 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); | 571 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); |
615 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 572 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 637 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
681 webrtc::VideoReceiveStream::Config configuration) { | 638 webrtc::VideoReceiveStream::Config configuration) { |
682 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 639 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
683 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 640 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
684 | 641 |
685 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 642 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
686 num_cpu_cores_, &packet_router_, std::move(configuration), | 643 num_cpu_cores_, &packet_router_, std::move(configuration), |
687 module_process_thread_.get(), call_stats_.get(), &remb_); | 644 module_process_thread_.get(), call_stats_.get(), &remb_); |
688 | 645 |
689 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 646 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
690 ReceiveRtpConfig receive_config(config.rtp.extensions, | 647 RtpTransportControllerReceiveInterface::Config receive_config; |
691 UseSendSideBwe(config)); | 648 receive_config.use_send_side_bwe = UseSendSideBwe(config); |
| 649 |
692 { | 650 { |
693 WriteLockScoped write_lock(*receive_crit_); | 651 WriteLockScoped write_lock(*receive_crit_); |
694 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 652 bool success = rtp_transport_receive_->AddReceiver( |
695 video_receive_ssrcs_.end()); | 653 config.rtp.remote_ssrc, MediaType::VIDEO, receive_config, |
696 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 654 receive_stream); |
| 655 RTC_DCHECK(success); |
697 if (config.rtp.rtx_ssrc) { | 656 if (config.rtp.rtx_ssrc) { |
698 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; | |
699 // We record identical config for the rtx stream as for the main | 657 // We record identical config for the rtx stream as for the main |
700 // stream. Since the transport_cc negotiation is per payload | 658 // stream. Since the transport_cc negotiation is per payload |
701 // type, we may get an incorrect value for the rtx stream, but | 659 // type, we may get an incorrect value for the rtx stream, but |
702 // that is unlikely to matter in practice. | 660 // that is unlikely to matter in practice. |
703 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config; | 661 bool success = rtp_transport_receive_->AddReceiver( |
| 662 config.rtp.remote_ssrc, MediaType::VIDEO, receive_config, |
| 663 receive_stream); |
| 664 |
| 665 RTC_DCHECK(success); |
704 } | 666 } |
705 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config; | |
706 video_receive_streams_.insert(receive_stream); | 667 video_receive_streams_.insert(receive_stream); |
707 ConfigureSync(config.sync_group); | 668 ConfigureSync(config.sync_group); |
708 } | 669 } |
709 receive_stream->SignalNetworkState(video_network_state_); | 670 receive_stream->SignalNetworkState(video_network_state_); |
710 UpdateAggregateNetworkState(); | 671 UpdateAggregateNetworkState(); |
711 event_log_->LogVideoReceiveStreamConfig(config); | 672 event_log_->LogVideoReceiveStreamConfig(config); |
712 return receive_stream; | 673 return receive_stream; |
713 } | 674 } |
714 | 675 |
715 void Call::DestroyVideoReceiveStream( | 676 void Call::DestroyVideoReceiveStream( |
716 webrtc::VideoReceiveStream* receive_stream) { | 677 webrtc::VideoReceiveStream* receive_stream) { |
717 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 678 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
718 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 679 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
719 RTC_DCHECK(receive_stream != nullptr); | 680 RTC_DCHECK(receive_stream != nullptr); |
720 VideoReceiveStream* receive_stream_impl = nullptr; | 681 VideoReceiveStream* receive_stream_impl = nullptr; |
721 { | 682 { |
722 WriteLockScoped write_lock(*receive_crit_); | 683 WriteLockScoped write_lock(*receive_crit_); |
723 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a | 684 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a |
724 // separate SSRC there can be either one or two. | 685 // separate SSRC there can be either one or two. |
725 auto it = video_receive_ssrcs_.begin(); | 686 auto it = video_receive_ssrcs_.begin(); |
726 while (it != video_receive_ssrcs_.end()) { | 687 while (it != video_receive_ssrcs_.end()) { |
727 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { | 688 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { |
728 if (receive_stream_impl != nullptr) | 689 if (receive_stream_impl != nullptr) |
729 RTC_DCHECK(receive_stream_impl == it->second); | 690 RTC_DCHECK(receive_stream_impl == it->second); |
730 receive_stream_impl = it->second; | 691 receive_stream_impl = it->second; |
731 receive_rtp_config_.erase(it->first); | |
732 it = video_receive_ssrcs_.erase(it); | 692 it = video_receive_ssrcs_.erase(it); |
733 } else { | 693 } else { |
734 ++it; | 694 ++it; |
735 } | 695 } |
736 } | 696 } |
737 video_receive_streams_.erase(receive_stream_impl); | 697 video_receive_streams_.erase(receive_stream_impl); |
738 RTC_CHECK(receive_stream_impl != nullptr); | 698 RTC_CHECK(receive_stream_impl != nullptr); |
739 ConfigureSync(receive_stream_impl->config().sync_group); | 699 ConfigureSync(receive_stream_impl->config().sync_group); |
| 700 rtp_transport_receive_->RemoveReceiver(receive_stream_impl); |
740 } | 701 } |
741 const VideoReceiveStream::Config& config = receive_stream_impl->config(); | 702 const VideoReceiveStream::Config& config = receive_stream_impl->config(); |
742 | 703 |
743 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 704 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) |
744 ->RemoveStream(config.rtp.remote_ssrc); | 705 ->RemoveStream(config.rtp.remote_ssrc); |
745 | 706 |
746 UpdateAggregateNetworkState(); | 707 UpdateAggregateNetworkState(); |
747 delete receive_stream_impl; | 708 delete receive_stream_impl; |
748 } | 709 } |
749 | 710 |
750 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( | 711 FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( |
751 const FlexfecReceiveStream::Config& config) { | 712 const FlexfecReceiveStream::Config& config) { |
752 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); | 713 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); |
753 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 714 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
754 | 715 |
755 RecoveredPacketReceiver* recovered_packet_receiver = this; | 716 RecoveredPacketReceiver* recovered_packet_receiver = this; |
756 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl( | 717 FlexfecReceiveStreamImpl* receive_stream = new FlexfecReceiveStreamImpl( |
757 config, recovered_packet_receiver, call_stats_->rtcp_rtt_stats(), | 718 config, recovered_packet_receiver, call_stats_->rtcp_rtt_stats(), |
758 module_process_thread_.get()); | 719 module_process_thread_.get()); |
759 | 720 |
760 { | 721 { |
761 WriteLockScoped write_lock(*receive_crit_); | 722 WriteLockScoped write_lock(*receive_crit_); |
| 723 rtp_transport_receive_->AddReceiver( |
| 724 config.remote_ssrc, MediaType::VIDEO, |
| 725 RtpTransportControllerReceiveInterface::Config(), receive_stream); |
762 | 726 |
763 RTC_DCHECK(flexfec_receive_streams_.find(receive_stream) == | 727 for (auto ssrc : config.protected_media_ssrcs) { |
764 flexfec_receive_streams_.end()); | 728 rtp_transport_receive_->AddSink(ssrc, MediaType::VIDEO, receive_stream); |
765 flexfec_receive_streams_.insert(receive_stream); | 729 } |
766 | |
767 for (auto ssrc : config.protected_media_ssrcs) | |
768 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); | |
769 | |
770 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == | |
771 flexfec_receive_ssrcs_protection_.end()); | |
772 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; | |
773 | |
774 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) == | |
775 receive_rtp_config_.end()); | |
776 receive_rtp_config_[config.remote_ssrc] = | |
777 ReceiveRtpConfig(config.rtp_header_extensions, UseSendSideBwe(config)); | |
778 } | 730 } |
779 | 731 |
780 // TODO(brandtr): Store config in RtcEventLog here. | 732 // TODO(brandtr): Store config in RtcEventLog here. |
781 | 733 |
782 return receive_stream; | 734 return receive_stream; |
783 } | 735 } |
784 | 736 |
785 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { | 737 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { |
786 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); | 738 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); |
787 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 739 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
788 | 740 |
789 RTC_DCHECK(receive_stream != nullptr); | 741 RTC_DCHECK(receive_stream != nullptr); |
790 // There exist no other derived classes of FlexfecReceiveStream, | 742 // There exist no other derived classes of FlexfecReceiveStream, |
791 // so this downcast is safe. | 743 // so this downcast is safe. |
792 FlexfecReceiveStreamImpl* receive_stream_impl = | 744 FlexfecReceiveStreamImpl* receive_stream_impl = |
793 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); | 745 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); |
794 { | 746 { |
795 WriteLockScoped write_lock(*receive_crit_); | 747 WriteLockScoped write_lock(*receive_crit_); |
796 | 748 rtp_transport_receive_->RemoveSink(receive_stream_impl); |
| 749 rtp_transport_receive_->RemoveReceiver(receive_stream_impl); |
797 const FlexfecReceiveStream::Config& config = | 750 const FlexfecReceiveStream::Config& config = |
798 receive_stream_impl->GetConfig(); | 751 receive_stream_impl->GetConfig(); |
799 uint32_t ssrc = config.remote_ssrc; | 752 uint32_t ssrc = config.remote_ssrc; |
800 receive_rtp_config_.erase(ssrc); | |
801 | |
802 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be | |
803 // destroyed. | |
804 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); | |
805 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { | |
806 if (prot_it->second == receive_stream_impl) | |
807 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); | |
808 else | |
809 ++prot_it; | |
810 } | |
811 auto media_it = flexfec_receive_ssrcs_media_.begin(); | |
812 while (media_it != flexfec_receive_ssrcs_media_.end()) { | |
813 if (media_it->second == receive_stream_impl) | |
814 media_it = flexfec_receive_ssrcs_media_.erase(media_it); | |
815 else | |
816 ++media_it; | |
817 } | |
818 | 753 |
819 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) | 754 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config)) |
820 ->RemoveStream(ssrc); | 755 ->RemoveStream(ssrc); |
821 | |
822 flexfec_receive_streams_.erase(receive_stream_impl); | |
823 } | 756 } |
824 | 757 |
825 delete receive_stream_impl; | 758 delete receive_stream_impl; |
826 } | 759 } |
827 | 760 |
828 Call::Stats Call::GetStats() const { | 761 Call::Stats Call::GetStats() const { |
829 // TODO(solenberg): Some test cases in EndToEndTest use this from a different | 762 // TODO(solenberg): Some test cases in EndToEndTest use this from a different |
830 // thread. Re-enable once that is fixed. | 763 // thread. Re-enable once that is fixed. |
831 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 764 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
832 Stats stats; | 765 Stats stats; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 | 1100 |
1168 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; | 1101 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; |
1169 } | 1102 } |
1170 | 1103 |
1171 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, | 1104 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, |
1172 const uint8_t* packet, | 1105 const uint8_t* packet, |
1173 size_t length, | 1106 size_t length, |
1174 const PacketTime& packet_time) { | 1107 const PacketTime& packet_time) { |
1175 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); | 1108 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); |
1176 | 1109 |
| 1110 int64_t arrival_time_ms; |
| 1111 if (packet_time.timestamp != -1) { |
| 1112 arrival_time_ms = (packet_time.timestamp + 500) / 1000; |
| 1113 } else { |
| 1114 arrival_time_ms = clock_->TimeInMilliseconds(); |
| 1115 } |
| 1116 |
1177 ReadLockScoped read_lock(*receive_crit_); | 1117 ReadLockScoped read_lock(*receive_crit_); |
1178 // TODO(nisse): We should parse the RTP header only here, and pass | |
1179 // on parsed_packet to the receive streams. | |
1180 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1181 ParseRtpPacket(packet, length, packet_time); | |
1182 | 1118 |
1183 if (!parsed_packet) | 1119 return rtp_transport_receive_->OnRtpPacket( |
1184 return DELIVERY_PACKET_ERROR; | 1120 media_type, arrival_time_ms, |
1185 | 1121 rtc::ArrayView<const uint8_t>(packet, length)); |
1186 NotifyBweOfReceivedPacket(*parsed_packet, media_type); | |
1187 | |
1188 uint32_t ssrc = parsed_packet->Ssrc(); | |
1189 | |
1190 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { | |
1191 auto it = audio_receive_ssrcs_.find(ssrc); | |
1192 if (it != audio_receive_ssrcs_.end()) { | |
1193 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | |
1194 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); | |
1195 it->second->OnRtpPacket(*parsed_packet); | |
1196 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | |
1197 return DELIVERY_OK; | |
1198 } | |
1199 } | |
1200 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | |
1201 auto it = video_receive_ssrcs_.find(ssrc); | |
1202 if (it != video_receive_ssrcs_.end()) { | |
1203 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | |
1204 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); | |
1205 it->second->OnRtpPacket(*parsed_packet); | |
1206 | |
1207 // Deliver media packets to FlexFEC subsystem. | |
1208 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); | |
1209 for (auto it = it_bounds.first; it != it_bounds.second; ++it) | |
1210 it->second->OnRtpPacket(*parsed_packet); | |
1211 | |
1212 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | |
1213 return DELIVERY_OK; | |
1214 } | |
1215 } | |
1216 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | |
1217 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | |
1218 // TODO(brandtr): Update here when FlexFEC supports protecting audio. | |
1219 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); | |
1220 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); | |
1221 if (it != flexfec_receive_ssrcs_protection_.end()) { | |
1222 it->second->OnRtpPacket(*parsed_packet); | |
1223 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | |
1224 return DELIVERY_OK; | |
1225 } | |
1226 } | |
1227 return DELIVERY_UNKNOWN_SSRC; | |
1228 } | 1122 } |
1229 | 1123 |
1230 PacketReceiver::DeliveryStatus Call::DeliverPacket( | 1124 PacketReceiver::DeliveryStatus Call::DeliverPacket( |
1231 MediaType media_type, | 1125 MediaType media_type, |
1232 const uint8_t* packet, | 1126 const uint8_t* packet, |
1233 size_t length, | 1127 size_t length, |
1234 const PacketTime& packet_time) { | 1128 const PacketTime& packet_time) { |
1235 // TODO(solenberg): Tests call this function on a network thread, libjingle | 1129 // TODO(solenberg): Tests call this function on a network thread, libjingle |
1236 // calls on the worker thread. We should move towards always using a network | 1130 // calls on the worker thread. We should move towards always using a network |
1237 // thread. Then this check can be enabled. | 1131 // thread. Then this check can be enabled. |
1238 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 1132 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
1239 if (RtpHeaderParser::IsRtcp(packet, length)) | 1133 if (RtpHeaderParser::IsRtcp(packet, length)) |
1240 return DeliverRtcp(media_type, packet, length); | 1134 return DeliverRtcp(media_type, packet, length); |
1241 | 1135 |
1242 return DeliverRtp(media_type, packet, length, packet_time); | 1136 return DeliverRtp(media_type, packet, length, packet_time); |
1243 } | 1137 } |
1244 | 1138 |
1245 // TODO(brandtr): Update this member function when we support protecting | 1139 // TODO(brandtr): Update this member function when we support protecting |
1246 // audio packets with FlexFEC. | 1140 // audio packets with FlexFEC. |
| 1141 |
| 1142 // TODO(nisse): Add a recovered flag to RtpParsedPacket, if needed for stats, |
| 1143 // and demux recovered packets in the same way as ordinary packets. |
1247 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { | 1144 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { |
1248 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1145 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
1249 ReadLockScoped read_lock(*receive_crit_); | 1146 ReadLockScoped read_lock(*receive_crit_); |
1250 auto it = video_receive_ssrcs_.find(ssrc); | 1147 auto it = video_receive_ssrcs_.find(ssrc); |
1251 if (it == video_receive_ssrcs_.end()) | 1148 if (it == video_receive_ssrcs_.end()) |
1252 return false; | 1149 return false; |
1253 return it->second->OnRecoveredPacket(packet, length); | 1150 return it->second->OnRecoveredPacket(packet, length); |
1254 } | 1151 } |
1255 | 1152 |
1256 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, | 1153 void Call::OnRtpPacket( |
1257 MediaType media_type) { | 1154 MediaType media_type, |
1258 auto it = receive_rtp_config_.find(packet.Ssrc()); | 1155 const RtpTransportControllerReceiveInterface::Config config, |
1259 bool use_send_side_bwe = | 1156 const RtpPacketReceived& packet) { |
1260 (it != receive_rtp_config_.end()) && it->second.use_send_side_bwe; | |
1261 | |
1262 RTPHeader header; | 1157 RTPHeader header; |
1263 packet.GetHeader(&header); | 1158 packet.GetHeader(&header); |
1264 | 1159 |
1265 if (!use_send_side_bwe && header.extension.hasTransportSequenceNumber) { | 1160 if (!config.use_send_side_bwe && |
| 1161 header.extension.hasTransportSequenceNumber) { |
1266 // Inconsistent configuration of send side BWE. Do nothing. | 1162 // Inconsistent configuration of send side BWE. Do nothing. |
1267 // TODO(nisse): Without this check, we may produce RTCP feedback | 1163 // TODO(nisse): Without this check, we may produce RTCP feedback |
1268 // packets even when not negotiated. But it would be cleaner to | 1164 // packets even when not negotiated. But it would be cleaner to |
1269 // move the check down to RTCPSender::SendFeedbackPacket, which | 1165 // move the check down to RTCPSender::SendFeedbackPacket, which |
1270 // would also help the PacketRouter to select an appropriate rtp | 1166 // would also help the PacketRouter to select an appropriate rtp |
1271 // module in the case that some, but not all, have RTCP feedback | 1167 // module in the case that some, but not all, have RTCP feedback |
1272 // enabled. | 1168 // enabled. |
1273 return; | 1169 return; |
1274 } | 1170 } |
1275 // For audio, we only support send side BWE. | 1171 // For audio, we only support send side BWE. |
1276 // TODO(nisse): Tests passes MediaType::ANY, see | 1172 // TODO(nisse): Tests passes MediaType::ANY, see |
1277 // FakeNetworkPipe::Process. We need to treat that as video. Tests | 1173 // FakeNetworkPipe::Process. We need to treat that as video. Tests |
1278 // should be fixed to use the same MediaType as the production code. | 1174 // should be fixed to use the same MediaType as the production code. |
1279 if (media_type != MediaType::AUDIO || | 1175 if (media_type != MediaType::AUDIO || |
1280 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { | 1176 (config.use_send_side_bwe && |
| 1177 header.extension.hasTransportSequenceNumber)) { |
1281 congestion_controller_->OnReceivedPacket( | 1178 congestion_controller_->OnReceivedPacket( |
1282 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), | 1179 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), |
1283 header); | 1180 header); |
1284 } | 1181 } |
1285 } | 1182 } |
1286 | 1183 |
1287 } // namespace internal | 1184 } // namespace internal |
1288 } // namespace webrtc | 1185 } // namespace webrtc |
OLD | NEW |