Avoid depending on codec info for audio jitter stat.
The clock rate is already known by the RTP statistician.
Also included some minor code cleanup.
Bug: b/331602608
Change-Id: I335fa2a1cfd7dcceb286706d295a175a92f6797c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/368920
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Jakob Ivarsson‎ <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43436}
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index d693a47..6864a6b 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -255,25 +255,35 @@
webrtc::AudioReceiveStreamInterface::Stats stats;
stats.remote_ssrc = remote_ssrc();
- webrtc::CallReceiveStatistics call_stats =
- channel_receive_->GetRTCPStatistics();
auto receive_codec = channel_receive_->GetReceiveCodec();
if (receive_codec) {
stats.codec_name = receive_codec->second.name;
stats.codec_payload_type = receive_codec->first;
- int clockrate_khz = receive_codec->second.clockrate_hz / 1000;
- if (clockrate_khz > 0) {
- stats.jitter_ms = call_stats.jitterSamples / clockrate_khz;
- }
}
+
+ webrtc::CallReceiveStatistics call_stats =
+ channel_receive_->GetRTCPStatistics();
stats.payload_bytes_received = call_stats.payload_bytes_received;
stats.header_and_padding_bytes_received =
call_stats.header_and_padding_bytes_received;
- stats.packets_received = call_stats.packetsReceived;
- stats.packets_lost = call_stats.cumulativeLost;
+ stats.packets_received = call_stats.packets_received;
+ stats.packets_lost = call_stats.packets_lost;
+ stats.jitter_ms = call_stats.jitter_ms;
stats.nacks_sent = call_stats.nacks_sent;
- stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms_;
+ stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms;
stats.last_packet_received = call_stats.last_packet_received;
+ stats.last_sender_report_timestamp = call_stats.last_sender_report_timestamp;
+ stats.last_sender_report_utc_timestamp =
+ call_stats.last_sender_report_utc_timestamp;
+ stats.last_sender_report_remote_utc_timestamp =
+ call_stats.last_sender_report_remote_utc_timestamp;
+ stats.sender_reports_packets_sent = call_stats.sender_reports_packets_sent;
+ stats.sender_reports_bytes_sent = call_stats.sender_reports_bytes_sent;
+ stats.sender_reports_reports_count = call_stats.sender_reports_reports_count;
+ stats.round_trip_time = call_stats.round_trip_time;
+ stats.round_trip_time_measurements = call_stats.round_trip_time_measurements;
+ stats.total_round_trip_time = call_stats.total_round_trip_time;
+
stats.delay_estimate_ms = channel_receive_->GetDelayEstimate();
stats.audio_level = channel_receive_->GetSpeechOutputLevelFullRange();
stats.total_output_energy = channel_receive_->GetTotalOutputEnergy();
@@ -332,18 +342,6 @@
stats.decoding_plc_cng = ds.decoded_plc_cng;
stats.decoding_muted_output = ds.decoded_muted_output;
- stats.last_sender_report_timestamp = call_stats.last_sender_report_timestamp;
- stats.last_sender_report_utc_timestamp =
- call_stats.last_sender_report_utc_timestamp;
- stats.last_sender_report_remote_utc_timestamp =
- call_stats.last_sender_report_remote_utc_timestamp;
- stats.sender_reports_packets_sent = call_stats.sender_reports_packets_sent;
- stats.sender_reports_bytes_sent = call_stats.sender_reports_bytes_sent;
- stats.sender_reports_reports_count = call_stats.sender_reports_reports_count;
- stats.round_trip_time = call_stats.round_trip_time;
- stats.round_trip_time_measurements = call_stats.round_trip_time_measurements;
- stats.total_round_trip_time = call_stats.total_round_trip_time;
-
return stats;
}
diff --git a/audio/audio_receive_stream_unittest.cc b/audio/audio_receive_stream_unittest.cc
index 0afda40..0320510 100644
--- a/audio/audio_receive_stream_unittest.cc
+++ b/audio/audio_receive_stream_unittest.cc
@@ -250,13 +250,11 @@
EXPECT_EQ(kCallStats.payload_bytes_received, stats.payload_bytes_received);
EXPECT_EQ(kCallStats.header_and_padding_bytes_received,
stats.header_and_padding_bytes_received);
- EXPECT_EQ(static_cast<uint32_t>(kCallStats.packetsReceived),
+ EXPECT_EQ(static_cast<uint32_t>(kCallStats.packets_received),
stats.packets_received);
- EXPECT_EQ(kCallStats.cumulativeLost, stats.packets_lost);
+ EXPECT_EQ(kCallStats.packets_lost, stats.packets_lost);
EXPECT_EQ(kReceiveCodec.second.name, stats.codec_name);
- EXPECT_EQ(
- kCallStats.jitterSamples / (kReceiveCodec.second.clockrate_hz / 1000),
- stats.jitter_ms);
+ EXPECT_EQ(kCallStats.jitter_ms, stats.jitter_ms);
EXPECT_EQ(kNetworkStats.currentBufferSize, stats.jitter_buffer_ms);
EXPECT_EQ(kNetworkStats.preferredBufferSize,
stats.jitter_buffer_preferred_ms);
@@ -320,7 +318,7 @@
EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng);
EXPECT_EQ(kAudioDecodeStats.decoded_muted_output,
stats.decoding_muted_output);
- EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_,
+ EXPECT_EQ(kCallStats.capture_start_ntp_time_ms,
stats.capture_start_ntp_time_ms);
EXPECT_EQ(kPlayoutNtpTimestampMs, stats.estimated_playout_ntp_timestamp_ms);
recv_stream->UnregisterFromTransport();
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc
index ea4c912..43b7d3e 100644
--- a/audio/channel_receive.cc
+++ b/audio/channel_receive.cc
@@ -839,23 +839,17 @@
rtp_stats = statistician->GetStats();
}
- stats.cumulativeLost = rtp_stats.packets_lost;
- stats.jitterSamples = rtp_stats.jitter;
+ stats.packets_lost = rtp_stats.packets_lost;
+ stats.jitter_ms = rtp_stats.interarrival_jitter.ms();
// Data counters.
if (statistician) {
stats.payload_bytes_received = rtp_stats.packet_counter.payload_bytes;
-
stats.header_and_padding_bytes_received =
rtp_stats.packet_counter.header_bytes +
rtp_stats.packet_counter.padding_bytes;
- stats.packetsReceived = rtp_stats.packet_counter.packets;
+ stats.packets_received = rtp_stats.packet_counter.packets;
stats.last_packet_received = rtp_stats.last_packet_received;
- } else {
- stats.payload_bytes_received = 0;
- stats.header_and_padding_bytes_received = 0;
- stats.packetsReceived = 0;
- stats.last_packet_received = std::nullopt;
}
{
@@ -866,7 +860,7 @@
// Timestamps.
{
MutexLock lock(&ts_stats_lock_);
- stats.capture_start_ntp_time_ms_ = capture_start_ntp_time_ms_;
+ stats.capture_start_ntp_time_ms = capture_start_ntp_time_ms_;
}
std::optional<RtpRtcpInterface::SenderReportStats> rtcp_sr_stats =
diff --git a/audio/channel_receive.h b/audio/channel_receive.h
index fbc7f1e..cb19535 100644
--- a/audio/channel_receive.h
+++ b/audio/channel_receive.h
@@ -50,15 +50,15 @@
class RtpRtcp;
struct CallReceiveStatistics {
- int cumulativeLost;
- unsigned int jitterSamples;
+ int packets_lost = 0;
+ uint32_t jitter_ms = 0;
int64_t payload_bytes_received = 0;
int64_t header_and_padding_bytes_received = 0;
- int packetsReceived;
+ int packets_received = 0;
uint32_t nacks_sent = 0;
// The capture NTP time (in local timebase) of the first played out audio
// frame.
- int64_t capture_start_ntp_time_ms_;
+ int64_t capture_start_ntp_time_ms = 0;
// The timestamp at which the last packet was received, i.e. the time of the
// local clock when it was received - not the RTP timestamp of that packet.
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp
@@ -77,7 +77,7 @@
uint64_t sender_reports_reports_count = 0;
std::optional<TimeDelta> round_trip_time;
TimeDelta total_round_trip_time = TimeDelta::Zero();
- int round_trip_time_measurements;
+ int round_trip_time_measurements = 0;
};
namespace voe {
diff --git a/audio/channel_receive_unittest.cc b/audio/channel_receive_unittest.cc
index 1c04fc9..289637c 100644
--- a/audio/channel_receive_unittest.cc
+++ b/audio/channel_receive_unittest.cc
@@ -151,7 +151,7 @@
channel.OnRtpPacket(CreateRtpPacket());
channel.GetAudioFrameWithInfo(kSampleRateHz, &audio_frame);
CallReceiveStatistics stats = channel.GetRTCPStatistics();
- return stats.capture_start_ntp_time_ms_;
+ return stats.capture_start_ntp_time_ms;
}
protected: