blob: 6580d1d576d7f71aba94a83e5159373ca369d00f [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#include "api/test/neteq_simulator_factory.h"
12
Alessio Bazzica5ad789c2019-03-13 11:51:44 +010013#include <string>
14
Ivo Creusen55de08e2018-09-03 11:49:27 +020015#include "absl/memory/memory.h"
16#include "modules/audio_coding/neteq/tools/neteq_test_factory.h"
Ivo Creusenf81b0f12018-09-11 10:30:58 +020017#include "rtc_base/checks.h"
18#include "rtc_base/flags.h"
Ivo Creusen55de08e2018-09-03 11:49:27 +020019
Ivo Creusenba7886b2019-02-26 13:03:21 +010020namespace {
21
22WEBRTC_DEFINE_string(replacement_audio_file,
23 "",
24 "A PCM file that will be used to populate dummy"
25 " RTP packets");
26WEBRTC_DEFINE_int(max_nr_packets_in_buffer,
27 50,
28 "Maximum allowed number of packets in the buffer");
29
30} // namespace
31
Ivo Creusen55de08e2018-09-03 11:49:27 +020032namespace webrtc {
33namespace test {
34
35NetEqSimulatorFactory::NetEqSimulatorFactory()
36 : factory_(absl::make_unique<NetEqTestFactory>()) {}
37
38NetEqSimulatorFactory::~NetEqSimulatorFactory() = default;
39
40std::unique_ptr<NetEqSimulator> NetEqSimulatorFactory::CreateSimulator(
41 int argc,
42 char* argv[]) {
Ivo Creusenf81b0f12018-09-11 10:30:58 +020043 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 Creusenba7886b2019-02-26 13:03:21 +010047 // TODO(ivoc) Stop (ab)using command-line flags in this function.
Alessio Bazzica5ad789c2019-03-13 11:51:44 +010048 const std::string output_audio_filename(argv[2]);
Ivo Creusenba7886b2019-02-26 13:03:21 +010049 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 Bazzica5ad789c2019-03-13 11:51:44 +010052 config.output_audio_filename = output_audio_filename;
53 return factory_->InitializeTest(argv[1], config);
Ivo Creusen55de08e2018-09-03 11:49:27 +020054}
55
56} // namespace test
57} // namespace webrtc