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