diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index a9cf2b26dc..a8345435f9 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -288,49 +288,6 @@ class RtpPacketSenderProxy : public RtpPacketSender { RtpPacketSender* rtp_packet_sender_ GUARDED_BY(&crit_); }; -// Extend the default RTCP statistics struct with max_jitter, defined as the -// maximum jitter value seen in an RTCP report block. -struct ChannelStatistics : public RtcpStatistics { - ChannelStatistics() : rtcp(), max_jitter(0) {} - - RtcpStatistics rtcp; - uint32_t max_jitter; -}; - -// Statistics callback, called at each generation of a new RTCP report block. -class StatisticsProxy : public RtcpStatisticsCallback { - public: - StatisticsProxy(uint32_t ssrc) : ssrc_(ssrc) {} - virtual ~StatisticsProxy() {} - - void StatisticsUpdated(const RtcpStatistics& statistics, - uint32_t ssrc) override { - if (ssrc != ssrc_) - return; - - rtc::CritScope cs(&stats_lock_); - stats_.rtcp = statistics; - if (statistics.jitter > stats_.max_jitter) { - stats_.max_jitter = statistics.jitter; - } - } - - void CNameChanged(const char* cname, uint32_t ssrc) override {} - - ChannelStatistics GetStats() { - rtc::CritScope cs(&stats_lock_); - return stats_; - } - - private: - // StatisticsUpdated calls are triggered from threads in the RTP module, - // while GetStats calls can be triggered from the public voice engine API, - // hence synchronization is needed. - rtc::CriticalSection stats_lock_; - const uint32_t ssrc_; - ChannelStatistics stats_; -}; - class VoERtcpObserver : public RtcpBandwidthObserver { public: explicit VoERtcpObserver(Channel* owner) @@ -575,7 +532,6 @@ int32_t Channel::OnReceivedPayloadData(const uint8_t* payloadData, WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), "received packet is discarded since playing is not" " activated"); - _numberOfDiscardedPackets++; return 0; } @@ -914,9 +870,7 @@ Channel::Channel(int32_t channelId, // random offset ntp_estimator_(Clock::GetRealTimeClock()), playout_timestamp_rtp_(0), - playout_timestamp_rtcp_(0), playout_delay_ms_(0), - _numberOfDiscardedPackets(0), send_sequence_number_(0), rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), capture_start_rtp_time_stamp_(-1), @@ -981,10 +935,6 @@ Channel::Channel(int32_t channelId, _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); _rtpRtcpModule->SetSendingMediaStatus(false); - - statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); - rtp_receive_statistics_->RegisterRtcpStatisticsCallback( - statistics_proxy_.get()); } Channel::~Channel() { @@ -1279,12 +1229,6 @@ int32_t Channel::StopSend() { return 0; } -void Channel::ResetDiscardedPacketCount() { - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), - "Channel::ResetDiscardedPacketCount()"); - _numberOfDiscardedPackets = 0; -} - int32_t Channel::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) { WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), "Channel::RegisterVoiceEngineObserver()"); @@ -2518,75 +2462,6 @@ int Channel::GetRemoteRTCP_CNAME(char cName[256]) { return 0; } -int Channel::GetRemoteRTCPData(unsigned int& NTPHigh, - unsigned int& NTPLow, - unsigned int& timestamp, - unsigned int& playoutTimestamp, - unsigned int* jitter, - unsigned short* fractionLost) { - // --- Information from sender info in received Sender Reports - - RTCPSenderInfo senderInfo; - if (_rtpRtcpModule->RemoteRTCPStat(&senderInfo) != 0) { - _engineStatisticsPtr->SetLastError( - VE_RTP_RTCP_MODULE_ERROR, kTraceError, - "GetRemoteRTCPData() failed to retrieve sender info for remote " - "side"); - return -1; - } - - // We only utilize 12 out of 20 bytes in the sender info (ignores packet - // and octet count) - NTPHigh = senderInfo.NTPseconds; - NTPLow = senderInfo.NTPfraction; - timestamp = senderInfo.RTPtimeStamp; - - // --- Locally derived information - - // This value is updated on each incoming RTCP packet (0 when no packet - // has been received) - playoutTimestamp = playout_timestamp_rtcp_; - - if (NULL != jitter || NULL != fractionLost) { - // Get all RTCP receiver report blocks that have been received on this - // channel. If we receive RTP packets from a remote source we know the - // remote SSRC and use the report block from him. - // Otherwise use the first report block. - std::vector remote_stats; - if (_rtpRtcpModule->RemoteRTCPStat(&remote_stats) != 0 || - remote_stats.empty()) { - WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), - "GetRemoteRTCPData() failed to measure statistics due" - " to lack of received RTP and/or RTCP packets"); - return -1; - } - - uint32_t remoteSSRC = rtp_receiver_->SSRC(); - std::vector::const_iterator it = remote_stats.begin(); - for (; it != remote_stats.end(); ++it) { - if (it->remoteSSRC == remoteSSRC) - break; - } - - if (it == remote_stats.end()) { - // If we have not received any RTCP packets from this SSRC it probably - // means that we have not received any RTP packets. - // Use the first received report block instead. - it = remote_stats.begin(); - remoteSSRC = it->remoteSSRC; - } - - if (jitter) { - *jitter = it->jitter; - } - - if (fractionLost) { - *fractionLost = it->fractionLost; - } - } - return 0; -} - int Channel::SendApplicationDefinedRTCPPacket( unsigned char subType, unsigned int name, @@ -2631,37 +2506,6 @@ int Channel::SendApplicationDefinedRTCPPacket( return 0; } -int Channel::GetRTPStatistics(unsigned int& averageJitterMs, - unsigned int& maxJitterMs, - unsigned int& discardedPackets) { - // The jitter statistics is updated for each received RTP packet and is - // based on received packets. - if (_rtpRtcpModule->RTCP() == RtcpMode::kOff) { - // If RTCP is off, there is no timed thread in the RTCP module regularly - // generating new stats, trigger the update manually here instead. - StreamStatistician* statistician = - rtp_receive_statistics_->GetStatistician(rtp_receiver_->SSRC()); - if (statistician) { - // Don't use returned statistics, use data from proxy instead so that - // max jitter can be fetched atomically. - RtcpStatistics s; - statistician->GetStatistics(&s, true); - } - } - - ChannelStatistics stats = statistics_proxy_->GetStats(); - const int32_t playoutFrequency = audio_coding_->PlayoutFrequency(); - if (playoutFrequency > 0) { - // Scale RTP statistics given the current playout frequency - maxJitterMs = stats.max_jitter / (playoutFrequency / 1000); - averageJitterMs = stats.rtcp.jitter / (playoutFrequency / 1000); - } - - discardedPackets = _numberOfDiscardedPackets; - - return 0; -} - int Channel::GetRemoteRTCPReportBlocks( std::vector* report_blocks) { if (report_blocks == NULL) { @@ -3219,9 +3063,7 @@ void Channel::UpdatePlayoutTimestamp(bool rtcp) { { rtc::CritScope lock(&video_sync_lock_); - if (rtcp) { - playout_timestamp_rtcp_ = playout_timestamp; - } else { + if (!rtcp) { playout_timestamp_rtp_ = playout_timestamp; } playout_delay_ms_ = delay_ms; diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h index c512c08384..6448349a8b 100644 --- a/webrtc/voice_engine/channel.h +++ b/webrtc/voice_engine/channel.h @@ -70,7 +70,6 @@ class RtcEventLogProxy; class RtcpRttStatsProxy; class RtpPacketSenderProxy; class Statistics; -class StatisticsProxy; class TransportFeedbackProxy; class TransmitMixer; class TransportSequenceNumberProxy; @@ -184,7 +183,6 @@ class Channel int32_t StopPlayout(); int32_t StartSend(); int32_t StopSend(); - void ResetDiscardedPacketCount(); int32_t RegisterVoiceEngineObserver(VoiceEngineObserver& observer); int32_t DeRegisterVoiceEngineObserver(); @@ -299,8 +297,6 @@ class Channel int GetRemoteSSRC(unsigned int& ssrc); int SetSendAudioLevelIndicationStatus(bool enable, unsigned char id); int SetReceiveAudioLevelIndicationStatus(bool enable, unsigned char id); - int SetSendAbsoluteSenderTimeStatus(bool enable, unsigned char id); - int SetReceiveAbsoluteSenderTimeStatus(bool enable, unsigned char id); void EnableSendTransportSequenceNumber(int id); void EnableReceiveTransportSequenceNumber(int id); @@ -316,19 +312,10 @@ class Channel int GetRTCPStatus(bool& enabled); int SetRTCP_CNAME(const char cName[256]); int GetRemoteRTCP_CNAME(char cName[256]); - int GetRemoteRTCPData(unsigned int& NTPHigh, - unsigned int& NTPLow, - unsigned int& timestamp, - unsigned int& playoutTimestamp, - unsigned int* jitter, - unsigned short* fractionLost); int SendApplicationDefinedRTCPPacket(unsigned char subType, unsigned int name, const char* data, unsigned short dataLengthInBytes); - int GetRTPStatistics(unsigned int& averageJitterMs, - unsigned int& maxJitterMs, - unsigned int& discardedPackets); int GetRemoteRTCPReportBlocks(std::vector* report_blocks); int GetRTPStatistics(CallStatistics& stats); int SetCodecFECStatus(bool enable); @@ -463,7 +450,6 @@ class Channel std::unique_ptr rtp_header_parser_; std::unique_ptr rtp_payload_registry_; std::unique_ptr rtp_receive_statistics_; - std::unique_ptr statistics_proxy_; std::unique_ptr rtp_receiver_; TelephoneEventHandler* telephone_event_handler_; std::unique_ptr _rtpRtcpModule; @@ -493,9 +479,7 @@ class Channel // Timestamp of the audio pulled from NetEq. rtc::Optional jitter_buffer_playout_timestamp_; uint32_t playout_timestamp_rtp_ GUARDED_BY(video_sync_lock_); - uint32_t playout_timestamp_rtcp_; uint32_t playout_delay_ms_ GUARDED_BY(video_sync_lock_); - uint32_t _numberOfDiscardedPackets; uint16_t send_sequence_number_; uint8_t restored_packet_[kVoiceEngineMaxIpPacketSizeBytes]; diff --git a/webrtc/voice_engine/include/voe_rtp_rtcp.h b/webrtc/voice_engine/include/voe_rtp_rtcp.h index 716566de32..b53deaec89 100644 --- a/webrtc/voice_engine/include/voe_rtp_rtcp.h +++ b/webrtc/voice_engine/include/voe_rtp_rtcp.h @@ -124,15 +124,6 @@ class WEBRTC_DLLEXPORT VoERTP_RTCP { bool enable, unsigned char id = 1) = 0; - // Sets the status of receiving rtp-audio-level-indication on a specific - // |channel|. - virtual int SetReceiveAudioLevelIndicationStatus(int channel, - bool enable, - unsigned char id = 1) { - // TODO(wu): Remove default implementation once talk is updated. - return 0; - } - // Sets the RTCP status on a specific |channel|. virtual int SetRTCPStatus(int channel, bool enable) = 0; @@ -143,46 +134,13 @@ class WEBRTC_DLLEXPORT VoERTP_RTCP { // specific |channel|. virtual int SetRTCP_CNAME(int channel, const char cName[256]) = 0; - // TODO(holmer): Remove this API once it has been removed from - // fakewebrtcvoiceengine.h. - virtual int GetRTCP_CNAME(int channel, char cName[256]) { return -1; } - // Gets the canonical name (CNAME) parameter for incoming RTCP reports // on a specific channel. virtual int GetRemoteRTCP_CNAME(int channel, char cName[256]) = 0; - // Gets RTCP data from incoming RTCP Sender Reports. - virtual int GetRemoteRTCPData(int channel, - unsigned int& NTPHigh, - unsigned int& NTPLow, - unsigned int& timestamp, - unsigned int& playoutTimestamp, - unsigned int* jitter = NULL, - unsigned short* fractionLost = NULL) = 0; - - // Gets RTP statistics for a specific |channel|. - virtual int GetRTPStatistics(int channel, - unsigned int& averageJitterMs, - unsigned int& maxJitterMs, - unsigned int& discardedPackets) = 0; - // Gets RTCP statistics for a specific |channel|. virtual int GetRTCPStatistics(int channel, CallStatistics& stats) = 0; - // Gets the report block parts of the last received RTCP Sender Report (SR), - // or RTCP Receiver Report (RR) on a specified |channel|. Each vector - // element also contains the SSRC of the sender in addition to a report - // block. - virtual int GetRemoteRTCPReportBlocks( - int channel, - std::vector* receive_blocks) = 0; - - // This function enables Negative Acknowledgment (NACK) using RTCP, - // implemented based on RFC 4585. NACK retransmits RTP packets if lost on - // the network. This creates a lossless transport at the expense of delay. - // If using NACK, NACK should be enabled on both endpoints in a call. - virtual int SetNACKStatus(int channel, bool enable, int maxNoPackets) = 0; - protected: VoERTP_RTCP() {} virtual ~VoERTP_RTCP() {} diff --git a/webrtc/voice_engine/voe_base_impl.cc b/webrtc/voice_engine/voe_base_impl.cc index 6432e502ad..5a037bf8ca 100644 --- a/webrtc/voice_engine/voe_base_impl.cc +++ b/webrtc/voice_engine/voe_base_impl.cc @@ -436,7 +436,6 @@ int VoEBaseImpl::StartReceive(int channel) { "StartReceive() failed to locate channel"); return -1; } - channelPtr->ResetDiscardedPacketCount(); return 0; } diff --git a/webrtc/voice_engine/voe_rtp_rtcp_impl.cc b/webrtc/voice_engine/voe_rtp_rtcp_impl.cc index 8cdb4f4779..b69ddf382d 100644 --- a/webrtc/voice_engine/voe_rtp_rtcp_impl.cc +++ b/webrtc/voice_engine/voe_rtp_rtcp_impl.cc @@ -118,38 +118,6 @@ int VoERTP_RTCPImpl::SetSendAudioLevelIndicationStatus(int channel, return channelPtr->SetSendAudioLevelIndicationStatus(enable, id); } -int VoERTP_RTCPImpl::SetReceiveAudioLevelIndicationStatus(int channel, - bool enable, - unsigned char id) { - WEBRTC_TRACE( - kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), - "SetReceiveAudioLevelIndicationStatus(channel=%d, enable=%d, id=%u)", - channel, enable, id); - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - if (enable && (id < kVoiceEngineMinRtpExtensionId || - id > kVoiceEngineMaxRtpExtensionId)) { - // [RFC5285] The 4-bit id is the local identifier of this element in - // the range 1-14 inclusive. - _shared->SetLastError( - VE_INVALID_ARGUMENT, kTraceError, - "SetReceiveAudioLevelIndicationStatus() invalid id parameter"); - return -1; - } - // Set state and id for the specified channel. - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channel_ptr = ch.channel(); - if (channel_ptr == NULL) { - _shared->SetLastError( - VE_CHANNEL_NOT_VALID, kTraceError, - "SetReceiveAudioLevelIndicationStatus() failed to locate channel"); - return -1; - } - return channel_ptr->SetReceiveAudioLevelIndicationStatus(enable, id); -} - int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable) { WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), "SetRTCPStatus(channel=%d, enable=%d)", channel, enable); @@ -215,49 +183,6 @@ int VoERTP_RTCPImpl::GetRemoteRTCP_CNAME(int channel, char cName[256]) { return channelPtr->GetRemoteRTCP_CNAME(cName); } -int VoERTP_RTCPImpl::GetRemoteRTCPData( - int channel, - unsigned int& NTPHigh, // from sender info in SR - unsigned int& NTPLow, // from sender info in SR - unsigned int& timestamp, // from sender info in SR - unsigned int& playoutTimestamp, // derived locally - unsigned int* jitter, // from report block 1 in SR/RR - unsigned short* fractionLost) // from report block 1 in SR/RR -{ - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channelPtr = ch.channel(); - if (channelPtr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "GetRemoteRTCP_CNAME() failed to locate channel"); - return -1; - } - return channelPtr->GetRemoteRTCPData(NTPHigh, NTPLow, timestamp, - playoutTimestamp, jitter, fractionLost); -} - -int VoERTP_RTCPImpl::GetRTPStatistics(int channel, - unsigned int& averageJitterMs, - unsigned int& maxJitterMs, - unsigned int& discardedPackets) { - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channelPtr = ch.channel(); - if (channelPtr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "GetRTPStatistics() failed to locate channel"); - return -1; - } - return channelPtr->GetRTPStatistics(averageJitterMs, maxJitterMs, - discardedPackets); -} - int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats) { if (!_shared->statistics().Initialized()) { _shared->SetLastError(VE_NOT_INITED, kTraceError); @@ -273,37 +198,4 @@ int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats) { return channelPtr->GetRTPStatistics(stats); } -int VoERTP_RTCPImpl::GetRemoteRTCPReportBlocks( - int channel, std::vector* report_blocks) { - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channel_ptr = ch.channel(); - if (channel_ptr == NULL) { - _shared->SetLastError( - VE_CHANNEL_NOT_VALID, kTraceError, - "GetRemoteRTCPReportBlocks() failed to locate channel"); - return -1; - } - return channel_ptr->GetRemoteRTCPReportBlocks(report_blocks); -} - -int VoERTP_RTCPImpl::SetNACKStatus(int channel, bool enable, int maxNoPackets) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), - "SetNACKStatus(channel=%d, enable=%d, maxNoPackets=%d)", channel, - enable, maxNoPackets); - - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channelPtr = ch.channel(); - if (channelPtr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "SetNACKStatus() failed to locate channel"); - return -1; - } - channelPtr->SetNACKStatus(enable, maxNoPackets); - return 0; -} - } // namespace webrtc diff --git a/webrtc/voice_engine/voe_rtp_rtcp_impl.h b/webrtc/voice_engine/voe_rtp_rtcp_impl.h index dcf28410a1..8b75682960 100644 --- a/webrtc/voice_engine/voe_rtp_rtcp_impl.h +++ b/webrtc/voice_engine/voe_rtp_rtcp_impl.h @@ -28,14 +28,6 @@ class VoERTP_RTCPImpl : public VoERTP_RTCP { int GetRemoteRTCP_CNAME(int channel, char cName[256]) override; - int GetRemoteRTCPData(int channel, - unsigned int& NTPHigh, - unsigned int& NTPLow, - unsigned int& timestamp, - unsigned int& playoutTimestamp, - unsigned int* jitter = NULL, - unsigned short* fractionLost = NULL) override; - // SSRC int SetLocalSSRC(int channel, unsigned int ssrc) override; @@ -47,25 +39,9 @@ class VoERTP_RTCPImpl : public VoERTP_RTCP { int SetSendAudioLevelIndicationStatus(int channel, bool enable, unsigned char id) override; - int SetReceiveAudioLevelIndicationStatus(int channel, - bool enable, - unsigned char id) override; - - // Statistics - int GetRTPStatistics(int channel, - unsigned int& averageJitterMs, - unsigned int& maxJitterMs, - unsigned int& discardedPackets) override; int GetRTCPStatistics(int channel, CallStatistics& stats) override; - int GetRemoteRTCPReportBlocks( - int channel, - std::vector* report_blocks) override; - - // NACK - int SetNACKStatus(int channel, bool enable, int maxNoPackets) override; - protected: VoERTP_RTCPImpl(voe::SharedData* shared); ~VoERTP_RTCPImpl() override;