From fe5d36b6fe3867ebd56d7285cd56b9aa57bb1ede Mon Sep 17 00:00:00 2001 From: "sprang@webrtc.org" Date: Mon, 28 Oct 2013 09:21:07 +0000 Subject: [PATCH] Move RtcpStatistics to webrtc/common_types.h, to be used by vie as well. We will do some refactoring of video engine and would like to use the same rtcp stats struct there. Both video and audio seem to use 8bit fraction lost, so that is changed in the struct as well. BUG= R=henrik.lundin@webrtc.org, kjellander@webrtc.org, mflodman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2959004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5039 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/common_types.h | 16 ++++++++++++++++ .../audio_coding/neteq4/interface/neteq.h | 9 +-------- .../audio_coding/neteq4/neteq_unittest.cc | 11 +++++++---- webrtc/modules/audio_coding/neteq4/rtcp.cc | 12 ++++++------ webrtc/tools/update_resources.py | 2 +- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/webrtc/common_types.h b/webrtc/common_types.h index 7e88666ab..b736a2fde 100644 --- a/webrtc/common_types.h +++ b/webrtc/common_types.h @@ -225,6 +225,22 @@ protected: Transport() {} }; +struct RtcpStatistics { + public: + RtcpStatistics() + : fraction_lost(0), + cumulative_lost(0), + extended_max_sequence_number(0), + jitter(0), + max_jitter(0) {} + + uint8_t fraction_lost; + uint32_t cumulative_lost; + uint32_t extended_max_sequence_number; + uint32_t jitter; + uint32_t max_jitter; +}; + // ================================================================== // Voice specific types // ================================================================== diff --git a/webrtc/modules/audio_coding/neteq4/interface/neteq.h b/webrtc/modules/audio_coding/neteq4/interface/neteq.h index ded87f58b..617393093 100644 --- a/webrtc/modules/audio_coding/neteq4/interface/neteq.h +++ b/webrtc/modules/audio_coding/neteq4/interface/neteq.h @@ -15,6 +15,7 @@ #include +#include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/neteq4/interface/audio_decoder.h" #include "webrtc/system_wrappers/interface/constructor_magic.h" #include "webrtc/typedefs.h" @@ -24,14 +25,6 @@ namespace webrtc { // Forward declarations. struct WebRtcRTPHeader; -// RTCP statistics. -struct RtcpStatistics { - uint16_t fraction_lost; - uint32_t cumulative_lost; - uint32_t extended_max; - uint32_t jitter; -}; - struct NetEqNetworkStatistics { uint16_t current_buffer_size_ms; // Current jitter buffer size in ms. uint16_t preferred_buffer_size_ms; // Target buffer size in ms. diff --git a/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc index bc2a9de17..1b1e950a8 100644 --- a/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc +++ b/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc @@ -149,7 +149,8 @@ void RefFiles::WriteToFile(const RtcpStatistics& stats) { output_fp_)); ASSERT_EQ(1u, fwrite(&(stats.cumulative_lost), sizeof(stats.cumulative_lost), 1, output_fp_)); - ASSERT_EQ(1u, fwrite(&(stats.extended_max), sizeof(stats.extended_max), 1, + ASSERT_EQ(1u, fwrite(&(stats.extended_max_sequence_number), + sizeof(stats.extended_max_sequence_number), 1, output_fp_)); ASSERT_EQ(1u, fwrite(&(stats.jitter), sizeof(stats.jitter), 1, output_fp_)); @@ -165,14 +166,16 @@ void RefFiles::ReadFromFileAndCompare( sizeof(ref_stats.fraction_lost), 1, input_fp_)); ASSERT_EQ(1u, fread(&(ref_stats.cumulative_lost), sizeof(ref_stats.cumulative_lost), 1, input_fp_)); - ASSERT_EQ(1u, fread(&(ref_stats.extended_max), - sizeof(ref_stats.extended_max), 1, input_fp_)); + ASSERT_EQ(1u, fread(&(ref_stats.extended_max_sequence_number), + sizeof(ref_stats.extended_max_sequence_number), 1, + input_fp_)); ASSERT_EQ(1u, fread(&(ref_stats.jitter), sizeof(ref_stats.jitter), 1, input_fp_)); // Compare EXPECT_EQ(ref_stats.fraction_lost, stats.fraction_lost); EXPECT_EQ(ref_stats.cumulative_lost, stats.cumulative_lost); - EXPECT_EQ(ref_stats.extended_max, stats.extended_max); + EXPECT_EQ(ref_stats.extended_max_sequence_number, + stats.extended_max_sequence_number); EXPECT_EQ(ref_stats.jitter, stats.jitter); } } diff --git a/webrtc/modules/audio_coding/neteq4/rtcp.cc b/webrtc/modules/audio_coding/neteq4/rtcp.cc index 357247146..f9dcf4491 100644 --- a/webrtc/modules/audio_coding/neteq4/rtcp.cc +++ b/webrtc/modules/audio_coding/neteq4/rtcp.cc @@ -10,6 +10,7 @@ #include "webrtc/modules/audio_coding/neteq4/rtcp.h" +#include #include #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" @@ -54,12 +55,14 @@ void Rtcp::Update(const RTPHeader& rtp_header, uint32_t receive_timestamp) { void Rtcp::GetStatistics(bool no_reset, RtcpStatistics* stats) { // Extended highest sequence number received. - stats->extended_max = (static_cast(cycles_) << 16) + max_seq_no_; + stats->extended_max_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_max - base_seq_no_ + 1; + uint32_t expected_packets = + stats->extended_max_sequence_number - base_seq_no_ + 1; if (received_packets_ == 0) { // No packets received, assume none lost. stats->cumulative_lost = 0; @@ -83,10 +86,7 @@ void Rtcp::GetStatistics(bool no_reset, RtcpStatistics* stats) { if (expected_since_last == 0 || lost <= 0 || received_packets_ == 0) { stats->fraction_lost = 0; } else { - stats->fraction_lost = (lost << 8) / expected_since_last; - } - if (stats->fraction_lost > 0xFF) { - stats->fraction_lost = 0xFF; + stats->fraction_lost = std::min(0xFFU, (lost << 8) / expected_since_last); } stats->jitter = jitter_ >> 4; // Scaling from Q4. diff --git a/webrtc/tools/update_resources.py b/webrtc/tools/update_resources.py index d9ec564db..1cb88f4fc 100755 --- a/webrtc/tools/update_resources.py +++ b/webrtc/tools/update_resources.py @@ -18,7 +18,7 @@ import tarfile import tempfile import urllib2 -DESIRED_VERSION = 17 +DESIRED_VERSION = 18 REMOTE_URL_BASE = 'http://commondatastorage.googleapis.com/webrtc-resources' VERSION_FILENAME = 'webrtc-resources-version' FILENAME_PREFIX = 'webrtc-resources-'