blob: 8f1cd81425ef018ae09e5be0927a1c333a837c11 [file] [log] [blame]
Ivo Creusen55de08e2018-09-03 11:49:27 +02001/*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef API_TEST_NETEQ_SIMULATOR_H_
12#define API_TEST_NETEQ_SIMULATOR_H_
13
14#include <stdint.h>
15#include <map>
16
17namespace webrtc {
18namespace test {
19
20class NetEqSimulator {
21 public:
22 virtual ~NetEqSimulator() = default;
23
24 enum class Action { kNormal, kExpand, kAccelerate, kPreemptiveExpand };
25
26 // The results of one simulation step.
27 struct SimulationStepResult {
28 SimulationStepResult();
29 SimulationStepResult(const SimulationStepResult& other);
30 ~SimulationStepResult();
31
32 bool is_simulation_finished = false;
33 // The amount of audio produced (in ms) with the actions in this time step.
34 std::map<Action, int> action_times_ms;
35 // The amount of wall clock time (in ms) that elapsed since the previous
36 // event. This is not necessarily equal to the sum of the values in
37 // action_times_ms.
38 int64_t simulation_step_ms = 0;
39 };
40
41 struct NetEqState {
42 // The sum of the packet buffer and sync buffer delay.
43 int current_delay_ms = 0;
44 // TODO(ivoc): Expand this struct with more useful metrics.
45 };
46
47 // Runs the simulation until we hit the next GetAudio event. If the simulation
48 // is finished, is_simulation_finished will be set to true in the returned
49 // SimulationStepResult.
50 virtual SimulationStepResult RunToNextGetAudio() = 0;
51
52 // Set the next action to be taken by NetEq. This will override any action
53 // that NetEq would normally decide to take.
54 virtual void SetNextAction(Action next_operation) = 0;
55
56 // Get the current state of NetEq.
57 virtual NetEqState GetNetEqState() = 0;
58};
59
60} // namespace test
61} // namespace webrtc
62
63#endif // API_TEST_NETEQ_SIMULATOR_H_