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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 // Get the sum of all the temporal layer for a specific spatial layer. 201 // Get the sum of all the temporal layer for a specific spatial layer.
202 uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const { 202 uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const {
203 RTC_CHECK_LT(spatial_index, kMaxSpatialLayers); 203 RTC_CHECK_LT(spatial_index, kMaxSpatialLayers);
204 uint32_t sum = 0; 204 uint32_t sum = 0;
205 for (int i = 0; i < kMaxTemporalStreams; ++i) 205 for (int i = 0; i < kMaxTemporalStreams; ++i)
206 sum += bitrates_[spatial_index][i]; 206 sum += bitrates_[spatial_index][i];
207 return sum; 207 return sum;
208 } 208 }
209 209
210 std::string BitrateAllocation::ToString() const {
211 if (sum_ == 0)
212 return "BitrateAllocation [ [] ]";
213
214 // TODO(sprang): Replace this stringstream with something cheaper.
215 std::ostringstream oss;
216 oss << "BitrateAllocation [";
217 uint32_t spatial_cumulator = 0;
218 for (int si = 0; si < kMaxSpatialLayers; ++si) {
219 RTC_DCHECK_LE(spatial_cumulator, sum_);
220 if (spatial_cumulator == sum_)
221 break;
222
223 const uint32_t layer_sum = GetSpatialLayerSum(si);
224 if (layer_sum == sum_) {
225 oss << " [";
226 } else {
227 if (si > 0)
228 oss << ",";
229 oss << std::endl << " [";
230 }
231 spatial_cumulator += layer_sum;
232
233 uint32_t temporal_cumulator = 0;
234 for (int ti = 0; ti < kMaxTemporalStreams; ++ti) {
235 RTC_DCHECK_LE(temporal_cumulator, layer_sum);
236 if (temporal_cumulator == layer_sum)
237 break;
238
239 if (ti > 0)
240 oss << ", ";
241
242 uint32_t bitrate = bitrates_[si][ti];
243 oss << bitrate;
244 temporal_cumulator += bitrate;
245 }
246 oss << "]";
247 }
248
249 RTC_DCHECK_EQ(spatial_cumulator, sum_);
250 oss << " ]";
251 return oss.str();
252 }
253
254 std::ostream& BitrateAllocation::operator<<(std::ostream& os) const {
255 os << ToString();
256 return os;
257 }
258
210 } // namespace webrtc 259 } // namespace webrtc
OLDNEW
« 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