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 enum class MediaType { ANY, AUDIO, VIDEO, DATA }; | |
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 used for storing SSRCs used in a Stream. |
77 struct Stream { | 78 struct Stream { |
78 Stream(uint32_t ssrc, | 79 Stream(uint32_t ssrc, MediaType media_type, webrtc::PacketDirection direction) |
79 webrtc::MediaType media_type, | |
80 webrtc::PacketDirection direction) | |
81 : ssrc(ssrc), media_type(media_type), direction(direction) {} | 80 : ssrc(ssrc), media_type(media_type), direction(direction) {} |
82 uint32_t ssrc; | 81 uint32_t ssrc; |
83 webrtc::MediaType media_type; | 82 MediaType media_type; |
84 webrtc::PacketDirection direction; | 83 webrtc::PacketDirection direction; |
85 }; | 84 }; |
86 | 85 |
87 // All configured streams found in the event log. | 86 // All configured streams found in the event log. |
88 std::vector<Stream> global_streams; | 87 std::vector<Stream> global_streams; |
89 | 88 |
90 // Returns the MediaType for registered SSRCs. Search from the end to use last | 89 // Returns the MediaType for registered SSRCs. Search from the end to use last |
91 // registered types first. | 90 // registered types first. |
92 webrtc::MediaType GetMediaType(uint32_t ssrc, | 91 MediaType GetMediaType(uint32_t ssrc, webrtc::PacketDirection direction) { |
93 webrtc::PacketDirection direction) { | |
94 for (auto rit = global_streams.rbegin(); rit != global_streams.rend(); | 92 for (auto rit = global_streams.rbegin(); rit != global_streams.rend(); |
95 ++rit) { | 93 ++rit) { |
96 if (rit->ssrc == ssrc && rit->direction == direction) | 94 if (rit->ssrc == ssrc && rit->direction == direction) |
97 return rit->media_type; | 95 return rit->media_type; |
98 } | 96 } |
99 return webrtc::MediaType::ANY; | 97 return MediaType::ANY; |
100 } | 98 } |
101 | 99 |
102 bool ExcludePacket(webrtc::PacketDirection direction, | 100 bool ExcludePacket(webrtc::PacketDirection direction, |
103 webrtc::MediaType media_type, | 101 MediaType media_type, |
104 uint32_t packet_ssrc) { | 102 uint32_t packet_ssrc) { |
105 if (FLAGS_nooutgoing && direction == webrtc::kOutgoingPacket) | 103 if (FLAGS_nooutgoing && direction == webrtc::kOutgoingPacket) |
106 return true; | 104 return true; |
107 if (FLAGS_noincoming && direction == webrtc::kIncomingPacket) | 105 if (FLAGS_noincoming && direction == webrtc::kIncomingPacket) |
108 return true; | 106 return true; |
109 if (FLAGS_noaudio && media_type == webrtc::MediaType::AUDIO) | 107 if (FLAGS_noaudio && media_type == MediaType::AUDIO) |
110 return true; | 108 return true; |
111 if (FLAGS_novideo && media_type == webrtc::MediaType::VIDEO) | 109 if (FLAGS_novideo && media_type == MediaType::VIDEO) |
112 return true; | 110 return true; |
113 if (FLAGS_nodata && media_type == webrtc::MediaType::DATA) | 111 if (FLAGS_nodata && media_type == MediaType::DATA) |
114 return true; | 112 return true; |
115 if (!FLAGS_ssrc.empty() && packet_ssrc != filtered_ssrc) | 113 if (!FLAGS_ssrc.empty() && packet_ssrc != filtered_ssrc) |
116 return true; | 114 return true; |
117 return false; | 115 return false; |
118 } | 116 } |
119 | 117 |
120 const char* StreamInfo(webrtc::PacketDirection direction, | 118 const char* StreamInfo(webrtc::PacketDirection direction, |
terelius
2017/05/23 11:57:58
This could be a toString() on the Stream object.
perkj_webrtc
2017/05/24 12:32:21
Prefer not to. I moved the Stream into the parser.
| |
121 webrtc::MediaType media_type) { | 119 MediaType media_type) { |
122 if (direction == webrtc::kOutgoingPacket) { | 120 if (direction == webrtc::kOutgoingPacket) { |
123 if (media_type == webrtc::MediaType::AUDIO) | 121 if (media_type == MediaType::AUDIO) |
124 return "(out,audio)"; | 122 return "(out,audio)"; |
125 else if (media_type == webrtc::MediaType::VIDEO) | 123 else if (media_type == MediaType::VIDEO) |
126 return "(out,video)"; | 124 return "(out,video)"; |
127 else if (media_type == webrtc::MediaType::DATA) | 125 else if (media_type == MediaType::DATA) |
128 return "(out,data)"; | 126 return "(out,data)"; |
129 else | 127 else |
130 return "(out)"; | 128 return "(out)"; |
131 } | 129 } |
132 if (direction == webrtc::kIncomingPacket) { | 130 if (direction == webrtc::kIncomingPacket) { |
133 if (media_type == webrtc::MediaType::AUDIO) | 131 if (media_type == MediaType::AUDIO) |
134 return "(in,audio)"; | 132 return "(in,audio)"; |
135 else if (media_type == webrtc::MediaType::VIDEO) | 133 else if (media_type == MediaType::VIDEO) |
136 return "(in,video)"; | 134 return "(in,video)"; |
137 else if (media_type == webrtc::MediaType::DATA) | 135 else if (media_type == MediaType::DATA) |
138 return "(in,data)"; | 136 return "(in,data)"; |
139 else | 137 else |
140 return "(in)"; | 138 return "(in)"; |
141 } | 139 } |
142 return "(unknown)"; | 140 return "(unknown)"; |
143 } | 141 } |
144 | 142 |
145 void PrintSenderReport(const webrtc::rtcp::CommonHeader& rtcp_block, | 143 void PrintSenderReport(const webrtc::rtcp::CommonHeader& rtcp_block, |
146 uint64_t log_timestamp, | 144 uint64_t log_timestamp, |
147 webrtc::PacketDirection direction) { | 145 webrtc::PacketDirection direction) { |
148 webrtc::rtcp::SenderReport sr; | 146 webrtc::rtcp::SenderReport sr; |
149 if (!sr.Parse(rtcp_block)) | 147 if (!sr.Parse(rtcp_block)) |
150 return; | 148 return; |
151 webrtc::MediaType media_type = GetMediaType(sr.sender_ssrc(), direction); | 149 MediaType media_type = GetMediaType(sr.sender_ssrc(), direction); |
152 if (ExcludePacket(direction, media_type, sr.sender_ssrc())) | 150 if (ExcludePacket(direction, media_type, sr.sender_ssrc())) |
153 return; | 151 return; |
154 std::cout << log_timestamp << "\t" | 152 std::cout << log_timestamp << "\t" |
155 << "RTCP_SR" << StreamInfo(direction, media_type) | 153 << "RTCP_SR" << StreamInfo(direction, media_type) |
156 << "\tssrc=" << sr.sender_ssrc() | 154 << "\tssrc=" << sr.sender_ssrc() |
157 << "\ttimestamp=" << sr.rtp_timestamp() << std::endl; | 155 << "\ttimestamp=" << sr.rtp_timestamp() << std::endl; |
158 } | 156 } |
159 | 157 |
160 void PrintReceiverReport(const webrtc::rtcp::CommonHeader& rtcp_block, | 158 void PrintReceiverReport(const webrtc::rtcp::CommonHeader& rtcp_block, |
161 uint64_t log_timestamp, | 159 uint64_t log_timestamp, |
162 webrtc::PacketDirection direction) { | 160 webrtc::PacketDirection direction) { |
163 webrtc::rtcp::ReceiverReport rr; | 161 webrtc::rtcp::ReceiverReport rr; |
164 if (!rr.Parse(rtcp_block)) | 162 if (!rr.Parse(rtcp_block)) |
165 return; | 163 return; |
166 webrtc::MediaType media_type = GetMediaType(rr.sender_ssrc(), direction); | 164 MediaType media_type = GetMediaType(rr.sender_ssrc(), direction); |
167 if (ExcludePacket(direction, media_type, rr.sender_ssrc())) | 165 if (ExcludePacket(direction, media_type, rr.sender_ssrc())) |
168 return; | 166 return; |
169 std::cout << log_timestamp << "\t" | 167 std::cout << log_timestamp << "\t" |
170 << "RTCP_RR" << StreamInfo(direction, media_type) | 168 << "RTCP_RR" << StreamInfo(direction, media_type) |
171 << "\tssrc=" << rr.sender_ssrc() << std::endl; | 169 << "\tssrc=" << rr.sender_ssrc() << std::endl; |
172 } | 170 } |
173 | 171 |
174 void PrintXr(const webrtc::rtcp::CommonHeader& rtcp_block, | 172 void PrintXr(const webrtc::rtcp::CommonHeader& rtcp_block, |
175 uint64_t log_timestamp, | 173 uint64_t log_timestamp, |
176 webrtc::PacketDirection direction) { | 174 webrtc::PacketDirection direction) { |
177 webrtc::rtcp::ExtendedReports xr; | 175 webrtc::rtcp::ExtendedReports xr; |
178 if (!xr.Parse(rtcp_block)) | 176 if (!xr.Parse(rtcp_block)) |
179 return; | 177 return; |
180 webrtc::MediaType media_type = GetMediaType(xr.sender_ssrc(), direction); | 178 MediaType media_type = GetMediaType(xr.sender_ssrc(), direction); |
181 if (ExcludePacket(direction, media_type, xr.sender_ssrc())) | 179 if (ExcludePacket(direction, media_type, xr.sender_ssrc())) |
182 return; | 180 return; |
183 std::cout << log_timestamp << "\t" | 181 std::cout << log_timestamp << "\t" |
184 << "RTCP_XR" << StreamInfo(direction, media_type) | 182 << "RTCP_XR" << StreamInfo(direction, media_type) |
185 << "\tssrc=" << xr.sender_ssrc() << std::endl; | 183 << "\tssrc=" << xr.sender_ssrc() << std::endl; |
186 } | 184 } |
187 | 185 |
188 void PrintSdes(const webrtc::rtcp::CommonHeader& rtcp_block, | 186 void PrintSdes(const webrtc::rtcp::CommonHeader& rtcp_block, |
189 uint64_t log_timestamp, | 187 uint64_t log_timestamp, |
190 webrtc::PacketDirection direction) { | 188 webrtc::PacketDirection direction) { |
191 std::cout << log_timestamp << "\t" | 189 std::cout << log_timestamp << "\t" |
192 << "RTCP_SDES" << StreamInfo(direction, webrtc::MediaType::ANY) | 190 << "RTCP_SDES" << StreamInfo(direction, MediaType::ANY) |
193 << std::endl; | 191 << std::endl; |
194 RTC_NOTREACHED() << "SDES should have been redacted when writing the log"; | 192 RTC_NOTREACHED() << "SDES should have been redacted when writing the log"; |
195 } | 193 } |
196 | 194 |
197 void PrintBye(const webrtc::rtcp::CommonHeader& rtcp_block, | 195 void PrintBye(const webrtc::rtcp::CommonHeader& rtcp_block, |
198 uint64_t log_timestamp, | 196 uint64_t log_timestamp, |
199 webrtc::PacketDirection direction) { | 197 webrtc::PacketDirection direction) { |
200 webrtc::rtcp::Bye bye; | 198 webrtc::rtcp::Bye bye; |
201 if (!bye.Parse(rtcp_block)) | 199 if (!bye.Parse(rtcp_block)) |
202 return; | 200 return; |
203 webrtc::MediaType media_type = GetMediaType(bye.sender_ssrc(), direction); | 201 MediaType media_type = GetMediaType(bye.sender_ssrc(), direction); |
204 if (ExcludePacket(direction, media_type, bye.sender_ssrc())) | 202 if (ExcludePacket(direction, media_type, bye.sender_ssrc())) |
205 return; | 203 return; |
206 std::cout << log_timestamp << "\t" | 204 std::cout << log_timestamp << "\t" |
207 << "RTCP_BYE" << StreamInfo(direction, media_type) | 205 << "RTCP_BYE" << StreamInfo(direction, media_type) |
208 << "\tssrc=" << bye.sender_ssrc() << std::endl; | 206 << "\tssrc=" << bye.sender_ssrc() << std::endl; |
209 } | 207 } |
210 | 208 |
211 void PrintRtpFeedback(const webrtc::rtcp::CommonHeader& rtcp_block, | 209 void PrintRtpFeedback(const webrtc::rtcp::CommonHeader& rtcp_block, |
212 uint64_t log_timestamp, | 210 uint64_t log_timestamp, |
213 webrtc::PacketDirection direction) { | 211 webrtc::PacketDirection direction) { |
214 switch (rtcp_block.fmt()) { | 212 switch (rtcp_block.fmt()) { |
215 case webrtc::rtcp::Nack::kFeedbackMessageType: { | 213 case webrtc::rtcp::Nack::kFeedbackMessageType: { |
216 webrtc::rtcp::Nack nack; | 214 webrtc::rtcp::Nack nack; |
217 if (!nack.Parse(rtcp_block)) | 215 if (!nack.Parse(rtcp_block)) |
218 return; | 216 return; |
219 webrtc::MediaType media_type = | 217 MediaType media_type = GetMediaType(nack.sender_ssrc(), direction); |
220 GetMediaType(nack.sender_ssrc(), direction); | |
221 if (ExcludePacket(direction, media_type, nack.sender_ssrc())) | 218 if (ExcludePacket(direction, media_type, nack.sender_ssrc())) |
222 return; | 219 return; |
223 std::cout << log_timestamp << "\t" | 220 std::cout << log_timestamp << "\t" |
224 << "RTCP_NACK" << StreamInfo(direction, media_type) | 221 << "RTCP_NACK" << StreamInfo(direction, media_type) |
225 << "\tssrc=" << nack.sender_ssrc() << std::endl; | 222 << "\tssrc=" << nack.sender_ssrc() << std::endl; |
226 break; | 223 break; |
227 } | 224 } |
228 case webrtc::rtcp::Tmmbr::kFeedbackMessageType: { | 225 case webrtc::rtcp::Tmmbr::kFeedbackMessageType: { |
229 webrtc::rtcp::Tmmbr tmmbr; | 226 webrtc::rtcp::Tmmbr tmmbr; |
230 if (!tmmbr.Parse(rtcp_block)) | 227 if (!tmmbr.Parse(rtcp_block)) |
231 return; | 228 return; |
232 webrtc::MediaType media_type = | 229 MediaType media_type = GetMediaType(tmmbr.sender_ssrc(), direction); |
233 GetMediaType(tmmbr.sender_ssrc(), direction); | |
234 if (ExcludePacket(direction, media_type, tmmbr.sender_ssrc())) | 230 if (ExcludePacket(direction, media_type, tmmbr.sender_ssrc())) |
235 return; | 231 return; |
236 std::cout << log_timestamp << "\t" | 232 std::cout << log_timestamp << "\t" |
237 << "RTCP_TMMBR" << StreamInfo(direction, media_type) | 233 << "RTCP_TMMBR" << StreamInfo(direction, media_type) |
238 << "\tssrc=" << tmmbr.sender_ssrc() << std::endl; | 234 << "\tssrc=" << tmmbr.sender_ssrc() << std::endl; |
239 break; | 235 break; |
240 } | 236 } |
241 case webrtc::rtcp::Tmmbn::kFeedbackMessageType: { | 237 case webrtc::rtcp::Tmmbn::kFeedbackMessageType: { |
242 webrtc::rtcp::Tmmbn tmmbn; | 238 webrtc::rtcp::Tmmbn tmmbn; |
243 if (!tmmbn.Parse(rtcp_block)) | 239 if (!tmmbn.Parse(rtcp_block)) |
244 return; | 240 return; |
245 webrtc::MediaType media_type = | 241 MediaType media_type = GetMediaType(tmmbn.sender_ssrc(), direction); |
246 GetMediaType(tmmbn.sender_ssrc(), direction); | |
247 if (ExcludePacket(direction, media_type, tmmbn.sender_ssrc())) | 242 if (ExcludePacket(direction, media_type, tmmbn.sender_ssrc())) |
248 return; | 243 return; |
249 std::cout << log_timestamp << "\t" | 244 std::cout << log_timestamp << "\t" |
250 << "RTCP_TMMBN" << StreamInfo(direction, media_type) | 245 << "RTCP_TMMBN" << StreamInfo(direction, media_type) |
251 << "\tssrc=" << tmmbn.sender_ssrc() << std::endl; | 246 << "\tssrc=" << tmmbn.sender_ssrc() << std::endl; |
252 break; | 247 break; |
253 } | 248 } |
254 case webrtc::rtcp::RapidResyncRequest::kFeedbackMessageType: { | 249 case webrtc::rtcp::RapidResyncRequest::kFeedbackMessageType: { |
255 webrtc::rtcp::RapidResyncRequest sr_req; | 250 webrtc::rtcp::RapidResyncRequest sr_req; |
256 if (!sr_req.Parse(rtcp_block)) | 251 if (!sr_req.Parse(rtcp_block)) |
257 return; | 252 return; |
258 webrtc::MediaType media_type = | 253 MediaType media_type = GetMediaType(sr_req.sender_ssrc(), direction); |
259 GetMediaType(sr_req.sender_ssrc(), direction); | |
260 if (ExcludePacket(direction, media_type, sr_req.sender_ssrc())) | 254 if (ExcludePacket(direction, media_type, sr_req.sender_ssrc())) |
261 return; | 255 return; |
262 std::cout << log_timestamp << "\t" | 256 std::cout << log_timestamp << "\t" |
263 << "RTCP_SRREQ" << StreamInfo(direction, media_type) | 257 << "RTCP_SRREQ" << StreamInfo(direction, media_type) |
264 << "\tssrc=" << sr_req.sender_ssrc() << std::endl; | 258 << "\tssrc=" << sr_req.sender_ssrc() << std::endl; |
265 break; | 259 break; |
266 } | 260 } |
267 case webrtc::rtcp::TransportFeedback::kFeedbackMessageType: { | 261 case webrtc::rtcp::TransportFeedback::kFeedbackMessageType: { |
268 webrtc::rtcp::TransportFeedback transport_feedback; | 262 webrtc::rtcp::TransportFeedback transport_feedback; |
269 if (!transport_feedback.Parse(rtcp_block)) | 263 if (!transport_feedback.Parse(rtcp_block)) |
270 return; | 264 return; |
271 webrtc::MediaType media_type = | 265 MediaType media_type = |
272 GetMediaType(transport_feedback.sender_ssrc(), direction); | 266 GetMediaType(transport_feedback.sender_ssrc(), direction); |
273 if (ExcludePacket(direction, media_type, | 267 if (ExcludePacket(direction, media_type, |
274 transport_feedback.sender_ssrc())) | 268 transport_feedback.sender_ssrc())) |
275 return; | 269 return; |
276 std::cout << log_timestamp << "\t" | 270 std::cout << log_timestamp << "\t" |
277 << "RTCP_NEWFB" << StreamInfo(direction, media_type) | 271 << "RTCP_NEWFB" << StreamInfo(direction, media_type) |
278 << "\tssrc=" << transport_feedback.sender_ssrc() << std::endl; | 272 << "\tssrc=" << transport_feedback.sender_ssrc() << std::endl; |
279 break; | 273 break; |
280 } | 274 } |
281 default: | 275 default: |
282 break; | 276 break; |
283 } | 277 } |
284 } | 278 } |
285 | 279 |
286 void PrintPsFeedback(const webrtc::rtcp::CommonHeader& rtcp_block, | 280 void PrintPsFeedback(const webrtc::rtcp::CommonHeader& rtcp_block, |
287 uint64_t log_timestamp, | 281 uint64_t log_timestamp, |
288 webrtc::PacketDirection direction) { | 282 webrtc::PacketDirection direction) { |
289 switch (rtcp_block.fmt()) { | 283 switch (rtcp_block.fmt()) { |
290 case webrtc::rtcp::Pli::kFeedbackMessageType: { | 284 case webrtc::rtcp::Pli::kFeedbackMessageType: { |
291 webrtc::rtcp::Pli pli; | 285 webrtc::rtcp::Pli pli; |
292 if (!pli.Parse(rtcp_block)) | 286 if (!pli.Parse(rtcp_block)) |
293 return; | 287 return; |
294 webrtc::MediaType media_type = GetMediaType(pli.sender_ssrc(), direction); | 288 MediaType media_type = GetMediaType(pli.sender_ssrc(), direction); |
295 if (ExcludePacket(direction, media_type, pli.sender_ssrc())) | 289 if (ExcludePacket(direction, media_type, pli.sender_ssrc())) |
296 return; | 290 return; |
297 std::cout << log_timestamp << "\t" | 291 std::cout << log_timestamp << "\t" |
298 << "RTCP_PLI" << StreamInfo(direction, media_type) | 292 << "RTCP_PLI" << StreamInfo(direction, media_type) |
299 << "\tssrc=" << pli.sender_ssrc() << std::endl; | 293 << "\tssrc=" << pli.sender_ssrc() << std::endl; |
300 break; | 294 break; |
301 } | 295 } |
302 case webrtc::rtcp::Fir::kFeedbackMessageType: { | 296 case webrtc::rtcp::Fir::kFeedbackMessageType: { |
303 webrtc::rtcp::Fir fir; | 297 webrtc::rtcp::Fir fir; |
304 if (!fir.Parse(rtcp_block)) | 298 if (!fir.Parse(rtcp_block)) |
305 return; | 299 return; |
306 webrtc::MediaType media_type = GetMediaType(fir.sender_ssrc(), direction); | 300 MediaType media_type = GetMediaType(fir.sender_ssrc(), direction); |
307 if (ExcludePacket(direction, media_type, fir.sender_ssrc())) | 301 if (ExcludePacket(direction, media_type, fir.sender_ssrc())) |
308 return; | 302 return; |
309 std::cout << log_timestamp << "\t" | 303 std::cout << log_timestamp << "\t" |
310 << "RTCP_FIR" << StreamInfo(direction, media_type) | 304 << "RTCP_FIR" << StreamInfo(direction, media_type) |
311 << "\tssrc=" << fir.sender_ssrc() << std::endl; | 305 << "\tssrc=" << fir.sender_ssrc() << std::endl; |
312 break; | 306 break; |
313 } | 307 } |
314 case webrtc::rtcp::Remb::kFeedbackMessageType: { | 308 case webrtc::rtcp::Remb::kFeedbackMessageType: { |
315 webrtc::rtcp::Remb remb; | 309 webrtc::rtcp::Remb remb; |
316 if (!remb.Parse(rtcp_block)) | 310 if (!remb.Parse(rtcp_block)) |
317 return; | 311 return; |
318 webrtc::MediaType media_type = | 312 MediaType media_type = GetMediaType(remb.sender_ssrc(), direction); |
319 GetMediaType(remb.sender_ssrc(), direction); | |
320 if (ExcludePacket(direction, media_type, remb.sender_ssrc())) | 313 if (ExcludePacket(direction, media_type, remb.sender_ssrc())) |
321 return; | 314 return; |
322 std::cout << log_timestamp << "\t" | 315 std::cout << log_timestamp << "\t" |
323 << "RTCP_REMB" << StreamInfo(direction, media_type) | 316 << "RTCP_REMB" << StreamInfo(direction, media_type) |
324 << "\tssrc=" << remb.sender_ssrc() << std::endl; | 317 << "\tssrc=" << remb.sender_ssrc() << std::endl; |
325 break; | 318 break; |
326 } | 319 } |
327 default: | 320 default: |
328 break; | 321 break; |
329 } | 322 } |
(...skipping 30 matching lines...) Expand all Loading... | |
360 std::cerr << "Error while parsing input file: " << input_file << std::endl; | 353 std::cerr << "Error while parsing input file: " << input_file << std::endl; |
361 return -1; | 354 return -1; |
362 } | 355 } |
363 | 356 |
364 for (size_t i = 0; i < parsed_stream.GetNumberOfEvents(); i++) { | 357 for (size_t i = 0; i < parsed_stream.GetNumberOfEvents(); i++) { |
365 if (parsed_stream.GetEventType(i) == | 358 if (parsed_stream.GetEventType(i) == |
366 webrtc::ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT) { | 359 webrtc::ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT) { |
367 webrtc::rtclog::StreamConfig config; | 360 webrtc::rtclog::StreamConfig config; |
368 parsed_stream.GetVideoReceiveConfig(i, &config); | 361 parsed_stream.GetVideoReceiveConfig(i, &config); |
369 | 362 |
370 global_streams.emplace_back(config.remote_ssrc, | 363 global_streams.emplace_back(config.remote_ssrc, MediaType::VIDEO, |
371 webrtc::MediaType::VIDEO, | |
372 webrtc::kIncomingPacket); | 364 webrtc::kIncomingPacket); |
373 global_streams.emplace_back(config.local_ssrc, | 365 global_streams.emplace_back(config.local_ssrc, MediaType::VIDEO, |
374 webrtc::MediaType::VIDEO, | |
375 webrtc::kOutgoingPacket); | 366 webrtc::kOutgoingPacket); |
376 | 367 |
377 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_noincoming) { | 368 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_noincoming) { |
378 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_RECV_CONFIG" | 369 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_RECV_CONFIG" |
379 << "\tssrc=" << config.remote_ssrc | 370 << "\tssrc=" << config.remote_ssrc |
380 << "\tfeedback_ssrc=" << config.local_ssrc << std::endl; | 371 << "\tfeedback_ssrc=" << config.local_ssrc << std::endl; |
381 } | 372 } |
382 } | 373 } |
383 if (parsed_stream.GetEventType(i) == | 374 if (parsed_stream.GetEventType(i) == |
384 webrtc::ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT) { | 375 webrtc::ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT) { |
385 webrtc::rtclog::StreamConfig config; | 376 webrtc::rtclog::StreamConfig config; |
386 parsed_stream.GetVideoSendConfig(i, &config); | 377 parsed_stream.GetVideoSendConfig(i, &config); |
387 global_streams.emplace_back(config.local_ssrc, webrtc::MediaType::VIDEO, | 378 global_streams.emplace_back(config.local_ssrc, MediaType::VIDEO, |
388 webrtc::kOutgoingPacket); | 379 webrtc::kOutgoingPacket); |
389 | 380 |
390 global_streams.emplace_back(config.rtx_ssrc, webrtc::MediaType::VIDEO, | 381 global_streams.emplace_back(config.rtx_ssrc, MediaType::VIDEO, |
391 webrtc::kOutgoingPacket); | 382 webrtc::kOutgoingPacket); |
392 | 383 |
393 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_nooutgoing) { | 384 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_nooutgoing) { |
394 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_SEND_CONFIG"; | 385 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_SEND_CONFIG"; |
395 std::cout << "\tssrcs=" << config.local_ssrc; | 386 std::cout << "\tssrcs=" << config.local_ssrc; |
396 std::cout << "\trtx_ssrcs=" << config.rtx_ssrc; | 387 std::cout << "\trtx_ssrcs=" << config.rtx_ssrc; |
397 std::cout << std::endl; | 388 std::cout << std::endl; |
398 } | 389 } |
399 } | 390 } |
400 if (parsed_stream.GetEventType(i) == | 391 if (parsed_stream.GetEventType(i) == |
401 webrtc::ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT) { | 392 webrtc::ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT) { |
402 webrtc::rtclog::StreamConfig config; | 393 webrtc::rtclog::StreamConfig config; |
403 parsed_stream.GetAudioReceiveConfig(i, &config); | 394 parsed_stream.GetAudioReceiveConfig(i, &config); |
404 global_streams.emplace_back(config.remote_ssrc, | 395 global_streams.emplace_back(config.remote_ssrc, MediaType::AUDIO, |
405 webrtc::MediaType::AUDIO, | |
406 webrtc::kIncomingPacket); | 396 webrtc::kIncomingPacket); |
407 global_streams.emplace_back(config.local_ssrc, | 397 global_streams.emplace_back(config.local_ssrc, MediaType::AUDIO, |
408 webrtc::MediaType::AUDIO, | |
409 webrtc::kOutgoingPacket); | 398 webrtc::kOutgoingPacket); |
410 if (!FLAGS_noconfig && !FLAGS_noaudio && !FLAGS_noincoming) { | 399 if (!FLAGS_noconfig && !FLAGS_noaudio && !FLAGS_noincoming) { |
411 std::cout << parsed_stream.GetTimestamp(i) << "\tAUDIO_RECV_CONFIG" | 400 std::cout << parsed_stream.GetTimestamp(i) << "\tAUDIO_RECV_CONFIG" |
412 << "\tssrc=" << config.remote_ssrc | 401 << "\tssrc=" << config.remote_ssrc |
413 << "\tfeedback_ssrc=" << config.local_ssrc << std::endl; | 402 << "\tfeedback_ssrc=" << config.local_ssrc << std::endl; |
414 } | 403 } |
415 } | 404 } |
416 if (parsed_stream.GetEventType(i) == | 405 if (parsed_stream.GetEventType(i) == |
417 webrtc::ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT) { | 406 webrtc::ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT) { |
418 webrtc::rtclog::StreamConfig config; | 407 webrtc::rtclog::StreamConfig config; |
419 parsed_stream.GetAudioSendConfig(i, &config); | 408 parsed_stream.GetAudioSendConfig(i, &config); |
420 global_streams.emplace_back(config.local_ssrc, webrtc::MediaType::AUDIO, | 409 global_streams.emplace_back(config.local_ssrc, MediaType::AUDIO, |
421 webrtc::kOutgoingPacket); | 410 webrtc::kOutgoingPacket); |
422 if (!FLAGS_noconfig && !FLAGS_noaudio && !FLAGS_nooutgoing) { | 411 if (!FLAGS_noconfig && !FLAGS_noaudio && !FLAGS_nooutgoing) { |
423 std::cout << parsed_stream.GetTimestamp(i) << "\tAUDIO_SEND_CONFIG" | 412 std::cout << parsed_stream.GetTimestamp(i) << "\tAUDIO_SEND_CONFIG" |
424 << "\tssrc=" << config.local_ssrc << std::endl; | 413 << "\tssrc=" << config.local_ssrc << std::endl; |
425 } | 414 } |
426 } | 415 } |
427 if (!FLAGS_nortp && | 416 if (!FLAGS_nortp && |
428 parsed_stream.GetEventType(i) == webrtc::ParsedRtcEventLog::RTP_EVENT) { | 417 parsed_stream.GetEventType(i) == webrtc::ParsedRtcEventLog::RTP_EVENT) { |
429 size_t header_length; | 418 size_t header_length; |
430 size_t total_length; | 419 size_t total_length; |
431 uint8_t header[IP_PACKET_SIZE]; | 420 uint8_t header[IP_PACKET_SIZE]; |
432 webrtc::PacketDirection direction; | 421 webrtc::PacketDirection direction; |
433 webrtc::MediaType media_type; | 422 |
434 parsed_stream.GetRtpHeader(i, &direction, &media_type, header, | 423 parsed_stream.GetRtpHeader(i, &direction, header, &header_length, |
435 &header_length, &total_length); | 424 &total_length); |
436 | 425 |
437 // Parse header to get SSRC and RTP time. | 426 // Parse header to get SSRC and RTP time. |
438 webrtc::RtpUtility::RtpHeaderParser rtp_parser(header, header_length); | 427 webrtc::RtpUtility::RtpHeaderParser rtp_parser(header, header_length); |
439 webrtc::RTPHeader parsed_header; | 428 webrtc::RTPHeader parsed_header; |
440 rtp_parser.Parse(&parsed_header); | 429 rtp_parser.Parse(&parsed_header); |
441 media_type = GetMediaType(parsed_header.ssrc, direction); | 430 MediaType media_type = GetMediaType(parsed_header.ssrc, direction); |
442 | 431 |
443 if (ExcludePacket(direction, media_type, parsed_header.ssrc)) | 432 if (ExcludePacket(direction, media_type, parsed_header.ssrc)) |
444 continue; | 433 continue; |
445 | 434 |
446 std::cout << parsed_stream.GetTimestamp(i) << "\tRTP" | 435 std::cout << parsed_stream.GetTimestamp(i) << "\tRTP" |
447 << StreamInfo(direction, media_type) | 436 << StreamInfo(direction, media_type) |
448 << "\tssrc=" << parsed_header.ssrc | 437 << "\tssrc=" << parsed_header.ssrc |
449 << "\ttimestamp=" << parsed_header.timestamp << std::endl; | 438 << "\ttimestamp=" << parsed_header.timestamp << std::endl; |
450 } | 439 } |
451 if (!FLAGS_nortcp && | 440 if (!FLAGS_nortcp && |
452 parsed_stream.GetEventType(i) == | 441 parsed_stream.GetEventType(i) == |
453 webrtc::ParsedRtcEventLog::RTCP_EVENT) { | 442 webrtc::ParsedRtcEventLog::RTCP_EVENT) { |
454 size_t length; | 443 size_t length; |
455 uint8_t packet[IP_PACKET_SIZE]; | 444 uint8_t packet[IP_PACKET_SIZE]; |
456 webrtc::PacketDirection direction; | 445 webrtc::PacketDirection direction; |
457 webrtc::MediaType media_type; | 446 parsed_stream.GetRtcpPacket(i, &direction, packet, &length); |
458 parsed_stream.GetRtcpPacket(i, &direction, &media_type, packet, &length); | |
459 | 447 |
460 webrtc::rtcp::CommonHeader rtcp_block; | 448 webrtc::rtcp::CommonHeader rtcp_block; |
461 const uint8_t* packet_end = packet + length; | 449 const uint8_t* packet_end = packet + length; |
462 for (const uint8_t* next_block = packet; next_block != packet_end; | 450 for (const uint8_t* next_block = packet; next_block != packet_end; |
463 next_block = rtcp_block.NextPacket()) { | 451 next_block = rtcp_block.NextPacket()) { |
464 ptrdiff_t remaining_blocks_size = packet_end - next_block; | 452 ptrdiff_t remaining_blocks_size = packet_end - next_block; |
465 RTC_DCHECK_GT(remaining_blocks_size, 0); | 453 RTC_DCHECK_GT(remaining_blocks_size, 0); |
466 if (!rtcp_block.Parse(next_block, remaining_blocks_size)) { | 454 if (!rtcp_block.Parse(next_block, remaining_blocks_size)) { |
467 break; | 455 break; |
468 } | 456 } |
(...skipping 22 matching lines...) Expand all Loading... | |
491 PrintPsFeedback(rtcp_block, log_timestamp, direction); | 479 PrintPsFeedback(rtcp_block, log_timestamp, direction); |
492 break; | 480 break; |
493 default: | 481 default: |
494 break; | 482 break; |
495 } | 483 } |
496 } | 484 } |
497 } | 485 } |
498 } | 486 } |
499 return 0; | 487 return 0; |
500 } | 488 } |
OLD | NEW |