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 
13 #include <string>
14 
15 #include "absl/flags/flag.h"
16 #include "absl/flags/parse.h"
17 #include "absl/flags/usage.h"
18 #include "rtc_tools/rtp_generator/rtp_generator.h"
19 
20 ABSL_FLAG(std::string, input_config, "", "JSON file with config");
21 ABSL_FLAG(std::string, output_rtpdump, "", "Where to store the rtpdump");
22 
main(int argc,char * argv[])23 int main(int argc, char* argv[]) {
24   absl::SetProgramUsageMessage(
25       "Generates custom configured rtpdumps for the purpose of testing.\n"
26       "Example Usage:\n"
27       "./rtp_generator --input_config=sender_config.json\n"
28       "                --output_rtpdump=my.rtpdump\n");
29   absl::ParseCommandLine(argc, argv);
30 
31   const std::string config_path = absl::GetFlag(FLAGS_input_config);
32   const std::string rtp_dump_path = absl::GetFlag(FLAGS_output_rtpdump);
33 
34   if (rtp_dump_path.empty() || config_path.empty()) {
35     return EXIT_FAILURE;
36   }
37 
38   absl::optional<webrtc::RtpGeneratorOptions> options =
39       webrtc::ParseRtpGeneratorOptionsFromFile(config_path);
40   if (!options.has_value()) {
41     return EXIT_FAILURE;
42   }
43 
44   webrtc::RtpGenerator rtp_generator(*options);
45   rtp_generator.GenerateRtpDump(rtp_dump_path);
46 
47   return EXIT_SUCCESS;
48 }
49