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 25 matching lines...) Expand all Loading... | |
36 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" | 36 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" |
37 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 37 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
38 #include "webrtc/video_receive_stream.h" | 38 #include "webrtc/video_receive_stream.h" |
39 #include "webrtc/video_send_stream.h" | 39 #include "webrtc/video_send_stream.h" |
40 | 40 |
41 namespace webrtc { | 41 namespace webrtc { |
42 namespace plotting { | 42 namespace plotting { |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
46 class PacketFeedbackComparator { | |
47 public: | |
48 inline bool operator()(const webrtc::PacketFeedback& lhs, | |
49 const webrtc::PacketFeedback& rhs) { | |
50 if (lhs.arrival_time_ms != rhs.arrival_time_ms) | |
51 return lhs.arrival_time_ms < rhs.arrival_time_ms; | |
52 if (lhs.send_time_ms != rhs.send_time_ms) | |
53 return lhs.send_time_ms < rhs.send_time_ms; | |
54 return lhs.sequence_number < rhs.sequence_number; | |
55 } | |
56 }; | |
57 | |
46 std::string SsrcToString(uint32_t ssrc) { | 58 std::string SsrcToString(uint32_t ssrc) { |
47 std::stringstream ss; | 59 std::stringstream ss; |
48 ss << "SSRC " << ssrc; | 60 ss << "SSRC " << ssrc; |
49 return ss.str(); | 61 return ss.str(); |
50 } | 62 } |
51 | 63 |
52 // Checks whether an SSRC is contained in the list of desired SSRCs. | 64 // Checks whether an SSRC is contained in the list of desired SSRCs. |
53 // Note that an empty SSRC list matches every SSRC. | 65 // Note that an empty SSRC list matches every SSRC. |
54 bool MatchingSsrc(uint32_t ssrc, const std::vector<uint32_t>& desired_ssrc) { | 66 bool MatchingSsrc(uint32_t ssrc, const std::vector<uint32_t>& desired_ssrc) { |
55 if (desired_ssrc.size() == 0) | 67 if (desired_ssrc.size() == 0) |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 plot->series_list_.back().style = LINE_DOT_GRAPH; | 562 plot->series_list_.back().style = LINE_DOT_GRAPH; |
551 for (auto& ana_event : audio_network_adaptation_events_) { | 563 for (auto& ana_event : audio_network_adaptation_events_) { |
552 rtc::Optional<float> y = get_y(ana_event); | 564 rtc::Optional<float> y = get_y(ana_event); |
553 if (y) { | 565 if (y) { |
554 float x = static_cast<float>(ana_event.timestamp - begin_time_) / 1000000; | 566 float x = static_cast<float>(ana_event.timestamp - begin_time_) / 1000000; |
555 plot->series_list_.back().points.emplace_back(x, *y); | 567 plot->series_list_.back().points.emplace_back(x, *y); |
556 } | 568 } |
557 } | 569 } |
558 } | 570 } |
559 | 571 |
572 void EventLogAnalyzer::SortPacketFeedbackVector( | |
terelius
2017/03/08 11:59:58
This method does not appear to use any state in th
| |
573 std::vector<PacketFeedback>* vec) const { | |
574 auto pred = [](const PacketFeedback& packet_feedback) { | |
575 return packet_feedback.arrival_time_ms == PacketFeedback::kNotReceived; | |
576 }; | |
577 vec->erase(std::remove_if(vec->begin(), vec->end(), pred), vec->end()); | |
578 std::sort(vec->begin(), vec->end(), PacketFeedbackComparator()); | |
579 } | |
580 | |
560 void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction, | 581 void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction, |
561 Plot* plot) { | 582 Plot* plot) { |
562 for (auto& kv : rtp_packets_) { | 583 for (auto& kv : rtp_packets_) { |
563 StreamId stream_id = kv.first; | 584 StreamId stream_id = kv.first; |
564 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; | 585 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; |
565 // Filter on direction and SSRC. | 586 // Filter on direction and SSRC. |
566 if (stream_id.GetDirection() != desired_direction || | 587 if (stream_id.GetDirection() != desired_direction || |
567 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { | 588 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { |
568 continue; | 589 continue; |
569 } | 590 } |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1050 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); | 1071 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); |
1051 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { | 1072 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { |
1052 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); | 1073 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); |
1053 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; | 1074 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; |
1054 if (rtcp.type == kRtcpTransportFeedback) { | 1075 if (rtcp.type == kRtcpTransportFeedback) { |
1055 TransportFeedbackObserver* observer = cc.GetTransportFeedbackObserver(); | 1076 TransportFeedbackObserver* observer = cc.GetTransportFeedbackObserver(); |
1056 observer->OnTransportFeedback(*static_cast<rtcp::TransportFeedback*>( | 1077 observer->OnTransportFeedback(*static_cast<rtcp::TransportFeedback*>( |
1057 rtcp.packet.get())); | 1078 rtcp.packet.get())); |
1058 std::vector<PacketFeedback> feedback = | 1079 std::vector<PacketFeedback> feedback = |
1059 observer->GetTransportFeedbackVector(); | 1080 observer->GetTransportFeedbackVector(); |
1081 SortPacketFeedbackVector(&feedback); | |
1060 rtc::Optional<uint32_t> bitrate_bps; | 1082 rtc::Optional<uint32_t> bitrate_bps; |
1061 if (!feedback.empty()) { | 1083 if (!feedback.empty()) { |
1062 for (const PacketFeedback& packet : feedback) | 1084 for (const PacketFeedback& packet : feedback) |
1063 acked_bitrate.Update(packet.payload_size, packet.arrival_time_ms); | 1085 acked_bitrate.Update(packet.payload_size, packet.arrival_time_ms); |
1064 bitrate_bps = acked_bitrate.Rate(feedback.back().arrival_time_ms); | 1086 bitrate_bps = acked_bitrate.Rate(feedback.back().arrival_time_ms); |
1065 } | 1087 } |
1066 uint32_t y = 0; | 1088 uint32_t y = 0; |
1067 if (bitrate_bps) | 1089 if (bitrate_bps) |
1068 y = *bitrate_bps / 1000; | 1090 y = *bitrate_bps / 1000; |
1069 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / | 1091 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1185 while (time_us != std::numeric_limits<int64_t>::max()) { | 1207 while (time_us != std::numeric_limits<int64_t>::max()) { |
1186 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); | 1208 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); |
1187 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { | 1209 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { |
1188 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); | 1210 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); |
1189 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; | 1211 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; |
1190 if (rtcp.type == kRtcpTransportFeedback) { | 1212 if (rtcp.type == kRtcpTransportFeedback) { |
1191 feedback_adapter.OnTransportFeedback( | 1213 feedback_adapter.OnTransportFeedback( |
1192 *static_cast<rtcp::TransportFeedback*>(rtcp.packet.get())); | 1214 *static_cast<rtcp::TransportFeedback*>(rtcp.packet.get())); |
1193 std::vector<PacketFeedback> feedback = | 1215 std::vector<PacketFeedback> feedback = |
1194 feedback_adapter.GetTransportFeedbackVector(); | 1216 feedback_adapter.GetTransportFeedbackVector(); |
1217 SortPacketFeedbackVector(&feedback); | |
1195 for (const PacketFeedback& packet : feedback) { | 1218 for (const PacketFeedback& packet : feedback) { |
1196 int64_t y = packet.arrival_time_ms - packet.send_time_ms; | 1219 int64_t y = packet.arrival_time_ms - packet.send_time_ms; |
1197 float x = | 1220 float x = |
1198 static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / | 1221 static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / |
1199 1000000; | 1222 1000000; |
1200 estimated_base_delay_ms = std::min(y, estimated_base_delay_ms); | 1223 estimated_base_delay_ms = std::min(y, estimated_base_delay_ms); |
1201 time_series.points.emplace_back(x, y); | 1224 time_series.points.emplace_back(x, y); |
1202 } | 1225 } |
1203 } | 1226 } |
1204 ++rtcp_iterator; | 1227 ++rtcp_iterator; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1381 return rtc::Optional<float>(); | 1404 return rtc::Optional<float>(); |
1382 }); | 1405 }); |
1383 plot->series_list_.back().label = "Audio encoder number of channels"; | 1406 plot->series_list_.back().label = "Audio encoder number of channels"; |
1384 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 1407 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
1385 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", | 1408 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", |
1386 kBottomMargin, kTopMargin); | 1409 kBottomMargin, kTopMargin); |
1387 plot->SetTitle("Reported audio encoder number of channels"); | 1410 plot->SetTitle("Reported audio encoder number of channels"); |
1388 } | 1411 } |
1389 } // namespace plotting | 1412 } // namespace plotting |
1390 } // namespace webrtc | 1413 } // namespace webrtc |
OLD | NEW |