OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 <sstream> | 12 #include <sstream> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "gflags/gflags.h" | 15 #include "gflags/gflags.h" |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/call/call.h" | |
18 #include "webrtc/common_types.h" | 17 #include "webrtc/common_types.h" |
19 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" | 18 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" |
24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" |
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" |
26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" |
27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
(...skipping 17 matching lines...) Expand all Loading... |
45 // TODO(terelius): Note that the media type doesn't work with outgoing packets. | 44 // TODO(terelius): Note that the media type doesn't work with outgoing packets. |
46 DEFINE_bool(nodata, false, "Excludes data packets."); | 45 DEFINE_bool(nodata, false, "Excludes data packets."); |
47 DEFINE_bool(nortp, false, "Excludes RTP packets."); | 46 DEFINE_bool(nortp, false, "Excludes RTP packets."); |
48 DEFINE_bool(nortcp, false, "Excludes RTCP packets."); | 47 DEFINE_bool(nortcp, false, "Excludes RTCP packets."); |
49 // TODO(terelius): Allow a list of SSRCs. | 48 // TODO(terelius): Allow a list of SSRCs. |
50 DEFINE_string(ssrc, | 49 DEFINE_string(ssrc, |
51 "", | 50 "", |
52 "Print only packets with this SSRC (decimal or hex, the latter " | 51 "Print only packets with this SSRC (decimal or hex, the latter " |
53 "starting with 0x)."); | 52 "starting with 0x)."); |
54 | 53 |
| 54 using MediaType = webrtc::ParsedRtcEventLog::MediaType; |
| 55 |
55 static uint32_t filtered_ssrc = 0; | 56 static uint32_t filtered_ssrc = 0; |
56 | 57 |
57 // Parses the input string for a valid SSRC. If a valid SSRC is found, it is | 58 // Parses the input string for a valid SSRC. If a valid SSRC is found, it is |
58 // written to the static global variable |filtered_ssrc|, and true is returned. | 59 // written to the static global variable |filtered_ssrc|, and true is returned. |
59 // Otherwise, false is returned. | 60 // Otherwise, false is returned. |
60 // The empty string must be validated as true, because it is the default value | 61 // The empty string must be validated as true, because it is the default value |
61 // of the command-line flag. In this case, no value is written to the output | 62 // of the command-line flag. In this case, no value is written to the output |
62 // variable. | 63 // variable. |
63 bool ParseSsrc(std::string str) { | 64 bool ParseSsrc(std::string str) { |
64 // If the input string starts with 0x or 0X it indicates a hexadecimal number. | 65 // If the input string starts with 0x or 0X it indicates a hexadecimal number. |
65 auto read_mode = std::dec; | 66 auto read_mode = std::dec; |
66 if (str.size() > 2 && | 67 if (str.size() > 2 && |
67 (str.substr(0, 2) == "0x" || str.substr(0, 2) == "0X")) { | 68 (str.substr(0, 2) == "0x" || str.substr(0, 2) == "0X")) { |
68 read_mode = std::hex; | 69 read_mode = std::hex; |
69 str = str.substr(2); | 70 str = str.substr(2); |
70 } | 71 } |
71 std::stringstream ss(str); | 72 std::stringstream ss(str); |
72 ss >> read_mode >> filtered_ssrc; | 73 ss >> read_mode >> filtered_ssrc; |
73 return str.empty() || (!ss.fail() && ss.eof()); | 74 return str.empty() || (!ss.fail() && ss.eof()); |
74 } | 75 } |
75 | 76 |
76 // Struct used for storing SSRCs used in a Stream. | |
77 struct Stream { | |
78 Stream(uint32_t ssrc, | |
79 webrtc::MediaType media_type, | |
80 webrtc::PacketDirection direction) | |
81 : ssrc(ssrc), media_type(media_type), direction(direction) {} | |
82 uint32_t ssrc; | |
83 webrtc::MediaType media_type; | |
84 webrtc::PacketDirection direction; | |
85 }; | |
86 | |
87 // All configured streams found in the event log. | |
88 std::vector<Stream> global_streams; | |
89 | |
90 // Returns the MediaType for registered SSRCs. Search from the end to use last | |
91 // registered types first. | |
92 webrtc::MediaType GetMediaType(uint32_t ssrc, | |
93 webrtc::PacketDirection direction) { | |
94 for (auto rit = global_streams.rbegin(); rit != global_streams.rend(); | |
95 ++rit) { | |
96 if (rit->ssrc == ssrc && rit->direction == direction) | |
97 return rit->media_type; | |
98 } | |
99 return webrtc::MediaType::ANY; | |
100 } | |
101 | |
102 bool ExcludePacket(webrtc::PacketDirection direction, | 77 bool ExcludePacket(webrtc::PacketDirection direction, |
103 webrtc::MediaType media_type, | 78 MediaType media_type, |
104 uint32_t packet_ssrc) { | 79 uint32_t packet_ssrc) { |
105 if (FLAGS_nooutgoing && direction == webrtc::kOutgoingPacket) | 80 if (FLAGS_nooutgoing && direction == webrtc::kOutgoingPacket) |
106 return true; | 81 return true; |
107 if (FLAGS_noincoming && direction == webrtc::kIncomingPacket) | 82 if (FLAGS_noincoming && direction == webrtc::kIncomingPacket) |
108 return true; | 83 return true; |
109 if (FLAGS_noaudio && media_type == webrtc::MediaType::AUDIO) | 84 if (FLAGS_noaudio && media_type == MediaType::AUDIO) |
110 return true; | 85 return true; |
111 if (FLAGS_novideo && media_type == webrtc::MediaType::VIDEO) | 86 if (FLAGS_novideo && media_type == MediaType::VIDEO) |
112 return true; | 87 return true; |
113 if (FLAGS_nodata && media_type == webrtc::MediaType::DATA) | 88 if (FLAGS_nodata && media_type == MediaType::DATA) |
114 return true; | 89 return true; |
115 if (!FLAGS_ssrc.empty() && packet_ssrc != filtered_ssrc) | 90 if (!FLAGS_ssrc.empty() && packet_ssrc != filtered_ssrc) |
116 return true; | 91 return true; |
117 return false; | 92 return false; |
118 } | 93 } |
119 | 94 |
120 const char* StreamInfo(webrtc::PacketDirection direction, | 95 const char* StreamInfo(webrtc::PacketDirection direction, |
121 webrtc::MediaType media_type) { | 96 MediaType media_type) { |
122 if (direction == webrtc::kOutgoingPacket) { | 97 if (direction == webrtc::kOutgoingPacket) { |
123 if (media_type == webrtc::MediaType::AUDIO) | 98 if (media_type == MediaType::AUDIO) |
124 return "(out,audio)"; | 99 return "(out,audio)"; |
125 else if (media_type == webrtc::MediaType::VIDEO) | 100 else if (media_type == MediaType::VIDEO) |
126 return "(out,video)"; | 101 return "(out,video)"; |
127 else if (media_type == webrtc::MediaType::DATA) | 102 else if (media_type == MediaType::DATA) |
128 return "(out,data)"; | 103 return "(out,data)"; |
129 else | 104 else |
130 return "(out)"; | 105 return "(out)"; |
131 } | 106 } |
132 if (direction == webrtc::kIncomingPacket) { | 107 if (direction == webrtc::kIncomingPacket) { |
133 if (media_type == webrtc::MediaType::AUDIO) | 108 if (media_type == MediaType::AUDIO) |
134 return "(in,audio)"; | 109 return "(in,audio)"; |
135 else if (media_type == webrtc::MediaType::VIDEO) | 110 else if (media_type == MediaType::VIDEO) |
136 return "(in,video)"; | 111 return "(in,video)"; |
137 else if (media_type == webrtc::MediaType::DATA) | 112 else if (media_type == MediaType::DATA) |
138 return "(in,data)"; | 113 return "(in,data)"; |
139 else | 114 else |
140 return "(in)"; | 115 return "(in)"; |
141 } | 116 } |
142 return "(unknown)"; | 117 return "(unknown)"; |
143 } | 118 } |
144 | 119 |
145 void PrintSenderReport(const webrtc::rtcp::CommonHeader& rtcp_block, | 120 void PrintSenderReport(const webrtc::ParsedRtcEventLog& parsed_stream, |
| 121 const webrtc::rtcp::CommonHeader& rtcp_block, |
146 uint64_t log_timestamp, | 122 uint64_t log_timestamp, |
147 webrtc::PacketDirection direction) { | 123 webrtc::PacketDirection direction) { |
148 webrtc::rtcp::SenderReport sr; | 124 webrtc::rtcp::SenderReport sr; |
149 if (!sr.Parse(rtcp_block)) | 125 if (!sr.Parse(rtcp_block)) |
150 return; | 126 return; |
151 webrtc::MediaType media_type = GetMediaType(sr.sender_ssrc(), direction); | 127 MediaType media_type = |
| 128 parsed_stream.GetMediaType(sr.sender_ssrc(), direction); |
152 if (ExcludePacket(direction, media_type, sr.sender_ssrc())) | 129 if (ExcludePacket(direction, media_type, sr.sender_ssrc())) |
153 return; | 130 return; |
154 std::cout << log_timestamp << "\t" | 131 std::cout << log_timestamp << "\t" |
155 << "RTCP_SR" << StreamInfo(direction, media_type) | 132 << "RTCP_SR" << StreamInfo(direction, media_type) |
156 << "\tssrc=" << sr.sender_ssrc() | 133 << "\tssrc=" << sr.sender_ssrc() |
157 << "\ttimestamp=" << sr.rtp_timestamp() << std::endl; | 134 << "\ttimestamp=" << sr.rtp_timestamp() << std::endl; |
158 } | 135 } |
159 | 136 |
160 void PrintReceiverReport(const webrtc::rtcp::CommonHeader& rtcp_block, | 137 void PrintReceiverReport(const webrtc::ParsedRtcEventLog& parsed_stream, |
| 138 const webrtc::rtcp::CommonHeader& rtcp_block, |
161 uint64_t log_timestamp, | 139 uint64_t log_timestamp, |
162 webrtc::PacketDirection direction) { | 140 webrtc::PacketDirection direction) { |
163 webrtc::rtcp::ReceiverReport rr; | 141 webrtc::rtcp::ReceiverReport rr; |
164 if (!rr.Parse(rtcp_block)) | 142 if (!rr.Parse(rtcp_block)) |
165 return; | 143 return; |
166 webrtc::MediaType media_type = GetMediaType(rr.sender_ssrc(), direction); | 144 MediaType media_type = |
| 145 parsed_stream.GetMediaType(rr.sender_ssrc(), direction); |
167 if (ExcludePacket(direction, media_type, rr.sender_ssrc())) | 146 if (ExcludePacket(direction, media_type, rr.sender_ssrc())) |
168 return; | 147 return; |
169 std::cout << log_timestamp << "\t" | 148 std::cout << log_timestamp << "\t" |
170 << "RTCP_RR" << StreamInfo(direction, media_type) | 149 << "RTCP_RR" << StreamInfo(direction, media_type) |
171 << "\tssrc=" << rr.sender_ssrc() << std::endl; | 150 << "\tssrc=" << rr.sender_ssrc() << std::endl; |
172 } | 151 } |
173 | 152 |
174 void PrintXr(const webrtc::rtcp::CommonHeader& rtcp_block, | 153 void PrintXr(const webrtc::ParsedRtcEventLog& parsed_stream, |
| 154 const webrtc::rtcp::CommonHeader& rtcp_block, |
175 uint64_t log_timestamp, | 155 uint64_t log_timestamp, |
176 webrtc::PacketDirection direction) { | 156 webrtc::PacketDirection direction) { |
177 webrtc::rtcp::ExtendedReports xr; | 157 webrtc::rtcp::ExtendedReports xr; |
178 if (!xr.Parse(rtcp_block)) | 158 if (!xr.Parse(rtcp_block)) |
179 return; | 159 return; |
180 webrtc::MediaType media_type = GetMediaType(xr.sender_ssrc(), direction); | 160 MediaType media_type = |
| 161 parsed_stream.GetMediaType(xr.sender_ssrc(), direction); |
181 if (ExcludePacket(direction, media_type, xr.sender_ssrc())) | 162 if (ExcludePacket(direction, media_type, xr.sender_ssrc())) |
182 return; | 163 return; |
183 std::cout << log_timestamp << "\t" | 164 std::cout << log_timestamp << "\t" |
184 << "RTCP_XR" << StreamInfo(direction, media_type) | 165 << "RTCP_XR" << StreamInfo(direction, media_type) |
185 << "\tssrc=" << xr.sender_ssrc() << std::endl; | 166 << "\tssrc=" << xr.sender_ssrc() << std::endl; |
186 } | 167 } |
187 | 168 |
188 void PrintSdes(const webrtc::rtcp::CommonHeader& rtcp_block, | 169 void PrintSdes(const webrtc::rtcp::CommonHeader& rtcp_block, |
189 uint64_t log_timestamp, | 170 uint64_t log_timestamp, |
190 webrtc::PacketDirection direction) { | 171 webrtc::PacketDirection direction) { |
191 std::cout << log_timestamp << "\t" | 172 std::cout << log_timestamp << "\t" |
192 << "RTCP_SDES" << StreamInfo(direction, webrtc::MediaType::ANY) | 173 << "RTCP_SDES" << StreamInfo(direction, MediaType::ANY) |
193 << std::endl; | 174 << std::endl; |
194 RTC_NOTREACHED() << "SDES should have been redacted when writing the log"; | 175 RTC_NOTREACHED() << "SDES should have been redacted when writing the log"; |
195 } | 176 } |
196 | 177 |
197 void PrintBye(const webrtc::rtcp::CommonHeader& rtcp_block, | 178 void PrintBye(const webrtc::ParsedRtcEventLog& parsed_stream, |
| 179 const webrtc::rtcp::CommonHeader& rtcp_block, |
198 uint64_t log_timestamp, | 180 uint64_t log_timestamp, |
199 webrtc::PacketDirection direction) { | 181 webrtc::PacketDirection direction) { |
200 webrtc::rtcp::Bye bye; | 182 webrtc::rtcp::Bye bye; |
201 if (!bye.Parse(rtcp_block)) | 183 if (!bye.Parse(rtcp_block)) |
202 return; | 184 return; |
203 webrtc::MediaType media_type = GetMediaType(bye.sender_ssrc(), direction); | 185 MediaType media_type = |
| 186 parsed_stream.GetMediaType(bye.sender_ssrc(), direction); |
204 if (ExcludePacket(direction, media_type, bye.sender_ssrc())) | 187 if (ExcludePacket(direction, media_type, bye.sender_ssrc())) |
205 return; | 188 return; |
206 std::cout << log_timestamp << "\t" | 189 std::cout << log_timestamp << "\t" |
207 << "RTCP_BYE" << StreamInfo(direction, media_type) | 190 << "RTCP_BYE" << StreamInfo(direction, media_type) |
208 << "\tssrc=" << bye.sender_ssrc() << std::endl; | 191 << "\tssrc=" << bye.sender_ssrc() << std::endl; |
209 } | 192 } |
210 | 193 |
211 void PrintRtpFeedback(const webrtc::rtcp::CommonHeader& rtcp_block, | 194 void PrintRtpFeedback(const webrtc::ParsedRtcEventLog& parsed_stream, |
| 195 const webrtc::rtcp::CommonHeader& rtcp_block, |
212 uint64_t log_timestamp, | 196 uint64_t log_timestamp, |
213 webrtc::PacketDirection direction) { | 197 webrtc::PacketDirection direction) { |
214 switch (rtcp_block.fmt()) { | 198 switch (rtcp_block.fmt()) { |
215 case webrtc::rtcp::Nack::kFeedbackMessageType: { | 199 case webrtc::rtcp::Nack::kFeedbackMessageType: { |
216 webrtc::rtcp::Nack nack; | 200 webrtc::rtcp::Nack nack; |
217 if (!nack.Parse(rtcp_block)) | 201 if (!nack.Parse(rtcp_block)) |
218 return; | 202 return; |
219 webrtc::MediaType media_type = | 203 MediaType media_type = |
220 GetMediaType(nack.sender_ssrc(), direction); | 204 parsed_stream.GetMediaType(nack.sender_ssrc(), direction); |
221 if (ExcludePacket(direction, media_type, nack.sender_ssrc())) | 205 if (ExcludePacket(direction, media_type, nack.sender_ssrc())) |
222 return; | 206 return; |
223 std::cout << log_timestamp << "\t" | 207 std::cout << log_timestamp << "\t" |
224 << "RTCP_NACK" << StreamInfo(direction, media_type) | 208 << "RTCP_NACK" << StreamInfo(direction, media_type) |
225 << "\tssrc=" << nack.sender_ssrc() << std::endl; | 209 << "\tssrc=" << nack.sender_ssrc() << std::endl; |
226 break; | 210 break; |
227 } | 211 } |
228 case webrtc::rtcp::Tmmbr::kFeedbackMessageType: { | 212 case webrtc::rtcp::Tmmbr::kFeedbackMessageType: { |
229 webrtc::rtcp::Tmmbr tmmbr; | 213 webrtc::rtcp::Tmmbr tmmbr; |
230 if (!tmmbr.Parse(rtcp_block)) | 214 if (!tmmbr.Parse(rtcp_block)) |
231 return; | 215 return; |
232 webrtc::MediaType media_type = | 216 MediaType media_type = |
233 GetMediaType(tmmbr.sender_ssrc(), direction); | 217 parsed_stream.GetMediaType(tmmbr.sender_ssrc(), direction); |
234 if (ExcludePacket(direction, media_type, tmmbr.sender_ssrc())) | 218 if (ExcludePacket(direction, media_type, tmmbr.sender_ssrc())) |
235 return; | 219 return; |
236 std::cout << log_timestamp << "\t" | 220 std::cout << log_timestamp << "\t" |
237 << "RTCP_TMMBR" << StreamInfo(direction, media_type) | 221 << "RTCP_TMMBR" << StreamInfo(direction, media_type) |
238 << "\tssrc=" << tmmbr.sender_ssrc() << std::endl; | 222 << "\tssrc=" << tmmbr.sender_ssrc() << std::endl; |
239 break; | 223 break; |
240 } | 224 } |
241 case webrtc::rtcp::Tmmbn::kFeedbackMessageType: { | 225 case webrtc::rtcp::Tmmbn::kFeedbackMessageType: { |
242 webrtc::rtcp::Tmmbn tmmbn; | 226 webrtc::rtcp::Tmmbn tmmbn; |
243 if (!tmmbn.Parse(rtcp_block)) | 227 if (!tmmbn.Parse(rtcp_block)) |
244 return; | 228 return; |
245 webrtc::MediaType media_type = | 229 MediaType media_type = |
246 GetMediaType(tmmbn.sender_ssrc(), direction); | 230 parsed_stream.GetMediaType(tmmbn.sender_ssrc(), direction); |
247 if (ExcludePacket(direction, media_type, tmmbn.sender_ssrc())) | 231 if (ExcludePacket(direction, media_type, tmmbn.sender_ssrc())) |
248 return; | 232 return; |
249 std::cout << log_timestamp << "\t" | 233 std::cout << log_timestamp << "\t" |
250 << "RTCP_TMMBN" << StreamInfo(direction, media_type) | 234 << "RTCP_TMMBN" << StreamInfo(direction, media_type) |
251 << "\tssrc=" << tmmbn.sender_ssrc() << std::endl; | 235 << "\tssrc=" << tmmbn.sender_ssrc() << std::endl; |
252 break; | 236 break; |
253 } | 237 } |
254 case webrtc::rtcp::RapidResyncRequest::kFeedbackMessageType: { | 238 case webrtc::rtcp::RapidResyncRequest::kFeedbackMessageType: { |
255 webrtc::rtcp::RapidResyncRequest sr_req; | 239 webrtc::rtcp::RapidResyncRequest sr_req; |
256 if (!sr_req.Parse(rtcp_block)) | 240 if (!sr_req.Parse(rtcp_block)) |
257 return; | 241 return; |
258 webrtc::MediaType media_type = | 242 MediaType media_type = |
259 GetMediaType(sr_req.sender_ssrc(), direction); | 243 parsed_stream.GetMediaType(sr_req.sender_ssrc(), direction); |
260 if (ExcludePacket(direction, media_type, sr_req.sender_ssrc())) | 244 if (ExcludePacket(direction, media_type, sr_req.sender_ssrc())) |
261 return; | 245 return; |
262 std::cout << log_timestamp << "\t" | 246 std::cout << log_timestamp << "\t" |
263 << "RTCP_SRREQ" << StreamInfo(direction, media_type) | 247 << "RTCP_SRREQ" << StreamInfo(direction, media_type) |
264 << "\tssrc=" << sr_req.sender_ssrc() << std::endl; | 248 << "\tssrc=" << sr_req.sender_ssrc() << std::endl; |
265 break; | 249 break; |
266 } | 250 } |
267 case webrtc::rtcp::TransportFeedback::kFeedbackMessageType: { | 251 case webrtc::rtcp::TransportFeedback::kFeedbackMessageType: { |
268 webrtc::rtcp::TransportFeedback transport_feedback; | 252 webrtc::rtcp::TransportFeedback transport_feedback; |
269 if (!transport_feedback.Parse(rtcp_block)) | 253 if (!transport_feedback.Parse(rtcp_block)) |
270 return; | 254 return; |
271 webrtc::MediaType media_type = | 255 MediaType media_type = parsed_stream.GetMediaType( |
272 GetMediaType(transport_feedback.sender_ssrc(), direction); | 256 transport_feedback.sender_ssrc(), direction); |
273 if (ExcludePacket(direction, media_type, | 257 if (ExcludePacket(direction, media_type, |
274 transport_feedback.sender_ssrc())) | 258 transport_feedback.sender_ssrc())) |
275 return; | 259 return; |
276 std::cout << log_timestamp << "\t" | 260 std::cout << log_timestamp << "\t" |
277 << "RTCP_NEWFB" << StreamInfo(direction, media_type) | 261 << "RTCP_NEWFB" << StreamInfo(direction, media_type) |
278 << "\tssrc=" << transport_feedback.sender_ssrc() << std::endl; | 262 << "\tssrc=" << transport_feedback.sender_ssrc() << std::endl; |
279 break; | 263 break; |
280 } | 264 } |
281 default: | 265 default: |
282 break; | 266 break; |
283 } | 267 } |
284 } | 268 } |
285 | 269 |
286 void PrintPsFeedback(const webrtc::rtcp::CommonHeader& rtcp_block, | 270 void PrintPsFeedback(const webrtc::ParsedRtcEventLog& parsed_stream, |
| 271 const webrtc::rtcp::CommonHeader& rtcp_block, |
287 uint64_t log_timestamp, | 272 uint64_t log_timestamp, |
288 webrtc::PacketDirection direction) { | 273 webrtc::PacketDirection direction) { |
289 switch (rtcp_block.fmt()) { | 274 switch (rtcp_block.fmt()) { |
290 case webrtc::rtcp::Pli::kFeedbackMessageType: { | 275 case webrtc::rtcp::Pli::kFeedbackMessageType: { |
291 webrtc::rtcp::Pli pli; | 276 webrtc::rtcp::Pli pli; |
292 if (!pli.Parse(rtcp_block)) | 277 if (!pli.Parse(rtcp_block)) |
293 return; | 278 return; |
294 webrtc::MediaType media_type = GetMediaType(pli.sender_ssrc(), direction); | 279 MediaType media_type = |
| 280 parsed_stream.GetMediaType(pli.sender_ssrc(), direction); |
295 if (ExcludePacket(direction, media_type, pli.sender_ssrc())) | 281 if (ExcludePacket(direction, media_type, pli.sender_ssrc())) |
296 return; | 282 return; |
297 std::cout << log_timestamp << "\t" | 283 std::cout << log_timestamp << "\t" |
298 << "RTCP_PLI" << StreamInfo(direction, media_type) | 284 << "RTCP_PLI" << StreamInfo(direction, media_type) |
299 << "\tssrc=" << pli.sender_ssrc() << std::endl; | 285 << "\tssrc=" << pli.sender_ssrc() << std::endl; |
300 break; | 286 break; |
301 } | 287 } |
302 case webrtc::rtcp::Fir::kFeedbackMessageType: { | 288 case webrtc::rtcp::Fir::kFeedbackMessageType: { |
303 webrtc::rtcp::Fir fir; | 289 webrtc::rtcp::Fir fir; |
304 if (!fir.Parse(rtcp_block)) | 290 if (!fir.Parse(rtcp_block)) |
305 return; | 291 return; |
306 webrtc::MediaType media_type = GetMediaType(fir.sender_ssrc(), direction); | 292 MediaType media_type = |
| 293 parsed_stream.GetMediaType(fir.sender_ssrc(), direction); |
307 if (ExcludePacket(direction, media_type, fir.sender_ssrc())) | 294 if (ExcludePacket(direction, media_type, fir.sender_ssrc())) |
308 return; | 295 return; |
309 std::cout << log_timestamp << "\t" | 296 std::cout << log_timestamp << "\t" |
310 << "RTCP_FIR" << StreamInfo(direction, media_type) | 297 << "RTCP_FIR" << StreamInfo(direction, media_type) |
311 << "\tssrc=" << fir.sender_ssrc() << std::endl; | 298 << "\tssrc=" << fir.sender_ssrc() << std::endl; |
312 break; | 299 break; |
313 } | 300 } |
314 case webrtc::rtcp::Remb::kFeedbackMessageType: { | 301 case webrtc::rtcp::Remb::kFeedbackMessageType: { |
315 webrtc::rtcp::Remb remb; | 302 webrtc::rtcp::Remb remb; |
316 if (!remb.Parse(rtcp_block)) | 303 if (!remb.Parse(rtcp_block)) |
317 return; | 304 return; |
318 webrtc::MediaType media_type = | 305 MediaType media_type = |
319 GetMediaType(remb.sender_ssrc(), direction); | 306 parsed_stream.GetMediaType(remb.sender_ssrc(), direction); |
320 if (ExcludePacket(direction, media_type, remb.sender_ssrc())) | 307 if (ExcludePacket(direction, media_type, remb.sender_ssrc())) |
321 return; | 308 return; |
322 std::cout << log_timestamp << "\t" | 309 std::cout << log_timestamp << "\t" |
323 << "RTCP_REMB" << StreamInfo(direction, media_type) | 310 << "RTCP_REMB" << StreamInfo(direction, media_type) |
324 << "\tssrc=" << remb.sender_ssrc() << std::endl; | 311 << "\tssrc=" << remb.sender_ssrc() << std::endl; |
325 break; | 312 break; |
326 } | 313 } |
327 default: | 314 default: |
328 break; | 315 break; |
329 } | 316 } |
(...skipping 25 matching lines...) Expand all Loading... |
355 if (!FLAGS_ssrc.empty()) | 342 if (!FLAGS_ssrc.empty()) |
356 RTC_CHECK(ParseSsrc(FLAGS_ssrc)) << "Flag verification has failed."; | 343 RTC_CHECK(ParseSsrc(FLAGS_ssrc)) << "Flag verification has failed."; |
357 | 344 |
358 webrtc::ParsedRtcEventLog parsed_stream; | 345 webrtc::ParsedRtcEventLog parsed_stream; |
359 if (!parsed_stream.ParseFile(input_file)) { | 346 if (!parsed_stream.ParseFile(input_file)) { |
360 std::cerr << "Error while parsing input file: " << input_file << std::endl; | 347 std::cerr << "Error while parsing input file: " << input_file << std::endl; |
361 return -1; | 348 return -1; |
362 } | 349 } |
363 | 350 |
364 for (size_t i = 0; i < parsed_stream.GetNumberOfEvents(); i++) { | 351 for (size_t i = 0; i < parsed_stream.GetNumberOfEvents(); i++) { |
365 if (parsed_stream.GetEventType(i) == | 352 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_noincoming && |
366 webrtc::ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT) { | 353 parsed_stream.GetEventType(i) == |
| 354 webrtc::ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT) { |
367 webrtc::rtclog::StreamConfig config; | 355 webrtc::rtclog::StreamConfig config; |
368 parsed_stream.GetVideoReceiveConfig(i, &config); | 356 parsed_stream.GetVideoReceiveConfig(i, &config); |
369 | 357 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_RECV_CONFIG" |
370 global_streams.emplace_back(config.remote_ssrc, | |
371 webrtc::MediaType::VIDEO, | |
372 webrtc::kIncomingPacket); | |
373 global_streams.emplace_back(config.local_ssrc, | |
374 webrtc::MediaType::VIDEO, | |
375 webrtc::kOutgoingPacket); | |
376 | |
377 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_noincoming) { | |
378 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_RECV_CONFIG" | |
379 << "\tssrc=" << config.remote_ssrc | 358 << "\tssrc=" << config.remote_ssrc |
380 << "\tfeedback_ssrc=" << config.local_ssrc << std::endl; | 359 << "\tfeedback_ssrc=" << config.local_ssrc << std::endl; |
381 } | |
382 } | 360 } |
383 if (parsed_stream.GetEventType(i) == | 361 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_nooutgoing && |
384 webrtc::ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT) { | 362 parsed_stream.GetEventType(i) == |
| 363 webrtc::ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT) { |
385 webrtc::rtclog::StreamConfig config; | 364 webrtc::rtclog::StreamConfig config; |
386 parsed_stream.GetVideoSendConfig(i, &config); | 365 parsed_stream.GetVideoSendConfig(i, &config); |
387 global_streams.emplace_back(config.local_ssrc, webrtc::MediaType::VIDEO, | |
388 webrtc::kOutgoingPacket); | |
389 | |
390 global_streams.emplace_back(config.rtx_ssrc, webrtc::MediaType::VIDEO, | |
391 webrtc::kOutgoingPacket); | |
392 | |
393 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_nooutgoing) { | |
394 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_SEND_CONFIG"; | 366 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_SEND_CONFIG"; |
395 std::cout << "\tssrcs=" << config.local_ssrc; | 367 std::cout << "\tssrcs=" << config.local_ssrc; |
396 std::cout << "\trtx_ssrcs=" << config.rtx_ssrc; | 368 std::cout << "\trtx_ssrcs=" << config.rtx_ssrc; |
397 std::cout << std::endl; | 369 std::cout << std::endl; |
398 } | |
399 } | 370 } |
400 if (parsed_stream.GetEventType(i) == | 371 if (!FLAGS_noconfig && !FLAGS_noaudio && !FLAGS_noincoming && |
401 webrtc::ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT) { | 372 parsed_stream.GetEventType(i) == |
| 373 webrtc::ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT) { |
402 webrtc::rtclog::StreamConfig config; | 374 webrtc::rtclog::StreamConfig config; |
403 parsed_stream.GetAudioReceiveConfig(i, &config); | 375 parsed_stream.GetAudioReceiveConfig(i, &config); |
404 global_streams.emplace_back(config.remote_ssrc, | 376 std::cout << parsed_stream.GetTimestamp(i) << "\tAUDIO_RECV_CONFIG" |
405 webrtc::MediaType::AUDIO, | 377 << "\tssrc=" << config.remote_ssrc |
406 webrtc::kIncomingPacket); | 378 << "\tfeedback_ssrc=" << config.local_ssrc << std::endl; |
407 global_streams.emplace_back(config.local_ssrc, | |
408 webrtc::MediaType::AUDIO, | |
409 webrtc::kOutgoingPacket); | |
410 if (!FLAGS_noconfig && !FLAGS_noaudio && !FLAGS_noincoming) { | |
411 std::cout << parsed_stream.GetTimestamp(i) << "\tAUDIO_RECV_CONFIG" | |
412 << "\tssrc=" << config.remote_ssrc | |
413 << "\tfeedback_ssrc=" << config.local_ssrc << std::endl; | |
414 } | |
415 } | 379 } |
416 if (parsed_stream.GetEventType(i) == | 380 if (!FLAGS_noconfig && !FLAGS_noaudio && !FLAGS_nooutgoing && |
417 webrtc::ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT) { | 381 parsed_stream.GetEventType(i) == |
| 382 webrtc::ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT) { |
418 webrtc::rtclog::StreamConfig config; | 383 webrtc::rtclog::StreamConfig config; |
419 parsed_stream.GetAudioSendConfig(i, &config); | 384 parsed_stream.GetAudioSendConfig(i, &config); |
420 global_streams.emplace_back(config.local_ssrc, webrtc::MediaType::AUDIO, | 385 std::cout << parsed_stream.GetTimestamp(i) << "\tAUDIO_SEND_CONFIG" |
421 webrtc::kOutgoingPacket); | 386 << "\tssrc=" << config.local_ssrc << std::endl; |
422 if (!FLAGS_noconfig && !FLAGS_noaudio && !FLAGS_nooutgoing) { | |
423 std::cout << parsed_stream.GetTimestamp(i) << "\tAUDIO_SEND_CONFIG" | |
424 << "\tssrc=" << config.local_ssrc << std::endl; | |
425 } | |
426 } | 387 } |
427 if (!FLAGS_nortp && | 388 if (!FLAGS_nortp && |
428 parsed_stream.GetEventType(i) == webrtc::ParsedRtcEventLog::RTP_EVENT) { | 389 parsed_stream.GetEventType(i) == webrtc::ParsedRtcEventLog::RTP_EVENT) { |
429 size_t header_length; | 390 size_t header_length; |
430 size_t total_length; | 391 size_t total_length; |
431 uint8_t header[IP_PACKET_SIZE]; | 392 uint8_t header[IP_PACKET_SIZE]; |
432 webrtc::PacketDirection direction; | 393 webrtc::PacketDirection direction; |
433 webrtc::MediaType media_type; | 394 |
434 parsed_stream.GetRtpHeader(i, &direction, &media_type, header, | 395 parsed_stream.GetRtpHeader(i, &direction, header, &header_length, |
435 &header_length, &total_length); | 396 &total_length); |
436 | 397 |
437 // Parse header to get SSRC and RTP time. | 398 // Parse header to get SSRC and RTP time. |
438 webrtc::RtpUtility::RtpHeaderParser rtp_parser(header, header_length); | 399 webrtc::RtpUtility::RtpHeaderParser rtp_parser(header, header_length); |
439 webrtc::RTPHeader parsed_header; | 400 webrtc::RTPHeader parsed_header; |
440 rtp_parser.Parse(&parsed_header); | 401 rtp_parser.Parse(&parsed_header); |
441 media_type = GetMediaType(parsed_header.ssrc, direction); | 402 MediaType media_type = |
| 403 parsed_stream.GetMediaType(parsed_header.ssrc, direction); |
442 | 404 |
443 if (ExcludePacket(direction, media_type, parsed_header.ssrc)) | 405 if (ExcludePacket(direction, media_type, parsed_header.ssrc)) |
444 continue; | 406 continue; |
445 | 407 |
446 std::cout << parsed_stream.GetTimestamp(i) << "\tRTP" | 408 std::cout << parsed_stream.GetTimestamp(i) << "\tRTP" |
447 << StreamInfo(direction, media_type) | 409 << StreamInfo(direction, media_type) |
448 << "\tssrc=" << parsed_header.ssrc | 410 << "\tssrc=" << parsed_header.ssrc |
449 << "\ttimestamp=" << parsed_header.timestamp << std::endl; | 411 << "\ttimestamp=" << parsed_header.timestamp << std::endl; |
450 } | 412 } |
451 if (!FLAGS_nortcp && | 413 if (!FLAGS_nortcp && |
452 parsed_stream.GetEventType(i) == | 414 parsed_stream.GetEventType(i) == |
453 webrtc::ParsedRtcEventLog::RTCP_EVENT) { | 415 webrtc::ParsedRtcEventLog::RTCP_EVENT) { |
454 size_t length; | 416 size_t length; |
455 uint8_t packet[IP_PACKET_SIZE]; | 417 uint8_t packet[IP_PACKET_SIZE]; |
456 webrtc::PacketDirection direction; | 418 webrtc::PacketDirection direction; |
457 webrtc::MediaType media_type; | 419 parsed_stream.GetRtcpPacket(i, &direction, packet, &length); |
458 parsed_stream.GetRtcpPacket(i, &direction, &media_type, packet, &length); | |
459 | 420 |
460 webrtc::rtcp::CommonHeader rtcp_block; | 421 webrtc::rtcp::CommonHeader rtcp_block; |
461 const uint8_t* packet_end = packet + length; | 422 const uint8_t* packet_end = packet + length; |
462 for (const uint8_t* next_block = packet; next_block != packet_end; | 423 for (const uint8_t* next_block = packet; next_block != packet_end; |
463 next_block = rtcp_block.NextPacket()) { | 424 next_block = rtcp_block.NextPacket()) { |
464 ptrdiff_t remaining_blocks_size = packet_end - next_block; | 425 ptrdiff_t remaining_blocks_size = packet_end - next_block; |
465 RTC_DCHECK_GT(remaining_blocks_size, 0); | 426 RTC_DCHECK_GT(remaining_blocks_size, 0); |
466 if (!rtcp_block.Parse(next_block, remaining_blocks_size)) { | 427 if (!rtcp_block.Parse(next_block, remaining_blocks_size)) { |
467 break; | 428 break; |
468 } | 429 } |
469 | 430 |
470 uint64_t log_timestamp = parsed_stream.GetTimestamp(i); | 431 uint64_t log_timestamp = parsed_stream.GetTimestamp(i); |
471 switch (rtcp_block.type()) { | 432 switch (rtcp_block.type()) { |
472 case webrtc::rtcp::SenderReport::kPacketType: | 433 case webrtc::rtcp::SenderReport::kPacketType: |
473 PrintSenderReport(rtcp_block, log_timestamp, direction); | 434 PrintSenderReport(parsed_stream, rtcp_block, log_timestamp, |
| 435 direction); |
474 break; | 436 break; |
475 case webrtc::rtcp::ReceiverReport::kPacketType: | 437 case webrtc::rtcp::ReceiverReport::kPacketType: |
476 PrintReceiverReport(rtcp_block, log_timestamp, direction); | 438 PrintReceiverReport(parsed_stream, rtcp_block, log_timestamp, |
| 439 direction); |
477 break; | 440 break; |
478 case webrtc::rtcp::Sdes::kPacketType: | 441 case webrtc::rtcp::Sdes::kPacketType: |
479 PrintSdes(rtcp_block, log_timestamp, direction); | 442 PrintSdes(rtcp_block, log_timestamp, direction); |
480 break; | 443 break; |
481 case webrtc::rtcp::ExtendedReports::kPacketType: | 444 case webrtc::rtcp::ExtendedReports::kPacketType: |
482 PrintXr(rtcp_block, log_timestamp, direction); | 445 PrintXr(parsed_stream, rtcp_block, log_timestamp, direction); |
483 break; | 446 break; |
484 case webrtc::rtcp::Bye::kPacketType: | 447 case webrtc::rtcp::Bye::kPacketType: |
485 PrintBye(rtcp_block, log_timestamp, direction); | 448 PrintBye(parsed_stream, rtcp_block, log_timestamp, direction); |
486 break; | 449 break; |
487 case webrtc::rtcp::Rtpfb::kPacketType: | 450 case webrtc::rtcp::Rtpfb::kPacketType: |
488 PrintRtpFeedback(rtcp_block, log_timestamp, direction); | 451 PrintRtpFeedback(parsed_stream, rtcp_block, log_timestamp, |
| 452 direction); |
489 break; | 453 break; |
490 case webrtc::rtcp::Psfb::kPacketType: | 454 case webrtc::rtcp::Psfb::kPacketType: |
491 PrintPsFeedback(rtcp_block, log_timestamp, direction); | 455 PrintPsFeedback(parsed_stream, rtcp_block, log_timestamp, |
| 456 direction); |
492 break; | 457 break; |
493 default: | 458 default: |
494 break; | 459 break; |
495 } | 460 } |
496 } | 461 } |
497 } | 462 } |
498 } | 463 } |
499 return 0; | 464 return 0; |
500 } | 465 } |
OLD | NEW |