| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 115     RTC_CHECK_GT(*window_size, 1) << "Need at least 2 points to fit a line."; | 115     RTC_CHECK_GT(*window_size, 1) << "Need at least 2 points to fit a line."; | 
| 116     RTC_CHECK_GT(*threshold_gain, 0) << "Threshold gain needs to be positive."; | 116     RTC_CHECK_GT(*threshold_gain, 0) << "Threshold gain needs to be positive."; | 
| 117     return true; | 117     return true; | 
| 118   } | 118   } | 
| 119   LOG(LS_WARNING) << "Failed to parse parameters for BweMedianSlopeFilter " | 119   LOG(LS_WARNING) << "Failed to parse parameters for BweMedianSlopeFilter " | 
| 120                      "experiment from field trial string. Using default."; | 120                      "experiment from field trial string. Using default."; | 
| 121   *window_size = kDefaultMedianSlopeWindowSize; | 121   *window_size = kDefaultMedianSlopeWindowSize; | 
| 122   *threshold_gain = kDefaultMedianSlopeThresholdGain; | 122   *threshold_gain = kDefaultMedianSlopeThresholdGain; | 
| 123   return false; | 123   return false; | 
| 124 } | 124 } | 
|  | 125 | 
|  | 126 class PacketFeedbackComparator { | 
|  | 127  public: | 
|  | 128   inline bool operator()(const webrtc::PacketFeedback& lhs, | 
|  | 129                          const webrtc::PacketFeedback& rhs) { | 
|  | 130     if (lhs.arrival_time_ms != rhs.arrival_time_ms) | 
|  | 131       return lhs.arrival_time_ms < rhs.arrival_time_ms; | 
|  | 132     if (lhs.send_time_ms != rhs.send_time_ms) | 
|  | 133       return lhs.send_time_ms < rhs.send_time_ms; | 
|  | 134     return lhs.sequence_number < rhs.sequence_number; | 
|  | 135   } | 
|  | 136 }; | 
|  | 137 | 
|  | 138 void SortPacketFeedbackVector(const std::vector<webrtc::PacketFeedback>& input, | 
|  | 139                               std::vector<webrtc::PacketFeedback>* output) { | 
|  | 140   auto pred = [](const webrtc::PacketFeedback& packet_feedback) { | 
|  | 141     return packet_feedback.arrival_time_ms != | 
|  | 142            webrtc::PacketFeedback::kNotReceived; | 
|  | 143   }; | 
|  | 144   std::copy_if(input.begin(), input.end(), std::back_inserter(*output), pred); | 
|  | 145   std::sort(output->begin(), output->end(), PacketFeedbackComparator()); | 
|  | 146 } | 
| 125 }  // namespace | 147 }  // namespace | 
| 126 | 148 | 
| 127 namespace webrtc { | 149 namespace webrtc { | 
| 128 | 150 | 
| 129 DelayBasedBwe::BitrateEstimator::BitrateEstimator() | 151 DelayBasedBwe::BitrateEstimator::BitrateEstimator() | 
| 130     : sum_(0), | 152     : sum_(0), | 
| 131       current_win_ms_(0), | 153       current_win_ms_(0), | 
| 132       prev_time_ms_(-1), | 154       prev_time_ms_(-1), | 
| 133       bitrate_estimate_(-1.0f), | 155       bitrate_estimate_(-1.0f), | 
| 134       bitrate_estimate_var_(50.0f), | 156       bitrate_estimate_var_(50.0f), | 
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 248   if (!in_trendline_experiment_ && !in_median_slope_experiment_) { | 270   if (!in_trendline_experiment_ && !in_median_slope_experiment_) { | 
| 249     LOG(LS_INFO) << "No overuse experiment enabled. Using Kalman filter."; | 271     LOG(LS_INFO) << "No overuse experiment enabled. Using Kalman filter."; | 
| 250   } | 272   } | 
| 251 | 273 | 
| 252   network_thread_.DetachFromThread(); | 274   network_thread_.DetachFromThread(); | 
| 253 } | 275 } | 
| 254 | 276 | 
| 255 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector( | 277 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector( | 
| 256     const std::vector<PacketFeedback>& packet_feedback_vector) { | 278     const std::vector<PacketFeedback>& packet_feedback_vector) { | 
| 257   RTC_DCHECK(network_thread_.CalledOnValidThread()); | 279   RTC_DCHECK(network_thread_.CalledOnValidThread()); | 
|  | 280 | 
|  | 281   std::vector<PacketFeedback> sorted_packet_feedback_vector; | 
|  | 282   SortPacketFeedbackVector(packet_feedback_vector, | 
|  | 283                            &sorted_packet_feedback_vector); | 
|  | 284 | 
| 258   if (!uma_recorded_) { | 285   if (!uma_recorded_) { | 
| 259     RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram, | 286     RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram, | 
| 260                               BweNames::kSendSideTransportSeqNum, | 287                               BweNames::kSendSideTransportSeqNum, | 
| 261                               BweNames::kBweNamesMax); | 288                               BweNames::kBweNamesMax); | 
| 262     uma_recorded_ = true; | 289     uma_recorded_ = true; | 
| 263   } | 290   } | 
| 264   Result aggregated_result; | 291   Result aggregated_result; | 
| 265   bool delayed_feedback = true; | 292   bool delayed_feedback = true; | 
| 266   for (const auto& packet_feedback : packet_feedback_vector) { | 293   for (const auto& packet_feedback : sorted_packet_feedback_vector) { | 
| 267     if (packet_feedback.send_time_ms < 0) | 294     if (packet_feedback.send_time_ms < 0) | 
| 268       continue; | 295       continue; | 
| 269     delayed_feedback = false; | 296     delayed_feedback = false; | 
| 270     Result result = IncomingPacketFeedback(packet_feedback); | 297     Result result = IncomingPacketFeedback(packet_feedback); | 
| 271     if (result.updated) | 298     if (result.updated) | 
| 272       aggregated_result = result; | 299       aggregated_result = result; | 
| 273   } | 300   } | 
| 274   if (delayed_feedback) { | 301   if (delayed_feedback) { | 
| 275     ++consecutive_delayed_feedbacks_; | 302     ++consecutive_delayed_feedbacks_; | 
| 276   } else { | 303   } else { | 
| 277     consecutive_delayed_feedbacks_ = 0; | 304     consecutive_delayed_feedbacks_ = 0; | 
| 278   } | 305   } | 
| 279   if (consecutive_delayed_feedbacks_ >= kMaxConsecutiveFailedLookups) { | 306   if (consecutive_delayed_feedbacks_ >= kMaxConsecutiveFailedLookups) { | 
| 280     aggregated_result = | 307     aggregated_result = OnLongFeedbackDelay( | 
| 281         OnLongFeedbackDelay(packet_feedback_vector.back().arrival_time_ms); | 308         sorted_packet_feedback_vector.back().arrival_time_ms); | 
| 282     consecutive_delayed_feedbacks_ = 0; | 309     consecutive_delayed_feedbacks_ = 0; | 
| 283   } | 310   } | 
| 284   return aggregated_result; | 311   return aggregated_result; | 
| 285 } | 312 } | 
| 286 | 313 | 
| 287 DelayBasedBwe::Result DelayBasedBwe::OnLongFeedbackDelay( | 314 DelayBasedBwe::Result DelayBasedBwe::OnLongFeedbackDelay( | 
| 288     int64_t arrival_time_ms) { | 315     int64_t arrival_time_ms) { | 
| 289   // Estimate should always be valid since a start bitrate always is set in the | 316   // Estimate should always be valid since a start bitrate always is set in the | 
| 290   // Call constructor. An alternative would be to return an empty Result here, | 317   // Call constructor. An alternative would be to return an empty Result here, | 
| 291   // or to estimate the throughput based on the feedback we received. | 318   // or to estimate the throughput based on the feedback we received. | 
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 450 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { | 477 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { | 
| 451   // Called from both the configuration thread and the network thread. Shouldn't | 478   // Called from both the configuration thread and the network thread. Shouldn't | 
| 452   // be called from the network thread in the future. | 479   // be called from the network thread in the future. | 
| 453   rate_control_.SetMinBitrate(min_bitrate_bps); | 480   rate_control_.SetMinBitrate(min_bitrate_bps); | 
| 454 } | 481 } | 
| 455 | 482 | 
| 456 int64_t DelayBasedBwe::GetProbingIntervalMs() const { | 483 int64_t DelayBasedBwe::GetProbingIntervalMs() const { | 
| 457   return probing_interval_estimator_.GetIntervalMs(); | 484   return probing_interval_estimator_.GetIntervalMs(); | 
| 458 } | 485 } | 
| 459 }  // namespace webrtc | 486 }  // namespace webrtc | 
| OLD | NEW | 
|---|