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 #include "api/test/neteq_simulator_factory.h"
12
13 #include <memory>
14 #include <string>
15 #include <vector>
16
17 #include "absl/flags/flag.h"
18 #include "absl/flags/parse.h"
19 #include "modules/audio_coding/neteq/tools/neteq_test_factory.h"
20 #include "rtc_base/checks.h"
21
22 namespace webrtc {
23 namespace test {
24
NetEqSimulatorFactory()25 NetEqSimulatorFactory::NetEqSimulatorFactory()
26 : factory_(std::make_unique<NetEqTestFactory>()) {}
27
28 NetEqSimulatorFactory::~NetEqSimulatorFactory() = default;
29
CreateSimulatorFromFile(absl::string_view event_log_filename,absl::string_view replacement_audio_filename,Config simulation_config)30 std::unique_ptr<NetEqSimulator> NetEqSimulatorFactory::CreateSimulatorFromFile(
31 absl::string_view event_log_filename,
32 absl::string_view replacement_audio_filename,
33 Config simulation_config) {
34 NetEqTestFactory::Config config;
35 config.replacement_audio_file = std::string(replacement_audio_filename);
36 config.max_nr_packets_in_buffer = simulation_config.max_nr_packets_in_buffer;
37 config.initial_dummy_packets = simulation_config.initial_dummy_packets;
38 config.skip_get_audio_events = simulation_config.skip_get_audio_events;
39 config.field_trial_string = simulation_config.field_trial_string;
40 config.output_audio_filename = simulation_config.output_audio_filename;
41 return factory_->InitializeTestFromFile(
42 std::string(event_log_filename), simulation_config.neteq_factory, config);
43 }
44
45 std::unique_ptr<NetEqSimulator>
CreateSimulatorFromString(absl::string_view event_log_file_contents,absl::string_view replacement_audio_filename,Config simulation_config)46 NetEqSimulatorFactory::CreateSimulatorFromString(
47 absl::string_view event_log_file_contents,
48 absl::string_view replacement_audio_filename,
49 Config simulation_config) {
50 NetEqTestFactory::Config config;
51 config.replacement_audio_file = std::string(replacement_audio_filename);
52 config.max_nr_packets_in_buffer = simulation_config.max_nr_packets_in_buffer;
53 config.initial_dummy_packets = simulation_config.initial_dummy_packets;
54 config.skip_get_audio_events = simulation_config.skip_get_audio_events;
55 config.field_trial_string = simulation_config.field_trial_string;
56 return factory_->InitializeTestFromString(
57 std::string(event_log_file_contents), simulation_config.neteq_factory,
58 config);
59 }
60
61 } // namespace test
62 } // namespace webrtc
63