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 <string.h> |
13 #include <limits> | 14 #include <limits> |
14 #include <string.h> | 15 #include <type_traits> |
15 | 16 |
16 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/stringutils.h" | 18 #include "webrtc/base/stringutils.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {} | 22 StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {} |
22 | 23 |
| 24 constexpr size_t StreamId::kMaxSize; |
| 25 |
| 26 void StreamId::Set(const char* data, size_t size) { |
| 27 // If |data| contains \0, the stream id size might become less than |size|. |
| 28 RTC_DCHECK_LE(size, kMaxSize); |
| 29 memcpy(value_, data, size); |
| 30 if (size < kMaxSize) |
| 31 value_[size] = 0; |
| 32 } |
| 33 |
| 34 // StreamId is used as member of RTPHeader that is sometimes copied with memcpy |
| 35 // and thus assume trivial destructibility. |
| 36 static_assert(std::is_trivially_destructible<StreamId>::value, ""); |
| 37 |
23 RTPHeaderExtension::RTPHeaderExtension() | 38 RTPHeaderExtension::RTPHeaderExtension() |
24 : hasTransmissionTimeOffset(false), | 39 : hasTransmissionTimeOffset(false), |
25 transmissionTimeOffset(0), | 40 transmissionTimeOffset(0), |
26 hasAbsoluteSendTime(false), | 41 hasAbsoluteSendTime(false), |
27 absoluteSendTime(0), | 42 absoluteSendTime(0), |
28 hasTransportSequenceNumber(false), | 43 hasTransportSequenceNumber(false), |
29 transportSequenceNumber(0), | 44 transportSequenceNumber(0), |
30 hasAudioLevel(false), | 45 hasAudioLevel(false), |
31 voiceActivity(false), | 46 voiceActivity(false), |
32 audioLevel(0), | 47 audioLevel(0), |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Get the sum of all the temporal layer for a specific spatial layer. | 195 // Get the sum of all the temporal layer for a specific spatial layer. |
181 uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const { | 196 uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const { |
182 RTC_CHECK_LT(spatial_index, kMaxSpatialLayers); | 197 RTC_CHECK_LT(spatial_index, kMaxSpatialLayers); |
183 uint32_t sum = 0; | 198 uint32_t sum = 0; |
184 for (int i = 0; i < kMaxTemporalStreams; ++i) | 199 for (int i = 0; i < kMaxTemporalStreams; ++i) |
185 sum += bitrates_[spatial_index][i]; | 200 sum += bitrates_[spatial_index][i]; |
186 return sum; | 201 return sum; |
187 } | 202 } |
188 | 203 |
189 } // namespace webrtc | 204 } // namespace webrtc |
OLD | NEW |