diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/libwebrtc/rtc_tools/rtc_event_log_to_text/main.cc | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/rtc_tools/rtc_event_log_to_text/main.cc')
-rw-r--r-- | third_party/libwebrtc/rtc_tools/rtc_event_log_to_text/main.cc | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/third_party/libwebrtc/rtc_tools/rtc_event_log_to_text/main.cc b/third_party/libwebrtc/rtc_tools/rtc_event_log_to_text/main.cc new file mode 100644 index 0000000000..e4937b1327 --- /dev/null +++ b/third_party/libwebrtc/rtc_tools/rtc_event_log_to_text/main.cc @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include <stdio.h> + +#include <string> +#include <vector> + +#include "absl/flags/flag.h" +#include "absl/flags/parse.h" +#include "absl/flags/usage.h" +#include "absl/strings/string_view.h" +#include "logging/rtc_event_log/rtc_event_log_parser.h" +#include "rtc_base/logging.h" +#include "rtc_tools/rtc_event_log_to_text/converter.h" + +ABSL_FLAG(bool, + parse_unconfigured_header_extensions, + true, + "Attempt to parse unconfigured header extensions using the default " + "WebRTC mapping. This can give very misleading results if the " + "application negotiates a different mapping."); + +// Prints an RTC event log as human readable text with one line per event. +// Note that the RTC event log text format isn't an API. Prefer to build +// tools directly on the parser (logging/rtc_event_log/rtc_event_log_parser.cc). +int main(int argc, char* argv[]) { + absl::SetProgramUsageMessage( + "A tool for converting WebRTC event logs to text.\n" + "The events are sorted by log time and printed\n" + "with one event per line, using the following format:\n" + "<EVENT_TYPE> <log_time_ms> <field1>=<value1> <field2>=<value2> ...\n" + "\n" + "Example usage:\n" + "./rtc_event_log_to_text <inputfile> <outputfile>\n" + "./rtc_event_log_to_text <inputfile>\n" + "If no output file is specified, the output is written to stdout\n"); + std::vector<char*> args = absl::ParseCommandLine(argc, argv); + + // Print RTC_LOG warnings and errors even in release builds. + if (rtc::LogMessage::GetLogToDebug() > rtc::LS_WARNING) { + rtc::LogMessage::LogToDebug(rtc::LS_WARNING); + } + rtc::LogMessage::SetLogToStderr(true); + + webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions header_extensions = + webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions::kDontParse; + if (absl::GetFlag(FLAGS_parse_unconfigured_header_extensions)) { + header_extensions = webrtc::ParsedRtcEventLog:: + UnconfiguredHeaderExtensions::kAttemptWebrtcDefaultConfig; + } + + std::string inputfile; + FILE* output = nullptr; + if (args.size() == 3) { + inputfile = args[1]; + std::string outputfile = args[2]; + output = fopen(outputfile.c_str(), "w"); + } else if (args.size() == 2) { + inputfile = args[1]; + output = stdout; + } else { + // Print usage information. + std::cerr << absl::ProgramUsageMessage(); + return 1; + } + + bool success = webrtc::Convert(inputfile, output, header_extensions); + + return success ? 0 : 1; +} |