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
3
DEPS
3
DEPS
@ -1638,4 +1638,7 @@ include_rules = [
|
||||
"+absl/strings/string_view.h",
|
||||
"+absl/types/optional.h",
|
||||
"+absl/types/variant.h",
|
||||
|
||||
# Abseil flags are allowed in tests and tools.
|
||||
"+absl/flags",
|
||||
]
|
||||
|
@ -1498,6 +1498,8 @@ if (rtc_include_tests) {
|
||||
"../../rtc_base:stringutils",
|
||||
"../../system_wrappers:field_trial",
|
||||
"../../test:field_trial",
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
@ -1605,6 +1607,8 @@ if (rtc_include_tests) {
|
||||
testonly = true
|
||||
|
||||
deps = audio_coding_deps + [
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
":audio_coding",
|
||||
":audio_encoder_cng",
|
||||
@ -1670,6 +1674,8 @@ if (rtc_include_tests) {
|
||||
":pcm16b",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"//testing/gtest",
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -11,136 +11,150 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "modules/audio_coding/neteq/tools/neteq_test.h"
|
||||
#include "modules/audio_coding/neteq/tools/neteq_test_factory.h"
|
||||
#include "rtc_base/flags.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "test/field_trial.h"
|
||||
|
||||
namespace {
|
||||
|
||||
using TestConfig = webrtc::test::NetEqTestFactory::Config;
|
||||
|
||||
WEBRTC_DEFINE_bool(codec_map,
|
||||
false,
|
||||
"Prints the mapping between RTP payload type and "
|
||||
"codec");
|
||||
WEBRTC_DEFINE_string(
|
||||
force_fieldtrials,
|
||||
"",
|
||||
"Field trials control experimental feature code which can be forced. "
|
||||
"E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
|
||||
" will assign the group Enable to field trial WebRTC-FooFeature.");
|
||||
WEBRTC_DEFINE_bool(help, false, "Prints this message");
|
||||
// Define command line flags.
|
||||
WEBRTC_DEFINE_int(pcmu,
|
||||
TestConfig::default_pcmu(),
|
||||
"RTP payload type for PCM-u");
|
||||
WEBRTC_DEFINE_int(pcma,
|
||||
TestConfig::default_pcma(),
|
||||
"RTP payload type for PCM-a");
|
||||
WEBRTC_DEFINE_int(ilbc,
|
||||
TestConfig::default_ilbc(),
|
||||
"RTP payload type for iLBC");
|
||||
WEBRTC_DEFINE_int(isac,
|
||||
TestConfig::default_isac(),
|
||||
"RTP payload type for iSAC");
|
||||
WEBRTC_DEFINE_int(isac_swb,
|
||||
TestConfig::default_isac_swb(),
|
||||
"RTP payload type for iSAC-swb (32 kHz)");
|
||||
WEBRTC_DEFINE_int(opus,
|
||||
TestConfig::default_opus(),
|
||||
"RTP payload type for Opus");
|
||||
WEBRTC_DEFINE_int(pcm16b,
|
||||
TestConfig::default_pcm16b(),
|
||||
"RTP payload type for PCM16b-nb (8 kHz)");
|
||||
WEBRTC_DEFINE_int(pcm16b_wb,
|
||||
TestConfig::default_pcm16b_wb(),
|
||||
"RTP payload type for PCM16b-wb (16 kHz)");
|
||||
WEBRTC_DEFINE_int(pcm16b_swb32,
|
||||
TestConfig::default_pcm16b_swb32(),
|
||||
"RTP payload type for PCM16b-swb32 (32 kHz)");
|
||||
WEBRTC_DEFINE_int(pcm16b_swb48,
|
||||
TestConfig::default_pcm16b_swb48(),
|
||||
"RTP payload type for PCM16b-swb48 (48 kHz)");
|
||||
WEBRTC_DEFINE_int(g722,
|
||||
TestConfig::default_g722(),
|
||||
"RTP payload type for G.722");
|
||||
WEBRTC_DEFINE_int(avt,
|
||||
TestConfig::default_avt(),
|
||||
"RTP payload type for AVT/DTMF (8 kHz)");
|
||||
WEBRTC_DEFINE_int(avt_16,
|
||||
TestConfig::default_avt_16(),
|
||||
"RTP payload type for AVT/DTMF (16 kHz)");
|
||||
WEBRTC_DEFINE_int(avt_32,
|
||||
TestConfig::default_avt_32(),
|
||||
"RTP payload type for AVT/DTMF (32 kHz)");
|
||||
WEBRTC_DEFINE_int(avt_48,
|
||||
TestConfig::default_avt_48(),
|
||||
"RTP payload type for AVT/DTMF (48 kHz)");
|
||||
WEBRTC_DEFINE_int(red,
|
||||
TestConfig::default_red(),
|
||||
"RTP payload type for redundant audio (RED)");
|
||||
WEBRTC_DEFINE_int(cn_nb,
|
||||
TestConfig::default_cn_nb(),
|
||||
"RTP payload type for comfort noise (8 kHz)");
|
||||
WEBRTC_DEFINE_int(cn_wb,
|
||||
TestConfig::default_cn_wb(),
|
||||
"RTP payload type for comfort noise (16 kHz)");
|
||||
WEBRTC_DEFINE_int(cn_swb32,
|
||||
TestConfig::default_cn_swb32(),
|
||||
"RTP payload type for comfort noise (32 kHz)");
|
||||
WEBRTC_DEFINE_int(cn_swb48,
|
||||
TestConfig::default_cn_swb48(),
|
||||
"RTP payload type for comfort noise (48 kHz)");
|
||||
WEBRTC_DEFINE_string(replacement_audio_file,
|
||||
"",
|
||||
"A PCM file that will be used to populate dummy"
|
||||
" RTP packets");
|
||||
WEBRTC_DEFINE_string(
|
||||
ssrc,
|
||||
"",
|
||||
"Only use packets with this SSRC (decimal or hex, the latter "
|
||||
"starting with 0x)");
|
||||
WEBRTC_DEFINE_int(audio_level,
|
||||
TestConfig::default_audio_level(),
|
||||
"Extension ID for audio level (RFC 6464)");
|
||||
WEBRTC_DEFINE_int(abs_send_time,
|
||||
TestConfig::default_abs_send_time(),
|
||||
"Extension ID for absolute sender time");
|
||||
WEBRTC_DEFINE_int(transport_seq_no,
|
||||
TestConfig::default_transport_seq_no(),
|
||||
"Extension ID for transport sequence number");
|
||||
WEBRTC_DEFINE_int(video_content_type,
|
||||
TestConfig::default_video_content_type(),
|
||||
"Extension ID for video content type");
|
||||
WEBRTC_DEFINE_int(video_timing,
|
||||
TestConfig::default_video_timing(),
|
||||
"Extension ID for video timing");
|
||||
WEBRTC_DEFINE_string(output_files_base_name,
|
||||
"",
|
||||
"Custom path used as prefix for the output files - i.e., "
|
||||
"matlab plot, python plot, text log.");
|
||||
WEBRTC_DEFINE_bool(matlabplot,
|
||||
false,
|
||||
"Generates a matlab script for plotting the delay profile");
|
||||
WEBRTC_DEFINE_bool(pythonplot,
|
||||
false,
|
||||
"Generates a python script for plotting the delay profile");
|
||||
WEBRTC_DEFINE_bool(textlog,
|
||||
false,
|
||||
"Generates a text log describing the simulation on a "
|
||||
"step-by-step basis.");
|
||||
WEBRTC_DEFINE_bool(concealment_events, false, "Prints concealment events");
|
||||
WEBRTC_DEFINE_int(max_nr_packets_in_buffer,
|
||||
TestConfig::default_max_nr_packets_in_buffer(),
|
||||
"Maximum allowed number of packets in the buffer");
|
||||
WEBRTC_DEFINE_bool(enable_fast_accelerate,
|
||||
false,
|
||||
"Enables jitter buffer fast accelerate");
|
||||
ABSL_FLAG(bool,
|
||||
codec_map,
|
||||
false,
|
||||
"Prints the mapping between RTP payload type and "
|
||||
"codec");
|
||||
ABSL_FLAG(std::string,
|
||||
force_fieldtrials,
|
||||
"",
|
||||
"Field trials control experimental feature code which can be forced. "
|
||||
"E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
|
||||
" will assign the group Enable to field trial WebRTC-FooFeature.");
|
||||
ABSL_FLAG(int, pcmu, TestConfig::default_pcmu(), "RTP payload type for PCM-u");
|
||||
ABSL_FLAG(int, pcma, TestConfig::default_pcma(), "RTP payload type for PCM-a");
|
||||
ABSL_FLAG(int, ilbc, TestConfig::default_ilbc(), "RTP payload type for iLBC");
|
||||
ABSL_FLAG(int, isac, TestConfig::default_isac(), "RTP payload type for iSAC");
|
||||
ABSL_FLAG(int,
|
||||
isac_swb,
|
||||
TestConfig::default_isac_swb(),
|
||||
"RTP payload type for iSAC-swb (32 kHz)");
|
||||
ABSL_FLAG(int, opus, TestConfig::default_opus(), "RTP payload type for Opus");
|
||||
ABSL_FLAG(int,
|
||||
pcm16b,
|
||||
TestConfig::default_pcm16b(),
|
||||
"RTP payload type for PCM16b-nb (8 kHz)");
|
||||
ABSL_FLAG(int,
|
||||
pcm16b_wb,
|
||||
TestConfig::default_pcm16b_wb(),
|
||||
"RTP payload type for PCM16b-wb (16 kHz)");
|
||||
ABSL_FLAG(int,
|
||||
pcm16b_swb32,
|
||||
TestConfig::default_pcm16b_swb32(),
|
||||
"RTP payload type for PCM16b-swb32 (32 kHz)");
|
||||
ABSL_FLAG(int,
|
||||
pcm16b_swb48,
|
||||
TestConfig::default_pcm16b_swb48(),
|
||||
"RTP payload type for PCM16b-swb48 (48 kHz)");
|
||||
ABSL_FLAG(int, g722, TestConfig::default_g722(), "RTP payload type for G.722");
|
||||
ABSL_FLAG(int,
|
||||
avt,
|
||||
TestConfig::default_avt(),
|
||||
"RTP payload type for AVT/DTMF (8 kHz)");
|
||||
ABSL_FLAG(int,
|
||||
avt_16,
|
||||
TestConfig::default_avt_16(),
|
||||
"RTP payload type for AVT/DTMF (16 kHz)");
|
||||
ABSL_FLAG(int,
|
||||
avt_32,
|
||||
TestConfig::default_avt_32(),
|
||||
"RTP payload type for AVT/DTMF (32 kHz)");
|
||||
ABSL_FLAG(int,
|
||||
avt_48,
|
||||
TestConfig::default_avt_48(),
|
||||
"RTP payload type for AVT/DTMF (48 kHz)");
|
||||
ABSL_FLAG(int,
|
||||
red,
|
||||
TestConfig::default_red(),
|
||||
"RTP payload type for redundant audio (RED)");
|
||||
ABSL_FLAG(int,
|
||||
cn_nb,
|
||||
TestConfig::default_cn_nb(),
|
||||
"RTP payload type for comfort noise (8 kHz)");
|
||||
ABSL_FLAG(int,
|
||||
cn_wb,
|
||||
TestConfig::default_cn_wb(),
|
||||
"RTP payload type for comfort noise (16 kHz)");
|
||||
ABSL_FLAG(int,
|
||||
cn_swb32,
|
||||
TestConfig::default_cn_swb32(),
|
||||
"RTP payload type for comfort noise (32 kHz)");
|
||||
ABSL_FLAG(int,
|
||||
cn_swb48,
|
||||
TestConfig::default_cn_swb48(),
|
||||
"RTP payload type for comfort noise (48 kHz)");
|
||||
ABSL_FLAG(std::string,
|
||||
replacement_audio_file,
|
||||
"",
|
||||
"A PCM file that will be used to populate dummy"
|
||||
" RTP packets");
|
||||
ABSL_FLAG(std::string,
|
||||
ssrc,
|
||||
"",
|
||||
"Only use packets with this SSRC (decimal or hex, the latter "
|
||||
"starting with 0x)");
|
||||
ABSL_FLAG(int,
|
||||
audio_level,
|
||||
TestConfig::default_audio_level(),
|
||||
"Extension ID for audio level (RFC 6464)");
|
||||
ABSL_FLAG(int,
|
||||
abs_send_time,
|
||||
TestConfig::default_abs_send_time(),
|
||||
"Extension ID for absolute sender time");
|
||||
ABSL_FLAG(int,
|
||||
transport_seq_no,
|
||||
TestConfig::default_transport_seq_no(),
|
||||
"Extension ID for transport sequence number");
|
||||
ABSL_FLAG(int,
|
||||
video_content_type,
|
||||
TestConfig::default_video_content_type(),
|
||||
"Extension ID for video content type");
|
||||
ABSL_FLAG(int,
|
||||
video_timing,
|
||||
TestConfig::default_video_timing(),
|
||||
"Extension ID for video timing");
|
||||
ABSL_FLAG(std::string,
|
||||
output_files_base_name,
|
||||
"",
|
||||
"Custom path used as prefix for the output files - i.e., "
|
||||
"matlab plot, python plot, text log.");
|
||||
ABSL_FLAG(bool,
|
||||
matlabplot,
|
||||
false,
|
||||
"Generates a matlab script for plotting the delay profile");
|
||||
ABSL_FLAG(bool,
|
||||
pythonplot,
|
||||
false,
|
||||
"Generates a python script for plotting the delay profile");
|
||||
ABSL_FLAG(bool,
|
||||
textlog,
|
||||
false,
|
||||
"Generates a text log describing the simulation on a "
|
||||
"step-by-step basis.");
|
||||
ABSL_FLAG(bool, concealment_events, false, "Prints concealment events");
|
||||
ABSL_FLAG(int,
|
||||
max_nr_packets_in_buffer,
|
||||
TestConfig::default_max_nr_packets_in_buffer(),
|
||||
"Maximum allowed number of packets in the buffer");
|
||||
ABSL_FLAG(bool,
|
||||
enable_fast_accelerate,
|
||||
false,
|
||||
"Enables jitter buffer fast accelerate");
|
||||
|
||||
namespace {
|
||||
|
||||
// Parses the input string for a valid SSRC (at the start of the string). If a
|
||||
// valid SSRC is found, it is written to the output variable |ssrc|, and true is
|
||||
@ -195,26 +209,30 @@ void PrintCodecMappingEntry(const char* codec, int flag) {
|
||||
}
|
||||
|
||||
void PrintCodecMapping() {
|
||||
PrintCodecMappingEntry("PCM-u", FLAG_pcmu);
|
||||
PrintCodecMappingEntry("PCM-a", FLAG_pcma);
|
||||
PrintCodecMappingEntry("iLBC", FLAG_ilbc);
|
||||
PrintCodecMappingEntry("iSAC", FLAG_isac);
|
||||
PrintCodecMappingEntry("iSAC-swb (32 kHz)", FLAG_isac_swb);
|
||||
PrintCodecMappingEntry("Opus", FLAG_opus);
|
||||
PrintCodecMappingEntry("PCM16b-nb (8 kHz)", FLAG_pcm16b);
|
||||
PrintCodecMappingEntry("PCM16b-wb (16 kHz)", FLAG_pcm16b_wb);
|
||||
PrintCodecMappingEntry("PCM16b-swb32 (32 kHz)", FLAG_pcm16b_swb32);
|
||||
PrintCodecMappingEntry("PCM16b-swb48 (48 kHz)", FLAG_pcm16b_swb48);
|
||||
PrintCodecMappingEntry("G.722", FLAG_g722);
|
||||
PrintCodecMappingEntry("AVT/DTMF (8 kHz)", FLAG_avt);
|
||||
PrintCodecMappingEntry("AVT/DTMF (16 kHz)", FLAG_avt_16);
|
||||
PrintCodecMappingEntry("AVT/DTMF (32 kHz)", FLAG_avt_32);
|
||||
PrintCodecMappingEntry("AVT/DTMF (48 kHz)", FLAG_avt_48);
|
||||
PrintCodecMappingEntry("redundant audio (RED)", FLAG_red);
|
||||
PrintCodecMappingEntry("comfort noise (8 kHz)", FLAG_cn_nb);
|
||||
PrintCodecMappingEntry("comfort noise (16 kHz)", FLAG_cn_wb);
|
||||
PrintCodecMappingEntry("comfort noise (32 kHz)", FLAG_cn_swb32);
|
||||
PrintCodecMappingEntry("comfort noise (48 kHz)", FLAG_cn_swb48);
|
||||
PrintCodecMappingEntry("PCM-u", absl::GetFlag(FLAGS_pcmu));
|
||||
PrintCodecMappingEntry("PCM-a", absl::GetFlag(FLAGS_pcma));
|
||||
PrintCodecMappingEntry("iLBC", absl::GetFlag(FLAGS_ilbc));
|
||||
PrintCodecMappingEntry("iSAC", absl::GetFlag(FLAGS_isac));
|
||||
PrintCodecMappingEntry("iSAC-swb (32 kHz)", absl::GetFlag(FLAGS_isac_swb));
|
||||
PrintCodecMappingEntry("Opus", absl::GetFlag(FLAGS_opus));
|
||||
PrintCodecMappingEntry("PCM16b-nb (8 kHz)", absl::GetFlag(FLAGS_pcm16b));
|
||||
PrintCodecMappingEntry("PCM16b-wb (16 kHz)", absl::GetFlag(FLAGS_pcm16b_wb));
|
||||
PrintCodecMappingEntry("PCM16b-swb32 (32 kHz)",
|
||||
absl::GetFlag(FLAGS_pcm16b_swb32));
|
||||
PrintCodecMappingEntry("PCM16b-swb48 (48 kHz)",
|
||||
absl::GetFlag(FLAGS_pcm16b_swb48));
|
||||
PrintCodecMappingEntry("G.722", absl::GetFlag(FLAGS_g722));
|
||||
PrintCodecMappingEntry("AVT/DTMF (8 kHz)", absl::GetFlag(FLAGS_avt));
|
||||
PrintCodecMappingEntry("AVT/DTMF (16 kHz)", absl::GetFlag(FLAGS_avt_16));
|
||||
PrintCodecMappingEntry("AVT/DTMF (32 kHz)", absl::GetFlag(FLAGS_avt_32));
|
||||
PrintCodecMappingEntry("AVT/DTMF (48 kHz)", absl::GetFlag(FLAGS_avt_48));
|
||||
PrintCodecMappingEntry("redundant audio (RED)", absl::GetFlag(FLAGS_red));
|
||||
PrintCodecMappingEntry("comfort noise (8 kHz)", absl::GetFlag(FLAGS_cn_nb));
|
||||
PrintCodecMappingEntry("comfort noise (16 kHz)", absl::GetFlag(FLAGS_cn_wb));
|
||||
PrintCodecMappingEntry("comfort noise (32 kHz)",
|
||||
absl::GetFlag(FLAGS_cn_swb32));
|
||||
PrintCodecMappingEntry("comfort noise (48 kHz)",
|
||||
absl::GetFlag(FLAGS_cn_swb48));
|
||||
}
|
||||
|
||||
bool ValidateOutputFilesOptions(bool textlog,
|
||||
@ -268,116 +286,111 @@ absl::optional<std::string> CreateOptionalOutputFileName(
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
webrtc::test::NetEqTestFactory factory;
|
||||
std::string program_name = argv[0];
|
||||
std::string usage =
|
||||
"Tool for decoding an RTP dump file using NetEq.\n"
|
||||
"Run " +
|
||||
program_name +
|
||||
" --help for usage.\n"
|
||||
"Example usage:\n" +
|
||||
program_name + " input.rtp [output.{pcm, wav}]\n";
|
||||
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true)) {
|
||||
exit(1);
|
||||
}
|
||||
if (FLAG_help) {
|
||||
std::cout << usage;
|
||||
rtc::FlagList::Print(nullptr, false);
|
||||
exit(0);
|
||||
}
|
||||
if (FLAG_codec_map) {
|
||||
"Example usage:\n"
|
||||
"./neteq_rtpplay input.rtp [output.{pcm, wav}]\n";
|
||||
if (absl::GetFlag(FLAGS_codec_map)) {
|
||||
PrintCodecMapping();
|
||||
exit(0);
|
||||
}
|
||||
if (argc < 2 || argc > 3) { // The output audio file is optional.
|
||||
if (args.size() != 2 &&
|
||||
args.size() != 3) { // The output audio file is optional.
|
||||
// Print usage information.
|
||||
std::cout << usage;
|
||||
exit(0);
|
||||
}
|
||||
const std::string output_audio_filename((argc == 3) ? argv[2] : "");
|
||||
const std::string output_files_base_name(FLAG_output_files_base_name);
|
||||
const std::string output_audio_filename((args.size() == 3) ? args[2] : "");
|
||||
const std::string output_files_base_name(
|
||||
absl::GetFlag(FLAGS_output_files_base_name));
|
||||
RTC_CHECK(ValidateOutputFilesOptions(
|
||||
FLAG_textlog, FLAG_matlabplot || FLAG_pythonplot, output_files_base_name,
|
||||
output_audio_filename));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_pcmu));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_pcma));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_ilbc));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_isac));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_isac_swb));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_opus));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_pcm16b));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_pcm16b_wb));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_pcm16b_swb32));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_pcm16b_swb48));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_g722));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_avt));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_avt_16));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_avt_32));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_avt_48));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_red));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_cn_nb));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_cn_wb));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_cn_swb32));
|
||||
RTC_CHECK(ValidatePayloadType(FLAG_cn_swb48));
|
||||
RTC_CHECK(ValidateSsrcValue(FLAG_ssrc));
|
||||
RTC_CHECK(ValidateExtensionId(FLAG_audio_level));
|
||||
RTC_CHECK(ValidateExtensionId(FLAG_abs_send_time));
|
||||
RTC_CHECK(ValidateExtensionId(FLAG_transport_seq_no));
|
||||
RTC_CHECK(ValidateExtensionId(FLAG_video_content_type));
|
||||
RTC_CHECK(ValidateExtensionId(FLAG_video_timing));
|
||||
absl::GetFlag(FLAGS_textlog),
|
||||
absl::GetFlag(FLAGS_matlabplot) || absl::GetFlag(FLAGS_pythonplot),
|
||||
output_files_base_name, output_audio_filename));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_pcmu)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_pcma)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_ilbc)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_isac)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_isac_swb)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_opus)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_pcm16b)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_pcm16b_wb)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_pcm16b_swb32)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_pcm16b_swb48)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_g722)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_avt)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_avt_16)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_avt_32)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_avt_48)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_red)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_cn_nb)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_cn_wb)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_cn_swb32)));
|
||||
RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_cn_swb48)));
|
||||
RTC_CHECK(ValidateSsrcValue(absl::GetFlag(FLAGS_ssrc)));
|
||||
RTC_CHECK(ValidateExtensionId(absl::GetFlag(FLAGS_audio_level)));
|
||||
RTC_CHECK(ValidateExtensionId(absl::GetFlag(FLAGS_abs_send_time)));
|
||||
RTC_CHECK(ValidateExtensionId(absl::GetFlag(FLAGS_transport_seq_no)));
|
||||
RTC_CHECK(ValidateExtensionId(absl::GetFlag(FLAGS_video_content_type)));
|
||||
RTC_CHECK(ValidateExtensionId(absl::GetFlag(FLAGS_video_timing)));
|
||||
|
||||
webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
|
||||
webrtc::field_trial::InitFieldTrialsFromString(
|
||||
absl::GetFlag(FLAGS_force_fieldtrials).c_str());
|
||||
webrtc::test::NetEqTestFactory::Config config;
|
||||
config.pcmu = FLAG_pcmu;
|
||||
config.pcma = FLAG_pcma;
|
||||
config.ilbc = FLAG_ilbc;
|
||||
config.isac = FLAG_isac;
|
||||
config.isac_swb = FLAG_isac_swb;
|
||||
config.opus = FLAG_opus;
|
||||
config.pcm16b = FLAG_pcm16b;
|
||||
config.pcm16b_wb = FLAG_pcm16b_wb;
|
||||
config.pcm16b_swb32 = FLAG_pcm16b_swb32;
|
||||
config.pcm16b_swb48 = FLAG_pcm16b_swb48;
|
||||
config.g722 = FLAG_g722;
|
||||
config.avt = FLAG_avt;
|
||||
config.avt_16 = FLAG_avt_16;
|
||||
config.avt_32 = FLAG_avt_32;
|
||||
config.avt_48 = FLAG_avt_48;
|
||||
config.red = FLAG_red;
|
||||
config.cn_nb = FLAG_cn_nb;
|
||||
config.cn_wb = FLAG_cn_wb;
|
||||
config.cn_swb32 = FLAG_cn_swb32;
|
||||
config.cn_swb48 = FLAG_cn_swb48;
|
||||
config.replacement_audio_file = FLAG_replacement_audio_file;
|
||||
config.audio_level = FLAG_audio_level;
|
||||
config.abs_send_time = FLAG_abs_send_time;
|
||||
config.transport_seq_no = FLAG_transport_seq_no;
|
||||
config.video_content_type = FLAG_video_content_type;
|
||||
config.video_timing = FLAG_video_timing;
|
||||
config.matlabplot = FLAG_matlabplot;
|
||||
config.pythonplot = FLAG_pythonplot;
|
||||
config.concealment_events = FLAG_concealment_events;
|
||||
config.max_nr_packets_in_buffer = FLAG_max_nr_packets_in_buffer;
|
||||
config.enable_fast_accelerate = FLAG_enable_fast_accelerate;
|
||||
config.pcmu = absl::GetFlag(FLAGS_pcmu);
|
||||
config.pcma = absl::GetFlag(FLAGS_pcma);
|
||||
config.ilbc = absl::GetFlag(FLAGS_ilbc);
|
||||
config.isac = absl::GetFlag(FLAGS_isac);
|
||||
config.isac_swb = absl::GetFlag(FLAGS_isac_swb);
|
||||
config.opus = absl::GetFlag(FLAGS_opus);
|
||||
config.pcm16b = absl::GetFlag(FLAGS_pcm16b);
|
||||
config.pcm16b_wb = absl::GetFlag(FLAGS_pcm16b_wb);
|
||||
config.pcm16b_swb32 = absl::GetFlag(FLAGS_pcm16b_swb32);
|
||||
config.pcm16b_swb48 = absl::GetFlag(FLAGS_pcm16b_swb48);
|
||||
config.g722 = absl::GetFlag(FLAGS_g722);
|
||||
config.avt = absl::GetFlag(FLAGS_avt);
|
||||
config.avt_16 = absl::GetFlag(FLAGS_avt_16);
|
||||
config.avt_32 = absl::GetFlag(FLAGS_avt_32);
|
||||
config.avt_48 = absl::GetFlag(FLAGS_avt_48);
|
||||
config.red = absl::GetFlag(FLAGS_red);
|
||||
config.cn_nb = absl::GetFlag(FLAGS_cn_nb);
|
||||
config.cn_wb = absl::GetFlag(FLAGS_cn_wb);
|
||||
config.cn_swb32 = absl::GetFlag(FLAGS_cn_swb32);
|
||||
config.cn_swb48 = absl::GetFlag(FLAGS_cn_swb48);
|
||||
config.replacement_audio_file = absl::GetFlag(FLAGS_replacement_audio_file);
|
||||
config.audio_level = absl::GetFlag(FLAGS_audio_level);
|
||||
config.abs_send_time = absl::GetFlag(FLAGS_abs_send_time);
|
||||
config.transport_seq_no = absl::GetFlag(FLAGS_transport_seq_no);
|
||||
config.video_content_type = absl::GetFlag(FLAGS_video_content_type);
|
||||
config.video_timing = absl::GetFlag(FLAGS_video_timing);
|
||||
config.matlabplot = absl::GetFlag(FLAGS_matlabplot);
|
||||
config.pythonplot = absl::GetFlag(FLAGS_pythonplot);
|
||||
config.concealment_events = absl::GetFlag(FLAGS_concealment_events);
|
||||
config.max_nr_packets_in_buffer =
|
||||
absl::GetFlag(FLAGS_max_nr_packets_in_buffer);
|
||||
config.enable_fast_accelerate = absl::GetFlag(FLAGS_enable_fast_accelerate);
|
||||
if (!output_audio_filename.empty()) {
|
||||
config.output_audio_filename = output_audio_filename;
|
||||
}
|
||||
config.textlog_filename =
|
||||
CreateOptionalOutputFileName(FLAG_textlog, output_files_base_name,
|
||||
output_audio_filename, ".text_log.txt");
|
||||
config.textlog_filename = CreateOptionalOutputFileName(
|
||||
absl::GetFlag(FLAGS_textlog), output_files_base_name,
|
||||
output_audio_filename, ".text_log.txt");
|
||||
config.plot_scripts_basename = CreateOptionalOutputFileName(
|
||||
FLAG_matlabplot || FLAG_pythonplot, output_files_base_name,
|
||||
output_audio_filename, "");
|
||||
absl::GetFlag(FLAGS_matlabplot) || absl::GetFlag(FLAGS_pythonplot),
|
||||
output_files_base_name, output_audio_filename, "");
|
||||
|
||||
// Check if an SSRC value was provided.
|
||||
if (strlen(FLAG_ssrc) > 0) {
|
||||
if (absl::GetFlag(FLAGS_ssrc).size() > 0) {
|
||||
uint32_t ssrc;
|
||||
RTC_CHECK(ParseSsrc(FLAG_ssrc, &ssrc)) << "Flag verification has failed.";
|
||||
RTC_CHECK(ParseSsrc(absl::GetFlag(FLAGS_ssrc), &ssrc))
|
||||
<< "Flag verification has failed.";
|
||||
config.ssrc_filter = absl::make_optional(ssrc);
|
||||
}
|
||||
|
||||
std::unique_ptr<webrtc::test::NetEqTest> test =
|
||||
factory.InitializeTestFromFile(/*input_filename=*/argv[1], config);
|
||||
factory.InitializeTestFromFile(/*input_filename=*/args[1], config);
|
||||
RTC_CHECK(test) << "ERROR: Unable to run test";
|
||||
test->Run();
|
||||
return 0;
|
||||
|
@ -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()) {
|
||||
|
@ -20,7 +20,10 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/audio/audio_frame.h"
|
||||
#include "api/audio_codecs/L16/audio_encoder_L16.h"
|
||||
@ -35,30 +38,29 @@
|
||||
#include "rtc_base/flags.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
|
||||
ABSL_FLAG(bool, list_codecs, false, "Enumerate all codecs");
|
||||
ABSL_FLAG(std::string, codec, "opus", "Codec to use");
|
||||
ABSL_FLAG(int,
|
||||
frame_len,
|
||||
0,
|
||||
"Frame length in ms; 0 indicates codec default value");
|
||||
ABSL_FLAG(int, bitrate, 0, "Bitrate in kbps; 0 indicates codec default value");
|
||||
ABSL_FLAG(int,
|
||||
payload_type,
|
||||
-1,
|
||||
"RTP payload type; -1 indicates codec default value");
|
||||
ABSL_FLAG(int,
|
||||
cng_payload_type,
|
||||
-1,
|
||||
"RTP payload type for CNG; -1 indicates default value");
|
||||
ABSL_FLAG(int, ssrc, 0, "SSRC to write to the RTP header");
|
||||
ABSL_FLAG(bool, dtx, false, "Use DTX/CNG");
|
||||
ABSL_FLAG(int, sample_rate, 48000, "Sample rate of the input file");
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
||||
// Define command line flags.
|
||||
WEBRTC_DEFINE_bool(list_codecs, false, "Enumerate all codecs");
|
||||
WEBRTC_DEFINE_string(codec, "opus", "Codec to use");
|
||||
WEBRTC_DEFINE_int(frame_len,
|
||||
0,
|
||||
"Frame length in ms; 0 indicates codec default value");
|
||||
WEBRTC_DEFINE_int(bitrate,
|
||||
0,
|
||||
"Bitrate in kbps; 0 indicates codec default value");
|
||||
WEBRTC_DEFINE_int(payload_type,
|
||||
-1,
|
||||
"RTP payload type; -1 indicates codec default value");
|
||||
WEBRTC_DEFINE_int(cng_payload_type,
|
||||
-1,
|
||||
"RTP payload type for CNG; -1 indicates default value");
|
||||
WEBRTC_DEFINE_int(ssrc, 0, "SSRC to write to the RTP header");
|
||||
WEBRTC_DEFINE_bool(dtx, false, "Use DTX/CNG");
|
||||
WEBRTC_DEFINE_int(sample_rate, 48000, "Sample rate of the input file");
|
||||
WEBRTC_DEFINE_bool(help, false, "Print this message");
|
||||
|
||||
// Add new codecs here, and to the map below.
|
||||
enum class CodecType {
|
||||
kOpus,
|
||||
@ -160,8 +162,8 @@ class Packetizer : public AudioPacketizationCallback {
|
||||
};
|
||||
|
||||
void SetFrameLenIfFlagIsPositive(int* config_frame_len) {
|
||||
if (FLAG_frame_len > 0) {
|
||||
*config_frame_len = FLAG_frame_len;
|
||||
if (absl::GetFlag(FLAGS_frame_len) > 0) {
|
||||
*config_frame_len = absl::GetFlag(FLAGS_frame_len);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,10 +201,10 @@ std::unique_ptr<AudioEncoder> CreateEncoder(CodecType codec_type,
|
||||
switch (codec_type) {
|
||||
case CodecType::kOpus: {
|
||||
AudioEncoderOpus::Config config = GetCodecConfig<AudioEncoderOpus>();
|
||||
if (FLAG_bitrate > 0) {
|
||||
config.bitrate_bps = FLAG_bitrate;
|
||||
if (absl::GetFlag(FLAGS_bitrate) > 0) {
|
||||
config.bitrate_bps = absl::GetFlag(FLAGS_bitrate);
|
||||
}
|
||||
config.dtx_enabled = FLAG_dtx;
|
||||
config.dtx_enabled = absl::GetFlag(FLAGS_dtx);
|
||||
RTC_CHECK(config.IsOk());
|
||||
return AudioEncoderOpus::MakeAudioEncoder(config, payload_type);
|
||||
}
|
||||
@ -261,33 +263,25 @@ AudioEncoderCngConfig GetCngConfig(int sample_rate_hz) {
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
cng_config.payload_type = FLAG_cng_payload_type != -1
|
||||
? FLAG_cng_payload_type
|
||||
cng_config.payload_type = absl::GetFlag(FLAGS_cng_payload_type) != -1
|
||||
? absl::GetFlag(FLAGS_cng_payload_type)
|
||||
: default_payload_type();
|
||||
return cng_config;
|
||||
}
|
||||
|
||||
int RunRtpEncode(int argc, char* argv[]) {
|
||||
const std::string program_name = argv[0];
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
const std::string usage =
|
||||
"Tool for generating an RTP dump file from audio input.\n"
|
||||
"Run " +
|
||||
program_name +
|
||||
" --help for usage.\n"
|
||||
"Example usage:\n" +
|
||||
program_name + " input.pcm output.rtp --codec=[codec] " +
|
||||
"Example usage:\n"
|
||||
"./rtp_encode input.pcm output.rtp --codec=[codec] "
|
||||
"--frame_len=[frame_len] --bitrate=[bitrate]\n\n";
|
||||
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
|
||||
(!FLAG_list_codecs && argc != 3)) {
|
||||
if (!absl::GetFlag(FLAGS_list_codecs) && args.size() != 3) {
|
||||
printf("%s", usage.c_str());
|
||||
if (FLAG_help) {
|
||||
rtc::FlagList::Print(nullptr, false);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (FLAG_list_codecs) {
|
||||
if (absl::GetFlag(FLAGS_list_codecs)) {
|
||||
printf("The following arguments are valid --codec parameters:\n");
|
||||
for (const auto& c : CodecList()) {
|
||||
printf(" %s\n", c.first.c_str());
|
||||
@ -295,22 +289,23 @@ int RunRtpEncode(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const auto codec_it = CodecList().find(FLAG_codec);
|
||||
const auto codec_it = CodecList().find(absl::GetFlag(FLAGS_codec));
|
||||
if (codec_it == CodecList().end()) {
|
||||
printf("%s is not a valid codec name.\n", FLAG_codec);
|
||||
printf("%s is not a valid codec name.\n",
|
||||
absl::GetFlag(FLAGS_codec).c_str());
|
||||
printf("Use argument --list_codecs to see all valid codec names.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create the codec.
|
||||
const int payload_type = FLAG_payload_type == -1
|
||||
const int payload_type = absl::GetFlag(FLAGS_payload_type) == -1
|
||||
? codec_it->second.default_payload_type
|
||||
: FLAG_payload_type;
|
||||
: absl::GetFlag(FLAGS_payload_type);
|
||||
std::unique_ptr<AudioEncoder> codec =
|
||||
CreateEncoder(codec_it->second.type, payload_type);
|
||||
|
||||
// Create an external VAD/CNG encoder if needed.
|
||||
if (FLAG_dtx && !codec_it->second.internal_dtx) {
|
||||
if (absl::GetFlag(FLAGS_dtx) && !codec_it->second.internal_dtx) {
|
||||
AudioEncoderCngConfig cng_config = GetCngConfig(codec->SampleRateHz());
|
||||
RTC_DCHECK(codec);
|
||||
cng_config.speech_encoder = std::move(codec);
|
||||
@ -325,11 +320,11 @@ int RunRtpEncode(int argc, char* argv[]) {
|
||||
acm->SetEncoder(std::move(codec));
|
||||
|
||||
// Open files.
|
||||
printf("Input file: %s\n", argv[1]);
|
||||
InputAudioFile input_file(argv[1], false); // Open input in non-looping mode.
|
||||
FILE* out_file = fopen(argv[2], "wb");
|
||||
RTC_CHECK(out_file) << "Could not open file " << argv[2] << " for writing";
|
||||
printf("Output file: %s\n", argv[2]);
|
||||
printf("Input file: %s\n", args[1]);
|
||||
InputAudioFile input_file(args[1], false); // Open input in non-looping mode.
|
||||
FILE* out_file = fopen(args[2], "wb");
|
||||
RTC_CHECK(out_file) << "Could not open file " << args[2] << " for writing";
|
||||
printf("Output file: %s\n", args[2]);
|
||||
fprintf(out_file, "#!rtpplay1.0 \n"); //,
|
||||
// Write 3 32-bit values followed by 2 16-bit values, all set to 0. This means
|
||||
// a total of 16 bytes.
|
||||
@ -337,12 +332,13 @@ int RunRtpEncode(int argc, char* argv[]) {
|
||||
RTC_CHECK_EQ(fwrite(file_header, sizeof(file_header), 1, out_file), 1);
|
||||
|
||||
// Create and register the packetizer, which will write the packets to file.
|
||||
Packetizer packetizer(out_file, FLAG_ssrc, timestamp_rate_hz);
|
||||
Packetizer packetizer(out_file, absl::GetFlag(FLAGS_ssrc), timestamp_rate_hz);
|
||||
RTC_DCHECK_EQ(acm->RegisterTransportCallback(&packetizer), 0);
|
||||
|
||||
AudioFrame audio_frame;
|
||||
audio_frame.samples_per_channel_ = FLAG_sample_rate / 100; // 10 ms
|
||||
audio_frame.sample_rate_hz_ = FLAG_sample_rate;
|
||||
audio_frame.samples_per_channel_ =
|
||||
absl::GetFlag(FLAGS_sample_rate) / 100; // 10 ms
|
||||
audio_frame.sample_rate_hz_ = absl::GetFlag(FLAGS_sample_rate);
|
||||
audio_frame.num_channels_ = 1;
|
||||
|
||||
while (input_file.Read(audio_frame.samples_per_channel_,
|
||||
|
@ -17,14 +17,11 @@
|
||||
#include "api/array_view.h"
|
||||
#include "modules/rtp_rtcp/source/byte_io.h"
|
||||
#include "rtc_base/buffer.h"
|
||||
#include "rtc_base/flags.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
||||
WEBRTC_DEFINE_bool(help, false, "Print help message");
|
||||
|
||||
constexpr size_t kRtpDumpHeaderLength = 8;
|
||||
|
||||
// Returns the next packet or an empty buffer if end of file was encountered.
|
||||
@ -83,10 +80,9 @@ int RunRtpJitter(int argc, char* argv[]) {
|
||||
"Tool for alternating the arrival times in an RTP dump file.\n"
|
||||
"Example usage:\n" +
|
||||
program_name + " input.rtp arrival_times_ms.txt output.rtp\n\n";
|
||||
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
|
||||
argc != 4) {
|
||||
if (argc != 4) {
|
||||
printf("%s", usage.c_str());
|
||||
return FLAG_help ? 0 : 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Input RTP file: %s\n", argv[1]);
|
||||
|
Reference in New Issue
Block a user