| Index: webrtc/common_types.cc
|
| diff --git a/webrtc/common_types.cc b/webrtc/common_types.cc
|
| index 8f117e11530b027fd80aea33354804ec8676e326..d543552bfc59557c0fe3e520b72f0b1e0db2f7e2 100644
|
| --- a/webrtc/common_types.cc
|
| +++ b/webrtc/common_types.cc
|
| @@ -10,6 +10,8 @@
|
|
|
| #include "webrtc/common_types.h"
|
|
|
| +#include "webrtc/base/checks.h"
|
| +
|
| #include <string.h>
|
|
|
| namespace webrtc {
|
| @@ -42,4 +44,38 @@ RTPHeader::RTPHeader()
|
| payload_type_frequency(0),
|
| extension() {}
|
|
|
| +BitrateAllocation::BitrateAllocation() : sum_(0), bitrates_{} {}
|
| +
|
| +bool BitrateAllocation::SetBitrate(size_t spatial_index,
|
| + size_t temporal_index,
|
| + uint32_t bitrate_bps) {
|
| + RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers));
|
| + RTC_DCHECK_LT(temporal_index, static_cast<size_t>(kMaxTemporalStreams));
|
| + if (bitrate_bps > kMaxBitrateBps ||
|
| + sum_ - bitrates_[spatial_index][temporal_index] + bitrate_bps >
|
| + kMaxBitrateBps) {
|
| + return false;
|
| + }
|
| + sum_ -= bitrates_[spatial_index][temporal_index];
|
| + bitrates_[spatial_index][temporal_index] = bitrate_bps;
|
| + sum_ += bitrate_bps;
|
| + return true;
|
| +}
|
| +
|
| +uint32_t BitrateAllocation::GetBitrate(size_t spatial_index,
|
| + size_t temporal_index) const {
|
| + RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers));
|
| + RTC_DCHECK_LT(temporal_index, static_cast<size_t>(kMaxTemporalStreams));
|
| + return bitrates_[spatial_index][temporal_index];
|
| +}
|
| +
|
| +// Get the sum of all the temporal layer for a specific spatial layer.
|
| +uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const {
|
| + RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers));
|
| + uint32_t sum = 0;
|
| + for (int i = 0; i < kMaxTemporalStreams; ++i)
|
| + sum += bitrates_[spatial_index][i];
|
| + return sum;
|
| +}
|
| +
|
| } // namespace webrtc
|
|
|