blob: dee1343fc42690ed71083331b706c28f7103cb2a [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:251/*
phoglund@webrtc.org8bfee842012-02-17 09:32:482 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:253 *
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 04:47:3111#ifndef COMMON_TYPES_H_
12#define COMMON_TYPES_H_
niklase@google.com470e71d2011-07-07 08:21:2513
pbos@webrtc.orgf577ae92014-03-19 08:43:5714#include <stddef.h>
mallinath@webrtc.org0209e562014-03-21 00:41:2815#include <string.h>
pbos@webrtc.org1e92b0a2014-05-15 09:35:0616#include <string>
pbos@webrtc.orgf577ae92014-03-19 08:43:5717#include <vector>
18
Mirko Bonadei92ea95e2017-09-15 04:47:3119#include "api/array_view.h"
20#include "api/optional.h"
Erik Språng566124a2018-04-23 10:32:2221// TODO(sprang): Remove this include when all usage includes it directly.
22#include "api/video/video_bitrate_allocation.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3123#include "rtc_base/checks.h"
24#include "rtc_base/deprecation.h"
Mirko Bonadei71207422017-09-15 11:58:0925#include "typedefs.h" // NOLINT(build/include)
niklase@google.com470e71d2011-07-07 08:21:2526
andrew@webrtc.org88b8b0d2012-08-14 00:05:5627#if defined(_MSC_VER)
28// Disable "new behavior: elements of array will be default initialized"
29// warning. Affects OverUseDetectorOptions.
solenberg634b86e2016-09-01 14:54:5330#pragma warning(disable : 4351)
andrew@webrtc.org88b8b0d2012-08-14 00:05:5631#endif
32
Peter Boström8b79b072016-02-26 15:31:3733#define RTP_PAYLOAD_NAME_SIZE 32u
henrika@webrtc.orgf75901f2012-01-16 08:45:4234
mallinath@webrtc.org0209e562014-03-21 00:41:2835#if defined(WEBRTC_WIN) || defined(WIN32)
andrew@webrtc.orgeda189b2013-09-09 17:50:1036// Compares two strings without regard to case.
37#define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2)
38// Compares characters of two strings without regard to case.
39#define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n)
40#else
41#define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2)
42#define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n)
43#endif
44
niklase@google.com470e71d2011-07-07 08:21:2545namespace webrtc {
46
pbos22993e12015-10-19 09:39:0647enum FrameType {
48 kEmptyFrame = 0,
49 kAudioFrameSpeech = 1,
50 kAudioFrameCN = 2,
51 kVideoFrameKey = 3,
52 kVideoFrameDelta = 4,
sprang@webrtc.org71f055f2013-12-04 15:09:2753};
54
sprang@webrtc.orgdc50aae2013-11-20 16:47:0755// Statistics for an RTCP channel
sprang@webrtc.orgfe5d36b2013-10-28 09:21:0756struct RtcpStatistics {
sprang@webrtc.orgfe5d36b2013-10-28 09:21:0757 RtcpStatistics()
solenberg634b86e2016-09-01 14:54:5358 : fraction_lost(0),
srte186d9c32017-08-04 12:03:5359 packets_lost(0),
60 extended_highest_sequence_number(0),
solenberg634b86e2016-09-01 14:54:5361 jitter(0) {}
sprang@webrtc.orgfe5d36b2013-10-28 09:21:0762
63 uint8_t fraction_lost;
srte186d9c32017-08-04 12:03:5364 union {
Harald Alvestrandc7c41912017-12-08 08:59:3465 int32_t packets_lost; // Defined as a 24 bit signed integer in RTCP
srte186d9c32017-08-04 12:03:5366 RTC_DEPRECATED uint32_t cumulative_lost;
67 };
68 union {
69 uint32_t extended_highest_sequence_number;
70 RTC_DEPRECATED uint32_t extended_max_sequence_number;
71 };
sprang@webrtc.orgfe5d36b2013-10-28 09:21:0772 uint32_t jitter;
sprang@webrtc.orgfe5d36b2013-10-28 09:21:0773};
74
sprang@webrtc.orgdc50aae2013-11-20 16:47:0775class RtcpStatisticsCallback {
76 public:
77 virtual ~RtcpStatisticsCallback() {}
78
79 virtual void StatisticsUpdated(const RtcpStatistics& statistics,
80 uint32_t ssrc) = 0;
pbos@webrtc.orgce4e9a32014-12-18 13:50:1681 virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:0782};
83
asapersson@webrtc.org8098e072014-02-19 11:59:0284// Statistics for RTCP packet types.
85struct RtcpPacketTypeCounter {
86 RtcpPacketTypeCounter()
solenberg634b86e2016-09-01 14:54:5387 : first_packet_time_ms(-1),
88 nack_packets(0),
89 fir_packets(0),
90 pli_packets(0),
91 nack_requests(0),
92 unique_nack_requests(0) {}
asapersson@webrtc.org8098e072014-02-19 11:59:0293
94 void Add(const RtcpPacketTypeCounter& other) {
95 nack_packets += other.nack_packets;
96 fir_packets += other.fir_packets;
97 pli_packets += other.pli_packets;
asapersson@webrtc.org2dd31342014-10-29 12:42:3098 nack_requests += other.nack_requests;
99 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.orgd08d3892014-12-16 12:03:11100 if (other.first_packet_time_ms != -1 &&
solenberg634b86e2016-09-01 14:54:53101 (other.first_packet_time_ms < first_packet_time_ms ||
102 first_packet_time_ms == -1)) {
asapersson@webrtc.orgd08d3892014-12-16 12:03:11103 // Use oldest time.
104 first_packet_time_ms = other.first_packet_time_ms;
105 }
106 }
107
sprang07fb9be2016-02-24 15:55:00108 void Subtract(const RtcpPacketTypeCounter& other) {
109 nack_packets -= other.nack_packets;
110 fir_packets -= other.fir_packets;
111 pli_packets -= other.pli_packets;
112 nack_requests -= other.nack_requests;
113 unique_nack_requests -= other.unique_nack_requests;
114 if (other.first_packet_time_ms != -1 &&
115 (other.first_packet_time_ms > first_packet_time_ms ||
116 first_packet_time_ms == -1)) {
117 // Use youngest time.
118 first_packet_time_ms = other.first_packet_time_ms;
119 }
120 }
121
asapersson@webrtc.orgd08d3892014-12-16 12:03:11122 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
123 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
asapersson@webrtc.org8098e072014-02-19 11:59:02124 }
125
asapersson@webrtc.org2dd31342014-10-29 12:42:30126 int UniqueNackRequestsInPercent() const {
127 if (nack_requests == 0) {
128 return 0;
129 }
solenberg634b86e2016-09-01 14:54:53130 return static_cast<int>((unique_nack_requests * 100.0f / nack_requests) +
131 0.5f);
asapersson@webrtc.org2dd31342014-10-29 12:42:30132 }
133
solenberg634b86e2016-09-01 14:54:53134 int64_t first_packet_time_ms; // Time when first packet is sent/received.
135 uint32_t nack_packets; // Number of RTCP NACK packets.
136 uint32_t fir_packets; // Number of RTCP FIR packets.
137 uint32_t pli_packets; // Number of RTCP PLI packets.
138 uint32_t nack_requests; // Number of NACKed RTP packets.
asapersson@webrtc.org2dd31342014-10-29 12:42:30139 uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
asapersson@webrtc.org8098e072014-02-19 11:59:02140};
141
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00142class RtcpPacketTypeCounterObserver {
143 public:
144 virtual ~RtcpPacketTypeCounterObserver() {}
145 virtual void RtcpPacketTypesCounterUpdated(
146 uint32_t ssrc,
147 const RtcpPacketTypeCounter& packet_counter) = 0;
148};
149
sprang@webrtc.orgdc50aae2013-11-20 16:47:07150// Callback, used to notify an observer whenever new rates have been estimated.
151class BitrateStatisticsObserver {
152 public:
153 virtual ~BitrateStatisticsObserver() {}
154
sprangcd349d92016-07-13 16:11:28155 virtual void Notify(uint32_t total_bitrate_bps,
156 uint32_t retransmit_bitrate_bps,
stefan@webrtc.org0bae1fa2014-11-05 14:05:29157 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07158};
159
pbos@webrtc.orgce4e9a32014-12-18 13:50:16160struct FrameCounts {
161 FrameCounts() : key_frames(0), delta_frames(0) {}
162 int key_frames;
163 int delta_frames;
164};
165
asapersson@webrtc.orgd08d3892014-12-16 12:03:11166// Callback, used to notify an observer whenever frame counts have been updated.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07167class FrameCountObserver {
168 public:
sprang@webrtc.org72964bd2013-11-21 09:09:54169 virtual ~FrameCountObserver() {}
pbos@webrtc.orgce4e9a32014-12-18 13:50:16170 virtual void FrameCountUpdated(const FrameCounts& frame_counts,
171 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07172};
173
stefan@webrtc.org168f23f2014-07-11 13:44:02174// Callback, used to notify an observer whenever the send-side delay is updated.
175class SendSideDelayObserver {
176 public:
177 virtual ~SendSideDelayObserver() {}
178 virtual void SendSideDelayUpdated(int avg_delay_ms,
179 int max_delay_ms,
180 uint32_t ssrc) = 0;
181};
182
asapersson35151f32016-05-03 06:44:01183// Callback, used to notify an observer whenever a packet is sent to the
184// transport.
185// TODO(asapersson): This class will remove the need for SendSideDelayObserver.
186// Remove SendSideDelayObserver once possible.
187class SendPacketObserver {
188 public:
189 virtual ~SendPacketObserver() {}
190 virtual void OnSendPacket(uint16_t packet_id,
191 int64_t capture_time_ms,
192 uint32_t ssrc) = 0;
193};
194
michaelt4da30442016-11-17 09:38:43195// Callback, used to notify an observer when the overhead per packet
196// has changed.
197class OverheadObserver {
198 public:
199 virtual ~OverheadObserver() = default;
200 virtual void OnOverheadChanged(size_t overhead_bytes_per_packet) = 0;
201};
202
niklase@google.com470e71d2011-07-07 08:21:25203// ==================================================================
204// Voice specific types
205// ==================================================================
206
207// Each codec supported can be described by this structure.
mallinath@webrtc.org0209e562014-03-21 00:41:28208struct CodecInst {
209 int pltype;
210 char plname[RTP_PAYLOAD_NAME_SIZE];
211 int plfreq;
212 int pacsize;
Peter Kasting69558702016-01-13 00:26:35213 size_t channels;
mallinath@webrtc.org0209e562014-03-21 00:41:28214 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
215
216 bool operator==(const CodecInst& other) const {
217 return pltype == other.pltype &&
218 (STR_CASE_CMP(plname, other.plname) == 0) &&
solenberg634b86e2016-09-01 14:54:53219 plfreq == other.plfreq && pacsize == other.pacsize &&
220 channels == other.channels && rate == other.rate;
mallinath@webrtc.org0209e562014-03-21 00:41:28221 }
222
solenberg634b86e2016-09-01 14:54:53223 bool operator!=(const CodecInst& other) const { return !(*this == other); }
niklase@google.com470e71d2011-07-07 08:21:25224};
225
niklase@google.com470e71d2011-07-07 08:21:25226// RTP
solenberg634b86e2016-09-01 14:54:53227enum { kRtpCsrcSize = 15 }; // RFC 3550 page 13
niklase@google.com470e71d2011-07-07 08:21:25228
solenberg634b86e2016-09-01 14:54:53229// NETEQ statistics.
230struct NetworkStatistics {
231 // current jitter buffer size in ms
232 uint16_t currentBufferSize;
233 // preferred (optimal) buffer size in ms
234 uint16_t preferredBufferSize;
235 // adding extra delay due to "peaky jitter"
236 bool jitterPeaksFound;
Gustaf Ullbergb0a02072017-10-02 10:00:34237 // Stats below correspond to similarly-named fields in the WebRTC stats spec.
238 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats
Steve Anton2dbc69f2017-08-25 00:15:13239 uint64_t totalSamplesReceived;
Steve Anton2dbc69f2017-08-25 00:15:13240 uint64_t concealedSamples;
Gustaf Ullberg9a2e9062017-09-18 07:28:20241 uint64_t concealmentEvents;
Gustaf Ullbergb0a02072017-10-02 10:00:34242 uint64_t jitterBufferDelayMs;
243 // Stats below DO NOT correspond directly to anything in the WebRTC stats
solenberg634b86e2016-09-01 14:54:53244 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
245 uint16_t currentPacketLossRate;
246 // Late loss rate; fraction between 0 and 1, scaled to Q14.
minyue-webrtc0c3ca752017-08-23 13:59:38247 union {
248 RTC_DEPRECATED uint16_t currentDiscardRate;
249 };
solenberg634b86e2016-09-01 14:54:53250 // fraction (of original stream) of synthesized audio inserted through
251 // expansion (in Q14)
252 uint16_t currentExpandRate;
253 // fraction (of original stream) of synthesized speech inserted through
254 // expansion (in Q14)
255 uint16_t currentSpeechExpandRate;
256 // fraction of synthesized speech inserted through pre-emptive expansion
257 // (in Q14)
258 uint16_t currentPreemptiveRate;
259 // fraction of data removed through acceleration (in Q14)
260 uint16_t currentAccelerateRate;
261 // fraction of data coming from secondary decoding (in Q14)
262 uint16_t currentSecondaryDecodedRate;
minyue-webrtc0e320ec2017-08-28 11:51:27263 // Fraction of secondary data, including FEC and RED, that is discarded (in
264 // Q14). Discarding of secondary data can be caused by the reception of the
265 // primary data, obsoleting the secondary data. It can also be caused by early
266 // or late arrival of secondary data.
minyue-webrtc0c3ca752017-08-23 13:59:38267 uint16_t currentSecondaryDiscardedRate;
solenberg634b86e2016-09-01 14:54:53268 // clock-drift in parts-per-million (negative or positive)
269 int32_t clockDriftPPM;
270 // average packet waiting time in the jitter buffer (ms)
271 int meanWaitingTimeMs;
272 // median packet waiting time in the jitter buffer (ms)
273 int medianWaitingTimeMs;
274 // min packet waiting time in the jitter buffer (ms)
275 int minWaitingTimeMs;
276 // max packet waiting time in the jitter buffer (ms)
277 int maxWaitingTimeMs;
278 // added samples in off mode due to packet loss
279 size_t addedSamples;
niklase@google.com470e71d2011-07-07 08:21:25280};
281
wu@webrtc.org24301a62013-12-13 19:17:43282// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
283struct AudioDecodingCallStats {
284 AudioDecodingCallStats()
285 : calls_to_silence_generator(0),
286 calls_to_neteq(0),
287 decoded_normal(0),
288 decoded_plc(0),
289 decoded_cng(0),
henrik.lundin63489782016-09-20 08:47:12290 decoded_plc_cng(0),
291 decoded_muted_output(0) {}
wu@webrtc.org24301a62013-12-13 19:17:43292
293 int calls_to_silence_generator; // Number of calls where silence generated,
294 // and NetEq was disengaged from decoding.
solenberg634b86e2016-09-01 14:54:53295 int calls_to_neteq; // Number of calls to NetEq.
wu@webrtc.org24301a62013-12-13 19:17:43296 int decoded_normal; // Number of calls where audio RTP packet decoded.
solenberg634b86e2016-09-01 14:54:53297 int decoded_plc; // Number of calls resulted in PLC.
wu@webrtc.org24301a62013-12-13 19:17:43298 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
299 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
henrik.lundin63489782016-09-20 08:47:12300 int decoded_muted_output; // Number of calls returning a muted state output.
wu@webrtc.org24301a62013-12-13 19:17:43301};
302
niklase@google.com470e71d2011-07-07 08:21:25303// ==================================================================
304// Video specific types
305// ==================================================================
306
nisseeb44b392017-04-28 14:18:05307// TODO(nisse): Delete, and switch to fourcc values everywhere?
308// Supported video types.
309enum class VideoType {
310 kUnknown,
311 kI420,
312 kIYUV,
313 kRGB24,
314 kABGR,
315 kARGB,
316 kARGB4444,
317 kRGB565,
318 kARGB1555,
319 kYUY2,
320 kYV12,
321 kUYVY,
322 kMJPEG,
323 kNV21,
324 kNV12,
325 kBGRA,
niklase@google.com470e71d2011-07-07 08:21:25326};
327
328// Video codec
solenberg634b86e2016-09-01 14:54:53329enum VideoCodecComplexity {
330 kComplexityNormal = 0,
331 kComplexityHigh = 1,
332 kComplexityHigher = 2,
333 kComplexityMax = 3
niklase@google.com470e71d2011-07-07 08:21:25334};
335
niklase@google.com470e71d2011-07-07 08:21:25336// VP8 specific
mallinath@webrtc.org0209e562014-03-21 00:41:28337struct VideoCodecVP8 {
Niels Möllerdef1ef52018-03-19 12:48:44338 bool operator==(const VideoCodecVP8& other) const;
339 bool operator!=(const VideoCodecVP8& other) const {
340 return !(*this == other);
341 }
mallinath@webrtc.org0209e562014-03-21 00:41:28342 VideoCodecComplexity complexity;
solenberg634b86e2016-09-01 14:54:53343 unsigned char numberOfTemporalLayers;
344 bool denoisingOn;
solenberg634b86e2016-09-01 14:54:53345 bool automaticResizeOn;
346 bool frameDroppingOn;
347 int keyFrameInterval;
niklase@google.com470e71d2011-07-07 08:21:25348};
349
Sergey Silkin6a8f30e2018-04-26 09:03:49350enum class InterLayerPredMode {
351 kOn, // Allow inter-layer prediction for all frames.
352 // Frame of low spatial layer can be used for
353 // prediction of next spatial layer frame.
354 kOff, // Encoder produces independent spatial layers.
355 kOnKeyPic // Allow inter-layer prediction only for frames
356 // within key picture.
357};
358
asaperssona9455ab2015-07-31 13:10:09359// VP9 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48360struct VideoCodecVP9 {
Niels Möllerdef1ef52018-03-19 12:48:44361 bool operator==(const VideoCodecVP9& other) const;
362 bool operator!=(const VideoCodecVP9& other) const {
363 return !(*this == other);
364 }
marpan@webrtc.org5b883172014-11-01 06:10:48365 VideoCodecComplexity complexity;
solenberg634b86e2016-09-01 14:54:53366 unsigned char numberOfTemporalLayers;
367 bool denoisingOn;
368 bool frameDroppingOn;
369 int keyFrameInterval;
370 bool adaptiveQpMode;
371 bool automaticResizeOn;
372 unsigned char numberOfSpatialLayers;
373 bool flexibleMode;
Sergey Silkin6a8f30e2018-04-26 09:03:49374 InterLayerPredMode interLayerPred;
marpan@webrtc.org5b883172014-11-01 06:10:48375};
376
magjede69a1a92016-11-25 18:06:31377// TODO(magjed): Move this and other H264 related classes out to their own file.
378namespace H264 {
379
380enum Profile {
381 kProfileConstrainedBaseline,
382 kProfileBaseline,
383 kProfileMain,
384 kProfileConstrainedHigh,
385 kProfileHigh,
386};
387
388} // namespace H264
389
stefan@webrtc.orgb9f54532014-07-04 12:42:07390// H264 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48391struct VideoCodecH264 {
Niels Möllerdef1ef52018-03-19 12:48:44392 bool operator==(const VideoCodecH264& other) const;
393 bool operator!=(const VideoCodecH264& other) const {
394 return !(*this == other);
395 }
solenberg634b86e2016-09-01 14:54:53396 bool frameDroppingOn;
397 int keyFrameInterval;
marpan@webrtc.org5b883172014-11-01 06:10:48398 // These are NULL/0 if not externally negotiated.
399 const uint8_t* spsData;
solenberg634b86e2016-09-01 14:54:53400 size_t spsLen;
marpan@webrtc.org5b883172014-11-01 06:10:48401 const uint8_t* ppsData;
solenberg634b86e2016-09-01 14:54:53402 size_t ppsLen;
magjede69a1a92016-11-25 18:06:31403 H264::Profile profile;
stefan@webrtc.orgb9f54532014-07-04 12:42:07404};
405
niklase@google.com470e71d2011-07-07 08:21:25406// Video codec types
marpan@webrtc.org5b883172014-11-01 06:10:48407enum VideoCodecType {
Niels Möller520ca4e2018-06-04 09:14:38408 // There are various memset(..., 0, ...) calls in the code that rely on
409 // kVideoCodecUnknown being zero.
410 kVideoCodecUnknown = 0,
marpan@webrtc.org5b883172014-11-01 06:10:48411 kVideoCodecVP8,
412 kVideoCodecVP9,
413 kVideoCodecH264,
414 kVideoCodecI420,
415 kVideoCodecRED,
416 kVideoCodecULPFEC,
brandtr87d7d772016-11-07 11:03:41417 kVideoCodecFlexfec,
marpan@webrtc.org5b883172014-11-01 06:10:48418 kVideoCodecGeneric,
Emircan Uysalerd7ae3c32018-01-25 21:01:09419 kVideoCodecMultiplex,
Niels Möller520ca4e2018-06-04 09:14:38420
421 // TODO(nisse): Deprecated aliases, for code expecting RtpVideoCodecTypes.
422 kRtpVideoNone = kVideoCodecUnknown,
423 kRtpVideoGeneric = kVideoCodecGeneric,
424 kRtpVideoVp8 = kVideoCodecVP8,
425 kRtpVideoVp9 = kVideoCodecVP9,
426 kRtpVideoH264 = kVideoCodecH264,
niklase@google.com470e71d2011-07-07 08:21:25427};
428
Erik Språng08127a92016-11-16 15:41:30429// Translates from name of codec to codec type and vice versa.
kthelgason1cdddc92017-08-24 10:52:48430const char* CodecTypeToPayloadString(VideoCodecType type);
431VideoCodecType PayloadStringToCodecType(const std::string& name);
Erik Språng08127a92016-11-16 15:41:30432
marpan@webrtc.org5b883172014-11-01 06:10:48433union VideoCodecUnion {
solenberg634b86e2016-09-01 14:54:53434 VideoCodecVP8 VP8;
435 VideoCodecVP9 VP9;
436 VideoCodecH264 H264;
niklase@google.com470e71d2011-07-07 08:21:25437};
438
Sergey Silkin13e74342018-03-02 11:28:00439struct SpatialLayer {
Niels Möllerdef1ef52018-03-19 12:48:44440 bool operator==(const SpatialLayer& other) const;
441 bool operator!=(const SpatialLayer& other) const { return !(*this == other); }
442
solenberg634b86e2016-09-01 14:54:53443 unsigned short width;
444 unsigned short height;
445 unsigned char numberOfTemporalLayers;
446 unsigned int maxBitrate; // kilobits/sec.
447 unsigned int targetBitrate; // kilobits/sec.
448 unsigned int minBitrate; // kilobits/sec.
449 unsigned int qpMax; // minimum quality
Seth Hampsonf6464c92018-01-17 21:55:14450 bool active; // encoded and sent.
pwestin@webrtc.org1da1ce02011-10-13 15:19:55451};
452
Sergey Silkin13e74342018-03-02 11:28:00453// Simulcast is when the same stream is encoded multiple times with different
454// settings such as resolution.
455typedef SpatialLayer SimulcastStream;
sprangce4aef12015-11-02 15:23:20456
solenberg634b86e2016-09-01 14:54:53457enum VideoCodecMode { kRealtimeVideo, kScreensharing };
stefan@webrtc.orgeb917922013-02-18 14:40:18458
niklase@google.com470e71d2011-07-07 08:21:25459// Common video codec properties
hta257dc392016-10-25 16:05:06460class VideoCodec {
461 public:
462 VideoCodec();
463
464 // Public variables. TODO(hta): Make them private with accessors.
solenberg634b86e2016-09-01 14:54:53465 VideoCodecType codecType;
solenberg634b86e2016-09-01 14:54:53466 unsigned char plType;
niklase@google.com470e71d2011-07-07 08:21:25467
solenberg634b86e2016-09-01 14:54:53468 unsigned short width;
469 unsigned short height;
niklase@google.com470e71d2011-07-07 08:21:25470
solenberg634b86e2016-09-01 14:54:53471 unsigned int startBitrate; // kilobits/sec.
472 unsigned int maxBitrate; // kilobits/sec.
473 unsigned int minBitrate; // kilobits/sec.
474 unsigned int targetBitrate; // kilobits/sec.
pbos@webrtc.org3c412b22014-03-24 12:36:52475
Stefan Holmer144475b2017-03-10 14:08:26476 uint32_t maxFramerate;
niklase@google.com470e71d2011-07-07 08:21:25477
Seth Hampsonf6464c92018-01-17 21:55:14478 // This enables/disables encoding and sending when there aren't multiple
479 // simulcast streams,by allocating 0 bitrate if inactive.
480 bool active;
481
solenberg634b86e2016-09-01 14:54:53482 unsigned int qpMax;
483 unsigned char numberOfSimulcastStreams;
484 SimulcastStream simulcastStream[kMaxSimulcastStreams];
sprangce4aef12015-11-02 15:23:20485 SpatialLayer spatialLayers[kMaxSpatialLayers];
stefan@webrtc.orgeb917922013-02-18 14:40:18486
solenberg634b86e2016-09-01 14:54:53487 VideoCodecMode mode;
488 bool expect_encode_from_texture;
andresp@webrtc.org185bae42013-05-14 08:02:25489
ilnik04f4d122017-06-19 14:18:55490 // Timing frames configuration. There is delay of delay_ms between two
491 // consequent timing frames, excluding outliers. Frame is always made a
492 // timing frame if it's at least outlier_ratio in percent of "ideal" average
493 // frame given bitrate and framerate, i.e. if it's bigger than
494 // |outlier_ratio / 100.0 * bitrate_bps / fps| in bits. This way, timing
495 // frames will not be sent too often usually. Yet large frames will always
496 // have timing information for debug purposes because they are more likely to
497 // cause extra delays.
498 struct TimingFrameTriggerThresholds {
499 int64_t delay_ms;
500 uint16_t outlier_ratio_percent;
501 } timing_frame_thresholds;
502
Peter Boström7b971e72016-01-19 15:26:16503 bool operator==(const VideoCodec& other) const = delete;
504 bool operator!=(const VideoCodec& other) const = delete;
hta257dc392016-10-25 16:05:06505
506 // Accessors for codec specific information.
507 // There is a const version of each that returns a reference,
508 // and a non-const version that returns a pointer, in order
509 // to allow modification of the parameters.
510 VideoCodecVP8* VP8();
511 const VideoCodecVP8& VP8() const;
512 VideoCodecVP9* VP9();
513 const VideoCodecVP9& VP9() const;
514 VideoCodecH264* H264();
515 const VideoCodecH264& H264() const;
516
hta527d3472016-11-17 07:23:04517 private:
hta257dc392016-10-25 16:05:06518 // TODO(hta): Consider replacing the union with a pointer type.
519 // This will allow removing the VideoCodec* types from this file.
hta527d3472016-11-17 07:23:04520 VideoCodecUnion codec_specific_;
niklase@google.com470e71d2011-07-07 08:21:25521};
astor@webrtc.orgbd7aeba2012-06-26 10:47:04522
Erik Språng566124a2018-04-23 10:32:22523// TODO(sprang): Remove this when downstream projects have been updated.
524using BitrateAllocation = VideoBitrateAllocation;
Erik Språng08127a92016-11-16 15:41:30525
stefan64c0a0a2015-11-27 09:02:31526// Bandwidth over-use detector options. These are used to drive
527// experimentation with bandwidth estimation parameters.
528// See modules/remote_bitrate_estimator/overuse_detector.h
terelius84f83f82016-12-27 18:43:01529// TODO(terelius): This is only used in overuse_estimator.cc, and only in the
530// default constructed state. Can we move the relevant variables into that
531// class and delete this? See also disabled warning at line 27
stefan64c0a0a2015-11-27 09:02:31532struct OverUseDetectorOptions {
533 OverUseDetectorOptions()
solenberg634b86e2016-09-01 14:54:53534 : initial_slope(8.0 / 512.0),
stefan64c0a0a2015-11-27 09:02:31535 initial_offset(0),
536 initial_e(),
537 initial_process_noise(),
538 initial_avg_noise(0.0),
539 initial_var_noise(50) {
540 initial_e[0][0] = 100;
541 initial_e[1][1] = 1e-1;
542 initial_e[0][1] = initial_e[1][0] = 0;
543 initial_process_noise[0] = 1e-13;
stefan1069cac2016-03-10 13:13:21544 initial_process_noise[1] = 1e-3;
stefan64c0a0a2015-11-27 09:02:31545 }
546 double initial_slope;
547 double initial_offset;
548 double initial_e[2][2];
549 double initial_process_noise[2];
550 double initial_avg_noise;
551 double initial_var_noise;
552};
553
wu@webrtc.orga9890802013-12-13 00:21:03554// This structure will have the information about when packet is actually
555// received by socket.
556struct PacketTime {
henrike@webrtc.org82d3cb62014-04-29 17:50:47557 PacketTime() : timestamp(-1), not_before(-1) {}
558 PacketTime(int64_t timestamp, int64_t not_before)
solenberg634b86e2016-09-01 14:54:53559 : timestamp(timestamp), not_before(not_before) {}
wu@webrtc.orga9890802013-12-13 00:21:03560
henrike@webrtc.org82d3cb62014-04-29 17:50:47561 int64_t timestamp; // Receive time after socket delivers the data.
562 int64_t not_before; // Earliest possible time the data could have arrived,
563 // indicating the potential error in the |timestamp|
564 // value,in case the system is busy.
565 // For example, the time of the last select() call.
566 // If unknown, this value will be set to zero.
wu@webrtc.orga9890802013-12-13 00:21:03567};
568
isheriff6b4b5f32016-06-08 07:24:21569// Minimum and maximum playout delay values from capture to render.
570// These are best effort values.
571//
572// A value < 0 indicates no change from previous valid value.
573//
574// min = max = 0 indicates that the receiver should try and render
575// frame as soon as possible.
576//
577// min = x, max = y indicates that the receiver is free to adapt
578// in the range (x, y) based on network jitter.
579//
580// Note: Given that this gets embedded in a union, it is up-to the owner to
581// initialize these values.
582struct PlayoutDelay {
583 int min_ms;
584 int max_ms;
585};
586
niklase@google.com470e71d2011-07-07 08:21:25587} // namespace webrtc
andrew@webrtc.orgeda189b2013-09-09 17:50:10588
Mirko Bonadei92ea95e2017-09-15 04:47:31589#endif // COMMON_TYPES_H_