aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorIvo Creusen <ivoc@webrtc.org>2018-09-07 17:19:56 +0200
committerCommit Bot <commit-bot@chromium.org>2018-09-10 09:10:53 +0000
commit4384f5328552692780647185816a02918b09aa35 (patch)
tree790f84f2e7182daad1c988ae5313a7ea2e977c4c /modules
parent7461eff1bd762b6509273f5194b24e098524e692 (diff)
downloadwebrtc-4384f5328552692780647185816a02918b09aa35.tar.gz
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 <minyue@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Ivo Creusen <ivoc@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24643}
Diffstat (limited to 'modules')
-rw-r--r--modules/audio_coding/neteq/tools/neteq_test.cc30
-rw-r--r--modules/audio_coding/neteq/tools/neteq_test.h2
2 files changed, 27 insertions, 5 deletions
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<int>(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.<action>_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<Action> next_action_;
+ absl::optional<int> last_packet_time_ms_;
std::unique_ptr<NetEq> neteq_;
std::unique_ptr<NetEqInput> input_;
std::unique_ptr<AudioSink> output_;
Callbacks callbacks_;
int sample_rate_hz_;
+ NetEqState current_state_;
};
} // namespace test