Chromium Code Reviews| Index: webrtc/common_types.h |
| diff --git a/webrtc/common_types.h b/webrtc/common_types.h |
| index b1842ef59598e78e86f99f71d495661b0d1a9483..eeceaa3a73dec55e772e52fb68e2f0c8b17be5fe 100644 |
| --- a/webrtc/common_types.h |
| +++ b/webrtc/common_types.h |
| @@ -622,6 +622,56 @@ struct VideoCodec { |
| bool operator!=(const VideoCodec& other) const = delete; |
| }; |
| +struct BitrateAllocation { |
|
perkj_webrtc
2016/10/21 08:24:28
please use class.
sprang_webrtc
2016/10/25 10:44:25
Agreed. This started out as a simple struct (that'
|
| + static const size_t kMaxBitrateBps = 100000000; |
| + BitrateAllocation() = default; |
| + |
| + bool set_bitrate(size_t spatial_index, |
| + size_t temporal_index, |
| + uint32_t bitrate_bps) { |
| + assert(spatial_index < kMaxSpatialLayers); |
|
perkj_webrtc
2016/10/21 08:24:28
CHECK or DCHECK instead of assert.
sprang_webrtc
2016/10/25 10:44:25
For some reason, everything here used assert and c
|
| + assert(temporal_index < kMaxTemporalStreams); |
| + if (bitrate_bps > kMaxBitrateBps || |
| + sum - bitrates[spatial_index][temporal_index] + bitrate_bps > |
| + kMaxBitrateBps) { |
| + return false; |
| + } |
| + sum -= bitrates[spatial_index][temporal_index]; |
|
perkj_webrtc
2016/10/21 08:24:28
please move implementation to a cc file.
sprang_webrtc
2016/10/25 10:44:25
Done.
|
| + bitrates[spatial_index][temporal_index] = bitrate_bps; |
| + sum += bitrate_bps; |
| + return true; |
| + } |
| + |
| + uint32_t get_bitrate(size_t spatial_index, size_t temporal_index) const { |
| + assert(spatial_index < kMaxSpatialLayers); |
|
perkj_webrtc
2016/10/21 08:24:28
dito
sprang_webrtc
2016/10/25 10:44:25
Done.
|
| + assert(temporal_index < kMaxSimulcastStreams); |
| + return bitrates[spatial_index][temporal_index]; |
| + } |
| + |
| + // Get the sum of all the temporal layer for a specific spatial layer. |
| + uint32_t get_spatial_layer_sum(size_t spatial_index) const { |
| + assert(spatial_index < kMaxSpatialLayers); |
| + uint32_t sum = 0; |
| + for (int i = 0; i < kMaxTemporalStreams; ++i) |
| + sum += bitrates[spatial_index][i]; |
| + return sum; |
| + } |
| + |
| + uint32_t get_sum_bps() const { return sum; } // Sum of all bitrates. |
| + uint32_t get_sum_kbps() const { return (sum + 500) / 1000; } |
| + |
| + inline bool operator==(const BitrateAllocation& other) const { |
| + return memcmp(bitrates, other.bitrates, sizeof(bitrates)) == 0; |
| + } |
| + inline bool operator!=(const BitrateAllocation& other) const { |
| + return !(*this == other); |
| + } |
| + |
| + private: |
| + uint32_t sum = 0; |
|
perkj_webrtc
2016/10/21 08:24:28
sum_
sprang_webrtc
2016/10/25 10:44:25
Done.
|
| + uint32_t bitrates[kMaxSpatialLayers][kMaxTemporalStreams] = {}; |
|
perkj_webrtc
2016/10/21 08:24:28
bitrates_
sprang_webrtc
2016/10/25 10:44:25
Done.
|
| +}; |
| + |
| // Bandwidth over-use detector options. These are used to drive |
| // experimentation with bandwidth estimation parameters. |
| // See modules/remote_bitrate_estimator/overuse_detector.h |