Add RTCP packet class.
Adds packet types: sr, rr, bye, fir.
BUG=2450
R=mflodman@webrtc.org, stefan@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/8079004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5592 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/test/rtcp_packet_parser.cc b/webrtc/test/rtcp_packet_parser.cc
new file mode 100644
index 0000000..2e5880e
--- /dev/null
+++ b/webrtc/test/rtcp_packet_parser.cc
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
+ *
+ * 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.
+ */
+
+#include "webrtc/test/rtcp_packet_parser.h"
+
+namespace webrtc {
+namespace test {
+
+RtcpPacketParser::RtcpPacketParser() {}
+
+RtcpPacketParser::~RtcpPacketParser() {}
+
+void RtcpPacketParser::Parse(const void *data, int len) {
+ const uint8_t* packet = static_cast<const uint8_t*>(data);
+ RTCPUtility::RTCPParserV2 parser(packet, len, true);
+ 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);
+ }
+ }
+}
+} // namespace test
+} // namespace webrtc