blob: 71181146da5b3ece4392e917af47a92ac11d3670 [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
13#include "absl/memory/memory.h"
14#include "modules/audio_coding/neteq/tools/neteq_test_factory.h"
Ivo Creusenf81b0f12018-09-11 10:30:58 +020015#include "rtc_base/checks.h"
16#include "rtc_base/flags.h"
Ivo Creusen55de08e2018-09-03 11:49:27 +020017
Ivo Creusenba7886b2019-02-26 13:03:21 +010018namespace {
19
20WEBRTC_DEFINE_string(replacement_audio_file,
21 "",
22 "A PCM file that will be used to populate dummy"
23 " RTP packets");
24WEBRTC_DEFINE_int(max_nr_packets_in_buffer,
25 50,
26 "Maximum allowed number of packets in the buffer");
27
28} // namespace
29
Ivo Creusen55de08e2018-09-03 11:49:27 +020030namespace webrtc {
31namespace test {
32
33NetEqSimulatorFactory::NetEqSimulatorFactory()
34 : factory_(absl::make_unique<NetEqTestFactory>()) {}
35
36NetEqSimulatorFactory::~NetEqSimulatorFactory() = default;
37
38std::unique_ptr<NetEqSimulator> NetEqSimulatorFactory::CreateSimulator(
39 int argc,
40 char* argv[]) {
Ivo Creusenf81b0f12018-09-11 10:30:58 +020041 RTC_CHECK(!rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true))
42 << "Error while parsing command-line flags";
43 RTC_CHECK_EQ(argc, 3) << "Wrong number of input arguments. Expected 3, got "
44 << argc;
Ivo Creusenba7886b2019-02-26 13:03:21 +010045 // TODO(ivoc) Stop (ab)using command-line flags in this function.
46 NetEqTestFactory::Config config;
47 config.replacement_audio_file = FLAG_replacement_audio_file;
48 config.max_nr_packets_in_buffer = FLAG_max_nr_packets_in_buffer;
49 return factory_->InitializeTest(argv[1], argv[2], config);
Ivo Creusen55de08e2018-09-03 11:49:27 +020050}
51
52} // namespace test
53} // namespace webrtc