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 |
11 #include "webrtc/common_types.h" | 11 #include "webrtc/common_types.h" |
12 | 12 |
| 13 #include "webrtc/base/checks.h" |
| 14 |
13 #include <string.h> | 15 #include <string.h> |
14 | 16 |
15 namespace webrtc { | 17 namespace webrtc { |
16 | 18 |
17 StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {} | 19 StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {} |
18 | 20 |
19 RTPHeaderExtension::RTPHeaderExtension() | 21 RTPHeaderExtension::RTPHeaderExtension() |
20 : hasTransmissionTimeOffset(false), | 22 : hasTransmissionTimeOffset(false), |
21 transmissionTimeOffset(0), | 23 transmissionTimeOffset(0), |
22 hasAbsoluteSendTime(false), | 24 hasAbsoluteSendTime(false), |
(...skipping 12 matching lines...) Expand all Loading... |
35 sequenceNumber(0), | 37 sequenceNumber(0), |
36 timestamp(0), | 38 timestamp(0), |
37 ssrc(0), | 39 ssrc(0), |
38 numCSRCs(0), | 40 numCSRCs(0), |
39 arrOfCSRCs(), | 41 arrOfCSRCs(), |
40 paddingLength(0), | 42 paddingLength(0), |
41 headerLength(0), | 43 headerLength(0), |
42 payload_type_frequency(0), | 44 payload_type_frequency(0), |
43 extension() {} | 45 extension() {} |
44 | 46 |
| 47 BitrateAllocation::BitrateAllocation() : sum_(0), bitrates_{} {} |
| 48 |
| 49 bool BitrateAllocation::SetBitrate(size_t spatial_index, |
| 50 size_t temporal_index, |
| 51 uint32_t bitrate_bps) { |
| 52 RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers)); |
| 53 RTC_DCHECK_LT(temporal_index, static_cast<size_t>(kMaxTemporalStreams)); |
| 54 if (bitrate_bps > kMaxBitrateBps || |
| 55 sum_ - bitrates_[spatial_index][temporal_index] + bitrate_bps > |
| 56 kMaxBitrateBps) { |
| 57 return false; |
| 58 } |
| 59 sum_ -= bitrates_[spatial_index][temporal_index]; |
| 60 bitrates_[spatial_index][temporal_index] = bitrate_bps; |
| 61 sum_ += bitrate_bps; |
| 62 return true; |
| 63 } |
| 64 |
| 65 uint32_t BitrateAllocation::GetBitrate(size_t spatial_index, |
| 66 size_t temporal_index) const { |
| 67 RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers)); |
| 68 RTC_DCHECK_LT(temporal_index, static_cast<size_t>(kMaxTemporalStreams)); |
| 69 return bitrates_[spatial_index][temporal_index]; |
| 70 } |
| 71 |
| 72 // Get the sum of all the temporal layer for a specific spatial layer. |
| 73 uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const { |
| 74 RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers)); |
| 75 uint32_t sum = 0; |
| 76 for (int i = 0; i < kMaxTemporalStreams; ++i) |
| 77 sum += bitrates_[spatial_index][i]; |
| 78 return sum; |
| 79 } |
| 80 |
45 } // namespace webrtc | 81 } // namespace webrtc |
OLD | NEW |