tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

neteq_speed_test.cc (2051B)


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