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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 | 103 |
104 // Implements PacketReceiver. | 104 // Implements PacketReceiver. |
105 DeliveryStatus DeliverPacket(MediaType media_type, | 105 DeliveryStatus DeliverPacket(MediaType media_type, |
106 const uint8_t* packet, | 106 const uint8_t* packet, |
107 size_t length, | 107 size_t length, |
108 const PacketTime& packet_time) override; | 108 const PacketTime& packet_time) override; |
109 | 109 |
110 // Implements RecoveredPacketReceiver. | 110 // Implements RecoveredPacketReceiver. |
111 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; | 111 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; |
112 | 112 |
113 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet); | |
114 | |
115 void SetBitrateConfig( | 113 void SetBitrateConfig( |
116 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; | 114 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; |
117 | 115 |
118 void SignalChannelNetworkState(MediaType media, NetworkState state) override; | 116 void SignalChannelNetworkState(MediaType media, NetworkState state) override; |
119 | 117 |
120 void OnTransportOverheadChanged(MediaType media, | 118 void OnTransportOverheadChanged(MediaType media, |
121 int transport_overhead_per_packet) override; | 119 int transport_overhead_per_packet) override; |
122 | 120 |
123 void OnNetworkRouteChanged(const std::string& transport_name, | 121 void OnNetworkRouteChanged(const std::string& transport_name, |
124 const rtc::NetworkRoute& network_route) override; | 122 const rtc::NetworkRoute& network_route) override; |
(...skipping 23 matching lines...) Expand all Loading... | |
148 | 146 |
149 VoiceEngine* voice_engine() { | 147 VoiceEngine* voice_engine() { |
150 internal::AudioState* audio_state = | 148 internal::AudioState* audio_state = |
151 static_cast<internal::AudioState*>(config_.audio_state.get()); | 149 static_cast<internal::AudioState*>(config_.audio_state.get()); |
152 if (audio_state) | 150 if (audio_state) |
153 return audio_state->voice_engine(); | 151 return audio_state->voice_engine(); |
154 else | 152 else |
155 return nullptr; | 153 return nullptr; |
156 } | 154 } |
157 | 155 |
156 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) | |
157 SHARED_LOCKS_REQUIRED(receive_crit_); | |
158 | |
158 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, | 159 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, |
159 size_t length, | 160 size_t length, |
160 const PacketTime& packet_time) | 161 const PacketTime& packet_time) |
161 SHARED_LOCKS_REQUIRED(receive_crit_); | 162 SHARED_LOCKS_REQUIRED(receive_crit_); |
162 | 163 |
163 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); | 164 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); |
164 void UpdateReceiveHistograms(); | 165 void UpdateReceiveHistograms(); |
165 void UpdateHistograms(); | 166 void UpdateHistograms(); |
166 void UpdateAggregateNetworkState(); | 167 void UpdateAggregateNetworkState(); |
167 | 168 |
(...skipping 23 matching lines...) Expand all Loading... | |
191 // streams. | 192 // streams. |
192 std::multimap<uint32_t, FlexfecReceiveStreamImpl*> | 193 std::multimap<uint32_t, FlexfecReceiveStreamImpl*> |
193 flexfec_receive_ssrcs_media_ GUARDED_BY(receive_crit_); | 194 flexfec_receive_ssrcs_media_ GUARDED_BY(receive_crit_); |
194 std::map<uint32_t, FlexfecReceiveStreamImpl*> | 195 std::map<uint32_t, FlexfecReceiveStreamImpl*> |
195 flexfec_receive_ssrcs_protection_ GUARDED_BY(receive_crit_); | 196 flexfec_receive_ssrcs_protection_ GUARDED_BY(receive_crit_); |
196 std::set<FlexfecReceiveStreamImpl*> flexfec_receive_streams_ | 197 std::set<FlexfecReceiveStreamImpl*> flexfec_receive_streams_ |
197 GUARDED_BY(receive_crit_); | 198 GUARDED_BY(receive_crit_); |
198 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ | 199 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ |
199 GUARDED_BY(receive_crit_); | 200 GUARDED_BY(receive_crit_); |
200 | 201 |
201 // Registered RTP header extensions for each stream. | 202 // This extra map is used for receive processing which is |
202 // Note that RTP header extensions are negotiated per track ("m= line") in the | 203 // independent of media type. |
203 // SDP, but we have no notion of tracks at the Call level. We therefore store | 204 |
204 // the RTP header extensions per SSRC instead, which leads to some storage | 205 // TODO(nisse): In the RTP transport refactoring, we should have a |
205 // overhead. | 206 // single mapping from ssrc to a more abstract receive stream, with |
206 std::map<uint32_t, RtpHeaderExtensionMap> received_rtp_header_extensions_ | 207 // accessor methods for all configuration we need at this level. |
208 struct ReceiveRtpConfig { | |
209 ReceiveRtpConfig() = default; // Needed by std::map | |
210 ReceiveRtpConfig(const std::vector<RtpExtension>& extensions, | |
211 bool transport_cc) | |
212 : extensions(extensions), transport_cc(transport_cc) {} | |
213 | |
214 // Registered RTP header extensions for each stream. Note that RTP header | |
215 // extensions are negotiated per track ("m= line") in the SDP, but we have | |
216 // no notion of tracks at the Call level. We therefore store the RTP header | |
217 // extensions per SSRC instead, which leads to some storage overhead. | |
218 RtpHeaderExtensionMap extensions; | |
219 // True if send side bandwith estimation was negotiated. | |
220 bool transport_cc; | |
221 }; | |
222 std::map<uint32_t, ReceiveRtpConfig> receive_rtp_config_ | |
207 GUARDED_BY(receive_crit_); | 223 GUARDED_BY(receive_crit_); |
208 | 224 |
209 std::unique_ptr<RWLockWrapper> send_crit_; | 225 std::unique_ptr<RWLockWrapper> send_crit_; |
210 // Audio and Video send streams are owned by the client that creates them. | 226 // Audio and Video send streams are owned by the client that creates them. |
211 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); | 227 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); |
212 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); | 228 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
213 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); | 229 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
214 | 230 |
215 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; | 231 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; |
216 webrtc::RtcEventLog* event_log_; | 232 webrtc::RtcEventLog* event_log_; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 } | 376 } |
361 | 377 |
362 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( | 378 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( |
363 const uint8_t* packet, | 379 const uint8_t* packet, |
364 size_t length, | 380 size_t length, |
365 const PacketTime& packet_time) { | 381 const PacketTime& packet_time) { |
366 RtpPacketReceived parsed_packet; | 382 RtpPacketReceived parsed_packet; |
367 if (!parsed_packet.Parse(packet, length)) | 383 if (!parsed_packet.Parse(packet, length)) |
368 return rtc::Optional<RtpPacketReceived>(); | 384 return rtc::Optional<RtpPacketReceived>(); |
369 | 385 |
370 auto it = received_rtp_header_extensions_.find(parsed_packet.Ssrc()); | 386 auto it = receive_rtp_config_.find(parsed_packet.Ssrc()); |
371 if (it != received_rtp_header_extensions_.end()) | 387 if (it != receive_rtp_config_.end()) |
372 parsed_packet.IdentifyExtensions(it->second); | 388 parsed_packet.IdentifyExtensions(it->second.extensions); |
373 | 389 |
374 int64_t arrival_time_ms; | 390 int64_t arrival_time_ms; |
375 if (packet_time.timestamp != -1) { | 391 if (packet_time.timestamp != -1) { |
376 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | 392 arrival_time_ms = (packet_time.timestamp + 500) / 1000; |
377 } else { | 393 } else { |
378 arrival_time_ms = clock_->TimeInMilliseconds(); | 394 arrival_time_ms = clock_->TimeInMilliseconds(); |
379 } | 395 } |
380 parsed_packet.set_arrival_time_ms(arrival_time_ms); | 396 parsed_packet.set_arrival_time_ms(arrival_time_ms); |
381 | 397 |
382 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); | 398 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 AudioReceiveStream* receive_stream = new AudioReceiveStream( | 536 AudioReceiveStream* receive_stream = new AudioReceiveStream( |
521 &packet_router_, | 537 &packet_router_, |
522 // TODO(nisse): Used only when UseSendSideBwe(config) is true. | 538 // TODO(nisse): Used only when UseSendSideBwe(config) is true. |
523 congestion_controller_->GetRemoteBitrateEstimator(true), config, | 539 congestion_controller_->GetRemoteBitrateEstimator(true), config, |
524 config_.audio_state, event_log_); | 540 config_.audio_state, event_log_); |
525 { | 541 { |
526 WriteLockScoped write_lock(*receive_crit_); | 542 WriteLockScoped write_lock(*receive_crit_); |
527 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 543 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
528 audio_receive_ssrcs_.end()); | 544 audio_receive_ssrcs_.end()); |
529 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 545 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
546 receive_rtp_config_[config.rtp.remote_ssrc] = | |
547 ReceiveRtpConfig(config.rtp.extensions, config.rtp.transport_cc); | |
548 | |
530 ConfigureSync(config.sync_group); | 549 ConfigureSync(config.sync_group); |
531 } | 550 } |
532 { | 551 { |
533 ReadLockScoped read_lock(*send_crit_); | 552 ReadLockScoped read_lock(*send_crit_); |
534 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); | 553 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); |
535 if (it != audio_send_ssrcs_.end()) { | 554 if (it != audio_send_ssrcs_.end()) { |
536 receive_stream->AssociateSendStream(it->second); | 555 receive_stream->AssociateSendStream(it->second); |
537 } | 556 } |
538 } | 557 } |
539 receive_stream->SignalNetworkState(audio_network_state_); | 558 receive_stream->SignalNetworkState(audio_network_state_); |
540 UpdateAggregateNetworkState(); | 559 UpdateAggregateNetworkState(); |
541 return receive_stream; | 560 return receive_stream; |
542 } | 561 } |
543 | 562 |
544 void Call::DestroyAudioReceiveStream( | 563 void Call::DestroyAudioReceiveStream( |
545 webrtc::AudioReceiveStream* receive_stream) { | 564 webrtc::AudioReceiveStream* receive_stream) { |
546 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); | 565 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); |
547 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 566 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
548 RTC_DCHECK(receive_stream != nullptr); | 567 RTC_DCHECK(receive_stream != nullptr); |
549 webrtc::internal::AudioReceiveStream* audio_receive_stream = | 568 webrtc::internal::AudioReceiveStream* audio_receive_stream = |
550 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); | 569 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); |
551 { | 570 { |
552 WriteLockScoped write_lock(*receive_crit_); | 571 WriteLockScoped write_lock(*receive_crit_); |
553 size_t num_deleted = audio_receive_ssrcs_.erase( | 572 uint32_t ssrc = audio_receive_stream->config().rtp.remote_ssrc; |
554 audio_receive_stream->config().rtp.remote_ssrc); | 573 |
574 size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); | |
555 RTC_DCHECK(num_deleted == 1); | 575 RTC_DCHECK(num_deleted == 1); |
556 const std::string& sync_group = audio_receive_stream->config().sync_group; | 576 const std::string& sync_group = audio_receive_stream->config().sync_group; |
557 const auto it = sync_stream_mapping_.find(sync_group); | 577 const auto it = sync_stream_mapping_.find(sync_group); |
558 if (it != sync_stream_mapping_.end() && | 578 if (it != sync_stream_mapping_.end() && |
559 it->second == audio_receive_stream) { | 579 it->second == audio_receive_stream) { |
560 sync_stream_mapping_.erase(it); | 580 sync_stream_mapping_.erase(it); |
561 ConfigureSync(sync_group); | 581 ConfigureSync(sync_group); |
562 } | 582 } |
583 receive_rtp_config_.erase(ssrc); | |
563 } | 584 } |
564 UpdateAggregateNetworkState(); | 585 UpdateAggregateNetworkState(); |
565 delete audio_receive_stream; | 586 delete audio_receive_stream; |
566 } | 587 } |
567 | 588 |
568 webrtc::VideoSendStream* Call::CreateVideoSendStream( | 589 webrtc::VideoSendStream* Call::CreateVideoSendStream( |
569 webrtc::VideoSendStream::Config config, | 590 webrtc::VideoSendStream::Config config, |
570 VideoEncoderConfig encoder_config) { | 591 VideoEncoderConfig encoder_config) { |
571 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); | 592 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); |
572 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 593 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 658 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
638 webrtc::VideoReceiveStream::Config configuration) { | 659 webrtc::VideoReceiveStream::Config configuration) { |
639 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 660 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
640 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 661 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
641 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 662 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
642 num_cpu_cores_, congestion_controller_.get(), &packet_router_, | 663 num_cpu_cores_, congestion_controller_.get(), &packet_router_, |
643 std::move(configuration), voice_engine(), module_process_thread_.get(), | 664 std::move(configuration), voice_engine(), module_process_thread_.get(), |
644 call_stats_.get(), &remb_); | 665 call_stats_.get(), &remb_); |
645 | 666 |
646 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 667 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
668 ReceiveRtpConfig receive_config(config.rtp.extensions, | |
669 config.rtp.transport_cc); | |
647 { | 670 { |
648 WriteLockScoped write_lock(*receive_crit_); | 671 WriteLockScoped write_lock(*receive_crit_); |
649 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 672 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
650 video_receive_ssrcs_.end()); | 673 video_receive_ssrcs_.end()); |
651 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 674 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
675 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config; | |
652 // TODO(pbos): Configure different RTX payloads per receive payload. | 676 // TODO(pbos): Configure different RTX payloads per receive payload. |
653 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 677 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = |
654 config.rtp.rtx.begin(); | 678 config.rtp.rtx.begin(); |
655 if (it != config.rtp.rtx.end()) | 679 if (it != config.rtp.rtx.end()) { |
656 video_receive_ssrcs_[it->second.ssrc] = receive_stream; | 680 video_receive_ssrcs_[it->second.ssrc] = receive_stream; |
681 receive_rtp_config_[it->second.ssrc] = receive_config; | |
682 } | |
657 video_receive_streams_.insert(receive_stream); | 683 video_receive_streams_.insert(receive_stream); |
684 | |
658 ConfigureSync(config.sync_group); | 685 ConfigureSync(config.sync_group); |
659 } | 686 } |
660 receive_stream->SignalNetworkState(video_network_state_); | 687 receive_stream->SignalNetworkState(video_network_state_); |
661 UpdateAggregateNetworkState(); | 688 UpdateAggregateNetworkState(); |
662 event_log_->LogVideoReceiveStreamConfig(config); | 689 event_log_->LogVideoReceiveStreamConfig(config); |
663 return receive_stream; | 690 return receive_stream; |
664 } | 691 } |
665 | 692 |
666 void Call::DestroyVideoReceiveStream( | 693 void Call::DestroyVideoReceiveStream( |
667 webrtc::VideoReceiveStream* receive_stream) { | 694 webrtc::VideoReceiveStream* receive_stream) { |
668 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 695 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
669 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 696 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
670 RTC_DCHECK(receive_stream != nullptr); | 697 RTC_DCHECK(receive_stream != nullptr); |
671 VideoReceiveStream* receive_stream_impl = nullptr; | 698 VideoReceiveStream* receive_stream_impl = nullptr; |
672 { | 699 { |
673 WriteLockScoped write_lock(*receive_crit_); | 700 WriteLockScoped write_lock(*receive_crit_); |
674 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a | 701 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a |
675 // separate SSRC there can be either one or two. | 702 // separate SSRC there can be either one or two. |
676 auto it = video_receive_ssrcs_.begin(); | 703 auto it = video_receive_ssrcs_.begin(); |
677 while (it != video_receive_ssrcs_.end()) { | 704 while (it != video_receive_ssrcs_.end()) { |
678 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { | 705 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { |
679 if (receive_stream_impl != nullptr) | 706 if (receive_stream_impl != nullptr) |
680 RTC_DCHECK(receive_stream_impl == it->second); | 707 RTC_DCHECK(receive_stream_impl == it->second); |
681 receive_stream_impl = it->second; | 708 receive_stream_impl = it->second; |
682 video_receive_ssrcs_.erase(it++); | 709 receive_rtp_config_.erase(it->first); |
710 it = video_receive_ssrcs_.erase(it); | |
683 } else { | 711 } else { |
684 ++it; | 712 ++it; |
685 } | 713 } |
686 } | 714 } |
687 video_receive_streams_.erase(receive_stream_impl); | 715 video_receive_streams_.erase(receive_stream_impl); |
688 RTC_CHECK(receive_stream_impl != nullptr); | 716 RTC_CHECK(receive_stream_impl != nullptr); |
689 ConfigureSync(receive_stream_impl->config().sync_group); | 717 ConfigureSync(receive_stream_impl->config().sync_group); |
690 } | 718 } |
691 UpdateAggregateNetworkState(); | 719 UpdateAggregateNetworkState(); |
692 delete receive_stream_impl; | 720 delete receive_stream_impl; |
(...skipping 16 matching lines...) Expand all Loading... | |
709 flexfec_receive_streams_.end()); | 737 flexfec_receive_streams_.end()); |
710 flexfec_receive_streams_.insert(receive_stream); | 738 flexfec_receive_streams_.insert(receive_stream); |
711 | 739 |
712 for (auto ssrc : config.protected_media_ssrcs) | 740 for (auto ssrc : config.protected_media_ssrcs) |
713 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); | 741 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); |
714 | 742 |
715 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == | 743 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == |
716 flexfec_receive_ssrcs_protection_.end()); | 744 flexfec_receive_ssrcs_protection_.end()); |
717 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; | 745 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; |
718 | 746 |
719 RTC_DCHECK(received_rtp_header_extensions_.find(config.remote_ssrc) == | 747 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) == |
720 received_rtp_header_extensions_.end()); | 748 receive_rtp_config_.end()); |
721 RtpHeaderExtensionMap rtp_header_extensions(config.rtp_header_extensions); | 749 receive_rtp_config_[config.remote_ssrc] = |
722 received_rtp_header_extensions_[config.remote_ssrc] = rtp_header_extensions; | 750 ReceiveRtpConfig(config.rtp_header_extensions, config.transport_cc); |
723 } | 751 } |
724 | 752 |
725 // TODO(brandtr): Store config in RtcEventLog here. | 753 // TODO(brandtr): Store config in RtcEventLog here. |
726 | 754 |
727 return receive_stream; | 755 return receive_stream; |
728 } | 756 } |
729 | 757 |
730 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { | 758 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { |
731 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); | 759 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); |
732 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 760 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
733 | 761 |
734 RTC_DCHECK(receive_stream != nullptr); | 762 RTC_DCHECK(receive_stream != nullptr); |
735 // There exist no other derived classes of FlexfecReceiveStream, | 763 // There exist no other derived classes of FlexfecReceiveStream, |
736 // so this downcast is safe. | 764 // so this downcast is safe. |
737 FlexfecReceiveStreamImpl* receive_stream_impl = | 765 FlexfecReceiveStreamImpl* receive_stream_impl = |
738 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); | 766 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); |
739 { | 767 { |
740 WriteLockScoped write_lock(*receive_crit_); | 768 WriteLockScoped write_lock(*receive_crit_); |
741 | 769 |
742 uint32_t ssrc = receive_stream_impl->GetConfig().remote_ssrc; | 770 uint32_t ssrc = receive_stream_impl->GetConfig().remote_ssrc; |
743 received_rtp_header_extensions_.erase(ssrc); | 771 receive_rtp_config_.erase(ssrc); |
744 | 772 |
745 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be | 773 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be |
746 // destroyed. | 774 // destroyed. |
747 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); | 775 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); |
748 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { | 776 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { |
749 if (prot_it->second == receive_stream_impl) | 777 if (prot_it->second == receive_stream_impl) |
750 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); | 778 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); |
751 else | 779 else |
752 ++prot_it; | 780 ++prot_it; |
753 } | 781 } |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1104 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length); | 1132 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length); |
1105 | 1133 |
1106 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; | 1134 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; |
1107 } | 1135 } |
1108 | 1136 |
1109 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, | 1137 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, |
1110 const uint8_t* packet, | 1138 const uint8_t* packet, |
1111 size_t length, | 1139 size_t length, |
1112 const PacketTime& packet_time) { | 1140 const PacketTime& packet_time) { |
1113 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); | 1141 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); |
1114 // Minimum RTP header size. | 1142 |
1115 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) | |
1116 return DELIVERY_PACKET_ERROR; | 1150 return DELIVERY_PACKET_ERROR; |
1117 | 1151 |
1118 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1152 NotifyBweOfReceivedPacket(*parsed_packet); |
1119 ReadLockScoped read_lock(*receive_crit_); | 1153 |
1154 uint32_t ssrc = parsed_packet->Ssrc(); | |
1155 | |
1120 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { | 1156 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { |
1121 auto it = audio_receive_ssrcs_.find(ssrc); | 1157 auto it = audio_receive_ssrcs_.find(ssrc); |
1122 if (it != audio_receive_ssrcs_.end()) { | 1158 if (it != audio_receive_ssrcs_.end()) { |
1123 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1159 received_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1124 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1160 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1125 auto status = it->second->DeliverRtp(packet, length, packet_time) | 1161 auto status = it->second->DeliverRtp(packet, length, packet_time) |
1126 ? DELIVERY_OK | 1162 ? DELIVERY_OK |
1127 : DELIVERY_PACKET_ERROR; | 1163 : DELIVERY_PACKET_ERROR; |
1128 if (status == DELIVERY_OK) | 1164 if (status == DELIVERY_OK) |
1129 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1165 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1130 return status; | 1166 return status; |
1131 } | 1167 } |
1132 } | 1168 } |
1133 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 1169 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
1134 auto it = video_receive_ssrcs_.find(ssrc); | 1170 auto it = video_receive_ssrcs_.find(ssrc); |
1135 if (it != video_receive_ssrcs_.end()) { | 1171 if (it != video_receive_ssrcs_.end()) { |
1136 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1172 received_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1137 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1173 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1138 // TODO(brandtr): Notify the BWE of received media packets here. | 1174 // TODO(brandtr): Notify the BWE of received media packets here. |
1139 auto status = it->second->DeliverRtp(packet, length, packet_time) | 1175 auto status = it->second->DeliverRtp(packet, length, packet_time) |
1140 ? DELIVERY_OK | 1176 ? DELIVERY_OK |
1141 : DELIVERY_PACKET_ERROR; | 1177 : DELIVERY_PACKET_ERROR; |
1142 // Deliver media packets to FlexFEC subsystem. RTP header extensions need | 1178 // Deliver media packets to FlexFEC subsystem. RTP header extensions need |
1143 // 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 |
1144 // 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 |
1145 // information about these media packets from the regular media pipeline. | 1181 // information about these media packets from the regular media pipeline. |
1146 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1147 ParseRtpPacket(packet, length, packet_time); | |
1148 if (parsed_packet) { | 1182 if (parsed_packet) { |
1149 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); | 1183 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); |
1150 for (auto it = it_bounds.first; it != it_bounds.second; ++it) | 1184 for (auto it = it_bounds.first; it != it_bounds.second; ++it) |
1151 it->second->AddAndProcessReceivedPacket(*parsed_packet); | 1185 it->second->AddAndProcessReceivedPacket(*parsed_packet); |
1152 } | 1186 } |
1153 if (status == DELIVERY_OK) | 1187 if (status == DELIVERY_OK) |
1154 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1188 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1155 return status; | 1189 return status; |
1156 } | 1190 } |
1157 } | 1191 } |
1158 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 1192 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
1159 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); | 1193 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); |
1160 if (it != flexfec_receive_ssrcs_protection_.end()) { | 1194 if (it != flexfec_receive_ssrcs_protection_.end()) { |
1161 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1162 ParseRtpPacket(packet, length, packet_time); | |
1163 if (parsed_packet) { | 1195 if (parsed_packet) { |
1164 NotifyBweOfReceivedPacket(*parsed_packet); | |
1165 auto status = it->second->AddAndProcessReceivedPacket(*parsed_packet) | 1196 auto status = it->second->AddAndProcessReceivedPacket(*parsed_packet) |
1166 ? DELIVERY_OK | 1197 ? DELIVERY_OK |
1167 : DELIVERY_PACKET_ERROR; | 1198 : DELIVERY_PACKET_ERROR; |
1168 if (status == DELIVERY_OK) | 1199 if (status == DELIVERY_OK) |
1169 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1200 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1170 return status; | 1201 return status; |
1171 } | 1202 } |
1172 } | 1203 } |
1173 } | 1204 } |
1174 return DELIVERY_UNKNOWN_SSRC; | 1205 return DELIVERY_UNKNOWN_SSRC; |
(...skipping 19 matching lines...) Expand all Loading... | |
1194 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { | 1225 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { |
1195 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1226 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
1196 ReadLockScoped read_lock(*receive_crit_); | 1227 ReadLockScoped read_lock(*receive_crit_); |
1197 auto it = video_receive_ssrcs_.find(ssrc); | 1228 auto it = video_receive_ssrcs_.find(ssrc); |
1198 if (it == video_receive_ssrcs_.end()) | 1229 if (it == video_receive_ssrcs_.end()) |
1199 return false; | 1230 return false; |
1200 return it->second->OnRecoveredPacket(packet, length); | 1231 return it->second->OnRecoveredPacket(packet, length); |
1201 } | 1232 } |
1202 | 1233 |
1203 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { | 1234 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { |
1235 auto it = receive_rtp_config_.find(packet.Ssrc()); | |
1236 bool transport_cc = | |
1237 (it != receive_rtp_config_.end()) && it->second.transport_cc; | |
1238 | |
1204 RTPHeader header; | 1239 RTPHeader header; |
1205 packet.GetHeader(&header); | 1240 packet.GetHeader(&header); |
1241 | |
1242 if (transport_cc != header.extension.hasTransportSequenceNumber) { | |
nisse-webrtc
2017/01/27 13:26:14
I intended to use the check
if (transport_cc &
| |
1243 // Send side BWE was negotiated, but required header extension not | |
1244 // present on this packet. Then don't use it for bandwidth | |
1245 // estimation at all. | |
1246 LOG(LS_ERROR) << "Not calling OnReceivedPacket"; | |
1247 return; | |
1248 } | |
1206 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), | 1249 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), |
1207 packet.payload_size(), header); | 1250 packet.payload_size(), header); |
1208 } | 1251 } |
1209 | 1252 |
1210 } // namespace internal | 1253 } // namespace internal |
1211 } // namespace webrtc | 1254 } // namespace webrtc |
OLD | NEW |