Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: webrtc/common_types.cc

Issue 2947633003: Allow parsing empty RTCP TargetBitrate messages, but stop sending them. (Closed)
Patch Set: Shotgun fix: missing initializer for unrelated member Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/common_types.cc
diff --git a/webrtc/common_types.cc b/webrtc/common_types.cc
index 5cbc452db33f82735092fd28460a56859f70e982..9af53af8df462ebff181813024da522dba4c7b80 100644
--- a/webrtc/common_types.cc
+++ b/webrtc/common_types.cc
@@ -207,4 +207,47 @@ 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();
+}
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698