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}
This commit is contained in:
Ivo Creusen
2018-09-27 11:43:42 +02:00
committed by Commit Bot
parent 32fe3d1299
commit dc6d5533e1
7 changed files with 31 additions and 0 deletions

View File

@ -47,9 +47,16 @@ class NetEqSimulator {
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

View File

@ -82,11 +82,17 @@ struct NetEqOperationsAndState {
// 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.

View File

@ -378,6 +378,10 @@ NetEqOperationsAndState NetEqImpl::GetOperationsAndState() const {
(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;
}

View File

@ -91,6 +91,7 @@ int PacketBuffer::InsertPacket(Packet&& packet, StatisticsCalculator* stats) {
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;
}

View File

@ -248,6 +248,10 @@ void StatisticsCalculator::SecondaryDecodedSamples(int num_samples) {
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 */,

View File

@ -83,6 +83,9 @@ class StatisticsCalculator {
// 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.

View File

@ -155,6 +155,12 @@ NetEqTest::SimulationStepResult NetEqTest::RunToNextGetAudio() {
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;