andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 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 | #ifndef WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RTCP_DEFINES_H_ |
| 12 | #define WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RTCP_DEFINES_H_ |
| 13 | |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 14 | #include <stddef.h> |
stefan@webrtc.org | 7485573 | 2013-09-17 07:49:56 +0000 | [diff] [blame] | 15 | #include <list> |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 16 | |
pbos@webrtc.org | cbd78ae | 2013-05-29 14:27:38 +0000 | [diff] [blame] | 17 | #include "webrtc/modules/interface/module_common_types.h" |
stefan@webrtc.org | 9858fc8 | 2013-01-17 14:01:20 +0000 | [diff] [blame] | 18 | #include "webrtc/system_wrappers/interface/clock.h" |
pbos@webrtc.org | cbd78ae | 2013-05-29 14:27:38 +0000 | [diff] [blame] | 19 | #include "webrtc/typedefs.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 20 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 21 | #define RTCP_CNAME_SIZE 256 // RFC 3550 page 44, including null termination |
| 22 | #define IP_PACKET_SIZE 1500 // we assume ethernet |
| 23 | #define MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS 10 |
| 24 | #define TIMEOUT_SEI_MESSAGES_MS 30000 // in milliseconds |
| 25 | |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 26 | namespace webrtc { |
phoglund@webrtc.org | 7d91c10 | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 27 | |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 28 | const int kVideoPayloadTypeFrequency = 90000; |
| 29 | |
| 30 | struct AudioPayload |
| 31 | { |
| 32 | uint32_t frequency; |
| 33 | uint8_t channels; |
| 34 | uint32_t rate; |
| 35 | }; |
| 36 | |
| 37 | struct VideoPayload |
| 38 | { |
| 39 | RtpVideoCodecTypes videoCodecType; |
| 40 | uint32_t maxRate; |
| 41 | }; |
| 42 | |
| 43 | union PayloadUnion |
| 44 | { |
| 45 | AudioPayload Audio; |
| 46 | VideoPayload Video; |
| 47 | }; |
phoglund@webrtc.org | 68950e5 | 2013-01-07 10:18:30 +0000 | [diff] [blame] | 48 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 49 | enum RTCPMethod |
| 50 | { |
| 51 | kRtcpOff = 0, |
| 52 | kRtcpCompound = 1, |
| 53 | kRtcpNonCompound = 2 |
| 54 | }; |
| 55 | |
| 56 | enum RTPAliveType |
| 57 | { |
| 58 | kRtpDead = 0, |
| 59 | kRtpNoRtp = 1, |
| 60 | kRtpAlive = 2 |
| 61 | }; |
| 62 | |
| 63 | enum StorageType { |
| 64 | kDontStore, |
| 65 | kDontRetransmit, |
| 66 | kAllowRetransmission |
| 67 | }; |
| 68 | |
| 69 | enum RTPExtensionType |
| 70 | { |
| 71 | kRtpExtensionNone, |
| 72 | kRtpExtensionTransmissionTimeOffset, |
| 73 | kRtpExtensionAudioLevel, |
solenberg@webrtc.org | a0b0025 | 2013-05-16 11:10:31 +0000 | [diff] [blame] | 74 | kRtpExtensionAbsoluteSendTime |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | enum RTCPAppSubTypes |
| 78 | { |
| 79 | kAppSubtypeBwe = 0x00 |
| 80 | }; |
| 81 | |
| 82 | enum RTCPPacketType |
| 83 | { |
| 84 | kRtcpReport = 0x0001, |
| 85 | kRtcpSr = 0x0002, |
| 86 | kRtcpRr = 0x0004, |
| 87 | kRtcpBye = 0x0008, |
| 88 | kRtcpPli = 0x0010, |
| 89 | kRtcpNack = 0x0020, |
| 90 | kRtcpFir = 0x0040, |
| 91 | kRtcpTmmbr = 0x0080, |
| 92 | kRtcpTmmbn = 0x0100, |
| 93 | kRtcpSrReq = 0x0200, |
| 94 | kRtcpXrVoipMetric = 0x0400, |
| 95 | kRtcpApp = 0x0800, |
| 96 | kRtcpSli = 0x4000, |
| 97 | kRtcpRpsi = 0x8000, |
| 98 | kRtcpRemb = 0x10000, |
asapersson@webrtc.org | d6da239 | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 99 | kRtcpTransmissionTimeOffset = 0x20000, |
| 100 | kRtcpXrReceiverReferenceTime = 0x40000, |
| 101 | kRtcpXrDlrrReportBlock = 0x80000 |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | enum KeyFrameRequestMethod |
| 105 | { |
| 106 | kKeyFrameReqFirRtp = 1, |
| 107 | kKeyFrameReqPliRtcp = 2, |
| 108 | kKeyFrameReqFirRtcp = 3 |
| 109 | }; |
| 110 | |
| 111 | enum RtpRtcpPacketType |
| 112 | { |
| 113 | kPacketRtp = 0, |
| 114 | kPacketKeepAlive = 1 |
| 115 | }; |
| 116 | |
| 117 | enum NACKMethod |
| 118 | { |
| 119 | kNackOff = 0, |
| 120 | kNackRtcp = 2 |
| 121 | }; |
| 122 | |
| 123 | enum RetransmissionMode { |
| 124 | kRetransmitOff = 0x0, |
| 125 | kRetransmitFECPackets = 0x1, |
| 126 | kRetransmitBaseLayer = 0x2, |
| 127 | kRetransmitHigherLayers = 0x4, |
| 128 | kRetransmitAllPackets = 0xFF |
| 129 | }; |
| 130 | |
mikhal@webrtc.org | 946d240 | 2013-03-15 23:21:52 +0000 | [diff] [blame] | 131 | enum RtxMode { |
| 132 | kRtxOff = 0, |
| 133 | kRtxRetransmitted = 1, // Apply RTX only to retransmitted packets. |
| 134 | kRtxAll = 2 // Apply RTX to all packets (source + retransmissions). |
| 135 | }; |
| 136 | |
mflodman@webrtc.org | 7bc7e02 | 2013-04-12 14:55:46 +0000 | [diff] [blame] | 137 | const int kRtxHeaderSize = 2; |
| 138 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 139 | struct RTCPSenderInfo |
| 140 | { |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 141 | uint32_t NTPseconds; |
| 142 | uint32_t NTPfraction; |
| 143 | uint32_t RTPtimeStamp; |
| 144 | uint32_t sendPacketCount; |
| 145 | uint32_t sendOctetCount; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 146 | }; |
| 147 | |
stefan@webrtc.org | 7485573 | 2013-09-17 07:49:56 +0000 | [diff] [blame] | 148 | struct RTCPReportBlock { |
| 149 | RTCPReportBlock() |
| 150 | : remoteSSRC(0), sourceSSRC(0), fractionLost(0), cumulativeLost(0), |
| 151 | extendedHighSeqNum(0), jitter(0), lastSR(0), |
| 152 | delaySinceLastSR(0) {} |
| 153 | |
| 154 | RTCPReportBlock(uint32_t remote_ssrc, |
| 155 | uint32_t source_ssrc, |
| 156 | uint8_t fraction_lost, |
| 157 | uint32_t cumulative_lost, |
| 158 | uint32_t extended_high_sequence_number, |
| 159 | uint32_t jitter, |
| 160 | uint32_t last_sender_report, |
| 161 | uint32_t delay_since_last_sender_report) |
| 162 | : remoteSSRC(remote_ssrc), |
| 163 | sourceSSRC(source_ssrc), |
| 164 | fractionLost(fraction_lost), |
| 165 | cumulativeLost(cumulative_lost), |
| 166 | extendedHighSeqNum(extended_high_sequence_number), |
| 167 | jitter(jitter), |
| 168 | lastSR(last_sender_report), |
| 169 | delaySinceLastSR(delay_since_last_sender_report) {} |
| 170 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 171 | // Fields as described by RFC 3550 6.4.2. |
stefan@webrtc.org | 7485573 | 2013-09-17 07:49:56 +0000 | [diff] [blame] | 172 | uint32_t remoteSSRC; // SSRC of sender of this report. |
| 173 | uint32_t sourceSSRC; // SSRC of the RTP packet sender. |
| 174 | uint8_t fractionLost; |
| 175 | uint32_t cumulativeLost; // 24 bits valid. |
| 176 | uint32_t extendedHighSeqNum; |
| 177 | uint32_t jitter; |
| 178 | uint32_t lastSR; |
| 179 | uint32_t delaySinceLastSR; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 180 | }; |
| 181 | |
asapersson@webrtc.org | d6da239 | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 182 | struct RtcpReceiveTimeInfo { |
| 183 | // Fields as described by RFC 3611 4.5. |
| 184 | uint32_t sourceSSRC; |
| 185 | uint32_t lastRR; |
| 186 | uint32_t delaySinceLastRR; |
| 187 | }; |
| 188 | |
stefan@webrtc.org | 7485573 | 2013-09-17 07:49:56 +0000 | [diff] [blame] | 189 | typedef std::list<RTCPReportBlock> ReportBlockList; |
| 190 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 191 | class RtpData |
| 192 | { |
| 193 | public: |
stefan@webrtc.org | aa445e7 | 2013-10-15 10:38:40 +0000 | [diff] [blame^] | 194 | virtual ~RtpData() {} |
| 195 | |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 196 | virtual int32_t OnReceivedPayloadData( |
| 197 | const uint8_t* payloadData, |
| 198 | const uint16_t payloadSize, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 199 | const WebRtcRTPHeader* rtpHeader) = 0; |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 200 | |
| 201 | virtual bool OnRecoveredPacket(const uint8_t* packet, |
| 202 | int packet_length) = 0; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 203 | }; |
| 204 | |
| 205 | class RtcpFeedback |
| 206 | { |
| 207 | public: |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 208 | virtual void OnApplicationDataReceived(const int32_t /*id*/, |
| 209 | const uint8_t /*subType*/, |
| 210 | const uint32_t /*name*/, |
| 211 | const uint16_t /*length*/, |
| 212 | const uint8_t* /*data*/) {}; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 213 | |
| 214 | virtual void OnXRVoIPMetricReceived( |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 215 | const int32_t /*id*/, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 216 | const RTCPVoIPMetric* /*metric*/) {}; |
| 217 | |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 218 | virtual void OnReceiveReportReceived(const int32_t id, |
| 219 | const uint32_t senderSSRC) {}; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 220 | |
| 221 | protected: |
| 222 | virtual ~RtcpFeedback() {} |
| 223 | }; |
| 224 | |
| 225 | class RtpFeedback |
| 226 | { |
| 227 | public: |
stefan@webrtc.org | aa445e7 | 2013-10-15 10:38:40 +0000 | [diff] [blame^] | 228 | virtual ~RtpFeedback() {} |
| 229 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 230 | // Receiving payload change or SSRC change. (return success!) |
| 231 | /* |
| 232 | * channels - number of channels in codec (1 = mono, 2 = stereo) |
| 233 | */ |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 234 | virtual int32_t OnInitializeDecoder( |
| 235 | const int32_t id, |
| 236 | const int8_t payloadType, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 237 | const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
| 238 | const int frequency, |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 239 | const uint8_t channels, |
| 240 | const uint32_t rate) = 0; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 241 | |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 242 | virtual void OnIncomingSSRCChanged( const int32_t id, |
stefan@webrtc.org | a20e2d4 | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 243 | const uint32_t ssrc) = 0; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 244 | |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 245 | virtual void OnIncomingCSRCChanged( const int32_t id, |
| 246 | const uint32_t CSRC, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 247 | const bool added) = 0; |
| 248 | |
stefan@webrtc.org | a20e2d4 | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 249 | virtual void ResetStatistics(uint32_t ssrc) = 0; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 250 | }; |
| 251 | |
| 252 | class RtpAudioFeedback { |
| 253 | public: |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 254 | |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 255 | virtual void OnPlayTelephoneEvent(const int32_t id, |
| 256 | const uint8_t event, |
| 257 | const uint16_t lengthMs, |
| 258 | const uint8_t volume) = 0; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 259 | protected: |
| 260 | virtual ~RtpAudioFeedback() {} |
| 261 | }; |
| 262 | |
| 263 | class RtcpIntraFrameObserver { |
| 264 | public: |
| 265 | virtual void OnReceivedIntraFrameRequest(uint32_t ssrc) = 0; |
| 266 | |
| 267 | virtual void OnReceivedSLI(uint32_t ssrc, |
| 268 | uint8_t picture_id) = 0; |
| 269 | |
| 270 | virtual void OnReceivedRPSI(uint32_t ssrc, |
| 271 | uint64_t picture_id) = 0; |
| 272 | |
| 273 | virtual void OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) = 0; |
| 274 | |
| 275 | virtual ~RtcpIntraFrameObserver() {} |
| 276 | }; |
| 277 | |
| 278 | class RtcpBandwidthObserver { |
| 279 | public: |
| 280 | // REMB or TMMBR |
| 281 | virtual void OnReceivedEstimatedBitrate(const uint32_t bitrate) = 0; |
| 282 | |
| 283 | virtual void OnReceivedRtcpReceiverReport( |
stefan@webrtc.org | 7485573 | 2013-09-17 07:49:56 +0000 | [diff] [blame] | 284 | const ReportBlockList& report_blocks, |
| 285 | uint16_t rtt, |
| 286 | int64_t now_ms) = 0; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 287 | |
| 288 | virtual ~RtcpBandwidthObserver() {} |
| 289 | }; |
| 290 | |
mflodman@webrtc.org | e296783 | 2012-11-16 13:57:26 +0000 | [diff] [blame] | 291 | class RtcpRttObserver { |
| 292 | public: |
| 293 | virtual void OnRttUpdate(uint32_t rtt) = 0; |
| 294 | |
| 295 | virtual ~RtcpRttObserver() {}; |
| 296 | }; |
| 297 | |
phoglund@webrtc.org | cd29867 | 2013-01-14 10:01:55 +0000 | [diff] [blame] | 298 | // Null object version of RtpFeedback. |
| 299 | class NullRtpFeedback : public RtpFeedback { |
| 300 | public: |
| 301 | virtual ~NullRtpFeedback() {} |
| 302 | |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 303 | virtual int32_t OnInitializeDecoder( |
| 304 | const int32_t id, |
| 305 | const int8_t payloadType, |
phoglund@webrtc.org | cd29867 | 2013-01-14 10:01:55 +0000 | [diff] [blame] | 306 | const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
| 307 | const int frequency, |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 308 | const uint8_t channels, |
pbos@webrtc.org | 9d71e28 | 2013-07-31 15:17:19 +0000 | [diff] [blame] | 309 | const uint32_t rate) OVERRIDE { |
stefan@webrtc.org | db74c61 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 310 | return 0; |
| 311 | } |
phoglund@webrtc.org | cd29867 | 2013-01-14 10:01:55 +0000 | [diff] [blame] | 312 | |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 313 | virtual void OnIncomingSSRCChanged(const int32_t id, |
stefan@webrtc.org | a20e2d4 | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 314 | const uint32_t ssrc) OVERRIDE {} |
phoglund@webrtc.org | cd29867 | 2013-01-14 10:01:55 +0000 | [diff] [blame] | 315 | |
stefan@webrtc.org | db74c61 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 316 | virtual void OnIncomingCSRCChanged(const int32_t id, |
| 317 | const uint32_t CSRC, |
| 318 | const bool added) OVERRIDE {} |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 319 | |
stefan@webrtc.org | db74c61 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 320 | virtual void ResetStatistics(uint32_t ssrc) OVERRIDE {} |
phoglund@webrtc.org | cd29867 | 2013-01-14 10:01:55 +0000 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | // Null object version of RtpData. |
| 324 | class NullRtpData : public RtpData { |
| 325 | public: |
| 326 | virtual ~NullRtpData() {} |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 327 | |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 328 | virtual int32_t OnReceivedPayloadData( |
| 329 | const uint8_t* payloadData, |
| 330 | const uint16_t payloadSize, |
pbos@webrtc.org | 9d71e28 | 2013-07-31 15:17:19 +0000 | [diff] [blame] | 331 | const WebRtcRTPHeader* rtpHeader) OVERRIDE { |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 332 | return 0; |
| 333 | } |
| 334 | |
| 335 | virtual bool OnRecoveredPacket(const uint8_t* packet, |
| 336 | int packet_length) { |
| 337 | return true; |
| 338 | } |
phoglund@webrtc.org | cd29867 | 2013-01-14 10:01:55 +0000 | [diff] [blame] | 339 | }; |
| 340 | |
| 341 | // Null object version of RtpAudioFeedback. |
| 342 | class NullRtpAudioFeedback : public RtpAudioFeedback { |
| 343 | public: |
| 344 | virtual ~NullRtpAudioFeedback() {} |
| 345 | |
pbos@webrtc.org | b57da65 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 346 | virtual void OnPlayTelephoneEvent(const int32_t id, |
| 347 | const uint8_t event, |
| 348 | const uint16_t lengthMs, |
pbos@webrtc.org | 9d71e28 | 2013-07-31 15:17:19 +0000 | [diff] [blame] | 349 | const uint8_t volume) OVERRIDE {} |
phoglund@webrtc.org | cd29867 | 2013-01-14 10:01:55 +0000 | [diff] [blame] | 350 | }; |
| 351 | |
pbos@webrtc.org | 3b89e10 | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 352 | } // namespace webrtc |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 353 | #endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RTCP_DEFINES_H_ |