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 |
11 #include "webrtc/tools/event_log_visualizer/analyzer.h" | 11 #include "webrtc/tools/event_log_visualizer/analyzer.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <limits> | 14 #include <limits> |
15 #include <map> | 15 #include <map> |
16 #include <sstream> | 16 #include <sstream> |
17 #include <string> | 17 #include <string> |
18 #include <utility> | 18 #include <utility> |
19 | 19 |
20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
21 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
22 #include "webrtc/base/rate_statistics.h" | 22 #include "webrtc/base/rate_statistics.h" |
23 #include "webrtc/call/audio_receive_stream.h" | 23 #include "webrtc/call/audio_receive_stream.h" |
24 #include "webrtc/call/audio_send_stream.h" | 24 #include "webrtc/call/audio_send_stream.h" |
25 #include "webrtc/call/call.h" | 25 #include "webrtc/call/call.h" |
26 #include "webrtc/common_types.h" | 26 #include "webrtc/common_types.h" |
27 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | |
28 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 27 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
29 #include "webrtc/modules/include/module_common_types.h" | 28 #include "webrtc/modules/include/module_common_types.h" |
30 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 29 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
31 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 30 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" | 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |
35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
36 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" | 35 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" |
37 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 36 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 RateStatistics acked_bitrate(250, 8000); | 1064 RateStatistics acked_bitrate(250, 8000); |
1066 | 1065 |
1067 int64_t time_us = std::min(NextRtpTime(), NextRtcpTime()); | 1066 int64_t time_us = std::min(NextRtpTime(), NextRtcpTime()); |
1068 int64_t last_update_us = 0; | 1067 int64_t last_update_us = 0; |
1069 while (time_us != std::numeric_limits<int64_t>::max()) { | 1068 while (time_us != std::numeric_limits<int64_t>::max()) { |
1070 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); | 1069 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); |
1071 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { | 1070 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { |
1072 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); | 1071 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); |
1073 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; | 1072 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; |
1074 if (rtcp.type == kRtcpTransportFeedback) { | 1073 if (rtcp.type == kRtcpTransportFeedback) { |
1075 TransportFeedbackObserver* observer = cc.GetTransportFeedbackObserver(); | 1074 cc.OnTransportFeedback( |
1076 observer->OnTransportFeedback(*static_cast<rtcp::TransportFeedback*>( | 1075 *static_cast<rtcp::TransportFeedback*>(rtcp.packet.get())); |
1077 rtcp.packet.get())); | 1076 std::vector<PacketFeedback> feedback = cc.GetTransportFeedbackVector(); |
1078 std::vector<PacketFeedback> feedback = | |
1079 observer->GetTransportFeedbackVector(); | |
1080 SortPacketFeedbackVector(&feedback); | 1077 SortPacketFeedbackVector(&feedback); |
1081 rtc::Optional<uint32_t> bitrate_bps; | 1078 rtc::Optional<uint32_t> bitrate_bps; |
1082 if (!feedback.empty()) { | 1079 if (!feedback.empty()) { |
1083 for (const PacketFeedback& packet : feedback) | 1080 for (const PacketFeedback& packet : feedback) |
1084 acked_bitrate.Update(packet.payload_size, packet.arrival_time_ms); | 1081 acked_bitrate.Update(packet.payload_size, packet.arrival_time_ms); |
1085 bitrate_bps = acked_bitrate.Rate(feedback.back().arrival_time_ms); | 1082 bitrate_bps = acked_bitrate.Rate(feedback.back().arrival_time_ms); |
1086 } | 1083 } |
1087 uint32_t y = 0; | 1084 uint32_t y = 0; |
1088 if (bitrate_bps) | 1085 if (bitrate_bps) |
1089 y = *bitrate_bps / 1000; | 1086 y = *bitrate_bps / 1000; |
1090 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / | 1087 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / |
1091 1000000; | 1088 1000000; |
1092 acked_time_series.points.emplace_back(x, y); | 1089 acked_time_series.points.emplace_back(x, y); |
1093 } | 1090 } |
1094 ++rtcp_iterator; | 1091 ++rtcp_iterator; |
1095 } | 1092 } |
1096 if (clock.TimeInMicroseconds() >= NextRtpTime()) { | 1093 if (clock.TimeInMicroseconds() >= NextRtpTime()) { |
1097 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtpTime()); | 1094 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtpTime()); |
1098 const LoggedRtpPacket& rtp = *rtp_iterator->second; | 1095 const LoggedRtpPacket& rtp = *rtp_iterator->second; |
1099 if (rtp.header.extension.hasTransportSequenceNumber) { | 1096 if (rtp.header.extension.hasTransportSequenceNumber) { |
1100 RTC_DCHECK(rtp.header.extension.hasTransportSequenceNumber); | 1097 RTC_DCHECK(rtp.header.extension.hasTransportSequenceNumber); |
1101 cc.GetTransportFeedbackObserver()->AddPacket( | 1098 cc.AddPacket(rtp.header.extension.transportSequenceNumber, |
1102 rtp.header.extension.transportSequenceNumber, rtp.total_length, | 1099 rtp.total_length, PacedPacketInfo()); |
1103 PacedPacketInfo()); | |
1104 rtc::SentPacket sent_packet( | 1100 rtc::SentPacket sent_packet( |
1105 rtp.header.extension.transportSequenceNumber, rtp.timestamp / 1000); | 1101 rtp.header.extension.transportSequenceNumber, rtp.timestamp / 1000); |
1106 cc.OnSentPacket(sent_packet); | 1102 cc.OnSentPacket(sent_packet); |
1107 } | 1103 } |
1108 ++rtp_iterator; | 1104 ++rtp_iterator; |
1109 } | 1105 } |
1110 if (clock.TimeInMicroseconds() >= NextProcessTime()) { | 1106 if (clock.TimeInMicroseconds() >= NextProcessTime()) { |
1111 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextProcessTime()); | 1107 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextProcessTime()); |
1112 cc.Process(); | 1108 cc.Process(); |
1113 } | 1109 } |
1114 if (observer.GetAndResetBitrateUpdated() || | 1110 if (observer.GetAndResetBitrateUpdated() || |
1115 time_us - last_update_us >= 1e6) { | 1111 time_us - last_update_us >= 1e6) { |
1116 uint32_t y = observer.last_bitrate_bps() / 1000; | 1112 uint32_t y = observer.last_bitrate_bps() / 1000; |
1117 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / | 1113 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / |
1118 1000000; | 1114 1000000; |
1119 time_series.points.emplace_back(x, y); | 1115 time_series.points.emplace_back(x, y); |
1120 last_update_us = time_us; | 1116 last_update_us = time_us; |
1121 } | 1117 } |
1122 time_us = std::min({NextRtpTime(), NextRtcpTime(), NextProcessTime()}); | 1118 time_us = std::min({NextRtpTime(), NextRtcpTime(), NextProcessTime()}); |
1123 } | 1119 } |
1124 // Add the data set to the plot. | 1120 // Add the data set to the plot. |
1125 plot->series_list_.push_back(std::move(time_series)); | 1121 plot->series_list_.push_back(std::move(time_series)); |
1126 plot->series_list_.push_back(std::move(acked_time_series)); | 1122 plot->series_list_.push_back(std::move(acked_time_series)); |
1127 | 1123 |
1128 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 1124 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
1129 plot->SetSuggestedYAxis(0, 10, "Bitrate (kbps)", kBottomMargin, kTopMargin); | 1125 plot->SetSuggestedYAxis(0, 10, "Bitrate (kbps)", kBottomMargin, kTopMargin); |
1130 plot->SetTitle("Simulated BWE behavior"); | 1126 plot->SetTitle("Simulated BWE behavior"); |
1131 } | 1127 } |
1132 | 1128 |
1133 // TODO(holmer): Remove once TransportFeedbackAdapter no longer needs a | |
1134 // BitrateController. | |
1135 class NullBitrateController : public BitrateController { | |
1136 public: | |
1137 ~NullBitrateController() override {} | |
1138 RtcpBandwidthObserver* CreateRtcpBandwidthObserver() override { | |
1139 return nullptr; | |
1140 } | |
1141 void SetStartBitrate(int start_bitrate_bps) override {} | |
1142 void SetMinMaxBitrate(int min_bitrate_bps, int max_bitrate_bps) override {} | |
1143 void SetBitrates(int start_bitrate_bps, | |
1144 int min_bitrate_bps, | |
1145 int max_bitrate_bps) override {} | |
1146 void ResetBitrates(int bitrate_bps, | |
1147 int min_bitrate_bps, | |
1148 int max_bitrate_bps) override {} | |
1149 void OnDelayBasedBweResult(const DelayBasedBwe::Result& result) override {} | |
1150 bool AvailableBandwidth(uint32_t* bandwidth) const override { return false; } | |
1151 void SetReservedBitrate(uint32_t reserved_bitrate_bps) override {} | |
1152 bool GetNetworkParameters(uint32_t* bitrate, | |
1153 uint8_t* fraction_loss, | |
1154 int64_t* rtt) override { | |
1155 return false; | |
1156 } | |
1157 int64_t TimeUntilNextProcess() override { return 0; } | |
1158 void Process() override {} | |
1159 }; | |
1160 | |
1161 void EventLogAnalyzer::CreateNetworkDelayFeedbackGraph(Plot* plot) { | 1129 void EventLogAnalyzer::CreateNetworkDelayFeedbackGraph(Plot* plot) { |
1162 std::map<uint64_t, const LoggedRtpPacket*> outgoing_rtp; | 1130 std::map<uint64_t, const LoggedRtpPacket*> outgoing_rtp; |
1163 std::map<uint64_t, const LoggedRtcpPacket*> incoming_rtcp; | 1131 std::map<uint64_t, const LoggedRtcpPacket*> incoming_rtcp; |
1164 | 1132 |
1165 for (const auto& kv : rtp_packets_) { | 1133 for (const auto& kv : rtp_packets_) { |
1166 if (kv.first.GetDirection() == PacketDirection::kOutgoingPacket) { | 1134 if (kv.first.GetDirection() == PacketDirection::kOutgoingPacket) { |
1167 for (const LoggedRtpPacket& rtp_packet : kv.second) | 1135 for (const LoggedRtpPacket& rtp_packet : kv.second) |
1168 outgoing_rtp.insert(std::make_pair(rtp_packet.timestamp, &rtp_packet)); | 1136 outgoing_rtp.insert(std::make_pair(rtp_packet.timestamp, &rtp_packet)); |
1169 } | 1137 } |
1170 } | 1138 } |
1171 | 1139 |
1172 for (const auto& kv : rtcp_packets_) { | 1140 for (const auto& kv : rtcp_packets_) { |
1173 if (kv.first.GetDirection() == PacketDirection::kIncomingPacket) { | 1141 if (kv.first.GetDirection() == PacketDirection::kIncomingPacket) { |
1174 for (const LoggedRtcpPacket& rtcp_packet : kv.second) | 1142 for (const LoggedRtcpPacket& rtcp_packet : kv.second) |
1175 incoming_rtcp.insert( | 1143 incoming_rtcp.insert( |
1176 std::make_pair(rtcp_packet.timestamp, &rtcp_packet)); | 1144 std::make_pair(rtcp_packet.timestamp, &rtcp_packet)); |
1177 } | 1145 } |
1178 } | 1146 } |
1179 | 1147 |
1180 SimulatedClock clock(0); | 1148 SimulatedClock clock(0); |
1181 NullBitrateController null_controller; | 1149 TransportFeedbackAdapter feedback_adapter(&clock); |
1182 TransportFeedbackAdapter feedback_adapter(nullptr, &clock, &null_controller); | |
1183 feedback_adapter.InitBwe(); | |
1184 | 1150 |
1185 TimeSeries time_series; | 1151 TimeSeries time_series; |
1186 time_series.label = "Network Delay Change"; | 1152 time_series.label = "Network Delay Change"; |
1187 time_series.style = LINE_DOT_GRAPH; | 1153 time_series.style = LINE_DOT_GRAPH; |
1188 int64_t estimated_base_delay_ms = std::numeric_limits<int64_t>::max(); | 1154 int64_t estimated_base_delay_ms = std::numeric_limits<int64_t>::max(); |
1189 | 1155 |
1190 auto rtp_iterator = outgoing_rtp.begin(); | 1156 auto rtp_iterator = outgoing_rtp.begin(); |
1191 auto rtcp_iterator = incoming_rtcp.begin(); | 1157 auto rtcp_iterator = incoming_rtcp.begin(); |
1192 | 1158 |
1193 auto NextRtpTime = [&]() { | 1159 auto NextRtpTime = [&]() { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 return rtc::Optional<float>(); | 1369 return rtc::Optional<float>(); |
1404 }); | 1370 }); |
1405 plot->series_list_.back().label = "Audio encoder number of channels"; | 1371 plot->series_list_.back().label = "Audio encoder number of channels"; |
1406 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 1372 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
1407 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", | 1373 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", |
1408 kBottomMargin, kTopMargin); | 1374 kBottomMargin, kTopMargin); |
1409 plot->SetTitle("Reported audio encoder number of channels"); | 1375 plot->SetTitle("Reported audio encoder number of channels"); |
1410 } | 1376 } |
1411 } // namespace plotting | 1377 } // namespace plotting |
1412 } // namespace webrtc | 1378 } // namespace webrtc |
OLD | NEW |