blob: f7c88b87b8e9b5551bd9d907f8bb226f45cb1c5b [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 COMMON_TYPES_H_
12#define COMMON_TYPES_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000014#include <stddef.h>
mallinath@webrtc.org0209e562014-03-21 00:41:28 +000015#include <string.h>
kwiberg5bf4e082016-12-19 06:04:04 -080016#include <ostream>
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000017#include <string>
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000018#include <vector>
19
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "api/array_view.h"
21#include "api/optional.h"
22#include "api/video/video_content_type.h"
23#include "api/video/video_rotation.h"
24#include "api/video/video_timing.h"
25#include "rtc_base/checks.h"
26#include "rtc_base/deprecation.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020027#include "typedefs.h" // NOLINT(build/include)
niklase@google.com470e71d2011-07-07 08:21:25 +000028
andrew@webrtc.org88b8b0d2012-08-14 00:05:56 +000029#if defined(_MSC_VER)
30// Disable "new behavior: elements of array will be default initialized"
31// warning. Affects OverUseDetectorOptions.
solenberg634b86e2016-09-01 07:54:53 -070032#pragma warning(disable : 4351)
andrew@webrtc.org88b8b0d2012-08-14 00:05:56 +000033#endif
34
kwiberg77eab702016-09-28 17:42:01 -070035#if defined(WEBRTC_EXPORT)
andrew@webrtc.org88b8b0d2012-08-14 00:05:56 +000036#define WEBRTC_DLLEXPORT _declspec(dllexport)
kwiberg77eab702016-09-28 17:42:01 -070037#elif defined(WEBRTC_DLL)
andrew@webrtc.org88b8b0d2012-08-14 00:05:56 +000038#define WEBRTC_DLLEXPORT _declspec(dllimport)
niklase@google.com470e71d2011-07-07 08:21:25 +000039#else
andrew@webrtc.org88b8b0d2012-08-14 00:05:56 +000040#define WEBRTC_DLLEXPORT
niklase@google.com470e71d2011-07-07 08:21:25 +000041#endif
42
43#ifndef NULL
andrew@webrtc.org88b8b0d2012-08-14 00:05:56 +000044#define NULL 0
niklase@google.com470e71d2011-07-07 08:21:25 +000045#endif
46
Peter Boström8b79b072016-02-26 16:31:37 +010047#define RTP_PAYLOAD_NAME_SIZE 32u
henrika@webrtc.orgf75901f2012-01-16 08:45:42 +000048
mallinath@webrtc.org0209e562014-03-21 00:41:28 +000049#if defined(WEBRTC_WIN) || defined(WIN32)
andrew@webrtc.orgeda189b2013-09-09 17:50:10 +000050// Compares two strings without regard to case.
51#define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2)
52// Compares characters of two strings without regard to case.
53#define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n)
54#else
55#define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2)
56#define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n)
57#endif
58
niklase@google.com470e71d2011-07-07 08:21:25 +000059namespace webrtc {
60
tommia6219cc2016-06-15 10:30:14 -070061class RewindableStream {
62 public:
63 virtual ~RewindableStream() {}
64 virtual int Rewind() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000065};
66
tommia6219cc2016-06-15 10:30:14 -070067class InStream : public RewindableStream {
68 public:
69 // Reads |len| bytes from file to |buf|. Returns the number of bytes read
70 // or -1 on error.
71 virtual int Read(void* buf, size_t len) = 0;
72};
73
74class OutStream : public RewindableStream {
75 public:
76 // Writes |len| bytes from |buf| to file. The actual writing may happen
77 // some time later. Call Flush() to force a write.
78 virtual bool Write(const void* buf, size_t len) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000079};
80
solenberg634b86e2016-09-01 07:54:53 -070081enum FileFormats {
82 kFileFormatWavFile = 1,
83 kFileFormatCompressedFile = 2,
84 kFileFormatPreencodedFile = 4,
85 kFileFormatPcm16kHzFile = 7,
86 kFileFormatPcm8kHzFile = 8,
Minyue Li85a3b6b2017-09-01 14:36:33 +020087 kFileFormatPcm32kHzFile = 9,
88 kFileFormatPcm48kHzFile = 10
niklase@google.com470e71d2011-07-07 08:21:25 +000089};
90
pbos22993e12015-10-19 02:39:06 -070091enum FrameType {
92 kEmptyFrame = 0,
93 kAudioFrameSpeech = 1,
94 kAudioFrameCN = 2,
95 kVideoFrameKey = 3,
96 kVideoFrameDelta = 4,
sprang@webrtc.org71f055f2013-12-04 15:09:27 +000097};
98
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +000099// Statistics for an RTCP channel
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07 +0000100struct RtcpStatistics {
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07 +0000101 RtcpStatistics()
solenberg634b86e2016-09-01 07:54:53 -0700102 : fraction_lost(0),
srte186d9c32017-08-04 05:03:53 -0700103 packets_lost(0),
104 extended_highest_sequence_number(0),
solenberg634b86e2016-09-01 07:54:53 -0700105 jitter(0) {}
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07 +0000106
107 uint8_t fraction_lost;
srte186d9c32017-08-04 05:03:53 -0700108 union {
109 uint32_t packets_lost;
110 RTC_DEPRECATED uint32_t cumulative_lost;
111 };
112 union {
113 uint32_t extended_highest_sequence_number;
114 RTC_DEPRECATED uint32_t extended_max_sequence_number;
115 };
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07 +0000116 uint32_t jitter;
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07 +0000117};
118
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +0000119class RtcpStatisticsCallback {
120 public:
121 virtual ~RtcpStatisticsCallback() {}
122
123 virtual void StatisticsUpdated(const RtcpStatistics& statistics,
124 uint32_t ssrc) = 0;
pbos@webrtc.orgce4e9a32014-12-18 13:50:16 +0000125 virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +0000126};
127
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000128// Statistics for RTCP packet types.
129struct RtcpPacketTypeCounter {
130 RtcpPacketTypeCounter()
solenberg634b86e2016-09-01 07:54:53 -0700131 : first_packet_time_ms(-1),
132 nack_packets(0),
133 fir_packets(0),
134 pli_packets(0),
135 nack_requests(0),
136 unique_nack_requests(0) {}
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000137
138 void Add(const RtcpPacketTypeCounter& other) {
139 nack_packets += other.nack_packets;
140 fir_packets += other.fir_packets;
141 pli_packets += other.pli_packets;
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000142 nack_requests += other.nack_requests;
143 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.orgd08d3892014-12-16 12:03:11 +0000144 if (other.first_packet_time_ms != -1 &&
solenberg634b86e2016-09-01 07:54:53 -0700145 (other.first_packet_time_ms < first_packet_time_ms ||
146 first_packet_time_ms == -1)) {
asapersson@webrtc.orgd08d3892014-12-16 12:03:11 +0000147 // Use oldest time.
148 first_packet_time_ms = other.first_packet_time_ms;
149 }
150 }
151
sprang07fb9be2016-02-24 07:55:00 -0800152 void Subtract(const RtcpPacketTypeCounter& other) {
153 nack_packets -= other.nack_packets;
154 fir_packets -= other.fir_packets;
155 pli_packets -= other.pli_packets;
156 nack_requests -= other.nack_requests;
157 unique_nack_requests -= other.unique_nack_requests;
158 if (other.first_packet_time_ms != -1 &&
159 (other.first_packet_time_ms > first_packet_time_ms ||
160 first_packet_time_ms == -1)) {
161 // Use youngest time.
162 first_packet_time_ms = other.first_packet_time_ms;
163 }
164 }
165
asapersson@webrtc.orgd08d3892014-12-16 12:03:11 +0000166 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
167 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000168 }
169
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000170 int UniqueNackRequestsInPercent() const {
171 if (nack_requests == 0) {
172 return 0;
173 }
solenberg634b86e2016-09-01 07:54:53 -0700174 return static_cast<int>((unique_nack_requests * 100.0f / nack_requests) +
175 0.5f);
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000176 }
177
solenberg634b86e2016-09-01 07:54:53 -0700178 int64_t first_packet_time_ms; // Time when first packet is sent/received.
179 uint32_t nack_packets; // Number of RTCP NACK packets.
180 uint32_t fir_packets; // Number of RTCP FIR packets.
181 uint32_t pli_packets; // Number of RTCP PLI packets.
182 uint32_t nack_requests; // Number of NACKed RTP packets.
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000183 uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000184};
185
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +0000186class RtcpPacketTypeCounterObserver {
187 public:
188 virtual ~RtcpPacketTypeCounterObserver() {}
189 virtual void RtcpPacketTypesCounterUpdated(
190 uint32_t ssrc,
191 const RtcpPacketTypeCounter& packet_counter) = 0;
192};
193
asapersson@webrtc.orgd08d3892014-12-16 12:03:11 +0000194// Rate statistics for a stream.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +0000195struct BitrateStatistics {
sprangcd349d92016-07-13 09:11:28 -0700196 BitrateStatistics() : bitrate_bps(0), packet_rate(0) {}
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +0000197
solenberg634b86e2016-09-01 07:54:53 -0700198 uint32_t bitrate_bps; // Bitrate in bits per second.
199 uint32_t packet_rate; // Packet rate in packets per second.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +0000200};
201
202// Callback, used to notify an observer whenever new rates have been estimated.
203class BitrateStatisticsObserver {
204 public:
205 virtual ~BitrateStatisticsObserver() {}
206
sprangcd349d92016-07-13 09:11:28 -0700207 virtual void Notify(uint32_t total_bitrate_bps,
208 uint32_t retransmit_bitrate_bps,
stefan@webrtc.org0bae1fa2014-11-05 14:05:29 +0000209 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +0000210};
211
pbos@webrtc.orgce4e9a32014-12-18 13:50:16 +0000212struct FrameCounts {
213 FrameCounts() : key_frames(0), delta_frames(0) {}
214 int key_frames;
215 int delta_frames;
216};
217
asapersson@webrtc.orgd08d3892014-12-16 12:03:11 +0000218// Callback, used to notify an observer whenever frame counts have been updated.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +0000219class FrameCountObserver {
220 public:
sprang@webrtc.org72964bd2013-11-21 09:09:54 +0000221 virtual ~FrameCountObserver() {}
pbos@webrtc.orgce4e9a32014-12-18 13:50:16 +0000222 virtual void FrameCountUpdated(const FrameCounts& frame_counts,
223 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07 +0000224};
225
stefan@webrtc.org168f23f2014-07-11 13:44:02 +0000226// Callback, used to notify an observer whenever the send-side delay is updated.
227class SendSideDelayObserver {
228 public:
229 virtual ~SendSideDelayObserver() {}
230 virtual void SendSideDelayUpdated(int avg_delay_ms,
231 int max_delay_ms,
232 uint32_t ssrc) = 0;
233};
234
asapersson35151f32016-05-02 23:44:01 -0700235// Callback, used to notify an observer whenever a packet is sent to the
236// transport.
237// TODO(asapersson): This class will remove the need for SendSideDelayObserver.
238// Remove SendSideDelayObserver once possible.
239class SendPacketObserver {
240 public:
241 virtual ~SendPacketObserver() {}
242 virtual void OnSendPacket(uint16_t packet_id,
243 int64_t capture_time_ms,
244 uint32_t ssrc) = 0;
245};
246
michaelt4da30442016-11-17 01:38:43 -0800247// Callback, used to notify an observer when the overhead per packet
248// has changed.
249class OverheadObserver {
250 public:
251 virtual ~OverheadObserver() = default;
252 virtual void OnOverheadChanged(size_t overhead_bytes_per_packet) = 0;
253};
254
niklase@google.com470e71d2011-07-07 08:21:25 +0000255// ==================================================================
256// Voice specific types
257// ==================================================================
258
259// Each codec supported can be described by this structure.
mallinath@webrtc.org0209e562014-03-21 00:41:28 +0000260struct CodecInst {
261 int pltype;
262 char plname[RTP_PAYLOAD_NAME_SIZE];
263 int plfreq;
264 int pacsize;
Peter Kasting69558702016-01-12 16:26:35 -0800265 size_t channels;
mallinath@webrtc.org0209e562014-03-21 00:41:28 +0000266 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
267
268 bool operator==(const CodecInst& other) const {
269 return pltype == other.pltype &&
270 (STR_CASE_CMP(plname, other.plname) == 0) &&
solenberg634b86e2016-09-01 07:54:53 -0700271 plfreq == other.plfreq && pacsize == other.pacsize &&
272 channels == other.channels && rate == other.rate;
mallinath@webrtc.org0209e562014-03-21 00:41:28 +0000273 }
274
solenberg634b86e2016-09-01 07:54:53 -0700275 bool operator!=(const CodecInst& other) const { return !(*this == other); }
kwiberg5bf4e082016-12-19 06:04:04 -0800276
277 friend std::ostream& operator<<(std::ostream& os, const CodecInst& ci) {
278 os << "{pltype: " << ci.pltype;
279 os << ", plname: " << ci.plname;
280 os << ", plfreq: " << ci.plfreq;
281 os << ", pacsize: " << ci.pacsize;
282 os << ", channels: " << ci.channels;
283 os << ", rate: " << ci.rate << "}";
284 return os;
285 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000286};
287
niklase@google.com470e71d2011-07-07 08:21:25 +0000288// RTP
solenberg634b86e2016-09-01 07:54:53 -0700289enum { kRtpCsrcSize = 15 }; // RFC 3550 page 13
niklase@google.com470e71d2011-07-07 08:21:25 +0000290
solenberg634b86e2016-09-01 07:54:53 -0700291enum PayloadFrequencies {
292 kFreq8000Hz = 8000,
293 kFreq16000Hz = 16000,
294 kFreq32000Hz = 32000
niklase@google.com470e71d2011-07-07 08:21:25 +0000295};
296
solenberg634b86e2016-09-01 07:54:53 -0700297// Degree of bandwidth reduction.
298enum VadModes {
299 kVadConventional = 0, // lowest reduction
300 kVadAggressiveLow,
301 kVadAggressiveMid,
302 kVadAggressiveHigh // highest reduction
niklase@google.com470e71d2011-07-07 08:21:25 +0000303};
304
solenberg634b86e2016-09-01 07:54:53 -0700305// NETEQ statistics.
306struct NetworkStatistics {
307 // current jitter buffer size in ms
308 uint16_t currentBufferSize;
309 // preferred (optimal) buffer size in ms
310 uint16_t preferredBufferSize;
311 // adding extra delay due to "peaky jitter"
312 bool jitterPeaksFound;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200313 // Stats below correspond to similarly-named fields in the WebRTC stats spec.
314 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats
Steve Anton2dbc69f2017-08-24 17:15:13 -0700315 uint64_t totalSamplesReceived;
Steve Anton2dbc69f2017-08-24 17:15:13 -0700316 uint64_t concealedSamples;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200317 uint64_t concealmentEvents;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200318 uint64_t jitterBufferDelayMs;
319 // Stats below DO NOT correspond directly to anything in the WebRTC stats
solenberg634b86e2016-09-01 07:54:53 -0700320 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
321 uint16_t currentPacketLossRate;
322 // Late loss rate; fraction between 0 and 1, scaled to Q14.
minyue-webrtc0c3ca752017-08-23 15:59:38 +0200323 union {
324 RTC_DEPRECATED uint16_t currentDiscardRate;
325 };
solenberg634b86e2016-09-01 07:54:53 -0700326 // fraction (of original stream) of synthesized audio inserted through
327 // expansion (in Q14)
328 uint16_t currentExpandRate;
329 // fraction (of original stream) of synthesized speech inserted through
330 // expansion (in Q14)
331 uint16_t currentSpeechExpandRate;
332 // fraction of synthesized speech inserted through pre-emptive expansion
333 // (in Q14)
334 uint16_t currentPreemptiveRate;
335 // fraction of data removed through acceleration (in Q14)
336 uint16_t currentAccelerateRate;
337 // fraction of data coming from secondary decoding (in Q14)
338 uint16_t currentSecondaryDecodedRate;
minyue-webrtc0e320ec2017-08-28 13:51:27 +0200339 // Fraction of secondary data, including FEC and RED, that is discarded (in
340 // Q14). Discarding of secondary data can be caused by the reception of the
341 // primary data, obsoleting the secondary data. It can also be caused by early
342 // or late arrival of secondary data.
minyue-webrtc0c3ca752017-08-23 15:59:38 +0200343 uint16_t currentSecondaryDiscardedRate;
solenberg634b86e2016-09-01 07:54:53 -0700344 // clock-drift in parts-per-million (negative or positive)
345 int32_t clockDriftPPM;
346 // average packet waiting time in the jitter buffer (ms)
347 int meanWaitingTimeMs;
348 // median packet waiting time in the jitter buffer (ms)
349 int medianWaitingTimeMs;
350 // min packet waiting time in the jitter buffer (ms)
351 int minWaitingTimeMs;
352 // max packet waiting time in the jitter buffer (ms)
353 int maxWaitingTimeMs;
354 // added samples in off mode due to packet loss
355 size_t addedSamples;
niklase@google.com470e71d2011-07-07 08:21:25 +0000356};
357
wu@webrtc.org24301a62013-12-13 19:17:43 +0000358// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
359struct AudioDecodingCallStats {
360 AudioDecodingCallStats()
361 : calls_to_silence_generator(0),
362 calls_to_neteq(0),
363 decoded_normal(0),
364 decoded_plc(0),
365 decoded_cng(0),
henrik.lundin63489782016-09-20 01:47:12 -0700366 decoded_plc_cng(0),
367 decoded_muted_output(0) {}
wu@webrtc.org24301a62013-12-13 19:17:43 +0000368
369 int calls_to_silence_generator; // Number of calls where silence generated,
370 // and NetEq was disengaged from decoding.
solenberg634b86e2016-09-01 07:54:53 -0700371 int calls_to_neteq; // Number of calls to NetEq.
wu@webrtc.org24301a62013-12-13 19:17:43 +0000372 int decoded_normal; // Number of calls where audio RTP packet decoded.
solenberg634b86e2016-09-01 07:54:53 -0700373 int decoded_plc; // Number of calls resulted in PLC.
wu@webrtc.org24301a62013-12-13 19:17:43 +0000374 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
375 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
henrik.lundin63489782016-09-20 01:47:12 -0700376 int decoded_muted_output; // Number of calls returning a muted state output.
wu@webrtc.org24301a62013-12-13 19:17:43 +0000377};
378
niklase@google.com470e71d2011-07-07 08:21:25 +0000379// ==================================================================
380// Video specific types
381// ==================================================================
382
nisseeb44b392017-04-28 07:18:05 -0700383// TODO(nisse): Delete, and switch to fourcc values everywhere?
384// Supported video types.
385enum class VideoType {
386 kUnknown,
387 kI420,
388 kIYUV,
389 kRGB24,
390 kABGR,
391 kARGB,
392 kARGB4444,
393 kRGB565,
394 kARGB1555,
395 kYUY2,
396 kYV12,
397 kUYVY,
398 kMJPEG,
399 kNV21,
400 kNV12,
401 kBGRA,
niklase@google.com470e71d2011-07-07 08:21:25 +0000402};
403
404// Video codec
solenberg634b86e2016-09-01 07:54:53 -0700405enum { kPayloadNameSize = 32 };
406enum { kMaxSimulcastStreams = 4 };
sprangce4aef12015-11-02 07:23:20 -0800407enum { kMaxSpatialLayers = 5 };
solenberg634b86e2016-09-01 07:54:53 -0700408enum { kMaxTemporalStreams = 4 };
niklase@google.com470e71d2011-07-07 08:21:25 +0000409
solenberg634b86e2016-09-01 07:54:53 -0700410enum VideoCodecComplexity {
411 kComplexityNormal = 0,
412 kComplexityHigh = 1,
413 kComplexityHigher = 2,
414 kComplexityMax = 3
niklase@google.com470e71d2011-07-07 08:21:25 +0000415};
416
stefan@webrtc.orgefd0a482011-12-29 10:12:35 +0000417enum VP8ResilienceMode {
418 kResilienceOff, // The stream produced by the encoder requires a
419 // recovery frame (typically a key frame) to be
420 // decodable after a packet loss.
421 kResilientStream, // A stream produced by the encoder is resilient to
422 // packet losses, but packets within a frame subsequent
423 // to a loss can't be decoded.
424 kResilientFrames // Same as kResilientStream but with added resilience
425 // within a frame.
426};
427
Peter Boström7b971e72016-01-19 16:26:16 +0100428class TemporalLayersFactory;
niklase@google.com470e71d2011-07-07 08:21:25 +0000429// VP8 specific
mallinath@webrtc.org0209e562014-03-21 00:41:28 +0000430struct VideoCodecVP8 {
nisse3257b162017-03-21 01:54:13 -0700431 // TODO(nisse): Unused, delete?
solenberg634b86e2016-09-01 07:54:53 -0700432 bool pictureLossIndicationOn;
mallinath@webrtc.org0209e562014-03-21 00:41:28 +0000433 VideoCodecComplexity complexity;
solenberg634b86e2016-09-01 07:54:53 -0700434 VP8ResilienceMode resilience;
435 unsigned char numberOfTemporalLayers;
436 bool denoisingOn;
437 bool errorConcealmentOn;
438 bool automaticResizeOn;
439 bool frameDroppingOn;
440 int keyFrameInterval;
Erik Språng08127a92016-11-16 16:41:30 +0100441 TemporalLayersFactory* tl_factory;
niklase@google.com470e71d2011-07-07 08:21:25 +0000442};
443
asaperssona9455ab2015-07-31 06:10:09 -0700444// VP9 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48 +0000445struct VideoCodecVP9 {
446 VideoCodecComplexity complexity;
asapersson15dcb382017-06-08 02:55:08 -0700447 bool resilienceOn;
solenberg634b86e2016-09-01 07:54:53 -0700448 unsigned char numberOfTemporalLayers;
449 bool denoisingOn;
450 bool frameDroppingOn;
451 int keyFrameInterval;
452 bool adaptiveQpMode;
453 bool automaticResizeOn;
454 unsigned char numberOfSpatialLayers;
455 bool flexibleMode;
marpan@webrtc.org5b883172014-11-01 06:10:48 +0000456};
457
magjede69a1a92016-11-25 10:06:31 -0800458// TODO(magjed): Move this and other H264 related classes out to their own file.
459namespace H264 {
460
461enum Profile {
462 kProfileConstrainedBaseline,
463 kProfileBaseline,
464 kProfileMain,
465 kProfileConstrainedHigh,
466 kProfileHigh,
467};
468
469} // namespace H264
470
stefan@webrtc.orgb9f54532014-07-04 12:42:07 +0000471// H264 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48 +0000472struct VideoCodecH264 {
solenberg634b86e2016-09-01 07:54:53 -0700473 bool frameDroppingOn;
474 int keyFrameInterval;
marpan@webrtc.org5b883172014-11-01 06:10:48 +0000475 // These are NULL/0 if not externally negotiated.
476 const uint8_t* spsData;
solenberg634b86e2016-09-01 07:54:53 -0700477 size_t spsLen;
marpan@webrtc.org5b883172014-11-01 06:10:48 +0000478 const uint8_t* ppsData;
solenberg634b86e2016-09-01 07:54:53 -0700479 size_t ppsLen;
magjede69a1a92016-11-25 10:06:31 -0800480 H264::Profile profile;
stefan@webrtc.orgb9f54532014-07-04 12:42:07 +0000481};
482
niklase@google.com470e71d2011-07-07 08:21:25 +0000483// Video codec types
marpan@webrtc.org5b883172014-11-01 06:10:48 +0000484enum VideoCodecType {
485 kVideoCodecVP8,
486 kVideoCodecVP9,
487 kVideoCodecH264,
488 kVideoCodecI420,
489 kVideoCodecRED,
490 kVideoCodecULPFEC,
brandtr87d7d772016-11-07 03:03:41 -0800491 kVideoCodecFlexfec,
marpan@webrtc.org5b883172014-11-01 06:10:48 +0000492 kVideoCodecGeneric,
493 kVideoCodecUnknown
niklase@google.com470e71d2011-07-07 08:21:25 +0000494};
495
Erik Språng08127a92016-11-16 16:41:30 +0100496// Translates from name of codec to codec type and vice versa.
kthelgason1cdddc92017-08-24 03:52:48 -0700497const char* CodecTypeToPayloadString(VideoCodecType type);
498VideoCodecType PayloadStringToCodecType(const std::string& name);
Erik Språng08127a92016-11-16 16:41:30 +0100499
marpan@webrtc.org5b883172014-11-01 06:10:48 +0000500union VideoCodecUnion {
solenberg634b86e2016-09-01 07:54:53 -0700501 VideoCodecVP8 VP8;
502 VideoCodecVP9 VP9;
503 VideoCodecH264 H264;
niklase@google.com470e71d2011-07-07 08:21:25 +0000504};
505
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000506// Simulcast is when the same stream is encoded multiple times with different
507// settings such as resolution.
mallinath@webrtc.org0209e562014-03-21 00:41:28 +0000508struct SimulcastStream {
solenberg634b86e2016-09-01 07:54:53 -0700509 unsigned short width;
510 unsigned short height;
511 unsigned char numberOfTemporalLayers;
512 unsigned int maxBitrate; // kilobits/sec.
513 unsigned int targetBitrate; // kilobits/sec.
514 unsigned int minBitrate; // kilobits/sec.
515 unsigned int qpMax; // minimum quality
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +0000516};
517
sprangce4aef12015-11-02 07:23:20 -0800518struct SpatialLayer {
519 int scaling_factor_num;
520 int scaling_factor_den;
521 int target_bitrate_bps;
522 // TODO(ivica): Add max_quantizer and min_quantizer?
523};
524
solenberg634b86e2016-09-01 07:54:53 -0700525enum VideoCodecMode { kRealtimeVideo, kScreensharing };
stefan@webrtc.orgeb917922013-02-18 14:40:18 +0000526
niklase@google.com470e71d2011-07-07 08:21:25 +0000527// Common video codec properties
hta257dc392016-10-25 09:05:06 -0700528class VideoCodec {
529 public:
530 VideoCodec();
531
532 // Public variables. TODO(hta): Make them private with accessors.
solenberg634b86e2016-09-01 07:54:53 -0700533 VideoCodecType codecType;
534 char plName[kPayloadNameSize];
535 unsigned char plType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000536
solenberg634b86e2016-09-01 07:54:53 -0700537 unsigned short width;
538 unsigned short height;
niklase@google.com470e71d2011-07-07 08:21:25 +0000539
solenberg634b86e2016-09-01 07:54:53 -0700540 unsigned int startBitrate; // kilobits/sec.
541 unsigned int maxBitrate; // kilobits/sec.
542 unsigned int minBitrate; // kilobits/sec.
543 unsigned int targetBitrate; // kilobits/sec.
pbos@webrtc.org3c412b22014-03-24 12:36:52 +0000544
Stefan Holmer144475b2017-03-10 15:08:26 +0100545 uint32_t maxFramerate;
niklase@google.com470e71d2011-07-07 08:21:25 +0000546
solenberg634b86e2016-09-01 07:54:53 -0700547 unsigned int qpMax;
548 unsigned char numberOfSimulcastStreams;
549 SimulcastStream simulcastStream[kMaxSimulcastStreams];
sprangce4aef12015-11-02 07:23:20 -0800550 SpatialLayer spatialLayers[kMaxSpatialLayers];
stefan@webrtc.orgeb917922013-02-18 14:40:18 +0000551
solenberg634b86e2016-09-01 07:54:53 -0700552 VideoCodecMode mode;
553 bool expect_encode_from_texture;
andresp@webrtc.org185bae42013-05-14 08:02:25 +0000554
ilnik04f4d122017-06-19 07:18:55 -0700555 // Timing frames configuration. There is delay of delay_ms between two
556 // consequent timing frames, excluding outliers. Frame is always made a
557 // timing frame if it's at least outlier_ratio in percent of "ideal" average
558 // frame given bitrate and framerate, i.e. if it's bigger than
559 // |outlier_ratio / 100.0 * bitrate_bps / fps| in bits. This way, timing
560 // frames will not be sent too often usually. Yet large frames will always
561 // have timing information for debug purposes because they are more likely to
562 // cause extra delays.
563 struct TimingFrameTriggerThresholds {
564 int64_t delay_ms;
565 uint16_t outlier_ratio_percent;
566 } timing_frame_thresholds;
567
Peter Boström7b971e72016-01-19 16:26:16 +0100568 bool operator==(const VideoCodec& other) const = delete;
569 bool operator!=(const VideoCodec& other) const = delete;
hta257dc392016-10-25 09:05:06 -0700570
571 // Accessors for codec specific information.
572 // There is a const version of each that returns a reference,
573 // and a non-const version that returns a pointer, in order
574 // to allow modification of the parameters.
575 VideoCodecVP8* VP8();
576 const VideoCodecVP8& VP8() const;
577 VideoCodecVP9* VP9();
578 const VideoCodecVP9& VP9() const;
579 VideoCodecH264* H264();
580 const VideoCodecH264& H264() const;
581
hta527d3472016-11-16 23:23:04 -0800582 private:
hta257dc392016-10-25 09:05:06 -0700583 // TODO(hta): Consider replacing the union with a pointer type.
584 // This will allow removing the VideoCodec* types from this file.
hta527d3472016-11-16 23:23:04 -0800585 VideoCodecUnion codec_specific_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000586};
astor@webrtc.orgbd7aeba2012-06-26 10:47:04 +0000587
Erik Språng08127a92016-11-16 16:41:30 +0100588class BitrateAllocation {
589 public:
590 static const uint32_t kMaxBitrateBps;
591 BitrateAllocation();
592
593 bool SetBitrate(size_t spatial_index,
594 size_t temporal_index,
595 uint32_t bitrate_bps);
596
597 uint32_t GetBitrate(size_t spatial_index, size_t temporal_index) const;
598
599 // Get the sum of all the temporal layer for a specific spatial layer.
600 uint32_t GetSpatialLayerSum(size_t spatial_index) const;
601
602 uint32_t get_sum_bps() const { return sum_; } // Sum of all bitrates.
603 uint32_t get_sum_kbps() const { return (sum_ + 500) / 1000; }
604
605 inline bool operator==(const BitrateAllocation& other) const {
606 return memcmp(bitrates_, other.bitrates_, sizeof(bitrates_)) == 0;
607 }
608 inline bool operator!=(const BitrateAllocation& other) const {
609 return !(*this == other);
610 }
611
sprangd0fc37a2017-06-22 05:40:25 -0700612 // Expensive, please use only in tests.
613 std::string ToString() const;
614 std::ostream& operator<<(std::ostream& os) const;
615
Erik Språng08127a92016-11-16 16:41:30 +0100616 private:
617 uint32_t sum_;
618 uint32_t bitrates_[kMaxSpatialLayers][kMaxTemporalStreams];
619};
620
stefan64c0a0a2015-11-27 01:02:31 -0800621// Bandwidth over-use detector options. These are used to drive
622// experimentation with bandwidth estimation parameters.
623// See modules/remote_bitrate_estimator/overuse_detector.h
terelius84f83f82016-12-27 10:43:01 -0800624// TODO(terelius): This is only used in overuse_estimator.cc, and only in the
625// default constructed state. Can we move the relevant variables into that
626// class and delete this? See also disabled warning at line 27
stefan64c0a0a2015-11-27 01:02:31 -0800627struct OverUseDetectorOptions {
628 OverUseDetectorOptions()
solenberg634b86e2016-09-01 07:54:53 -0700629 : initial_slope(8.0 / 512.0),
stefan64c0a0a2015-11-27 01:02:31 -0800630 initial_offset(0),
631 initial_e(),
632 initial_process_noise(),
633 initial_avg_noise(0.0),
634 initial_var_noise(50) {
635 initial_e[0][0] = 100;
636 initial_e[1][1] = 1e-1;
637 initial_e[0][1] = initial_e[1][0] = 0;
638 initial_process_noise[0] = 1e-13;
stefan1069cac2016-03-10 05:13:21 -0800639 initial_process_noise[1] = 1e-3;
stefan64c0a0a2015-11-27 01:02:31 -0800640 }
641 double initial_slope;
642 double initial_offset;
643 double initial_e[2][2];
644 double initial_process_noise[2];
645 double initial_avg_noise;
646 double initial_var_noise;
647};
648
wu@webrtc.orga9890802013-12-13 00:21:03 +0000649// This structure will have the information about when packet is actually
650// received by socket.
651struct PacketTime {
henrike@webrtc.org82d3cb62014-04-29 17:50:47 +0000652 PacketTime() : timestamp(-1), not_before(-1) {}
653 PacketTime(int64_t timestamp, int64_t not_before)
solenberg634b86e2016-09-01 07:54:53 -0700654 : timestamp(timestamp), not_before(not_before) {}
wu@webrtc.orga9890802013-12-13 00:21:03 +0000655
henrike@webrtc.org82d3cb62014-04-29 17:50:47 +0000656 int64_t timestamp; // Receive time after socket delivers the data.
657 int64_t not_before; // Earliest possible time the data could have arrived,
658 // indicating the potential error in the |timestamp|
659 // value,in case the system is busy.
660 // For example, the time of the last select() call.
661 // If unknown, this value will be set to zero.
wu@webrtc.orga9890802013-12-13 00:21:03 +0000662};
663
isheriff6b4b5f32016-06-08 00:24:21 -0700664// Minimum and maximum playout delay values from capture to render.
665// These are best effort values.
666//
667// A value < 0 indicates no change from previous valid value.
668//
669// min = max = 0 indicates that the receiver should try and render
670// frame as soon as possible.
671//
672// min = x, max = y indicates that the receiver is free to adapt
673// in the range (x, y) based on network jitter.
674//
675// Note: Given that this gets embedded in a union, it is up-to the owner to
676// initialize these values.
677struct PlayoutDelay {
678 int min_ms;
679 int max_ms;
680};
681
Steve Antona3251dd2017-07-21 09:58:31 -0700682// Class to represent the value of RTP header extensions that are
683// variable-length strings (e.g., RtpStreamId and RtpMid).
danilchapef8d7732017-04-19 02:59:48 -0700684// Unlike std::string, it can be copied with memcpy and cleared with memset.
Steve Antona3251dd2017-07-21 09:58:31 -0700685//
686// Empty value represents unset header extension (use empty() to query).
687class StringRtpHeaderExtension {
danilchapef8d7732017-04-19 02:59:48 -0700688 public:
Steve Antona3251dd2017-07-21 09:58:31 -0700689 // String RTP header extensions are limited to 16 bytes because it is the
690 // maximum length that can be encoded with one-byte header extensions.
danilchapef8d7732017-04-19 02:59:48 -0700691 static constexpr size_t kMaxSize = 16;
692
eladalond0244c22017-06-08 04:19:13 -0700693 static bool IsLegalName(rtc::ArrayView<const char> name);
694
Steve Antona3251dd2017-07-21 09:58:31 -0700695 StringRtpHeaderExtension() { value_[0] = 0; }
696 explicit StringRtpHeaderExtension(rtc::ArrayView<const char> value) {
danilchapef8d7732017-04-19 02:59:48 -0700697 Set(value.data(), value.size());
698 }
Steve Antona3251dd2017-07-21 09:58:31 -0700699 StringRtpHeaderExtension(const StringRtpHeaderExtension&) = default;
700 StringRtpHeaderExtension& operator=(const StringRtpHeaderExtension&) =
701 default;
danilchapef8d7732017-04-19 02:59:48 -0700702
703 bool empty() const { return value_[0] == 0; }
704 const char* data() const { return value_; }
705 size_t size() const { return strnlen(value_, kMaxSize); }
706
707 void Set(rtc::ArrayView<const uint8_t> value) {
708 Set(reinterpret_cast<const char*>(value.data()), value.size());
709 }
710 void Set(const char* data, size_t size);
711
Steve Antona3251dd2017-07-21 09:58:31 -0700712 friend bool operator==(const StringRtpHeaderExtension& lhs,
713 const StringRtpHeaderExtension& rhs) {
danilchapef8d7732017-04-19 02:59:48 -0700714 return strncmp(lhs.value_, rhs.value_, kMaxSize) == 0;
715 }
Steve Antona3251dd2017-07-21 09:58:31 -0700716 friend bool operator!=(const StringRtpHeaderExtension& lhs,
717 const StringRtpHeaderExtension& rhs) {
danilchapef8d7732017-04-19 02:59:48 -0700718 return !(lhs == rhs);
719 }
720
721 private:
722 char value_[kMaxSize];
723};
724
Steve Antona3251dd2017-07-21 09:58:31 -0700725// StreamId represents RtpStreamId which is a string.
726typedef StringRtpHeaderExtension StreamId;
727
728// Mid represents RtpMid which is a string.
729typedef StringRtpHeaderExtension Mid;
730
solenberg@webrtc.orgb1f50102014-03-24 10:38:25 +0000731struct RTPHeaderExtension {
sprang@webrtc.org30933902015-03-17 14:33:12 +0000732 RTPHeaderExtension();
eladalon98b1b7d2017-09-11 08:48:26 -0700733 RTPHeaderExtension(const RTPHeaderExtension& other);
734 RTPHeaderExtension& operator=(const RTPHeaderExtension& other);
solenberg@webrtc.orgb1f50102014-03-24 10:38:25 +0000735
736 bool hasTransmissionTimeOffset;
737 int32_t transmissionTimeOffset;
738 bool hasAbsoluteSendTime;
739 uint32_t absoluteSendTime;
sprang@webrtc.org30933902015-03-17 14:33:12 +0000740 bool hasTransportSequenceNumber;
741 uint16_t transportSequenceNumber;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25 +0000742
743 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
744 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
745 bool hasAudioLevel;
Minyue4cee4192015-08-10 15:08:36 +0200746 bool voiceActivity;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25 +0000747 uint8_t audioLevel;
guoweis@webrtc.org45362892015-03-04 22:55:15 +0000748
749 // For Coordination of Video Orientation. See
750 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
751 // ts_126114v120700p.pdf
752 bool hasVideoRotation;
magjed71eb61c2016-09-08 03:24:58 -0700753 VideoRotation videoRotation;
isheriff6b4b5f32016-06-08 00:24:21 -0700754
ilnik00d802b2017-04-11 10:34:31 -0700755 // TODO(ilnik): Refactor this and one above to be rtc::Optional() and remove
756 // a corresponding bool flag.
757 bool hasVideoContentType;
758 VideoContentType videoContentType;
759
ilnik04f4d122017-06-19 07:18:55 -0700760 bool has_video_timing;
ilnik2edc6842017-07-06 03:06:50 -0700761 VideoSendTiming video_timing;
ilnik04f4d122017-06-19 07:18:55 -0700762
isheriff6b4b5f32016-06-08 00:24:21 -0700763 PlayoutDelay playout_delay = {-1, -1};
danilchapef8d7732017-04-19 02:59:48 -0700764
765 // For identification of a stream when ssrc is not signaled. See
766 // https://tools.ietf.org/html/draft-ietf-avtext-rid-09
767 // TODO(danilchap): Update url from draft to release version.
768 StreamId stream_id;
769 StreamId repaired_stream_id;
Steve Antona3251dd2017-07-21 09:58:31 -0700770
771 // For identifying the media section used to interpret this RTP packet. See
772 // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-38
773 Mid mid;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25 +0000774};
775
776struct RTPHeader {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000777 RTPHeader();
eladalon98b1b7d2017-09-11 08:48:26 -0700778 RTPHeader(const RTPHeader& other);
779 RTPHeader& operator=(const RTPHeader& other);
solenberg@webrtc.orgb1f50102014-03-24 10:38:25 +0000780
781 bool markerBit;
782 uint8_t payloadType;
783 uint16_t sequenceNumber;
784 uint32_t timestamp;
785 uint32_t ssrc;
786 uint8_t numCSRCs;
787 uint32_t arrOfCSRCs[kRtpCsrcSize];
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +0000788 size_t paddingLength;
789 size_t headerLength;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25 +0000790 int payload_type_frequency;
791 RTPHeaderExtension extension;
792};
793
asapersson@webrtc.org44149392015-02-04 08:34:47 +0000794struct RtpPacketCounter {
795 RtpPacketCounter()
solenberg634b86e2016-09-01 07:54:53 -0700796 : header_bytes(0), payload_bytes(0), padding_bytes(0), packets(0) {}
asapersson@webrtc.org44149392015-02-04 08:34:47 +0000797
798 void Add(const RtpPacketCounter& other) {
799 header_bytes += other.header_bytes;
800 payload_bytes += other.payload_bytes;
801 padding_bytes += other.padding_bytes;
802 packets += other.packets;
803 }
804
Erik Språng22c2b482016-03-01 09:40:42 +0100805 void Subtract(const RtpPacketCounter& other) {
kwibergb890c95c2016-11-29 05:30:40 -0800806 RTC_DCHECK_GE(header_bytes, other.header_bytes);
Erik Språng22c2b482016-03-01 09:40:42 +0100807 header_bytes -= other.header_bytes;
kwibergb890c95c2016-11-29 05:30:40 -0800808 RTC_DCHECK_GE(payload_bytes, other.payload_bytes);
Erik Språng22c2b482016-03-01 09:40:42 +0100809 payload_bytes -= other.payload_bytes;
kwibergb890c95c2016-11-29 05:30:40 -0800810 RTC_DCHECK_GE(padding_bytes, other.padding_bytes);
Erik Språng22c2b482016-03-01 09:40:42 +0100811 padding_bytes -= other.padding_bytes;
kwibergb890c95c2016-11-29 05:30:40 -0800812 RTC_DCHECK_GE(packets, other.packets);
Erik Språng22c2b482016-03-01 09:40:42 +0100813 packets -= other.packets;
814 }
815
asapersson@webrtc.org44149392015-02-04 08:34:47 +0000816 void AddPacket(size_t packet_length, const RTPHeader& header) {
817 ++packets;
818 header_bytes += header.headerLength;
819 padding_bytes += header.paddingLength;
820 payload_bytes +=
821 packet_length - (header.headerLength + header.paddingLength);
822 }
823
824 size_t TotalBytes() const {
825 return header_bytes + payload_bytes + padding_bytes;
826 }
827
828 size_t header_bytes; // Number of bytes used by RTP headers.
829 size_t payload_bytes; // Payload bytes, excluding RTP headers and padding.
830 size_t padding_bytes; // Number of padding bytes.
831 uint32_t packets; // Number of packets.
832};
833
834// Data usage statistics for a (rtp) stream.
835struct StreamDataCounters {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000836 StreamDataCounters();
asapersson@webrtc.org44149392015-02-04 08:34:47 +0000837
838 void Add(const StreamDataCounters& other) {
839 transmitted.Add(other.transmitted);
840 retransmitted.Add(other.retransmitted);
841 fec.Add(other.fec);
842 if (other.first_packet_time_ms != -1 &&
solenberg634b86e2016-09-01 07:54:53 -0700843 (other.first_packet_time_ms < first_packet_time_ms ||
844 first_packet_time_ms == -1)) {
asapersson@webrtc.org44149392015-02-04 08:34:47 +0000845 // Use oldest time.
846 first_packet_time_ms = other.first_packet_time_ms;
847 }
848 }
849
Erik Språng22c2b482016-03-01 09:40:42 +0100850 void Subtract(const StreamDataCounters& other) {
851 transmitted.Subtract(other.transmitted);
852 retransmitted.Subtract(other.retransmitted);
853 fec.Subtract(other.fec);
854 if (other.first_packet_time_ms != -1 &&
855 (other.first_packet_time_ms > first_packet_time_ms ||
856 first_packet_time_ms == -1)) {
857 // Use youngest time.
858 first_packet_time_ms = other.first_packet_time_ms;
859 }
860 }
861
asapersson@webrtc.org44149392015-02-04 08:34:47 +0000862 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
863 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
864 }
865
866 // Returns the number of bytes corresponding to the actual media payload (i.e.
867 // RTP headers, padding, retransmissions and fec packets are excluded).
868 // Note this function does not have meaning for an RTX stream.
869 size_t MediaPayloadBytes() const {
870 return transmitted.payload_bytes - retransmitted.payload_bytes -
871 fec.payload_bytes;
872 }
873
solenberg634b86e2016-09-01 07:54:53 -0700874 int64_t first_packet_time_ms; // Time when first packet is sent/received.
875 RtpPacketCounter transmitted; // Number of transmitted packets/bytes.
asapersson@webrtc.org44149392015-02-04 08:34:47 +0000876 RtpPacketCounter retransmitted; // Number of retransmitted packets/bytes.
solenberg634b86e2016-09-01 07:54:53 -0700877 RtpPacketCounter fec; // Number of redundancy packets/bytes.
asapersson@webrtc.org44149392015-02-04 08:34:47 +0000878};
879
880// Callback, called whenever byte/packet counts have been updated.
881class StreamDataCountersCallback {
882 public:
883 virtual ~StreamDataCountersCallback() {}
884
885 virtual void DataCountersUpdated(const StreamDataCounters& counters,
886 uint32_t ssrc) = 0;
887};
pbosda903ea2015-10-02 02:36:56 -0700888
889// RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size
890// RTCP mode is described by RFC 5506.
891enum class RtcpMode { kOff, kCompound, kReducedSize };
892
pbos1ba8d392016-05-01 20:18:34 -0700893enum NetworkState {
894 kNetworkUp,
895 kNetworkDown,
896};
897
sprangdb2a9fc2017-08-09 06:42:32 -0700898struct RtpKeepAliveConfig final {
sprang168794c2017-07-06 04:38:06 -0700899 // If no packet has been sent for |timeout_interval_ms|, send a keep-alive
900 // packet. The keep-alive packet is an empty (no payload) RTP packet with a
901 // payload type of 20 as long as the other end has not negotiated the use of
902 // this value. If this value has already been negotiated, then some other
903 // unused static payload type from table 5 of RFC 3551 shall be used and set
904 // in |payload_type|.
905 int64_t timeout_interval_ms = -1;
906 uint8_t payload_type = 20;
sprangdb2a9fc2017-08-09 06:42:32 -0700907
908 bool operator==(const RtpKeepAliveConfig& o) const {
909 return timeout_interval_ms == o.timeout_interval_ms &&
910 payload_type == o.payload_type;
911 }
912 bool operator!=(const RtpKeepAliveConfig& o) const { return !(*this == o); }
sprang168794c2017-07-06 04:38:06 -0700913};
914
Åsa Persson4bece9a2017-10-06 10:04:04 +0200915// Currently only VP8/VP9 specific.
916struct RtpPayloadState {
917 int16_t picture_id = -1;
918};
919
niklase@google.com470e71d2011-07-07 08:21:25 +0000920} // namespace webrtc
andrew@webrtc.orgeda189b2013-09-09 17:50:10 +0000921
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200922#endif // COMMON_TYPES_H_