Adds scalar division to DataRate.
Bug: webrtc:9709 Change-Id: I73eac1d2f27bd0f30a7b1ca075009a6aece08b03 Reviewed-on: https://webrtc-review.googlesource.com/c/110786 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25680}
This commit is contained in:
committed by
Commit Bot
parent
8ef57932b1
commit
b5f82011ba
@ -206,6 +206,13 @@ inline DataRate operator*(const int32_t& scalar, const DataRate& rate) {
|
||||
return rate * scalar;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, DataRate>::type operator/(
|
||||
const DataRate& rate,
|
||||
const T& scalar) {
|
||||
return DataRate::bps(rate.bps<double>() / scalar);
|
||||
}
|
||||
|
||||
inline DataRate operator/(const DataSize& size, const TimeDelta& duration) {
|
||||
return DataRate::bps(data_rate_impl::Microbits(size) / duration.us());
|
||||
}
|
||||
|
||||
@ -130,6 +130,9 @@ TEST(DataRateTest, MathOperations) {
|
||||
|
||||
EXPECT_EQ(rate_a / rate_b, static_cast<double>(kValueA) / kValueB);
|
||||
|
||||
EXPECT_EQ((rate_a / 10).bps(), kValueA / 10);
|
||||
EXPECT_NEAR((rate_a / 0.5).bps(), kValueA * 2, 1);
|
||||
|
||||
DataRate mutable_rate = DataRate::bps(kValueA);
|
||||
mutable_rate += rate_b;
|
||||
EXPECT_EQ(mutable_rate.bps(), kValueA + kValueB);
|
||||
|
||||
Reference in New Issue
Block a user