1 /*
2  *  Copyright (c) 2013 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 <stdio.h>
12 
13 #include <iostream>
14 #include <vector>
15 
16 #include "absl/flags/flag.h"
17 #include "absl/flags/parse.h"
18 #include "modules/audio_coding/neteq/tools/neteq_performance_test.h"
19 #include "rtc_base/checks.h"
20 
21 // Define command line flags.
22 ABSL_FLAG(int, runtime_ms, 10000, "Simulated runtime in ms.");
23 ABSL_FLAG(int, lossrate, 10, "Packet lossrate; drop every N packets.");
24 ABSL_FLAG(float, drift, 0.1f, "Clockdrift factor.");
25 
main(int argc,char * argv[])26 int main(int argc, char* argv[]) {
27   std::vector<char*> args = absl::ParseCommandLine(argc, argv);
28   std::string program_name = args[0];
29   std::string usage =
30       "Tool for measuring the speed of NetEq.\n"
31       "Usage: " +
32       program_name +
33       " [options]\n\n"
34       "  --runtime_ms=N         runtime in ms; default is 10000 ms\n"
35       "  --lossrate=N           drop every N packets; default is 10\n"
36       "  --drift=F              clockdrift factor between 0.0 and 1.0; "
37       "default is 0.1\n";
38   if (args.size() != 1) {
39     printf("%s", usage.c_str());
40     return 1;
41   }
42   RTC_CHECK_GT(absl::GetFlag(FLAGS_runtime_ms), 0);
43   RTC_CHECK_GE(absl::GetFlag(FLAGS_lossrate), 0);
44   RTC_CHECK(absl::GetFlag(FLAGS_drift) >= 0.0 &&
45             absl::GetFlag(FLAGS_drift) < 1.0);
46 
47   int64_t result = webrtc::test::NetEqPerformanceTest::Run(
48       absl::GetFlag(FLAGS_runtime_ms), absl::GetFlag(FLAGS_lossrate),
49       absl::GetFlag(FLAGS_drift));
50   if (result <= 0) {
51     std::cout << "There was an error" << std::endl;
52     return -1;
53   }
54 
55   std::cout << "Simulation done" << std::endl;
56   std::cout << "Runtime = " << result << " ms" << std::endl;
57   return 0;
58 }
59