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

Side by Side Diff: webrtc/logging/rtc_event_log/rtc_event_log2rtp_dump.cc

Issue 2855143002: Removed RtcEventLog deps to call:call_interfaces. (Closed)
Patch Set: Formatting. Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <iostream> 11 #include <iostream>
12 #include <memory> 12 #include <memory>
13 #include <sstream> 13 #include <sstream>
14 #include <string> 14 #include <string>
15 15
16 #include "gflags/gflags.h" 16 #include "gflags/gflags.h"
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/call/call.h"
19 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 18 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
20 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" 19 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h"
21 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 20 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
22 #include "webrtc/test/rtp_file_writer.h" 22 #include "webrtc/test/rtp_file_writer.h"
23 23
24 namespace { 24 namespace {
25 25
26 using MediaType = webrtc::ParsedRtcEventLog::MediaType;
27
26 DEFINE_bool(noaudio, 28 DEFINE_bool(noaudio,
27 false, 29 false,
28 "Excludes audio packets from the converted RTPdump file."); 30 "Excludes audio packets from the converted RTPdump file.");
29 DEFINE_bool(novideo, 31 DEFINE_bool(novideo,
30 false, 32 false,
31 "Excludes video packets from the converted RTPdump file."); 33 "Excludes video packets from the converted RTPdump file.");
32 DEFINE_bool(nodata, 34 DEFINE_bool(nodata,
33 false, 35 false,
34 "Excludes data packets from the converted RTPdump file."); 36 "Excludes data packets from the converted RTPdump file.");
35 DEFINE_bool(nortp, 37 DEFINE_bool(nortp,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 bool header_only = false; 113 bool header_only = false;
112 for (size_t i = 0; i < parsed_stream.GetNumberOfEvents(); i++) { 114 for (size_t i = 0; i < parsed_stream.GetNumberOfEvents(); i++) {
113 // The parsed_stream will assert if the protobuf event is missing 115 // The parsed_stream will assert if the protobuf event is missing
114 // some required fields and we attempt to access them. We could consider 116 // some required fields and we attempt to access them. We could consider
115 // a softer failure option, but it does not seem useful to generate 117 // a softer failure option, but it does not seem useful to generate
116 // RTP dumps based on broken event logs. 118 // RTP dumps based on broken event logs.
117 if (!FLAGS_nortp && 119 if (!FLAGS_nortp &&
118 parsed_stream.GetEventType(i) == webrtc::ParsedRtcEventLog::RTP_EVENT) { 120 parsed_stream.GetEventType(i) == webrtc::ParsedRtcEventLog::RTP_EVENT) {
119 webrtc::test::RtpPacket packet; 121 webrtc::test::RtpPacket packet;
120 webrtc::PacketDirection direction; 122 webrtc::PacketDirection direction;
121 webrtc::MediaType media_type; 123 parsed_stream.GetRtpHeader(i, &direction, packet.data, &packet.length,
122 parsed_stream.GetRtpHeader(i, &direction, &media_type, packet.data, 124 &packet.original_length);
123 &packet.length, &packet.original_length);
124 if (packet.original_length > packet.length) 125 if (packet.original_length > packet.length)
125 header_only = true; 126 header_only = true;
126 packet.time_ms = parsed_stream.GetTimestamp(i) / 1000; 127 packet.time_ms = parsed_stream.GetTimestamp(i) / 1000;
127 128
129 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet.data,
130 packet.length);
131
128 // TODO(terelius): Maybe add a flag to dump outgoing traffic instead? 132 // TODO(terelius): Maybe add a flag to dump outgoing traffic instead?
129 if (direction == webrtc::kOutgoingPacket) 133 if (direction == webrtc::kOutgoingPacket)
130 continue; 134 continue;
131 if (FLAGS_noaudio && media_type == webrtc::MediaType::AUDIO) 135
136 webrtc::RTPHeader parsed_header;
137 rtp_parser.Parse(&parsed_header);
138 MediaType media_type =
139 parsed_stream.GetMediaType(parsed_header.ssrc, direction);
140 if (FLAGS_noaudio && media_type == MediaType::AUDIO)
132 continue; 141 continue;
133 if (FLAGS_novideo && media_type == webrtc::MediaType::VIDEO) 142 if (FLAGS_novideo && media_type == MediaType::VIDEO)
134 continue; 143 continue;
135 if (FLAGS_nodata && media_type == webrtc::MediaType::DATA) 144 if (FLAGS_nodata && media_type == MediaType::DATA)
136 continue; 145 continue;
137 if (!FLAGS_ssrc.empty()) { 146 if (!FLAGS_ssrc.empty()) {
138 const uint32_t packet_ssrc = 147 const uint32_t packet_ssrc =
139 webrtc::ByteReader<uint32_t>::ReadBigEndian( 148 webrtc::ByteReader<uint32_t>::ReadBigEndian(
140 reinterpret_cast<const uint8_t*>(packet.data + 8)); 149 reinterpret_cast<const uint8_t*>(packet.data + 8));
141 if (packet_ssrc != ssrc_filter) 150 if (packet_ssrc != ssrc_filter)
142 continue; 151 continue;
143 } 152 }
144 153
145 rtp_writer->WritePacket(&packet); 154 rtp_writer->WritePacket(&packet);
146 rtp_counter++; 155 rtp_counter++;
147 } 156 }
148 if (!FLAGS_nortcp && 157 if (!FLAGS_nortcp &&
149 parsed_stream.GetEventType(i) == 158 parsed_stream.GetEventType(i) ==
150 webrtc::ParsedRtcEventLog::RTCP_EVENT) { 159 webrtc::ParsedRtcEventLog::RTCP_EVENT) {
151 webrtc::test::RtpPacket packet; 160 webrtc::test::RtpPacket packet;
152 webrtc::PacketDirection direction; 161 webrtc::PacketDirection direction;
153 webrtc::MediaType media_type; 162 parsed_stream.GetRtcpPacket(i, &direction, packet.data, &packet.length);
154 parsed_stream.GetRtcpPacket(i, &direction, &media_type, packet.data,
155 &packet.length);
156 // For RTCP packets the original_length should be set to 0 in the 163 // For RTCP packets the original_length should be set to 0 in the
157 // RTPdump format. 164 // RTPdump format.
158 packet.original_length = 0; 165 packet.original_length = 0;
159 packet.time_ms = parsed_stream.GetTimestamp(i) / 1000; 166 packet.time_ms = parsed_stream.GetTimestamp(i) / 1000;
160 167
161 // TODO(terelius): Maybe add a flag to dump outgoing traffic instead? 168 // TODO(terelius): Maybe add a flag to dump outgoing traffic instead?
162 if (direction == webrtc::kOutgoingPacket) 169 if (direction == webrtc::kOutgoingPacket)
163 continue; 170 continue;
164 if (FLAGS_noaudio && media_type == webrtc::MediaType::AUDIO) 171
172 // Note that |packet_ssrc| is the sender SSRC. An RTCP message may contain
173 // report blocks for many streams, thus several SSRCs and they doen't
174 // necessarily have to be of the same media type.
175 const uint32_t packet_ssrc = webrtc::ByteReader<uint32_t>::ReadBigEndian(
176 reinterpret_cast<const uint8_t*>(packet.data + 4));
177 MediaType media_type = parsed_stream.GetMediaType(packet_ssrc, direction);
178 if (FLAGS_noaudio && media_type == MediaType::AUDIO)
165 continue; 179 continue;
166 if (FLAGS_novideo && media_type == webrtc::MediaType::VIDEO) 180 if (FLAGS_novideo && media_type == MediaType::VIDEO)
167 continue; 181 continue;
168 if (FLAGS_nodata && media_type == webrtc::MediaType::DATA) 182 if (FLAGS_nodata && media_type == MediaType::DATA)
169 continue; 183 continue;
170 if (!FLAGS_ssrc.empty()) { 184 if (!FLAGS_ssrc.empty()) {
171 const uint32_t packet_ssrc =
172 webrtc::ByteReader<uint32_t>::ReadBigEndian(
173 reinterpret_cast<const uint8_t*>(packet.data + 4));
174 if (packet_ssrc != ssrc_filter) 185 if (packet_ssrc != ssrc_filter)
175 continue; 186 continue;
176 } 187 }
177 188
178 rtp_writer->WritePacket(&packet); 189 rtp_writer->WritePacket(&packet);
179 rtcp_counter++; 190 rtcp_counter++;
180 } 191 }
181 } 192 }
182 std::cout << "Wrote " << rtp_counter << (header_only ? " header-only" : "") 193 std::cout << "Wrote " << rtp_counter << (header_only ? " header-only" : "")
183 << " RTP packets and " << rtcp_counter << " RTCP packets to the " 194 << " RTP packets and " << rtcp_counter << " RTCP packets to the "
184 << "output file." << std::endl; 195 << "output file." << std::endl;
185 return 0; 196 return 0;
186 } 197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698