Reland "NetEQ RTP Play: Optionally write output audio file"
This reverts commit c4b391a257ebf85448e58e73a96eb267635b6d6a. Reason for revert: issue fixed Original change's description: > Revert "NetEQ RTP Play: Optionally write output audio file" > > This reverts commit 6330818ec8159ee476481ba4a89f884fb3653f3f. > > Reason for revert: This breaks api/test/neteq_simulator_factory.cc, which unfortunately was not caught by our bots. > > Original change's description: > > NetEQ RTP Play: Optionally write output audio file > > > > This CL makes the output audio file optional to more > > quickly run neteq_rtpplay when no audio output is needed. > > The CL also includes necessary adaptations because of pre-existing > > dependencies (e.g., the output audio file name is used to create > > the plotting script file names). > > > > The command line arguments are retro-compatible - i.e., same behavior > > when specifying the output audio file and the new flag > > --output_files_base_name is not used. > > > > This CL also includes a test script with which the retro-compatibility > > has been verified. > > > > Bug: webrtc:10337 > > Change-Id: Ie3f301b3b2ed0682fb74426d9cf452396f2b112b > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126224 > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#27067} > > TBR=henrik.lundin@webrtc.org,alessiob@webrtc.org,ivoc@webrtc.org > > Change-Id: I0c63a8ba9566ef567ee398f571f2a511916fa742 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10337 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127293 > Reviewed-by: Ivo Creusen <ivoc@webrtc.org> > Commit-Queue: Ivo Creusen <ivoc@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27078} TBR=henrik.lundin@webrtc.org,alessiob@webrtc.org,ivoc@webrtc.org Change-Id: Ia7061f7c2d69db61638ad612e82cd429eb49d539 Bug: webrtc:10337 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127540 Reviewed-by: Ivo Creusen <ivoc@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27106}
This commit is contained in:
committed by
Commit Bot
parent
123f3453e2
commit
5ad789ceff
@ -11,9 +11,12 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#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"
|
||||
|
||||
@ -117,6 +120,10 @@ WEBRTC_DEFINE_int(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");
|
||||
@ -210,6 +217,54 @@ void PrintCodecMapping() {
|
||||
PrintCodecMappingEntry("comfort noise (48 kHz)", FLAG_cn_swb48);
|
||||
}
|
||||
|
||||
bool ValidateOutputFilesOptions(bool textlog,
|
||||
bool plotting,
|
||||
absl::string_view output_files_base_name,
|
||||
absl::string_view output_audio_filename) {
|
||||
bool output_files_base_name_specified = !output_files_base_name.empty();
|
||||
if (!textlog && !plotting && output_files_base_name_specified) {
|
||||
std::cout << "Error: --output_files_base_name cannot be used without at "
|
||||
<< "least one of the following flags: --textlog, --matlabplot, "
|
||||
<< "--pythonplot." << std::endl;
|
||||
return false;
|
||||
}
|
||||
// Without |output_audio_filename|, |output_files_base_name| is required when
|
||||
// one or more output files must be generated (in order to form a valid output
|
||||
// file name).
|
||||
if (output_audio_filename.empty() && (textlog || plotting) &&
|
||||
!output_files_base_name_specified) {
|
||||
std::cout << "Error: when no output audio file is specified and --textlog, "
|
||||
<< "--matlabplot and/or --pythonplot are used, "
|
||||
<< "--output_files_base_name must be also used." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
absl::optional<std::string> CreateOptionalOutputFileName(
|
||||
bool output_requested,
|
||||
absl::string_view basename,
|
||||
absl::string_view output_audio_filename,
|
||||
absl::string_view suffix) {
|
||||
if (!output_requested) {
|
||||
return absl::nullopt;
|
||||
}
|
||||
if (!basename.empty()) {
|
||||
// Override the automatic assignment.
|
||||
rtc::StringBuilder sb(basename);
|
||||
sb << suffix;
|
||||
return sb.str();
|
||||
}
|
||||
if (!output_audio_filename.empty()) {
|
||||
// Automatically assign name.
|
||||
rtc::StringBuilder sb(output_audio_filename);
|
||||
sb << suffix;
|
||||
return sb.str();
|
||||
}
|
||||
std::cout << "Error: invalid text log file parameters.";
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
@ -221,7 +276,7 @@ int main(int argc, char* argv[]) {
|
||||
program_name +
|
||||
" --help for usage.\n"
|
||||
"Example usage:\n" +
|
||||
program_name + " input.rtp output.{pcm, wav}\n";
|
||||
program_name + " input.rtp [output.{pcm, wav}]\n";
|
||||
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true)) {
|
||||
exit(1);
|
||||
}
|
||||
@ -234,11 +289,16 @@ int main(int argc, char* argv[]) {
|
||||
PrintCodecMapping();
|
||||
exit(0);
|
||||
}
|
||||
if (argc != 3) {
|
||||
if (argc < 2 || argc > 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);
|
||||
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));
|
||||
@ -297,10 +357,19 @@ int main(int argc, char* argv[]) {
|
||||
config.video_timing = FLAG_video_timing;
|
||||
config.matlabplot = FLAG_matlabplot;
|
||||
config.pythonplot = FLAG_pythonplot;
|
||||
config.textlog = FLAG_textlog;
|
||||
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;
|
||||
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.plot_scripts_basename = CreateOptionalOutputFileName(
|
||||
FLAG_matlabplot || FLAG_pythonplot, output_files_base_name,
|
||||
output_audio_filename, "");
|
||||
|
||||
// Check if an SSRC value was provided.
|
||||
if (strlen(FLAG_ssrc) > 0) {
|
||||
uint32_t ssrc;
|
||||
@ -308,8 +377,8 @@ int main(int argc, char* argv[]) {
|
||||
config.ssrc_filter = absl::make_optional(ssrc);
|
||||
}
|
||||
|
||||
std::unique_ptr<webrtc::test::NetEqTest> test =
|
||||
factory.InitializeTest(argv[1], argv[2], config);
|
||||
std::unique_ptr<webrtc::test::NetEqTest> test = factory.InitializeTest(
|
||||
/*input_filename=*/argv[1], config);
|
||||
test->Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user