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 // Video Timing. |
| 248 // 5 timestamps in milliseconds counted from capture time stored in rtp header: |
| 249 // ecode start/finish, packetization complete, pacer exit and reserved for |
| 250 // modification by the network modification. |
| 251 // 0 1 2 3 |
| 252 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 |
| 253 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 254 // | ID | len=9 | encode start ms delta | encode finish | |
| 255 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 256 // | ms delta | packetizer finish ms delta | pacer exit | |
| 257 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 258 // | ms delta | network timestamp ms delta | | |
| 259 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 260 |
| 261 constexpr RTPExtensionType VideoTimingExtension::kId; |
| 262 constexpr uint8_t VideoTimingExtension::kValueSizeBytes; |
| 263 constexpr const char* VideoTimingExtension::kUri; |
| 264 |
| 265 bool VideoTimingExtension::Parse(rtc::ArrayView<const uint8_t> data, |
| 266 VideoTiming* timing) { |
| 267 RTC_DCHECK(timing); |
| 268 if (data.size() != 10) |
| 269 return false; |
| 270 timing->encode_start_ms_delta = |
| 271 ByteReader<uint16_t>::ReadBigEndian(data.data()); |
| 272 timing->encode_finish_ms_delta = ByteReader<uint16_t, 2>::ReadBigEndian( |
| 273 data.data() + 2 * VideoTiming::kEncodeFinishIdx); |
| 274 timing->packetization_finish_ms_delta = |
| 275 ByteReader<uint16_t>::ReadBigEndian( |
| 276 data.data() + 2 * VideoTiming::kPacketizationFinishDeltaIdx); |
| 277 timing->pacer_exit_ms_delta = ByteReader<uint16_t, 2>::ReadBigEndian( |
| 278 data.data() + 2 * VideoTiming::kPacerExitDeltaIdx); |
| 279 timing->network_timstamp_ms_delta = ByteReader<uint16_t, 2>::ReadBigEndian( |
| 280 data.data() + 2 * VideoTiming::kNetworkTimestampDeltaIdx); |
| 281 timing->is_timing_frame = true; |
| 282 return true; |
| 283 } |
| 284 |
| 285 bool VideoTimingExtension::Write(uint8_t* data, const VideoTiming& timing) { |
| 286 ByteWriter<uint16_t>::WriteBigEndian(data, timing.encode_start_ms_delta); |
| 287 ByteWriter<uint16_t>::WriteBigEndian( |
| 288 data + 2 * VideoTiming::kEncodeFinishIdx, timing.encode_finish_ms_delta); |
| 289 ByteWriter<uint16_t>::WriteBigEndian( |
| 290 data + 2 * VideoTiming::kPacketizationFinishDeltaIdx, |
| 291 timing.packetization_finish_ms_delta); |
| 292 ByteWriter<uint16_t>::WriteBigEndian( |
| 293 data + 2 * VideoTiming::kPacerExitDeltaIdx, timing.pacer_exit_ms_delta); |
| 294 ByteWriter<uint16_t>::WriteBigEndian( |
| 295 data + 2 * VideoTiming::kNetworkTimestampDeltaIdx, 0); // reserved |
| 296 return true; |
| 297 } |
| 298 |
| 299 bool VideoTimingExtension::Write(uint8_t* data, |
| 300 uint16_t time_delta_ms, |
| 301 uint8_t idx) { |
| 302 RTC_DCHECK_LT(idx, 5); |
| 303 ByteWriter<uint16_t>::WriteBigEndian(data + 2 * idx, time_delta_ms); |
| 304 return true; |
| 305 } |
| 306 |
247 // RtpStreamId. | 307 // RtpStreamId. |
248 constexpr RTPExtensionType RtpStreamId::kId; | 308 constexpr RTPExtensionType RtpStreamId::kId; |
249 constexpr const char* RtpStreamId::kUri; | 309 constexpr const char* RtpStreamId::kUri; |
250 | 310 |
251 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) { | 311 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) { |
252 if (data.empty() || data[0] == 0) // Valid rsid can't be empty. | 312 if (data.empty() || data[0] == 0) // Valid rsid can't be empty. |
253 return false; | 313 return false; |
254 rsid->Set(data); | 314 rsid->Set(data); |
255 RTC_DCHECK(!rsid->empty()); | 315 RTC_DCHECK(!rsid->empty()); |
256 return true; | 316 return true; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 366 |
307 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) { | 367 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) { |
308 return RtpStreamId::ValueSize(rsid); | 368 return RtpStreamId::ValueSize(rsid); |
309 } | 369 } |
310 | 370 |
311 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) { | 371 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) { |
312 return RtpStreamId::Write(data, rsid); | 372 return RtpStreamId::Write(data, rsid); |
313 } | 373 } |
314 | 374 |
315 } // namespace webrtc | 375 } // namespace webrtc |
OLD | NEW |