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

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

Issue 2491273002: Cleanup RtpHeaderExtensionMap removing use of two legacy functions (Closed)
Patch Set: rebase Created 4 years, 1 month 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
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_header_parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 return; 324 return;
325 } 325 }
326 326
327 if (ptrRTPDataExtensionEnd - ptr < (len + 1)) { 327 if (ptrRTPDataExtensionEnd - ptr < (len + 1)) {
328 LOG(LS_WARNING) << "Incorrect one-byte extension len: " << (len + 1) 328 LOG(LS_WARNING) << "Incorrect one-byte extension len: " << (len + 1)
329 << ", bytes left in buffer: " 329 << ", bytes left in buffer: "
330 << (ptrRTPDataExtensionEnd - ptr); 330 << (ptrRTPDataExtensionEnd - ptr);
331 return; 331 return;
332 } 332 }
333 333
334 RTPExtensionType type; 334 RTPExtensionType type = ptrExtensionMap->GetType(id);
335 if (ptrExtensionMap->GetType(id, &type) != 0) { 335 if (type == RtpHeaderExtensionMap::kInvalidType) {
336 // If we encounter an unknown extension, just skip over it. 336 // If we encounter an unknown extension, just skip over it.
337 LOG(LS_WARNING) << "Failed to find extension id: " << id; 337 LOG(LS_WARNING) << "Failed to find extension id: " << id;
338 } else { 338 } else {
339 switch (type) { 339 switch (type) {
340 case kRtpExtensionTransmissionTimeOffset: { 340 case kRtpExtensionTransmissionTimeOffset: {
341 if (len != 2) { 341 if (len != 2) {
342 LOG(LS_WARNING) << "Incorrect transmission time offset len: " 342 LOG(LS_WARNING) << "Incorrect transmission time offset len: "
343 << len; 343 << len;
344 return; 344 return;
345 } 345 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 432 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
433 433
434 int min_playout_delay = (ptr[0] << 4) | ((ptr[1] >> 4) & 0xf); 434 int min_playout_delay = (ptr[0] << 4) | ((ptr[1] >> 4) & 0xf);
435 int max_playout_delay = ((ptr[1] & 0xf) << 8) | ptr[2]; 435 int max_playout_delay = ((ptr[1] & 0xf) << 8) | ptr[2];
436 header->extension.playout_delay.min_ms = 436 header->extension.playout_delay.min_ms =
437 min_playout_delay * kPlayoutDelayGranularityMs; 437 min_playout_delay * kPlayoutDelayGranularityMs;
438 header->extension.playout_delay.max_ms = 438 header->extension.playout_delay.max_ms =
439 max_playout_delay * kPlayoutDelayGranularityMs; 439 max_playout_delay * kPlayoutDelayGranularityMs;
440 break; 440 break;
441 } 441 }
442 default: { 442 case kRtpExtensionNone:
443 LOG(LS_WARNING) << "Extension type not implemented: " << type; 443 case kRtpExtensionNumberOfExtensions: {
444 RTC_NOTREACHED() << "Invalid extension type: " << type;
444 return; 445 return;
445 } 446 }
446 } 447 }
447 } 448 }
448 ptr += (len + 1); 449 ptr += (len + 1);
449 uint8_t num_bytes = ParsePaddingBytes(ptrRTPDataExtensionEnd, ptr); 450 uint8_t num_bytes = ParsePaddingBytes(ptrRTPDataExtensionEnd, ptr);
450 ptr += num_bytes; 451 ptr += num_bytes;
451 } 452 }
452 } 453 }
453 454
454 uint8_t RtpHeaderParser::ParsePaddingBytes( 455 uint8_t RtpHeaderParser::ParsePaddingBytes(
455 const uint8_t* ptrRTPDataExtensionEnd, 456 const uint8_t* ptrRTPDataExtensionEnd,
456 const uint8_t* ptr) const { 457 const uint8_t* ptr) const {
457 uint8_t num_zero_bytes = 0; 458 uint8_t num_zero_bytes = 0;
458 while (ptrRTPDataExtensionEnd - ptr > 0) { 459 while (ptrRTPDataExtensionEnd - ptr > 0) {
459 if (*ptr != 0) { 460 if (*ptr != 0) {
460 return num_zero_bytes; 461 return num_zero_bytes;
461 } 462 }
462 ptr++; 463 ptr++;
463 num_zero_bytes++; 464 num_zero_bytes++;
464 } 465 }
465 return num_zero_bytes; 466 return num_zero_bytes;
466 } 467 }
467 } // namespace RtpUtility 468 } // namespace RtpUtility
468 } // namespace webrtc 469 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_header_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698