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

Unified Diff: webrtc/common_types.cc

Issue 2947633003: Allow parsing empty RTCP TargetBitrate messages, but stop sending them. (Closed)
Patch Set: Add comment about using ToString only in tests 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
« no previous file with comments | « webrtc/common_types.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « webrtc/common_types.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698