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 |
| 58 void SortPacketFeedbackVector(std::vector<PacketFeedback>* vec) { |
| 59 auto pred = [](const PacketFeedback& packet_feedback) { |
| 60 return packet_feedback.arrival_time_ms == PacketFeedback::kNotReceived; |
| 61 }; |
| 62 vec->erase(std::remove_if(vec->begin(), vec->end(), pred), vec->end()); |
| 63 std::sort(vec->begin(), vec->end(), PacketFeedbackComparator()); |
| 64 } |
| 65 |
46 std::string SsrcToString(uint32_t ssrc) { | 66 std::string SsrcToString(uint32_t ssrc) { |
47 std::stringstream ss; | 67 std::stringstream ss; |
48 ss << "SSRC " << ssrc; | 68 ss << "SSRC " << ssrc; |
49 return ss.str(); | 69 return ss.str(); |
50 } | 70 } |
51 | 71 |
52 // Checks whether an SSRC is contained in the list of desired SSRCs. | 72 // Checks whether an SSRC is contained in the list of desired SSRCs. |
53 // Note that an empty SSRC list matches every SSRC. | 73 // Note that an empty SSRC list matches every SSRC. |
54 bool MatchingSsrc(uint32_t ssrc, const std::vector<uint32_t>& desired_ssrc) { | 74 bool MatchingSsrc(uint32_t ssrc, const std::vector<uint32_t>& desired_ssrc) { |
55 if (desired_ssrc.size() == 0) | 75 if (desired_ssrc.size() == 0) |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); | 1070 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); |
1051 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { | 1071 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { |
1052 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); | 1072 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); |
1053 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; | 1073 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; |
1054 if (rtcp.type == kRtcpTransportFeedback) { | 1074 if (rtcp.type == kRtcpTransportFeedback) { |
1055 TransportFeedbackObserver* observer = cc.GetTransportFeedbackObserver(); | 1075 TransportFeedbackObserver* observer = cc.GetTransportFeedbackObserver(); |
1056 observer->OnTransportFeedback(*static_cast<rtcp::TransportFeedback*>( | 1076 observer->OnTransportFeedback(*static_cast<rtcp::TransportFeedback*>( |
1057 rtcp.packet.get())); | 1077 rtcp.packet.get())); |
1058 std::vector<PacketFeedback> feedback = | 1078 std::vector<PacketFeedback> feedback = |
1059 observer->GetTransportFeedbackVector(); | 1079 observer->GetTransportFeedbackVector(); |
| 1080 SortPacketFeedbackVector(&feedback); |
1060 rtc::Optional<uint32_t> bitrate_bps; | 1081 rtc::Optional<uint32_t> bitrate_bps; |
1061 if (!feedback.empty()) { | 1082 if (!feedback.empty()) { |
1062 for (const PacketFeedback& packet : feedback) | 1083 for (const PacketFeedback& packet : feedback) |
1063 acked_bitrate.Update(packet.payload_size, packet.arrival_time_ms); | 1084 acked_bitrate.Update(packet.payload_size, packet.arrival_time_ms); |
1064 bitrate_bps = acked_bitrate.Rate(feedback.back().arrival_time_ms); | 1085 bitrate_bps = acked_bitrate.Rate(feedback.back().arrival_time_ms); |
1065 } | 1086 } |
1066 uint32_t y = 0; | 1087 uint32_t y = 0; |
1067 if (bitrate_bps) | 1088 if (bitrate_bps) |
1068 y = *bitrate_bps / 1000; | 1089 y = *bitrate_bps / 1000; |
1069 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / | 1090 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()) { | 1206 while (time_us != std::numeric_limits<int64_t>::max()) { |
1186 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); | 1207 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); |
1187 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { | 1208 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { |
1188 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); | 1209 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); |
1189 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; | 1210 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; |
1190 if (rtcp.type == kRtcpTransportFeedback) { | 1211 if (rtcp.type == kRtcpTransportFeedback) { |
1191 feedback_adapter.OnTransportFeedback( | 1212 feedback_adapter.OnTransportFeedback( |
1192 *static_cast<rtcp::TransportFeedback*>(rtcp.packet.get())); | 1213 *static_cast<rtcp::TransportFeedback*>(rtcp.packet.get())); |
1193 std::vector<PacketFeedback> feedback = | 1214 std::vector<PacketFeedback> feedback = |
1194 feedback_adapter.GetTransportFeedbackVector(); | 1215 feedback_adapter.GetTransportFeedbackVector(); |
| 1216 SortPacketFeedbackVector(&feedback); |
1195 for (const PacketFeedback& packet : feedback) { | 1217 for (const PacketFeedback& packet : feedback) { |
1196 int64_t y = packet.arrival_time_ms - packet.send_time_ms; | 1218 int64_t y = packet.arrival_time_ms - packet.send_time_ms; |
1197 float x = | 1219 float x = |
1198 static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / | 1220 static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / |
1199 1000000; | 1221 1000000; |
1200 estimated_base_delay_ms = std::min(y, estimated_base_delay_ms); | 1222 estimated_base_delay_ms = std::min(y, estimated_base_delay_ms); |
1201 time_series.points.emplace_back(x, y); | 1223 time_series.points.emplace_back(x, y); |
1202 } | 1224 } |
1203 } | 1225 } |
1204 ++rtcp_iterator; | 1226 ++rtcp_iterator; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 return rtc::Optional<float>(); | 1403 return rtc::Optional<float>(); |
1382 }); | 1404 }); |
1383 plot->series_list_.back().label = "Audio encoder number of channels"; | 1405 plot->series_list_.back().label = "Audio encoder number of channels"; |
1384 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 1406 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
1385 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", | 1407 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", |
1386 kBottomMargin, kTopMargin); | 1408 kBottomMargin, kTopMargin); |
1387 plot->SetTitle("Reported audio encoder number of channels"); | 1409 plot->SetTitle("Reported audio encoder number of channels"); |
1388 } | 1410 } |
1389 } // namespace plotting | 1411 } // namespace plotting |
1390 } // namespace webrtc | 1412 } // namespace webrtc |
OLD | NEW |