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) {} | |
brandtr
2017/01/30 12:03:53
Should we store a bool for REMB here too? The mech
nisse-webrtc
2017/01/30 14:56:57
Maybe. Are you suggesting I do something about it
brandtr
2017/02/01 10:05:11
Actually, there is probably no direct value in kee
| |
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. | |
brandtr
2017/01/30 12:03:53
Mention that |transport_cc| only has to do with th
nisse-webrtc
2017/01/30 14:56:57
Done.
| |
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 delete audio_send_stream; | 528 delete audio_send_stream; |
513 } | 529 } |
514 | 530 |
515 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 531 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
516 const webrtc::AudioReceiveStream::Config& config) { | 532 const webrtc::AudioReceiveStream::Config& config) { |
517 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 533 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
518 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 534 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
519 event_log_->LogAudioReceiveStreamConfig(config); | 535 event_log_->LogAudioReceiveStreamConfig(config); |
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. |
brandtr
2017/01/30 12:03:53
Could this TODO be removed now?
nisse-webrtc
2017/01/30 14:56:57
Done.
| |
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 protected_by_flexfec = | 666 protected_by_flexfec = |
646 flexfec_receive_ssrcs_media_.find(configuration.rtp.remote_ssrc) != | 667 flexfec_receive_ssrcs_media_.find(configuration.rtp.remote_ssrc) != |
647 flexfec_receive_ssrcs_media_.end(); | 668 flexfec_receive_ssrcs_media_.end(); |
648 } | 669 } |
649 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 670 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
650 num_cpu_cores_, protected_by_flexfec, congestion_controller_.get(), | 671 num_cpu_cores_, protected_by_flexfec, congestion_controller_.get(), |
651 &packet_router_, std::move(configuration), voice_engine(), | 672 &packet_router_, std::move(configuration), voice_engine(), |
652 module_process_thread_.get(), call_stats_.get(), &remb_); | 673 module_process_thread_.get(), call_stats_.get(), &remb_); |
653 | 674 |
654 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 675 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
676 ReceiveRtpConfig receive_config(config.rtp.extensions, | |
677 config.rtp.transport_cc); | |
655 { | 678 { |
656 WriteLockScoped write_lock(*receive_crit_); | 679 WriteLockScoped write_lock(*receive_crit_); |
657 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 680 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
658 video_receive_ssrcs_.end()); | 681 video_receive_ssrcs_.end()); |
659 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 682 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
660 if (config.rtp.rtx_ssrc) | 683 if (config.rtp.rtx_ssrc) { |
661 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; | 684 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; |
685 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config; | |
brandtr
2017/01/30 12:03:53
config.rtp.transport_cc describes if the RTCP feed
nisse-webrtc
2017/01/30 14:56:57
If it's more correct to set transport_cc always fa
nisse-webrtc
2017/02/01 09:59:53
Added a comment now.
brandtr
2017/02/01 10:05:11
I think neither is more correct, so it's probably
| |
686 } | |
687 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config; | |
662 video_receive_streams_.insert(receive_stream); | 688 video_receive_streams_.insert(receive_stream); |
663 ConfigureSync(config.sync_group); | 689 ConfigureSync(config.sync_group); |
664 } | 690 } |
665 receive_stream->SignalNetworkState(video_network_state_); | 691 receive_stream->SignalNetworkState(video_network_state_); |
666 UpdateAggregateNetworkState(); | 692 UpdateAggregateNetworkState(); |
667 event_log_->LogVideoReceiveStreamConfig(config); | 693 event_log_->LogVideoReceiveStreamConfig(config); |
668 return receive_stream; | 694 return receive_stream; |
669 } | 695 } |
670 | 696 |
671 void Call::DestroyVideoReceiveStream( | 697 void Call::DestroyVideoReceiveStream( |
672 webrtc::VideoReceiveStream* receive_stream) { | 698 webrtc::VideoReceiveStream* receive_stream) { |
673 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 699 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
674 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 700 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
675 RTC_DCHECK(receive_stream != nullptr); | 701 RTC_DCHECK(receive_stream != nullptr); |
676 VideoReceiveStream* receive_stream_impl = nullptr; | 702 VideoReceiveStream* receive_stream_impl = nullptr; |
677 { | 703 { |
678 WriteLockScoped write_lock(*receive_crit_); | 704 WriteLockScoped write_lock(*receive_crit_); |
679 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a | 705 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a |
680 // separate SSRC there can be either one or two. | 706 // separate SSRC there can be either one or two. |
681 auto it = video_receive_ssrcs_.begin(); | 707 auto it = video_receive_ssrcs_.begin(); |
682 while (it != video_receive_ssrcs_.end()) { | 708 while (it != video_receive_ssrcs_.end()) { |
683 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { | 709 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { |
684 if (receive_stream_impl != nullptr) | 710 if (receive_stream_impl != nullptr) |
685 RTC_DCHECK(receive_stream_impl == it->second); | 711 RTC_DCHECK(receive_stream_impl == it->second); |
686 receive_stream_impl = it->second; | 712 receive_stream_impl = it->second; |
687 video_receive_ssrcs_.erase(it++); | 713 receive_rtp_config_.erase(it->first); |
714 it = video_receive_ssrcs_.erase(it); | |
688 } else { | 715 } else { |
689 ++it; | 716 ++it; |
690 } | 717 } |
691 } | 718 } |
692 video_receive_streams_.erase(receive_stream_impl); | 719 video_receive_streams_.erase(receive_stream_impl); |
693 RTC_CHECK(receive_stream_impl != nullptr); | 720 RTC_CHECK(receive_stream_impl != nullptr); |
694 ConfigureSync(receive_stream_impl->config().sync_group); | 721 ConfigureSync(receive_stream_impl->config().sync_group); |
695 } | 722 } |
696 UpdateAggregateNetworkState(); | 723 UpdateAggregateNetworkState(); |
697 delete receive_stream_impl; | 724 delete receive_stream_impl; |
(...skipping 16 matching lines...) Expand all Loading... | |
714 flexfec_receive_streams_.end()); | 741 flexfec_receive_streams_.end()); |
715 flexfec_receive_streams_.insert(receive_stream); | 742 flexfec_receive_streams_.insert(receive_stream); |
716 | 743 |
717 for (auto ssrc : config.protected_media_ssrcs) | 744 for (auto ssrc : config.protected_media_ssrcs) |
718 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); | 745 flexfec_receive_ssrcs_media_.insert(std::make_pair(ssrc, receive_stream)); |
719 | 746 |
720 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == | 747 RTC_DCHECK(flexfec_receive_ssrcs_protection_.find(config.remote_ssrc) == |
721 flexfec_receive_ssrcs_protection_.end()); | 748 flexfec_receive_ssrcs_protection_.end()); |
722 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; | 749 flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; |
723 | 750 |
724 RTC_DCHECK(received_rtp_header_extensions_.find(config.remote_ssrc) == | 751 RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) == |
725 received_rtp_header_extensions_.end()); | 752 receive_rtp_config_.end()); |
726 RtpHeaderExtensionMap rtp_header_extensions(config.rtp_header_extensions); | 753 receive_rtp_config_[config.remote_ssrc] = |
727 received_rtp_header_extensions_[config.remote_ssrc] = rtp_header_extensions; | 754 ReceiveRtpConfig(config.rtp_header_extensions, config.transport_cc); |
728 } | 755 } |
729 | 756 |
730 // TODO(brandtr): Store config in RtcEventLog here. | 757 // TODO(brandtr): Store config in RtcEventLog here. |
731 | 758 |
732 return receive_stream; | 759 return receive_stream; |
733 } | 760 } |
734 | 761 |
735 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { | 762 void Call::DestroyFlexfecReceiveStream(FlexfecReceiveStream* receive_stream) { |
736 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); | 763 TRACE_EVENT0("webrtc", "Call::DestroyFlexfecReceiveStream"); |
737 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 764 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
738 | 765 |
739 RTC_DCHECK(receive_stream != nullptr); | 766 RTC_DCHECK(receive_stream != nullptr); |
740 // There exist no other derived classes of FlexfecReceiveStream, | 767 // There exist no other derived classes of FlexfecReceiveStream, |
741 // so this downcast is safe. | 768 // so this downcast is safe. |
742 FlexfecReceiveStreamImpl* receive_stream_impl = | 769 FlexfecReceiveStreamImpl* receive_stream_impl = |
743 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); | 770 static_cast<FlexfecReceiveStreamImpl*>(receive_stream); |
744 { | 771 { |
745 WriteLockScoped write_lock(*receive_crit_); | 772 WriteLockScoped write_lock(*receive_crit_); |
746 | 773 |
747 uint32_t ssrc = receive_stream_impl->GetConfig().remote_ssrc; | 774 uint32_t ssrc = receive_stream_impl->GetConfig().remote_ssrc; |
748 received_rtp_header_extensions_.erase(ssrc); | 775 receive_rtp_config_.erase(ssrc); |
749 | 776 |
750 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be | 777 // Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be |
751 // destroyed. | 778 // destroyed. |
752 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); | 779 auto prot_it = flexfec_receive_ssrcs_protection_.begin(); |
753 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { | 780 while (prot_it != flexfec_receive_ssrcs_protection_.end()) { |
754 if (prot_it->second == receive_stream_impl) | 781 if (prot_it->second == receive_stream_impl) |
755 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); | 782 prot_it = flexfec_receive_ssrcs_protection_.erase(prot_it); |
756 else | 783 else |
757 ++prot_it; | 784 ++prot_it; |
758 } | 785 } |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1111 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length); | 1138 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length); |
1112 | 1139 |
1113 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; | 1140 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; |
1114 } | 1141 } |
1115 | 1142 |
1116 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, | 1143 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, |
1117 const uint8_t* packet, | 1144 const uint8_t* packet, |
1118 size_t length, | 1145 size_t length, |
1119 const PacketTime& packet_time) { | 1146 const PacketTime& packet_time) { |
1120 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); | 1147 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); |
1121 // Minimum RTP header size. | 1148 |
1122 if (length < 12) | 1149 ReadLockScoped read_lock(*receive_crit_); |
1150 // TODO(nisse): We should parse the RTP header only here, and pass | |
1151 // on parsed_packet to the receive streams. | |
1152 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1153 ParseRtpPacket(packet, length, packet_time); | |
1154 | |
1155 if (!parsed_packet) | |
1123 return DELIVERY_PACKET_ERROR; | 1156 return DELIVERY_PACKET_ERROR; |
1124 | 1157 |
1125 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1158 NotifyBweOfReceivedPacket(*parsed_packet); |
1126 ReadLockScoped read_lock(*receive_crit_); | 1159 |
1160 uint32_t ssrc = parsed_packet->Ssrc(); | |
1161 | |
1127 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { | 1162 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { |
1128 auto it = audio_receive_ssrcs_.find(ssrc); | 1163 auto it = audio_receive_ssrcs_.find(ssrc); |
1129 if (it != audio_receive_ssrcs_.end()) { | 1164 if (it != audio_receive_ssrcs_.end()) { |
1130 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1165 received_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1131 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1166 received_audio_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1132 auto status = it->second->DeliverRtp(packet, length, packet_time) | 1167 auto status = it->second->DeliverRtp(packet, length, packet_time) |
1133 ? DELIVERY_OK | 1168 ? DELIVERY_OK |
1134 : DELIVERY_PACKET_ERROR; | 1169 : DELIVERY_PACKET_ERROR; |
1135 if (status == DELIVERY_OK) | 1170 if (status == DELIVERY_OK) |
1136 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1171 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1137 return status; | 1172 return status; |
1138 } | 1173 } |
1139 } | 1174 } |
1140 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 1175 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
1141 auto it = video_receive_ssrcs_.find(ssrc); | 1176 auto it = video_receive_ssrcs_.find(ssrc); |
1142 if (it != video_receive_ssrcs_.end()) { | 1177 if (it != video_receive_ssrcs_.end()) { |
1143 received_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1178 received_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1144 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); | 1179 received_video_bytes_per_second_counter_.Add(static_cast<int>(length)); |
1145 // TODO(brandtr): Notify the BWE of received media packets here. | 1180 // TODO(brandtr): Notify the BWE of received media packets here. |
1146 auto status = it->second->DeliverRtp(packet, length, packet_time) | 1181 auto status = it->second->DeliverRtp(packet, length, packet_time) |
1147 ? DELIVERY_OK | 1182 ? DELIVERY_OK |
1148 : DELIVERY_PACKET_ERROR; | 1183 : DELIVERY_PACKET_ERROR; |
1149 // Deliver media packets to FlexFEC subsystem. RTP header extensions need | 1184 // Deliver media packets to FlexFEC subsystem. RTP header extensions need |
1150 // not be parsed, as FlexFEC is oblivious to the semantic meaning of the | 1185 // not be parsed, as FlexFEC is oblivious to the semantic meaning of the |
1151 // packet contents beyond the 12 byte RTP base header. The BWE is fed | 1186 // packet contents beyond the 12 byte RTP base header. The BWE is fed |
1152 // information about these media packets from the regular media pipeline. | 1187 // information about these media packets from the regular media pipeline. |
1153 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1154 ParseRtpPacket(packet, length, packet_time); | |
1155 if (parsed_packet) { | 1188 if (parsed_packet) { |
1156 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); | 1189 auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); |
1157 for (auto it = it_bounds.first; it != it_bounds.second; ++it) | 1190 for (auto it = it_bounds.first; it != it_bounds.second; ++it) |
1158 it->second->AddAndProcessReceivedPacket(*parsed_packet); | 1191 it->second->AddAndProcessReceivedPacket(*parsed_packet); |
1159 } | 1192 } |
1160 if (status == DELIVERY_OK) | 1193 if (status == DELIVERY_OK) |
1161 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1194 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1162 return status; | 1195 return status; |
1163 } | 1196 } |
1164 } | 1197 } |
1165 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 1198 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
1166 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); | 1199 auto it = flexfec_receive_ssrcs_protection_.find(ssrc); |
1167 if (it != flexfec_receive_ssrcs_protection_.end()) { | 1200 if (it != flexfec_receive_ssrcs_protection_.end()) { |
1168 rtc::Optional<RtpPacketReceived> parsed_packet = | |
1169 ParseRtpPacket(packet, length, packet_time); | |
1170 if (parsed_packet) { | 1201 if (parsed_packet) { |
1171 NotifyBweOfReceivedPacket(*parsed_packet); | |
1172 auto status = it->second->AddAndProcessReceivedPacket(*parsed_packet) | 1202 auto status = it->second->AddAndProcessReceivedPacket(*parsed_packet) |
1173 ? DELIVERY_OK | 1203 ? DELIVERY_OK |
1174 : DELIVERY_PACKET_ERROR; | 1204 : DELIVERY_PACKET_ERROR; |
1175 if (status == DELIVERY_OK) | 1205 if (status == DELIVERY_OK) |
1176 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 1206 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
1177 return status; | 1207 return status; |
1178 } | 1208 } |
1179 } | 1209 } |
1180 } | 1210 } |
1181 return DELIVERY_UNKNOWN_SSRC; | 1211 return DELIVERY_UNKNOWN_SSRC; |
(...skipping 19 matching lines...) Expand all Loading... | |
1201 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { | 1231 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { |
1202 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1232 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
1203 ReadLockScoped read_lock(*receive_crit_); | 1233 ReadLockScoped read_lock(*receive_crit_); |
1204 auto it = video_receive_ssrcs_.find(ssrc); | 1234 auto it = video_receive_ssrcs_.find(ssrc); |
1205 if (it == video_receive_ssrcs_.end()) | 1235 if (it == video_receive_ssrcs_.end()) |
1206 return false; | 1236 return false; |
1207 return it->second->OnRecoveredPacket(packet, length); | 1237 return it->second->OnRecoveredPacket(packet, length); |
1208 } | 1238 } |
1209 | 1239 |
1210 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { | 1240 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { |
1241 auto it = receive_rtp_config_.find(packet.Ssrc()); | |
1242 bool transport_cc = | |
1243 (it != receive_rtp_config_.end()) && it->second.transport_cc; | |
1244 | |
1211 RTPHeader header; | 1245 RTPHeader header; |
1212 packet.GetHeader(&header); | 1246 packet.GetHeader(&header); |
1247 | |
1248 // transport_cc represents the negotiation of the RTCP feedback | |
1249 // message used for send side BWE. If it was negotiated but the | |
1250 // corresponding RTP header extension is not present, or vice versa, | |
1251 // bandwidth estimation is not correctly configured. | |
1252 if (transport_cc != header.extension.hasTransportSequenceNumber) { | |
1253 LOG(LS_ERROR) << "Inconsistent configuration of send side BWE."; | |
1254 return; | |
1255 } | |
1213 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), | 1256 congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), |
1214 packet.payload_size(), header); | 1257 packet.payload_size(), header); |
1215 } | 1258 } |
1216 | 1259 |
1217 } // namespace internal | 1260 } // namespace internal |
1218 } // namespace webrtc | 1261 } // namespace webrtc |
OLD | NEW |