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

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

Issue 2007743003: Add sender controlled playout delay limits (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@cleanup_rtp_hdr_extensions
Patch Set: Created 4 years, 7 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 // May not be present in packet. 242 // May not be present in packet.
243 header->extension.hasAudioLevel = false; 243 header->extension.hasAudioLevel = false;
244 header->extension.voiceActivity = false; 244 header->extension.voiceActivity = false;
245 header->extension.audioLevel = 0; 245 header->extension.audioLevel = 0;
246 246
247 // May not be present in packet. 247 // May not be present in packet.
248 header->extension.hasVideoRotation = false; 248 header->extension.hasVideoRotation = false;
249 header->extension.videoRotation = 0; 249 header->extension.videoRotation = 0;
250 250
251 // May not be present in packet.
252 header->extension.min_playout_delay_ms = -1;
253 header->extension.max_playout_delay_ms = -1;
254
251 if (X) { 255 if (X) {
252 /* RTP header extension, RFC 3550. 256 /* RTP header extension, RFC 3550.
253 0 1 2 3 257 0 1 2 3
254 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 258 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
255 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 259 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
256 | defined by profile | length | 260 | defined by profile | length |
257 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 261 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
258 | header extension | 262 | header extension |
259 | .... | 263 | .... |
260 */ 264 */
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 404 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
401 // | ID | L=1 |transport wide sequence number | 405 // | ID | L=1 |transport wide sequence number |
402 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 406 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
403 407
404 uint16_t sequence_number = ptr[0] << 8; 408 uint16_t sequence_number = ptr[0] << 8;
405 sequence_number += ptr[1]; 409 sequence_number += ptr[1];
406 header->extension.transportSequenceNumber = sequence_number; 410 header->extension.transportSequenceNumber = sequence_number;
407 header->extension.hasTransportSequenceNumber = true; 411 header->extension.hasTransportSequenceNumber = true;
408 break; 412 break;
409 } 413 }
414 case kRtpExtensionPlayoutDelay: {
415 if (len != 2) {
416 LOG(LS_WARNING) << "Incorrect playout delay len: " << len;
417 return;
418 }
419 // 0 1 2 3
420 // 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
421 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
422 // | ID | len=2 | MIN delay | MAX delay |
423 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
424
425 uint16_t min_playout_delay = (ptr[0] << 4) | ((ptr[1] >> 4) & 0xf);
426 uint16_t max_playout_delay = ((ptr[1] & 0xf) << 8) | ptr[2];
427 header->extension.min_playout_delay_ms = min_playout_delay * 10;
danilchap 2016/05/24 13:28:24 kPlayoutDelayGranularityMs instead of 10 here and
Irfan 2016/05/25 09:32:53 Done.
428 header->extension.max_playout_delay_ms = max_playout_delay * 10;
429 break;
430 }
410 default: { 431 default: {
411 LOG(LS_WARNING) << "Extension type not implemented: " << type; 432 LOG(LS_WARNING) << "Extension type not implemented: " << type;
412 return; 433 return;
413 } 434 }
414 } 435 }
415 } 436 }
416 ptr += (len + 1); 437 ptr += (len + 1);
417 uint8_t num_bytes = ParsePaddingBytes(ptrRTPDataExtensionEnd, ptr); 438 uint8_t num_bytes = ParsePaddingBytes(ptrRTPDataExtensionEnd, ptr);
418 ptr += num_bytes; 439 ptr += num_bytes;
419 } 440 }
420 } 441 }
421 442
422 uint8_t RtpHeaderParser::ParsePaddingBytes( 443 uint8_t RtpHeaderParser::ParsePaddingBytes(
423 const uint8_t* ptrRTPDataExtensionEnd, 444 const uint8_t* ptrRTPDataExtensionEnd,
424 const uint8_t* ptr) const { 445 const uint8_t* ptr) const {
425 uint8_t num_zero_bytes = 0; 446 uint8_t num_zero_bytes = 0;
426 while (ptrRTPDataExtensionEnd - ptr > 0) { 447 while (ptrRTPDataExtensionEnd - ptr > 0) {
427 if (*ptr != 0) { 448 if (*ptr != 0) {
428 return num_zero_bytes; 449 return num_zero_bytes;
429 } 450 }
430 ptr++; 451 ptr++;
431 num_zero_bytes++; 452 num_zero_bytes++;
432 } 453 }
433 return num_zero_bytes; 454 return num_zero_bytes;
434 } 455 }
435 } // namespace RtpUtility 456 } // namespace RtpUtility
436 } // namespace webrtc 457 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698