OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ | 10 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 template <typename Extension, typename... Values> | 176 template <typename Extension, typename... Values> |
177 bool Packet::GetExtension(Values... values) const { | 177 bool Packet::GetExtension(Values... values) const { |
178 auto raw = FindExtension(Extension::kId); | 178 auto raw = FindExtension(Extension::kId); |
179 if (raw.empty()) | 179 if (raw.empty()) |
180 return false; | 180 return false; |
181 return Extension::Parse(raw, values...); | 181 return Extension::Parse(raw, values...); |
182 } | 182 } |
183 | 183 |
184 template <typename Extension, typename... Values> | 184 template <typename Extension, typename... Values> |
185 bool Packet::SetExtension(Values... values) { | 185 bool Packet::SetExtension(Values... values) { |
186 auto buffer = AllocateExtension(Extension::kId, Extension::kValueSizeBytes); | 186 auto buffer = AllocateExtension(Extension::kId, |
| 187 Extension::ValueSize(values...)); |
187 if (buffer.empty()) | 188 if (buffer.empty()) |
188 return false; | 189 return false; |
189 return Extension::Write(buffer.data(), values...); | 190 return Extension::Write(buffer.data(), values...); |
190 } | 191 } |
191 | 192 |
192 template <typename Extension> | 193 template <typename Extension> |
193 bool Packet::ReserveExtension() { | 194 bool Packet::ReserveExtension() { |
194 auto buffer = AllocateExtension(Extension::kId, Extension::kValueSizeBytes); | 195 auto buffer = AllocateExtension(Extension::kId, Extension::kValueSizeBytes); |
195 if (buffer.empty()) | 196 if (buffer.empty()) |
196 return false; | 197 return false; |
197 memset(buffer.data(), 0, Extension::kValueSizeBytes); | 198 memset(buffer.data(), 0, Extension::kValueSizeBytes); |
198 return true; | 199 return true; |
199 } | 200 } |
200 } // namespace rtp | 201 } // namespace rtp |
201 } // namespace webrtc | 202 } // namespace webrtc |
202 | 203 |
203 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ | 204 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ |
OLD | NEW |