OLD | NEW |
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 Loading... |
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 std::ostringstream oss; |
| 215 oss << "BitrateAllocation ["; |
| 216 uint32_t spatial_cumulator = 0; |
| 217 for (int si = 0; si < kMaxSpatialLayers; ++si) { |
| 218 RTC_DCHECK_LE(spatial_cumulator, sum_); |
| 219 if (spatial_cumulator == sum_) |
| 220 break; |
| 221 |
| 222 const uint32_t layer_sum = GetSpatialLayerSum(si); |
| 223 if (layer_sum == sum_) { |
| 224 oss << " ["; |
| 225 } else { |
| 226 if (si > 0) |
| 227 oss << ","; |
| 228 oss << std::endl << " ["; |
| 229 } |
| 230 spatial_cumulator += layer_sum; |
| 231 |
| 232 uint32_t temporal_cumulator = 0; |
| 233 for (int ti = 0; ti < kMaxTemporalStreams; ++ti) { |
| 234 RTC_DCHECK_LE(temporal_cumulator, layer_sum); |
| 235 if (temporal_cumulator == layer_sum) |
| 236 break; |
| 237 |
| 238 if (ti > 0) |
| 239 oss << ", "; |
| 240 |
| 241 uint32_t bitrate = bitrates_[si][ti]; |
| 242 oss << bitrate; |
| 243 temporal_cumulator += bitrate; |
| 244 } |
| 245 oss << "]"; |
| 246 } |
| 247 |
| 248 RTC_DCHECK_EQ(spatial_cumulator, sum_); |
| 249 oss << " ]"; |
| 250 return oss.str(); |
| 251 } |
| 252 |
210 } // namespace webrtc | 253 } // namespace webrtc |
OLD | NEW |