mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-15 06:40:43 +01:00

Negative infinity is useful in comparisons as it represents a value guaranteed to be less than any other timestamp. This avoid using Timestamp::ms(0) to represent such a value or having to use optional for the special case of first time execution. To avoid ambiguity, Timestamp::Infinity is renamed to PlusInfinity. Bug: webrtc:9709 Change-Id: Ib2debff91036e94d1dc903ec0c6faae30febde4e Reviewed-on: https://webrtc-review.googlesource.com/79440 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24556}
50 lines
1.7 KiB
C++
50 lines
1.7 KiB
C++
/*
|
|
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
#ifndef MODULES_CONGESTION_CONTROLLER_BBR_DATA_TRANSFER_TRACKER_H_
|
|
#define MODULES_CONGESTION_CONTROLLER_BBR_DATA_TRANSFER_TRACKER_H_
|
|
|
|
#include <deque>
|
|
|
|
#include "api/units/data_size.h"
|
|
#include "api/units/time_delta.h"
|
|
#include "api/units/timestamp.h"
|
|
|
|
namespace webrtc {
|
|
namespace bbr {
|
|
class DataTransferTracker {
|
|
public:
|
|
struct Result {
|
|
TimeDelta ack_timespan = TimeDelta::Zero();
|
|
TimeDelta send_timespan = TimeDelta::Zero();
|
|
DataSize acked_data = DataSize::Zero();
|
|
};
|
|
DataTransferTracker();
|
|
~DataTransferTracker();
|
|
void AddSample(DataSize size_delta, Timestamp send_time, Timestamp ack_time);
|
|
void ClearOldSamples(Timestamp excluding_end);
|
|
|
|
// Get the average data rate in the window that starts with the last ack which
|
|
// comes before covered_start and ends at the first ack that comes after or at
|
|
// including_end.
|
|
Result GetRatesByAckTime(Timestamp covered_start, Timestamp including_end);
|
|
|
|
private:
|
|
struct Sample {
|
|
Timestamp ack_time = Timestamp::PlusInfinity();
|
|
Timestamp send_time = Timestamp::PlusInfinity();
|
|
DataSize size_delta = DataSize::Zero();
|
|
DataSize size_sum = DataSize::Zero();
|
|
};
|
|
std::deque<Sample> samples_;
|
|
DataSize size_sum_ = DataSize::Zero();
|
|
};
|
|
} // namespace bbr
|
|
} // namespace webrtc
|
|
#endif // MODULES_CONGESTION_CONTROLLER_BBR_DATA_TRANSFER_TRACKER_H_
|