asapersson@webrtc.org | 0f2809a | 2014-02-21 08:14:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "webrtc/test/rtcp_packet_parser.h" |
| 12 | |
| 13 | namespace webrtc { |
| 14 | namespace test { |
| 15 | |
| 16 | RtcpPacketParser::RtcpPacketParser() {} |
| 17 | |
| 18 | RtcpPacketParser::~RtcpPacketParser() {} |
| 19 | |
| 20 | void RtcpPacketParser::Parse(const void *data, int len) { |
| 21 | const uint8_t* packet = static_cast<const uint8_t*>(data); |
| 22 | RTCPUtility::RTCPParserV2 parser(packet, len, true); |
| 23 | for (RTCPUtility::RTCPPacketTypes type = parser.Begin(); |
| 24 | type != RTCPUtility::kRtcpNotValidCode; |
| 25 | type = parser.Iterate()) { |
| 26 | if (type == RTCPUtility::kRtcpSrCode) { |
| 27 | sender_report_.Set(parser.Packet().SR); |
| 28 | } else if (type == RTCPUtility::kRtcpRrCode) { |
| 29 | receiver_report_.Set(parser.Packet().RR); |
| 30 | } else if (type == RTCPUtility::kRtcpByeCode) { |
| 31 | bye_.Set(parser.Packet().BYE); |
| 32 | } else if (type == RTCPUtility::kRtcpReportBlockItemCode) { |
| 33 | report_block_.Set(parser.Packet().ReportBlockItem); |
| 34 | ++report_blocks_per_ssrc_[parser.Packet().ReportBlockItem.SSRC]; |
| 35 | } else if (type == RTCPUtility::kRtcpPsfbFirCode) { |
| 36 | fir_.Set(parser.Packet().FIR); |
| 37 | } else if (type == webrtc::RTCPUtility::kRtcpPsfbFirItemCode) { |
| 38 | fir_item_.Set(parser.Packet().FIRItem); |
| 39 | } else if (type == RTCPUtility::kRtcpRtpfbNackCode) { |
| 40 | nack_.Set(parser.Packet().NACK); |
| 41 | } else if (type == RTCPUtility::kRtcpRtpfbNackItemCode) { |
| 42 | nack_item_.Set(parser.Packet().NACKItem); |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | } // namespace test |
| 47 | } // namespace webrtc |