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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc

Issue 2867713003: Remove hardcoded kValueSizeBytes values from variable-length header extensions. (Closed)
Patch Set: 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 10
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 239 }
240 240
241 bool VideoContentTypeExtension::Write(uint8_t* data, 241 bool VideoContentTypeExtension::Write(uint8_t* data,
242 VideoContentType content_type) { 242 VideoContentType content_type) {
243 data[0] = static_cast<uint8_t>(content_type); 243 data[0] = static_cast<uint8_t>(content_type);
244 return true; 244 return true;
245 } 245 }
246 246
247 // RtpStreamId. 247 // RtpStreamId.
248 constexpr RTPExtensionType RtpStreamId::kId; 248 constexpr RTPExtensionType RtpStreamId::kId;
249 constexpr uint8_t RtpStreamId::kValueSizeBytes;
250 constexpr const char* RtpStreamId::kUri; 249 constexpr const char* RtpStreamId::kUri;
251 250
252 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) { 251 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) {
253 if (data.empty() || data[0] == 0) // Valid rsid can't be empty. 252 if (data.empty() || data[0] == 0) // Valid rsid can't be empty.
254 return false; 253 return false;
255 rsid->Set(data); 254 rsid->Set(data);
256 RTC_DCHECK(!rsid->empty()); 255 RTC_DCHECK(!rsid->empty());
257 return true; 256 return true;
258 } 257 }
259 258
260 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, std::string* rsid) { 259 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, std::string* rsid) {
261 if (data.empty() || data[0] == 0) // Valid rsid can't be empty. 260 if (data.empty() || data[0] == 0) // Valid rsid can't be empty.
262 return false; 261 return false;
263 const char* str = reinterpret_cast<const char*>(data.data()); 262 const char* str = reinterpret_cast<const char*>(data.data());
264 // If there is a \0 character in the middle of the |data|, treat it as end of 263 // If there is a \0 character in the middle of the |data|, treat it as end of
265 // the string. Well-formed rsid shouldn't contain it. 264 // the string. Well-formed rsid shouldn't contain it.
266 rsid->assign(str, strnlen(str, data.size())); 265 rsid->assign(str, strnlen(str, data.size()));
267 RTC_DCHECK(!rsid->empty()); 266 RTC_DCHECK(!rsid->empty());
268 return true; 267 return true;
269 } 268 }
270 269
271 // RepairedRtpStreamId. 270 // RepairedRtpStreamId.
272 constexpr RTPExtensionType RepairedRtpStreamId::kId; 271 constexpr RTPExtensionType RepairedRtpStreamId::kId;
273 constexpr uint8_t RepairedRtpStreamId::kValueSizeBytes;
274 constexpr const char* RepairedRtpStreamId::kUri; 272 constexpr const char* RepairedRtpStreamId::kUri;
275 273
276 // RtpStreamId and RepairedRtpStreamId use the same format to store rsid. 274 // RtpStreamId and RepairedRtpStreamId use the same format to store rsid.
277 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, 275 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data,
278 StreamId* rsid) { 276 StreamId* rsid) {
279 return RtpStreamId::Parse(data, rsid); 277 return RtpStreamId::Parse(data, rsid);
280 } 278 }
281 279
282 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, 280 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data,
283 std::string* rsid) { 281 std::string* rsid) {
284 return RtpStreamId::Parse(data, rsid); 282 return RtpStreamId::Parse(data, rsid);
285 } 283 }
286 284
287 } // namespace webrtc 285 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698