Add more NetEq information to NetEqState.
Some important NetEq information was not available in NetEqState, which
meant it was not available on the API. This CL adds additional
information.
Bug: webrtc:9667
Change-Id: I702707c7d60472f488047d48fb286f839c5608dc
Reviewed-on: https://webrtc-review.googlesource.com/c/102300
Reviewed-by: Minyue Li <minyue@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24985}
diff --git a/api/test/neteq_simulator.h b/api/test/neteq_simulator.h
index ab6db9c..8ef6731 100644
--- a/api/test/neteq_simulator.h
+++ b/api/test/neteq_simulator.h
@@ -47,9 +47,16 @@
int current_delay_ms = 0;
// An indicator that packet loss occurred since the last GetAudio event.
bool packet_loss_occurred = false;
+ // An indicator that the packet buffer has been flushed since the last
+ // GetAudio event.
+ bool packet_buffer_flushed = false;
+ // Indicates if the next needed packet is available in the buffer.
+ bool next_packet_available = false;
// The inter-arrival times in ms of the packets that have arrived since the
// last GetAudio event.
std::vector<int> packet_iat_ms;
+ // The current packet size in ms.
+ int packet_size_ms = 0;
};
// Runs the simulation until we hit the next GetAudio event. If the simulation
diff --git a/modules/audio_coding/neteq/include/neteq.h b/modules/audio_coding/neteq/include/neteq.h
index 918b006..530975f 100644
--- a/modules/audio_coding/neteq/include/neteq.h
+++ b/modules/audio_coding/neteq/include/neteq.h
@@ -82,11 +82,17 @@
// NetEqLifetimeStatistics::total_samples_received.
uint64_t preemptive_samples = 0;
uint64_t accelerate_samples = 0;
+ // Count of the number of buffer flushes.
+ uint64_t packet_buffer_flushes = 0;
// The statistics below are not cumulative.
// The waiting time of the last decoded packet.
uint64_t last_waiting_time_ms = 0;
// The sum of the packet and jitter buffer size in ms.
uint64_t current_buffer_size_ms = 0;
+ // The current frame size in ms.
+ uint64_t current_frame_size_ms = 0;
+ // Flag to indicate that the next packet is available.
+ bool next_packet_available = false;
};
// This is the interface class for NetEq.
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 857a4d7..f428be1 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -378,6 +378,10 @@
(packet_buffer_->NumSamplesInBuffer(decoder_frame_length_) +
sync_buffer_->FutureLength()) *
1000 / fs_hz_;
+ result.current_frame_size_ms = decoder_frame_length_ * 1000 / fs_hz_;
+ result.next_packet_available = packet_buffer_->PeekNextPacket() &&
+ packet_buffer_->PeekNextPacket()->timestamp ==
+ sync_buffer_->end_timestamp();
return result;
}
diff --git a/modules/audio_coding/neteq/packet_buffer.cc b/modules/audio_coding/neteq/packet_buffer.cc
index c04534e..eba4d3e 100644
--- a/modules/audio_coding/neteq/packet_buffer.cc
+++ b/modules/audio_coding/neteq/packet_buffer.cc
@@ -91,6 +91,7 @@
if (buffer_.size() >= max_number_of_packets_) {
// Buffer is full. Flush it.
Flush();
+ stats->FlushedPacketBuffer();
RTC_LOG(LS_WARNING) << "Packet buffer flushed";
return_val = kFlushed;
}
diff --git a/modules/audio_coding/neteq/statistics_calculator.cc b/modules/audio_coding/neteq/statistics_calculator.cc
index 7ce156e..c0e7a40 100644
--- a/modules/audio_coding/neteq/statistics_calculator.cc
+++ b/modules/audio_coding/neteq/statistics_calculator.cc
@@ -248,6 +248,10 @@
secondary_decoded_samples_ += num_samples;
}
+void StatisticsCalculator::FlushedPacketBuffer() {
+ operations_and_state_.packet_buffer_flushes++;
+}
+
void StatisticsCalculator::LogDelayedPacketOutageEvent(int outage_duration_ms) {
RTC_HISTOGRAM_COUNTS("WebRTC.Audio.DelayedPacketOutageEventMs",
outage_duration_ms, 1 /* min */, 2000 /* max */,
diff --git a/modules/audio_coding/neteq/statistics_calculator.h b/modules/audio_coding/neteq/statistics_calculator.h
index 37540fd..9e5dacf 100644
--- a/modules/audio_coding/neteq/statistics_calculator.h
+++ b/modules/audio_coding/neteq/statistics_calculator.h
@@ -83,6 +83,9 @@
// Reports that |num_samples| samples were decoded from secondary packets.
void SecondaryDecodedSamples(int num_samples);
+ // Rerport that the packet buffer was flushed.
+ void FlushedPacketBuffer();
+
// Logs a delayed packet outage event of |outage_duration_ms|. A delayed
// packet outage event is defined as an expand period caused not by an actual
// packet loss, but by a delayed packet.
diff --git a/modules/audio_coding/neteq/tools/neteq_test.cc b/modules/audio_coding/neteq/tools/neteq_test.cc
index fdd1b24..421f380 100644
--- a/modules/audio_coding/neteq/tools/neteq_test.cc
+++ b/modules/audio_coding/neteq/tools/neteq_test.cc
@@ -155,6 +155,12 @@
input_->NextEventTime().value_or(time_now_ms) - start_time_ms;
const auto operations_state = neteq_->GetOperationsAndState();
current_state_.current_delay_ms = operations_state.current_buffer_size_ms;
+ current_state_.packet_size_ms = operations_state.current_frame_size_ms;
+ current_state_.next_packet_available =
+ operations_state.next_packet_available;
+ current_state_.packet_buffer_flushed =
+ operations_state.packet_buffer_flushes >
+ prev_ops_state_.packet_buffer_flushes;
// TODO(ivoc): Add more accurate reporting by tracking the origin of
// samples in the sync buffer.
result.action_times_ms[Action::kExpand] = 0;