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
This commit is contained in:
parent
97077a3ab2
commit
fe5d36b6fe
@ -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
|
||||
// ==================================================================
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#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.
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "webrtc/modules/audio_coding/neteq4/rtcp.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
|
||||
#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<int>(cycles_) << 16) + max_seq_no_;
|
||||
stats->extended_max_sequence_number =
|
||||
(static_cast<int>(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.
|
||||
|
@ -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-'
|
||||
|
Loading…
Reference in New Issue
Block a user