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
diff --git a/webrtc/test/rtcp_packet_parser.cc b/webrtc/test/rtcp_packet_parser.cc
index 2e5880e..9ae8543 100644
--- a/webrtc/test/rtcp_packet_parser.cc
+++ b/webrtc/test/rtcp_packet_parser.cc
@@ -23,25 +23,54 @@
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