Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_packet.h

Issue 2871813003: Add write support for the RtpStreamId and RepairedRtpStreamId header extensions. (Closed)
Patch Set: Patch 3 Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 const size_t value_size = Extension::ValueSize(values...);
187 if (value_size == 0 || value_size > 16)
188 return false;
189 auto buffer = AllocateExtension(Extension::kId, value_size);
187 if (buffer.empty()) 190 if (buffer.empty())
188 return false; 191 return false;
189 return Extension::Write(buffer.data(), values...); 192 return Extension::Write(buffer.data(), values...);
190 } 193 }
191 194
192 template <typename Extension> 195 template <typename Extension>
193 bool Packet::ReserveExtension() { 196 bool Packet::ReserveExtension() {
194 auto buffer = AllocateExtension(Extension::kId, Extension::kValueSizeBytes); 197 auto buffer = AllocateExtension(Extension::kId, Extension::kValueSizeBytes);
195 if (buffer.empty()) 198 if (buffer.empty())
196 return false; 199 return false;
197 memset(buffer.data(), 0, Extension::kValueSizeBytes); 200 memset(buffer.data(), 0, Extension::kValueSizeBytes);
198 return true; 201 return true;
199 } 202 }
200 } // namespace rtp 203 } // namespace rtp
201 } // namespace webrtc 204 } // namespace webrtc
202 205
203 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ 206 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698