blob: 1e25f2880a669abad96f4b526bad16c3cd0db841 [file] [log] [blame]
Henrik Kjellanderff761fb2015-11-04 08:31:52 +01001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_
12#define MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010013
14#include <stddef.h>
15#include <list>
Stefan Holmer60e43462016-09-07 09:58:20 +020016#include <vector>
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010017
Karl Wibergc62f6c72017-10-04 12:38:53 +020018#include "api/audio_codecs/audio_format.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020019#include "common_types.h" // NOLINT(build/include)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "modules/include/module_common_types.h"
21#include "rtc_base/deprecation.h"
22#include "system_wrappers/include/clock.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020023#include "typedefs.h" // NOLINT(build/include)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010024
25#define RTCP_CNAME_SIZE 256 // RFC 3550 page 44, including null termination
26#define IP_PACKET_SIZE 1500 // we assume ethernet
27#define MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS 10
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010028
29namespace webrtc {
30namespace rtcp {
31class TransportFeedback;
32}
33
34const int kVideoPayloadTypeFrequency = 90000;
solenbergb19d2882016-10-03 06:22:25 -070035// TODO(solenberg): RTP time stamp rate for RTCP is fixed at 8k, this is legacy
36// and should be fixed.
37// See: https://bugs.chromium.org/p/webrtc/issues/detail?id=6458
38const int kBogusRtpRateForAudioRtcp = 8000;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010039
40// Minimum RTP header size in bytes.
41const uint8_t kRtpHeaderSize = 12;
42
danilchap5c1def82015-12-10 09:51:54 -080043struct AudioPayload {
Karl Wibergc62f6c72017-10-04 12:38:53 +020044 SdpAudioFormat format;
45 uint32_t rate;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010046};
47
danilchap5c1def82015-12-10 09:51:54 -080048struct VideoPayload {
magjede69a1a92016-11-25 10:06:31 -080049 RtpVideoCodecTypes videoCodecType;
50 // The H264 profile only matters if videoCodecType == kRtpVideoH264.
51 H264::Profile h264_profile;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010052};
53
Karl Wiberg83d3ec12017-09-28 19:54:38 +020054class PayloadUnion {
55 public:
Karl Wiberg884e49f2017-10-02 09:54:48 +020056 explicit PayloadUnion(const AudioPayload& payload);
57 explicit PayloadUnion(const VideoPayload& payload);
58 PayloadUnion(const PayloadUnion&);
59 PayloadUnion(PayloadUnion&&);
60 ~PayloadUnion();
Karl Wiberg83d3ec12017-09-28 19:54:38 +020061
Karl Wiberg884e49f2017-10-02 09:54:48 +020062 PayloadUnion& operator=(const PayloadUnion&);
63 PayloadUnion& operator=(PayloadUnion&&);
64
65 bool is_audio() const { return audio_payload_.has_value(); }
66 bool is_video() const { return video_payload_.has_value(); }
Karl Wiberg83d3ec12017-09-28 19:54:38 +020067 const AudioPayload& audio_payload() const {
Karl Wiberg884e49f2017-10-02 09:54:48 +020068 RTC_DCHECK(audio_payload_);
69 return *audio_payload_;
Karl Wiberg83d3ec12017-09-28 19:54:38 +020070 }
71 const VideoPayload& video_payload() const {
Karl Wiberg884e49f2017-10-02 09:54:48 +020072 RTC_DCHECK(video_payload_);
73 return *video_payload_;
Karl Wiberg83d3ec12017-09-28 19:54:38 +020074 }
75 AudioPayload& audio_payload() {
Karl Wiberg884e49f2017-10-02 09:54:48 +020076 RTC_DCHECK(audio_payload_);
77 return *audio_payload_;
Karl Wiberg83d3ec12017-09-28 19:54:38 +020078 }
79 VideoPayload& video_payload() {
Karl Wiberg884e49f2017-10-02 09:54:48 +020080 RTC_DCHECK(video_payload_);
81 return *video_payload_;
Karl Wiberg83d3ec12017-09-28 19:54:38 +020082 }
83
Karl Wiberg83d3ec12017-09-28 19:54:38 +020084 private:
Karl Wiberg884e49f2017-10-02 09:54:48 +020085 rtc::Optional<AudioPayload> audio_payload_;
86 rtc::Optional<VideoPayload> video_payload_;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010087};
88
danilchap5c1def82015-12-10 09:51:54 -080089enum RTPAliveType { kRtpDead = 0, kRtpNoRtp = 1, kRtpAlive = 2 };
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010090
91enum ProtectionType {
92 kUnprotectedPacket,
93 kProtectedPacket
94};
95
96enum StorageType {
97 kDontRetransmit,
98 kAllowRetransmission
99};
100
101enum RTPExtensionType {
102 kRtpExtensionNone,
103 kRtpExtensionTransmissionTimeOffset,
104 kRtpExtensionAudioLevel,
105 kRtpExtensionAbsoluteSendTime,
106 kRtpExtensionVideoRotation,
107 kRtpExtensionTransportSequenceNumber,
isheriff6b4b5f32016-06-08 00:24:21 -0700108 kRtpExtensionPlayoutDelay,
ilnik00d802b2017-04-11 10:34:31 -0700109 kRtpExtensionVideoContentType,
ilnik04f4d122017-06-19 07:18:55 -0700110 kRtpExtensionVideoTiming,
danilchapef8d7732017-04-19 02:59:48 -0700111 kRtpExtensionRtpStreamId,
112 kRtpExtensionRepairedRtpStreamId,
Steve Antona3251dd2017-07-21 09:58:31 -0700113 kRtpExtensionMid,
ilnik00d802b2017-04-11 10:34:31 -0700114 kRtpExtensionNumberOfExtensions // Must be the last entity in the enum.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100115};
116
danilchap5c1def82015-12-10 09:51:54 -0800117enum RTCPAppSubTypes { kAppSubtypeBwe = 0x00 };
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100118
119// TODO(sprang): Make this an enum class once rtcp_receiver has been cleaned up.
120enum RTCPPacketType : uint32_t {
121 kRtcpReport = 0x0001,
122 kRtcpSr = 0x0002,
123 kRtcpRr = 0x0004,
124 kRtcpSdes = 0x0008,
125 kRtcpBye = 0x0010,
126 kRtcpPli = 0x0020,
127 kRtcpNack = 0x0040,
128 kRtcpFir = 0x0080,
129 kRtcpTmmbr = 0x0100,
130 kRtcpTmmbn = 0x0200,
131 kRtcpSrReq = 0x0400,
132 kRtcpXrVoipMetric = 0x0800,
133 kRtcpApp = 0x1000,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100134 kRtcpRemb = 0x10000,
135 kRtcpTransmissionTimeOffset = 0x20000,
136 kRtcpXrReceiverReferenceTime = 0x40000,
137 kRtcpXrDlrrReportBlock = 0x80000,
138 kRtcpTransportFeedback = 0x100000,
sprang5e38c962016-12-01 05:18:09 -0800139 kRtcpXrTargetBitrate = 0x200000
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100140};
141
142enum KeyFrameRequestMethod { kKeyFrameReqPliRtcp, kKeyFrameReqFirRtcp };
143
danilchap5c1def82015-12-10 09:51:54 -0800144enum RtpRtcpPacketType { kPacketRtp = 0, kPacketKeepAlive = 1 };
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100145
spranga8ae6f22017-09-04 07:23:56 -0700146// kConditionallyRetransmitHigherLayers allows retransmission of video frames
147// in higher layers if either the last frame in that layer was too far back in
148// time, or if we estimate that a new frame will be available in a lower layer
149// in a shorter time than it would take to request and receive a retransmission.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100150enum RetransmissionMode : uint8_t {
151 kRetransmitOff = 0x0,
152 kRetransmitFECPackets = 0x1,
153 kRetransmitBaseLayer = 0x2,
154 kRetransmitHigherLayers = 0x4,
spranga8ae6f22017-09-04 07:23:56 -0700155 kConditionallyRetransmitHigherLayers = 0x8,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100156 kRetransmitAllPackets = 0xFF
157};
158
159enum RtxMode {
160 kRtxOff = 0x0,
161 kRtxRetransmitted = 0x1, // Only send retransmissions over RTX.
162 kRtxRedundantPayloads = 0x2 // Preventively send redundant payloads
163 // instead of padding.
164};
165
166const size_t kRtxHeaderSize = 2;
167
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100168struct RTCPReportBlock {
169 RTCPReportBlock()
srte3e69e5c2017-08-09 06:13:45 -0700170 : sender_ssrc(0),
171 source_ssrc(0),
172 fraction_lost(0),
173 packets_lost(0),
174 extended_highest_sequence_number(0),
175 jitter(0),
176 last_sender_report_timestamp(0),
177 delay_since_last_sender_report(0) {}
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100178
srte3e69e5c2017-08-09 06:13:45 -0700179 RTCPReportBlock(uint32_t sender_ssrc,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100180 uint32_t source_ssrc,
181 uint8_t fraction_lost,
srte3e69e5c2017-08-09 06:13:45 -0700182 uint32_t packets_lost,
183 uint32_t extended_highest_sequence_number,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100184 uint32_t jitter,
srte3e69e5c2017-08-09 06:13:45 -0700185 uint32_t last_sender_report_timestamp,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100186 uint32_t delay_since_last_sender_report)
srte3e69e5c2017-08-09 06:13:45 -0700187 : sender_ssrc(sender_ssrc),
188 source_ssrc(source_ssrc),
189 fraction_lost(fraction_lost),
190 packets_lost(packets_lost),
191 extended_highest_sequence_number(extended_highest_sequence_number),
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100192 jitter(jitter),
srte3e69e5c2017-08-09 06:13:45 -0700193 last_sender_report_timestamp(last_sender_report_timestamp),
194 delay_since_last_sender_report(delay_since_last_sender_report) {}
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100195
196 // Fields as described by RFC 3550 6.4.2.
srte3e69e5c2017-08-09 06:13:45 -0700197 union {
198 uint32_t sender_ssrc; // SSRC of sender of this report.
199 RTC_DEPRECATED uint32_t remoteSSRC;
200 };
201 union {
202 uint32_t source_ssrc; // SSRC of the RTP packet sender.
203 RTC_DEPRECATED uint32_t sourceSSRC;
204 };
205 union {
206 RTC_DEPRECATED uint8_t fractionLost;
207 uint8_t fraction_lost;
208 };
209 union {
210 uint32_t packets_lost; // 24 bits valid.
211 RTC_DEPRECATED uint32_t cumulativeLost;
212 };
213 union {
214 uint32_t extended_highest_sequence_number;
215 RTC_DEPRECATED uint32_t extendedHighSeqNum;
216 };
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100217 uint32_t jitter;
srte3e69e5c2017-08-09 06:13:45 -0700218 union {
219 uint32_t last_sender_report_timestamp;
220 RTC_DEPRECATED uint32_t lastSR;
221 };
222 union {
223 uint32_t delay_since_last_sender_report;
224 RTC_DEPRECATED uint32_t delaySinceLastSR;
225 };
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100226};
227
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100228typedef std::list<RTCPReportBlock> ReportBlockList;
229
230struct RtpState {
231 RtpState()
232 : sequence_number(0),
233 start_timestamp(0),
234 timestamp(0),
235 capture_time_ms(-1),
236 last_timestamp_time_ms(-1),
237 media_has_been_sent(false) {}
238 uint16_t sequence_number;
239 uint32_t start_timestamp;
240 uint32_t timestamp;
241 int64_t capture_time_ms;
242 int64_t last_timestamp_time_ms;
243 bool media_has_been_sent;
244};
245
danilchap5c1def82015-12-10 09:51:54 -0800246class RtpData {
247 public:
248 virtual ~RtpData() {}
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100249
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700250 virtual int32_t OnReceivedPayloadData(const uint8_t* payload_data,
251 size_t payload_size,
252 const WebRtcRTPHeader* rtp_header) = 0;
nisse30e89312017-05-29 08:16:37 -0700253};
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100254
nisse30e89312017-05-29 08:16:37 -0700255// Callback interface for packets recovered by FlexFEC or ULPFEC. In
256// the FlexFEC case, the implementation should be able to demultiplex
257// the recovered RTP packets based on SSRC.
258class RecoveredPacketReceiver {
259 public:
260 virtual void OnRecoveredPacket(const uint8_t* packet, size_t length) = 0;
261
262 protected:
263 virtual ~RecoveredPacketReceiver() = default;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100264};
265
danilchap5c1def82015-12-10 09:51:54 -0800266class RtpFeedback {
267 public:
268 virtual ~RtpFeedback() {}
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100269
danilchap5c1def82015-12-10 09:51:54 -0800270 // Receiving payload change or SSRC change. (return success!)
271 /*
272 * channels - number of channels in codec (1 = mono, 2 = stereo)
273 */
Karl Wibergc62f6c72017-10-04 12:38:53 +0200274 virtual int32_t OnInitializeDecoder(int payload_type,
275 const SdpAudioFormat& audio_format,
276 uint32_t rate) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100277
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700278 virtual void OnIncomingSSRCChanged(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100279
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700280 virtual void OnIncomingCSRCChanged(uint32_t csrc, bool added) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100281};
282
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100283class RtcpIntraFrameObserver {
284 public:
285 virtual void OnReceivedIntraFrameRequest(uint32_t ssrc) = 0;
286
nisse25d0bdc2017-03-22 07:15:09 -0700287 RTC_DEPRECATED virtual void OnReceivedSLI(uint32_t ssrc,
288 uint8_t picture_id) {}
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100289
nisse25d0bdc2017-03-22 07:15:09 -0700290 RTC_DEPRECATED virtual void OnReceivedRPSI(uint32_t ssrc,
291 uint64_t picture_id) {}
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100292
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100293 virtual ~RtcpIntraFrameObserver() {}
294};
295
296class RtcpBandwidthObserver {
297 public:
298 // REMB or TMMBR
299 virtual void OnReceivedEstimatedBitrate(uint32_t bitrate) = 0;
300
301 virtual void OnReceivedRtcpReceiverReport(
302 const ReportBlockList& report_blocks,
303 int64_t rtt,
304 int64_t now_ms) = 0;
305
306 virtual ~RtcpBandwidthObserver() {}
307};
308
elad.alonf9490002017-03-06 05:32:21 -0800309struct PacketFeedback {
310 PacketFeedback(int64_t arrival_time_ms, uint16_t sequence_number)
311 : PacketFeedback(-1,
312 arrival_time_ms,
313 -1,
314 sequence_number,
315 0,
Stefan Holmer9ea46b52017-03-15 12:40:25 +0100316 0,
317 0,
elad.alonf9490002017-03-06 05:32:21 -0800318 PacedPacketInfo()) {}
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100319
elad.alonf9490002017-03-06 05:32:21 -0800320 PacketFeedback(int64_t arrival_time_ms,
321 int64_t send_time_ms,
322 uint16_t sequence_number,
323 size_t payload_size,
324 const PacedPacketInfo& pacing_info)
325 : PacketFeedback(-1,
326 arrival_time_ms,
327 send_time_ms,
328 sequence_number,
329 payload_size,
Stefan Holmer9ea46b52017-03-15 12:40:25 +0100330 0,
331 0,
332 pacing_info) {}
333
334 PacketFeedback(int64_t creation_time_ms,
335 uint16_t sequence_number,
336 size_t payload_size,
337 uint16_t local_net_id,
338 uint16_t remote_net_id,
339 const PacedPacketInfo& pacing_info)
340 : PacketFeedback(creation_time_ms,
341 -1,
342 -1,
343 sequence_number,
344 payload_size,
345 local_net_id,
346 remote_net_id,
elad.alonf9490002017-03-06 05:32:21 -0800347 pacing_info) {}
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100348
elad.alonf9490002017-03-06 05:32:21 -0800349 PacketFeedback(int64_t creation_time_ms,
350 int64_t arrival_time_ms,
351 int64_t send_time_ms,
352 uint16_t sequence_number,
353 size_t payload_size,
Stefan Holmer9ea46b52017-03-15 12:40:25 +0100354 uint16_t local_net_id,
355 uint16_t remote_net_id,
elad.alonf9490002017-03-06 05:32:21 -0800356 const PacedPacketInfo& pacing_info)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100357 : creation_time_ms(creation_time_ms),
358 arrival_time_ms(arrival_time_ms),
359 send_time_ms(send_time_ms),
360 sequence_number(sequence_number),
361 payload_size(payload_size),
Stefan Holmer9ea46b52017-03-15 12:40:25 +0100362 local_net_id(local_net_id),
363 remote_net_id(remote_net_id),
philipel8aadd502017-02-23 02:56:13 -0800364 pacing_info(pacing_info) {}
365
366 static constexpr int kNotAProbe = -1;
elad.alonec304f92017-03-08 05:03:53 -0800367 static constexpr int64_t kNotReceived = -1;
philipel8aadd502017-02-23 02:56:13 -0800368
369 // NOTE! The variable |creation_time_ms| is not used when testing equality.
370 // This is due to |creation_time_ms| only being used by SendTimeHistory
371 // for book-keeping, and is of no interest outside that class.
elad.alonf9490002017-03-06 05:32:21 -0800372 // TODO(philipel): Remove |creation_time_ms| from PacketFeedback when cleaning
373 // up SendTimeHistory.
374 bool operator==(const PacketFeedback& rhs) const {
philipel8aadd502017-02-23 02:56:13 -0800375 return arrival_time_ms == rhs.arrival_time_ms &&
376 send_time_ms == rhs.send_time_ms &&
377 sequence_number == rhs.sequence_number &&
378 payload_size == rhs.payload_size && pacing_info == rhs.pacing_info;
379 }
philipela1ed0b32016-06-01 06:31:17 -0700380
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100381 // Time corresponding to when this object was created.
382 int64_t creation_time_ms;
383 // Time corresponding to when the packet was received. Timestamped with the
elad.alonec304f92017-03-08 05:03:53 -0800384 // receiver's clock. For unreceived packet, the sentinel value kNotReceived
385 // is used.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100386 int64_t arrival_time_ms;
387 // Time corresponding to when the packet was sent, timestamped with the
388 // sender's clock.
389 int64_t send_time_ms;
390 // Packet identifier, incremented with 1 for every packet generated by the
391 // sender.
392 uint16_t sequence_number;
393 // Size of the packet excluding RTP headers.
394 size_t payload_size;
Stefan Holmer9ea46b52017-03-15 12:40:25 +0100395 // The network route ids that this packet is associated with.
396 uint16_t local_net_id;
397 uint16_t remote_net_id;
philipel8aadd502017-02-23 02:56:13 -0800398 // Pacing information about this packet.
399 PacedPacketInfo pacing_info;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100400};
401
tschumim3fae6282017-06-11 23:57:17 -0700402class PacketFeedbackComparator {
403 public:
404 inline bool operator()(const PacketFeedback& lhs, const PacketFeedback& rhs) {
405 if (lhs.arrival_time_ms != rhs.arrival_time_ms)
406 return lhs.arrival_time_ms < rhs.arrival_time_ms;
407 if (lhs.send_time_ms != rhs.send_time_ms)
408 return lhs.send_time_ms < rhs.send_time_ms;
409 return lhs.sequence_number < rhs.sequence_number;
410 }
411};
412
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100413class TransportFeedbackObserver {
414 public:
415 TransportFeedbackObserver() {}
416 virtual ~TransportFeedbackObserver() {}
417
philipel8aadd502017-02-23 02:56:13 -0800418 // Note: Transport-wide sequence number as sequence number.
elad.alond12a8e12017-03-23 11:04:48 -0700419 virtual void AddPacket(uint32_t ssrc,
420 uint16_t sequence_number,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100421 size_t length,
philipel8aadd502017-02-23 02:56:13 -0800422 const PacedPacketInfo& pacing_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100423
424 virtual void OnTransportFeedback(const rtcp::TransportFeedback& feedback) = 0;
Stefan Holmer60e43462016-09-07 09:58:20 +0200425
elad.alonf9490002017-03-06 05:32:21 -0800426 virtual std::vector<PacketFeedback> GetTransportFeedbackVector() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100427};
428
elad.alond12a8e12017-03-23 11:04:48 -0700429class PacketFeedbackObserver {
430 public:
431 virtual ~PacketFeedbackObserver() = default;
432
433 virtual void OnPacketAdded(uint32_t ssrc, uint16_t seq_num) = 0;
434 virtual void OnPacketFeedbackVector(
435 const std::vector<PacketFeedback>& packet_feedback_vector) = 0;
436};
437
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100438class RtcpRttStats {
439 public:
440 virtual void OnRttUpdate(int64_t rtt) = 0;
441
442 virtual int64_t LastProcessedRtt() const = 0;
443
danilchap5c1def82015-12-10 09:51:54 -0800444 virtual ~RtcpRttStats() {}
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100445};
446
terelius838cdb32016-10-24 09:38:22 -0700447// Null object version of RtpFeedback.
448class NullRtpFeedback : public RtpFeedback {
449 public:
nisse76e62b02017-05-31 02:24:52 -0700450 ~NullRtpFeedback() override {}
terelius838cdb32016-10-24 09:38:22 -0700451
Karl Wibergc62f6c72017-10-04 12:38:53 +0200452 int32_t OnInitializeDecoder(int payload_type,
453 const SdpAudioFormat& audio_format,
nisse76e62b02017-05-31 02:24:52 -0700454 uint32_t rate) override;
terelius838cdb32016-10-24 09:38:22 -0700455
456 void OnIncomingSSRCChanged(uint32_t ssrc) override {}
457 void OnIncomingCSRCChanged(uint32_t csrc, bool added) override {}
458};
459
nisse76e62b02017-05-31 02:24:52 -0700460inline int32_t NullRtpFeedback::OnInitializeDecoder(
Karl Wibergc62f6c72017-10-04 12:38:53 +0200461 int payload_type,
462 const SdpAudioFormat& audio_format,
nisse76e62b02017-05-31 02:24:52 -0700463 uint32_t rate) {
464 return 0;
465}
466
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100467// Statistics about packet loss for a single directional connection. All values
468// are totals since the connection initiated.
469struct RtpPacketLossStats {
470 // The number of packets lost in events where no adjacent packets were also
471 // lost.
472 uint64_t single_packet_loss_count;
473 // The number of events in which more than one adjacent packet was lost.
474 uint64_t multiple_packet_loss_event_count;
475 // The number of packets lost in events where more than one adjacent packet
476 // was lost.
477 uint64_t multiple_packet_loss_packet_count;
478};
479
480class RtpPacketSender {
481 public:
482 RtpPacketSender() {}
483 virtual ~RtpPacketSender() {}
484
485 enum Priority {
486 kHighPriority = 0, // Pass through; will be sent immediately.
487 kNormalPriority = 2, // Put in back of the line.
488 kLowPriority = 3, // Put in back of the low priority line.
489 };
490 // Low priority packets are mixed with the normal priority packets
491 // while we are paused.
492
493 // Returns true if we send the packet now, else it will add the packet
494 // information to the queue and call TimeToSendPacket when it's time to send.
495 virtual void InsertPacket(Priority priority,
496 uint32_t ssrc,
497 uint16_t sequence_number,
498 int64_t capture_time_ms,
499 size_t bytes,
500 bool retransmission) = 0;
501};
502
503class TransportSequenceNumberAllocator {
504 public:
505 TransportSequenceNumberAllocator() {}
506 virtual ~TransportSequenceNumberAllocator() {}
507
508 virtual uint16_t AllocateSequenceNumber() = 0;
509};
510
511} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200512#endif // MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_