Adds arithmetic support to DataRate.

Bug: webrtc:9709
Change-Id: Id3fde2b7bbc63c6372cadc76b92c4568665b17f9
Reviewed-on: https://webrtc-review.googlesource.com/97702
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24562}
This commit is contained in:
Sebastian Jansson
2018-09-04 18:34:45 +02:00
committed by Commit Bot
parent 96816753d9
commit af21eab531
3 changed files with 26 additions and 3 deletions

View File

@ -133,7 +133,20 @@ class DataRate {
return bits_per_sec_ == data_rate_impl::kPlusInfinityVal;
}
constexpr bool IsFinite() const { return !IsInfinite(); }
DataRate operator-(const DataRate& other) const {
return DataRate::bps(bps() - other.bps());
}
DataRate operator+(const DataRate& other) const {
return DataRate::bps(bps() + other.bps());
}
DataRate& operator-=(const DataRate& other) {
*this = *this - other;
return *this;
}
DataRate& operator+=(const DataRate& other) {
*this = *this + other;
return *this;
}
constexpr double operator/(const DataRate& other) const {
return bps<double>() / other.bps<double>();
}