OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 int64_t min_difference = max_difference - modulus + 1; | 69 int64_t min_difference = max_difference - modulus + 1; |
70 if (difference > max_difference) { | 70 if (difference > max_difference) { |
71 difference -= modulus; | 71 difference -= modulus; |
72 } | 72 } |
73 if (difference < min_difference) { | 73 if (difference < min_difference) { |
74 difference += modulus; | 74 difference += modulus; |
75 } | 75 } |
76 return difference; | 76 return difference; |
77 } | 77 } |
78 | 78 |
79 class StreamId { | |
80 public: | |
81 StreamId(uint32_t ssrc, | |
82 webrtc::PacketDirection direction, | |
83 webrtc::MediaType media_type) | |
84 : ssrc_(ssrc), direction_(direction), media_type_(media_type) {} | |
85 | |
86 bool operator<(const StreamId& other) const { | |
87 if (ssrc_ < other.ssrc_) { | |
88 return true; | |
89 } | |
90 if (ssrc_ == other.ssrc_) { | |
91 if (media_type_ < other.media_type_) { | |
92 return true; | |
93 } | |
94 if (media_type_ == other.media_type_) { | |
95 if (direction_ < other.direction_) { | |
96 return true; | |
97 } | |
98 } | |
99 } | |
100 return false; | |
101 } | |
102 | |
103 bool operator==(const StreamId& other) const { | |
104 return ssrc_ == other.ssrc_ && direction_ == other.direction_ && | |
105 media_type_ == other.media_type_; | |
106 } | |
107 | |
108 uint32_t GetSsrc() const { return ssrc_; } | |
109 | |
110 private: | |
111 uint32_t ssrc_; | |
112 webrtc::PacketDirection direction_; | |
113 webrtc::MediaType media_type_; | |
114 }; | |
115 | |
116 const double kXMargin = 1.02; | 79 const double kXMargin = 1.02; |
117 const double kYMargin = 1.1; | 80 const double kYMargin = 1.1; |
118 const double kDefaultXMin = -1; | 81 const double kDefaultXMin = -1; |
119 const double kDefaultYMin = -1; | 82 const double kDefaultYMin = -1; |
120 | 83 |
121 } // namespace | 84 } // namespace |
122 | 85 |
123 namespace webrtc { | 86 namespace webrtc { |
124 namespace plotting { | 87 namespace plotting { |
125 | 88 |
126 EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log) | 89 EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log) |
127 : parsed_log_(log), window_duration_(250000), step_(10000) { | 90 : parsed_log_(log), window_duration_(250000), step_(10000) { |
128 uint64_t first_timestamp = std::numeric_limits<uint64_t>::max(); | 91 uint64_t first_timestamp = std::numeric_limits<uint64_t>::max(); |
129 uint64_t last_timestamp = std::numeric_limits<uint64_t>::min(); | 92 uint64_t last_timestamp = std::numeric_limits<uint64_t>::min(); |
93 | |
94 // Maps a stream identifier consisting of ssrc, direction and MediaType | |
95 // to the header extensions used by that stream, | |
96 std::map<StreamId, RtpHeaderExtensionMap> extension_maps; | |
97 | |
98 PacketDirection direction; | |
99 MediaType media_type; | |
100 uint8_t header[IP_PACKET_SIZE]; | |
101 size_t header_length, total_length; | |
philipel
2016/07/14 14:36:14
split to two lines
terelius
2016/07/18 15:48:13
Done.
| |
102 | |
130 for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) { | 103 for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) { |
131 ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i); | 104 ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i); |
132 if (event_type == ParsedRtcEventLog::EventType::VIDEO_RECEIVER_CONFIG_EVENT) | 105 if (event_type != ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT && |
133 continue; | 106 event_type != ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT && |
134 if (event_type == ParsedRtcEventLog::EventType::VIDEO_SENDER_CONFIG_EVENT) | 107 event_type != ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT && |
135 continue; | 108 event_type != ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT) { |
136 if (event_type == ParsedRtcEventLog::EventType::AUDIO_RECEIVER_CONFIG_EVENT) | 109 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
137 continue; | 110 first_timestamp = std::min(first_timestamp, timestamp); |
138 if (event_type == ParsedRtcEventLog::EventType::AUDIO_SENDER_CONFIG_EVENT) | 111 last_timestamp = std::max(last_timestamp, timestamp); |
139 continue; | 112 } |
140 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 113 |
141 first_timestamp = std::min(first_timestamp, timestamp); | 114 switch (parsed_log_.GetEventType(i)) { |
142 last_timestamp = std::max(last_timestamp, timestamp); | 115 case ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT: { |
116 VideoReceiveStream::Config config(nullptr); | |
117 parsed_log_.GetVideoReceiveConfig(i, &config); | |
118 StreamId stream(config.rtp.remote_ssrc, kIncomingPacket, | |
119 MediaType::VIDEO); | |
120 extension_maps[stream].Erase(); | |
121 for (size_t j = 0; j < config.rtp.extensions.size(); ++j) { | |
122 const std::string& extension = config.rtp.extensions[j].uri; | |
123 int id = config.rtp.extensions[j].id; | |
124 extension_maps[stream].Register(StringToRtpExtensionType(extension), | |
125 id); | |
126 } | |
127 break; | |
128 } | |
129 case ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT: { | |
130 VideoSendStream::Config config(nullptr); | |
131 parsed_log_.GetVideoSendConfig(i, &config); | |
132 for (auto ssrc : config.rtp.ssrcs) { | |
133 StreamId stream(ssrc, kOutgoingPacket, MediaType::VIDEO); | |
134 extension_maps[stream].Erase(); | |
135 for (size_t j = 0; j < config.rtp.extensions.size(); ++j) { | |
136 const std::string& extension = config.rtp.extensions[j].uri; | |
137 int id = config.rtp.extensions[j].id; | |
138 extension_maps[stream].Register(StringToRtpExtensionType(extension), | |
139 id); | |
140 } | |
141 } | |
142 break; | |
143 } | |
144 case ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT: { | |
145 AudioReceiveStream::Config config; | |
146 // TODO(terelius): Parse the audio configs once we have them. | |
147 break; | |
148 } | |
149 case ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT: { | |
150 AudioSendStream::Config config(nullptr); | |
151 // TODO(terelius): Parse the audio configs once we have them. | |
152 break; | |
153 } | |
154 case ParsedRtcEventLog::RTP_EVENT: { | |
155 parsed_log_.GetRtpHeader(i, &direction, &media_type, header, | |
156 &header_length, &total_length); | |
157 // Parse header to get SSRC. | |
158 RtpUtility::RtpHeaderParser rtp_parser(header, header_length); | |
159 RTPHeader parsed_header; | |
160 rtp_parser.Parse(&parsed_header); | |
161 StreamId stream(parsed_header.ssrc, direction, media_type); | |
162 // Look up the extension_map and parse it again to get the extensions. | |
163 if (extension_maps.count(stream) == 1) { | |
164 RtpHeaderExtensionMap* extension_map = &extension_maps[stream]; | |
165 rtp_parser.Parse(&parsed_header, extension_map); | |
166 } | |
167 uint64_t timestamp = parsed_log_.GetTimestamp(i); | |
168 rtp_packets_[stream].push_back( | |
169 LoggedRtpPacket(timestamp, parsed_header)); | |
170 break; | |
171 } | |
172 case ParsedRtcEventLog::RTCP_EVENT: { | |
173 break; | |
174 } | |
175 case ParsedRtcEventLog::LOG_START: { | |
176 break; | |
177 } | |
178 case ParsedRtcEventLog::LOG_END: { | |
179 break; | |
180 } | |
181 case ParsedRtcEventLog::BWE_PACKET_LOSS_EVENT: { | |
182 break; | |
183 } | |
184 case ParsedRtcEventLog::BWE_PACKET_DELAY_EVENT: { | |
185 break; | |
186 } | |
187 case ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT: { | |
188 break; | |
189 } | |
190 case ParsedRtcEventLog::UNKNOWN_EVENT: { | |
191 break; | |
192 } | |
193 } | |
143 } | 194 } |
195 | |
144 if (last_timestamp < first_timestamp) { | 196 if (last_timestamp < first_timestamp) { |
145 // No useful events in the log. | 197 // No useful events in the log. |
146 first_timestamp = last_timestamp = 0; | 198 first_timestamp = last_timestamp = 0; |
147 } | 199 } |
148 begin_time_ = first_timestamp; | 200 begin_time_ = first_timestamp; |
149 end_time_ = last_timestamp; | 201 end_time_ = last_timestamp; |
150 } | 202 } |
151 | 203 |
152 void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction, | 204 void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction, |
153 Plot* plot) { | 205 Plot* plot) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 plot->xaxis_min = kDefaultXMin; | 352 plot->xaxis_min = kDefaultXMin; |
301 plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin; | 353 plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin; |
302 plot->xaxis_label = "Time (s)"; | 354 plot->xaxis_label = "Time (s)"; |
303 plot->yaxis_min = min_y - (kYMargin - 1) / 2 * (max_y - min_y); | 355 plot->yaxis_min = min_y - (kYMargin - 1) / 2 * (max_y - min_y); |
304 plot->yaxis_max = max_y + (kYMargin - 1) / 2 * (max_y - min_y); | 356 plot->yaxis_max = max_y + (kYMargin - 1) / 2 * (max_y - min_y); |
305 plot->yaxis_label = "Difference since last packet"; | 357 plot->yaxis_label = "Difference since last packet"; |
306 plot->title = "Sequence number"; | 358 plot->title = "Sequence number"; |
307 } | 359 } |
308 | 360 |
309 void EventLogAnalyzer::CreateDelayChangeGraph(Plot* plot) { | 361 void EventLogAnalyzer::CreateDelayChangeGraph(Plot* plot) { |
310 // Maps a stream identifier consisting of ssrc, direction and MediaType | |
311 // to the header extensions used by that stream, | |
312 std::map<StreamId, RtpHeaderExtensionMap> extension_maps; | |
313 | |
314 struct SendReceiveTime { | |
315 SendReceiveTime() = default; | |
316 SendReceiveTime(uint32_t send_time, uint64_t recv_time) | |
317 : absolute_send_time(send_time), receive_timestamp(recv_time) {} | |
318 uint32_t absolute_send_time; // 24-bit value in units of 2^-18 seconds. | |
319 uint64_t receive_timestamp; // In microseconds. | |
320 }; | |
321 std::map<StreamId, SendReceiveTime> last_packet; | |
322 std::map<StreamId, TimeSeries> time_series; | |
323 | |
324 PacketDirection direction; | |
325 MediaType media_type; | |
326 uint8_t header[IP_PACKET_SIZE]; | |
327 size_t header_length, total_length; | |
328 | |
329 double max_y = 10; | 362 double max_y = 10; |
330 double min_y = 0; | 363 double min_y = 0; |
331 | 364 |
332 for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) { | 365 for (auto& kv : rtp_packets_) { |
333 ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i); | 366 StreamId stream_id = kv.first; |
334 if (event_type == ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT) { | 367 // Filter on direction and SSRC. |
335 VideoReceiveStream::Config config(nullptr); | 368 if (stream_id.GetDirection() != kIncomingPacket || |
336 parsed_log_.GetVideoReceiveConfig(i, &config); | 369 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { |
337 StreamId stream(config.rtp.remote_ssrc, kIncomingPacket, | 370 continue; |
338 MediaType::VIDEO); | 371 } |
339 extension_maps[stream].Erase(); | 372 |
340 for (size_t j = 0; j < config.rtp.extensions.size(); ++j) { | 373 TimeSeries time_series; |
341 const std::string& extension = config.rtp.extensions[j].uri; | 374 time_series.label = SsrcToString(stream_id.GetSsrc()); |
342 int id = config.rtp.extensions[j].id; | 375 time_series.style = BAR_GRAPH; |
343 extension_maps[stream].Register(StringToRtpExtensionType(extension), | 376 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; |
344 id); | 377 int64_t last_abs_send_time = 0; |
345 } | 378 int64_t last_timestamp = 0; |
346 } else if (event_type == ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT) { | 379 for (const LoggedRtpPacket& packet : packet_stream) { |
347 VideoSendStream::Config config(nullptr); | 380 if (packet.header.extension.hasAbsoluteSendTime) { |
348 parsed_log_.GetVideoSendConfig(i, &config); | 381 int64_t send_time_diff = |
349 for (auto ssrc : config.rtp.ssrcs) { | 382 WrappingDifference(packet.header.extension.absoluteSendTime, |
philipel
2016/07/14 14:36:14
You can include base/mod_ops.h and use the MinDiff
terelius
2016/07/18 15:48:13
That's not quite the same thing though. I want to
philipel
2016/07/18 16:29:47
Right, I see.
| |
350 StreamId stream(ssrc, kIncomingPacket, MediaType::VIDEO); | 383 last_abs_send_time, 1ul << 24); |
351 extension_maps[stream].Erase(); | 384 int64_t recv_time_diff = packet.timestamp - last_timestamp; |
philipel
2016/07/14 14:36:14
Do we know that |last_timestamp| <= |packet.timest
terelius
2016/07/18 15:48:13
The timestamp refers to the logging time. I think
philipel
2016/07/18 16:29:48
Acknowledged.
| |
352 for (size_t j = 0; j < config.rtp.extensions.size(); ++j) { | 385 |
353 const std::string& extension = config.rtp.extensions[j].uri; | 386 last_abs_send_time = packet.header.extension.absoluteSendTime; |
354 int id = config.rtp.extensions[j].id; | 387 last_timestamp = packet.timestamp; |
355 extension_maps[stream].Register(StringToRtpExtensionType(extension), | 388 |
356 id); | 389 float x = static_cast<float>(packet.timestamp - begin_time_) / 1000000; |
390 double y = | |
391 static_cast<double>(recv_time_diff - | |
392 AbsSendTimeToMicroseconds(send_time_diff)) / | |
393 1000; | |
394 if (time_series.points.size() == 0) { | |
395 // There were no previously logged packets for this SSRC. | |
396 // Generate a point, but place it on the x-axis. | |
397 y = 0; | |
357 } | 398 } |
358 } | 399 max_y = std::max(max_y, y); |
359 } else if (event_type == ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT) { | 400 min_y = std::min(min_y, y); |
360 AudioReceiveStream::Config config; | 401 time_series.points.push_back(TimeSeriesPoint(x, y)); |
philipel
2016/07/14 14:36:14
Change to 'time_series.points.emplace_back(x, y)'.
terelius
2016/07/18 15:48:13
The chromium style guide is rather ambiguous about
philipel
2016/07/18 16:29:47
Still prefer emplace_back, the reason is that you
terelius
2016/07/18 16:38:04
Done.
| |
361 // TODO(terelius): Parse the audio configs once we have them | |
362 } else if (event_type == ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT) { | |
363 AudioSendStream::Config config(nullptr); | |
364 // TODO(terelius): Parse the audio configs once we have them | |
365 } else if (event_type == ParsedRtcEventLog::RTP_EVENT) { | |
366 parsed_log_.GetRtpHeader(i, &direction, &media_type, header, | |
367 &header_length, &total_length); | |
368 if (direction == kIncomingPacket) { | |
369 // Parse header to get SSRC. | |
370 RtpUtility::RtpHeaderParser rtp_parser(header, header_length); | |
371 RTPHeader parsed_header; | |
372 rtp_parser.Parse(&parsed_header); | |
373 // Filter on SSRC. | |
374 if (MatchingSsrc(parsed_header.ssrc, desired_ssrc_)) { | |
375 StreamId stream(parsed_header.ssrc, direction, media_type); | |
376 // Look up the extension_map and parse it again to get the extensions. | |
377 if (extension_maps.count(stream) == 1) { | |
378 RtpHeaderExtensionMap* extension_map = &extension_maps[stream]; | |
379 rtp_parser.Parse(&parsed_header, extension_map); | |
380 if (parsed_header.extension.hasAbsoluteSendTime) { | |
381 uint64_t timestamp = parsed_log_.GetTimestamp(i); | |
382 int64_t send_time_diff = WrappingDifference( | |
383 parsed_header.extension.absoluteSendTime, | |
384 last_packet[stream].absolute_send_time, 1ul << 24); | |
385 int64_t recv_time_diff = | |
386 timestamp - last_packet[stream].receive_timestamp; | |
387 | |
388 float x = static_cast<float>(timestamp - begin_time_) / 1000000; | |
389 double y = static_cast<double>( | |
390 recv_time_diff - | |
391 AbsSendTimeToMicroseconds(send_time_diff)) / | |
392 1000; | |
393 if (time_series[stream].points.size() == 0) { | |
394 // There were no previusly logged playout for this SSRC. | |
395 // Generate a point, but place it on the x-axis. | |
396 y = 0; | |
397 } | |
398 max_y = std::max(max_y, y); | |
399 min_y = std::min(min_y, y); | |
400 time_series[stream].points.push_back(TimeSeriesPoint(x, y)); | |
401 last_packet[stream] = SendReceiveTime( | |
402 parsed_header.extension.absoluteSendTime, timestamp); | |
403 } | |
404 } | |
405 } | |
406 } | 402 } |
407 } | 403 } |
408 } | 404 // Add the data set to the plot. |
409 | 405 plot->series.push_back(std::move(time_series)); |
410 // Set labels and put in graph. | |
411 for (auto& kv : time_series) { | |
412 kv.second.label = SsrcToString(kv.first.GetSsrc()); | |
413 kv.second.style = BAR_GRAPH; | |
414 plot->series.push_back(std::move(kv.second)); | |
415 } | 406 } |
416 | 407 |
417 plot->xaxis_min = kDefaultXMin; | 408 plot->xaxis_min = kDefaultXMin; |
418 plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin; | 409 plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin; |
419 plot->xaxis_label = "Time (s)"; | 410 plot->xaxis_label = "Time (s)"; |
420 plot->yaxis_min = min_y - (kYMargin - 1) / 2 * (max_y - min_y); | 411 plot->yaxis_min = min_y - (kYMargin - 1) / 2 * (max_y - min_y); |
421 plot->yaxis_max = max_y + (kYMargin - 1) / 2 * (max_y - min_y); | 412 plot->yaxis_max = max_y + (kYMargin - 1) / 2 * (max_y - min_y); |
422 plot->yaxis_label = "Latency change (ms)"; | 413 plot->yaxis_label = "Latency change (ms)"; |
423 plot->title = "Network latency change between consecutive packets"; | 414 plot->title = "Network latency change between consecutive packets"; |
424 } | 415 } |
425 | 416 |
426 void EventLogAnalyzer::CreateAccumulatedDelayChangeGraph(Plot* plot) { | 417 void EventLogAnalyzer::CreateAccumulatedDelayChangeGraph(Plot* plot) { |
427 // TODO(terelius): Refactor | |
428 | |
429 // Maps a stream identifier consisting of ssrc, direction and MediaType | |
430 // to the header extensions used by that stream. | |
431 std::map<StreamId, RtpHeaderExtensionMap> extension_maps; | |
432 | |
433 struct SendReceiveTime { | |
434 SendReceiveTime() = default; | |
435 SendReceiveTime(uint32_t send_time, uint64_t recv_time, double accumulated) | |
436 : absolute_send_time(send_time), | |
437 receive_timestamp(recv_time), | |
438 accumulated_delay(accumulated) {} | |
439 uint32_t absolute_send_time; // 24-bit value in units of 2^-18 seconds. | |
440 uint64_t receive_timestamp; // In microseconds. | |
441 double accumulated_delay; // In milliseconds. | |
442 }; | |
443 std::map<StreamId, SendReceiveTime> last_packet; | |
444 std::map<StreamId, TimeSeries> time_series; | |
445 | |
446 PacketDirection direction; | |
447 MediaType media_type; | |
448 uint8_t header[IP_PACKET_SIZE]; | |
449 size_t header_length, total_length; | |
450 | |
451 double max_y = 10; | 418 double max_y = 10; |
452 double min_y = 0; | 419 double min_y = 0; |
453 | 420 |
454 for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) { | 421 for (auto& kv : rtp_packets_) { |
philipel
2016/07/14 14:36:14
Can |kv| be changed to something more descriptive?
terelius
2016/07/18 15:48:13
I agree with you, but for (auto& kv : map) seems t
philipel
2016/07/18 16:29:47
|kv| is fine.
stefan-webrtc
2016/07/18 16:58:50
I think kv is ok the same way "it" is used for ite
| |
455 ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i); | 422 StreamId stream_id = kv.first; |
456 if (event_type == ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT) { | 423 // Filter on direction and SSRC. |
457 VideoReceiveStream::Config config(nullptr); | 424 if (stream_id.GetDirection() != kIncomingPacket || |
458 parsed_log_.GetVideoReceiveConfig(i, &config); | 425 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { |
459 StreamId stream(config.rtp.remote_ssrc, kIncomingPacket, | 426 continue; |
460 MediaType::VIDEO); | 427 } |
461 extension_maps[stream].Erase(); | 428 TimeSeries time_series; |
462 for (size_t j = 0; j < config.rtp.extensions.size(); ++j) { | 429 time_series.label = SsrcToString(stream_id.GetSsrc()); |
463 const std::string& extension = config.rtp.extensions[j].uri; | 430 time_series.style = LINE_GRAPH; |
464 int id = config.rtp.extensions[j].id; | 431 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; |
465 extension_maps[stream].Register(StringToRtpExtensionType(extension), | 432 int64_t last_abs_send_time = 0; |
466 id); | 433 int64_t last_timestamp = 0; |
467 } | 434 double accumulated_delay = 0; |
philipel
2016/07/14 14:36:14
accumulated_delay_ms
terelius
2016/07/18 15:48:14
Done.
| |
468 } else if (event_type == ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT) { | 435 for (const LoggedRtpPacket& packet : packet_stream) { |
469 VideoSendStream::Config config(nullptr); | 436 if (packet.header.extension.hasAbsoluteSendTime) { |
470 parsed_log_.GetVideoSendConfig(i, &config); | 437 int64_t send_time_diff = |
471 for (auto ssrc : config.rtp.ssrcs) { | 438 WrappingDifference(packet.header.extension.absoluteSendTime, |
philipel
2016/07/14 14:36:14
MinDiff()
terelius
2016/07/18 15:48:14
See above.
philipel
2016/07/18 16:29:48
Acknowledged.
| |
472 StreamId stream(ssrc, kIncomingPacket, MediaType::VIDEO); | 439 last_abs_send_time, 1ul << 24); |
473 extension_maps[stream].Erase(); | 440 int64_t recv_time_diff = packet.timestamp - last_timestamp; |
philipel
2016/07/14 14:36:14
Maybe DCHECK or MinDiff()?
terelius
2016/07/18 15:48:14
See above. I don't see what a DCHECK would accompl
philipel
2016/07/18 16:29:47
Acknowledged.
| |
474 for (size_t j = 0; j < config.rtp.extensions.size(); ++j) { | 441 |
475 const std::string& extension = config.rtp.extensions[j].uri; | 442 last_abs_send_time = packet.header.extension.absoluteSendTime; |
476 int id = config.rtp.extensions[j].id; | 443 last_timestamp = packet.timestamp; |
477 extension_maps[stream].Register(StringToRtpExtensionType(extension), | 444 |
478 id); | 445 float x = static_cast<float>(packet.timestamp - begin_time_) / 1000000; |
446 accumulated_delay += | |
447 static_cast<double>(recv_time_diff - | |
448 AbsSendTimeToMicroseconds(send_time_diff)) / | |
449 1000; | |
450 if (time_series.points.size() == 0) { | |
451 // There were no previously logged packets for this SSRC. | |
452 // Generate a point, but place it on the x-axis. | |
453 accumulated_delay = 0; | |
479 } | 454 } |
480 } | 455 max_y = std::max(max_y, accumulated_delay); |
481 } else if (event_type == ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT) { | 456 min_y = std::min(min_y, accumulated_delay); |
482 AudioReceiveStream::Config config; | 457 time_series.points.push_back(TimeSeriesPoint(x, accumulated_delay)); |
philipel
2016/07/14 14:36:14
emplace_back
terelius
2016/07/18 15:48:14
See above.
philipel
2016/07/18 16:29:47
See above :)
terelius
2016/07/18 16:38:03
Done.
| |
483 // TODO(terelius): Parse the audio configs once we have them | |
484 } else if (event_type == ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT) { | |
485 AudioSendStream::Config config(nullptr); | |
486 // TODO(terelius): Parse the audio configs once we have them | |
487 } else if (event_type == ParsedRtcEventLog::RTP_EVENT) { | |
488 parsed_log_.GetRtpHeader(i, &direction, &media_type, header, | |
489 &header_length, &total_length); | |
490 if (direction == kIncomingPacket) { | |
491 // Parse header to get SSRC. | |
492 RtpUtility::RtpHeaderParser rtp_parser(header, header_length); | |
493 RTPHeader parsed_header; | |
494 rtp_parser.Parse(&parsed_header); | |
495 // Filter on SSRC. | |
496 if (MatchingSsrc(parsed_header.ssrc, desired_ssrc_)) { | |
497 StreamId stream(parsed_header.ssrc, direction, media_type); | |
498 // Look up the extension_map and parse it again to get the extensions. | |
499 if (extension_maps.count(stream) == 1) { | |
500 RtpHeaderExtensionMap* extension_map = &extension_maps[stream]; | |
501 rtp_parser.Parse(&parsed_header, extension_map); | |
502 if (parsed_header.extension.hasAbsoluteSendTime) { | |
503 uint64_t timestamp = parsed_log_.GetTimestamp(i); | |
504 int64_t send_time_diff = WrappingDifference( | |
505 parsed_header.extension.absoluteSendTime, | |
506 last_packet[stream].absolute_send_time, 1ul << 24); | |
507 int64_t recv_time_diff = | |
508 timestamp - last_packet[stream].receive_timestamp; | |
509 | |
510 float x = static_cast<float>(timestamp - begin_time_) / 1000000; | |
511 double y = last_packet[stream].accumulated_delay + | |
512 static_cast<double>( | |
513 recv_time_diff - | |
514 AbsSendTimeToMicroseconds(send_time_diff)) / | |
515 1000; | |
516 if (time_series[stream].points.size() == 0) { | |
517 // There were no previusly logged playout for this SSRC. | |
518 // Generate a point, but place it on the x-axis. | |
519 y = 0; | |
520 } | |
521 max_y = std::max(max_y, y); | |
522 min_y = std::min(min_y, y); | |
523 time_series[stream].points.push_back(TimeSeriesPoint(x, y)); | |
524 last_packet[stream] = SendReceiveTime( | |
525 parsed_header.extension.absoluteSendTime, timestamp, y); | |
526 } | |
527 } | |
528 } | |
529 } | 458 } |
530 } | 459 } |
531 } | 460 // Add the data set to the plot. |
532 | 461 plot->series.push_back(std::move(time_series)); |
533 // Set labels and put in graph. | |
534 for (auto& kv : time_series) { | |
535 kv.second.label = SsrcToString(kv.first.GetSsrc()); | |
536 kv.second.style = LINE_GRAPH; | |
537 plot->series.push_back(std::move(kv.second)); | |
538 } | 462 } |
539 | 463 |
540 plot->xaxis_min = kDefaultXMin; | 464 plot->xaxis_min = kDefaultXMin; |
541 plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin; | 465 plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin; |
542 plot->xaxis_label = "Time (s)"; | 466 plot->xaxis_label = "Time (s)"; |
543 plot->yaxis_min = min_y - (kYMargin - 1) / 2 * (max_y - min_y); | 467 plot->yaxis_min = min_y - (kYMargin - 1) / 2 * (max_y - min_y); |
544 plot->yaxis_max = max_y + (kYMargin - 1) / 2 * (max_y - min_y); | 468 plot->yaxis_max = max_y + (kYMargin - 1) / 2 * (max_y - min_y); |
545 plot->yaxis_label = "Latency change (ms)"; | 469 plot->yaxis_label = "Latency change (ms)"; |
546 plot->title = "Accumulated network latency change"; | 470 plot->title = "Accumulated network latency change"; |
547 } | 471 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
701 plot->yaxis_label = "Bitrate (kbps)"; | 625 plot->yaxis_label = "Bitrate (kbps)"; |
702 if (desired_direction == webrtc::PacketDirection::kIncomingPacket) { | 626 if (desired_direction == webrtc::PacketDirection::kIncomingPacket) { |
703 plot->title = "Incoming bitrate per stream"; | 627 plot->title = "Incoming bitrate per stream"; |
704 } else if (desired_direction == webrtc::PacketDirection::kOutgoingPacket) { | 628 } else if (desired_direction == webrtc::PacketDirection::kOutgoingPacket) { |
705 plot->title = "Outgoing bitrate per stream"; | 629 plot->title = "Outgoing bitrate per stream"; |
706 } | 630 } |
707 } | 631 } |
708 | 632 |
709 } // namespace plotting | 633 } // namespace plotting |
710 } // namespace webrtc | 634 } // namespace webrtc |
OLD | NEW |