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 <string.h> |
14 #include <algorithm> | |
14 #include <limits> | 15 #include <limits> |
15 #include <type_traits> | 16 #include <type_traits> |
16 | 17 |
17 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
18 #include "webrtc/base/stringutils.h" | 19 #include "webrtc/base/stringutils.h" |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {} | 23 StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {} |
23 | 24 |
24 constexpr size_t StreamId::kMaxSize; | 25 constexpr size_t StreamId::kMaxSize; |
25 | 26 |
27 bool StreamId::IsLegalName(const char* data, size_t size) { | |
28 return (size <= kMaxSize && size > 0 && | |
29 std::all_of(data, data + size, isalnum)); | |
danilchap
2017/06/02 17:42:20
may be remove () around the expression.
https://go
eladalon
2017/06/02 19:44:05
That link seems to suggest that the parenthesis ar
danilchap
2017/06/07 13:45:41
yep, in this case it is ok, thus 'may be'
| |
30 } | |
31 | |
26 void StreamId::Set(const char* data, size_t size) { | 32 void StreamId::Set(const char* data, size_t size) { |
27 // If |data| contains \0, the stream id size might become less than |size|. | 33 // If |data| contains \0, the stream id size might become less than |size|. |
28 RTC_DCHECK_LE(size, kMaxSize); | 34 RTC_DCHECK_LE(size, kMaxSize); // TODO(eladalon): IsLegalName? |
danilchap
2017/06/02 17:42:20
probably not:
Set is called by parser too. While p
eladalon
2017/06/02 19:44:05
My intention with this TODO is to come back to thi
danilchap
2017/06/07 13:45:41
I prefer to think about StreamId as a special impl
| |
29 memcpy(value_, data, size); | 35 memcpy(value_, data, size); |
30 if (size < kMaxSize) | 36 if (size < kMaxSize) |
31 value_[size] = 0; | 37 value_[size] = 0; |
32 } | 38 } |
33 | 39 |
34 // StreamId is used as member of RTPHeader that is sometimes copied with memcpy | 40 // StreamId is used as member of RTPHeader that is sometimes copied with memcpy |
35 // and thus assume trivial destructibility. | 41 // and thus assume trivial destructibility. |
36 static_assert(std::is_trivially_destructible<StreamId>::value, ""); | 42 static_assert(std::is_trivially_destructible<StreamId>::value, ""); |
37 | 43 |
38 RTPHeaderExtension::RTPHeaderExtension() | 44 RTPHeaderExtension::RTPHeaderExtension() |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 // 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. |
196 uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const { | 202 uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const { |
197 RTC_CHECK_LT(spatial_index, kMaxSpatialLayers); | 203 RTC_CHECK_LT(spatial_index, kMaxSpatialLayers); |
198 uint32_t sum = 0; | 204 uint32_t sum = 0; |
199 for (int i = 0; i < kMaxTemporalStreams; ++i) | 205 for (int i = 0; i < kMaxTemporalStreams; ++i) |
200 sum += bitrates_[spatial_index][i]; | 206 sum += bitrates_[spatial_index][i]; |
201 return sum; | 207 return sum; |
202 } | 208 } |
203 | 209 |
204 } // namespace webrtc | 210 } // namespace webrtc |
OLD | NEW |