Benjamin Wright | 87bbb91 | 2019-02-01 10:00:05 -0800 | [diff] [blame] | 1 | /* |
| 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> |
| 12 | #include <string> |
| 13 | |
Mirko Bonadei | a95949e | 2019-06-25 08:46:18 +0200 | [diff] [blame^] | 14 | #include "absl/flags/flag.h" |
| 15 | #include "absl/flags/parse.h" |
Benjamin Wright | 87bbb91 | 2019-02-01 10:00:05 -0800 | [diff] [blame] | 16 | #include "rtc_tools/rtp_generator/rtp_generator.h" |
Mirko Bonadei | a95949e | 2019-06-25 08:46:18 +0200 | [diff] [blame^] | 17 | |
| 18 | ABSL_FLAG(std::string, input_config, "", "JSON file with config"); |
| 19 | ABSL_FLAG(std::string, output_rtpdump, "", "Where to store the rtpdump"); |
Benjamin Wright | 87bbb91 | 2019-02-01 10:00:05 -0800 | [diff] [blame] | 20 | |
| 21 | int main(int argc, char* argv[]) { |
Mirko Bonadei | a95949e | 2019-06-25 08:46:18 +0200 | [diff] [blame^] | 22 | absl::ParseCommandLine(argc, argv); |
Benjamin Wright | 87bbb91 | 2019-02-01 10:00:05 -0800 | [diff] [blame] | 23 | |
Mirko Bonadei | a95949e | 2019-06-25 08:46:18 +0200 | [diff] [blame^] | 24 | // TODO(bugs.webrtc.org/10616): Add program usage message when Abseil |
| 25 | // flags supports it. |
| 26 | // const std::string usage = |
| 27 | // "Generates custom configured rtpdumps for the purpose of testing.\n" |
| 28 | // "Example Usage:\n" |
| 29 | // "./rtp_generator --input_config=sender_config.json\n" |
| 30 | // " --output_rtpdump=my.rtpdump\n"; |
Benjamin Wright | 87bbb91 | 2019-02-01 10:00:05 -0800 | [diff] [blame] | 31 | |
Mirko Bonadei | a95949e | 2019-06-25 08:46:18 +0200 | [diff] [blame^] | 32 | const std::string config_path = absl::GetFlag(FLAGS_input_config); |
| 33 | const std::string rtp_dump_path = absl::GetFlag(FLAGS_output_rtpdump); |
Benjamin Wright | 87bbb91 | 2019-02-01 10:00:05 -0800 | [diff] [blame] | 34 | |
Mirko Bonadei | a95949e | 2019-06-25 08:46:18 +0200 | [diff] [blame^] | 35 | if (rtp_dump_path.empty() || config_path.empty()) { |
Benjamin Wright | 87bbb91 | 2019-02-01 10:00:05 -0800 | [diff] [blame] | 36 | return EXIT_FAILURE; |
| 37 | } |
| 38 | |
| 39 | absl::optional<webrtc::RtpGeneratorOptions> options = |
| 40 | webrtc::ParseRtpGeneratorOptionsFromFile(config_path); |
| 41 | if (!options.has_value()) { |
| 42 | return EXIT_FAILURE; |
| 43 | } |
| 44 | |
| 45 | webrtc::RtpGenerator rtp_generator(*options); |
| 46 | rtp_generator.GenerateRtpDump(rtp_dump_path); |
| 47 | |
| 48 | return EXIT_SUCCESS; |
| 49 | } |