From 4384f5328552692780647185816a02918b09aa35 Mon Sep 17 00:00:00 2001 From: Ivo Creusen Date: Fri, 7 Sep 2018 17:19:56 +0200 Subject: Add more useful information to NetEqState and implement action_times_ms This CL adds more useful information to NetEqState, and implements setting action_times_ms, which can be used to get a better idea of what actually happened during a timestep. Bug: webrtc:9667 Change-Id: I789a3e1ad852066fdf4e9b4c96b8fb6033dacb27 Reviewed-on: https://webrtc-review.googlesource.com/98163 Reviewed-by: Minyue Li Reviewed-by: Karl Wiberg Commit-Queue: Ivo Creusen Cr-Commit-Position: refs/heads/master@{#24643} --- modules/audio_coding/neteq/tools/neteq_test.cc | 30 +++++++++++++++++++++----- modules/audio_coding/neteq/tools/neteq_test.h | 2 ++ 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/audio_coding/neteq/tools/neteq_test.cc b/modules/audio_coding/neteq/tools/neteq_test.cc index 110819c85b..08e17dc023 100644 --- a/modules/audio_coding/neteq/tools/neteq_test.cc +++ b/modules/audio_coding/neteq/tools/neteq_test.cc @@ -85,6 +85,7 @@ NetEqTest::SimulationStepResult NetEqTest::RunToNextGetAudio() { SimulationStepResult result; const int64_t start_time_ms = *input_->NextEventTime(); int64_t time_now_ms = start_time_ms; + current_state_.packet_iat_ms.clear(); while (!input_->ended()) { // Advance time to next event. @@ -105,6 +106,11 @@ NetEqTest::SimulationStepResult NetEqTest::RunToNextGetAudio() { callbacks_.post_insert_packet->AfterInsertPacket(*packet_data, neteq_.get()); } + if (last_packet_time_ms_) { + current_state_.packet_iat_ms.push_back(time_now_ms - + *last_packet_time_ms_); + } + last_packet_time_ms_ = absl::make_optional(time_now_ms); } // Check if it is time to get output audio. @@ -139,7 +145,24 @@ NetEqTest::SimulationStepResult NetEqTest::RunToNextGetAudio() { input_->AdvanceOutputEvent(); result.simulation_step_ms = time_now_ms - start_time_ms; - // TODO(ivoc): Set the result._ms values correctly. + const auto network_stats = SimulationStats(); + current_state_.current_delay_ms = network_stats.current_buffer_size_ms; + current_state_.packet_loss_occurred = network_stats.packet_loss_rate > 0; + int scaling_factor = std::max(1 << 14, network_stats.accelerate_rate + + network_stats.expand_rate + + network_stats.preemptive_rate); + // TODO(ivoc): Improve the accuracy of these numbers by adding a new API + // to NetEq. + result.action_times_ms[Action::kAccelerate] = + (10 * network_stats.accelerate_rate) / scaling_factor; + result.action_times_ms[Action::kExpand] = + (10 * network_stats.expand_rate) / scaling_factor; + result.action_times_ms[Action::kPreemptiveExpand] = + (10 * network_stats.preemptive_rate) / scaling_factor; + result.action_times_ms[Action::kNormal] = + 10 - result.action_times_ms[Action::kAccelerate] - + result.action_times_ms[Action::kExpand] - + result.action_times_ms[Action::kPreemptiveExpand]; result.is_simulation_finished = input_->ended(); return result; } @@ -154,10 +177,7 @@ void NetEqTest::SetNextAction(NetEqTest::Action next_operation) { } NetEqTest::NetEqState NetEqTest::GetNetEqState() { - NetEqState state; - const auto network_stats = SimulationStats(); - state.current_delay_ms = network_stats.current_buffer_size_ms; - return state; + return current_state_; } NetEqNetworkStatistics NetEqTest::SimulationStats() { diff --git a/modules/audio_coding/neteq/tools/neteq_test.h b/modules/audio_coding/neteq/tools/neteq_test.h index c5580456ad..787d507504 100644 --- a/modules/audio_coding/neteq/tools/neteq_test.h +++ b/modules/audio_coding/neteq/tools/neteq_test.h @@ -113,11 +113,13 @@ class NetEqTest : public NetEqSimulator { void RegisterDecoders(const DecoderMap& codecs); void RegisterExternalDecoders(const ExtDecoderMap& codecs); absl::optional next_action_; + absl::optional last_packet_time_ms_; std::unique_ptr neteq_; std::unique_ptr input_; std::unique_ptr output_; Callbacks callbacks_; int sample_rate_hz_; + NetEqState current_state_; }; } // namespace test -- cgit v1.2.3