Rename discarded_primary_packets to packets_discarded.

This it what it is called in the spec:
https://w3c.github.io/webrtc-stats/#dom-rtcreceivedrtpstreamstats-packetsdiscarded

Also log the metric in neteq_rtpplay.

Bug: webrtc:8199
Change-Id: Ie0262d17b913eb6949daa703844d90327eee0aa4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/263725
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Jakob Ivarsson‎ <jakobi@webrtc.org>
Reviewed-by: Jakob Ivarsson‎ <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37063}
This commit is contained in:
Jakob Ivarsson
2022-05-25 22:00:14 +02:00
committed by WebRTC LUCI CQ
parent c4b5f4da97
commit 1a5a81340d
7 changed files with 23 additions and 32 deletions

View File

@ -72,6 +72,7 @@ struct NetEqLifetimeStatistics {
uint64_t silent_concealed_samples = 0; uint64_t silent_concealed_samples = 0;
uint64_t fec_packets_received = 0; uint64_t fec_packets_received = 0;
uint64_t fec_packets_discarded = 0; uint64_t fec_packets_discarded = 0;
uint64_t packets_discarded = 0;
// Below stats are not part of the spec. // Below stats are not part of the spec.
uint64_t delayed_packet_outage_samples = 0; uint64_t delayed_packet_outage_samples = 0;
// This is sum of relative packet arrival delays of received packets so far. // This is sum of relative packet arrival delays of received packets so far.
@ -102,8 +103,6 @@ struct NetEqOperationsAndState {
uint64_t accelerate_samples = 0; uint64_t accelerate_samples = 0;
// Count of the number of buffer flushes. // Count of the number of buffer flushes.
uint64_t packet_buffer_flushes = 0; uint64_t packet_buffer_flushes = 0;
// The number of primary packets that were discarded.
uint64_t discarded_primary_packets = 0;
// The statistics below are not cumulative. // The statistics below are not cumulative.
// The waiting time of the last decoded packet. // The waiting time of the last decoded packet.
uint64_t last_waiting_time_ms = 0; uint64_t last_waiting_time_ms = 0;

View File

@ -302,13 +302,12 @@ void AcmReceiver::GetNetworkStatistics(
neteq_lifetime_stat.removed_samples_for_acceleration; neteq_lifetime_stat.removed_samples_for_acceleration;
acm_stat->fecPacketsReceived = neteq_lifetime_stat.fec_packets_received; acm_stat->fecPacketsReceived = neteq_lifetime_stat.fec_packets_received;
acm_stat->fecPacketsDiscarded = neteq_lifetime_stat.fec_packets_discarded; acm_stat->fecPacketsDiscarded = neteq_lifetime_stat.fec_packets_discarded;
acm_stat->packetsDiscarded = neteq_lifetime_stat.packets_discarded;
NetEqOperationsAndState neteq_operations_and_state = NetEqOperationsAndState neteq_operations_and_state =
neteq_->GetOperationsAndState(); neteq_->GetOperationsAndState();
acm_stat->packetBufferFlushes = acm_stat->packetBufferFlushes =
neteq_operations_and_state.packet_buffer_flushes; neteq_operations_and_state.packet_buffer_flushes;
acm_stat->packetsDiscarded =
neteq_operations_and_state.discarded_primary_packets;
} }
int AcmReceiver::EnableNack(size_t max_nack_list_size) { int AcmReceiver::EnableNack(size_t max_nack_list_size) {

View File

@ -651,8 +651,8 @@ TEST_F(NetEqImplTest, ReorderedPacket) {
// out-of-order packet should have been discarded. // out-of-order packet should have been discarded.
EXPECT_TRUE(packet_buffer_->Empty()); EXPECT_TRUE(packet_buffer_->Empty());
// NetEq `discarded_primary_packets` should capture this packet discard. // NetEq `packets_discarded` should capture this packet discard.
EXPECT_EQ(1u, neteq_->GetOperationsAndState().discarded_primary_packets); EXPECT_EQ(1u, neteq_->GetLifetimeStatistics().packets_discarded);
// Verify `output.packet_infos_`. Expect to only see the second packet. // Verify `output.packet_infos_`. Expect to only see the second packet.
ASSERT_THAT(output.packet_infos_, SizeIs(1)); ASSERT_THAT(output.packet_infos_, SizeIs(1));

View File

@ -235,7 +235,7 @@ void StatisticsCalculator::GeneratedNoiseSamples(size_t num_samples) {
} }
void StatisticsCalculator::PacketsDiscarded(size_t num_packets) { void StatisticsCalculator::PacketsDiscarded(size_t num_packets) {
operations_and_state_.discarded_primary_packets += num_packets; lifetime_stats_.packets_discarded += num_packets;
} }
void StatisticsCalculator::SecondaryPacketsDiscarded(size_t num_packets) { void StatisticsCalculator::SecondaryPacketsDiscarded(size_t num_packets) {

View File

@ -179,37 +179,28 @@ TEST(StatisticsCalculator, InterruptionCounterDoNotLogBeforeDecoding) {
EXPECT_EQ(1, lts.interruption_count); EXPECT_EQ(1, lts.interruption_count);
} }
// Test that |discarded_primary_packets| as reported from
// |GetOperationsAndState| always matches the arguments to |PacketsDiscarded|
// accumulated.
TEST(StatisticsCalculator, DiscardedPackets) { TEST(StatisticsCalculator, DiscardedPackets) {
StatisticsCalculator statistics_calculator; StatisticsCalculator statistics_calculator;
EXPECT_EQ( EXPECT_EQ(0u,
0u, statistics_calculator.GetLifetimeStatistics().packets_discarded);
statistics_calculator.GetOperationsAndState().discarded_primary_packets);
statistics_calculator.PacketsDiscarded(1); statistics_calculator.PacketsDiscarded(1);
EXPECT_EQ( EXPECT_EQ(1u,
1u, statistics_calculator.GetLifetimeStatistics().packets_discarded);
statistics_calculator.GetOperationsAndState().discarded_primary_packets);
statistics_calculator.PacketsDiscarded(10); statistics_calculator.PacketsDiscarded(10);
EXPECT_EQ( EXPECT_EQ(11u,
11u, statistics_calculator.GetLifetimeStatistics().packets_discarded);
statistics_calculator.GetOperationsAndState().discarded_primary_packets);
// Calling |SecondaryPacketsDiscarded| does not modify // Calling `SecondaryPacketsDiscarded` does not modify `packets_discarded`.
// |discarded_primary_packets|.
statistics_calculator.SecondaryPacketsDiscarded(1); statistics_calculator.SecondaryPacketsDiscarded(1);
EXPECT_EQ( EXPECT_EQ(11u,
11u, statistics_calculator.GetLifetimeStatistics().packets_discarded);
statistics_calculator.GetOperationsAndState().discarded_primary_packets);
// Calling |FlushedPacketBuffer| does not modify |discarded_primary_packets|. // Calling `FlushedPacketBuffer` does not modify `packets_discarded`.
statistics_calculator.FlushedPacketBuffer(); statistics_calculator.FlushedPacketBuffer();
EXPECT_EQ( EXPECT_EQ(11u,
11u, statistics_calculator.GetLifetimeStatistics().packets_discarded);
statistics_calculator.GetOperationsAndState().discarded_primary_packets);
} }
} // namespace webrtc } // namespace webrtc

View File

@ -100,6 +100,8 @@ void NetEqStatsPlotter::SimulationEnded(int64_t simulation_time_ms) {
lifetime_stats.inserted_samples_for_deceleration); lifetime_stats.inserted_samples_for_deceleration);
printf(" generated_noise_samples: %" PRIu64 "\n", printf(" generated_noise_samples: %" PRIu64 "\n",
lifetime_stats.generated_noise_samples); lifetime_stats.generated_noise_samples);
printf(" packets_discarded: %" PRIu64 "\n",
lifetime_stats.packets_discarded);
} }
} }

View File

@ -248,11 +248,11 @@ NetEqTest::SimulationStepResult NetEqTest::RunToNextGetAudio() {
<< ", voice concealed: " << voice_concealed << ", voice concealed: " << voice_concealed
<< ", buffer size: " << std::setw(4) << ", buffer size: " << std::setw(4)
<< current_state_.current_delay_ms << std::endl; << current_state_.current_delay_ms << std::endl;
if (operations_state.discarded_primary_packets > if (lifetime_stats.packets_discarded >
prev_ops_state_.discarded_primary_packets) { prev_lifetime_stats_.packets_discarded) {
*text_log_ << "Discarded " *text_log_ << "Discarded "
<< (operations_state.discarded_primary_packets - << (lifetime_stats.packets_discarded -
prev_ops_state_.discarded_primary_packets) prev_lifetime_stats_.packets_discarded)
<< " primary packets." << std::endl; << " primary packets." << std::endl;
} }
if (operations_state.packet_buffer_flushes > if (operations_state.packet_buffer_flushes >