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

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

Issue 2871813003: Add write support for the RtpStreamId and RepairedRtpStreamId 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 constexpr const char* RtpStreamId::kUri; 250 constexpr const char* RtpStreamId::kUri;
251 251
252 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) { 252 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) {
253 if (data.empty() || data[0] == 0) // Valid rsid can't be empty. 253 if (data.empty() || data[0] == 0) // Valid rsid can't be empty.
254 return false; 254 return false;
255 rsid->Set(data); 255 rsid->Set(data);
256 RTC_DCHECK(!rsid->empty()); 256 RTC_DCHECK(!rsid->empty());
257 return true; 257 return true;
258 } 258 }
259 259
260 bool RtpStreamId::Write(uint8_t* data, const StreamId& rsid) {
261 memcpy(data, rsid.data(), rsid.size());
262 return true;
263 }
264
260 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, std::string* rsid) { 265 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. 266 if (data.empty() || data[0] == 0) // Valid rsid can't be empty.
262 return false; 267 return false;
263 const char* str = reinterpret_cast<const char*>(data.data()); 268 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 269 // 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. 270 // the string. Well-formed rsid shouldn't contain it.
266 rsid->assign(str, strnlen(str, data.size())); 271 rsid->assign(str, strnlen(str, data.size()));
267 RTC_DCHECK(!rsid->empty()); 272 RTC_DCHECK(!rsid->empty());
268 return true; 273 return true;
269 } 274 }
270 275
276 bool RtpStreamId::Write(uint8_t* data, const std::string& rsid) {
277 memcpy(data, rsid.data(), rsid.size());
278 return true;
279 }
280
271 // RepairedRtpStreamId. 281 // RepairedRtpStreamId.
272 constexpr RTPExtensionType RepairedRtpStreamId::kId; 282 constexpr RTPExtensionType RepairedRtpStreamId::kId;
273 constexpr uint8_t RepairedRtpStreamId::kValueSizeBytes; 283 constexpr uint8_t RepairedRtpStreamId::kValueSizeBytes;
274 constexpr const char* RepairedRtpStreamId::kUri; 284 constexpr const char* RepairedRtpStreamId::kUri;
275 285
276 // RtpStreamId and RepairedRtpStreamId use the same format to store rsid. 286 // RtpStreamId and RepairedRtpStreamId use the same format to store rsid.
277 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, 287 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data,
278 StreamId* rsid) { 288 StreamId* rsid) {
279 return RtpStreamId::Parse(data, rsid); 289 return RtpStreamId::Parse(data, rsid);
280 } 290 }
281 291
292 bool RepairedRtpStreamId::Write(uint8_t* data, const StreamId& rsid) {
293 return RtpStreamId::Write(data, rsid);
294 }
295
282 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, 296 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data,
283 std::string* rsid) { 297 std::string* rsid) {
284 return RtpStreamId::Parse(data, rsid); 298 return RtpStreamId::Parse(data, rsid);
285 } 299 }
286 300
301 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) {
302 return RtpStreamId::Write(data, rsid);
303 }
304
287 } // namespace webrtc 305 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698