Reland "Refactors BitrateProber with unit types and absolute probe time."

This is a reland of 739a5b3692880cb6b41ae620fb9e755c39b044b1

Patchset 1 is the original CL, patchset 3 includes a fix

Original change's description:
> Refactors BitrateProber with unit types and absolute probe time.
>
> Using unit types improves readability and some conversion in PacedSender
> can be removed.
>
> TimeUntilNextProbe() is replaced by NextProbeTime(), so returning an
> absolute time rather than a delta. This fits better with the upcoming
> TaskQueue based pacer, and is also what is already stored internally
> in BitrateProber.
>
> Bug: webrtc:10809
> Change-Id: I5a4e289d2b53e99d3c0a2f4b36a966dba759d5cf
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158743
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#29670}

Bug: webrtc:10809
Change-Id: I033193c78474fdd82c109fdab0a8f09a05f7b30e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158841
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29688}
This commit is contained in:
Erik Språng
2019-11-05 11:21:48 +01:00
committed by Commit Bot
parent 1983458981
commit b210eeb812
8 changed files with 210 additions and 126 deletions

View File

@ -123,7 +123,7 @@ PacingController::PacingController(Clock* clock,
PacingController::~PacingController() = default;
void PacingController::CreateProbeCluster(DataRate bitrate, int cluster_id) {
prober_.CreateProbeCluster(bitrate.bps(), CurrentTime().ms(), cluster_id);
prober_.CreateProbeCluster(bitrate, CurrentTime(), cluster_id);
}
void PacingController::Pause() {
@ -233,10 +233,10 @@ TimeDelta PacingController::OldestPacketWaitTime() const {
void PacingController::EnqueuePacketInternal(
std::unique_ptr<RtpPacketToSend> packet,
int priority) {
Timestamp now = CurrentTime();
prober_.OnIncomingPacket(packet->payload_size());
// TODO(sprang): Make sure tests respect this, replace with DCHECK.
Timestamp now = CurrentTime();
if (packet->capture_time_ms() < 0) {
packet->set_capture_time_ms(now.ms());
}
@ -272,19 +272,26 @@ bool PacingController::ShouldSendKeepalive(Timestamp now) const {
return false;
}
absl::optional<TimeDelta> PacingController::TimeUntilNextProbe() {
Timestamp PacingController::NextProbeTime() {
if (!prober_.IsProbing()) {
return absl::nullopt;
return Timestamp::PlusInfinity();
}
TimeDelta time_delta =
TimeDelta::ms(prober_.TimeUntilNextProbe(CurrentTime().ms()));
if (time_delta > TimeDelta::Zero() ||
(time_delta == TimeDelta::Zero() && !probing_send_failure_)) {
return time_delta;
Timestamp now = CurrentTime();
Timestamp probe_time = prober_.NextProbeTime(now);
if (probe_time.IsInfinite()) {
return probe_time;
}
return absl::nullopt;
if (probe_time > now) {
return probe_time;
}
if (probing_send_failure_ || now - probe_time > TimeDelta::ms(1)) {
return Timestamp::PlusInfinity();
}
return probe_time;
}
TimeDelta PacingController::TimeElapsedSinceLastProcess() const {
@ -400,7 +407,7 @@ void PacingController::ProcessPackets() {
if (is_probing) {
probing_send_failure_ = data_sent == DataSize::Zero();
if (!probing_send_failure_) {
prober_.ProbeSent(CurrentTime().ms(), data_sent.bytes());
prober_.ProbeSent(CurrentTime(), data_sent.bytes());
}
}
}