Shaka Packager SDK
bandwidth_estimator.h
1 // Copyright 2014 Google LLC. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MPD_BASE_BANDWIDTH_ESTIMATOR_H_
8 #define MPD_BASE_BANDWIDTH_ESTIMATOR_H_
9 
10 #include <cstdint>
11 #include <vector>
12 
13 namespace shaka {
14 
16  public:
19 
22  void AddBlock(uint64_t size_in_bytes, double duration);
23 
28  uint64_t Estimate() const;
29 
34  uint64_t Max() const;
35 
36  private:
37  BandwidthEstimator(const BandwidthEstimator&) = delete;
38  BandwidthEstimator& operator=(const BandwidthEstimator&) = delete;
39 
40  struct Block {
41  uint64_t size_in_bits;
42  double duration;
43  };
44  // Return the average block duration of the blocks in |initial_blocks_|.
45  double GetAverageBlockDuration() const;
46  // Return the bitrate of the block. Note that a bitrate of 0 is returned if
47  // the block duration is less than 50% of target block duration.
48  uint64_t GetBitrate(const Block& block, double target_block_duration) const;
49 
50  std::vector<Block> initial_blocks_;
51  // Target block duration will be estimated from the average duration of the
52  // initial blocks.
53  double target_block_duration_ = 0;
54 
55  uint64_t total_size_in_bits_ = 0;
56  double total_duration_ = 0;
57  uint64_t max_bitrate_ = 0;
58 };
59 
60 } // namespace shaka
61 
62 #endif // MPD_BASE_BANDWIDTH_ESTIMATOR_H_
void AddBlock(uint64_t size_in_bytes, double duration)
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66