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 | |
| 14 | #include "rtc_tools/rtp_generator/rtp_generator.h" |
| 15 | #include "rtc_tools/simple_command_line_parser.h" |
| 16 | |
| 17 | int main(int argc, char* argv[]) { |
| 18 | const std::string usage = |
| 19 | "Generates custom configured rtpdumps for the purpose of testing.\n" |
| 20 | "Example Usage:\n" |
| 21 | "./rtp_generator --input_config=sender_config.json\n" |
| 22 | " --output_rtpdump=my.rtpdump\n"; |
| 23 | |
| 24 | webrtc::test::CommandLineParser cmd_parser; |
| 25 | cmd_parser.Init(argc, argv); |
| 26 | cmd_parser.SetUsageMessage(usage); |
| 27 | cmd_parser.SetFlag("input_config", ""); |
| 28 | cmd_parser.SetFlag("output_rtpdump", ""); |
| 29 | cmd_parser.ProcessFlags(); |
| 30 | |
| 31 | const std::string config_path = cmd_parser.GetFlag("input_config"); |
| 32 | const std::string rtp_dump_path = cmd_parser.GetFlag("output_rtpdump"); |
| 33 | |
| 34 | if (cmd_parser.GetFlag("help") == "true" || rtp_dump_path.empty() || |
| 35 | config_path.empty()) { |
| 36 | cmd_parser.PrintUsageMessage(); |
| 37 | 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 | } |