Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: webrtc/tools/event_log_visualizer/analyzer.cc

Issue 2346363003: Added graph for plotting the audio level from an Rtc event log. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/tools/event_log_visualizer/analyzer.h ('k') | webrtc/tools/event_log_visualizer/main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
91 } 91 }
92 92
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 // Add default values for audio header extensions, since these are not stored
102 // in the eventlog.
103 // TODO(ivoc): Remove this once this is stored in the event log.
hlundin-webrtc 2016/09/21 08:51:13 Do we have a tracking bug for this work? If not, p
ivoc 2016/09/21 11:50:04 I have a CL up to include this information in the
104 extension_map->Register(
terelius 2016/09/21 09:44:32 Could you do this for audio streams only please.
ivoc 2016/09/21 11:50:04 I moved this to a seperate function, which returns
105 webrtc::StringToRtpExtensionType(webrtc::RtpExtension::kAudioLevelUri),
106 webrtc::RtpExtension::kAudioLevelDefaultId);
107 extension_map->Register(
108 webrtc::StringToRtpExtensionType(webrtc::RtpExtension::kAbsSendTimeUri),
109 webrtc::RtpExtension::kAbsSendTimeDefaultId);
101 } 110 }
102 111
103 constexpr float kLeftMargin = 0.01f; 112 constexpr float kLeftMargin = 0.01f;
104 constexpr float kRightMargin = 0.02f; 113 constexpr float kRightMargin = 0.02f;
105 constexpr float kBottomMargin = 0.02f; 114 constexpr float kBottomMargin = 0.02f;
106 constexpr float kTopMargin = 0.05f; 115 constexpr float kTopMargin = 0.05f;
107 116
108 class PacketSizeBytes { 117 class PacketSizeBytes {
109 public: 118 public:
110 using DataType = LoggedRtpPacket; 119 using DataType = LoggedRtpPacket;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 &header_length, &total_length); 354 &header_length, &total_length);
346 // Parse header to get SSRC. 355 // Parse header to get SSRC.
347 RtpUtility::RtpHeaderParser rtp_parser(header, header_length); 356 RtpUtility::RtpHeaderParser rtp_parser(header, header_length);
348 RTPHeader parsed_header; 357 RTPHeader parsed_header;
349 rtp_parser.Parse(&parsed_header); 358 rtp_parser.Parse(&parsed_header);
350 StreamId stream(parsed_header.ssrc, direction); 359 StreamId stream(parsed_header.ssrc, direction);
351 // Look up the extension_map and parse it again to get the extensions. 360 // Look up the extension_map and parse it again to get the extensions.
352 if (extension_maps.count(stream) == 1) { 361 if (extension_maps.count(stream) == 1) {
353 RtpHeaderExtensionMap* extension_map = &extension_maps[stream]; 362 RtpHeaderExtensionMap* extension_map = &extension_maps[stream];
354 rtp_parser.Parse(&parsed_header, extension_map); 363 rtp_parser.Parse(&parsed_header, extension_map);
364 } else {
365 // Make a default extension map.
366 RtpHeaderExtensionMap extension_map;
367 std::vector<webrtc::RtpExtension> extensions;
368 RegisterHeaderExtensions(extensions, &extension_map);
terelius 2016/09/21 09:44:32 Mark this with a TODO. We don't want to reregister
ivoc 2016/09/21 11:50:04 Good point, I moved the creation of the extension
369 rtp_parser.Parse(&parsed_header, &extension_map);
355 } 370 }
356 uint64_t timestamp = parsed_log_.GetTimestamp(i); 371 uint64_t timestamp = parsed_log_.GetTimestamp(i);
357 rtp_packets_[stream].push_back( 372 rtp_packets_[stream].push_back(
358 LoggedRtpPacket(timestamp, parsed_header, total_length)); 373 LoggedRtpPacket(timestamp, parsed_header, total_length));
359 break; 374 break;
360 } 375 }
361 case ParsedRtcEventLog::RTCP_EVENT: { 376 case ParsedRtcEventLog::RTCP_EVENT: {
362 uint8_t packet[IP_PACKET_SIZE]; 377 uint8_t packet[IP_PACKET_SIZE];
363 MediaType media_type; 378 MediaType media_type;
364 parsed_log_.GetRtcpPacket(i, &direction, &media_type, packet, 379 parsed_log_.GetRtcpPacket(i, &direction, &media_type, packet,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 std::stringstream name; 490 std::stringstream name;
476 if (IsAudioSsrc(stream_id)) { 491 if (IsAudioSsrc(stream_id)) {
477 name << "Audio "; 492 name << "Audio ";
478 } else if (IsVideoSsrc(stream_id)) { 493 } else if (IsVideoSsrc(stream_id)) {
479 name << "Video "; 494 name << "Video ";
480 } else { 495 } else {
481 name << "Unknown "; 496 name << "Unknown ";
482 } 497 }
483 if (IsRtxSsrc(stream_id)) 498 if (IsRtxSsrc(stream_id))
484 name << "RTX "; 499 name << "RTX ";
500 if (stream_id.GetDirection() == kIncomingPacket) {
501 name << "(In) ";
502 } else {
503 name << "(Out) ";
504 }
485 name << SsrcToString(stream_id.GetSsrc()); 505 name << SsrcToString(stream_id.GetSsrc());
486 return name.str(); 506 return name.str();
487 } 507 }
488 508
489 void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction, 509 void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction,
490 Plot* plot) { 510 Plot* plot) {
491 for (auto& kv : rtp_packets_) { 511 for (auto& kv : rtp_packets_) {
492 StreamId stream_id = kv.first; 512 StreamId stream_id = kv.first;
493 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; 513 const std::vector<LoggedRtpPacket>& packet_stream = kv.second;
494 // Filter on direction and SSRC. 514 // Filter on direction and SSRC.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 kv.second.style = BAR_GRAPH; 613 kv.second.style = BAR_GRAPH;
594 plot->series_list_.push_back(std::move(kv.second)); 614 plot->series_list_.push_back(std::move(kv.second));
595 } 615 }
596 616
597 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); 617 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
598 plot->SetSuggestedYAxis(0, 1, "Time since last playout (ms)", kBottomMargin, 618 plot->SetSuggestedYAxis(0, 1, "Time since last playout (ms)", kBottomMargin,
599 kTopMargin); 619 kTopMargin);
600 plot->SetTitle("Audio playout"); 620 plot->SetTitle("Audio playout");
601 } 621 }
602 622
623 // For audio SSRCs, plot the audio level.
624 void EventLogAnalyzer::CreateAudioLevelGraph(Plot* plot) {
625 std::map<StreamId, TimeSeries> time_series;
626
627 for (auto& kv : rtp_packets_) {
628 StreamId stream_id = kv.first;
629 const std::vector<LoggedRtpPacket>& packet_stream = kv.second;
terelius 2016/09/21 10:00:14 In the future, you should only search the packets
ivoc 2016/09/21 11:50:04 Good point, added.
630 for (auto& packet : packet_stream) {
631 if (packet.header.extension.hasAudioLevel) {
632 float x = static_cast<float>(packet.timestamp - begin_time_) / 1000000;
633 // The audio level is stored in -dBov (so e.g. -10 dBov is stored as 10)
634 // Here we convert it to dBov.
635 float y = static_cast<float>(-packet.header.extension.audioLevel);
636 time_series[stream_id].points.emplace_back(TimeSeriesPoint(x, y));
637 }
638 }
639 }
640
641 for (auto& series : time_series) {
642 series.second.label = GetStreamName(series.first);
643 series.second.style = LINE_GRAPH;
644 plot->series_list_.push_back(std::move(series.second));
645 }
646
647 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
648 plot->SetYAxis(-127, 0, "Audio playout level (dBov)", kBottomMargin,
649 kTopMargin);
650 plot->SetTitle("Audio level");
651 }
652
603 // For each SSRC, plot the time between the consecutive playouts. 653 // For each SSRC, plot the time between the consecutive playouts.
604 void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) { 654 void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) {
605 for (auto& kv : rtp_packets_) { 655 for (auto& kv : rtp_packets_) {
606 StreamId stream_id = kv.first; 656 StreamId stream_id = kv.first;
607 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; 657 const std::vector<LoggedRtpPacket>& packet_stream = kv.second;
608 // Filter on direction and SSRC. 658 // Filter on direction and SSRC.
609 if (stream_id.GetDirection() != kIncomingPacket || 659 if (stream_id.GetDirection() != kIncomingPacket ||
610 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { 660 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) {
611 continue; 661 continue;
612 } 662 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 point.y -= estimated_base_delay_ms; 1122 point.y -= estimated_base_delay_ms;
1073 // Add the data set to the plot. 1123 // Add the data set to the plot.
1074 plot->series_list_.push_back(std::move(time_series)); 1124 plot->series_list_.push_back(std::move(time_series));
1075 1125
1076 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); 1126 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
1077 plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin); 1127 plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin);
1078 plot->SetTitle("Network Delay Change."); 1128 plot->SetTitle("Network Delay Change.");
1079 } 1129 }
1080 } // namespace plotting 1130 } // namespace plotting
1081 } // namespace webrtc 1131 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/tools/event_log_visualizer/analyzer.h ('k') | webrtc/tools/event_log_visualizer/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698