Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: webrtc/video/rtc_event_log2rtp_dump.cc

Issue 1297653002: Tool to convert RtcEventLog files to RtpDump format. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Initial version Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/webrtc.gyp » ('j') | webrtc/webrtc.gyp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/rtc_event_log2rtp_dump.cc
diff --git a/webrtc/video/rtc_event_log2rtp_dump.cc b/webrtc/video/rtc_event_log2rtp_dump.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2882812df43e6abb48cb3f55f5806ba8d30a8ef0
--- /dev/null
+++ b/webrtc/video/rtc_event_log2rtp_dump.cc
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2015 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 <iostream>
+#include <string>
+
+#include "gflags/gflags.h"
+#include "webrtc/base/scoped_ptr.h"
+#include "webrtc/test/rtp_file_writer.h"
+#include "webrtc/video/rtc_event_log.h"
+
+// Files generated at build-time by the protobuf compiler.
+#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
+#include "external/webrtc/webrtc/video/rtc_event_log.pb.h"
+#else
+#include "webrtc/video/rtc_event_log.pb.h"
+#endif
+
+DEFINE_bool(audio_only,
hlundin-webrtc 2015/08/17 11:14:34 Feature request: Can you add a flag to store only
ivoc 2015/08/21 14:30:57 Done.
+ false,
+ "Store only audio packets in the converted "
+ "RTPdump file.");
+DEFINE_bool(video_only,
+ false,
+ "Store only video packets in the converted "
+ "RTPdump file.");
+DEFINE_bool(data_only,
+ false,
+ "Store only data packets in the converted "
+ "RTPdump file.");
+
+// This utility will convert a stored event log to the rtpdump format.
+int main(int argc, char* argv[]) {
+ std::string program_name = argv[0];
+ std::string usage =
+ "Tool for converting an RtcEventLog file to an RTP dump file.\n"
+ "Run " +
+ program_name +
+ " --helpshort for usage.\n"
+ "Example usage:\n" +
+ program_name + " input.rel output.rtp\n";
+ google::SetUsageMessage(usage);
+ google::ParseCommandLineFlags(&argc, &argv, true);
+
+ if (argc != 3) {
+ std::cout << google::ProgramUsage();
+ return 0;
+ }
+ std::string input_file = argv[1];
+ std::string output_file = argv[2];
+
+ webrtc::rtclog::EventStream event_stream;
+ if (!webrtc::RtcEventLog::ParseRtcEventLog(input_file, &event_stream)) {
+ std::cerr << "Error while parsing input file: " << input_file << std::endl;
+ return -1;
+ }
+
+ rtc::scoped_ptr<webrtc::test::RtpFileWriter> rtp_writer(
+ webrtc::test::RtpFileWriter::Create(
+ webrtc::test::RtpFileWriter::FileFormat::kRtpDump, output_file));
+
+ if (!rtp_writer.get()) {
+ std::cerr << "Error while opening output file: " << output_file
+ << std::endl;
+ return -1;
+ }
+
+ std::cout << "Found " << event_stream.stream_size()
+ << " events in the input file." << std::endl;
+ int rtp_counter = 0;
+ // TODO(ivoc): This can be refactored once the packet interpretation
+ // functions are finished.
+ for (int i = 0; i < event_stream.stream_size(); i++) {
+ const webrtc::rtclog::Event& event = event_stream.stream(i);
hlundin-webrtc 2015/08/17 11:14:34 const auto& ? Or is the compiler unable to deduce
terelius 2015/08/17 11:39:06 Personally, I like being explicit with the types.
ivoc 2015/08/21 14:30:57 I tend to agree with terelius@ on this one, let me
hlundin-webrtc 2015/08/26 09:24:37 Acknowledged.
+ if (event.has_type() && event.type() == event.RTP_EVENT) {
+ if (event.has_timestamp_us() && event.has_rtp_packet() &&
+ event.rtp_packet().has_header() &&
+ event.rtp_packet().has_packet_length() &&
+ event.rtp_packet().has_type()) {
+ if (FLAGS_audio_only &&
+ event.rtp_packet().type() != webrtc::rtclog::AUDIO)
+ continue;
+ if (FLAGS_video_only &&
+ event.rtp_packet().type() != webrtc::rtclog::VIDEO)
+ continue;
+ if (FLAGS_data_only &&
+ event.rtp_packet().type() != webrtc::rtclog::DATA)
+ continue;
+ webrtc::test::RtpPacket packet;
+ packet.length = event.rtp_packet().header().size();
+ if (packet.length > packet.kMaxPacketBufferSize) {
+ std::cout << "Skipping packet with size " << packet.length
+ << ", the maximum supported size is "
+ << packet.kMaxPacketBufferSize << std::endl;
+ continue;
+ }
+ packet.original_length = event.rtp_packet().packet_length();
hlundin-webrtc 2015/08/17 11:14:33 I think it would be handy to know if the output is
ivoc 2015/08/21 14:30:57 Done.
+ packet.time_ms = event.timestamp_us() / 1000;
+ memcpy(packet.data, event.rtp_packet().header().data(), packet.length);
+ rtp_writer->WritePacket(&packet);
+ rtp_counter++;
+ } else {
+ std::cout << "Skipping malformed event." << std::endl;
+ }
+ }
+ }
+ std::cout << "Wrote " << rtp_counter << " RTP packets to the output file."
+ << std::endl;
+ return 0;
+}
« no previous file with comments | « no previous file | webrtc/webrtc.gyp » ('j') | webrtc/webrtc.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698