blob: 0e5dee8582d0cd83c6e410733ec1d124513df8be [file] [log] [blame]
Benjamin Wright87bbb912019-02-01 10:00:05 -08001/*
2 * Copyright (c) 2019 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 <stdlib.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020012
Benjamin Wright87bbb912019-02-01 10:00:05 -080013#include <string>
14
Mirko Bonadeia95949e2019-06-25 08:46:18 +020015#include "absl/flags/flag.h"
16#include "absl/flags/parse.h"
Benjamin Wright87bbb912019-02-01 10:00:05 -080017#include "rtc_tools/rtp_generator/rtp_generator.h"
Mirko Bonadeia95949e2019-06-25 08:46:18 +020018
19ABSL_FLAG(std::string, input_config, "", "JSON file with config");
20ABSL_FLAG(std::string, output_rtpdump, "", "Where to store the rtpdump");
Benjamin Wright87bbb912019-02-01 10:00:05 -080021
22int main(int argc, char* argv[]) {
Mirko Bonadeia95949e2019-06-25 08:46:18 +020023 absl::ParseCommandLine(argc, argv);
Benjamin Wright87bbb912019-02-01 10:00:05 -080024
Mirko Bonadeia95949e2019-06-25 08:46:18 +020025 // TODO(bugs.webrtc.org/10616): Add program usage message when Abseil
26 // flags supports it.
27 // const std::string usage =
28 // "Generates custom configured rtpdumps for the purpose of testing.\n"
29 // "Example Usage:\n"
30 // "./rtp_generator --input_config=sender_config.json\n"
31 // " --output_rtpdump=my.rtpdump\n";
Benjamin Wright87bbb912019-02-01 10:00:05 -080032
Mirko Bonadeia95949e2019-06-25 08:46:18 +020033 const std::string config_path = absl::GetFlag(FLAGS_input_config);
34 const std::string rtp_dump_path = absl::GetFlag(FLAGS_output_rtpdump);
Benjamin Wright87bbb912019-02-01 10:00:05 -080035
Mirko Bonadeia95949e2019-06-25 08:46:18 +020036 if (rtp_dump_path.empty() || config_path.empty()) {
Benjamin Wright87bbb912019-02-01 10:00:05 -080037 return EXIT_FAILURE;
38 }
39
40 absl::optional<webrtc::RtpGeneratorOptions> options =
41 webrtc::ParseRtpGeneratorOptionsFromFile(config_path);
42 if (!options.has_value()) {
43 return EXIT_FAILURE;
44 }
45
46 webrtc::RtpGenerator rtp_generator(*options);
47 rtp_generator.GenerateRtpDump(rtp_dump_path);
48
49 return EXIT_SUCCESS;
50}