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

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

Issue 2710093004: Rename webrtc::PacketInfo to webrtc::PacketFeedback (Closed)
Patch Set: Rebased 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 PacketInfoComparator { 33 class PacketFeedbackComparator {
34 public: 34 public:
35 inline bool operator()(const PacketInfo& lhs, const PacketInfo& rhs) { 35 inline bool operator()(const PacketFeedback& lhs, const PacketFeedback& rhs) {
36 if (lhs.arrival_time_ms != rhs.arrival_time_ms) 36 if (lhs.arrival_time_ms != rhs.arrival_time_ms)
37 return 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) 38 if (lhs.send_time_ms != rhs.send_time_ms)
39 return 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; 40 return lhs.sequence_number < rhs.sequence_number;
41 } 41 }
42 }; 42 };
43 43
44 TransportFeedbackAdapter::TransportFeedbackAdapter( 44 TransportFeedbackAdapter::TransportFeedbackAdapter(
45 RtcEventLog* event_log, 45 RtcEventLog* event_log,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 int transport_overhead_bytes_per_packet) { 92 int transport_overhead_bytes_per_packet) {
93 rtc::CritScope cs(&lock_); 93 rtc::CritScope cs(&lock_);
94 transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet; 94 transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet;
95 } 95 }
96 96
97 int64_t TransportFeedbackAdapter::GetProbingIntervalMs() const { 97 int64_t TransportFeedbackAdapter::GetProbingIntervalMs() const {
98 rtc::CritScope cs(&bwe_lock_); 98 rtc::CritScope cs(&bwe_lock_);
99 return delay_based_bwe_->GetProbingIntervalMs(); 99 return delay_based_bwe_->GetProbingIntervalMs();
100 } 100 }
101 101
102 std::vector<PacketInfo> TransportFeedbackAdapter::GetPacketFeedbackVector( 102 std::vector<PacketFeedback> TransportFeedbackAdapter::GetPacketFeedbackVector(
103 const rtcp::TransportFeedback& feedback) { 103 const rtcp::TransportFeedback& feedback) {
104 int64_t timestamp_us = feedback.GetBaseTimeUs(); 104 int64_t timestamp_us = feedback.GetBaseTimeUs();
105 // Add timestamp deltas to a local time base selected on first packet arrival. 105 // Add timestamp deltas to a local time base selected on first packet arrival.
106 // This won't be the true time base, but makes it easier to manually inspect 106 // This won't be the true time base, but makes it easier to manually inspect
107 // time stamps. 107 // time stamps.
108 if (last_timestamp_us_ == kNoTimestamp) { 108 if (last_timestamp_us_ == kNoTimestamp) {
109 current_offset_ms_ = clock_->TimeInMilliseconds(); 109 current_offset_ms_ = clock_->TimeInMilliseconds();
110 } else { 110 } else {
111 int64_t delta = timestamp_us - last_timestamp_us_; 111 int64_t delta = timestamp_us - last_timestamp_us_;
112 112
113 // Detect and compensate for wrap-arounds in base time. 113 // Detect and compensate for wrap-arounds in base time.
114 if (std::abs(delta - kBaseTimestampRangeSizeUs) < std::abs(delta)) { 114 if (std::abs(delta - kBaseTimestampRangeSizeUs) < std::abs(delta)) {
115 delta -= kBaseTimestampRangeSizeUs; // Wrap backwards. 115 delta -= kBaseTimestampRangeSizeUs; // Wrap backwards.
116 } else if (std::abs(delta + kBaseTimestampRangeSizeUs) < std::abs(delta)) { 116 } else if (std::abs(delta + kBaseTimestampRangeSizeUs) < std::abs(delta)) {
117 delta += kBaseTimestampRangeSizeUs; // Wrap forwards. 117 delta += kBaseTimestampRangeSizeUs; // Wrap forwards.
118 } 118 }
119 119
120 current_offset_ms_ += delta / 1000; 120 current_offset_ms_ += delta / 1000;
121 } 121 }
122 last_timestamp_us_ = timestamp_us; 122 last_timestamp_us_ = timestamp_us;
123 123
124 auto received_packets = feedback.GetReceivedPackets(); 124 auto received_packets = feedback.GetReceivedPackets();
125 std::vector<PacketInfo> packet_feedback_vector; 125 std::vector<PacketFeedback> packet_feedback_vector;
126 packet_feedback_vector.reserve(received_packets.size()); 126 packet_feedback_vector.reserve(received_packets.size());
127 if (received_packets.empty()) { 127 if (received_packets.empty()) {
128 LOG(LS_INFO) << "Empty transport feedback packet received."; 128 LOG(LS_INFO) << "Empty transport feedback packet received.";
129 return packet_feedback_vector; 129 return packet_feedback_vector;
130 } 130 }
131 { 131 {
132 rtc::CritScope cs(&lock_); 132 rtc::CritScope cs(&lock_);
133 size_t failed_lookups = 0; 133 size_t failed_lookups = 0;
134 int64_t offset_us = 0; 134 int64_t offset_us = 0;
135 int64_t timestamp_ms = 0; 135 int64_t timestamp_ms = 0;
136 for (const auto& packet : feedback.GetReceivedPackets()) { 136 for (const auto& packet : feedback.GetReceivedPackets()) {
137 offset_us += packet.delta_us(); 137 offset_us += packet.delta_us();
138 timestamp_ms = current_offset_ms_ + (offset_us / 1000); 138 timestamp_ms = current_offset_ms_ + (offset_us / 1000);
139 PacketInfo info(timestamp_ms, packet.sequence_number()); 139 PacketFeedback packet_feedback(timestamp_ms, packet.sequence_number());
140 if (!send_time_history_.GetInfo(&info, true)) 140 if (!send_time_history_.GetFeedback(&packet_feedback, true))
141 ++failed_lookups; 141 ++failed_lookups;
142 packet_feedback_vector.push_back(info); 142 packet_feedback_vector.push_back(packet_feedback);
143 } 143 }
144 std::sort(packet_feedback_vector.begin(), packet_feedback_vector.end(), 144 std::sort(packet_feedback_vector.begin(), packet_feedback_vector.end(),
145 PacketInfoComparator()); 145 PacketFeedbackComparator());
146 if (failed_lookups > 0) { 146 if (failed_lookups > 0) {
147 LOG(LS_WARNING) << "Failed to lookup send time for " << failed_lookups 147 LOG(LS_WARNING) << "Failed to lookup send time for " << failed_lookups
148 << " packet" << (failed_lookups > 1 ? "s" : "") 148 << " packet" << (failed_lookups > 1 ? "s" : "")
149 << ". Send time history too small?"; 149 << ". Send time history too small?";
150 } 150 }
151 } 151 }
152 return packet_feedback_vector; 152 return packet_feedback_vector;
153 } 153 }
154 154
155 void TransportFeedbackAdapter::OnTransportFeedback( 155 void TransportFeedbackAdapter::OnTransportFeedback(
156 const rtcp::TransportFeedback& feedback) { 156 const rtcp::TransportFeedback& feedback) {
157 last_packet_feedback_vector_ = GetPacketFeedbackVector(feedback); 157 last_packet_feedback_vector_ = GetPacketFeedbackVector(feedback);
158 DelayBasedBwe::Result result; 158 DelayBasedBwe::Result result;
159 { 159 {
160 rtc::CritScope cs(&bwe_lock_); 160 rtc::CritScope cs(&bwe_lock_);
161 result = delay_based_bwe_->IncomingPacketFeedbackVector( 161 result = delay_based_bwe_->IncomingPacketFeedbackVector(
162 last_packet_feedback_vector_); 162 last_packet_feedback_vector_);
163 } 163 }
164 if (result.updated) 164 if (result.updated)
165 bitrate_controller_->OnDelayBasedBweResult(result); 165 bitrate_controller_->OnDelayBasedBweResult(result);
166 } 166 }
167 167
168 std::vector<PacketInfo> TransportFeedbackAdapter::GetTransportFeedbackVector() 168 std::vector<PacketFeedback>
169 const { 169 TransportFeedbackAdapter::GetTransportFeedbackVector() const {
170 return last_packet_feedback_vector_; 170 return last_packet_feedback_vector_;
171 } 171 }
172 172
173 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms, 173 void TransportFeedbackAdapter::OnRttUpdate(int64_t avg_rtt_ms,
174 int64_t max_rtt_ms) { 174 int64_t max_rtt_ms) {
175 rtc::CritScope cs(&bwe_lock_); 175 rtc::CritScope cs(&bwe_lock_);
176 delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); 176 delay_based_bwe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms);
177 } 177 }
178 178
179 } // namespace webrtc 179 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698