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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 | 102 |
103 // Implements PacketReceiver. | 103 // Implements PacketReceiver. |
104 DeliveryStatus DeliverPacket(MediaType media_type, | 104 DeliveryStatus DeliverPacket(MediaType media_type, |
105 const uint8_t* packet, | 105 const uint8_t* packet, |
106 size_t length, | 106 size_t length, |
107 const PacketTime& packet_time) override; | 107 const PacketTime& packet_time) override; |
108 | 108 |
109 // Implements RecoveredPacketReceiver. | 109 // Implements RecoveredPacketReceiver. |
110 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; | 110 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; |
111 | 111 |
112 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet); | |
113 | |
114 void SetBitrateConfig( | 112 void SetBitrateConfig( |
115 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; | 113 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; |
116 | 114 |
117 void SignalChannelNetworkState(MediaType media, NetworkState state) override; | 115 void SignalChannelNetworkState(MediaType media, NetworkState state) override; |
118 | 116 |
119 void OnTransportOverheadChanged(MediaType media, | 117 void OnTransportOverheadChanged(MediaType media, |
120 int transport_overhead_per_packet) override; | 118 int transport_overhead_per_packet) override; |
121 | 119 |
122 void OnNetworkRouteChanged(const std::string& transport_name, | 120 void OnNetworkRouteChanged(const std::string& transport_name, |
123 const rtc::NetworkRoute& network_route) override; | 121 const rtc::NetworkRoute& network_route) override; |
(...skipping 14 matching lines...) Expand all Loading... | |
138 private: | 136 private: |
139 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, | 137 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, |
140 size_t length); | 138 size_t length); |
141 DeliveryStatus DeliverRtp(MediaType media_type, | 139 DeliveryStatus DeliverRtp(MediaType media_type, |
142 const uint8_t* packet, | 140 const uint8_t* packet, |
143 size_t length, | 141 size_t length, |
144 const PacketTime& packet_time); | 142 const PacketTime& packet_time); |
145 void ConfigureSync(const std::string& sync_group) | 143 void ConfigureSync(const std::string& sync_group) |
146 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); | 144 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
147 | 145 |
146 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, | |
147 MediaType media_type) | |
148 SHARED_LOCKS_REQUIRED(receive_crit_); | |
149 | |
148 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, | 150 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, |
149 size_t length, | 151 size_t length, |
150 const PacketTime& packet_time) | 152 const PacketTime& packet_time) |
151 SHARED_LOCKS_REQUIRED(receive_crit_); | 153 SHARED_LOCKS_REQUIRED(receive_crit_); |
152 | 154 |
153 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); | 155 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); |
154 void UpdateReceiveHistograms(); | 156 void UpdateReceiveHistograms(); |
155 void UpdateHistograms(); | 157 void UpdateHistograms(); |
156 void UpdateAggregateNetworkState(); | 158 void UpdateAggregateNetworkState(); |
157 | 159 |
(...skipping 23 matching lines...) Expand all Loading... | |
181 // streams. | 183 // streams. |
182 std::multimap<uint32_t, FlexfecReceiveStreamImpl*> | 184 std::multimap<uint32_t, FlexfecReceiveStreamImpl*> |
183 flexfec_receive_ssrcs_media_ GUARDED_BY(receive_crit_); | 185 flexfec_receive_ssrcs_media_ GUARDED_BY(receive_crit_); |
184 std::map<uint32_t, FlexfecReceiveStreamImpl*> | 186 std::map<uint32_t, FlexfecReceiveStreamImpl*> |
185 flexfec_receive_ssrcs_protection_ GUARDED_BY(receive_crit_); | 187 flexfec_receive_ssrcs_protection_ GUARDED_BY(receive_crit_); |
186 std::set<FlexfecReceiveStreamImpl*> flexfec_receive_streams_ | 188 std::set<FlexfecReceiveStreamImpl*> flexfec_receive_streams_ |
187 GUARDED_BY(receive_crit_); | 189 GUARDED_BY(receive_crit_); |
188 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ | 190 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ |
189 GUARDED_BY(receive_crit_); | 191 GUARDED_BY(receive_crit_); |
190 | 192 |
191 // Registered RTP header extensions for each stream. | 193 // This extra map is used for receive processing which is |
192 // Note that RTP header extensions are negotiated per track ("m= line") in the | 194 // independent of media type. |
193 // SDP, but we have no notion of tracks at the Call level. We therefore store | 195 |
194 // the RTP header extensions per SSRC instead, which leads to some storage | 196 // TODO(nisse): In the RTP transport refactoring, we should have a |
195 // overhead. | 197 // single mapping from ssrc to a more abstract receive stream, with |
196 std::map<uint32_t, RtpHeaderExtensionMap> received_rtp_header_extensions_ | 198 // accessor methods for all configuration we need at this level. |
199 struct ReceiveRtpConfig { | |
200 ReceiveRtpConfig() = default; // Needed by std::map | |
201 ReceiveRtpConfig(const std::vector<RtpExtension>& extensions, | |
202 bool transport_cc) | |
203 : extensions(extensions), transport_cc(transport_cc) {} | |
204 | |
205 // Registered RTP header extensions for each stream. Note that RTP header | |
206 // extensions are negotiated per track ("m= line") in the SDP, but we have | |
207 // no notion of tracks at the Call level. We therefore store the RTP header | |
208 // extensions per SSRC instead, which leads to some storage overhead. | |
209 RtpHeaderExtensionMap extensions; | |
210 // Set if the RTCP feedback message needed for send side BWE was negotiated. | |
211 bool transport_cc; | |
212 }; | |
213 std::map<uint32_t, ReceiveRtpConfig> receive_rtp_config_ | |
197 GUARDED_BY(receive_crit_); | 214 GUARDED_BY(receive_crit_); |
198 | 215 |
199 std::unique_ptr<RWLockWrapper> send_crit_; | 216 std::unique_ptr<RWLockWrapper> send_crit_; |
200 // Audio and Video send streams are owned by the client that creates them. | 217 // Audio and Video send streams are owned by the client that creates them. |
201 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); | 218 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); |
202 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); | 219 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
203 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); | 220 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
204 | 221 |
205 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; | 222 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; |
206 webrtc::RtcEventLog* event_log_; | 223 webrtc::RtcEventLog* event_log_; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 } | 367 } |
351 | 368 |
352 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( | 369 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( |
353 const uint8_t* packet, | 370 const uint8_t* packet, |
354 size_t length, | 371 size_t length, |
355 const PacketTime& packet_time) { | 372 const PacketTime& packet_time) { |
356 RtpPacketReceived parsed_packet; | 373 RtpPacketReceived parsed_packet; |
357 if (!parsed_packet.Parse(packet, length)) | 374 if (!parsed_packet.Parse(packet, length)) |
358 return rtc::Optional<RtpPacketReceived>(); | 375 return rtc::Optional<RtpPacketReceived>(); |
359 | 376 |
360 auto it = received_rtp_header_extensions_.find(parsed_packet.Ssrc()); | 377 auto it = receive_rtp_config_.find(parsed_packet.Ssrc()); |
361 if (it != received_rtp_header_extensions_.end()) | 378 if (it != receive_rtp_config_.end()) |
362 parsed_packet.IdentifyExtensions(it->second); | 379 parsed_packet.IdentifyExtensions(it->second.extensions); |
363 | 380 |
364 int64_t arrival_time_ms; | 381 int64_t arrival_time_ms; |
365 if (packet_time.timestamp != -1) { | 382 if (packet_time.timestamp != -1) { |
366 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | 383 arrival_time_ms = (packet_time.timestamp + 500) / 1000; |
367 } else { | 384 } else { |
368 arrival_time_ms = clock_->TimeInMilliseconds(); | 385 arrival_time_ms = clock_->TimeInMilliseconds(); |
369 } | 386 } |
370 parsed_packet.set_arrival_time_ms(arrival_time_ms); | 387 parsed_packet.set_arrival_time_ms(arrival_time_ms); |
371 | 388 |
372 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); | 389 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 delete audio_send_stream; | 519 delete audio_send_stream; |
503 } | 520 } |
504 | 521 |
505 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 522 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
506 const webrtc::AudioReceiveStream::Config& config) { | 523 const webrtc::AudioReceiveStream::Config& config) { |
507 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 524 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
508 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 525 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
509 event_log_->LogAudioReceiveStreamConfig(config); | 526 event_log_->LogAudioReceiveStreamConfig(config); |
510 AudioReceiveStream* receive_stream = new AudioReceiveStream( | 527 AudioReceiveStream* receive_stream = new AudioReceiveStream( |
511 &packet_router_, | 528 &packet_router_, |
512 // TODO(nisse): Used only when UseSendSideBwe(config) is true. | |
513 congestion_controller_->GetRemoteBitrateEstimator(true), config, | 529 congestion_controller_->GetRemoteBitrateEstimator(true), config, |
514 config_.audio_state, event_log_); | 530 config_.audio_state, event_log_); |
515 { | 531 { |
516 WriteLockScoped write_lock(*receive_crit_); | 532 WriteLockScoped write_lock(*receive_crit_); |
517 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 533 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
518 audio_receive_ssrcs_.end()); | 534 audio_receive_ssrcs_.end()); |
519 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 535 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
536 receive_rtp_config_[config.rtp.remote_ssrc] = | |
537 ReceiveRtpConfig(config.rtp.extensions, config.rtp.transport_cc); | |
538 | |
520 ConfigureSync(config.sync_group); | 539 ConfigureSync(config.sync_group); |
521 } | 540 } |
522 { | 541 { |
523 ReadLockScoped read_lock(*send_crit_); | 542 ReadLockScoped read_lock(*send_crit_); |
524 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); | 543 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); |
525 if (it != audio_send_ssrcs_.end()) { | 544 if (it != audio_send_ssrcs_.end()) { |
526 receive_stream->AssociateSendStream(it->second); | 545 receive_stream->AssociateSendStream(it->second); |
527 } | 546 } |
528 } | 547 } |
529 receive_stream->SignalNetworkState(audio_network_state_); | 548 receive_stream->SignalNetworkState(audio_network_state_); |
530 UpdateAggregateNetworkState(); | 549 UpdateAggregateNetworkState(); |
531 return receive_stream; | 550 return receive_stream; |
532 } | 551 } |
533 | 552 |
534 void Call::DestroyAudioReceiveStream( | 553 void Call::DestroyAudioReceiveStream( |
535 webrtc::AudioReceiveStream* receive_stream) { | 554 webrtc::AudioReceiveStream* receive_stream) { |
536 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); | 555 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); |
537 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 556 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
538 RTC_DCHECK(receive_stream != nullptr); | 557 RTC_DCHECK(receive_stream != nullptr); |
539 webrtc::internal::AudioReceiveStream* audio_receive_stream = | 558 webrtc::internal::AudioReceiveStream* audio_receive_stream = |
540 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); | 559 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); |
541 { | 560 { |
542 WriteLockScoped write_lock(*receive_crit_); | 561 WriteLockScoped write_lock(*receive_crit_); |
543 size_t num_deleted = audio_receive_ssrcs_.erase( | 562 uint32_t ssrc = audio_receive_stream->config().rtp.remote_ssrc; |
544 audio_receive_stream->config().rtp.remote_ssrc); | 563 |
564 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); | |
545 RTC_DCHECK(num_deleted == 1); | 565 RTC_DCHECK(num_deleted == 1); |
546 const std::string& sync_group = audio_receive_stream->config().sync_group; | 566 const std::string& sync_group = audio_receive_stream->config().sync_group; |
547 const auto it = sync_stream_mapping_.find(sync_group); | 567 const auto it = sync_stream_mapping_.find(sync_group); |
548 if (it != sync_stream_mapping_.end() && | 568 if (it != sync_stream_mapping_.end() && |
549 it->second == audio_receive_stream) { | 569 it->second == audio_receive_stream) { |
550 sync_stream_mapping_.erase(it); | 570 sync_stream_mapping_.erase(it); |
551 ConfigureSync(sync_group); | 571 ConfigureSync(sync_group); |
552 } | 572 } |
573 receive_rtp_config_.erase(ssrc); | |
553 } | 574 } |
554 UpdateAggregateNetworkState(); | 575 UpdateAggregateNetworkState(); |
555 delete audio_receive_stream; | 576 delete audio_receive_stream; |
556 } | 577 } |
557 | 578 |
558 webrtc::VideoSendStream* Call::CreateVideoSendStream( | 579 webrtc::VideoSendStream* Call::CreateVideoSendStream( |
559 webrtc::VideoSendStream::Config config, | 580 webrtc::VideoSendStream::Config config, |
560 VideoEncoderConfig encoder_config) { | 581 VideoEncoderConfig encoder_config) { |
561 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); | 582 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); |
562 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 583 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 protected_by_flexfec = | 656 protected_by_flexfec = |
636 flexfec_receive_ssrcs_media_.find(configuration.rtp.remote_ssrc) != | 657 flexfec_receive_ssrcs_media_.find(configuration.rtp.remote_ssrc) != |
637 flexfec_receive_ssrcs_media_.end(); | 658 flexfec_receive_ssrcs_media_.end(); |
638 } | 659 } |
639 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 660 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
640 num_cpu_cores_, protected_by_flexfec, congestion_controller_.get(), | 661 num_cpu_cores_, protected_by_flexfec, congestion_controller_.get(), |
641 &packet_router_, std::move(configuration), module_process_thread_.get(), | 662 &packet_router_, std::move(configuration), module_process_thread_.get(), |
642 call_stats_.get(), &remb_); | 663 call_stats_.get(), &remb_); |
643 | 664 |
644 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 665 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
666 ReceiveRtpConfig receive_config(config.rtp.extensions, | |
667 config.rtp.transport_cc); | |
645 { | 668 { |
646 WriteLockScoped write_lock(*receive_crit_); | 669 WriteLockScoped write_lock(*receive_crit_); |
647 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 670 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
648 video_receive_ssrcs_.end()); | 671 video_receive_ssrcs_.end()); |
649 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 672 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
650 if (config.rtp.rtx_ssrc) | 673 if (config.rtp.rtx_ssrc) { |
651 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; | 674 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; |
675 // We record identical config for the rtx stream as for the main | |
676 // stream. Since the transport_cc negotiation is per payload | |
677 // type, we may get an incorrect value for the rtx stream, but | |
678 // that is unlikely to matter in practice. | |
679 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config; | |
680 } | |
681 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config; | |
652 video_receive_streams_.insert(receive_stream); | 682 video_receive_streams_.insert(receive_stream); |
653 ConfigureSync(config.sync_group); | 683 ConfigureSync(config.sync_group); |
654 } | 684 } |
655 receive_stream->SignalNetworkState(video_network_state_); | 685 receive_stream->SignalNetworkState(video_network_state_); |
656 UpdateAggregateNetworkState(); | 686 UpdateAggregateNetworkState(); |
657 event_log_->LogVideoReceiveStreamConfig(config); | 687 event_log_->LogVideoReceiveStreamConfig(config); |
658 return receive_stream; | 688 return receive_stream; |
659 } | 689 } |
660 | 690 |
661 void Call::DestroyVideoReceiveStream( | 691 void Call::DestroyVideoReceiveStream( |
662 webrtc::VideoReceiveStream* receive_stream) { | 692 webrtc::VideoReceiveStream* receive_stream) { |
663 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 693 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
664 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 694 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
665 RTC_DCHECK(receive_stream != nullptr); | 695 RTC_DCHECK(receive_stream != nullptr); |
666 VideoReceiveStream* receive_stream_impl = nullptr; | 696 VideoReceiveStream* receive_stream_impl = nullptr; |
667 { | 697 { |
668 WriteLockScoped write_lock(*receive_crit_); | 698 WriteLockScoped write_lock(*receive_crit_); |
669 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a | 699 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a |
670 // separate SSRC there can be either one or two. | 700 // separate SSRC there can be either one or two. |
671 auto it = video_receive_ssrcs_.begin(); | 701 auto it = video_receive_ssrcs_.begin(); |
672 while (it != video_receive_ssrcs_.end()) { | 702 while (it != video_receive_ssrcs_.end()) { |
673 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { | 703 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { |
674 if (receive_stream_impl != nullptr) | 704 if (receive_stream_impl != nullptr) |
675 RTC_DCHECK(receive_stream_impl == it->second); | 705 RTC_DCHECK(receive_stream_impl == it->second); |
676 receive_stream_impl = it->second; | 706 receive_stream_impl = it->second; |
677 video_receive_ssrcs_.erase(it++); | 707 receive_rtp_config_.erase(it->first); |
708 it = video_receive_ssrcs_.erase(it); | |
678 } else { | 709 } else { |
679 ++it; | 710 ++it; |
680 } | 711 } |
681 } | 712 } |
682 video_receive_streams_.erase(receive_stream_impl); | 713 video_receive_streams_.erase(receive_stream_impl); |
683 RTC_CHECK(receive_stream_impl != nullptr); | 714 RTC_CHECK(receive_stream_impl != nullptr); |
684 ConfigureSync(receive_stream_impl->config().sync_group); | 715 ConfigureSync(receive_stream_impl->config().sync_group); |
685 } | 716 } |
686 UpdateAggregateNetworkState(); | 717 UpdateAggregateNetworkState(); |
687 delete receive_stream_impl; | 718 delete receive_stream_impl; |
(...skipping 16 matching lines...) Expand all Loading... | |
704 flexfec_receive_streams_.end()); | 735 flexfec_receive_streams_.end()); |
705 flexfec_receive_streams_.insert(receive_stream); | 736 flexfec_receive_streams_.insert(receive_stream); |
706 | 737 |
707 for (auto ssrc : config.protected_media_ssrcs) | 738 for (auto ssrc : config.protected_media_ssrcs) |
708 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); | 739 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); |
709 | 740 |
710 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == | 741 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == |
711 flexfec_receive_ssrcs_protection_.end()); | 742 flexfec_receive_ssrcs_protection_.end()); |
712 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; | 743 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; |
713 | 744 |
714 RTC_DCHECK(received_rtp_header_extensions_.find(config.remote_ssrc) == | 745 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) == |
715 received_rtp_header_extensions_.end()); | 746 receive_rtp_config_.end()); |
716 RtpHeaderExtensionMap rtp_header_extensions(config.rtp_header_extensions); | 747 receive_rtp_config_[config.remote_ssrc] = |
717 received_rtp_header_extensions_[config.remote_ssrc] = rtp_header_extensions; | 748 ReceiveRtpConfig(config.rtp_header_extensions, config.transport_cc); |
718 } | 749 } |
719 | 750 |
720 // TODO(brandtr): Store config in RtcEventLog here. | 751 // TODO(brandtr): Store config in RtcEventLog here. |
721 | 752 |
722 return receive_stream; | 753 return receive_stream; |
723 } | 754 } |
724 | 755 |
725 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { | 756 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { |
726 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); | 757 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); |
727 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 758 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
728 | 759 |
729 RTC_DCHECK(receive_stream != nullptr); | 760 RTC_DCHECK(receive_stream != nullptr); |
730 // There exist no other derived classes of FlexfecReceiveStream, | 761 // There exist no other derived classes of FlexfecReceiveStream, |
731 // so this downcast is safe. | 762 // so this downcast is safe. |
732 FlexfecReceiveStreamImpl* receive_stream_impl = | 763 FlexfecReceiveStreamImpl* receive_stream_impl = |
733 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); | 764 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); |
734 { | 765 { |
735 WriteLockScoped write_lock(*receive_crit_); | 766 WriteLockScoped write_lock(*receive_crit_); |
736 | 767 |
737 uint32_t ssrc = receive_stream_impl->GetConfig().remote_ssrc; | 768 uint32_t ssrc = receive_stream_impl->GetConfig().remote_ssrc; |
738 received_rtp_header_extensions_.erase(ssrc); | 769 receive_rtp_config_.erase(ssrc); |
739 | 770 |
740 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be | 771 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be |
741 // destroyed. | 772 // destroyed. |
742 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); | 773 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); |
743 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { | 774 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { |
744 if (prot_it->second == receive_stream_impl) | 775 if (prot_it->second == receive_stream_impl) |
745 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); | 776 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); |
746 else | 777 else |
747 ++prot_it; | 778 ++prot_it; |
748 } | 779 } |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1101 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length); | 1132 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length); |
1102 | 1133 |
1103 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; | 1134 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; |
1104 } | 1135 } |
1105 | 1136 |
1106 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, | 1137 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, |
1107 const uint8_t* packet, | 1138 const uint8_t* packet, |
1108 size_t length, | 1139 size_t length, |
1109 const PacketTime& packet_time) { | 1140 const PacketTime& packet_time) { |
1110 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); | 1141 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); |
1111 // Minimum RTP header size. | 1142 |
1112 if (length < 12) | 1143 ReadLockScoped read_lock(*receive_crit_); |
1144 // TODO(nisse): We should parse the RTP header only here, and pass | |
1145 // on parsed_packet to the receive streams. | |
1146 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1147 ParseRtpPacket(packet, length, packet_time); | |
1148 | |
1149 if (!parsed_packet) | |
1113 return DELIVERY_PACKET_ERROR; | 1150 return DELIVERY_PACKET_ERROR; |
1114 | 1151 |
1115 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1152 NotifyBweOfReceivedPacket(*parsed_packet, media_type); |
1116 ReadLockScoped read_lock(*receive_crit_); | 1153 |
1154 uint32_t ssrc = parsed_packet->Ssrc(); | |
1155 | |
1117 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { | 1156 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { |
1118 auto it = audio_receive_ssrcs_.find(ssrc); | 1157 auto it = audio_receive_ssrcs_.find(ssrc); |
1119 if (it != audio_receive_ssrcs_.end()) { | 1158 if (it != audio_receive_ssrcs_.end()) { |
1120 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1159 received_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1121 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1160 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1122 auto status = it->second->DeliverRtp(packet, length, packet_time) | 1161 auto status = it->second->DeliverRtp(packet, length, packet_time) |
1123 ? DELIVERY_OK | 1162 ? DELIVERY_OK |
1124 : DELIVERY_PACKET_ERROR; | 1163 : DELIVERY_PACKET_ERROR; |
1125 if (status == DELIVERY_OK) | 1164 if (status == DELIVERY_OK) |
1126 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1165 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1127 return status; | 1166 return status; |
1128 } | 1167 } |
1129 } | 1168 } |
1130 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 1169 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
1131 auto it = video_receive_ssrcs_.find(ssrc); | 1170 auto it = video_receive_ssrcs_.find(ssrc); |
1132 if (it != video_receive_ssrcs_.end()) { | 1171 if (it != video_receive_ssrcs_.end()) { |
1133 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1172 received_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1134 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1173 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1135 // TODO(brandtr): Notify the BWE of received media packets here. | 1174 // TODO(brandtr): Notify the BWE of received media packets here. |
1136 auto status = it->second->DeliverRtp(packet, length, packet_time) | 1175 auto status = it->second->DeliverRtp(packet, length, packet_time) |
1137 ? DELIVERY_OK | 1176 ? DELIVERY_OK |
1138 : DELIVERY_PACKET_ERROR; | 1177 : DELIVERY_PACKET_ERROR; |
1139 // Deliver media packets to FlexFEC subsystem. RTP header extensions need | 1178 // Deliver media packets to FlexFEC subsystem. RTP header extensions need |
1140 // not be parsed, as FlexFEC is oblivious to the semantic meaning of the | 1179 // not be parsed, as FlexFEC is oblivious to the semantic meaning of the |
1141 // packet contents beyond the 12 byte RTP base header. The BWE is fed | 1180 // packet contents beyond the 12 byte RTP base header. The BWE is fed |
1142 // information about these media packets from the regular media pipeline. | 1181 // information about these media packets from the regular media pipeline. |
1143 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1144 ParseRtpPacket(packet, length, packet_time); | |
1145 if (parsed_packet) { | 1182 if (parsed_packet) { |
1146 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); | 1183 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); |
1147 for (auto it = it_bounds.first; it != it_bounds.second; ++it) | 1184 for (auto it = it_bounds.first; it != it_bounds.second; ++it) |
1148 it->second->AddAndProcessReceivedPacket(*parsed_packet); | 1185 it->second->AddAndProcessReceivedPacket(*parsed_packet); |
1149 } | 1186 } |
1150 if (status == DELIVERY_OK) | 1187 if (status == DELIVERY_OK) |
1151 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1188 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1152 return status; | 1189 return status; |
1153 } | 1190 } |
1154 } | 1191 } |
1155 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 1192 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
1156 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); | 1193 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); |
1157 if (it != flexfec_receive_ssrcs_protection_.end()) { | 1194 if (it != flexfec_receive_ssrcs_protection_.end()) { |
1158 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1159 ParseRtpPacket(packet, length, packet_time); | |
1160 if (parsed_packet) { | 1195 if (parsed_packet) { |
1161 NotifyBweOfReceivedPacket(*parsed_packet); | |
1162 auto status = it->second->AddAndProcessReceivedPacket(*parsed_packet) | 1196 auto status = it->second->AddAndProcessReceivedPacket(*parsed_packet) |
1163 ? DELIVERY_OK | 1197 ? DELIVERY_OK |
1164 : DELIVERY_PACKET_ERROR; | 1198 : DELIVERY_PACKET_ERROR; |
1165 if (status == DELIVERY_OK) | 1199 if (status == DELIVERY_OK) |
1166 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1200 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1167 return status; | 1201 return status; |
1168 } | 1202 } |
1169 } | 1203 } |
1170 } | 1204 } |
1171 return DELIVERY_UNKNOWN_SSRC; | 1205 return DELIVERY_UNKNOWN_SSRC; |
(...skipping 18 matching lines...) Expand all Loading... | |
1190 // audio packets with FlexFEC. | 1224 // audio packets with FlexFEC. |
1191 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { | 1225 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { |
1192 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1226 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
1193 ReadLockScoped read_lock(*receive_crit_); | 1227 ReadLockScoped read_lock(*receive_crit_); |
1194 auto it = video_receive_ssrcs_.find(ssrc); | 1228 auto it = video_receive_ssrcs_.find(ssrc); |
1195 if (it == video_receive_ssrcs_.end()) | 1229 if (it == video_receive_ssrcs_.end()) |
1196 return false; | 1230 return false; |
1197 return it->second->OnRecoveredPacket(packet, length); | 1231 return it->second->OnRecoveredPacket(packet, length); |
1198 } | 1232 } |
1199 | 1233 |
1200 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { | 1234 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, |
1235 MediaType media_type) { | |
1236 auto it = receive_rtp_config_.find(packet.Ssrc()); | |
1237 bool transport_cc = | |
1238 (it != receive_rtp_config_.end()) && it->second.transport_cc; | |
1239 | |
1201 RTPHeader header; | 1240 RTPHeader header; |
1202 packet.GetHeader(&header); | 1241 packet.GetHeader(&header); |
1203 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), | 1242 |
1204 packet.payload_size(), header); | 1243 if (!transport_cc && header.extension.hasTransportSequenceNumber) |
brandtr
2017/02/03 09:50:29
Add {}.
nisse-webrtc
2017/02/03 10:19:47
Done.
| |
1244 // Inconsistent configuration of send side BWE. Do nothing. | |
1245 // TODO(nisse): Without this check, we may produce RTCP feedback | |
1246 // packets even when not negotiated. But it would be cleaner to | |
1247 // move the check down to RTCPSender::SendFeedbackPacket, which | |
1248 // would also help the PacketRouter to select an appropriate rtp | |
1249 // module in the case that some, but not all, have RTCP feedback | |
1250 // enabled. | |
1251 return; | |
1252 | |
1253 // For audio, we only support send side BWE. | |
1254 // TODO(nisse): Tests passes MediaType::ANY, see | |
1255 // FakeNetworkPipe::Process. We need to treat that as video. Tests | |
1256 // should be fixed to use the same MediaType as the production code. | |
1257 if (media_type != MediaType::AUDIO || | |
1258 (transport_cc && header.extension.hasTransportSequenceNumber)) | |
brandtr
2017/02/03 09:50:29
{}
nisse-webrtc
2017/02/03 10:19:47
Done.
| |
1259 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), | |
1260 packet.payload_size(), header); | |
1205 } | 1261 } |
1206 | 1262 |
1207 } // namespace internal | 1263 } // namespace internal |
1208 } // namespace webrtc | 1264 } // namespace webrtc |
OLD | NEW |