niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_UTILITY_H_ |
| 12 | #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_UTILITY_H_ |
| 13 | |
pbos@webrtc.org | 12dc1a3 | 2013-08-05 16:22:53 +0000 | [diff] [blame] | 14 | #include <stddef.h> // size_t, ptrdiff_t |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
pbos@webrtc.org | a048d7c | 2013-05-29 14:27:38 +0000 | [diff] [blame] | 16 | #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" |
| 17 | #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
| 18 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | namespace RTCPUtility { |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 22 | uint32_t MidNtp(uint32_t ntp_sec, uint32_t ntp_frac); |
| 23 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | // CNAME |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 25 | struct RTCPCnameInformation |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | { |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 27 | char name[RTCP_CNAME_SIZE]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | struct RTCPPacketRR |
| 30 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 31 | uint32_t SenderSSRC; |
| 32 | uint8_t NumberOfReportBlocks; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | }; |
| 34 | struct RTCPPacketSR |
| 35 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 36 | uint32_t SenderSSRC; |
| 37 | uint8_t NumberOfReportBlocks; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
| 39 | // sender info |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 40 | uint32_t NTPMostSignificant; |
| 41 | uint32_t NTPLeastSignificant; |
| 42 | uint32_t RTPTimestamp; |
| 43 | uint32_t SenderPacketCount; |
| 44 | uint32_t SenderOctetCount; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | }; |
| 46 | struct RTCPPacketReportBlockItem |
| 47 | { |
| 48 | // report block |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 49 | uint32_t SSRC; |
| 50 | uint8_t FractionLost; |
| 51 | uint32_t CumulativeNumOfPacketsLost; |
| 52 | uint32_t ExtendedHighestSequenceNumber; |
| 53 | uint32_t Jitter; |
| 54 | uint32_t LastSR; |
| 55 | uint32_t DelayLastSR; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | struct RTCPPacketSDESCName |
| 58 | { |
| 59 | // RFC3550 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 60 | uint32_t SenderSSRC; |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 61 | char CName[RTCP_CNAME_SIZE]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 64 | struct RTCPPacketExtendedJitterReportItem |
| 65 | { |
| 66 | // RFC 5450 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 67 | uint32_t Jitter; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 70 | struct RTCPPacketBYE |
| 71 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 72 | uint32_t SenderSSRC; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | }; |
| 74 | struct RTCPPacketXR |
| 75 | { |
| 76 | // RFC 3611 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 77 | uint32_t OriginatorSSRC; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 78 | }; |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 79 | struct RTCPPacketXRReceiverReferenceTimeItem |
| 80 | { |
| 81 | // RFC 3611 4.4 |
| 82 | uint32_t NTPMostSignificant; |
| 83 | uint32_t NTPLeastSignificant; |
| 84 | }; |
| 85 | struct RTCPPacketXRDLRRReportBlockItem |
| 86 | { |
| 87 | // RFC 3611 4.5 |
| 88 | uint32_t SSRC; |
| 89 | uint32_t LastRR; |
| 90 | uint32_t DelayLastRR; |
| 91 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | struct RTCPPacketXRVOIPMetricItem |
| 93 | { |
| 94 | // RFC 3611 4.7 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 95 | uint32_t SSRC; |
| 96 | uint8_t lossRate; |
| 97 | uint8_t discardRate; |
| 98 | uint8_t burstDensity; |
| 99 | uint8_t gapDensity; |
| 100 | uint16_t burstDuration; |
| 101 | uint16_t gapDuration; |
| 102 | uint16_t roundTripDelay; |
| 103 | uint16_t endSystemDelay; |
| 104 | uint8_t signalLevel; |
| 105 | uint8_t noiseLevel; |
| 106 | uint8_t RERL; |
| 107 | uint8_t Gmin; |
| 108 | uint8_t Rfactor; |
| 109 | uint8_t extRfactor; |
| 110 | uint8_t MOSLQ; |
| 111 | uint8_t MOSCQ; |
| 112 | uint8_t RXconfig; |
| 113 | uint16_t JBnominal; |
| 114 | uint16_t JBmax; |
| 115 | uint16_t JBabsMax; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | struct RTCPPacketRTPFBNACK |
| 119 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 120 | uint32_t SenderSSRC; |
| 121 | uint32_t MediaSSRC; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 122 | }; |
| 123 | struct RTCPPacketRTPFBNACKItem |
| 124 | { |
| 125 | // RFC4585 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 126 | uint16_t PacketID; |
| 127 | uint16_t BitMask; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 128 | }; |
| 129 | |
| 130 | struct RTCPPacketRTPFBTMMBR |
| 131 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 132 | uint32_t SenderSSRC; |
| 133 | uint32_t MediaSSRC; // zero! |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 134 | }; |
| 135 | struct RTCPPacketRTPFBTMMBRItem |
| 136 | { |
| 137 | // RFC5104 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 138 | uint32_t SSRC; |
| 139 | uint32_t MaxTotalMediaBitRate; // In Kbit/s |
| 140 | uint32_t MeasuredOverhead; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | struct RTCPPacketRTPFBTMMBN |
| 144 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 145 | uint32_t SenderSSRC; |
| 146 | uint32_t MediaSSRC; // zero! |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 147 | }; |
| 148 | struct RTCPPacketRTPFBTMMBNItem |
| 149 | { |
| 150 | // RFC5104 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 151 | uint32_t SSRC; // "Owner" |
| 152 | uint32_t MaxTotalMediaBitRate; |
| 153 | uint32_t MeasuredOverhead; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | struct RTCPPacketPSFBFIR |
| 157 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 158 | uint32_t SenderSSRC; |
| 159 | uint32_t MediaSSRC; // zero! |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 160 | }; |
| 161 | struct RTCPPacketPSFBFIRItem |
| 162 | { |
| 163 | // RFC5104 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 164 | uint32_t SSRC; |
| 165 | uint8_t CommandSequenceNumber; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | struct RTCPPacketPSFBPLI |
| 169 | { |
| 170 | // RFC4585 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 171 | uint32_t SenderSSRC; |
| 172 | uint32_t MediaSSRC; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 173 | }; |
| 174 | |
| 175 | struct RTCPPacketPSFBSLI |
| 176 | { |
| 177 | // RFC4585 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 178 | uint32_t SenderSSRC; |
| 179 | uint32_t MediaSSRC; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 180 | }; |
| 181 | struct RTCPPacketPSFBSLIItem |
| 182 | { |
| 183 | // RFC4585 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 184 | uint16_t FirstMB; |
| 185 | uint16_t NumberOfMB; |
| 186 | uint8_t PictureId; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 187 | }; |
| 188 | struct RTCPPacketPSFBRPSI |
| 189 | { |
| 190 | // RFC4585 |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 191 | uint32_t SenderSSRC; |
| 192 | uint32_t MediaSSRC; |
| 193 | uint8_t PayloadType; |
| 194 | uint16_t NumberOfValidBits; |
| 195 | uint8_t NativeBitString[RTCP_RPSI_DATA_SIZE]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 196 | }; |
asapersson@webrtc.org | a768970 | 2012-04-19 07:01:29 +0000 | [diff] [blame] | 197 | struct RTCPPacketPSFBAPP |
| 198 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 199 | uint32_t SenderSSRC; |
| 200 | uint32_t MediaSSRC; |
asapersson@webrtc.org | a768970 | 2012-04-19 07:01:29 +0000 | [diff] [blame] | 201 | }; |
| 202 | struct RTCPPacketPSFBREMBItem |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 203 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 204 | uint32_t BitRate; |
| 205 | uint8_t NumberOfSSRCs; |
| 206 | uint32_t SSRCs[MAX_NUMBER_OF_REMB_FEEDBACK_SSRCS]; |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 207 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 208 | // generic name APP |
| 209 | struct RTCPPacketAPP |
| 210 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 211 | uint8_t SubType; |
| 212 | uint32_t Name; |
| 213 | uint8_t Data[kRtcpAppCode_DATA_SIZE]; |
| 214 | uint16_t Size; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 215 | }; |
| 216 | |
| 217 | union RTCPPacket |
| 218 | { |
| 219 | RTCPPacketRR RR; |
| 220 | RTCPPacketSR SR; |
| 221 | RTCPPacketReportBlockItem ReportBlockItem; |
| 222 | |
| 223 | RTCPPacketSDESCName CName; |
| 224 | RTCPPacketBYE BYE; |
| 225 | |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 226 | RTCPPacketExtendedJitterReportItem ExtendedJitterReportItem; |
| 227 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 228 | RTCPPacketRTPFBNACK NACK; |
| 229 | RTCPPacketRTPFBNACKItem NACKItem; |
| 230 | |
| 231 | RTCPPacketPSFBPLI PLI; |
| 232 | RTCPPacketPSFBSLI SLI; |
| 233 | RTCPPacketPSFBSLIItem SLIItem; |
| 234 | RTCPPacketPSFBRPSI RPSI; |
asapersson@webrtc.org | a768970 | 2012-04-19 07:01:29 +0000 | [diff] [blame] | 235 | RTCPPacketPSFBAPP PSFBAPP; |
| 236 | RTCPPacketPSFBREMBItem REMBItem; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 237 | |
| 238 | RTCPPacketRTPFBTMMBR TMMBR; |
| 239 | RTCPPacketRTPFBTMMBRItem TMMBRItem; |
| 240 | RTCPPacketRTPFBTMMBN TMMBN; |
| 241 | RTCPPacketRTPFBTMMBNItem TMMBNItem; |
| 242 | RTCPPacketPSFBFIR FIR; |
| 243 | RTCPPacketPSFBFIRItem FIRItem; |
| 244 | |
| 245 | RTCPPacketXR XR; |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 246 | RTCPPacketXRReceiverReferenceTimeItem XRReceiverReferenceTimeItem; |
| 247 | RTCPPacketXRDLRRReportBlockItem XRDLRRReportBlockItem; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 248 | RTCPPacketXRVOIPMetricItem XRVOIPMetricItem; |
| 249 | |
| 250 | RTCPPacketAPP APP; |
| 251 | }; |
| 252 | |
| 253 | enum RTCPPacketTypes |
| 254 | { |
| 255 | kRtcpNotValidCode, |
| 256 | |
| 257 | // RFC3550 |
| 258 | kRtcpRrCode, |
| 259 | kRtcpSrCode, |
| 260 | kRtcpReportBlockItemCode, |
| 261 | |
| 262 | kRtcpSdesCode, |
| 263 | kRtcpSdesChunkCode, |
| 264 | kRtcpByeCode, |
| 265 | |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 266 | // RFC5450 |
| 267 | kRtcpExtendedIjCode, |
| 268 | kRtcpExtendedIjItemCode, |
| 269 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 270 | // RFC4585 |
| 271 | kRtcpRtpfbNackCode, |
| 272 | kRtcpRtpfbNackItemCode, |
| 273 | |
| 274 | kRtcpPsfbPliCode, |
| 275 | kRtcpPsfbRpsiCode, |
| 276 | kRtcpPsfbSliCode, |
| 277 | kRtcpPsfbSliItemCode, |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 278 | kRtcpPsfbAppCode, |
asapersson@webrtc.org | a768970 | 2012-04-19 07:01:29 +0000 | [diff] [blame] | 279 | kRtcpPsfbRembCode, |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 280 | kRtcpPsfbRembItemCode, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 281 | |
| 282 | // RFC5104 |
| 283 | kRtcpRtpfbTmmbrCode, |
| 284 | kRtcpRtpfbTmmbrItemCode, |
| 285 | kRtcpRtpfbTmmbnCode, |
| 286 | kRtcpRtpfbTmmbnItemCode, |
| 287 | kRtcpPsfbFirCode, |
| 288 | kRtcpPsfbFirItemCode, |
| 289 | |
| 290 | // draft-perkins-avt-rapid-rtp-sync |
| 291 | kRtcpRtpfbSrReqCode, |
| 292 | |
| 293 | // RFC 3611 |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 294 | kRtcpXrHeaderCode, |
| 295 | kRtcpXrReceiverReferenceTimeCode, |
| 296 | kRtcpXrDlrrReportBlockCode, |
| 297 | kRtcpXrDlrrReportBlockItemCode, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 298 | kRtcpXrVoipMetricCode, |
| 299 | |
| 300 | kRtcpAppCode, |
| 301 | kRtcpAppItemCode, |
| 302 | }; |
| 303 | |
| 304 | struct RTCPRawPacket |
| 305 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 306 | const uint8_t* _ptrPacketBegin; |
| 307 | const uint8_t* _ptrPacketEnd; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 308 | }; |
| 309 | |
| 310 | struct RTCPModRawPacket |
| 311 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 312 | uint8_t* _ptrPacketBegin; |
| 313 | uint8_t* _ptrPacketEnd; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 314 | }; |
| 315 | |
| 316 | struct RTCPCommonHeader |
| 317 | { |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 318 | uint8_t V; // Version |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 319 | bool P; // Padding |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 320 | uint8_t IC; // Item count/subtype |
| 321 | uint8_t PT; // Packet Type |
| 322 | uint16_t LengthInOctets; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 323 | }; |
| 324 | |
| 325 | enum RTCPPT |
| 326 | { |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 327 | PT_IJ = 195, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 328 | PT_SR = 200, |
| 329 | PT_RR = 201, |
| 330 | PT_SDES = 202, |
| 331 | PT_BYE = 203, |
| 332 | PT_APP = 204, |
| 333 | PT_RTPFB = 205, |
| 334 | PT_PSFB = 206, |
| 335 | PT_XR = 207 |
| 336 | }; |
| 337 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 338 | bool RTCPParseCommonHeader( const uint8_t* ptrDataBegin, |
| 339 | const uint8_t* ptrDataEnd, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 340 | RTCPCommonHeader& parsedHeader); |
| 341 | |
| 342 | class RTCPParserV2 |
| 343 | { |
| 344 | public: |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 345 | RTCPParserV2(const uint8_t* rtcpData, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 346 | size_t rtcpDataLength, |
| 347 | bool rtcpReducedSizeEnable); // Set to true, to allow non-compound RTCP! |
| 348 | ~RTCPParserV2(); |
| 349 | |
| 350 | RTCPPacketTypes PacketType() const; |
| 351 | const RTCPPacket& Packet() const; |
| 352 | const RTCPRawPacket& RawPacket() const; |
| 353 | ptrdiff_t LengthLeft() const; |
| 354 | |
| 355 | bool IsValid() const; |
| 356 | |
| 357 | RTCPPacketTypes Begin(); |
| 358 | RTCPPacketTypes Iterate(); |
| 359 | |
| 360 | private: |
| 361 | enum ParseState |
| 362 | { |
| 363 | State_TopLevel, // Top level packet |
| 364 | State_ReportBlockItem, // SR/RR report block |
| 365 | State_SDESChunk, // SDES chunk |
| 366 | State_BYEItem, // BYE item |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 367 | State_ExtendedJitterItem, // Extended jitter report item |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 368 | State_RTPFB_NACKItem, // NACK FCI item |
| 369 | State_RTPFB_TMMBRItem, // TMMBR FCI item |
| 370 | State_RTPFB_TMMBNItem, // TMMBN FCI item |
| 371 | State_PSFB_SLIItem, // SLI FCI item |
| 372 | State_PSFB_RPSIItem, // RPSI FCI item |
| 373 | State_PSFB_FIRItem, // FIR FCI item |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 374 | State_PSFB_AppItem, // Application specific FCI item |
| 375 | State_PSFB_REMBItem, // Application specific REMB item |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 376 | State_XRItem, |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 377 | State_XR_DLLRItem, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 378 | State_AppItem |
| 379 | }; |
| 380 | |
| 381 | private: |
| 382 | void IterateTopLevel(); |
| 383 | void IterateReportBlockItem(); |
| 384 | void IterateSDESChunk(); |
| 385 | void IterateBYEItem(); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 386 | void IterateExtendedJitterItem(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 387 | void IterateNACKItem(); |
| 388 | void IterateTMMBRItem(); |
| 389 | void IterateTMMBNItem(); |
| 390 | void IterateSLIItem(); |
| 391 | void IterateRPSIItem(); |
| 392 | void IterateFIRItem(); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 393 | void IteratePsfbAppItem(); |
| 394 | void IteratePsfbREMBItem(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 395 | void IterateAppItem(); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 396 | void IterateXrItem(); |
| 397 | void IterateXrDlrrItem(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 398 | |
| 399 | void Validate(); |
| 400 | void EndCurrentBlock(); |
| 401 | |
| 402 | bool ParseRR(); |
| 403 | bool ParseSR(); |
| 404 | bool ParseReportBlockItem(); |
| 405 | |
| 406 | bool ParseSDES(); |
| 407 | bool ParseSDESChunk(); |
| 408 | bool ParseSDESItem(); |
| 409 | |
| 410 | bool ParseBYE(); |
| 411 | bool ParseBYEItem(); |
| 412 | |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 413 | bool ParseIJ(); |
| 414 | bool ParseIJItem(); |
| 415 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 416 | bool ParseXR(); |
| 417 | bool ParseXRItem(); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 418 | bool ParseXRReceiverReferenceTimeItem(); |
| 419 | bool ParseXRDLRRReportBlockItem(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 420 | bool ParseXRVOIPMetricItem(); |
| 421 | |
| 422 | bool ParseFBCommon(const RTCPCommonHeader& header); |
| 423 | bool ParseNACKItem(); |
| 424 | bool ParseTMMBRItem(); |
| 425 | bool ParseTMMBNItem(); |
| 426 | bool ParseSLIItem(); |
| 427 | bool ParseRPSIItem(); |
| 428 | bool ParseFIRItem(); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 429 | bool ParsePsfbAppItem(); |
| 430 | bool ParsePsfbREMBItem(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 431 | |
| 432 | bool ParseAPP(const RTCPCommonHeader& header); |
| 433 | bool ParseAPPItem(); |
| 434 | |
| 435 | private: |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 436 | const uint8_t* const _ptrRTCPDataBegin; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 437 | const bool _RTCPReducedSizeEnable; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 438 | const uint8_t* const _ptrRTCPDataEnd; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 439 | |
| 440 | bool _validPacket; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 441 | const uint8_t* _ptrRTCPData; |
| 442 | const uint8_t* _ptrRTCPBlockEnd; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 443 | |
| 444 | ParseState _state; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 445 | uint8_t _numberOfBlocks; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 446 | |
| 447 | RTCPPacketTypes _packetType; |
| 448 | RTCPPacket _packet; |
| 449 | }; |
| 450 | |
| 451 | class RTCPPacketIterator |
| 452 | { |
| 453 | public: |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 454 | RTCPPacketIterator(uint8_t* rtcpData, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 455 | size_t rtcpDataLength); |
| 456 | ~RTCPPacketIterator(); |
| 457 | |
| 458 | const RTCPCommonHeader* Begin(); |
| 459 | const RTCPCommonHeader* Iterate(); |
| 460 | const RTCPCommonHeader* Current(); |
| 461 | |
| 462 | private: |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 463 | uint8_t* const _ptrBegin; |
| 464 | uint8_t* const _ptrEnd; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 465 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 466 | uint8_t* _ptrBlock; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 467 | |
| 468 | RTCPCommonHeader _header; |
| 469 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 470 | } // RTCPUtility |
| 471 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 472 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_UTILITY_H_ |