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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 237 } |
238 return false; | 238 return false; |
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. |
| 248 constexpr RTPExtensionType RtpStreamId::kId; |
| 249 constexpr uint8_t RtpStreamId::kValueSizeBytes; |
| 250 constexpr const char* RtpStreamId::kUri; |
| 251 |
| 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. |
| 254 return false; |
| 255 rsid->Set(data); |
| 256 RTC_DCHECK(!rsid->empty()); |
| 257 return true; |
| 258 } |
| 259 |
| 260 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. |
| 262 return false; |
| 263 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 |
| 265 // the string. Well-formed rsid shouldn't contain it. |
| 266 rsid->assign(str, strnlen(str, data.size())); |
| 267 RTC_DCHECK(!rsid->empty()); |
| 268 return true; |
| 269 } |
| 270 |
| 271 // RepairedRtpStreamId. |
| 272 constexpr RTPExtensionType RepairedRtpStreamId::kId; |
| 273 constexpr uint8_t RepairedRtpStreamId::kValueSizeBytes; |
| 274 constexpr const char* RepairedRtpStreamId::kUri; |
| 275 |
| 276 // RtpStreamId and RepairedRtpStreamId use the same format to store rsid. |
| 277 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, |
| 278 StreamId* rsid) { |
| 279 return RtpStreamId::Parse(data, rsid); |
| 280 } |
| 281 |
| 282 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, |
| 283 std::string* rsid) { |
| 284 return RtpStreamId::Parse(data, rsid); |
| 285 } |
| 286 |
247 } // namespace webrtc | 287 } // namespace webrtc |
OLD | NEW |