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

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

Issue 2743553003: Revert of Move delay_based_bwe_ into CongestionController (Closed)
Patch Set: Created 3 years, 9 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
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
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"
27 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" 28 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
28 #include "webrtc/modules/include/module_common_types.h" 29 #include "webrtc/modules/include/module_common_types.h"
29 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 30 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
30 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 31 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
35 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" 36 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h"
36 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 37 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 RateStatistics acked_bitrate(250, 8000); 1065 RateStatistics acked_bitrate(250, 8000);
1065 1066
1066 int64_t time_us = std::min(NextRtpTime(), NextRtcpTime()); 1067 int64_t time_us = std::min(NextRtpTime(), NextRtcpTime());
1067 int64_t last_update_us = 0; 1068 int64_t last_update_us = 0;
1068 while (time_us != std::numeric_limits<int64_t>::max()) { 1069 while (time_us != std::numeric_limits<int64_t>::max()) {
1069 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); 1070 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds());
1070 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { 1071 if (clock.TimeInMicroseconds() >= NextRtcpTime()) {
1071 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); 1072 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime());
1072 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; 1073 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second;
1073 if (rtcp.type == kRtcpTransportFeedback) { 1074 if (rtcp.type == kRtcpTransportFeedback) {
1074 cc.OnTransportFeedback( 1075 TransportFeedbackObserver* observer = cc.GetTransportFeedbackObserver();
1075 *static_cast<rtcp::TransportFeedback*>(rtcp.packet.get())); 1076 observer->OnTransportFeedback(*static_cast<rtcp::TransportFeedback*>(
1076 std::vector<PacketFeedback> feedback = cc.GetTransportFeedbackVector(); 1077 rtcp.packet.get()));
1078 std::vector<PacketFeedback> feedback =
1079 observer->GetTransportFeedbackVector();
1077 SortPacketFeedbackVector(&feedback); 1080 SortPacketFeedbackVector(&feedback);
1078 rtc::Optional<uint32_t> bitrate_bps; 1081 rtc::Optional<uint32_t> bitrate_bps;
1079 if (!feedback.empty()) { 1082 if (!feedback.empty()) {
1080 for (const PacketFeedback& packet : feedback) 1083 for (const PacketFeedback& packet : feedback)
1081 acked_bitrate.Update(packet.payload_size, packet.arrival_time_ms); 1084 acked_bitrate.Update(packet.payload_size, packet.arrival_time_ms);
1082 bitrate_bps = acked_bitrate.Rate(feedback.back().arrival_time_ms); 1085 bitrate_bps = acked_bitrate.Rate(feedback.back().arrival_time_ms);
1083 } 1086 }
1084 uint32_t y = 0; 1087 uint32_t y = 0;
1085 if (bitrate_bps) 1088 if (bitrate_bps)
1086 y = *bitrate_bps / 1000; 1089 y = *bitrate_bps / 1000;
1087 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / 1090 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) /
1088 1000000; 1091 1000000;
1089 acked_time_series.points.emplace_back(x, y); 1092 acked_time_series.points.emplace_back(x, y);
1090 } 1093 }
1091 ++rtcp_iterator; 1094 ++rtcp_iterator;
1092 } 1095 }
1093 if (clock.TimeInMicroseconds() >= NextRtpTime()) { 1096 if (clock.TimeInMicroseconds() >= NextRtpTime()) {
1094 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtpTime()); 1097 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtpTime());
1095 const LoggedRtpPacket& rtp = *rtp_iterator->second; 1098 const LoggedRtpPacket& rtp = *rtp_iterator->second;
1096 if (rtp.header.extension.hasTransportSequenceNumber) { 1099 if (rtp.header.extension.hasTransportSequenceNumber) {
1097 RTC_DCHECK(rtp.header.extension.hasTransportSequenceNumber); 1100 RTC_DCHECK(rtp.header.extension.hasTransportSequenceNumber);
1098 cc.AddPacket(rtp.header.extension.transportSequenceNumber, 1101 cc.GetTransportFeedbackObserver()->AddPacket(
1099 rtp.total_length, PacedPacketInfo()); 1102 rtp.header.extension.transportSequenceNumber, rtp.total_length,
1103 PacedPacketInfo());
1100 rtc::SentPacket sent_packet( 1104 rtc::SentPacket sent_packet(
1101 rtp.header.extension.transportSequenceNumber, rtp.timestamp / 1000); 1105 rtp.header.extension.transportSequenceNumber, rtp.timestamp / 1000);
1102 cc.OnSentPacket(sent_packet); 1106 cc.OnSentPacket(sent_packet);
1103 } 1107 }
1104 ++rtp_iterator; 1108 ++rtp_iterator;
1105 } 1109 }
1106 if (clock.TimeInMicroseconds() >= NextProcessTime()) { 1110 if (clock.TimeInMicroseconds() >= NextProcessTime()) {
1107 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextProcessTime()); 1111 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextProcessTime());
1108 cc.Process(); 1112 cc.Process();
1109 } 1113 }
1110 if (observer.GetAndResetBitrateUpdated() || 1114 if (observer.GetAndResetBitrateUpdated() ||
1111 time_us - last_update_us >= 1e6) { 1115 time_us - last_update_us >= 1e6) {
1112 uint32_t y = observer.last_bitrate_bps() / 1000; 1116 uint32_t y = observer.last_bitrate_bps() / 1000;
1113 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / 1117 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) /
1114 1000000; 1118 1000000;
1115 time_series.points.emplace_back(x, y); 1119 time_series.points.emplace_back(x, y);
1116 last_update_us = time_us; 1120 last_update_us = time_us;
1117 } 1121 }
1118 time_us = std::min({NextRtpTime(), NextRtcpTime(), NextProcessTime()}); 1122 time_us = std::min({NextRtpTime(), NextRtcpTime(), NextProcessTime()});
1119 } 1123 }
1120 // Add the data set to the plot. 1124 // Add the data set to the plot.
1121 plot->series_list_.push_back(std::move(time_series)); 1125 plot->series_list_.push_back(std::move(time_series));
1122 plot->series_list_.push_back(std::move(acked_time_series)); 1126 plot->series_list_.push_back(std::move(acked_time_series));
1123 1127
1124 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); 1128 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
1125 plot->SetSuggestedYAxis(0, 10, "Bitrate (kbps)", kBottomMargin, kTopMargin); 1129 plot->SetSuggestedYAxis(0, 10, "Bitrate (kbps)", kBottomMargin, kTopMargin);
1126 plot->SetTitle("Simulated BWE behavior"); 1130 plot->SetTitle("Simulated BWE behavior");
1127 } 1131 }
1128 1132
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
1129 void EventLogAnalyzer::CreateNetworkDelayFeedbackGraph(Plot* plot) { 1161 void EventLogAnalyzer::CreateNetworkDelayFeedbackGraph(Plot* plot) {
1130 std::map<uint64_t, const LoggedRtpPacket*> outgoing_rtp; 1162 std::map<uint64_t, const LoggedRtpPacket*> outgoing_rtp;
1131 std::map<uint64_t, const LoggedRtcpPacket*> incoming_rtcp; 1163 std::map<uint64_t, const LoggedRtcpPacket*> incoming_rtcp;
1132 1164
1133 for (const auto& kv : rtp_packets_) { 1165 for (const auto& kv : rtp_packets_) {
1134 if (kv.first.GetDirection() == PacketDirection::kOutgoingPacket) { 1166 if (kv.first.GetDirection() == PacketDirection::kOutgoingPacket) {
1135 for (const LoggedRtpPacket& rtp_packet : kv.second) 1167 for (const LoggedRtpPacket& rtp_packet : kv.second)
1136 outgoing_rtp.insert(std::make_pair(rtp_packet.timestamp, &rtp_packet)); 1168 outgoing_rtp.insert(std::make_pair(rtp_packet.timestamp, &rtp_packet));
1137 } 1169 }
1138 } 1170 }
1139 1171
1140 for (const auto& kv : rtcp_packets_) { 1172 for (const auto& kv : rtcp_packets_) {
1141 if (kv.first.GetDirection() == PacketDirection::kIncomingPacket) { 1173 if (kv.first.GetDirection() == PacketDirection::kIncomingPacket) {
1142 for (const LoggedRtcpPacket& rtcp_packet : kv.second) 1174 for (const LoggedRtcpPacket& rtcp_packet : kv.second)
1143 incoming_rtcp.insert( 1175 incoming_rtcp.insert(
1144 std::make_pair(rtcp_packet.timestamp, &rtcp_packet)); 1176 std::make_pair(rtcp_packet.timestamp, &rtcp_packet));
1145 } 1177 }
1146 } 1178 }
1147 1179
1148 SimulatedClock clock(0); 1180 SimulatedClock clock(0);
1149 TransportFeedbackAdapter feedback_adapter(&clock); 1181 NullBitrateController null_controller;
1182 TransportFeedbackAdapter feedback_adapter(nullptr, &clock, &null_controller);
1183 feedback_adapter.InitBwe();
1150 1184
1151 TimeSeries time_series; 1185 TimeSeries time_series;
1152 time_series.label = "Network Delay Change"; 1186 time_series.label = "Network Delay Change";
1153 time_series.style = LINE_DOT_GRAPH; 1187 time_series.style = LINE_DOT_GRAPH;
1154 int64_t estimated_base_delay_ms = std::numeric_limits<int64_t>::max(); 1188 int64_t estimated_base_delay_ms = std::numeric_limits<int64_t>::max();
1155 1189
1156 auto rtp_iterator = outgoing_rtp.begin(); 1190 auto rtp_iterator = outgoing_rtp.begin();
1157 auto rtcp_iterator = incoming_rtcp.begin(); 1191 auto rtcp_iterator = incoming_rtcp.begin();
1158 1192
1159 auto NextRtpTime = [&]() { 1193 auto NextRtpTime = [&]() {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 return rtc::Optional<float>(); 1403 return rtc::Optional<float>();
1370 }); 1404 });
1371 plot->series_list_.back().label = "Audio encoder number of channels"; 1405 plot->series_list_.back().label = "Audio encoder number of channels";
1372 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); 1406 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
1373 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", 1407 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))",
1374 kBottomMargin, kTopMargin); 1408 kBottomMargin, kTopMargin);
1375 plot->SetTitle("Reported audio encoder number of channels"); 1409 plot->SetTitle("Reported audio encoder number of channels");
1376 } 1410 }
1377 } // namespace plotting 1411 } // namespace plotting
1378 } // namespace webrtc 1412 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/congestion_controller/transport_feedback_adapter_unittest.cc ('k') | webrtc/video/video_send_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698