diff --git a/webrtc/tools/BUILD.gn b/webrtc/tools/BUILD.gn index 2850552f1a..df9a85945c 100644 --- a/webrtc/tools/BUILD.gn +++ b/webrtc/tools/BUILD.gn @@ -244,8 +244,8 @@ if (rtc_include_tests) { defines = [ "ENABLE_RTC_EVENT_LOG" ] deps = [ ":event_log_visualizer_utils", + "../base:rtc_base_approved", "../test:field_trial", - "//third_party/gflags", ] } } @@ -262,13 +262,13 @@ if (rtc_include_tests) { } deps = [ + "../base:rtc_base_approved", "../modules:module_api", "../modules/audio_processing", "../system_wrappers:metrics_default", "../test:test_support", "//build/win:default_exe_manifest", "//testing/gtest", - "//third_party/gflags", ] } diff --git a/webrtc/tools/agc/activity_metric.cc b/webrtc/tools/agc/activity_metric.cc index a98730a342..599777c3be 100644 --- a/webrtc/tools/agc/activity_metric.cc +++ b/webrtc/tools/agc/activity_metric.cc @@ -16,7 +16,7 @@ #include #include -#include "gflags/gflags.h" +#include "webrtc/base/flags.h" #include "webrtc/modules/audio_processing/agc/agc.h" #include "webrtc/modules/audio_processing/agc/loudness_histogram.h" #include "webrtc/modules/audio_processing/agc/utility.h" @@ -28,7 +28,7 @@ #include "webrtc/test/gtest.h" static const int kAgcAnalWindowSamples = 100; -static const double kDefaultActivityThreshold = 0.3; +static const float kDefaultActivityThreshold = 0.3f; DEFINE_bool(standalone_vad, true, "enable stand-alone VAD"); DEFINE_string(true_vad, "", "name of a file containing true VAD in 'int'" @@ -44,8 +44,9 @@ DEFINE_string(result, "", "name of a file to write the results. The results" " will be appended to the end of the file. This is optional."); DEFINE_string(audio_content, "", "name of a file where audio content is written" " to, in double format."); -DEFINE_double(activity_threshold, kDefaultActivityThreshold, +DEFINE_float(activity_threshold, kDefaultActivityThreshold, "Activity threshold"); +DEFINE_bool(help, false, "prints this message"); namespace webrtc { @@ -105,13 +106,13 @@ class AgcStat { AudioFeatures features; audio_processing_->ExtractFeatures( frame.data_, frame.samples_per_channel_, &features); - if (FLAGS_standalone_vad) { + if (FLAG_standalone_vad) { standalone_vad_->AddAudio(frame.data_, frame.samples_per_channel_); } if (features.num_frames > 0) { double p[kMaxNumFrames] = {0.5, 0.5, 0.5, 0.5}; - if (FLAGS_standalone_vad) { + if (FLAG_standalone_vad) { standalone_vad_->GetActivity(p, kMaxNumFrames); } // TODO(turajs) combining and limiting are used in the source files as @@ -175,20 +176,20 @@ void void_main(int argc, char* argv[]) { } FILE* true_vad_fid = NULL; - ASSERT_GT(FLAGS_true_vad.size(), 0u) << "Specify the file containing true " + ASSERT_GT(strlen(FLAG_true_vad), 0u) << "Specify the file containing true " "VADs using --true_vad flag."; - true_vad_fid = fopen(FLAGS_true_vad.c_str(), "rb"); + true_vad_fid = fopen(FLAG_true_vad, "rb"); ASSERT_TRUE(true_vad_fid != NULL) << "Cannot open the active list " << - FLAGS_true_vad; + FLAG_true_vad; FILE* results_fid = NULL; - if (FLAGS_result.size() > 0) { + if (strlen(FLAG_result) > 0) { // True if this is the first time writing to this function and we add a // header to the beginning of the file. bool write_header; // Open in the read mode. If it fails, the file doesn't exist and has to // write a header for it. Otherwise no need to write a header. - results_fid = fopen(FLAGS_result.c_str(), "r"); + results_fid = fopen(FLAG_result, "r"); if (results_fid == NULL) { write_header = true; } else { @@ -196,9 +197,9 @@ void void_main(int argc, char* argv[]) { write_header = false; } // Open in append mode. - results_fid = fopen(FLAGS_result.c_str(), "a"); + results_fid = fopen(FLAG_result, "a"); ASSERT_TRUE(results_fid != NULL) << "Cannot open the file, " << - FLAGS_result << ", to write the results."; + FLAG_result << ", to write the results."; // Write the header if required. if (write_header) { fprintf(results_fid, "%% Total Active, Misdetection, " @@ -208,19 +209,19 @@ void void_main(int argc, char* argv[]) { } FILE* video_vad_fid = NULL; - if (FLAGS_video_vad.size() > 0) { - video_vad_fid = fopen(FLAGS_video_vad.c_str(), "rb"); + if (strlen(FLAG_video_vad) > 0) { + video_vad_fid = fopen(FLAG_video_vad, "rb"); ASSERT_TRUE(video_vad_fid != NULL) << "Cannot open the file, " << - FLAGS_video_vad << " to read video-based VAD decisions.\n"; + FLAG_video_vad << " to read video-based VAD decisions.\n"; } // AgsStat will be the owner of this file and will close it at its // destructor. FILE* audio_content_fid = NULL; - if (FLAGS_audio_content.size() > 0) { - audio_content_fid = fopen(FLAGS_audio_content.c_str(), "wb"); + if (strlen(FLAG_audio_content) > 0) { + audio_content_fid = fopen(FLAG_audio_content, "wb"); ASSERT_TRUE(audio_content_fid != NULL) << "Cannot open file, " << - FLAGS_audio_content << " to write audio-content.\n"; + FLAG_audio_content << " to write audio-content.\n"; agc_stat.set_audio_content_file(audio_content_fid); } @@ -231,7 +232,7 @@ void void_main(int argc, char* argv[]) { const size_t kSamplesToRead = frame.num_channels_ * frame.samples_per_channel_; - agc_stat.SetActivityThreshold(FLAGS_activity_threshold); + agc_stat.SetActivityThreshold(FLAG_activity_threshold); int ret_val = 0; int num_frames = 0; @@ -369,17 +370,25 @@ void void_main(int argc, char* argv[]) { } // namespace webrtc int main(int argc, char* argv[]) { - char kUsage[] = + if (argc == 1) { + // Print usage information. + std::cout << "\nCompute the number of misdetected and false-positive frames. Not\n" " that for each frame of audio (10 ms) there should be one true\n" " activity. If any video-based activity is given, there should also be\n" " one probability per frame.\n" + "Run with --help for more details on available flags.\n" "\nUsage:\n\n" "activity_metric input_pcm [options]\n" "where 'input_pcm' is the input audio sampled at 16 kHz in 16 bits " "format.\n\n"; - google::SetUsageMessage(kUsage); - google::ParseCommandLineFlags(&argc, &argv, true); + return 0; + } + rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true); + if (FLAG_help) { + rtc::FlagList::Print(nullptr, false); + return 0; + } webrtc::void_main(argc, argv); return 0; } diff --git a/webrtc/tools/event_log_visualizer/main.cc b/webrtc/tools/event_log_visualizer/main.cc index 2f5ecd63e4..b9edd99fa3 100644 --- a/webrtc/tools/event_log_visualizer/main.cc +++ b/webrtc/tools/event_log_visualizer/main.cc @@ -10,7 +10,7 @@ #include -#include "gflags/gflags.h" +#include "webrtc/base/flags.h" #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" #include "webrtc/test/field_trial.h" #include "webrtc/tools/event_log_visualizer/analyzer.h" @@ -84,6 +84,7 @@ DEFINE_string( "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/" " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple " "trials are separated by \"/\""); +DEFINE_bool(help, false, "prints this message"); int main(int argc, char* argv[]) { std::string program_name = argv[0]; @@ -92,16 +93,19 @@ int main(int argc, char* argv[]) { "Example usage:\n" + program_name + " | python\n" + "Run " + program_name + " --help for a list of command line options\n"; - google::SetUsageMessage(usage); - google::ParseCommandLineFlags(&argc, &argv, true); - - if (argc != 2) { - // Print usage information. - std::cout << google::ProgramUsage(); + rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true); + if (FLAG_help) { + rtc::FlagList::Print(nullptr, false); return 0; } - webrtc::test::InitFieldTrialsFromString(FLAGS_force_fieldtrials); + if (argc != 2) { + // Print usage information. + std::cout << usage; + return 0; + } + + webrtc::test::InitFieldTrialsFromString(FLAG_force_fieldtrials); std::string filename = argv[1]; @@ -118,15 +122,15 @@ int main(int argc, char* argv[]) { std::unique_ptr collection( new webrtc::plotting::PythonPlotCollection()); - if (FLAGS_plot_all || FLAGS_plot_packets) { - if (FLAGS_incoming) { + if (FLAG_plot_all || FLAG_plot_packets) { + if (FLAG_incoming) { analyzer.CreatePacketGraph(webrtc::PacketDirection::kIncomingPacket, collection->AppendNewPlot()); analyzer.CreateAccumulatedPacketsGraph( webrtc::PacketDirection::kIncomingPacket, collection->AppendNewPlot()); } - if (FLAGS_outgoing) { + if (FLAG_outgoing) { analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket, collection->AppendNewPlot()); analyzer.CreateAccumulatedPacketsGraph( @@ -135,95 +139,95 @@ int main(int argc, char* argv[]) { } } - if (FLAGS_plot_all || FLAGS_plot_audio_playout) { + if (FLAG_plot_all || FLAG_plot_audio_playout) { analyzer.CreatePlayoutGraph(collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_plot_audio_level) { + if (FLAG_plot_all || FLAG_plot_audio_level) { analyzer.CreateAudioLevelGraph(collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_plot_sequence_number) { - if (FLAGS_incoming) { + if (FLAG_plot_all || FLAG_plot_sequence_number) { + if (FLAG_incoming) { analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot()); } } - if (FLAGS_plot_all || FLAGS_plot_delay_change) { - if (FLAGS_incoming) { + if (FLAG_plot_all || FLAG_plot_delay_change) { + if (FLAG_incoming) { analyzer.CreateDelayChangeGraph(collection->AppendNewPlot()); } } - if (FLAGS_plot_all || FLAGS_plot_accumulated_delay_change) { - if (FLAGS_incoming) { + if (FLAG_plot_all || FLAG_plot_accumulated_delay_change) { + if (FLAG_incoming) { analyzer.CreateAccumulatedDelayChangeGraph(collection->AppendNewPlot()); } } - if (FLAGS_plot_all || FLAGS_plot_fraction_loss) { + if (FLAG_plot_all || FLAG_plot_fraction_loss) { analyzer.CreateFractionLossGraph(collection->AppendNewPlot()); analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_plot_total_bitrate) { - if (FLAGS_incoming) { + if (FLAG_plot_all || FLAG_plot_total_bitrate) { + if (FLAG_incoming) { analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kIncomingPacket, collection->AppendNewPlot()); } - if (FLAGS_outgoing) { + if (FLAG_outgoing) { analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kOutgoingPacket, collection->AppendNewPlot()); } } - if (FLAGS_plot_all || FLAGS_plot_stream_bitrate) { - if (FLAGS_incoming) { + if (FLAG_plot_all || FLAG_plot_stream_bitrate) { + if (FLAG_incoming) { analyzer.CreateStreamBitrateGraph( webrtc::PacketDirection::kIncomingPacket, collection->AppendNewPlot()); } - if (FLAGS_outgoing) { + if (FLAG_outgoing) { analyzer.CreateStreamBitrateGraph( webrtc::PacketDirection::kOutgoingPacket, collection->AppendNewPlot()); } } - if (FLAGS_plot_all || FLAGS_plot_bwe) { + if (FLAG_plot_all || FLAG_plot_bwe) { analyzer.CreateBweSimulationGraph(collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_plot_network_delay_feedback) { + if (FLAG_plot_all || FLAG_plot_network_delay_feedback) { analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_plot_timestamps) { + if (FLAG_plot_all || FLAG_plot_timestamps) { analyzer.CreateTimestampGraph(collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_audio_encoder_bitrate_bps) { + if (FLAG_plot_all || FLAG_audio_encoder_bitrate_bps) { analyzer.CreateAudioEncoderTargetBitrateGraph(collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_audio_encoder_frame_length_ms) { + if (FLAG_plot_all || FLAG_audio_encoder_frame_length_ms) { analyzer.CreateAudioEncoderFrameLengthGraph(collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_audio_encoder_uplink_packet_loss_fraction) { + if (FLAG_plot_all || FLAG_audio_encoder_uplink_packet_loss_fraction) { analyzer.CreateAudioEncoderUplinkPacketLossFractionGraph( collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_audio_encoder_fec) { + if (FLAG_plot_all || FLAG_audio_encoder_fec) { analyzer.CreateAudioEncoderEnableFecGraph(collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_audio_encoder_dtx) { + if (FLAG_plot_all || FLAG_audio_encoder_dtx) { analyzer.CreateAudioEncoderEnableDtxGraph(collection->AppendNewPlot()); } - if (FLAGS_plot_all || FLAGS_audio_encoder_num_channels) { + if (FLAG_plot_all || FLAG_audio_encoder_num_channels) { analyzer.CreateAudioEncoderNumChannelsGraph(collection->AppendNewPlot()); }