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