Index: webrtc/common_types.cc |
diff --git a/webrtc/common_types.cc b/webrtc/common_types.cc |
index 5cbc452db33f82735092fd28460a56859f70e982..f495142d29a996de15f502979a20c87e052c76f2 100644 |
--- a/webrtc/common_types.cc |
+++ b/webrtc/common_types.cc |
@@ -207,4 +207,52 @@ uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const { |
return sum; |
} |
+std::string BitrateAllocation::ToString() const { |
+ if (sum_ == 0) |
+ return "BitrateAllocation [ [] ]"; |
+ |
+ 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& operator<<(std::ostream& os, const BitrateAllocation& bitrate) { |
+ os << bitrate.ToString(); |
+ return os; |
+} |
+ |
} // namespace webrtc |