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 | #include "api/test/neteq_simulator_factory.h" |
| 12 | |
Alessio Bazzica | 5ad789c | 2019-03-13 11:51:44 +0100 | [diff] [blame^] | 13 | #include <string> |
| 14 | |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 15 | #include "absl/memory/memory.h" |
| 16 | #include "modules/audio_coding/neteq/tools/neteq_test_factory.h" |
Ivo Creusen | f81b0f1 | 2018-09-11 10:30:58 +0200 | [diff] [blame] | 17 | #include "rtc_base/checks.h" |
| 18 | #include "rtc_base/flags.h" |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 19 | |
Ivo Creusen | ba7886b | 2019-02-26 13:03:21 +0100 | [diff] [blame] | 20 | namespace { |
| 21 | |
| 22 | WEBRTC_DEFINE_string(replacement_audio_file, |
| 23 | "", |
| 24 | "A PCM file that will be used to populate dummy" |
| 25 | " RTP packets"); |
| 26 | WEBRTC_DEFINE_int(max_nr_packets_in_buffer, |
| 27 | 50, |
| 28 | "Maximum allowed number of packets in the buffer"); |
| 29 | |
| 30 | } // namespace |
| 31 | |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 32 | namespace webrtc { |
| 33 | namespace test { |
| 34 | |
| 35 | NetEqSimulatorFactory::NetEqSimulatorFactory() |
| 36 | : factory_(absl::make_unique<NetEqTestFactory>()) {} |
| 37 | |
| 38 | NetEqSimulatorFactory::~NetEqSimulatorFactory() = default; |
| 39 | |
| 40 | std::unique_ptr<NetEqSimulator> NetEqSimulatorFactory::CreateSimulator( |
| 41 | int argc, |
| 42 | char* argv[]) { |
Ivo Creusen | f81b0f1 | 2018-09-11 10:30:58 +0200 | [diff] [blame] | 43 | RTC_CHECK(!rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true)) |
| 44 | << "Error while parsing command-line flags"; |
| 45 | RTC_CHECK_EQ(argc, 3) << "Wrong number of input arguments. Expected 3, got " |
| 46 | << argc; |
Ivo Creusen | ba7886b | 2019-02-26 13:03:21 +0100 | [diff] [blame] | 47 | // TODO(ivoc) Stop (ab)using command-line flags in this function. |
Alessio Bazzica | 5ad789c | 2019-03-13 11:51:44 +0100 | [diff] [blame^] | 48 | const std::string output_audio_filename(argv[2]); |
Ivo Creusen | ba7886b | 2019-02-26 13:03:21 +0100 | [diff] [blame] | 49 | NetEqTestFactory::Config config; |
| 50 | config.replacement_audio_file = FLAG_replacement_audio_file; |
| 51 | config.max_nr_packets_in_buffer = FLAG_max_nr_packets_in_buffer; |
Alessio Bazzica | 5ad789c | 2019-03-13 11:51:44 +0100 | [diff] [blame^] | 52 | config.output_audio_filename = output_audio_filename; |
| 53 | return factory_->InitializeTest(argv[1], config); |
Ivo Creusen | 55de08e | 2018-09-03 11:49:27 +0200 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | } // namespace test |
| 57 | } // namespace webrtc |