Switch neteq tools to ABSL_FLAG.
Bug: webrtc:10616 Change-Id: I2aa688f0976d5618347e402f25d8701b0cf5a360 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144027 Reviewed-by: Ivo Creusen <ivoc@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28442}
This commit is contained in:
committed by
Commit Bot
parent
e731a2ed98
commit
14be7993c6
@ -14,76 +14,73 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "modules/audio_coding/neteq/tools/packet.h"
|
||||
#include "modules/audio_coding/neteq/tools/rtp_file_source.h"
|
||||
#include "rtc_base/flags.h"
|
||||
|
||||
// Define command line flags.
|
||||
WEBRTC_DEFINE_int(red, 117, "RTP payload type for RED");
|
||||
WEBRTC_DEFINE_int(audio_level,
|
||||
-1,
|
||||
"Extension ID for audio level (RFC 6464); "
|
||||
"-1 not to print audio level");
|
||||
WEBRTC_DEFINE_int(abs_send_time,
|
||||
-1,
|
||||
"Extension ID for absolute sender time; "
|
||||
"-1 not to print absolute send time");
|
||||
WEBRTC_DEFINE_bool(help, false, "Print this message");
|
||||
ABSL_FLAG(int, red, 117, "RTP payload type for RED");
|
||||
ABSL_FLAG(int,
|
||||
audio_level,
|
||||
-1,
|
||||
"Extension ID for audio level (RFC 6464); "
|
||||
"-1 not to print audio level");
|
||||
ABSL_FLAG(int,
|
||||
abs_send_time,
|
||||
-1,
|
||||
"Extension ID for absolute sender time; "
|
||||
"-1 not to print absolute send time");
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::string program_name = argv[0];
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
std::string usage =
|
||||
"Tool for parsing an RTP dump file to text output.\n"
|
||||
"Run " +
|
||||
program_name +
|
||||
" --help for usage.\n"
|
||||
"Example usage:\n" +
|
||||
program_name + " input.rtp output.txt\n\n" +
|
||||
"Output is sent to stdout if no output file is given. " +
|
||||
"Example usage:\n"
|
||||
"./rtp_analyze input.rtp output.txt\n\n"
|
||||
"Output is sent to stdout if no output file is given. "
|
||||
"Note that this tool can read files with or without payloads.\n";
|
||||
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
|
||||
(argc != 2 && argc != 3)) {
|
||||
if (args.size() != 2 && args.size() != 3) {
|
||||
printf("%s", usage.c_str());
|
||||
if (FLAG_help) {
|
||||
rtc::FlagList::Print(nullptr, false);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
RTC_CHECK(FLAG_red >= 0 && FLAG_red <= 127); // Payload type
|
||||
RTC_CHECK(FLAG_audio_level == -1 || // Default
|
||||
(FLAG_audio_level > 0 && FLAG_audio_level <= 255)); // Extension ID
|
||||
RTC_CHECK(
|
||||
FLAG_abs_send_time == -1 || // Default
|
||||
(FLAG_abs_send_time > 0 && FLAG_abs_send_time <= 255)); // Extension ID
|
||||
RTC_CHECK(absl::GetFlag(FLAGS_red) >= 0 &&
|
||||
absl::GetFlag(FLAGS_red) <= 127); // Payload type
|
||||
RTC_CHECK(absl::GetFlag(FLAGS_audio_level) == -1 || // Default
|
||||
(absl::GetFlag(FLAGS_audio_level) > 0 &&
|
||||
absl::GetFlag(FLAGS_audio_level) <= 255)); // Extension ID
|
||||
RTC_CHECK(absl::GetFlag(FLAGS_abs_send_time) == -1 || // Default
|
||||
(absl::GetFlag(FLAGS_abs_send_time) > 0 &&
|
||||
absl::GetFlag(FLAGS_abs_send_time) <= 255)); // Extension ID
|
||||
|
||||
printf("Input file: %s\n", argv[1]);
|
||||
printf("Input file: %s\n", args[1]);
|
||||
std::unique_ptr<webrtc::test::RtpFileSource> file_source(
|
||||
webrtc::test::RtpFileSource::Create(argv[1]));
|
||||
webrtc::test::RtpFileSource::Create(args[1]));
|
||||
assert(file_source.get());
|
||||
// Set RTP extension IDs.
|
||||
bool print_audio_level = false;
|
||||
if (FLAG_audio_level != -1) {
|
||||
if (absl::GetFlag(FLAGS_audio_level) != -1) {
|
||||
print_audio_level = true;
|
||||
file_source->RegisterRtpHeaderExtension(webrtc::kRtpExtensionAudioLevel,
|
||||
FLAG_audio_level);
|
||||
absl::GetFlag(FLAGS_audio_level));
|
||||
}
|
||||
bool print_abs_send_time = false;
|
||||
if (FLAG_abs_send_time != -1) {
|
||||
if (absl::GetFlag(FLAGS_abs_send_time) != -1) {
|
||||
print_abs_send_time = true;
|
||||
file_source->RegisterRtpHeaderExtension(
|
||||
webrtc::kRtpExtensionAbsoluteSendTime, FLAG_abs_send_time);
|
||||
webrtc::kRtpExtensionAbsoluteSendTime,
|
||||
absl::GetFlag(FLAGS_abs_send_time));
|
||||
}
|
||||
|
||||
FILE* out_file;
|
||||
if (argc == 3) {
|
||||
out_file = fopen(argv[2], "wt");
|
||||
if (args.size() == 3) {
|
||||
out_file = fopen(args[2], "wt");
|
||||
if (!out_file) {
|
||||
printf("Cannot open output file %s\n", argv[2]);
|
||||
printf("Cannot open output file %s\n", args[2]);
|
||||
return -1;
|
||||
}
|
||||
printf("Output file: %s\n\n", argv[2]);
|
||||
printf("Output file: %s\n\n", args[2]);
|
||||
} else {
|
||||
out_file = stdout;
|
||||
}
|
||||
@ -150,7 +147,7 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
fprintf(out_file, "\n");
|
||||
|
||||
if (packet->header().payloadType == FLAG_red) {
|
||||
if (packet->header().payloadType == absl::GetFlag(FLAGS_red)) {
|
||||
std::list<webrtc::RTPHeader*> red_headers;
|
||||
packet->ExtractRedHeaders(&red_headers);
|
||||
while (!red_headers.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user