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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/webrtc.gyp » ('j') | webrtc/webrtc.gyp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <iostream>
12 #include <string>
13
14 #include "gflags/gflags.h"
15 #include "webrtc/base/scoped_ptr.h"
16 #include "webrtc/test/rtp_file_writer.h"
17 #include "webrtc/video/rtc_event_log.h"
18
19 // Files generated at build-time by the protobuf compiler.
20 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
21 #include "external/webrtc/webrtc/video/rtc_event_log.pb.h"
22 #else
23 #include "webrtc/video/rtc_event_log.pb.h"
24 #endif
25
26 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.
27 false,
28 "Store only audio packets in the converted "
29 "RTPdump file.");
30 DEFINE_bool(video_only,
31 false,
32 "Store only video packets in the converted "
33 "RTPdump file.");
34 DEFINE_bool(data_only,
35 false,
36 "Store only data packets in the converted "
37 "RTPdump file.");
38
39 // This utility will convert a stored event log to the rtpdump format.
40 int main(int argc, char* argv[]) {
41 std::string program_name = argv[0];
42 std::string usage =
43 "Tool for converting an RtcEventLog file to an RTP dump file.\n"
44 "Run " +
45 program_name +
46 " --helpshort for usage.\n"
47 "Example usage:\n" +
48 program_name + " input.rel output.rtp\n";
49 google::SetUsageMessage(usage);
50 google::ParseCommandLineFlags(&argc, &argv, true);
51
52 if (argc != 3) {
53 std::cout << google::ProgramUsage();
54 return 0;
55 }
56 std::string input_file = argv[1];
57 std::string output_file = argv[2];
58
59 webrtc::rtclog::EventStream event_stream;
60 if (!webrtc::RtcEventLog::ParseRtcEventLog(input_file, &event_stream)) {
61 std::cerr << "Error while parsing input file: " << input_file << std::endl;
62 return -1;
63 }
64
65 rtc::scoped_ptr<webrtc::test::RtpFileWriter> rtp_writer(
66 webrtc::test::RtpFileWriter::Create(
67 webrtc::test::RtpFileWriter::FileFormat::kRtpDump, output_file));
68
69 if (!rtp_writer.get()) {
70 std::cerr << "Error while opening output file: " << output_file
71 << std::endl;
72 return -1;
73 }
74
75 std::cout << "Found " << event_stream.stream_size()
76 << " events in the input file." << std::endl;
77 int rtp_counter = 0;
78 // TODO(ivoc): This can be refactored once the packet interpretation
79 // functions are finished.
80 for (int i = 0; i < event_stream.stream_size(); i++) {
81 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.
82 if (event.has_type() && event.type() == event.RTP_EVENT) {
83 if (event.has_timestamp_us() && event.has_rtp_packet() &&
84 event.rtp_packet().has_header() &&
85 event.rtp_packet().has_packet_length() &&
86 event.rtp_packet().has_type()) {
87 if (FLAGS_audio_only &&
88 event.rtp_packet().type() != webrtc::rtclog::AUDIO)
89 continue;
90 if (FLAGS_video_only &&
91 event.rtp_packet().type() != webrtc::rtclog::VIDEO)
92 continue;
93 if (FLAGS_data_only &&
94 event.rtp_packet().type() != webrtc::rtclog::DATA)
95 continue;
96 webrtc::test::RtpPacket packet;
97 packet.length = event.rtp_packet().header().size();
98 if (packet.length > packet.kMaxPacketBufferSize) {
99 std::cout << "Skipping packet with size " << packet.length
100 << ", the maximum supported size is "
101 << packet.kMaxPacketBufferSize << std::endl;
102 continue;
103 }
104 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.
105 packet.time_ms = event.timestamp_us() / 1000;
106 memcpy(packet.data, event.rtp_packet().header().data(), packet.length);
107 rtp_writer->WritePacket(&packet);
108 rtp_counter++;
109 } else {
110 std::cout << "Skipping malformed event." << std::endl;
111 }
112 }
113 }
114 std::cout << "Wrote " << rtp_counter << " RTP packets to the output file."
115 << std::endl;
116 return 0;
117 }
OLDNEW
« 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