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 | 10 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 if (rsid.empty() || rsid.size() > StreamId::kMaxSize) | |
262 return false; | |
263 memcpy(data, rsid.data(), rsid.size()); | |
264 return true; | |
265 } | |
266 | |
260 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, std::string* rsid) { | 267 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. | 268 if (data.empty() || data[0] == 0) // Valid rsid can't be empty. |
262 return false; | 269 return false; |
263 const char* str = reinterpret_cast<const char*>(data.data()); | 270 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 | 271 // 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. | 272 // the string. Well-formed rsid shouldn't contain it. |
266 rsid->assign(str, strnlen(str, data.size())); | 273 rsid->assign(str, strnlen(str, data.size())); |
267 RTC_DCHECK(!rsid->empty()); | 274 RTC_DCHECK(!rsid->empty()); |
268 return true; | 275 return true; |
269 } | 276 } |
270 | 277 |
278 bool RtpStreamId::Write(uint8_t* data, const std::string& rsid) { | |
279 if (rsid.empty() || rsid.size() > StreamId::kMaxSize) | |
danilchap
2017/05/10 11:25:18
may be DCHECK here:
caller must ensure |data| has
erikvarga1
2017/05/10 14:48:19
Done.
| |
280 return false; | |
281 memcpy(data, rsid.data(), rsid.size()); | |
282 return true; | |
283 } | |
284 | |
271 // RepairedRtpStreamId. | 285 // RepairedRtpStreamId. |
272 constexpr RTPExtensionType RepairedRtpStreamId::kId; | 286 constexpr RTPExtensionType RepairedRtpStreamId::kId; |
273 constexpr uint8_t RepairedRtpStreamId::kValueSizeBytes; | 287 constexpr uint8_t RepairedRtpStreamId::kValueSizeBytes; |
274 constexpr const char* RepairedRtpStreamId::kUri; | 288 constexpr const char* RepairedRtpStreamId::kUri; |
275 | 289 |
276 // RtpStreamId and RepairedRtpStreamId use the same format to store rsid. | 290 // RtpStreamId and RepairedRtpStreamId use the same format to store rsid. |
277 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, | 291 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, |
278 StreamId* rsid) { | 292 StreamId* rsid) { |
279 return RtpStreamId::Parse(data, rsid); | 293 return RtpStreamId::Parse(data, rsid); |
280 } | 294 } |
281 | 295 |
296 size_t RepairedRtpStreamId::ValueSize(const StreamId& rsid) { | |
297 return RtpStreamId::ValueSize(rsid); | |
298 } | |
299 | |
300 bool RepairedRtpStreamId::Write(uint8_t* data, const StreamId& rsid) { | |
301 return RtpStreamId::Write(data, rsid); | |
302 } | |
303 | |
282 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, | 304 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, |
283 std::string* rsid) { | 305 std::string* rsid) { |
284 return RtpStreamId::Parse(data, rsid); | 306 return RtpStreamId::Parse(data, rsid); |
285 } | 307 } |
286 | 308 |
309 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) { | |
310 return RtpStreamId::ValueSize(rsid); | |
311 } | |
312 | |
313 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) { | |
314 return RtpStreamId::Write(data, rsid); | |
315 } | |
316 | |
287 } // namespace webrtc | 317 } // namespace webrtc |
OLD | NEW |