Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 1 | /* |
| 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_FACTORY_H_ |
| 12 | #define API_TEST_NETEQ_SIMULATOR_FACTORY_H_ |
| 13 | |
| 14 | #include <memory> |
Ivo Creusen | 5ec6156 | 2019-03-20 10:52:18 +0100 | [diff] [blame] | 15 | #include <string> |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 16 | |
Ivo Creusen | 5ec6156 | 2019-03-20 10:52:18 +0100 | [diff] [blame] | 17 | #include "absl/strings/string_view.h" |
Ivo Creusen | 26d52e1 | 2020-03-24 15:59:26 +0100 | [diff] [blame] | 18 | #include "absl/types/optional.h" |
Ivo Creusen | cee751a | 2020-01-16 17:17:09 +0100 | [diff] [blame] | 19 | #include "api/neteq/neteq_factory.h" |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 20 | #include "api/test/neteq_simulator.h" |
| 21 | |
| 22 | namespace webrtc { |
| 23 | namespace test { |
| 24 | |
| 25 | class NetEqTestFactory; |
| 26 | |
| 27 | class NetEqSimulatorFactory { |
| 28 | public: |
| 29 | NetEqSimulatorFactory(); |
| 30 | ~NetEqSimulatorFactory(); |
Ivo Creusen | 5ec6156 | 2019-03-20 10:52:18 +0100 | [diff] [blame] | 31 | struct Config { |
Ivo Creusen | 99a2096 | 2019-10-07 13:18:18 +0200 | [diff] [blame] | 32 | // The maximum allowed number of packets in the jitter buffer. |
Ivo Creusen | 5ec6156 | 2019-03-20 10:52:18 +0100 | [diff] [blame] | 33 | int max_nr_packets_in_buffer = 0; |
Ivo Creusen | 99a2096 | 2019-10-07 13:18:18 +0200 | [diff] [blame] | 34 | // The number of audio packets to insert at the start of the simulation. |
| 35 | // Since the simulation is done with a replacement audio file, these |
| 36 | // artificial packets will take a small piece of that replacement audio. |
| 37 | int initial_dummy_packets = 0; |
| 38 | // The number of simulation steps to skip at the start of the simulation. |
| 39 | // This removes incoming packets and GetAudio events from the start of the |
| 40 | // simulation, until the requested number of GetAudio events has been |
| 41 | // removed. |
| 42 | int skip_get_audio_events = 0; |
| 43 | // A WebRTC field trial string to be used during the simulation. |
| 44 | std::string field_trial_string; |
Ivo Creusen | 26d52e1 | 2020-03-24 15:59:26 +0100 | [diff] [blame] | 45 | // A filename for the generated output audio file. |
| 46 | absl::optional<std::string> output_audio_filename; |
Ivo Creusen | 47156e2 | 2020-10-13 15:17:32 +0200 | [diff] [blame] | 47 | // A filename for the python plot. |
| 48 | absl::optional<std::string> python_plot_filename; |
| 49 | // A filename for the text log. |
| 50 | absl::optional<std::string> text_log_filename; |
Ivo Creusen | cee751a | 2020-01-16 17:17:09 +0100 | [diff] [blame] | 51 | // A custom NetEqFactory can be used. |
| 52 | NetEqFactory* neteq_factory = nullptr; |
Ivo Creusen | 5ec6156 | 2019-03-20 10:52:18 +0100 | [diff] [blame] | 53 | }; |
Ivo Creusen | 5ec6156 | 2019-03-20 10:52:18 +0100 | [diff] [blame] | 54 | std::unique_ptr<NetEqSimulator> CreateSimulatorFromFile( |
| 55 | absl::string_view event_log_filename, |
| 56 | absl::string_view replacement_audio_filename, |
| 57 | Config simulation_config); |
| 58 | // The same as above, but pass the file contents as a string. |
| 59 | std::unique_ptr<NetEqSimulator> CreateSimulatorFromString( |
| 60 | absl::string_view event_log_file_contents, |
| 61 | absl::string_view replacement_audio_file, |
| 62 | Config simulation_config); |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 63 | |
| 64 | private: |
| 65 | std::unique_ptr<NetEqTestFactory> factory_; |
| 66 | }; |
| 67 | |
| 68 | } // namespace test |
| 69 | } // namespace webrtc |
| 70 | |
| 71 | #endif // API_TEST_NETEQ_SIMULATOR_FACTORY_H_ |