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: | |
åsapersson
2017/06/12 14:33:41
6 timestamps
ilnik
2017/06/13 08:43:13
Done.
| |
249 // ecode start/finish, packetization complete, pacer exit and reserved for | |
åsapersson
2017/06/12 14:33:41
encode
ilnik
2017/06/13 08:43:13
Done.
| |
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=11| encode start ms delta | encode finish | | |
255 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
256 // | ms delta | packetizer finish ms delta | pacer exit | | |
257 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
258 // | ms delta | network timestamp ms delta | network2 time-| | |
259 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
260 // | stamp ms delta| | |
261 // +-+-+-+-+-+-+-+-+ | |
262 | |
263 constexpr RTPExtensionType VideoTimingExtension::kId; | |
264 constexpr uint8_t VideoTimingExtension::kValueSizeBytes; | |
265 constexpr const char* VideoTimingExtension::kUri; | |
266 | |
267 bool VideoTimingExtension::Parse(rtc::ArrayView<const uint8_t> data, | |
268 VideoTiming* timing) { | |
269 RTC_DCHECK(timing); | |
270 if (data.size() != kValueSizeBytes) | |
271 return false; | |
272 timing->encode_start_ms_delta = | |
273 ByteReader<uint16_t>::ReadBigEndian(data.data()); | |
274 timing->encode_finish_ms_delta = ByteReader<uint16_t, 2>::ReadBigEndian( | |
åsapersson
2017/06/12 14:33:41
ByteReader<uint16_t> here and below.
ilnik
2017/06/13 08:43:13
Done.
| |
275 data.data() + 2 * VideoTiming::kEncodeFinishIdx); | |
276 timing->packetization_finish_ms_delta = ByteReader<uint16_t>::ReadBigEndian( | |
277 data.data() + 2 * VideoTiming::kPacketizationFinishDeltaIdx); | |
278 timing->pacer_exit_ms_delta = ByteReader<uint16_t, 2>::ReadBigEndian( | |
279 data.data() + 2 * VideoTiming::kPacerExitDeltaIdx); | |
280 timing->network_timstamp_ms_delta = ByteReader<uint16_t, 2>::ReadBigEndian( | |
281 data.data() + 2 * VideoTiming::kNetworkTimestampDeltaIdx); | |
282 timing->network2_timstamp_ms_delta = ByteReader<uint16_t, 2>::ReadBigEndian( | |
283 data.data() + 2 * VideoTiming::kNetwork2TimestampDeltaIdx); | |
284 timing->is_timing_frame = true; | |
285 return true; | |
286 } | |
287 | |
288 bool VideoTimingExtension::Write(uint8_t* data, const VideoTiming& timing) { | |
289 ByteWriter<uint16_t>::WriteBigEndian(data, timing.encode_start_ms_delta); | |
290 ByteWriter<uint16_t>::WriteBigEndian(data + 2 * VideoTiming::kEncodeFinishIdx, | |
291 timing.encode_finish_ms_delta); | |
292 ByteWriter<uint16_t>::WriteBigEndian( | |
293 data + 2 * VideoTiming::kPacketizationFinishDeltaIdx, | |
294 timing.packetization_finish_ms_delta); | |
295 ByteWriter<uint16_t>::WriteBigEndian( | |
296 data + 2 * VideoTiming::kPacerExitDeltaIdx, timing.pacer_exit_ms_delta); | |
297 ByteWriter<uint16_t>::WriteBigEndian( | |
298 data + 2 * VideoTiming::kNetworkTimestampDeltaIdx, 0); // reserved | |
299 ByteWriter<uint16_t>::WriteBigEndian( | |
300 data + 2 * VideoTiming::kNetwork2TimestampDeltaIdx, 0); // reserved | |
301 return true; | |
302 } | |
303 | |
304 bool VideoTimingExtension::Write(uint8_t* data, | |
305 uint16_t time_delta_ms, | |
306 uint8_t idx) { | |
307 RTC_DCHECK_LT(idx, 6); | |
308 ByteWriter<uint16_t>::WriteBigEndian(data + 2 * idx, time_delta_ms); | |
309 return true; | |
310 } | |
311 | |
247 // RtpStreamId. | 312 // RtpStreamId. |
248 constexpr RTPExtensionType RtpStreamId::kId; | 313 constexpr RTPExtensionType RtpStreamId::kId; |
249 constexpr const char* RtpStreamId::kUri; | 314 constexpr const char* RtpStreamId::kUri; |
250 | 315 |
251 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) { | 316 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) { |
252 if (data.empty() || data[0] == 0) // Valid rsid can't be empty. | 317 if (data.empty() || data[0] == 0) // Valid rsid can't be empty. |
253 return false; | 318 return false; |
254 rsid->Set(data); | 319 rsid->Set(data); |
255 RTC_DCHECK(!rsid->empty()); | 320 RTC_DCHECK(!rsid->empty()); |
256 return true; | 321 return true; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 | 371 |
307 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) { | 372 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) { |
308 return RtpStreamId::ValueSize(rsid); | 373 return RtpStreamId::ValueSize(rsid); |
309 } | 374 } |
310 | 375 |
311 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) { | 376 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) { |
312 return RtpStreamId::Write(data, rsid); | 377 return RtpStreamId::Write(data, rsid); |
313 } | 378 } |
314 | 379 |
315 } // namespace webrtc | 380 } // namespace webrtc |
OLD | NEW |