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

Side by Side Diff: webrtc/modules/congestion_controller/transport_feedback_adapter.cc

Issue 2707383006: GetTransportFeedbackVector() includes unreceived packets, sorted by seq-num (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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 12 matching lines...) Expand all
23 #include "webrtc/system_wrappers/include/field_trial.h" 23 #include "webrtc/system_wrappers/include/field_trial.h"
24 24
25 namespace webrtc { 25 namespace webrtc {
26 26
27 const int64_t kNoTimestamp = -1; 27 const int64_t kNoTimestamp = -1;
28 const int64_t kSendTimeHistoryWindowMs = 60000; 28 const int64_t kSendTimeHistoryWindowMs = 60000;
29 const int64_t kBaseTimestampScaleFactor = 29 const int64_t kBaseTimestampScaleFactor =
30 rtcp::TransportFeedback::kDeltaScaleFactor * (1 << 8); 30 rtcp::TransportFeedback::kDeltaScaleFactor * (1 << 8);
31 const int64_t kBaseTimestampRangeSizeUs = kBaseTimestampScaleFactor * (1 << 24); 31 const int64_t kBaseTimestampRangeSizeUs = kBaseTimestampScaleFactor * (1 << 24);
32 32
33 class PacketFeedbackComparator {
34 public:
35 inline bool operator()(const PacketFeedback& lhs, const PacketFeedback& rhs) {
36 if (lhs.arrival_time_ms != rhs.arrival_time_ms)
37 return lhs.arrival_time_ms < rhs.arrival_time_ms;
38 if (lhs.send_time_ms != rhs.send_time_ms)
39 return lhs.send_time_ms < rhs.send_time_ms;
40 return lhs.sequence_number < rhs.sequence_number;
41 }
42 };
43
44 TransportFeedbackAdapter::TransportFeedbackAdapter( 33 TransportFeedbackAdapter::TransportFeedbackAdapter(
45 RtcEventLog* event_log, 34 RtcEventLog* event_log,
46 Clock* clock, 35 Clock* clock,
47 BitrateController* bitrate_controller) 36 BitrateController* bitrate_controller)
48 : send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName( 37 : send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName(
49 "WebRTC-SendSideBwe-WithOverhead") == 38 "WebRTC-SendSideBwe-WithOverhead") ==
50 "Enabled"), 39 "Enabled"),
51 transport_overhead_bytes_per_packet_(0), 40 transport_overhead_bytes_per_packet_(0),
52 send_time_history_(clock, kSendTimeHistoryWindowMs), 41 send_time_history_(clock, kSendTimeHistoryWindowMs),
53 event_log_(event_log), 42 event_log_(event_log),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 if (std::abs(delta - kBaseTimestampRangeSizeUs) < std::abs(delta)) { 115 if (std::abs(delta - kBaseTimestampRangeSizeUs) < std::abs(delta)) {
127 delta -= kBaseTimestampRangeSizeUs; // Wrap backwards. 116 delta -= kBaseTimestampRangeSizeUs; // Wrap backwards.
128 } else if (std::abs(delta + kBaseTimestampRangeSizeUs) < std::abs(delta)) { 117 } else if (std::abs(delta + kBaseTimestampRangeSizeUs) < std::abs(delta)) {
129 delta += kBaseTimestampRangeSizeUs; // Wrap forwards. 118 delta += kBaseTimestampRangeSizeUs; // Wrap forwards.
130 } 119 }
131 120
132 current_offset_ms_ += delta / 1000; 121 current_offset_ms_ += delta / 1000;
133 } 122 }
134 last_timestamp_us_ = timestamp_us; 123 last_timestamp_us_ = timestamp_us;
135 124
136 auto received_packets = feedback.GetReceivedPackets(); 125 auto status_vector = feedback.GetStatusVector();
137 std::vector<PacketFeedback> packet_feedback_vector; 126 std::vector<PacketFeedback> packet_feedback_vector;
138 packet_feedback_vector.reserve(received_packets.size()); 127 packet_feedback_vector.reserve(status_vector.size());
139 if (received_packets.empty()) { 128 if (status_vector.empty()) {
140 LOG(LS_INFO) << "Empty transport feedback packet received."; 129 LOG(LS_INFO) << "Empty transport feedback packet received.";
141 return packet_feedback_vector; 130 return packet_feedback_vector;
142 } 131 }
143 { 132 {
144 rtc::CritScope cs(&lock_); 133 rtc::CritScope cs(&lock_);
145 size_t failed_lookups = 0; 134 size_t failed_lookups = 0;
146 int64_t offset_us = 0; 135 int64_t offset_us = 0;
147 int64_t timestamp_ms = 0; 136 int64_t timestamp_ms = 0;
137 uint16_t seq_no = feedback.GetBaseSequence();
148 for (const auto& packet : feedback.GetReceivedPackets()) { 138 for (const auto& packet : feedback.GetReceivedPackets()) {
139 // Insert into the vector those unreceived packets which precede this
140 // iteration's received packet.
141 for (; seq_no != packet.sequence_number(); ++seq_no) {
142 PacketFeedback packet_feedback(PacketFeedback::kLost, seq_no);
stefan-webrtc 2017/02/28 14:51:12 Is kLost the right name? It indicates that he pack
elad.alon_webrtc.org 2017/02/28 15:20:18 I was thinking kNotReceived, but I was afraid some
143 // Note: Element not removed from history because it might be reported
144 // as received by another feedback.
145 if (!send_time_history_.GetFeedback(&packet_feedback, false))
146 ++failed_lookups;
147 packet_feedback_vector.push_back(packet_feedback);
148 }
149
150 // Handle this iteration's received packet.
149 offset_us += packet.delta_us(); 151 offset_us += packet.delta_us();
150 timestamp_ms = current_offset_ms_ + (offset_us / 1000); 152 timestamp_ms = current_offset_ms_ + (offset_us / 1000);
151 PacketFeedback packet_feedback(timestamp_ms, packet.sequence_number()); 153 PacketFeedback packet_feedback(timestamp_ms, packet.sequence_number());
152 if (!send_time_history_.GetFeedback(&packet_feedback, true)) 154 if (!send_time_history_.GetFeedback(&packet_feedback, true))
153 ++failed_lookups; 155 ++failed_lookups;
154 packet_feedback_vector.push_back(packet_feedback); 156 packet_feedback_vector.push_back(packet_feedback);
157
158 ++seq_no;
155 } 159 }
156 std::sort(packet_feedback_vector.begin(), packet_feedback_vector.end(), 160
157 PacketFeedbackComparator());
158 if (failed_lookups > 0) { 161 if (failed_lookups > 0) {
159 LOG(LS_WARNING) << "Failed to lookup send time for " << failed_lookups 162 LOG(LS_WARNING) << "Failed to lookup send time for " << failed_lookups
160 << " packet" << (failed_lookups > 1 ? "s" : "") 163 << " packet" << (failed_lookups > 1 ? "s" : "")
161 << ". Send time history too small?"; 164 << ". Send time history too small?";
162 } 165 }
163 } 166 }
164 return packet_feedback_vector; 167 return packet_feedback_vector;
165 } 168 }
166 169
167 void TransportFeedbackAdapter::OnTransportFeedback( 170 void TransportFeedbackAdapter::OnTransportFeedback(
(...skipping 17 matching lines...) Expand all
185 } 188 }
186 189
187 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms, 190 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms,
188 int64_t max_rtt_ms) { 191 int64_t max_rtt_ms) {
189 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); 192 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
190 rtc::CritScope cs(&bwe_lock_); 193 rtc::CritScope cs(&bwe_lock_);
191 delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); 194 delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms);
192 } 195 }
193 196
194 } // namespace webrtc 197 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698