| Index: webrtc/common_types.cc
|
| diff --git a/webrtc/common_types.cc b/webrtc/common_types.cc
|
| index 5cbc452db33f82735092fd28460a56859f70e982..b6955cfbc3fb9f94eb9f54125e0bd48472bca445 100644
|
| --- a/webrtc/common_types.cc
|
| +++ b/webrtc/common_types.cc
|
| @@ -207,4 +207,53 @@ uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const {
|
| return sum;
|
| }
|
|
|
| +std::string BitrateAllocation::ToString() const {
|
| + if (sum_ == 0)
|
| + return "BitrateAllocation [ [] ]";
|
| +
|
| + // TODO(sprang): Replace this stringstream with something cheaper.
|
| + std::ostringstream oss;
|
| + oss << "BitrateAllocation [";
|
| + uint32_t spatial_cumulator = 0;
|
| + for (int si = 0; si < kMaxSpatialLayers; ++si) {
|
| + RTC_DCHECK_LE(spatial_cumulator, sum_);
|
| + if (spatial_cumulator == sum_)
|
| + break;
|
| +
|
| + const uint32_t layer_sum = GetSpatialLayerSum(si);
|
| + if (layer_sum == sum_) {
|
| + oss << " [";
|
| + } else {
|
| + if (si > 0)
|
| + oss << ",";
|
| + oss << std::endl << " [";
|
| + }
|
| + spatial_cumulator += layer_sum;
|
| +
|
| + uint32_t temporal_cumulator = 0;
|
| + for (int ti = 0; ti < kMaxTemporalStreams; ++ti) {
|
| + RTC_DCHECK_LE(temporal_cumulator, layer_sum);
|
| + if (temporal_cumulator == layer_sum)
|
| + break;
|
| +
|
| + if (ti > 0)
|
| + oss << ", ";
|
| +
|
| + uint32_t bitrate = bitrates_[si][ti];
|
| + oss << bitrate;
|
| + temporal_cumulator += bitrate;
|
| + }
|
| + oss << "]";
|
| + }
|
| +
|
| + RTC_DCHECK_EQ(spatial_cumulator, sum_);
|
| + oss << " ]";
|
| + return oss.str();
|
| +}
|
| +
|
| +std::ostream& BitrateAllocation::operator<<(std::ostream& os) const {
|
| + os << ToString();
|
| + return os;
|
| +}
|
| +
|
| } // namespace webrtc
|
|
|