2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-24 17:16:59 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-08-05 16:22:53 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
#include <math.h> // ceil
|
|
|
|
|
#include <string.h> // memcpy
|
2011-08-29 15:37:12 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
#if defined(_WIN32)
|
2013-05-29 14:27:38 +00:00
|
|
|
// Order for these headers are important
|
2012-02-08 23:41:49 +00:00
|
|
|
#include <Windows.h> // FILETIME
|
2013-05-29 14:27:38 +00:00
|
|
|
|
2012-02-08 23:41:49 +00:00
|
|
|
#include <WinSock.h> // timeval
|
2013-05-29 14:27:38 +00:00
|
|
|
|
2012-02-08 23:41:49 +00:00
|
|
|
#include <MMSystem.h> // timeGetTime
|
2011-07-07 08:21:25 +00:00
|
|
|
#elif ((defined WEBRTC_LINUX) || (defined WEBRTC_MAC))
|
2012-02-08 23:41:49 +00:00
|
|
|
#include <sys/time.h> // gettimeofday
|
|
|
|
|
#include <time.h>
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
#if (defined(_DEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
|
|
|
|
|
#include <stdio.h>
|
2012-02-08 23:41:49 +00:00
|
|
|
#endif
|
|
|
|
|
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/system_wrappers/interface/tick_util.h"
|
2014-04-08 11:06:12 +00:00
|
|
|
#include "webrtc/system_wrappers/interface/logging.h"
|
2012-02-08 23:41:49 +00:00
|
|
|
|
|
|
|
|
#if (defined(_DEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
|
|
|
|
|
#define DEBUG_PRINT(...) \
|
|
|
|
|
{ \
|
|
|
|
|
char msg[256]; \
|
|
|
|
|
sprintf(msg, __VA_ARGS__); \
|
2011-07-07 08:21:25 +00:00
|
|
|
OutputDebugString(msg); \
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
#else
|
|
|
|
|
// special fix for visual 2003
|
|
|
|
|
#define DEBUG_PRINT(exp) ((void)0)
|
|
|
|
|
#endif // defined(_DEBUG) && defined(_WIN32)
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
RtpData* NullObjectRtpData() {
|
|
|
|
|
static NullRtpData null_rtp_data;
|
|
|
|
|
return &null_rtp_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtpFeedback* NullObjectRtpFeedback() {
|
|
|
|
|
static NullRtpFeedback null_rtp_feedback;
|
|
|
|
|
return &null_rtp_feedback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtpAudioFeedback* NullObjectRtpAudioFeedback() {
|
|
|
|
|
static NullRtpAudioFeedback null_rtp_audio_feedback;
|
|
|
|
|
return &null_rtp_audio_feedback;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-21 20:58:21 +00:00
|
|
|
ReceiveStatistics* NullObjectReceiveStatistics() {
|
|
|
|
|
static NullReceiveStatistics null_receive_statistics;
|
|
|
|
|
return &null_receive_statistics;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-08 12:10:51 +00:00
|
|
|
namespace RtpUtility {
|
2012-02-08 23:41:49 +00:00
|
|
|
|
2013-03-26 14:02:30 +00:00
|
|
|
enum {
|
2013-06-26 08:36:07 +00:00
|
|
|
kRtcpExpectedVersion = 2,
|
2013-03-26 14:02:30 +00:00
|
|
|
kRtcpMinHeaderLength = 4,
|
2013-06-26 08:36:07 +00:00
|
|
|
kRtcpMinParseLength = 8,
|
|
|
|
|
|
|
|
|
|
kRtpExpectedVersion = 2,
|
|
|
|
|
kRtpMinParseLength = 12
|
2013-03-26 14:02:30 +00:00
|
|
|
};
|
|
|
|
|
|
2011-12-01 15:42:31 +00:00
|
|
|
/*
|
|
|
|
|
* Time routines.
|
|
|
|
|
*/
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t GetCurrentRTP(Clock* clock, uint32_t freq) {
|
2012-02-15 23:54:59 +00:00
|
|
|
const bool use_global_clock = (clock == NULL);
|
2013-01-17 14:01:20 +00:00
|
|
|
Clock* local_clock = clock;
|
2012-02-15 23:54:59 +00:00
|
|
|
if (use_global_clock) {
|
2013-01-17 14:01:20 +00:00
|
|
|
local_clock = Clock::GetRealTimeClock();
|
2012-02-15 23:54:59 +00:00
|
|
|
}
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t secs = 0, frac = 0;
|
2013-01-17 14:01:20 +00:00
|
|
|
local_clock->CurrentNtp(secs, frac);
|
2012-02-15 23:54:59 +00:00
|
|
|
if (use_global_clock) {
|
|
|
|
|
delete local_clock;
|
|
|
|
|
}
|
2012-02-08 23:41:49 +00:00
|
|
|
return ConvertNTPTimeToRTP(secs, frac, freq);
|
2011-12-01 15:42:31 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t ConvertNTPTimeToRTP(uint32_t NTPsec, uint32_t NTPfrac, uint32_t freq) {
|
2012-02-08 23:41:49 +00:00
|
|
|
float ftemp = (float)NTPfrac / (float)NTP_FRAC;
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t tmp = (uint32_t)(ftemp * freq);
|
2012-02-08 23:41:49 +00:00
|
|
|
return NTPsec * freq + tmp;
|
2011-12-01 15:42:31 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-09 14:56:29 +00:00
|
|
|
uint32_t ConvertNTPTimeToMS(uint32_t NTPsec, uint32_t NTPfrac) {
|
|
|
|
|
int freq = 1000;
|
|
|
|
|
float ftemp = (float)NTPfrac / (float)NTP_FRAC;
|
|
|
|
|
uint32_t tmp = (uint32_t)(ftemp * freq);
|
|
|
|
|
uint32_t MStime = NTPsec * freq + tmp;
|
|
|
|
|
return MStime;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-01 15:42:31 +00:00
|
|
|
/*
|
|
|
|
|
* Misc utility routines
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
2012-02-08 23:41:49 +00:00
|
|
|
bool StringCompare(const char* str1, const char* str2,
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint32_t length) {
|
2012-02-08 23:41:49 +00:00
|
|
|
return (_strnicmp(str1, str2, length) == 0) ? true : false;
|
2011-12-01 15:42:31 +00:00
|
|
|
}
|
|
|
|
|
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
|
2012-02-08 23:41:49 +00:00
|
|
|
bool StringCompare(const char* str1, const char* str2,
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint32_t length) {
|
2012-02-08 23:41:49 +00:00
|
|
|
return (strncasecmp(str1, str2, length) == 0) ? true : false;
|
2011-12-01 15:42:31 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/* for RTP/RTCP
|
|
|
|
|
All integer fields are carried in network byte order, that is, most
|
|
|
|
|
significant byte (octet) first. AKA big-endian.
|
|
|
|
|
*/
|
2013-04-08 11:08:41 +00:00
|
|
|
void AssignUWord32ToBuffer(uint8_t* dataBuffer, uint32_t value) {
|
2013-10-22 10:27:23 +00:00
|
|
|
#if defined(WEBRTC_ARCH_LITTLE_ENDIAN)
|
2013-04-08 11:08:41 +00:00
|
|
|
dataBuffer[0] = static_cast<uint8_t>(value >> 24);
|
|
|
|
|
dataBuffer[1] = static_cast<uint8_t>(value >> 16);
|
|
|
|
|
dataBuffer[2] = static_cast<uint8_t>(value >> 8);
|
|
|
|
|
dataBuffer[3] = static_cast<uint8_t>(value);
|
2011-07-07 08:21:25 +00:00
|
|
|
#else
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t* ptr = reinterpret_cast<uint32_t*>(dataBuffer);
|
2012-02-08 23:41:49 +00:00
|
|
|
ptr[0] = value;
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
void AssignUWord24ToBuffer(uint8_t* dataBuffer, uint32_t value) {
|
2013-10-22 10:27:23 +00:00
|
|
|
#if defined(WEBRTC_ARCH_LITTLE_ENDIAN)
|
2013-04-08 11:08:41 +00:00
|
|
|
dataBuffer[0] = static_cast<uint8_t>(value >> 16);
|
|
|
|
|
dataBuffer[1] = static_cast<uint8_t>(value >> 8);
|
|
|
|
|
dataBuffer[2] = static_cast<uint8_t>(value);
|
2011-07-07 08:21:25 +00:00
|
|
|
#else
|
2013-04-08 11:08:41 +00:00
|
|
|
dataBuffer[0] = static_cast<uint8_t>(value);
|
|
|
|
|
dataBuffer[1] = static_cast<uint8_t>(value >> 8);
|
|
|
|
|
dataBuffer[2] = static_cast<uint8_t>(value >> 16);
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
void AssignUWord16ToBuffer(uint8_t* dataBuffer, uint16_t value) {
|
2013-10-22 10:27:23 +00:00
|
|
|
#if defined(WEBRTC_ARCH_LITTLE_ENDIAN)
|
2013-04-08 11:08:41 +00:00
|
|
|
dataBuffer[0] = static_cast<uint8_t>(value >> 8);
|
|
|
|
|
dataBuffer[1] = static_cast<uint8_t>(value);
|
2011-07-07 08:21:25 +00:00
|
|
|
#else
|
2013-04-08 11:08:41 +00:00
|
|
|
uint16_t* ptr = reinterpret_cast<uint16_t*>(dataBuffer);
|
2012-02-08 23:41:49 +00:00
|
|
|
ptr[0] = value;
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint16_t BufferToUWord16(const uint8_t* dataBuffer) {
|
2013-10-22 10:27:23 +00:00
|
|
|
#if defined(WEBRTC_ARCH_LITTLE_ENDIAN)
|
2012-02-08 23:41:49 +00:00
|
|
|
return (dataBuffer[0] << 8) + dataBuffer[1];
|
2011-07-07 08:21:25 +00:00
|
|
|
#else
|
2013-04-08 11:08:41 +00:00
|
|
|
return *reinterpret_cast<const uint16_t*>(dataBuffer);
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t BufferToUWord24(const uint8_t* dataBuffer) {
|
2012-02-08 23:41:49 +00:00
|
|
|
return (dataBuffer[0] << 16) + (dataBuffer[1] << 8) + dataBuffer[2];
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t BufferToUWord32(const uint8_t* dataBuffer) {
|
2013-10-22 10:27:23 +00:00
|
|
|
#if defined(WEBRTC_ARCH_LITTLE_ENDIAN)
|
2012-02-08 23:41:49 +00:00
|
|
|
return (dataBuffer[0] << 24) + (dataBuffer[1] << 16) + (dataBuffer[2] << 8) +
|
|
|
|
|
dataBuffer[3];
|
2011-07-07 08:21:25 +00:00
|
|
|
#else
|
2013-04-08 11:08:41 +00:00
|
|
|
return *reinterpret_cast<const uint32_t*>(dataBuffer);
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-17 14:33:12 +00:00
|
|
|
size_t Word32Align(size_t size) {
|
|
|
|
|
uint32_t remainder = size % 4;
|
|
|
|
|
if (remainder != 0)
|
|
|
|
|
return size + 4 - remainder;
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t pow2(uint8_t exp) {
|
2012-02-08 23:41:49 +00:00
|
|
|
return 1 << exp;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-08 12:10:51 +00:00
|
|
|
RtpHeaderParser::RtpHeaderParser(const uint8_t* rtpData,
|
|
|
|
|
const size_t rtpDataLength)
|
|
|
|
|
: _ptrRTPDataBegin(rtpData),
|
|
|
|
|
_ptrRTPDataEnd(rtpData ? (rtpData + rtpDataLength) : NULL) {
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-08 12:10:51 +00:00
|
|
|
RtpHeaderParser::~RtpHeaderParser() {
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-08 12:10:51 +00:00
|
|
|
bool RtpHeaderParser::RTCP() const {
|
2012-02-08 23:41:49 +00:00
|
|
|
// 72 to 76 is reserved for RTP
|
|
|
|
|
// 77 to 79 is not reserver but they are not assigned we will block them
|
|
|
|
|
// for RTCP 200 SR == marker bit + 72
|
|
|
|
|
// for RTCP 204 APP == marker bit + 76
|
|
|
|
|
/*
|
|
|
|
|
* RTCP
|
|
|
|
|
*
|
|
|
|
|
* FIR full INTRA-frame request 192 [RFC2032] supported
|
|
|
|
|
* NACK negative acknowledgement 193 [RFC2032]
|
|
|
|
|
* IJ Extended inter-arrival jitter report 195 [RFC-ietf-avt-rtp-toff
|
|
|
|
|
* set-07.txt] http://tools.ietf.org/html/draft-ietf-avt-rtp-toffset-07
|
|
|
|
|
* SR sender report 200 [RFC3551] supported
|
|
|
|
|
* RR receiver report 201 [RFC3551] supported
|
|
|
|
|
* SDES source description 202 [RFC3551] supported
|
|
|
|
|
* BYE goodbye 203 [RFC3551] supported
|
|
|
|
|
* APP application-defined 204 [RFC3551] ignored
|
|
|
|
|
* RTPFB Transport layer FB message 205 [RFC4585] supported
|
|
|
|
|
* PSFB Payload-specific FB message 206 [RFC4585] supported
|
|
|
|
|
* XR extended report 207 [RFC3611] supported
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* 205 RFC 5104
|
|
|
|
|
* FMT 1 NACK supported
|
|
|
|
|
* FMT 2 reserved
|
|
|
|
|
* FMT 3 TMMBR supported
|
|
|
|
|
* FMT 4 TMMBN supported
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* 206 RFC 5104
|
|
|
|
|
* FMT 1: Picture Loss Indication (PLI) supported
|
|
|
|
|
* FMT 2: Slice Lost Indication (SLI)
|
|
|
|
|
* FMT 3: Reference Picture Selection Indication (RPSI)
|
|
|
|
|
* FMT 4: Full Intra Request (FIR) Command supported
|
|
|
|
|
* FMT 5: Temporal-Spatial Trade-off Request (TSTR)
|
|
|
|
|
* FMT 6: Temporal-Spatial Trade-off Notification (TSTN)
|
|
|
|
|
* FMT 7: Video Back Channel Message (VBCM)
|
|
|
|
|
* FMT 15: Application layer FB message
|
|
|
|
|
*/
|
|
|
|
|
|
2013-03-26 14:02:30 +00:00
|
|
|
const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin;
|
|
|
|
|
if (length < kRtcpMinHeaderLength) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-02-08 23:41:49 +00:00
|
|
|
|
2015-02-23 21:28:22 +00:00
|
|
|
const uint8_t V = _ptrRTPDataBegin[0] >> 6;
|
2013-03-26 14:02:30 +00:00
|
|
|
if (V != kRtcpExpectedVersion) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-02-08 23:41:49 +00:00
|
|
|
|
2015-02-23 21:28:22 +00:00
|
|
|
const uint8_t payloadType = _ptrRTPDataBegin[1];
|
2012-02-08 23:41:49 +00:00
|
|
|
switch (payloadType) {
|
2011-07-07 08:21:25 +00:00
|
|
|
case 192:
|
2015-02-23 21:28:22 +00:00
|
|
|
return true;
|
2011-07-07 08:21:25 +00:00
|
|
|
case 193:
|
2012-02-08 23:41:49 +00:00
|
|
|
// not supported
|
|
|
|
|
// pass through and check for a potential RTP packet
|
2015-02-23 21:28:22 +00:00
|
|
|
return false;
|
2011-12-16 14:31:37 +00:00
|
|
|
case 195:
|
2011-07-07 08:21:25 +00:00
|
|
|
case 200:
|
|
|
|
|
case 201:
|
|
|
|
|
case 202:
|
|
|
|
|
case 203:
|
|
|
|
|
case 204:
|
|
|
|
|
case 205:
|
|
|
|
|
case 206:
|
|
|
|
|
case 207:
|
2015-02-23 21:28:22 +00:00
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-08 12:10:51 +00:00
|
|
|
bool RtpHeaderParser::ParseRtcp(RTPHeader* header) const {
|
2013-06-26 08:36:07 +00:00
|
|
|
assert(header != NULL);
|
|
|
|
|
|
|
|
|
|
const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin;
|
|
|
|
|
if (length < kRtcpMinParseLength) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint8_t V = _ptrRTPDataBegin[0] >> 6;
|
|
|
|
|
if (V != kRtcpExpectedVersion) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint8_t PT = _ptrRTPDataBegin[1];
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
const size_t len = (_ptrRTPDataBegin[2] << 8) + _ptrRTPDataBegin[3];
|
2013-06-26 08:36:07 +00:00
|
|
|
const uint8_t* ptr = &_ptrRTPDataBegin[4];
|
|
|
|
|
|
|
|
|
|
uint32_t SSRC = *ptr++ << 24;
|
|
|
|
|
SSRC += *ptr++ << 16;
|
|
|
|
|
SSRC += *ptr++ << 8;
|
|
|
|
|
SSRC += *ptr++;
|
|
|
|
|
|
|
|
|
|
header->payloadType = PT;
|
|
|
|
|
header->ssrc = SSRC;
|
|
|
|
|
header->headerLength = 4 + (len << 2);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-08 12:10:51 +00:00
|
|
|
bool RtpHeaderParser::Parse(RTPHeader& header,
|
2012-02-08 23:41:49 +00:00
|
|
|
RtpHeaderExtensionMap* ptrExtensionMap) const {
|
|
|
|
|
const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin;
|
2013-06-26 08:36:07 +00:00
|
|
|
if (length < kRtpMinParseLength) {
|
2012-02-08 23:41:49 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-02-08 23:41:49 +00:00
|
|
|
// Version
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint8_t V = _ptrRTPDataBegin[0] >> 6;
|
2012-02-08 23:41:49 +00:00
|
|
|
// Padding
|
|
|
|
|
const bool P = ((_ptrRTPDataBegin[0] & 0x20) == 0) ? false : true;
|
|
|
|
|
// eXtension
|
|
|
|
|
const bool X = ((_ptrRTPDataBegin[0] & 0x10) == 0) ? false : true;
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint8_t CC = _ptrRTPDataBegin[0] & 0x0f;
|
2012-02-08 23:41:49 +00:00
|
|
|
const bool M = ((_ptrRTPDataBegin[1] & 0x80) == 0) ? false : true;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint8_t PT = _ptrRTPDataBegin[1] & 0x7f;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint16_t sequenceNumber = (_ptrRTPDataBegin[2] << 8) +
|
2012-02-08 23:41:49 +00:00
|
|
|
_ptrRTPDataBegin[3];
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint8_t* ptr = &_ptrRTPDataBegin[4];
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t RTPTimestamp = *ptr++ << 24;
|
2012-02-08 23:41:49 +00:00
|
|
|
RTPTimestamp += *ptr++ << 16;
|
|
|
|
|
RTPTimestamp += *ptr++ << 8;
|
|
|
|
|
RTPTimestamp += *ptr++;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t SSRC = *ptr++ << 24;
|
2012-02-08 23:41:49 +00:00
|
|
|
SSRC += *ptr++ << 16;
|
|
|
|
|
SSRC += *ptr++ << 8;
|
|
|
|
|
SSRC += *ptr++;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-06-26 08:36:07 +00:00
|
|
|
if (V != kRtpExpectedVersion) {
|
2012-02-08 23:41:49 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
const size_t CSRCocts = CC * 4;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-02-08 23:41:49 +00:00
|
|
|
if ((ptr + CSRCocts) > _ptrRTPDataEnd) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-29 12:12:51 +00:00
|
|
|
header.markerBit = M;
|
|
|
|
|
header.payloadType = PT;
|
|
|
|
|
header.sequenceNumber = sequenceNumber;
|
|
|
|
|
header.timestamp = RTPTimestamp;
|
|
|
|
|
header.ssrc = SSRC;
|
|
|
|
|
header.numCSRCs = CC;
|
|
|
|
|
header.paddingLength = P ? *(_ptrRTPDataEnd - 1) : 0;
|
2012-02-08 23:41:49 +00:00
|
|
|
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
for (uint8_t i = 0; i < CC; ++i) {
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t CSRC = *ptr++ << 24;
|
2012-02-08 23:41:49 +00:00
|
|
|
CSRC += *ptr++ << 16;
|
|
|
|
|
CSRC += *ptr++ << 8;
|
|
|
|
|
CSRC += *ptr++;
|
2013-05-29 12:12:51 +00:00
|
|
|
header.arrOfCSRCs[i] = CSRC;
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-29 12:12:51 +00:00
|
|
|
header.headerLength = 12 + CSRCocts;
|
2012-02-08 23:41:49 +00:00
|
|
|
|
|
|
|
|
// If in effect, MAY be omitted for those packets for which the offset
|
|
|
|
|
// is zero.
|
2013-12-16 12:24:44 +00:00
|
|
|
header.extension.hasTransmissionTimeOffset = false;
|
2013-05-29 12:12:51 +00:00
|
|
|
header.extension.transmissionTimeOffset = 0;
|
2012-02-08 23:41:49 +00:00
|
|
|
|
2013-05-16 11:10:31 +00:00
|
|
|
// May not be present in packet.
|
2013-12-16 12:24:44 +00:00
|
|
|
header.extension.hasAbsoluteSendTime = false;
|
2013-05-29 12:12:51 +00:00
|
|
|
header.extension.absoluteSendTime = 0;
|
2013-05-16 11:10:31 +00:00
|
|
|
|
2014-03-06 23:49:08 +00:00
|
|
|
// May not be present in packet.
|
|
|
|
|
header.extension.hasAudioLevel = false;
|
|
|
|
|
header.extension.audioLevel = 0;
|
|
|
|
|
|
2015-03-04 22:55:15 +00:00
|
|
|
// May not be present in packet.
|
|
|
|
|
header.extension.hasVideoRotation = false;
|
|
|
|
|
header.extension.videoRotation = 0;
|
|
|
|
|
|
2012-02-08 23:41:49 +00:00
|
|
|
if (X) {
|
|
|
|
|
/* RTP header extension, RFC 3550.
|
|
|
|
|
0 1 2 3
|
|
|
|
|
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
|
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
| defined by profile | length |
|
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
| header extension |
|
|
|
|
|
| .... |
|
|
|
|
|
*/
|
|
|
|
|
const ptrdiff_t remain = _ptrRTPDataEnd - ptr;
|
|
|
|
|
if (remain < 4) {
|
|
|
|
|
return false;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-29 12:12:51 +00:00
|
|
|
header.headerLength += 4;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint16_t definedByProfile = *ptr++ << 8;
|
2012-02-08 23:41:49 +00:00
|
|
|
definedByProfile += *ptr++;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t XLen = *ptr++ << 8;
|
2012-02-08 23:41:49 +00:00
|
|
|
XLen += *ptr++; // in 32 bit words
|
|
|
|
|
XLen *= 4; // in octs
|
2011-07-07 08:21:25 +00:00
|
|
|
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
if (static_cast<size_t>(remain) < (4 + XLen)) {
|
2012-02-08 23:41:49 +00:00
|
|
|
return false;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2013-05-07 12:36:21 +00:00
|
|
|
if (definedByProfile == kRtpOneByteHeaderExtensionId) {
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint8_t* ptrRTPDataExtensionEnd = ptr + XLen;
|
2013-05-29 12:12:51 +00:00
|
|
|
ParseOneByteExtensionHeader(header,
|
2012-02-08 23:41:49 +00:00
|
|
|
ptrExtensionMap,
|
|
|
|
|
ptrRTPDataExtensionEnd,
|
|
|
|
|
ptr);
|
|
|
|
|
}
|
2013-05-29 12:12:51 +00:00
|
|
|
header.headerLength += XLen;
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
|
|
|
|
return true;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-08 12:10:51 +00:00
|
|
|
void RtpHeaderParser::ParseOneByteExtensionHeader(
|
2013-05-29 12:12:51 +00:00
|
|
|
RTPHeader& header,
|
2011-12-16 14:31:37 +00:00
|
|
|
const RtpHeaderExtensionMap* ptrExtensionMap,
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint8_t* ptrRTPDataExtensionEnd,
|
|
|
|
|
const uint8_t* ptr) const {
|
2012-02-08 23:41:49 +00:00
|
|
|
if (!ptrExtensionMap) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-12-16 14:31:37 +00:00
|
|
|
|
2012-02-08 23:41:49 +00:00
|
|
|
while (ptrRTPDataExtensionEnd - ptr > 0) {
|
|
|
|
|
// 0
|
|
|
|
|
// 0 1 2 3 4 5 6 7
|
|
|
|
|
// +-+-+-+-+-+-+-+-+
|
|
|
|
|
// | ID | len |
|
|
|
|
|
// +-+-+-+-+-+-+-+-+
|
|
|
|
|
|
2014-03-25 19:57:07 +00:00
|
|
|
// Note that 'len' is the header extension element length, which is the
|
|
|
|
|
// number of bytes - 1.
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint8_t id = (*ptr & 0xf0) >> 4;
|
|
|
|
|
const uint8_t len = (*ptr & 0x0f);
|
2012-02-08 23:41:49 +00:00
|
|
|
ptr++;
|
2011-12-16 14:31:37 +00:00
|
|
|
|
2012-02-08 23:41:49 +00:00
|
|
|
if (id == 15) {
|
2014-04-08 11:06:12 +00:00
|
|
|
LOG(LS_WARNING)
|
|
|
|
|
<< "RTP extension header 15 encountered. Terminate parsing.";
|
2012-02-08 23:41:49 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2011-12-16 14:31:37 +00:00
|
|
|
|
2012-02-08 23:41:49 +00:00
|
|
|
RTPExtensionType type;
|
|
|
|
|
if (ptrExtensionMap->GetType(id, &type) != 0) {
|
2014-03-25 19:57:07 +00:00
|
|
|
// If we encounter an unknown extension, just skip over it.
|
2014-04-24 20:33:08 +00:00
|
|
|
LOG(LS_WARNING) << "Failed to find extension id: "
|
|
|
|
|
<< static_cast<int>(id);
|
2014-03-25 19:57:07 +00:00
|
|
|
} else {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case kRtpExtensionTransmissionTimeOffset: {
|
|
|
|
|
if (len != 2) {
|
2014-04-08 11:06:12 +00:00
|
|
|
LOG(LS_WARNING) << "Incorrect transmission time offset len: "
|
|
|
|
|
<< len;
|
2014-03-25 19:57:07 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 0 1 2 3
|
|
|
|
|
// 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
|
|
|
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
// | ID | len=2 | transmission offset |
|
|
|
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
|
|
|
|
|
int32_t transmissionTimeOffset = ptr[0] << 16;
|
|
|
|
|
transmissionTimeOffset += ptr[1] << 8;
|
|
|
|
|
transmissionTimeOffset += ptr[2];
|
|
|
|
|
header.extension.transmissionTimeOffset =
|
|
|
|
|
transmissionTimeOffset;
|
|
|
|
|
if (transmissionTimeOffset & 0x800000) {
|
|
|
|
|
// Negative offset, correct sign for Word24 to Word32.
|
|
|
|
|
header.extension.transmissionTimeOffset |= 0xFF000000;
|
|
|
|
|
}
|
|
|
|
|
header.extension.hasTransmissionTimeOffset = true;
|
|
|
|
|
break;
|
2011-12-16 14:31:37 +00:00
|
|
|
}
|
2014-03-25 19:57:07 +00:00
|
|
|
case kRtpExtensionAudioLevel: {
|
|
|
|
|
if (len != 0) {
|
2014-04-08 11:06:12 +00:00
|
|
|
LOG(LS_WARNING) << "Incorrect audio level len: " << len;
|
2014-03-25 19:57:07 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2015-03-17 14:33:12 +00:00
|
|
|
// 0 1
|
|
|
|
|
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
|
|
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
// | ID | len=0 |V| level |
|
|
|
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
2014-03-25 19:57:07 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// Parse out the fields but only use it for debugging for now.
|
|
|
|
|
// const uint8_t V = (*ptr & 0x80) >> 7;
|
|
|
|
|
// const uint8_t level = (*ptr & 0x7f);
|
|
|
|
|
// DEBUG_PRINT("RTP_AUDIO_LEVEL_UNIQUE_ID: ID=%u, len=%u, V=%u,
|
|
|
|
|
// level=%u", ID, len, V, level);
|
|
|
|
|
|
|
|
|
|
header.extension.audioLevel = ptr[0];
|
|
|
|
|
header.extension.hasAudioLevel = true;
|
|
|
|
|
break;
|
2012-06-28 07:53:15 +00:00
|
|
|
}
|
2014-03-25 19:57:07 +00:00
|
|
|
case kRtpExtensionAbsoluteSendTime: {
|
|
|
|
|
if (len != 2) {
|
2014-04-08 11:06:12 +00:00
|
|
|
LOG(LS_WARNING) << "Incorrect absolute send time len: " << len;
|
2014-03-25 19:57:07 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 0 1 2 3
|
|
|
|
|
// 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
|
|
|
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
// | ID | len=2 | absolute send time |
|
|
|
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
|
|
|
|
|
uint32_t absoluteSendTime = ptr[0] << 16;
|
|
|
|
|
absoluteSendTime += ptr[1] << 8;
|
|
|
|
|
absoluteSendTime += ptr[2];
|
|
|
|
|
header.extension.absoluteSendTime = absoluteSendTime;
|
|
|
|
|
header.extension.hasAbsoluteSendTime = true;
|
|
|
|
|
break;
|
2014-03-06 23:49:08 +00:00
|
|
|
}
|
2015-03-04 22:55:15 +00:00
|
|
|
case kRtpExtensionVideoRotation: {
|
|
|
|
|
if (len != 0) {
|
|
|
|
|
LOG(LS_WARNING)
|
|
|
|
|
<< "Incorrect coordination of video coordination len: " << len;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-03-17 14:33:12 +00:00
|
|
|
// 0 1
|
|
|
|
|
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
|
|
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
// | ID | len=0 |0 0 0 0 C F R R|
|
|
|
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
2015-03-04 22:55:15 +00:00
|
|
|
header.extension.hasVideoRotation = true;
|
|
|
|
|
header.extension.videoRotation = ptr[0];
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-03-17 14:33:12 +00:00
|
|
|
case kRtpExtensionTransportSequenceNumber: {
|
|
|
|
|
if (len != 1) {
|
|
|
|
|
LOG(LS_WARNING)
|
|
|
|
|
<< "Incorrect peer connection sequence number len: " << len;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 0 1 2
|
|
|
|
|
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
|
|
|
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
// | ID | L=1 |transport wide sequence number |
|
|
|
|
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
|
|
|
|
|
uint16_t sequence_number = ptr[0] << 8;
|
|
|
|
|
sequence_number += ptr[1];
|
|
|
|
|
header.extension.transportSequenceNumber = sequence_number;
|
|
|
|
|
header.extension.hasTransportSequenceNumber = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-03-25 19:57:07 +00:00
|
|
|
default: {
|
2014-04-08 11:06:12 +00:00
|
|
|
LOG(LS_WARNING) << "Extension type not implemented: " << type;
|
2013-05-16 11:10:31 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2011-12-16 14:31:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-03-25 19:57:07 +00:00
|
|
|
ptr += (len + 1);
|
2013-04-08 11:08:41 +00:00
|
|
|
uint8_t num_bytes = ParsePaddingBytes(ptrRTPDataExtensionEnd, ptr);
|
2012-02-08 23:41:49 +00:00
|
|
|
ptr += num_bytes;
|
|
|
|
|
}
|
2011-12-16 14:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-08 12:10:51 +00:00
|
|
|
uint8_t RtpHeaderParser::ParsePaddingBytes(
|
|
|
|
|
const uint8_t* ptrRTPDataExtensionEnd,
|
|
|
|
|
const uint8_t* ptr) const {
|
2013-04-08 11:08:41 +00:00
|
|
|
uint8_t num_zero_bytes = 0;
|
2011-12-16 14:31:37 +00:00
|
|
|
while (ptrRTPDataExtensionEnd - ptr > 0) {
|
|
|
|
|
if (*ptr != 0) {
|
|
|
|
|
return num_zero_bytes;
|
|
|
|
|
}
|
|
|
|
|
ptr++;
|
|
|
|
|
num_zero_bytes++;
|
|
|
|
|
}
|
|
|
|
|
return num_zero_bytes;
|
|
|
|
|
}
|
2014-07-08 12:10:51 +00:00
|
|
|
} // namespace RtpUtility
|
2012-02-08 23:41:49 +00:00
|
|
|
|
|
|
|
|
} // namespace webrtc
|