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