Do basic parsing of RTCP headers in PcapFileReader to enable log filtering.
BUG= R=mflodman@webrtc.org, stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1697004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4266 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -49,8 +49,12 @@ namespace webrtc {
|
||||
namespace ModuleRTPUtility {
|
||||
|
||||
enum {
|
||||
kRtcpExpectedVersion = 2,
|
||||
kRtcpMinHeaderLength = 4,
|
||||
kRtcpExpectedVersion = 2
|
||||
kRtcpMinParseLength = 8,
|
||||
|
||||
kRtpExpectedVersion = 2,
|
||||
kRtpMinParseLength = 12
|
||||
};
|
||||
|
||||
/*
|
||||
@ -291,11 +295,39 @@ bool RTPHeaderParser::RTCP() const {
|
||||
return RTCP;
|
||||
}
|
||||
|
||||
bool RTPHeaderParser::ParseRtcp(RTPHeader* header) const {
|
||||
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];
|
||||
const uint16_t len = (_ptrRTPDataBegin[2] << 8) + _ptrRTPDataBegin[3];
|
||||
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;
|
||||
}
|
||||
|
||||
bool RTPHeaderParser::Parse(RTPHeader& header,
|
||||
RtpHeaderExtensionMap* ptrExtensionMap) const {
|
||||
const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin;
|
||||
|
||||
if (length < 12) {
|
||||
if (length < kRtpMinParseLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -325,7 +357,7 @@ bool RTPHeaderParser::Parse(RTPHeader& header,
|
||||
SSRC += *ptr++ << 8;
|
||||
SSRC += *ptr++;
|
||||
|
||||
if (V != 2) {
|
||||
if (V != kRtpExpectedVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user