From d51b3553dbe5d5041bfbd840468664d081a05624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Wed, 21 Nov 2018 13:51:24 +0100 Subject: [PATCH] Delete unused NetEq Rtcp stats. Bug: webrtc:7135 Change-Id: Ib3ca9e02b051b8b41c2eac4e43a4f1f37999bf75 Reviewed-on: https://webrtc-review.googlesource.com/c/111640 Reviewed-by: Henrik Lundin Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#25743} --- modules/audio_coding/BUILD.gn | 2 - modules/audio_coding/neteq/include/neteq.h | 7 -- modules/audio_coding/neteq/neteq_impl.cc | 19 ---- modules/audio_coding/neteq/neteq_impl.h | 9 -- modules/audio_coding/neteq/neteq_unittest.cc | 35 +------ modules/audio_coding/neteq/rtcp.cc | 96 -------------------- modules/audio_coding/neteq/rtcp.h | 56 ------------ 7 files changed, 3 insertions(+), 221 deletions(-) delete mode 100644 modules/audio_coding/neteq/rtcp.cc delete mode 100644 modules/audio_coding/neteq/rtcp.h diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index 5163d16e0a..3422665ce2 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -1025,8 +1025,6 @@ rtc_static_library("neteq") { "neteq/random_vector.h", "neteq/red_payload_splitter.cc", "neteq/red_payload_splitter.h", - "neteq/rtcp.cc", - "neteq/rtcp.h", "neteq/statistics_calculator.cc", "neteq/statistics_calculator.h", "neteq/sync_buffer.cc", diff --git a/modules/audio_coding/neteq/include/neteq.h b/modules/audio_coding/neteq/include/neteq.h index 530975f3b8..3b3d969bf3 100644 --- a/modules/audio_coding/neteq/include/neteq.h +++ b/modules/audio_coding/neteq/include/neteq.h @@ -231,13 +231,6 @@ class NetEq { // statistics are never reset. virtual NetEqOperationsAndState GetOperationsAndState() const = 0; - // Writes the current RTCP statistics to |stats|. The statistics are reset - // and a new report period is started with the call. - virtual void GetRtcpStatistics(RtcpStatistics* stats) = 0; - - // Same as RtcpStatistics(), but does not reset anything. - virtual void GetRtcpStatisticsNoReset(RtcpStatistics* stats) = 0; - // Enables post-decode VAD. When enabled, GetAudio() will return // kOutputVADPassive when the signal contains no speech. virtual void EnableVad() = 0; diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc index 6a2cbae066..68af21a24b 100644 --- a/modules/audio_coding/neteq/neteq_impl.cc +++ b/modules/audio_coding/neteq/neteq_impl.cc @@ -387,20 +387,6 @@ NetEqOperationsAndState NetEqImpl::GetOperationsAndState() const { return result; } -void NetEqImpl::GetRtcpStatistics(RtcpStatistics* stats) { - rtc::CritScope lock(&crit_sect_); - if (stats) { - rtcp_.GetStatistics(false, stats); - } -} - -void NetEqImpl::GetRtcpStatisticsNoReset(RtcpStatistics* stats) { - rtc::CritScope lock(&crit_sect_); - if (stats) { - rtcp_.GetStatistics(true, stats); - } -} - void NetEqImpl::EnableVad() { rtc::CritScope lock(&crit_sect_); assert(vad_.get()); @@ -576,8 +562,6 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, // Note: |first_packet_| will be cleared further down in this method, once // the packet has been successfully inserted into the packet buffer. - rtcp_.Init(rtp_header.sequenceNumber); - // Flush the packet buffer and DTMF buffer. packet_buffer_->Flush(); dtmf_buffer_->Flush(); @@ -592,9 +576,6 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, timestamp_ = main_timestamp; } - // Update RTCP statistics, only for regular packets. - rtcp_.Update(rtp_header, receive_timestamp); - if (nack_enabled_) { RTC_DCHECK(nack_); if (update_sample_rate_and_channels) { diff --git a/modules/audio_coding/neteq/neteq_impl.h b/modules/audio_coding/neteq/neteq_impl.h index 36990fb670..6fcaf9cce8 100644 --- a/modules/audio_coding/neteq/neteq_impl.h +++ b/modules/audio_coding/neteq/neteq_impl.h @@ -22,7 +22,6 @@ #include "modules/audio_coding/neteq/include/neteq.h" #include "modules/audio_coding/neteq/packet.h" #include "modules/audio_coding/neteq/random_vector.h" -#include "modules/audio_coding/neteq/rtcp.h" #include "modules/audio_coding/neteq/statistics_calculator.h" #include "modules/audio_coding/neteq/tick_timer.h" #include "rtc_base/constructormagic.h" @@ -170,17 +169,10 @@ class NetEqImpl : public webrtc::NetEq { // after the call. int NetworkStatistics(NetEqNetworkStatistics* stats) override; - // Writes the current RTCP statistics to |stats|. The statistics are reset - // and a new report period is started with the call. - void GetRtcpStatistics(RtcpStatistics* stats) override; - NetEqLifetimeStatistics GetLifetimeStatistics() const override; NetEqOperationsAndState GetOperationsAndState() const override; - // Same as RtcpStatistics(), but does not reset anything. - void GetRtcpStatisticsNoReset(RtcpStatistics* stats) override; - // Enables post-decode VAD. When enabled, GetAudio() will return // kOutputVADPassive when the signal contains no speech. void EnableVad() override; @@ -395,7 +387,6 @@ class NetEqImpl : public webrtc::NetEq { RTC_GUARDED_BY(crit_sect_); RandomVector random_vector_ RTC_GUARDED_BY(crit_sect_); std::unique_ptr comfort_noise_ RTC_GUARDED_BY(crit_sect_); - Rtcp rtcp_ RTC_GUARDED_BY(crit_sect_); StatisticsCalculator stats_ RTC_GUARDED_BY(crit_sect_); int fs_hz_ RTC_GUARDED_BY(crit_sect_); int fs_mult_ RTC_GUARDED_BY(crit_sect_); diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc index 2130a246ac..2aced6aa7e 100644 --- a/modules/audio_coding/neteq/neteq_unittest.cc +++ b/modules/audio_coding/neteq/neteq_unittest.cc @@ -265,7 +265,6 @@ class NetEqDecodingTest : public ::testing::Test { void DecodeAndCompare(const std::string& rtp_file, const std::string& output_checksum, const std::string& network_stats_checksum, - const std::string& rtcp_stats_checksum, bool gen_ref); static void PopulateRtpInfo(int frame_index, @@ -373,7 +372,6 @@ void NetEqDecodingTest::DecodeAndCompare( const std::string& rtp_file, const std::string& output_checksum, const std::string& network_stats_checksum, - const std::string& rtcp_stats_checksum, bool gen_ref) { OpenInputFile(rtp_file); @@ -385,10 +383,6 @@ void NetEqDecodingTest::DecodeAndCompare( gen_ref ? webrtc::test::OutputPath() + "neteq_network_stats.dat" : ""; ResultSink network_stats(stat_out_file); - std::string rtcp_out_file = - gen_ref ? webrtc::test::OutputPath() + "neteq_rtcp_stats.dat" : ""; - ResultSink rtcp_stats(rtcp_out_file); - packet_ = rtp_source_->NextPacket(); int i = 0; uint64_t last_concealed_samples = 0; @@ -425,11 +419,6 @@ void NetEqDecodingTest::DecodeAndCompare( EXPECT_NEAR( (delta_concealed_samples << 14) / delta_total_samples_received, current_network_stats.expand_rate, (2 << 14) / 100.0); - - // Process RTCPstat. - RtcpStatistics current_rtcp_stats; - neteq_->GetRtcpStatistics(¤t_rtcp_stats); - ASSERT_NO_FATAL_FAILURE(rtcp_stats.AddResult(current_rtcp_stats)); } } @@ -437,8 +426,6 @@ void NetEqDecodingTest::DecodeAndCompare( output.VerifyChecksum(output_checksum); SCOPED_TRACE("Check network stats."); network_stats.VerifyChecksum(network_stats_checksum); - SCOPED_TRACE("Check rtcp stats."); - rtcp_stats.VerifyChecksum(rtcp_stats_checksum); } void NetEqDecodingTest::PopulateRtpInfo(int frame_index, @@ -488,14 +475,8 @@ TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) { "4b2370f5c794741d2a46be5c7935c66ef3fb53e9", "4b2370f5c794741d2a46be5c7935c66ef3fb53e9"); - const std::string rtcp_stats_checksum = - PlatformChecksum("b8880bf9fed2487efbddcb8d94b9937a29ae521d", - "f3f7b3d3e71d7e635240b5373b57df6a7e4ce9d4", "not used", - "b8880bf9fed2487efbddcb8d94b9937a29ae521d", - "b8880bf9fed2487efbddcb8d94b9937a29ae521d"); - DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, - rtcp_stats_checksum, FLAG_gen_ref); + FLAG_gen_ref); } #if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ @@ -523,15 +504,8 @@ TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) { "adb3272498e436d1c019cbfd71610e9510c54497", "adb3272498e436d1c019cbfd71610e9510c54497"); - const std::string rtcp_stats_checksum = - PlatformChecksum("e37c797e3de6a64dda88c9ade7a013d022a2e1e0", - "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", - "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", - "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", - "e37c797e3de6a64dda88c9ade7a013d022a2e1e0"); - DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, - rtcp_stats_checksum, FLAG_gen_ref); + FLAG_gen_ref); } #if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ @@ -554,11 +528,8 @@ TEST_F(NetEqDecodingTest, MAYBE_TestOpusDtxBitExactness) { const std::string network_stats_checksum = "bab58dc587d956f326056d7340c96eb9d2d3cc21"; - const std::string rtcp_stats_checksum = - "ac27a7f305efb58b39bf123dccee25dee5758e63"; - DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, - rtcp_stats_checksum, FLAG_gen_ref); + FLAG_gen_ref); } // Use fax mode to avoid time-scaling. This is to simplify the testing of diff --git a/modules/audio_coding/neteq/rtcp.cc b/modules/audio_coding/neteq/rtcp.cc deleted file mode 100644 index 65193370dc..0000000000 --- a/modules/audio_coding/neteq/rtcp.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/audio_coding/neteq/rtcp.h" - -#include -#include - -#include "api/rtp_headers.h" -#include "common_types.h" -#include "rtc_base/checks.h" - -namespace webrtc { - -void Rtcp::Init(uint16_t start_sequence_number) { - cycles_ = 0; - max_seq_no_ = start_sequence_number; - base_seq_no_ = start_sequence_number; - received_packets_ = 0; - received_packets_prior_ = 0; - expected_prior_ = 0; - jitter_ = 0; - transit_ = 0; -} - -void Rtcp::Update(const RTPHeader& rtp_header, uint32_t receive_timestamp) { - // Update number of received packets, and largest packet number received. - received_packets_++; - int16_t sn_diff = rtp_header.sequenceNumber - max_seq_no_; - if (sn_diff >= 0) { - if (rtp_header.sequenceNumber < max_seq_no_) { - // Wrap-around detected. - cycles_++; - } - max_seq_no_ = rtp_header.sequenceNumber; - } - - // Calculate jitter according to RFC 3550, and update previous timestamps. - // Note that the value in |jitter_| is in Q4. - if (received_packets_ > 1) { - int32_t ts_diff = receive_timestamp - (rtp_header.timestamp - transit_); - int64_t jitter_diff = (std::abs(int64_t{ts_diff}) << 4) - jitter_; - // Calculate 15 * jitter_ / 16 + jitter_diff / 16 (with proper rounding). - jitter_ = jitter_ + ((jitter_diff + 8) >> 4); - RTC_DCHECK_GE(jitter_, 0); - } - transit_ = rtp_header.timestamp - receive_timestamp; -} - -void Rtcp::GetStatistics(bool no_reset, RtcpStatistics* stats) { - // Extended highest sequence number received. - stats->extended_highest_sequence_number = - (static_cast(cycles_) << 16) + max_seq_no_; - - // Calculate expected number of packets and compare it with the number of - // packets that were actually received. The cumulative number of lost packets - // can be extracted. - uint32_t expected_packets = - stats->extended_highest_sequence_number - base_seq_no_ + 1; - if (received_packets_ == 0) { - // No packets received, assume none lost. - stats->packets_lost = 0; - } else if (expected_packets > received_packets_) { - stats->packets_lost = expected_packets - received_packets_; - if (stats->packets_lost > 0xFFFFFF) { - stats->packets_lost = 0xFFFFFF; - } - } else { - stats->packets_lost = 0; - } - - // Fraction lost since last report. - uint32_t expected_since_last = expected_packets - expected_prior_; - uint32_t received_since_last = received_packets_ - received_packets_prior_; - if (!no_reset) { - expected_prior_ = expected_packets; - received_packets_prior_ = received_packets_; - } - int32_t lost = expected_since_last - received_since_last; - if (expected_since_last == 0 || lost <= 0 || received_packets_ == 0) { - stats->fraction_lost = 0; - } else { - stats->fraction_lost = std::min(0xFFU, (lost << 8) / expected_since_last); - } - - stats->jitter = jitter_ >> 4; // Scaling from Q4. -} - -} // namespace webrtc diff --git a/modules/audio_coding/neteq/rtcp.h b/modules/audio_coding/neteq/rtcp.h deleted file mode 100644 index 60c2673103..0000000000 --- a/modules/audio_coding/neteq/rtcp.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_AUDIO_CODING_NETEQ_RTCP_H_ -#define MODULES_AUDIO_CODING_NETEQ_RTCP_H_ - -#include - -#include "rtc_base/constructormagic.h" - -namespace webrtc { - -struct RtcpStatistics; -struct RTPHeader; - -class Rtcp { - public: - Rtcp() { Init(0); } - - ~Rtcp() {} - - // Resets the RTCP statistics, and sets the first received sequence number. - void Init(uint16_t start_sequence_number); - - // Updates the RTCP statistics with a new received packet. - void Update(const RTPHeader& rtp_header, uint32_t receive_timestamp); - - // Returns the current RTCP statistics. If |no_reset| is true, the statistics - // are not reset, otherwise they are. - void GetStatistics(bool no_reset, RtcpStatistics* stats); - - private: - uint16_t cycles_; // The number of wrap-arounds for the sequence number. - uint16_t max_seq_no_; // The maximum sequence number received. Starts over - // from 0 after wrap-around. - uint16_t base_seq_no_; // The sequence number of the first received packet. - uint32_t received_packets_; // The number of packets that have been received. - uint32_t received_packets_prior_; // Number of packets received when last - // report was generated. - uint32_t expected_prior_; // Expected number of packets, at the time of the - // last report. - int64_t jitter_; // Current jitter value in Q4. - int32_t transit_; // Clock difference for previous packet. - - RTC_DISALLOW_COPY_AND_ASSIGN(Rtcp); -}; - -} // namespace webrtc -#endif // MODULES_AUDIO_CODING_NETEQ_RTCP_H_