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

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

Issue 1888793003: Fixed undefined shift in parsing Tmmbr, Tmmbn and Remb (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | 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 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 } 1440 }
1441 1441
1442 _packet.REMBItem.NumberOfSSRCs = *_ptrRTCPData++; 1442 _packet.REMBItem.NumberOfSSRCs = *_ptrRTCPData++;
1443 const uint8_t brExp = (_ptrRTCPData[0] >> 2) & 0x3F; 1443 const uint8_t brExp = (_ptrRTCPData[0] >> 2) & 0x3F;
1444 1444
1445 uint32_t brMantissa = (_ptrRTCPData[0] & 0x03) << 16; 1445 uint32_t brMantissa = (_ptrRTCPData[0] & 0x03) << 16;
1446 brMantissa += (_ptrRTCPData[1] << 8); 1446 brMantissa += (_ptrRTCPData[1] << 8);
1447 brMantissa += (_ptrRTCPData[2]); 1447 brMantissa += (_ptrRTCPData[2]);
1448 1448
1449 _ptrRTCPData += 3; // Fwd read data 1449 _ptrRTCPData += 3; // Fwd read data
1450 if (brExp >= 32) {
1451 _state = ParseState::State_TopLevel;
1452 EndCurrentBlock();
1453 return false;
1454 }
1450 _packet.REMBItem.BitRate = (brMantissa << brExp); 1455 _packet.REMBItem.BitRate = (brMantissa << brExp);
åsapersson 2016/04/18 09:51:47 Might give an incorrect bitrate if brExp > 14, rig
danilchap 2016/04/18 10:41:42 Yes, it can. Updated code to be stricter about uns
1451 1456
1452 const ptrdiff_t length_ssrcs = _ptrRTCPBlockEnd - _ptrRTCPData; 1457 const ptrdiff_t length_ssrcs = _ptrRTCPBlockEnd - _ptrRTCPData;
1453 if (length_ssrcs < 4 * _packet.REMBItem.NumberOfSSRCs) 1458 if (length_ssrcs < 4 * _packet.REMBItem.NumberOfSSRCs)
1454 { 1459 {
1455 _state = ParseState::State_TopLevel; 1460 _state = ParseState::State_TopLevel;
1456 1461
1457 EndCurrentBlock(); 1462 EndCurrentBlock();
1458 return false; 1463 return false;
1459 } 1464 }
1460 1465
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 1501
1497 uint32_t mxtbrMantissa = (_ptrRTCPData[0] & 0x03) << 15; 1502 uint32_t mxtbrMantissa = (_ptrRTCPData[0] & 0x03) << 15;
1498 mxtbrMantissa += (_ptrRTCPData[1] << 7); 1503 mxtbrMantissa += (_ptrRTCPData[1] << 7);
1499 mxtbrMantissa += (_ptrRTCPData[2] >> 1) & 0x7F; 1504 mxtbrMantissa += (_ptrRTCPData[2] >> 1) & 0x7F;
1500 1505
1501 uint32_t measuredOH = (_ptrRTCPData[2] & 0x01) << 8; 1506 uint32_t measuredOH = (_ptrRTCPData[2] & 0x01) << 8;
1502 measuredOH += _ptrRTCPData[3]; 1507 measuredOH += _ptrRTCPData[3];
1503 1508
1504 _ptrRTCPData += 4; // Fwd read data 1509 _ptrRTCPData += 4; // Fwd read data
1505 1510
1511 if (mxtbrExp >= 32) {
1512 _state = ParseState::State_TopLevel;
1513 EndCurrentBlock();
1514 return false;
1515 }
1516
1506 _packet.TMMBRItem.MaxTotalMediaBitRate = ((mxtbrMantissa << mxtbrExp) / 1000 ); 1517 _packet.TMMBRItem.MaxTotalMediaBitRate = ((mxtbrMantissa << mxtbrExp) / 1000 );
1507 _packet.TMMBRItem.MeasuredOverhead = measuredOH; 1518 _packet.TMMBRItem.MeasuredOverhead = measuredOH;
1508 1519
1509 return true; 1520 return true;
1510 } 1521 }
1511 1522
1512 bool 1523 bool
1513 RTCPUtility::RTCPParserV2::ParseTMMBNItem() 1524 RTCPUtility::RTCPParserV2::ParseTMMBNItem()
1514 { 1525 {
1515 // RFC 5104 4.2.2. Temporary Maximum Media Stream Bit Rate Notification (TMM BN) 1526 // RFC 5104 4.2.2. Temporary Maximum Media Stream Bit Rate Notification (TMM BN)
(...skipping 19 matching lines...) Expand all
1535 1546
1536 uint32_t mxtbrMantissa = (_ptrRTCPData[0] & 0x03) << 15; 1547 uint32_t mxtbrMantissa = (_ptrRTCPData[0] & 0x03) << 15;
1537 mxtbrMantissa += (_ptrRTCPData[1] << 7); 1548 mxtbrMantissa += (_ptrRTCPData[1] << 7);
1538 mxtbrMantissa += (_ptrRTCPData[2] >> 1) & 0x7F; 1549 mxtbrMantissa += (_ptrRTCPData[2] >> 1) & 0x7F;
1539 1550
1540 uint32_t measuredOH = (_ptrRTCPData[2] & 0x01) << 8; 1551 uint32_t measuredOH = (_ptrRTCPData[2] & 0x01) << 8;
1541 measuredOH += _ptrRTCPData[3]; 1552 measuredOH += _ptrRTCPData[3];
1542 1553
1543 _ptrRTCPData += 4; // Fwd read data 1554 _ptrRTCPData += 4; // Fwd read data
1544 1555
1556 if (mxtbrExp >= 32) {
1557 _state = ParseState::State_TopLevel;
1558 EndCurrentBlock();
1559 return false;
1560 }
1561
1545 _packet.TMMBNItem.MaxTotalMediaBitRate = ((mxtbrMantissa << mxtbrExp) / 1000 ); 1562 _packet.TMMBNItem.MaxTotalMediaBitRate = ((mxtbrMantissa << mxtbrExp) / 1000 );
1546 _packet.TMMBNItem.MeasuredOverhead = measuredOH; 1563 _packet.TMMBNItem.MeasuredOverhead = measuredOH;
1547 1564
1548 return true; 1565 return true;
1549 } 1566 }
1550 1567
1551 bool 1568 bool
1552 RTCPUtility::RTCPParserV2::ParseSLIItem() 1569 RTCPUtility::RTCPParserV2::ParseSLIItem()
1553 { 1570 {
1554 // RFC 5104 6.3.2. Slice Loss Indication (SLI) 1571 // RFC 5104 6.3.2. Slice Loss Indication (SLI)
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 const RTCPUtility::RtcpCommonHeader* 1728 const RTCPUtility::RtcpCommonHeader*
1712 RTCPUtility::RTCPPacketIterator::Current() { 1729 RTCPUtility::RTCPPacketIterator::Current() {
1713 if (!_ptrBlock) 1730 if (!_ptrBlock)
1714 { 1731 {
1715 return NULL; 1732 return NULL;
1716 } 1733 }
1717 1734
1718 return &_header; 1735 return &_header;
1719 } 1736 }
1720 } // namespace webrtc 1737 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698