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

Unified Diff: webrtc/modules/congestion_controller/delay_based_bwe.cc

Issue 2235373004: Probing: Add support for exponential startup probing (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@fix_probing2
Patch Set: Updates Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/congestion_controller/delay_based_bwe.cc
diff --git a/webrtc/modules/congestion_controller/delay_based_bwe.cc b/webrtc/modules/congestion_controller/delay_based_bwe.cc
index a7d2788ff862d56ad874ee4b4c77e162f0bd565f..bf40ab3fe959d81c8b5352bed705b223e1b60b31 100644
--- a/webrtc/modules/congestion_controller/delay_based_bwe.cc
+++ b/webrtc/modules/congestion_controller/delay_based_bwe.cc
@@ -18,6 +18,7 @@
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/thread_annotations.h"
+#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
#include "webrtc/modules/pacing/paced_sender.h"
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
@@ -40,18 +41,17 @@ constexpr uint32_t kFixedSsrc = 0;
namespace webrtc {
-DelayBasedBwe::DelayBasedBwe(RemoteBitrateObserver* observer, Clock* clock)
+DelayBasedBwe::DelayBasedBwe(CongestionController* controller, Clock* clock)
: clock_(clock),
- observer_(observer),
+ controller_(controller),
inter_arrival_(),
estimator_(),
detector_(OverUseDetectorOptions()),
incoming_bitrate_(kBitrateWindowMs, 8000),
- first_packet_time_ms_(-1),
last_update_ms_(-1),
last_seen_packet_ms_(-1),
uma_recorded_(false) {
- RTC_DCHECK(observer_);
+ RTC_DCHECK(controller_);
network_thread_.DetachFromThread();
}
@@ -72,12 +72,9 @@ void DelayBasedBwe::IncomingPacketFeedbackVector(
void DelayBasedBwe::IncomingPacketInfo(const PacketInfo& info) {
int64_t now_ms = clock_->TimeInMilliseconds();
- if (first_packet_time_ms_ == -1)
- first_packet_time_ms_ = now_ms;
-
incoming_bitrate_.Update(info.payload_size, info.arrival_time_ms);
- bool update_estimate = false;
- uint32_t target_bitrate_bps = 0;
+ bool delay_based_bwe_changed = false;
+ int target_bitrate_bps = 0;
{
rtc::CritScope lock(&crit_);
@@ -91,15 +88,6 @@ void DelayBasedBwe::IncomingPacketInfo(const PacketInfo& info) {
}
last_seen_packet_ms_ = now_ms;
- if (info.probe_cluster_id != PacketInfo::kNotAProbe) {
- ProbingResult probe_result =
- probe_bitrate_estimator_.PacketFeedback(info);
- if (probe_result.valid()) {
- remote_rate_.SetEstimate(probe_result.bps, probe_result.timestamp);
- update_estimate = true;
- }
- }
-
uint32_t send_time_24bits =
static_cast<uint32_t>(((static_cast<uint64_t>(info.send_time_ms)
<< kAbsSendTimeFraction) +
@@ -122,41 +110,70 @@ void DelayBasedBwe::IncomingPacketInfo(const PacketInfo& info) {
estimator_->num_of_deltas(), info.arrival_time_ms);
}
- if (!update_estimate) {
- // Check if it's time for a periodic update or if we should update because
- // of an over-use.
- if (last_update_ms_ == -1 ||
- now_ms - last_update_ms_ > remote_rate_.GetFeedbackInterval()) {
- update_estimate = true;
- } else if (detector_.State() == kBwOverusing) {
- rtc::Optional<uint32_t> incoming_rate =
- incoming_bitrate_.Rate(info.arrival_time_ms);
- if (incoming_rate &&
- remote_rate_.TimeToReduceFurther(now_ms, *incoming_rate)) {
- update_estimate = true;
- }
+ int probing_bps = 0;
+ if (info.probe_cluster_id != PacketInfo::kNotAProbe &&
+ controller_->SenderState() ==
+ PacedSender::State::kWaitForProbingResult) {
+ // Without a valid estimate, we wait for two clusters and then later on
+ // wait on a single cluster to update probing bitrate.
+ if (!remote_rate_.ValidEstimate()) {
+ probing_bps =
+ probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(info, 2);
philipel 2016/08/16 14:44:43 Seems like probe_bitrate_estimator.h/.cc haven't b
Irfan 2016/08/16 16:04:17 https://codereview.chromium.org/2239143002/ is the
+ } else {
+ probing_bps =
+ probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(info, 1);
}
}
- if (update_estimate) {
- // The first overuse should immediately trigger a new estimate.
- // We also have to update the estimate immediately if we are overusing
- // and the target bitrate is too high compared to what we are receiving.
- const RateControlInput input(detector_.State(),
- incoming_bitrate_.Rate(info.arrival_time_ms),
- estimator_->var_noise());
- remote_rate_.Update(&input, now_ms);
- target_bitrate_bps = remote_rate_.UpdateBandwidthEstimate(now_ms);
- update_estimate = remote_rate_.ValidEstimate();
+ // Overuse
stefan-webrtc 2016/08/16 11:27:04 End the comments with "."
Irfan 2016/08/16 18:12:47 Will make these full sentence comments and add ful
+ if (detector_.State() == kBwOverusing) {
+ rtc::Optional<uint32_t> incoming_rate =
+ incoming_bitrate_.Rate(info.arrival_time_ms);
+ if (incoming_rate &&
+ remote_rate_.TimeToReduceFurther(now_ms, *incoming_rate)) {
+ delay_based_bwe_changed =
+ UpdateEstimate(info.arrival_time_ms, now_ms, &target_bitrate_bps);
+ }
+ // Probe results with overuse
+ if (probing_bps) {
+ // Stop probing
+ controller_->OnProbingBitrateMeasured(0);
stefan-webrtc 2016/08/16 11:27:04 This looks a bit hacky. It's not really that we me
Irfan 2016/08/16 18:12:47 Will make it a well-defined name instead. Works fo
+ }
+ // No overuse, but probing measured a bitrate
+ } else if (probing_bps > 0) {
+ controller_->OnProbingBitrateMeasured(probing_bps);
+ remote_rate_.SetEstimate(probing_bps, info.arrival_time_ms);
+ target_bitrate_bps = probing_bps;
+ delay_based_bwe_changed = true;
+ // Been a while since we updated
stefan-webrtc 2016/08/16 11:27:04 Move this inside the else if below instead to make
Irfan 2016/08/16 18:12:47 Done.
+ } else if (last_update_ms_ == -1 ||
+ now_ms - last_update_ms_ > remote_rate_.GetFeedbackInterval()) {
+ delay_based_bwe_changed =
+ UpdateEstimate(info.arrival_time_ms, now_ms, &target_bitrate_bps);
}
}
- if (update_estimate) {
+ if (delay_based_bwe_changed) {
last_update_ms_ = now_ms;
- observer_->OnReceiveBitrateChanged({kFixedSsrc}, target_bitrate_bps);
+ controller_->OnDelayBasedBweChanged(target_bitrate_bps);
}
}
+bool DelayBasedBwe::UpdateEstimate(int64_t arrival_time_ms,
+ int64_t now_ms,
+ int* target_bitrate_bps) {
+ rtc::CritScope lock(&crit_);
+ // The first overuse should immediately trigger a new estimate.
+ // We also have to update the estimate immediately if we are overusing
+ // and the target bitrate is too high compared to what we are receiving.
+ const RateControlInput input(detector_.State(),
+ incoming_bitrate_.Rate(arrival_time_ms),
+ estimator_->var_noise());
+ remote_rate_.Update(&input, now_ms);
+ *target_bitrate_bps = remote_rate_.UpdateBandwidthEstimate(now_ms);
+ return remote_rate_.ValidEstimate();
+}
+
void DelayBasedBwe::Process() {}
int64_t DelayBasedBwe::TimeUntilNextProcess() {

Powered by Google App Engine
This is Rietveld 408576698