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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 extension_map->Register(webrtc::StringToRtpExtensionType(extension.uri), | 91 extension_map->Register(webrtc::StringToRtpExtensionType(extension.uri), |
92 extension.id); | 92 extension.id); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 constexpr float kLeftMargin = 0.01f; | 96 constexpr float kLeftMargin = 0.01f; |
97 constexpr float kRightMargin = 0.02f; | 97 constexpr float kRightMargin = 0.02f; |
98 constexpr float kBottomMargin = 0.02f; | 98 constexpr float kBottomMargin = 0.02f; |
99 constexpr float kTopMargin = 0.05f; | 99 constexpr float kTopMargin = 0.05f; |
100 | 100 |
101 class OneWayDelayChangeAbsSendTime { | |
stefan-webrtc
2016/08/09 11:43:17
Can't we make these classes inherit from an Extrac
terelius
2016/08/09 12:04:27
The idea is to add more functions that will be use
stefan-webrtc
2016/08/09 12:19:48
Makes sense.
danilchap
2016/08/09 12:39:58
It is not easy to see from from the long name of t
terelius
2016/08/09 14:42:54
The Extractors compute a difference in this CL but
danilchap
2016/08/09 15:09:44
It does for me, like a space between words or an e
| |
102 public: | |
103 double operator()(const LoggedRtpPacket& old_packet, | |
104 const LoggedRtpPacket& new_packet) { | |
105 if (old_packet.header.extension.hasAbsoluteSendTime && | |
106 new_packet.header.extension.hasAbsoluteSendTime) { | |
107 int64_t send_time_diff = WrappingDifference( | |
108 new_packet.header.extension.absoluteSendTime, | |
109 old_packet.header.extension.absoluteSendTime, 1ul << 24); | |
110 int64_t recv_time_diff = new_packet.timestamp - old_packet.timestamp; | |
111 return static_cast<double>(recv_time_diff - | |
112 AbsSendTimeToMicroseconds(send_time_diff)) / | |
113 1000; | |
114 } else { | |
115 return 0; | |
116 } | |
117 } | |
118 }; | |
119 | |
120 class OneWayDelayChangeCaptureTime { | |
121 public: | |
122 double operator()(const LoggedRtpPacket& old_packet, | |
123 const LoggedRtpPacket& new_packet) { | |
124 int64_t send_time_diff = WrappingDifference( | |
125 new_packet.header.timestamp, old_packet.header.timestamp, 1ul << 32); | |
126 int64_t recv_time_diff = new_packet.timestamp - old_packet.timestamp; | |
127 | |
128 const double kVideoSampleRate = 90000; | |
129 // TODO(terelius): We treat all streams as video for now, even though | |
130 // audio might be sampled at e.g. 16kHz, because it is really difficult to | |
131 // figure out the true sampling rate of a stream. The effect is that the | |
132 // delay will be scaled incorrectly for non-video streams. | |
133 | |
134 double delay_change = | |
135 static_cast<double>(recv_time_diff) / 1000 - | |
136 static_cast<double>(send_time_diff) / kVideoSampleRate * 1000; | |
137 return delay_change; | |
138 } | |
139 }; | |
140 | |
141 template <typename Extractor> | |
danilchap
2016/08/09 12:39:58
Accumulated designed just for LoggedRtpPacket, but
| |
142 class Accumulated { | |
143 public: | |
144 Accumulated() : extract(), sum(0) {} | |
danilchap
2016/08/09 12:39:58
default constructor for Extractor probably better
terelius
2016/08/09 14:42:54
Done.
| |
145 double operator()(const LoggedRtpPacket& old_packet, | |
146 const LoggedRtpPacket& new_packet) { | |
147 sum += extract(old_packet, new_packet); | |
148 return sum; | |
149 } | |
150 | |
151 private: | |
152 Extractor extract; | |
153 double sum; | |
154 }; | |
155 | |
156 template <typename T, typename Extractor> | |
157 void Pairwise(const std::vector<T>& data, | |
158 uint64_t begin_time, | |
159 webrtc::plotting::TimeSeries* result) { | |
danilchap
2016/08/09 12:39:58
since you are in ::webrtc::plotting namesapce, you
terelius
2016/08/09 14:42:54
Done. Was moving some code around.
| |
160 Extractor extract; | |
161 for (size_t i = 1; i < data.size(); i++) { | |
162 float x = static_cast<float>(data[i].timestamp - begin_time) / 1000000; | |
163 float y = extract(data[i - 1], data[i]); | |
164 result->points.emplace_back(x, y); | |
165 } | |
166 } | |
167 | |
101 } // namespace | 168 } // namespace |
102 | 169 |
103 EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log) | 170 EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log) |
104 : parsed_log_(log), window_duration_(250000), step_(10000) { | 171 : parsed_log_(log), window_duration_(250000), step_(10000) { |
105 uint64_t first_timestamp = std::numeric_limits<uint64_t>::max(); | 172 uint64_t first_timestamp = std::numeric_limits<uint64_t>::max(); |
106 uint64_t last_timestamp = std::numeric_limits<uint64_t>::min(); | 173 uint64_t last_timestamp = std::numeric_limits<uint64_t>::min(); |
107 | 174 |
108 // Maps a stream identifier consisting of ssrc and direction | 175 // Maps a stream identifier consisting of ssrc and direction |
109 // to the header extensions used by that stream, | 176 // to the header extensions used by that stream, |
110 std::map<StreamId, RtpHeaderExtensionMap> extension_maps; | 177 std::map<StreamId, RtpHeaderExtensionMap> extension_maps; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 | 506 |
440 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 507 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
441 plot->SetSuggestedYAxis(0, 1, "Difference since last packet", kBottomMargin, | 508 plot->SetSuggestedYAxis(0, 1, "Difference since last packet", kBottomMargin, |
442 kTopMargin); | 509 kTopMargin); |
443 plot->SetTitle("Sequence number"); | 510 plot->SetTitle("Sequence number"); |
444 } | 511 } |
445 | 512 |
446 void EventLogAnalyzer::CreateDelayChangeGraph(Plot* plot) { | 513 void EventLogAnalyzer::CreateDelayChangeGraph(Plot* plot) { |
447 for (auto& kv : rtp_packets_) { | 514 for (auto& kv : rtp_packets_) { |
448 StreamId stream_id = kv.first; | 515 StreamId stream_id = kv.first; |
516 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; | |
517 uint32_t ssrc = stream_id.GetSsrc(); | |
449 // Filter on direction and SSRC. | 518 // Filter on direction and SSRC. |
450 if (stream_id.GetDirection() != kIncomingPacket || | 519 if (stream_id.GetDirection() != kIncomingPacket || |
451 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { | 520 !MatchingSsrc(ssrc, desired_ssrc_) || IsAudioSsrc(stream_id) || |
521 !IsVideoSsrc(stream_id) || IsRtxSsrc(stream_id)) { | |
452 continue; | 522 continue; |
453 } | 523 } |
454 | 524 |
455 TimeSeries time_series; | 525 TimeSeries capture_time_data; |
456 time_series.label = SsrcToString(stream_id.GetSsrc()); | 526 capture_time_data.label = SsrcToString(ssrc) + " capture-time"; |
457 time_series.style = BAR_GRAPH; | 527 capture_time_data.style = BAR_GRAPH; |
458 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; | 528 Pairwise<LoggedRtpPacket, OneWayDelayChangeCaptureTime>( |
459 int64_t last_abs_send_time = 0; | 529 packet_stream, begin_time_, &capture_time_data); |
460 int64_t last_timestamp = 0; | 530 plot->series_list_.push_back(std::move(capture_time_data)); |
461 for (const LoggedRtpPacket& packet : packet_stream) { | |
462 if (packet.header.extension.hasAbsoluteSendTime) { | |
463 int64_t send_time_diff = | |
464 WrappingDifference(packet.header.extension.absoluteSendTime, | |
465 last_abs_send_time, 1ul << 24); | |
466 int64_t recv_time_diff = packet.timestamp - last_timestamp; | |
467 | 531 |
468 last_abs_send_time = packet.header.extension.absoluteSendTime; | 532 TimeSeries send_time_data; |
469 last_timestamp = packet.timestamp; | 533 send_time_data.label = SsrcToString(ssrc) + " abs-send-time"; |
470 | 534 send_time_data.style = BAR_GRAPH; |
471 float x = static_cast<float>(packet.timestamp - begin_time_) / 1000000; | 535 Pairwise<LoggedRtpPacket, OneWayDelayChangeAbsSendTime>( |
472 double y = | 536 packet_stream, begin_time_, &send_time_data); |
473 static_cast<double>(recv_time_diff - | 537 plot->series_list_.push_back(std::move(send_time_data)); |
474 AbsSendTimeToMicroseconds(send_time_diff)) / | |
475 1000; | |
476 if (time_series.points.size() == 0) { | |
477 // There were no previously logged packets for this SSRC. | |
478 // Generate a point, but place it on the x-axis. | |
479 y = 0; | |
480 } | |
481 time_series.points.emplace_back(x, y); | |
482 } | |
483 } | |
484 // Add the data set to the plot. | |
485 plot->series_list_.push_back(std::move(time_series)); | |
486 } | 538 } |
487 | 539 |
488 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 540 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
489 plot->SetSuggestedYAxis(0, 1, "Latency change (ms)", kBottomMargin, | 541 plot->SetSuggestedYAxis(0, 1, "Latency change (ms)", kBottomMargin, |
490 kTopMargin); | 542 kTopMargin); |
491 plot->SetTitle("Network latency change between consecutive packets"); | 543 plot->SetTitle("Network latency change between consecutive packets"); |
492 } | 544 } |
493 | 545 |
494 void EventLogAnalyzer::CreateAccumulatedDelayChangeGraph(Plot* plot) { | 546 void EventLogAnalyzer::CreateAccumulatedDelayChangeGraph(Plot* plot) { |
495 for (auto& kv : rtp_packets_) { | 547 for (auto& kv : rtp_packets_) { |
496 StreamId stream_id = kv.first; | 548 StreamId stream_id = kv.first; |
549 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; | |
550 uint32_t ssrc = stream_id.GetSsrc(); | |
497 // Filter on direction and SSRC. | 551 // Filter on direction and SSRC. |
498 if (stream_id.GetDirection() != kIncomingPacket || | 552 if (stream_id.GetDirection() != kIncomingPacket || |
499 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { | 553 !MatchingSsrc(ssrc, desired_ssrc_) || IsAudioSsrc(stream_id) || |
554 !IsVideoSsrc(stream_id) || IsRtxSsrc(stream_id)) { | |
500 continue; | 555 continue; |
501 } | 556 } |
502 TimeSeries time_series; | |
503 time_series.label = SsrcToString(stream_id.GetSsrc()); | |
504 time_series.style = LINE_GRAPH; | |
505 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; | |
506 int64_t last_abs_send_time = 0; | |
507 int64_t last_timestamp = 0; | |
508 double accumulated_delay_ms = 0; | |
509 for (const LoggedRtpPacket& packet : packet_stream) { | |
510 if (packet.header.extension.hasAbsoluteSendTime) { | |
511 int64_t send_time_diff = | |
512 WrappingDifference(packet.header.extension.absoluteSendTime, | |
513 last_abs_send_time, 1ul << 24); | |
514 int64_t recv_time_diff = packet.timestamp - last_timestamp; | |
515 | 557 |
516 last_abs_send_time = packet.header.extension.absoluteSendTime; | 558 TimeSeries capture_time_data; |
517 last_timestamp = packet.timestamp; | 559 capture_time_data.label = SsrcToString(ssrc) + " capture-time"; |
560 capture_time_data.style = LINE_GRAPH; | |
561 Pairwise<LoggedRtpPacket, Accumulated<OneWayDelayChangeCaptureTime>>( | |
562 packet_stream, begin_time_, &capture_time_data); | |
563 plot->series_list_.push_back(std::move(capture_time_data)); | |
518 | 564 |
519 float x = static_cast<float>(packet.timestamp - begin_time_) / 1000000; | 565 TimeSeries send_time_data; |
520 accumulated_delay_ms += | 566 send_time_data.label = SsrcToString(ssrc) + " abs-send-time"; |
521 static_cast<double>(recv_time_diff - | 567 send_time_data.style = LINE_GRAPH; |
522 AbsSendTimeToMicroseconds(send_time_diff)) / | 568 Pairwise<LoggedRtpPacket, Accumulated<OneWayDelayChangeAbsSendTime>>( |
523 1000; | 569 packet_stream, begin_time_, &send_time_data); |
524 if (time_series.points.size() == 0) { | 570 plot->series_list_.push_back(std::move(send_time_data)); |
525 // There were no previously logged packets for this SSRC. | |
526 // Generate a point, but place it on the x-axis. | |
527 accumulated_delay_ms = 0; | |
528 } | |
529 time_series.points.emplace_back(x, accumulated_delay_ms); | |
530 } | |
531 } | |
532 // Add the data set to the plot. | |
533 plot->series_list_.push_back(std::move(time_series)); | |
534 } | 571 } |
535 | 572 |
536 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 573 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
537 plot->SetSuggestedYAxis(0, 1, "Latency change (ms)", kBottomMargin, | 574 plot->SetSuggestedYAxis(0, 1, "Latency change (ms)", kBottomMargin, |
538 kTopMargin); | 575 kTopMargin); |
539 plot->SetTitle("Accumulated network latency change"); | 576 plot->SetTitle("Accumulated network latency change"); |
540 } | 577 } |
541 | 578 |
542 // Plot the fraction of packets lost (as perceived by the loss-based BWE). | 579 // Plot the fraction of packets lost (as perceived by the loss-based BWE). |
543 void EventLogAnalyzer::CreateFractionLossGraph(Plot* plot) { | 580 void EventLogAnalyzer::CreateFractionLossGraph(Plot* plot) { |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
899 point.y -= estimated_base_delay_ms; | 936 point.y -= estimated_base_delay_ms; |
900 // Add the data set to the plot. | 937 // Add the data set to the plot. |
901 plot->series_list_.push_back(std::move(time_series)); | 938 plot->series_list_.push_back(std::move(time_series)); |
902 | 939 |
903 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 940 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
904 plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin); | 941 plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin); |
905 plot->SetTitle("Network Delay Change."); | 942 plot->SetTitle("Network Delay Change."); |
906 } | 943 } |
907 } // namespace plotting | 944 } // namespace plotting |
908 } // namespace webrtc | 945 } // namespace webrtc |
OLD | NEW |