| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 void SetSequenceNumber(uint16_t seq_no); | 76 void SetSequenceNumber(uint16_t seq_no); |
| 77 void SetTimestamp(uint32_t timestamp); | 77 void SetTimestamp(uint32_t timestamp); |
| 78 void SetSsrc(uint32_t ssrc); | 78 void SetSsrc(uint32_t ssrc); |
| 79 | 79 |
| 80 // Writes csrc list. Assumes: | 80 // Writes csrc list. Assumes: |
| 81 // a) There is enough room left in buffer. | 81 // a) There is enough room left in buffer. |
| 82 // b) Extension headers, payload or padding data has not already been added. | 82 // b) Extension headers, payload or padding data has not already been added. |
| 83 void SetCsrcs(const std::vector<uint32_t>& csrcs); | 83 void SetCsrcs(const std::vector<uint32_t>& csrcs); |
| 84 | 84 |
| 85 // Header extensions. | 85 // Header extensions. |
| 86 template <typename Extension> |
| 87 bool HasExtension() const; |
| 88 |
| 86 template <typename Extension, typename... Values> | 89 template <typename Extension, typename... Values> |
| 87 bool GetExtension(Values...) const; | 90 bool GetExtension(Values...) const; |
| 88 | 91 |
| 89 template <typename Extension, typename... Values> | 92 template <typename Extension, typename... Values> |
| 90 bool SetExtension(Values...); | 93 bool SetExtension(Values...); |
| 91 | 94 |
| 92 template <typename Extension> | 95 template <typename Extension> |
| 93 bool ReserveExtension(); | 96 bool ReserveExtension(); |
| 94 | 97 |
| 95 // Reserve size_bytes for payload. Returns nullptr on failure. | 98 // Reserve size_bytes for payload. Returns nullptr on failure. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 size_t payload_size_; | 156 size_t payload_size_; |
| 154 | 157 |
| 155 uint8_t num_extensions_ = 0; | 158 uint8_t num_extensions_ = 0; |
| 156 ExtensionInfo extension_entries_[kMaxExtensionHeaders]; | 159 ExtensionInfo extension_entries_[kMaxExtensionHeaders]; |
| 157 uint16_t extensions_size_ = 0; // Unaligned. | 160 uint16_t extensions_size_ = 0; // Unaligned. |
| 158 rtc::CopyOnWriteBuffer buffer_; | 161 rtc::CopyOnWriteBuffer buffer_; |
| 159 | 162 |
| 160 Packet() = delete; | 163 Packet() = delete; |
| 161 }; | 164 }; |
| 162 | 165 |
| 166 template <typename Extension> |
| 167 bool Packet::HasExtension() const { |
| 168 uint16_t offset = 0; |
| 169 return FindExtension(Extension::kId, Extension::kValueSizeBytes, &offset); |
| 170 } |
| 171 |
| 163 template <typename Extension, typename... Values> | 172 template <typename Extension, typename... Values> |
| 164 bool Packet::GetExtension(Values... values) const { | 173 bool Packet::GetExtension(Values... values) const { |
| 165 uint16_t offset = 0; | 174 uint16_t offset = 0; |
| 166 if (!FindExtension(Extension::kId, Extension::kValueSizeBytes, &offset)) | 175 if (!FindExtension(Extension::kId, Extension::kValueSizeBytes, &offset)) |
| 167 return false; | 176 return false; |
| 168 return Extension::Parse(data() + offset, values...); | 177 return Extension::Parse(data() + offset, values...); |
| 169 } | 178 } |
| 170 | 179 |
| 171 template <typename Extension, typename... Values> | 180 template <typename Extension, typename... Values> |
| 172 bool Packet::SetExtension(Values... values) { | 181 bool Packet::SetExtension(Values... values) { |
| 173 uint16_t offset = 0; | 182 uint16_t offset = 0; |
| 174 if (!AllocateExtension(Extension::kId, Extension::kValueSizeBytes, &offset)) | 183 if (!AllocateExtension(Extension::kId, Extension::kValueSizeBytes, &offset)) |
| 175 return false; | 184 return false; |
| 176 return Extension::Write(WriteAt(offset), values...); | 185 return Extension::Write(WriteAt(offset), values...); |
| 177 } | 186 } |
| 178 | 187 |
| 179 template <typename Extension> | 188 template <typename Extension> |
| 180 bool Packet::ReserveExtension() { | 189 bool Packet::ReserveExtension() { |
| 181 uint16_t offset = 0; | 190 uint16_t offset = 0; |
| 182 if (!AllocateExtension(Extension::kId, Extension::kValueSizeBytes, &offset)) | 191 if (!AllocateExtension(Extension::kId, Extension::kValueSizeBytes, &offset)) |
| 183 return false; | 192 return false; |
| 184 memset(WriteAt(offset), 0, Extension::kValueSizeBytes); | 193 memset(WriteAt(offset), 0, Extension::kValueSizeBytes); |
| 185 return true; | 194 return true; |
| 186 } | 195 } |
| 187 } // namespace rtp | 196 } // namespace rtp |
| 188 } // namespace webrtc | 197 } // namespace webrtc |
| 189 | 198 |
| 190 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ | 199 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ |
| OLD | NEW |