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

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

Issue 2911193002: Implement timing frames. (Closed)
Patch Set: Implement Holmer@ comments Created 3 years, 6 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
239 return false; 239 return false;
240 } 240 }
241 241
242 bool VideoContentTypeExtension::Write(uint8_t* data, 242 bool VideoContentTypeExtension::Write(uint8_t* data,
243 VideoContentType content_type) { 243 VideoContentType content_type) {
244 data[0] = static_cast<uint8_t>(content_type); 244 data[0] = static_cast<uint8_t>(content_type);
245 return true; 245 return true;
246 } 246 }
247 247
248 // Video Timing.
249 // 6 timestamps in milliseconds counted from capture time stored in rtp header:
250 // encode start/finish, packetization complete, pacer exit and reserved for
251 // modification by the network modification.
252 // 0 1 2 3
253 // 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
254 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
255 // | ID | len=11| encode start ms delta | encode finish |
256 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
257 // | ms delta | packetizer finish ms delta | pacer exit |
258 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
259 // | ms delta | network timestamp ms delta | network2 time-|
260 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
261 // | stamp ms delta|
262 // +-+-+-+-+-+-+-+-+
263
264 constexpr RTPExtensionType VideoTimingExtension::kId;
265 constexpr uint8_t VideoTimingExtension::kValueSizeBytes;
266 constexpr const char* VideoTimingExtension::kUri;
267
268 bool VideoTimingExtension::Parse(rtc::ArrayView<const uint8_t> data,
269 VideoTiming* timing) {
270 RTC_DCHECK(timing);
271 if (data.size() != kValueSizeBytes)
272 return false;
273 timing->encode_start_delta_ms =
274 ByteReader<uint16_t>::ReadBigEndian(data.data());
275 timing->encode_finish_delta_ms = ByteReader<uint16_t>::ReadBigEndian(
276 data.data() + 2 * VideoTiming::kEncodeFinishDeltaIdx);
277 timing->packetization_finish_delta_ms = ByteReader<uint16_t>::ReadBigEndian(
278 data.data() + 2 * VideoTiming::kPacketizationFinishDeltaIdx);
279 timing->pacer_exit_delta_ms = ByteReader<uint16_t>::ReadBigEndian(
280 data.data() + 2 * VideoTiming::kPacerExitDeltaIdx);
281 timing->network_timstamp_delta_ms = ByteReader<uint16_t>::ReadBigEndian(
282 data.data() + 2 * VideoTiming::kNetworkTimestampDeltaIdx);
283 timing->network2_timstamp_delta_ms = ByteReader<uint16_t>::ReadBigEndian(
284 data.data() + 2 * VideoTiming::kNetwork2TimestampDeltaIdx);
285 timing->is_timing_frame = true;
286 return true;
287 }
288
289 bool VideoTimingExtension::Write(uint8_t* data, const VideoTiming& timing) {
290 ByteWriter<uint16_t>::WriteBigEndian(data, timing.encode_start_delta_ms);
291 ByteWriter<uint16_t>::WriteBigEndian(
292 data + 2 * VideoTiming::kEncodeFinishDeltaIdx,
293 timing.encode_finish_delta_ms);
294 ByteWriter<uint16_t>::WriteBigEndian(
295 data + 2 * VideoTiming::kPacketizationFinishDeltaIdx,
296 timing.packetization_finish_delta_ms);
297 ByteWriter<uint16_t>::WriteBigEndian(
298 data + 2 * VideoTiming::kPacerExitDeltaIdx, timing.pacer_exit_delta_ms);
299 ByteWriter<uint16_t>::WriteBigEndian(
300 data + 2 * VideoTiming::kNetworkTimestampDeltaIdx, 0); // reserved
301 ByteWriter<uint16_t>::WriteBigEndian(
302 data + 2 * VideoTiming::kNetwork2TimestampDeltaIdx, 0); // reserved
303 return true;
304 }
305
306 bool VideoTimingExtension::Write(uint8_t* data,
307 uint16_t time_delta_ms,
308 uint8_t idx) {
309 RTC_DCHECK_LT(idx, 6);
310 ByteWriter<uint16_t>::WriteBigEndian(data + 2 * idx, time_delta_ms);
311 return true;
312 }
313
248 // RtpStreamId. 314 // RtpStreamId.
249 constexpr RTPExtensionType RtpStreamId::kId; 315 constexpr RTPExtensionType RtpStreamId::kId;
250 constexpr const char* RtpStreamId::kUri; 316 constexpr const char* RtpStreamId::kUri;
251 317
252 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) { 318 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) {
253 if (data.empty() || data[0] == 0) // Valid rsid can't be empty. 319 if (data.empty() || data[0] == 0) // Valid rsid can't be empty.
254 return false; 320 return false;
255 rsid->Set(data); 321 rsid->Set(data);
256 RTC_DCHECK(!rsid->empty()); 322 RTC_DCHECK(!rsid->empty());
257 return true; 323 return true;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 373
308 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) { 374 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) {
309 return RtpStreamId::ValueSize(rsid); 375 return RtpStreamId::ValueSize(rsid);
310 } 376 }
311 377
312 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) { 378 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) {
313 return RtpStreamId::Write(data, rsid); 379 return RtpStreamId::Write(data, rsid);
314 } 380 }
315 381
316 } // namespace webrtc 382 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_packet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698