Revert "Delete legacy DataSize and DataRate factories"

This reverts commit 70490aa3a0b08c9342ea9a12d5ac1fa9666fb7fb.

Reason for revert: Breaks downstream project.

Original change's description:
> Delete legacy DataSize and DataRate factories
> 
> Bug: webrtc:9709
> Change-Id: Ia9464893ec9868c51d72eedaee8efc82b0c17b28
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168722
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#30564}

TBR=danilchap@webrtc.org,srte@webrtc.org

Change-Id: I3f5a8b4ec473bd2af80ca3acfe0e9c82f25a12ba
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9709
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168940
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30574}
This commit is contained in:
Mirko Bonadei
2020-02-20 14:42:17 +00:00
committed by Commit Bot
parent 4805a480fe
commit 74c5b0ac23
3 changed files with 39 additions and 3 deletions

View File

@ -49,7 +49,31 @@ class DataRate final : public rtc_units_impl::RelativeUnit<DataRate> {
static constexpr DataRate Infinity() { return PlusInfinity(); } static constexpr DataRate Infinity() { return PlusInfinity(); }
DataRate() = delete; DataRate() = delete;
// TODO(danilchap): Migrate all code to the 3 factories above and delete the
// 5 factories below.
template <int64_t bps>
static constexpr DataRate BitsPerSec() {
return FromValue(bps);
}
template <int64_t kbps>
static constexpr DataRate KilobitsPerSec() {
return FromFraction(1000, kbps);
}
template <typename T>
static constexpr DataRate bps(T bits_per_second) {
static_assert(std::is_arithmetic<T>::value, "");
return FromValue(bits_per_second);
}
template <typename T>
static constexpr DataRate bytes_per_sec(T bytes_per_second) {
static_assert(std::is_arithmetic<T>::value, "");
return FromFraction(8, bytes_per_second);
}
template <typename T>
static constexpr DataRate kbps(T kilobits_per_sec) {
static_assert(std::is_arithmetic<T>::value, "");
return FromFraction(1000, kilobits_per_sec);
}
template <typename T = int64_t> template <typename T = int64_t>
constexpr T bps() const { constexpr T bps() const {
return ToValue<T>(); return ToValue<T>();

View File

@ -32,7 +32,18 @@ class DataSize final : public rtc_units_impl::RelativeUnit<DataSize> {
static constexpr DataSize Infinity() { return PlusInfinity(); } static constexpr DataSize Infinity() { return PlusInfinity(); }
DataSize() = delete; DataSize() = delete;
// TODO(danilchap): Migrate all code to the factory above and delete the
// 2 factories below.
template <int64_t bytes>
static constexpr DataSize Bytes() {
return FromValue(bytes);
}
template <typename T>
static constexpr DataSize bytes(T bytes) {
static_assert(std::is_arithmetic<T>::value, "");
return FromValue(bytes);
}
template <typename T = int64_t> template <typename T = int64_t>
constexpr T bytes() const { constexpr T bytes() const {
return ToValue<T>(); return ToValue<T>();

View File

@ -32,8 +32,9 @@ constexpr int64_t kMinPacketsNumberPerInterval = 20;
const TimeDelta kMinDurationOfMonitorInterval = TimeDelta::Millis(50); const TimeDelta kMinDurationOfMonitorInterval = TimeDelta::Millis(50);
const TimeDelta kStartupDuration = TimeDelta::Millis(500); const TimeDelta kStartupDuration = TimeDelta::Millis(500);
constexpr double kMinRateChangeBps = 4000; constexpr double kMinRateChangeBps = 4000;
constexpr DataRate kMinRateHaveMultiplicativeRateChange = DataRate::BitsPerSec( constexpr DataRate kMinRateHaveMultiplicativeRateChange =
static_cast<int64_t>(kMinRateChangeBps / kDefaultSamplingStep)); DataRate::BitsPerSec<static_cast<int64_t>(kMinRateChangeBps /
kDefaultSamplingStep)>();
// Bitrate controller constants. // Bitrate controller constants.
constexpr double kInitialConversionFactor = 5; constexpr double kInitialConversionFactor = 5;