Add a new function to BitrateAllocation: HasBitrate.
This can be used to determine whether the bitrate of a given spatial and temporal layer has been set in the allocation, even if the value it's set to is zero. GetBitrate still returns 0 if the queried layer does not have the bitrate set. Bug: webrtc:8479 Change-Id: I1d982e211da9b052fcccdbf588b67da1a4550c60 Reviewed-on: https://webrtc-review.googlesource.com/17440 Reviewed-by: Stefan Holmer <stefan@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Varga <erikvarga@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20852}
This commit is contained in:

committed by
Commit Bot

parent
d7e251378b
commit
01f2ec35a6
@ -181,7 +181,7 @@ VideoCodecType PayloadStringToCodecType(const std::string& name) {
|
||||
const uint32_t BitrateAllocation::kMaxBitrateBps =
|
||||
std::numeric_limits<uint32_t>::max();
|
||||
|
||||
BitrateAllocation::BitrateAllocation() : sum_(0), bitrates_{} {}
|
||||
BitrateAllocation::BitrateAllocation() : sum_(0), bitrates_{}, has_bitrate_{} {}
|
||||
|
||||
bool BitrateAllocation::SetBitrate(size_t spatial_index,
|
||||
size_t temporal_index,
|
||||
@ -196,10 +196,18 @@ bool BitrateAllocation::SetBitrate(size_t spatial_index,
|
||||
return false;
|
||||
|
||||
bitrates_[spatial_index][temporal_index] = bitrate_bps;
|
||||
has_bitrate_[spatial_index][temporal_index] = true;
|
||||
sum_ = static_cast<uint32_t>(new_bitrate_sum_bps);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BitrateAllocation::HasBitrate(size_t spatial_index,
|
||||
size_t temporal_index) const {
|
||||
RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
|
||||
RTC_CHECK_LT(temporal_index, kMaxTemporalStreams);
|
||||
return has_bitrate_[spatial_index][temporal_index];
|
||||
}
|
||||
|
||||
uint32_t BitrateAllocation::GetBitrate(size_t spatial_index,
|
||||
size_t temporal_index) const {
|
||||
RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
|
||||
@ -207,6 +215,17 @@ uint32_t BitrateAllocation::GetBitrate(size_t spatial_index,
|
||||
return bitrates_[spatial_index][temporal_index];
|
||||
}
|
||||
|
||||
// Whether the specific spatial layers has the bitrate set in any of its
|
||||
// temporal layers.
|
||||
bool BitrateAllocation::IsSpatialLayerUsed(size_t spatial_index) const {
|
||||
RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
|
||||
for (int i = 0; i < kMaxTemporalStreams; ++i) {
|
||||
if (has_bitrate_[spatial_index][i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the sum of all the temporal layer for a specific spatial layer.
|
||||
uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const {
|
||||
RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
|
||||
|
Reference in New Issue
Block a user