OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 _callbackCritSectPtr(NULL), | 898 _callbackCritSectPtr(NULL), |
899 _transportPtr(NULL), | 899 _transportPtr(NULL), |
900 input_mute_(false), | 900 input_mute_(false), |
901 previous_frame_muted_(false), | 901 previous_frame_muted_(false), |
902 _outputGain(1.0f), | 902 _outputGain(1.0f), |
903 _mixFileWithMicrophone(false), | 903 _mixFileWithMicrophone(false), |
904 _includeAudioLevelIndication(false), | 904 _includeAudioLevelIndication(false), |
905 transport_overhead_per_packet_(0), | 905 transport_overhead_per_packet_(0), |
906 rtp_overhead_per_packet_(0), | 906 rtp_overhead_per_packet_(0), |
907 _outputSpeechType(AudioFrame::kNormalSpeech), | 907 _outputSpeechType(AudioFrame::kNormalSpeech), |
908 restored_packet_in_use_(false), | |
909 rtcp_observer_(new VoERtcpObserver(this)), | 908 rtcp_observer_(new VoERtcpObserver(this)), |
910 associate_send_channel_(ChannelOwner(nullptr)), | 909 associate_send_channel_(ChannelOwner(nullptr)), |
911 pacing_enabled_(config.enable_voice_pacing), | 910 pacing_enabled_(config.enable_voice_pacing), |
912 feedback_observer_proxy_(new TransportFeedbackProxy()), | 911 feedback_observer_proxy_(new TransportFeedbackProxy()), |
913 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), | 912 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), |
914 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), | 913 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), |
915 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), | 914 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), |
916 kMaxRetransmissionWindowMs)), | 915 kMaxRetransmissionWindowMs)), |
917 decoder_factory_(config.acm_config.decoder_factory), | 916 decoder_factory_(config.acm_config.decoder_factory), |
918 use_twcc_plr_for_ana_( | 917 use_twcc_plr_for_ana_( |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 | 1739 |
1741 RTPHeader header; | 1740 RTPHeader header; |
1742 packet.GetHeader(&header); | 1741 packet.GetHeader(&header); |
1743 OnRtpPacketWithHeader(packet.data(), packet.size(), &header); | 1742 OnRtpPacketWithHeader(packet.data(), packet.size(), &header); |
1744 } | 1743 } |
1745 | 1744 |
1746 bool Channel::ReceivePacket(const uint8_t* packet, | 1745 bool Channel::ReceivePacket(const uint8_t* packet, |
1747 size_t packet_length, | 1746 size_t packet_length, |
1748 const RTPHeader& header, | 1747 const RTPHeader& header, |
1749 bool in_order) { | 1748 bool in_order) { |
1750 if (rtp_payload_registry_->IsRtx(header)) { | |
1751 return HandleRtxPacket(packet, packet_length, header); | |
1752 } | |
1753 const uint8_t* payload = packet + header.headerLength; | 1749 const uint8_t* payload = packet + header.headerLength; |
1754 assert(packet_length >= header.headerLength); | 1750 assert(packet_length >= header.headerLength); |
1755 size_t payload_length = packet_length - header.headerLength; | 1751 size_t payload_length = packet_length - header.headerLength; |
1756 PayloadUnion payload_specific; | 1752 PayloadUnion payload_specific; |
1757 if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, | 1753 if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, |
1758 &payload_specific)) { | 1754 &payload_specific)) { |
1759 return false; | 1755 return false; |
1760 } | 1756 } |
1761 return rtp_receiver_->IncomingRtpPacket(header, payload, payload_length, | 1757 return rtp_receiver_->IncomingRtpPacket(header, payload, payload_length, |
1762 payload_specific, in_order); | 1758 payload_specific, in_order); |
1763 } | 1759 } |
1764 | 1760 |
1765 bool Channel::HandleRtxPacket(const uint8_t* packet, | |
1766 size_t packet_length, | |
1767 const RTPHeader& header) { | |
1768 if (!rtp_payload_registry_->IsRtx(header)) | |
1769 return false; | |
1770 | |
1771 // Remove the RTX header and parse the original RTP header. | |
1772 if (packet_length < header.headerLength) | |
1773 return false; | |
1774 if (packet_length > kVoiceEngineMaxIpPacketSizeBytes) | |
1775 return false; | |
1776 if (restored_packet_in_use_) { | |
1777 WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVoice, _channelId, | |
1778 "Multiple RTX headers detected, dropping packet"); | |
1779 return false; | |
1780 } | |
1781 if (!rtp_payload_registry_->RestoreOriginalPacket( | |
1782 restored_packet_, packet, &packet_length, rtp_receiver_->SSRC(), | |
1783 header)) { | |
1784 WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVoice, _channelId, | |
1785 "Incoming RTX packet: invalid RTP header"); | |
1786 return false; | |
1787 } | |
1788 restored_packet_in_use_ = true; | |
1789 bool ret = OnRecoveredPacket(restored_packet_, packet_length); | |
1790 restored_packet_in_use_ = false; | |
1791 return ret; | |
1792 } | |
1793 | |
1794 bool Channel::IsPacketInOrder(const RTPHeader& header) const { | 1761 bool Channel::IsPacketInOrder(const RTPHeader& header) const { |
1795 StreamStatistician* statistician = | 1762 StreamStatistician* statistician = |
1796 rtp_receive_statistics_->GetStatistician(header.ssrc); | 1763 rtp_receive_statistics_->GetStatistician(header.ssrc); |
1797 if (!statistician) | 1764 if (!statistician) |
1798 return false; | 1765 return false; |
1799 return statistician->IsPacketInOrder(header.sequenceNumber); | 1766 return statistician->IsPacketInOrder(header.sequenceNumber); |
1800 } | 1767 } |
1801 | 1768 |
1802 bool Channel::IsPacketRetransmitted(const RTPHeader& header, | 1769 bool Channel::IsPacketRetransmitted(const RTPHeader& header, |
1803 bool in_order) const { | 1770 bool in_order) const { |
1804 // Retransmissions are handled separately if RTX is enabled. | |
1805 if (rtp_payload_registry_->RtxEnabled()) | |
1806 return false; | |
1807 StreamStatistician* statistician = | 1771 StreamStatistician* statistician = |
1808 rtp_receive_statistics_->GetStatistician(header.ssrc); | 1772 rtp_receive_statistics_->GetStatistician(header.ssrc); |
1809 if (!statistician) | 1773 if (!statistician) |
1810 return false; | 1774 return false; |
1811 // Check if this is a retransmission. | 1775 // Check if this is a retransmission. |
1812 int64_t min_rtt = 0; | 1776 int64_t min_rtt = 0; |
1813 _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL); | 1777 _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL); |
1814 return !in_order && statistician->IsRetransmitOfOldPacket(header, min_rtt); | 1778 return !in_order && statistician->IsRetransmitOfOldPacket(header, min_rtt); |
1815 } | 1779 } |
1816 | 1780 |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3165 int64_t min_rtt = 0; | 3129 int64_t min_rtt = 0; |
3166 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3130 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3167 0) { | 3131 0) { |
3168 return 0; | 3132 return 0; |
3169 } | 3133 } |
3170 return rtt; | 3134 return rtt; |
3171 } | 3135 } |
3172 | 3136 |
3173 } // namespace voe | 3137 } // namespace voe |
3174 } // namespace webrtc | 3138 } // namespace webrtc |
OLD | NEW |