2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
11 #include "webrtc/test/rtcp_packet_parser.h"
16 RtcpPacketParser::RtcpPacketParser() {}
18 RtcpPacketParser::~RtcpPacketParser() {}
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()) {
27 case RTCPUtility::kRtcpSrCode:
28 sender_report_.Set(parser.Packet().SR);
30 case RTCPUtility::kRtcpRrCode:
31 receiver_report_.Set(parser.Packet().RR);
33 case RTCPUtility::kRtcpReportBlockItemCode:
34 report_block_.Set(parser.Packet().ReportBlockItem);
35 ++report_blocks_per_ssrc_[parser.Packet().ReportBlockItem.SSRC];
37 case RTCPUtility::kRtcpSdesCode:
40 case RTCPUtility::kRtcpSdesChunkCode:
41 sdes_chunk_.Set(parser.Packet().CName);
43 case RTCPUtility::kRtcpByeCode:
44 bye_.Set(parser.Packet().BYE);
46 case RTCPUtility::kRtcpAppCode:
47 app_.Set(parser.Packet().APP);
49 case RTCPUtility::kRtcpAppItemCode:
50 app_item_.Set(parser.Packet().APP);
52 case RTCPUtility::kRtcpExtendedIjCode:
55 case RTCPUtility::kRtcpExtendedIjItemCode:
56 ij_item_.Set(parser.Packet().ExtendedJitterReportItem);
58 case RTCPUtility::kRtcpPsfbPliCode:
59 pli_.Set(parser.Packet().PLI);
61 case RTCPUtility::kRtcpPsfbSliCode:
62 sli_.Set(parser.Packet().SLI);
64 case RTCPUtility::kRtcpPsfbSliItemCode:
65 sli_item_.Set(parser.Packet().SLIItem);
67 case RTCPUtility::kRtcpPsfbRpsiCode:
68 rpsi_.Set(parser.Packet().RPSI);
70 case RTCPUtility::kRtcpPsfbFirCode:
71 fir_.Set(parser.Packet().FIR);
73 case RTCPUtility::kRtcpPsfbFirItemCode:
74 fir_item_.Set(parser.Packet().FIRItem);
76 case RTCPUtility::kRtcpRtpfbNackCode:
77 nack_.Set(parser.Packet().NACK);
80 case RTCPUtility::kRtcpRtpfbNackItemCode:
81 nack_item_.Set(parser.Packet().NACKItem);
89 uint64_t Rpsi::PictureId() const {
90 assert(num_packets_ > 0);
91 uint16_t num_bytes = rpsi_.NumberOfValidBits / 8;
92 assert(num_bytes > 0);
93 uint64_t picture_id = 0;
94 for (uint16_t i = 0; i < num_bytes - 1; ++i) {
95 picture_id += (rpsi_.NativeBitString[i] & 0x7f);
98 picture_id += (rpsi_.NativeBitString[num_bytes - 1] & 0x7f);
103 } // namespace webrtc