OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 if (lhs.send_time_ms != rhs.send_time_ms) | 37 if (lhs.send_time_ms != rhs.send_time_ms) |
38 return lhs.send_time_ms < rhs.send_time_ms; | 38 return lhs.send_time_ms < rhs.send_time_ms; |
39 return lhs.sequence_number < rhs.sequence_number; | 39 return lhs.sequence_number < rhs.sequence_number; |
40 } | 40 } |
41 }; | 41 }; |
42 | 42 |
43 TransportFeedbackAdapter::TransportFeedbackAdapter( | 43 TransportFeedbackAdapter::TransportFeedbackAdapter( |
44 Clock* clock, | 44 Clock* clock, |
45 BitrateController* bitrate_controller) | 45 BitrateController* bitrate_controller) |
46 : send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName( | 46 : send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName( |
47 "WebRTC-SendSideBwe-WithOverhead") == "Enabled"), | 47 "WebRTC-SendSideBwe-WithOverhead") == |
| 48 "Enabled"), |
48 transport_overhead_bytes_per_packet_(0), | 49 transport_overhead_bytes_per_packet_(0), |
49 send_time_history_(clock, kSendTimeHistoryWindowMs), | 50 send_time_history_(clock, kSendTimeHistoryWindowMs), |
50 clock_(clock), | 51 clock_(clock), |
51 current_offset_ms_(kNoTimestamp), | 52 current_offset_ms_(kNoTimestamp), |
52 last_timestamp_us_(kNoTimestamp), | 53 last_timestamp_us_(kNoTimestamp), |
53 bitrate_controller_(bitrate_controller) {} | 54 bitrate_controller_(bitrate_controller) {} |
54 | 55 |
55 TransportFeedbackAdapter::~TransportFeedbackAdapter() {} | 56 TransportFeedbackAdapter::~TransportFeedbackAdapter() {} |
56 | 57 |
57 void TransportFeedbackAdapter::InitBwe() { | 58 void TransportFeedbackAdapter::InitBwe() { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 if (std::abs(delta - kBaseTimestampRangeSizeUs) < std::abs(delta)) { | 112 if (std::abs(delta - kBaseTimestampRangeSizeUs) < std::abs(delta)) { |
112 delta -= kBaseTimestampRangeSizeUs; // Wrap backwards. | 113 delta -= kBaseTimestampRangeSizeUs; // Wrap backwards. |
113 } else if (std::abs(delta + kBaseTimestampRangeSizeUs) < std::abs(delta)) { | 114 } else if (std::abs(delta + kBaseTimestampRangeSizeUs) < std::abs(delta)) { |
114 delta += kBaseTimestampRangeSizeUs; // Wrap forwards. | 115 delta += kBaseTimestampRangeSizeUs; // Wrap forwards. |
115 } | 116 } |
116 | 117 |
117 current_offset_ms_ += delta / 1000; | 118 current_offset_ms_ += delta / 1000; |
118 } | 119 } |
119 last_timestamp_us_ = timestamp_us; | 120 last_timestamp_us_ = timestamp_us; |
120 | 121 |
| 122 auto received_packets = feedback.GetReceivedPackets(); |
121 std::vector<PacketInfo> packet_feedback_vector; | 123 std::vector<PacketInfo> packet_feedback_vector; |
122 packet_feedback_vector.reserve(feedback.GetReceivedPackets().size()); | 124 packet_feedback_vector.reserve(received_packets.size()); |
| 125 if (received_packets.empty()) { |
| 126 LOG(LS_INFO) << "Empty transport feedback packet received."; |
| 127 return packet_feedback_vector; |
| 128 } |
123 { | 129 { |
124 rtc::CritScope cs(&lock_); | 130 rtc::CritScope cs(&lock_); |
125 size_t failed_lookups = 0; | 131 size_t failed_lookups = 0; |
126 int64_t offset_us = 0; | 132 int64_t offset_us = 0; |
| 133 int64_t timestamp_ms = 0; |
127 for (const auto& packet : feedback.GetReceivedPackets()) { | 134 for (const auto& packet : feedback.GetReceivedPackets()) { |
128 offset_us += packet.delta_us(); | 135 offset_us += packet.delta_us(); |
129 int64_t timestamp_ms = current_offset_ms_ + (offset_us / 1000); | 136 timestamp_ms = current_offset_ms_ + (offset_us / 1000); |
130 PacketInfo info(timestamp_ms, packet.sequence_number()); | 137 PacketInfo info(timestamp_ms, packet.sequence_number()); |
131 if (send_time_history_.GetInfo(&info, true) && info.send_time_ms >= 0) { | 138 if (!send_time_history_.GetInfo(&info, true)) |
132 packet_feedback_vector.push_back(info); | |
133 } else { | |
134 ++failed_lookups; | 139 ++failed_lookups; |
135 } | 140 packet_feedback_vector.push_back(info); |
136 } | 141 } |
137 std::sort(packet_feedback_vector.begin(), packet_feedback_vector.end(), | 142 std::sort(packet_feedback_vector.begin(), packet_feedback_vector.end(), |
138 PacketInfoComparator()); | 143 PacketInfoComparator()); |
139 if (failed_lookups > 0) { | 144 if (failed_lookups > 0) { |
140 LOG(LS_WARNING) << "Failed to lookup send time for " << failed_lookups | 145 LOG(LS_WARNING) << "Failed to lookup send time for " << failed_lookups |
141 << " packet" << (failed_lookups > 1 ? "s" : "") | 146 << " packet" << (failed_lookups > 1 ? "s" : "") |
142 << ". Send time history too small?"; | 147 << ". Send time history too small?"; |
143 } | 148 } |
144 } | 149 } |
145 return packet_feedback_vector; | 150 return packet_feedback_vector; |
(...skipping 17 matching lines...) Expand all Loading... |
163 return last_packet_feedback_vector_; | 168 return last_packet_feedback_vector_; |
164 } | 169 } |
165 | 170 |
166 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms, | 171 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms, |
167 int64_t max_rtt_ms) { | 172 int64_t max_rtt_ms) { |
168 rtc::CritScope cs(&bwe_lock_); | 173 rtc::CritScope cs(&bwe_lock_); |
169 delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); | 174 delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
170 } | 175 } |
171 | 176 |
172 } // namespace webrtc | 177 } // namespace webrtc |
OLD | NEW |