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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 bool RtpHeaderExtensionMap::RegisterByUri(uint8_t id, const std::string& uri) { | 89 bool RtpHeaderExtensionMap::RegisterByUri(uint8_t id, const std::string& uri) { |
90 for (const ExtensionInfo& extension : kExtensions) | 90 for (const ExtensionInfo& extension : kExtensions) |
91 if (uri == extension.uri) | 91 if (uri == extension.uri) |
92 return Register(id, extension.type, extension.value_size, extension.uri); | 92 return Register(id, extension.type, extension.value_size, extension.uri); |
93 LOG(LS_WARNING) << "Unknown extension uri:'" << uri | 93 LOG(LS_WARNING) << "Unknown extension uri:'" << uri |
94 << "', id: " << static_cast<int>(id) << '.'; | 94 << "', id: " << static_cast<int>(id) << '.'; |
95 return false; | 95 return false; |
96 } | 96 } |
97 | 97 |
98 size_t RtpHeaderExtensionMap::GetTotalLengthInBytes() const { | 98 size_t RtpHeaderExtensionMap::GetTotalLengthInBytes() const { |
| 99 static constexpr size_t kRtpOneByteHeaderLength = 4; |
99 if (total_values_size_bytes_ == 0) | 100 if (total_values_size_bytes_ == 0) |
100 return 0; | 101 return 0; |
101 return Word32Align(kRtpOneByteHeaderLength + total_values_size_bytes_); | 102 return Word32Align(kRtpOneByteHeaderLength + total_values_size_bytes_); |
102 } | 103 } |
103 | 104 |
104 int32_t RtpHeaderExtensionMap::Deregister(RTPExtensionType type) { | 105 int32_t RtpHeaderExtensionMap::Deregister(RTPExtensionType type) { |
105 if (IsRegistered(type)) { | 106 if (IsRegistered(type)) { |
106 uint8_t id = GetId(type); | 107 uint8_t id = GetId(type); |
107 total_values_size_bytes_ -= (ValueSize(type) + 1); | 108 total_values_size_bytes_ -= (ValueSize(type) + 1); |
108 types_[id] = kInvalidType; | 109 types_[id] = kInvalidType; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 142 } |
142 RTC_DCHECK(!IsRegistered(type)); | 143 RTC_DCHECK(!IsRegistered(type)); |
143 | 144 |
144 types_[id] = type; | 145 types_[id] = type; |
145 ids_[type] = id; | 146 ids_[type] = id; |
146 total_values_size_bytes_ += (value_size + 1); | 147 total_values_size_bytes_ += (value_size + 1); |
147 return true; | 148 return true; |
148 } | 149 } |
149 | 150 |
150 } // namespace webrtc | 151 } // namespace webrtc |
OLD | NEW |