Add NACK and RPSI packet types to RTCP packet builder.

Fixes bug found when parsing received RPSI packet.

BUG=2450
R=mflodman@webrtc.org, stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/17419004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6194 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
asapersson@webrtc.org
2014-05-20 09:53:51 +00:00
parent 2db9f45038
commit a826006132
6 changed files with 574 additions and 149 deletions

View File

@ -23,25 +23,54 @@ void RtcpPacketParser::Parse(const void *data, int len) {
for (RTCPUtility::RTCPPacketTypes type = parser.Begin();
type != RTCPUtility::kRtcpNotValidCode;
type = parser.Iterate()) {
if (type == RTCPUtility::kRtcpSrCode) {
sender_report_.Set(parser.Packet().SR);
} else if (type == RTCPUtility::kRtcpRrCode) {
receiver_report_.Set(parser.Packet().RR);
} else if (type == RTCPUtility::kRtcpByeCode) {
bye_.Set(parser.Packet().BYE);
} else if (type == RTCPUtility::kRtcpReportBlockItemCode) {
report_block_.Set(parser.Packet().ReportBlockItem);
++report_blocks_per_ssrc_[parser.Packet().ReportBlockItem.SSRC];
} else if (type == RTCPUtility::kRtcpPsfbFirCode) {
fir_.Set(parser.Packet().FIR);
} else if (type == webrtc::RTCPUtility::kRtcpPsfbFirItemCode) {
fir_item_.Set(parser.Packet().FIRItem);
} else if (type == RTCPUtility::kRtcpRtpfbNackCode) {
nack_.Set(parser.Packet().NACK);
} else if (type == RTCPUtility::kRtcpRtpfbNackItemCode) {
nack_item_.Set(parser.Packet().NACKItem);
switch (type) {
case RTCPUtility::kRtcpSrCode:
sender_report_.Set(parser.Packet().SR);
break;
case RTCPUtility::kRtcpRrCode:
receiver_report_.Set(parser.Packet().RR);
break;
case RTCPUtility::kRtcpByeCode:
bye_.Set(parser.Packet().BYE);
break;
case RTCPUtility::kRtcpReportBlockItemCode:
report_block_.Set(parser.Packet().ReportBlockItem);
++report_blocks_per_ssrc_[parser.Packet().ReportBlockItem.SSRC];
break;
case RTCPUtility::kRtcpPsfbRpsiCode:
rpsi_.Set(parser.Packet().RPSI);
break;
case RTCPUtility::kRtcpPsfbFirCode:
fir_.Set(parser.Packet().FIR);
break;
case RTCPUtility::kRtcpPsfbFirItemCode:
fir_item_.Set(parser.Packet().FIRItem);
break;
case RTCPUtility::kRtcpRtpfbNackCode:
nack_.Set(parser.Packet().NACK);
nack_item_.Clear();
break;
case RTCPUtility::kRtcpRtpfbNackItemCode:
nack_item_.Set(parser.Packet().NACKItem);
break;
default:
break;
}
}
}
uint64_t Rpsi::PictureId() const {
assert(num_packets_ > 0);
uint16_t num_bytes = rpsi_.NumberOfValidBits / 8;
assert(num_bytes > 0);
uint64_t picture_id = 0;
for (uint16_t i = 0; i < num_bytes - 1; ++i) {
picture_id += (rpsi_.NativeBitString[i] & 0x7f);
picture_id <<= 7;
}
picture_id += (rpsi_.NativeBitString[num_bytes - 1] & 0x7f);
return picture_id;
}
} // namespace test
} // namespace webrtc