blob: 21dcc9f3889c38f25b66ff98423f9226ae6a79eb [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +00001/*
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.org7fc75bb2013-08-15 23:38:54 +000014#include <stddef.h>
stefan@webrtc.org74855732013-09-17 07:49:56 +000015#include <list>
wu@webrtc.org7fc75bb2013-08-15 23:38:54 +000016
pbos@webrtc.orgcbd78ae2013-05-29 14:27:38 +000017#include "webrtc/modules/interface/module_common_types.h"
stefan@webrtc.org9858fc82013-01-17 14:01:20 +000018#include "webrtc/system_wrappers/interface/clock.h"
pbos@webrtc.orgcbd78ae2013-05-29 14:27:38 +000019#include "webrtc/typedefs.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000020
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000021#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.org7fc75bb2013-08-15 23:38:54 +000026namespace webrtc {
phoglund@webrtc.org7d91c102012-12-18 15:40:53 +000027
wu@webrtc.org7fc75bb2013-08-15 23:38:54 +000028const int kVideoPayloadTypeFrequency = 90000;
29
30struct AudioPayload
31{
32 uint32_t frequency;
33 uint8_t channels;
34 uint32_t rate;
35};
36
37struct VideoPayload
38{
39 RtpVideoCodecTypes videoCodecType;
40 uint32_t maxRate;
41};
42
43union PayloadUnion
44{
45 AudioPayload Audio;
46 VideoPayload Video;
47};
phoglund@webrtc.org68950e52013-01-07 10:18:30 +000048
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000049enum RTCPMethod
50{
51 kRtcpOff = 0,
52 kRtcpCompound = 1,
53 kRtcpNonCompound = 2
54};
55
56enum RTPAliveType
57{
58 kRtpDead = 0,
59 kRtpNoRtp = 1,
60 kRtpAlive = 2
61};
62
63enum StorageType {
64 kDontStore,
65 kDontRetransmit,
66 kAllowRetransmission
67};
68
69enum RTPExtensionType
70{
71 kRtpExtensionNone,
72 kRtpExtensionTransmissionTimeOffset,
73 kRtpExtensionAudioLevel,
solenberg@webrtc.orga0b00252013-05-16 11:10:31 +000074 kRtpExtensionAbsoluteSendTime
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000075};
76
77enum RTCPAppSubTypes
78{
79 kAppSubtypeBwe = 0x00
80};
81
82enum 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.orgd6da2392013-10-02 13:15:34 +000099 kRtcpTransmissionTimeOffset = 0x20000,
100 kRtcpXrReceiverReferenceTime = 0x40000,
101 kRtcpXrDlrrReportBlock = 0x80000
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000102};
103
104enum KeyFrameRequestMethod
105{
106 kKeyFrameReqFirRtp = 1,
107 kKeyFrameReqPliRtcp = 2,
108 kKeyFrameReqFirRtcp = 3
109};
110
111enum RtpRtcpPacketType
112{
113 kPacketRtp = 0,
114 kPacketKeepAlive = 1
115};
116
117enum NACKMethod
118{
119 kNackOff = 0,
120 kNackRtcp = 2
121};
122
123enum RetransmissionMode {
124 kRetransmitOff = 0x0,
125 kRetransmitFECPackets = 0x1,
126 kRetransmitBaseLayer = 0x2,
127 kRetransmitHigherLayers = 0x4,
128 kRetransmitAllPackets = 0xFF
129};
130
mikhal@webrtc.org946d2402013-03-15 23:21:52 +0000131enum 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.org7bc7e022013-04-12 14:55:46 +0000137const int kRtxHeaderSize = 2;
138
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000139struct RTCPSenderInfo
140{
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000141 uint32_t NTPseconds;
142 uint32_t NTPfraction;
143 uint32_t RTPtimeStamp;
144 uint32_t sendPacketCount;
145 uint32_t sendOctetCount;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000146};
147
stefan@webrtc.org74855732013-09-17 07:49:56 +0000148struct 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.orgb015cbe2012-10-22 18:19:23 +0000171 // Fields as described by RFC 3550 6.4.2.
stefan@webrtc.org74855732013-09-17 07:49:56 +0000172 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.orgb015cbe2012-10-22 18:19:23 +0000180};
181
asapersson@webrtc.orgd6da2392013-10-02 13:15:34 +0000182struct 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.org74855732013-09-17 07:49:56 +0000189typedef std::list<RTCPReportBlock> ReportBlockList;
190
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000191class RtpData
192{
193public:
stefan@webrtc.orgaa445e72013-10-15 10:38:40 +0000194 virtual ~RtpData() {}
195
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000196 virtual int32_t OnReceivedPayloadData(
197 const uint8_t* payloadData,
198 const uint16_t payloadSize,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000199 const WebRtcRTPHeader* rtpHeader) = 0;
wu@webrtc.org7fc75bb2013-08-15 23:38:54 +0000200
201 virtual bool OnRecoveredPacket(const uint8_t* packet,
202 int packet_length) = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000203};
204
205class RtcpFeedback
206{
207public:
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000208 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.orgb015cbe2012-10-22 18:19:23 +0000213
214 virtual void OnXRVoIPMetricReceived(
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000215 const int32_t /*id*/,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000216 const RTCPVoIPMetric* /*metric*/) {};
217
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000218 virtual void OnReceiveReportReceived(const int32_t id,
219 const uint32_t senderSSRC) {};
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000220
221protected:
222 virtual ~RtcpFeedback() {}
223};
224
225class RtpFeedback
226{
227public:
stefan@webrtc.orgaa445e72013-10-15 10:38:40 +0000228 virtual ~RtpFeedback() {}
229
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000230 // Receiving payload change or SSRC change. (return success!)
231 /*
232 * channels - number of channels in codec (1 = mono, 2 = stereo)
233 */
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000234 virtual int32_t OnInitializeDecoder(
235 const int32_t id,
236 const int8_t payloadType,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000237 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
238 const int frequency,
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000239 const uint8_t channels,
240 const uint32_t rate) = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000241
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000242 virtual void OnIncomingSSRCChanged( const int32_t id,
stefan@webrtc.orga20e2d42013-08-21 20:58:21 +0000243 const uint32_t ssrc) = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000244
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000245 virtual void OnIncomingCSRCChanged( const int32_t id,
246 const uint32_t CSRC,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000247 const bool added) = 0;
248
stefan@webrtc.orga20e2d42013-08-21 20:58:21 +0000249 virtual void ResetStatistics(uint32_t ssrc) = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000250};
251
252class RtpAudioFeedback {
253 public:
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000254
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000255 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.orgb015cbe2012-10-22 18:19:23 +0000259 protected:
260 virtual ~RtpAudioFeedback() {}
261};
262
263class 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
278class RtcpBandwidthObserver {
279 public:
280 // REMB or TMMBR
281 virtual void OnReceivedEstimatedBitrate(const uint32_t bitrate) = 0;
282
283 virtual void OnReceivedRtcpReceiverReport(
stefan@webrtc.org74855732013-09-17 07:49:56 +0000284 const ReportBlockList& report_blocks,
285 uint16_t rtt,
286 int64_t now_ms) = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000287
288 virtual ~RtcpBandwidthObserver() {}
289};
290
mflodman@webrtc.orge2967832012-11-16 13:57:26 +0000291class RtcpRttObserver {
292 public:
293 virtual void OnRttUpdate(uint32_t rtt) = 0;
294
295 virtual ~RtcpRttObserver() {};
296};
297
phoglund@webrtc.orgcd298672013-01-14 10:01:55 +0000298// Null object version of RtpFeedback.
299class NullRtpFeedback : public RtpFeedback {
300 public:
301 virtual ~NullRtpFeedback() {}
302
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000303 virtual int32_t OnInitializeDecoder(
304 const int32_t id,
305 const int8_t payloadType,
phoglund@webrtc.orgcd298672013-01-14 10:01:55 +0000306 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
307 const int frequency,
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000308 const uint8_t channels,
pbos@webrtc.org9d71e282013-07-31 15:17:19 +0000309 const uint32_t rate) OVERRIDE {
stefan@webrtc.orgdb74c612013-09-06 13:40:11 +0000310 return 0;
311 }
phoglund@webrtc.orgcd298672013-01-14 10:01:55 +0000312
wu@webrtc.org7fc75bb2013-08-15 23:38:54 +0000313 virtual void OnIncomingSSRCChanged(const int32_t id,
stefan@webrtc.orga20e2d42013-08-21 20:58:21 +0000314 const uint32_t ssrc) OVERRIDE {}
phoglund@webrtc.orgcd298672013-01-14 10:01:55 +0000315
stefan@webrtc.orgdb74c612013-09-06 13:40:11 +0000316 virtual void OnIncomingCSRCChanged(const int32_t id,
317 const uint32_t CSRC,
318 const bool added) OVERRIDE {}
wu@webrtc.org7fc75bb2013-08-15 23:38:54 +0000319
stefan@webrtc.orgdb74c612013-09-06 13:40:11 +0000320 virtual void ResetStatistics(uint32_t ssrc) OVERRIDE {}
phoglund@webrtc.orgcd298672013-01-14 10:01:55 +0000321};
322
323// Null object version of RtpData.
324class NullRtpData : public RtpData {
325 public:
326 virtual ~NullRtpData() {}
wu@webrtc.org7fc75bb2013-08-15 23:38:54 +0000327
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000328 virtual int32_t OnReceivedPayloadData(
329 const uint8_t* payloadData,
330 const uint16_t payloadSize,
pbos@webrtc.org9d71e282013-07-31 15:17:19 +0000331 const WebRtcRTPHeader* rtpHeader) OVERRIDE {
wu@webrtc.org7fc75bb2013-08-15 23:38:54 +0000332 return 0;
333 }
334
335 virtual bool OnRecoveredPacket(const uint8_t* packet,
336 int packet_length) {
337 return true;
338 }
phoglund@webrtc.orgcd298672013-01-14 10:01:55 +0000339};
340
341// Null object version of RtpAudioFeedback.
342class NullRtpAudioFeedback : public RtpAudioFeedback {
343 public:
344 virtual ~NullRtpAudioFeedback() {}
345
pbos@webrtc.orgb57da652013-04-08 11:08:41 +0000346 virtual void OnPlayTelephoneEvent(const int32_t id,
347 const uint8_t event,
348 const uint16_t lengthMs,
pbos@webrtc.org9d71e282013-07-31 15:17:19 +0000349 const uint8_t volume) OVERRIDE {}
phoglund@webrtc.orgcd298672013-01-14 10:01:55 +0000350};
351
pbos@webrtc.org3b89e102013-07-03 15:12:26 +0000352} // namespace webrtc
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000353#endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RTCP_DEFINES_H_