7 #include "packager/mpd/base/bandwidth_estimator.h" 12 #include "packager/base/logging.h" 16 BandwidthEstimator::BandwidthEstimator() =
default;
17 BandwidthEstimator::~BandwidthEstimator() =
default;
20 if (size_in_bytes == 0 || duration == 0) {
21 LOG(WARNING) <<
"Ignore block with size=" << size_in_bytes
22 <<
", duration=" << duration;
26 const int kBitsInByte = 8;
27 const uint64_t size_in_bits = size_in_bytes * kBitsInByte;
28 total_size_in_bits_ += size_in_bits;
30 total_duration_ += duration;
32 const uint64_t bitrate =
static_cast<uint64_t
>(ceil(size_in_bits / duration));
33 max_bitrate_ = std::max(bitrate, max_bitrate_);
37 if (total_duration_ == 0)
39 return static_cast<uint64_t
>(ceil(total_size_in_bits_ / total_duration_));
All the methods that are virtual are virtual for mocking.
void AddBlock(uint64_t size_in_bytes, double duration)
uint64_t Estimate() const