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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 void RegisterHeaderExtensions( | 93 void RegisterHeaderExtensions( |
94 const std::vector<webrtc::RtpExtension>& extensions, | 94 const std::vector<webrtc::RtpExtension>& extensions, |
95 webrtc::RtpHeaderExtensionMap* extension_map) { | 95 webrtc::RtpHeaderExtensionMap* extension_map) { |
96 extension_map->Erase(); | 96 extension_map->Erase(); |
97 for (const webrtc::RtpExtension& extension : extensions) { | 97 for (const webrtc::RtpExtension& extension : extensions) { |
98 extension_map->Register(webrtc::StringToRtpExtensionType(extension.uri), | 98 extension_map->Register(webrtc::StringToRtpExtensionType(extension.uri), |
99 extension.id); | 99 extension.id); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
| 103 // Return default values for header extensions, to use on streams without stored |
| 104 // mapping data. Currently this only applies to audio streams, since the mapping |
| 105 // is not stored in the event log. |
| 106 // TODO(ivoc): Remove this once this mapping is stored in the event log for |
| 107 // audio streams. Tracking bug: webrtc:6399 |
| 108 webrtc::RtpHeaderExtensionMap GetDefaultHeaderExtensionMap() { |
| 109 webrtc::RtpHeaderExtensionMap default_map; |
| 110 default_map.Register( |
| 111 webrtc::StringToRtpExtensionType(webrtc::RtpExtension::kAudioLevelUri), |
| 112 webrtc::RtpExtension::kAudioLevelDefaultId); |
| 113 default_map.Register( |
| 114 webrtc::StringToRtpExtensionType(webrtc::RtpExtension::kAbsSendTimeUri), |
| 115 webrtc::RtpExtension::kAbsSendTimeDefaultId); |
| 116 return default_map; |
| 117 } |
| 118 |
103 constexpr float kLeftMargin = 0.01f; | 119 constexpr float kLeftMargin = 0.01f; |
104 constexpr float kRightMargin = 0.02f; | 120 constexpr float kRightMargin = 0.02f; |
105 constexpr float kBottomMargin = 0.02f; | 121 constexpr float kBottomMargin = 0.02f; |
106 constexpr float kTopMargin = 0.05f; | 122 constexpr float kTopMargin = 0.05f; |
107 | 123 |
108 class PacketSizeBytes { | 124 class PacketSizeBytes { |
109 public: | 125 public: |
110 using DataType = LoggedRtpPacket; | 126 using DataType = LoggedRtpPacket; |
111 using ResultType = size_t; | 127 using ResultType = size_t; |
112 size_t operator()(const LoggedRtpPacket& packet) { | 128 size_t operator()(const LoggedRtpPacket& packet) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 290 |
275 // Maps a stream identifier consisting of ssrc and direction | 291 // Maps a stream identifier consisting of ssrc and direction |
276 // to the header extensions used by that stream, | 292 // to the header extensions used by that stream, |
277 std::map<StreamId, RtpHeaderExtensionMap> extension_maps; | 293 std::map<StreamId, RtpHeaderExtensionMap> extension_maps; |
278 | 294 |
279 PacketDirection direction; | 295 PacketDirection direction; |
280 uint8_t header[IP_PACKET_SIZE]; | 296 uint8_t header[IP_PACKET_SIZE]; |
281 size_t header_length; | 297 size_t header_length; |
282 size_t total_length; | 298 size_t total_length; |
283 | 299 |
| 300 // Make a default extension map for streams without configuration information. |
| 301 // TODO(ivoc): Once configuration of audio streams is stored in the event log, |
| 302 // this can be removed. Tracking bug: webrtc:6399 |
| 303 RtpHeaderExtensionMap default_extension_map = GetDefaultHeaderExtensionMap(); |
| 304 |
284 for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) { | 305 for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) { |
285 ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i); | 306 ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i); |
286 if (event_type != ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT && | 307 if (event_type != ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT && |
287 event_type != ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT && | 308 event_type != ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT && |
288 event_type != ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT && | 309 event_type != ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT && |
289 event_type != ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT && | 310 event_type != ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT && |
290 event_type != ParsedRtcEventLog::LOG_START && | 311 event_type != ParsedRtcEventLog::LOG_START && |
291 event_type != ParsedRtcEventLog::LOG_END) { | 312 event_type != ParsedRtcEventLog::LOG_END) { |
292 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 313 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
293 first_timestamp = std::min(first_timestamp, timestamp); | 314 first_timestamp = std::min(first_timestamp, timestamp); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 &header_length, &total_length); | 366 &header_length, &total_length); |
346 // Parse header to get SSRC. | 367 // Parse header to get SSRC. |
347 RtpUtility::RtpHeaderParser rtp_parser(header, header_length); | 368 RtpUtility::RtpHeaderParser rtp_parser(header, header_length); |
348 RTPHeader parsed_header; | 369 RTPHeader parsed_header; |
349 rtp_parser.Parse(&parsed_header); | 370 rtp_parser.Parse(&parsed_header); |
350 StreamId stream(parsed_header.ssrc, direction); | 371 StreamId stream(parsed_header.ssrc, direction); |
351 // Look up the extension_map and parse it again to get the extensions. | 372 // Look up the extension_map and parse it again to get the extensions. |
352 if (extension_maps.count(stream) == 1) { | 373 if (extension_maps.count(stream) == 1) { |
353 RtpHeaderExtensionMap* extension_map = &extension_maps[stream]; | 374 RtpHeaderExtensionMap* extension_map = &extension_maps[stream]; |
354 rtp_parser.Parse(&parsed_header, extension_map); | 375 rtp_parser.Parse(&parsed_header, extension_map); |
| 376 } else { |
| 377 // Use the default extension map. |
| 378 // TODO(ivoc): Once configuration of audio streams is stored in the |
| 379 // event log, this can be removed. |
| 380 // Tracking bug: webrtc:6399 |
| 381 rtp_parser.Parse(&parsed_header, &default_extension_map); |
355 } | 382 } |
356 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 383 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
357 rtp_packets_[stream].push_back( | 384 rtp_packets_[stream].push_back( |
358 LoggedRtpPacket(timestamp, parsed_header, total_length)); | 385 LoggedRtpPacket(timestamp, parsed_header, total_length)); |
359 break; | 386 break; |
360 } | 387 } |
361 case ParsedRtcEventLog::RTCP_EVENT: { | 388 case ParsedRtcEventLog::RTCP_EVENT: { |
362 uint8_t packet[IP_PACKET_SIZE]; | 389 uint8_t packet[IP_PACKET_SIZE]; |
363 MediaType media_type; | 390 MediaType media_type; |
364 parsed_log_.GetRtcpPacket(i, &direction, &media_type, packet, | 391 parsed_log_.GetRtcpPacket(i, &direction, &media_type, packet, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 std::stringstream name; | 502 std::stringstream name; |
476 if (IsAudioSsrc(stream_id)) { | 503 if (IsAudioSsrc(stream_id)) { |
477 name << "Audio "; | 504 name << "Audio "; |
478 } else if (IsVideoSsrc(stream_id)) { | 505 } else if (IsVideoSsrc(stream_id)) { |
479 name << "Video "; | 506 name << "Video "; |
480 } else { | 507 } else { |
481 name << "Unknown "; | 508 name << "Unknown "; |
482 } | 509 } |
483 if (IsRtxSsrc(stream_id)) | 510 if (IsRtxSsrc(stream_id)) |
484 name << "RTX "; | 511 name << "RTX "; |
| 512 if (stream_id.GetDirection() == kIncomingPacket) { |
| 513 name << "(In) "; |
| 514 } else { |
| 515 name << "(Out) "; |
| 516 } |
485 name << SsrcToString(stream_id.GetSsrc()); | 517 name << SsrcToString(stream_id.GetSsrc()); |
486 return name.str(); | 518 return name.str(); |
487 } | 519 } |
488 | 520 |
489 void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction, | 521 void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction, |
490 Plot* plot) { | 522 Plot* plot) { |
491 for (auto& kv : rtp_packets_) { | 523 for (auto& kv : rtp_packets_) { |
492 StreamId stream_id = kv.first; | 524 StreamId stream_id = kv.first; |
493 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; | 525 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; |
494 // Filter on direction and SSRC. | 526 // Filter on direction and SSRC. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 kv.second.style = BAR_GRAPH; | 625 kv.second.style = BAR_GRAPH; |
594 plot->series_list_.push_back(std::move(kv.second)); | 626 plot->series_list_.push_back(std::move(kv.second)); |
595 } | 627 } |
596 | 628 |
597 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 629 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
598 plot->SetSuggestedYAxis(0, 1, "Time since last playout (ms)", kBottomMargin, | 630 plot->SetSuggestedYAxis(0, 1, "Time since last playout (ms)", kBottomMargin, |
599 kTopMargin); | 631 kTopMargin); |
600 plot->SetTitle("Audio playout"); | 632 plot->SetTitle("Audio playout"); |
601 } | 633 } |
602 | 634 |
| 635 // For audio SSRCs, plot the audio level. |
| 636 void EventLogAnalyzer::CreateAudioLevelGraph(Plot* plot) { |
| 637 std::map<StreamId, TimeSeries> time_series; |
| 638 |
| 639 for (auto& kv : rtp_packets_) { |
| 640 StreamId stream_id = kv.first; |
| 641 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; |
| 642 // TODO(ivoc): When audio send/receive configs are stored in the event |
| 643 // log, a check should be added here to only process audio |
| 644 // streams. Tracking bug: webrtc:6399 |
| 645 for (auto& packet : packet_stream) { |
| 646 if (packet.header.extension.hasAudioLevel) { |
| 647 float x = static_cast<float>(packet.timestamp - begin_time_) / 1000000; |
| 648 // The audio level is stored in -dBov (so e.g. -10 dBov is stored as 10) |
| 649 // Here we convert it to dBov. |
| 650 float y = static_cast<float>(-packet.header.extension.audioLevel); |
| 651 time_series[stream_id].points.emplace_back(TimeSeriesPoint(x, y)); |
| 652 } |
| 653 } |
| 654 } |
| 655 |
| 656 for (auto& series : time_series) { |
| 657 series.second.label = GetStreamName(series.first); |
| 658 series.second.style = LINE_GRAPH; |
| 659 plot->series_list_.push_back(std::move(series.second)); |
| 660 } |
| 661 |
| 662 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
| 663 plot->SetYAxis(-127, 0, "Audio playout level (dBov)", kBottomMargin, |
| 664 kTopMargin); |
| 665 plot->SetTitle("Audio level"); |
| 666 } |
| 667 |
603 // For each SSRC, plot the time between the consecutive playouts. | 668 // For each SSRC, plot the time between the consecutive playouts. |
604 void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) { | 669 void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) { |
605 for (auto& kv : rtp_packets_) { | 670 for (auto& kv : rtp_packets_) { |
606 StreamId stream_id = kv.first; | 671 StreamId stream_id = kv.first; |
607 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; | 672 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; |
608 // Filter on direction and SSRC. | 673 // Filter on direction and SSRC. |
609 if (stream_id.GetDirection() != kIncomingPacket || | 674 if (stream_id.GetDirection() != kIncomingPacket || |
610 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { | 675 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { |
611 continue; | 676 continue; |
612 } | 677 } |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 point.y -= estimated_base_delay_ms; | 1137 point.y -= estimated_base_delay_ms; |
1073 // Add the data set to the plot. | 1138 // Add the data set to the plot. |
1074 plot->series_list_.push_back(std::move(time_series)); | 1139 plot->series_list_.push_back(std::move(time_series)); |
1075 | 1140 |
1076 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 1141 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
1077 plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin); | 1142 plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin); |
1078 plot->SetTitle("Network Delay Change."); | 1143 plot->SetTitle("Network Delay Change."); |
1079 } | 1144 } |
1080 } // namespace plotting | 1145 } // namespace plotting |
1081 } // namespace webrtc | 1146 } // namespace webrtc |
OLD | NEW |