blob: 68f2baa41bd28119728b8b57df6fb3887fc885a3 [file] [log] [blame]
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +00001/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
andrew@webrtc.org81c4d242013-09-09 17:50:10 +000011#ifndef WEBRTC_COMMON_TYPES_H_
12#define WEBRTC_COMMON_TYPES_H_
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +000013
pbos@webrtc.orgf39df522014-03-19 08:43:57 +000014#include <stddef.h>
mallinath@webrtc.org40fee002014-03-21 00:41:28 +000015#include <string.h>
pbos@webrtc.orgf39df522014-03-19 08:43:57 +000016#include <vector>
17
andrew@webrtc.org81c4d242013-09-09 17:50:10 +000018#include "webrtc/typedefs.h"
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +000019
20#if defined(_MSC_VER)
21// Disable "new behavior: elements of array will be default initialized"
22// warning. Affects OverUseDetectorOptions.
23#pragma warning(disable:4351)
24#endif
25
26#ifdef WEBRTC_EXPORT
27#define WEBRTC_DLLEXPORT _declspec(dllexport)
28#elif WEBRTC_DLL
29#define WEBRTC_DLLEXPORT _declspec(dllimport)
30#else
31#define WEBRTC_DLLEXPORT
32#endif
33
34#ifndef NULL
35#define NULL 0
36#endif
37
38#define RTP_PAYLOAD_NAME_SIZE 32
39
mallinath@webrtc.org40fee002014-03-21 00:41:28 +000040#if defined(WEBRTC_WIN) || defined(WIN32)
andrew@webrtc.org81c4d242013-09-09 17:50:10 +000041// Compares two strings without regard to case.
42#define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2)
43// Compares characters of two strings without regard to case.
44#define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n)
45#else
46#define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2)
47#define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n)
48#endif
49
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +000050namespace webrtc {
51
andresp@webrtc.org1e8424f2013-05-14 08:02:25 +000052class Config;
53
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +000054class InStream
55{
56public:
57 virtual int Read(void *buf,int len) = 0;
58 virtual int Rewind() {return -1;}
59 virtual ~InStream() {}
60protected:
61 InStream() {}
62};
63
64class OutStream
65{
66public:
67 virtual bool Write(const void *buf,int len) = 0;
68 virtual int Rewind() {return -1;}
69 virtual ~OutStream() {}
70protected:
71 OutStream() {}
72};
73
74enum TraceModule
75{
pbos@webrtc.org39139dc2013-12-16 12:24:44 +000076 kTraceUndefined = 0,
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +000077 // not a module, triggered from the engine code
pbos@webrtc.org39139dc2013-12-16 12:24:44 +000078 kTraceVoice = 0x0001,
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +000079 // not a module, triggered from the engine code
pbos@webrtc.org39139dc2013-12-16 12:24:44 +000080 kTraceVideo = 0x0002,
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +000081 // not a module, triggered from the utility code
pbos@webrtc.org39139dc2013-12-16 12:24:44 +000082 kTraceUtility = 0x0003,
83 kTraceRtpRtcp = 0x0004,
84 kTraceTransport = 0x0005,
85 kTraceSrtp = 0x0006,
86 kTraceAudioCoding = 0x0007,
87 kTraceAudioMixerServer = 0x0008,
88 kTraceAudioMixerClient = 0x0009,
89 kTraceFile = 0x000a,
90 kTraceAudioProcessing = 0x000b,
91 kTraceVideoCoding = 0x0010,
92 kTraceVideoMixer = 0x0011,
93 kTraceAudioDevice = 0x0012,
94 kTraceVideoRenderer = 0x0014,
95 kTraceVideoCapture = 0x0015,
pbos@webrtc.org39139dc2013-12-16 12:24:44 +000096 kTraceRemoteBitrateEstimator = 0x0017,
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +000097};
98
99enum TraceLevel
100{
101 kTraceNone = 0x0000, // no trace
102 kTraceStateInfo = 0x0001,
103 kTraceWarning = 0x0002,
104 kTraceError = 0x0004,
105 kTraceCritical = 0x0008,
106 kTraceApiCall = 0x0010,
107 kTraceDefault = 0x00ff,
108
109 kTraceModuleCall = 0x0020,
110 kTraceMemory = 0x0100, // memory info
111 kTraceTimer = 0x0200, // timing info
112 kTraceStream = 0x0400, // "continuous" stream of data
113
114 // used for debug purposes
115 kTraceDebug = 0x0800, // debug
116 kTraceInfo = 0x1000, // debug info
117
andrew@webrtc.org10e0b282012-11-20 07:34:45 +0000118 // Non-verbose level used by LS_INFO of logging.h. Do not use directly.
119 kTraceTerseInfo = 0x2000,
120
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000121 kTraceAll = 0xffff
122};
123
124// External Trace API
andrew@webrtc.org4c8c3072012-11-15 05:33:25 +0000125class TraceCallback {
126 public:
127 virtual void Print(TraceLevel level, const char* message, int length) = 0;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000128
andrew@webrtc.org4c8c3072012-11-15 05:33:25 +0000129 protected:
130 virtual ~TraceCallback() {}
131 TraceCallback() {}
132};
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000133
134enum FileFormats
135{
136 kFileFormatWavFile = 1,
137 kFileFormatCompressedFile = 2,
138 kFileFormatAviFile = 3,
139 kFileFormatPreencodedFile = 4,
140 kFileFormatPcm16kHzFile = 7,
141 kFileFormatPcm8kHzFile = 8,
142 kFileFormatPcm32kHzFile = 9
143};
144
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000145enum ProcessingTypes
146{
147 kPlaybackPerChannel = 0,
148 kPlaybackAllChannelsMixed,
149 kRecordingPerChannel,
150 kRecordingAllChannelsMixed,
151 kRecordingPreprocessing
152};
153
sprang@webrtc.org9435a172013-12-04 15:09:27 +0000154enum FrameType
155{
156 kFrameEmpty = 0,
157 kAudioFrameSpeech = 1,
158 kAudioFrameCN = 2,
159 kVideoFrameKey = 3, // independent frame
160 kVideoFrameDelta = 4, // depends on the previus frame
161};
162
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000163// External transport callback interface
164class Transport
165{
166public:
167 virtual int SendPacket(int channel, const void *data, int len) = 0;
168 virtual int SendRTCPPacket(int channel, const void *data, int len) = 0;
169
170protected:
171 virtual ~Transport() {}
172 Transport() {}
173};
174
sprang@webrtc.org13a4d312013-11-20 16:47:07 +0000175// Statistics for an RTCP channel
sprang@webrtc.org4043e7e2013-10-28 09:21:07 +0000176struct RtcpStatistics {
sprang@webrtc.org4043e7e2013-10-28 09:21:07 +0000177 RtcpStatistics()
178 : fraction_lost(0),
179 cumulative_lost(0),
180 extended_max_sequence_number(0),
sprang@webrtc.org89119372013-12-05 09:48:44 +0000181 jitter(0) {}
sprang@webrtc.org4043e7e2013-10-28 09:21:07 +0000182
183 uint8_t fraction_lost;
184 uint32_t cumulative_lost;
185 uint32_t extended_max_sequence_number;
186 uint32_t jitter;
sprang@webrtc.org4043e7e2013-10-28 09:21:07 +0000187};
188
sprang@webrtc.org13a4d312013-11-20 16:47:07 +0000189// Callback, called whenever a new rtcp report block is transmitted.
190class RtcpStatisticsCallback {
191 public:
192 virtual ~RtcpStatisticsCallback() {}
193
194 virtual void StatisticsUpdated(const RtcpStatistics& statistics,
195 uint32_t ssrc) = 0;
196};
197
asapersson@webrtc.org2fa9f7e2014-02-19 11:59:02 +0000198// Statistics for RTCP packet types.
199struct RtcpPacketTypeCounter {
200 RtcpPacketTypeCounter()
201 : nack_packets(0),
202 fir_packets(0),
203 pli_packets(0) {}
204
205 void Add(const RtcpPacketTypeCounter& other) {
206 nack_packets += other.nack_packets;
207 fir_packets += other.fir_packets;
208 pli_packets += other.pli_packets;
209 }
210
211 uint32_t nack_packets;
212 uint32_t fir_packets;
213 uint32_t pli_packets;
214};
215
sprang@webrtc.org13a4d312013-11-20 16:47:07 +0000216// Data usage statistics for a (rtp) stream
217struct StreamDataCounters {
sprang@webrtc.org13a4d312013-11-20 16:47:07 +0000218 StreamDataCounters()
219 : bytes(0),
sprang@webrtc.orgcf5c5522013-12-05 14:29:02 +0000220 header_bytes(0),
sprang@webrtc.org13a4d312013-11-20 16:47:07 +0000221 padding_bytes(0),
222 packets(0),
223 retransmitted_packets(0),
224 fec_packets(0) {}
225
sprang@webrtc.orgcf5c5522013-12-05 14:29:02 +0000226 uint32_t bytes; // Payload bytes, excluding RTP headers and padding.
227 uint32_t header_bytes; // Number of bytes used by RTP headers.
228 uint32_t padding_bytes; // Number of padding bytes.
229 uint32_t packets; // Number of packets.
230 uint32_t retransmitted_packets; // Number of retransmitted packets.
231 uint32_t fec_packets; // Number of redundancy packets.
sprang@webrtc.org13a4d312013-11-20 16:47:07 +0000232};
233
234// Callback, called whenever byte/packet counts have been updated.
235class StreamDataCountersCallback {
236 public:
237 virtual ~StreamDataCountersCallback() {}
238
239 virtual void DataCountersUpdated(const StreamDataCounters& counters,
240 uint32_t ssrc) = 0;
241};
242
243// Rate statistics for a stream
244struct BitrateStatistics {
sprang@webrtc.org0e4512b2013-12-13 09:46:59 +0000245 BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
sprang@webrtc.org13a4d312013-11-20 16:47:07 +0000246
sprang@webrtc.org0e4512b2013-12-13 09:46:59 +0000247 uint32_t bitrate_bps; // Bitrate in bits per second.
248 uint32_t packet_rate; // Packet rate in packets per second.
249 uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation.
sprang@webrtc.org13a4d312013-11-20 16:47:07 +0000250};
251
252// Callback, used to notify an observer whenever new rates have been estimated.
253class BitrateStatisticsObserver {
254 public:
255 virtual ~BitrateStatisticsObserver() {}
256
257 virtual void Notify(const BitrateStatistics& stats, uint32_t ssrc) = 0;
258};
259
260// Callback, used to notify an observer whenever frame counts have been updated
261class FrameCountObserver {
262 public:
sprang@webrtc.orge92aec92013-11-21 09:09:54 +0000263 virtual ~FrameCountObserver() {}
sprang@webrtc.org9435a172013-12-04 15:09:27 +0000264 virtual void FrameCountUpdated(FrameType frame_type,
265 uint32_t frame_count,
266 const unsigned int ssrc) = 0;
sprang@webrtc.org13a4d312013-11-20 16:47:07 +0000267};
268
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000269// ==================================================================
270// Voice specific types
271// ==================================================================
272
273// Each codec supported can be described by this structure.
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000274struct CodecInst {
275 int pltype;
276 char plname[RTP_PAYLOAD_NAME_SIZE];
277 int plfreq;
278 int pacsize;
279 int channels;
280 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
281
282 bool operator==(const CodecInst& other) const {
283 return pltype == other.pltype &&
284 (STR_CASE_CMP(plname, other.plname) == 0) &&
285 plfreq == other.plfreq &&
286 pacsize == other.pacsize &&
287 channels == other.channels &&
288 rate == other.rate;
289 }
290
291 bool operator!=(const CodecInst& other) const {
292 return !(*this == other);
293 }
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000294};
295
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000296// RTP
297enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
298
299enum RTPDirections
300{
301 kRtpIncoming = 0,
302 kRtpOutgoing
303};
304
305enum PayloadFrequencies
306{
307 kFreq8000Hz = 8000,
308 kFreq16000Hz = 16000,
309 kFreq32000Hz = 32000
310};
311
312enum VadModes // degree of bandwidth reduction
313{
314 kVadConventional = 0, // lowest reduction
315 kVadAggressiveLow,
316 kVadAggressiveMid,
317 kVadAggressiveHigh // highest reduction
318};
319
320struct NetworkStatistics // NETEQ statistics
321{
322 // current jitter buffer size in ms
pbos@webrtc.orgc22830f2013-05-03 12:02:11 +0000323 uint16_t currentBufferSize;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000324 // preferred (optimal) buffer size in ms
pbos@webrtc.orgc22830f2013-05-03 12:02:11 +0000325 uint16_t preferredBufferSize;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000326 // adding extra delay due to "peaky jitter"
327 bool jitterPeaksFound;
328 // loss rate (network + late) in percent (in Q14)
pbos@webrtc.orgc22830f2013-05-03 12:02:11 +0000329 uint16_t currentPacketLossRate;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000330 // late loss rate in percent (in Q14)
pbos@webrtc.orgc22830f2013-05-03 12:02:11 +0000331 uint16_t currentDiscardRate;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000332 // fraction (of original stream) of synthesized speech inserted through
333 // expansion (in Q14)
pbos@webrtc.orgc22830f2013-05-03 12:02:11 +0000334 uint16_t currentExpandRate;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000335 // fraction of synthesized speech inserted through pre-emptive expansion
336 // (in Q14)
pbos@webrtc.orgc22830f2013-05-03 12:02:11 +0000337 uint16_t currentPreemptiveRate;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000338 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.orgc22830f2013-05-03 12:02:11 +0000339 uint16_t currentAccelerateRate;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000340 // clock-drift in parts-per-million (negative or positive)
341 int32_t clockDriftPPM;
342 // average packet waiting time in the jitter buffer (ms)
343 int meanWaitingTimeMs;
344 // median packet waiting time in the jitter buffer (ms)
345 int medianWaitingTimeMs;
346 // min packet waiting time in the jitter buffer (ms)
347 int minWaitingTimeMs;
348 // max packet waiting time in the jitter buffer (ms)
349 int maxWaitingTimeMs;
roosa@google.comd0a96082012-12-14 00:06:18 +0000350 // added samples in off mode due to packet loss
351 int addedSamples;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000352};
353
wu@webrtc.org7f0519e2013-12-13 19:17:43 +0000354// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
355struct AudioDecodingCallStats {
356 AudioDecodingCallStats()
357 : calls_to_silence_generator(0),
358 calls_to_neteq(0),
359 decoded_normal(0),
360 decoded_plc(0),
361 decoded_cng(0),
362 decoded_plc_cng(0) {}
363
364 int calls_to_silence_generator; // Number of calls where silence generated,
365 // and NetEq was disengaged from decoding.
366 int calls_to_neteq; // Number of calls to NetEq.
367 int decoded_normal; // Number of calls where audio RTP packet decoded.
368 int decoded_plc; // Number of calls resulted in PLC.
369 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
370 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
371};
372
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000373typedef struct
374{
375 int min; // minumum
376 int max; // maximum
377 int average; // average
378} StatVal;
379
380typedef struct // All levels are reported in dBm0
381{
382 StatVal speech_rx; // long-term speech levels on receiving side
383 StatVal speech_tx; // long-term speech levels on transmitting side
384 StatVal noise_rx; // long-term noise/silence levels on receiving side
385 StatVal noise_tx; // long-term noise/silence levels on transmitting side
386} LevelStatistics;
387
388typedef struct // All levels are reported in dB
389{
390 StatVal erl; // Echo Return Loss
391 StatVal erle; // Echo Return Loss Enhancement
392 StatVal rerl; // RERL = ERL + ERLE
393 // Echo suppression inside EC at the point just before its NLP
394 StatVal a_nlp;
395} EchoStatistics;
396
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000397enum NsModes // type of Noise Suppression
398{
399 kNsUnchanged = 0, // previously set mode
400 kNsDefault, // platform default
401 kNsConference, // conferencing default
402 kNsLowSuppression, // lowest suppression
403 kNsModerateSuppression,
404 kNsHighSuppression,
405 kNsVeryHighSuppression, // highest suppression
406};
407
408enum AgcModes // type of Automatic Gain Control
409{
410 kAgcUnchanged = 0, // previously set mode
411 kAgcDefault, // platform default
412 // adaptive mode for use when analog volume control exists (e.g. for
413 // PC softphone)
414 kAgcAdaptiveAnalog,
415 // scaling takes place in the digital domain (e.g. for conference servers
416 // and embedded devices)
417 kAgcAdaptiveDigital,
418 // can be used on embedded devices where the capture signal level
419 // is predictable
420 kAgcFixedDigital
421};
422
423// EC modes
424enum EcModes // type of Echo Control
425{
426 kEcUnchanged = 0, // previously set mode
427 kEcDefault, // platform default
428 kEcConference, // conferencing default (aggressive AEC)
429 kEcAec, // Acoustic Echo Cancellation
430 kEcAecm, // AEC mobile
431};
432
433// AECM modes
434enum AecmModes // mode of AECM
435{
436 kAecmQuietEarpieceOrHeadset = 0,
437 // Quiet earpiece or headset use
438 kAecmEarpiece, // most earpiece use
439 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
440 kAecmSpeakerphone, // most speakerphone use (default)
441 kAecmLoudSpeakerphone // Loud speakerphone
442};
443
444// AGC configuration
445typedef struct
446{
447 unsigned short targetLeveldBOv;
448 unsigned short digitalCompressionGaindB;
449 bool limiterEnable;
450} AgcConfig; // AGC configuration parameters
451
452enum StereoChannel
453{
454 kStereoLeft = 0,
455 kStereoRight,
456 kStereoBoth
457};
458
459// Audio device layers
460enum AudioLayers
461{
462 kAudioPlatformDefault = 0,
463 kAudioWindowsWave = 1,
464 kAudioWindowsCore = 2,
465 kAudioLinuxAlsa = 3,
466 kAudioLinuxPulse = 4
467};
468
henrika@webrtc.org514abde2014-04-17 10:45:01 +0000469// TODO(henrika): to be removed.
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000470enum NetEqModes // NetEQ playout configurations
471{
472 // Optimized trade-off between low delay and jitter robustness for two-way
473 // communication.
474 kNetEqDefault = 0,
475 // Improved jitter robustness at the cost of increased delay. Can be
476 // used in one-way communication.
477 kNetEqStreaming = 1,
478 // Optimzed for decodability of fax signals rather than for perceived audio
479 // quality.
480 kNetEqFax = 2,
roosa@google.come68106f2012-12-12 21:59:14 +0000481 // Minimal buffer management. Inserts zeros for lost packets and during
482 // buffer increases.
483 kNetEqOff = 3,
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000484};
485
henrika@webrtc.org514abde2014-04-17 10:45:01 +0000486// TODO(henrika): to be removed.
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000487enum OnHoldModes // On Hold direction
488{
489 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
490 kHoldSendOnly, // Put only sending in on-hold state.
491 kHoldPlayOnly // Put only playing in on-hold state.
492};
493
henrika@webrtc.org514abde2014-04-17 10:45:01 +0000494// TODO(henrika): to be removed.
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000495enum AmrMode
496{
497 kRfc3267BwEfficient = 0,
498 kRfc3267OctetAligned = 1,
499 kRfc3267FileStorage = 2,
500};
501
502// ==================================================================
503// Video specific types
504// ==================================================================
505
506// Raw video types
507enum RawVideoType
508{
509 kVideoI420 = 0,
510 kVideoYV12 = 1,
511 kVideoYUY2 = 2,
512 kVideoUYVY = 3,
513 kVideoIYUV = 4,
514 kVideoARGB = 5,
515 kVideoRGB24 = 6,
516 kVideoRGB565 = 7,
517 kVideoARGB4444 = 8,
518 kVideoARGB1555 = 9,
519 kVideoMJPEG = 10,
520 kVideoNV12 = 11,
521 kVideoNV21 = 12,
522 kVideoBGRA = 13,
523 kVideoUnknown = 99
524};
525
526// Video codec
527enum { kConfigParameterSize = 128};
528enum { kPayloadNameSize = 32};
529enum { kMaxSimulcastStreams = 4};
530enum { kMaxTemporalStreams = 4};
531
532enum VideoCodecComplexity
533{
534 kComplexityNormal = 0,
535 kComplexityHigh = 1,
536 kComplexityHigher = 2,
537 kComplexityMax = 3
538};
539
540enum VideoCodecProfile
541{
542 kProfileBase = 0x00,
543 kProfileMain = 0x01
544};
545
546enum VP8ResilienceMode {
547 kResilienceOff, // The stream produced by the encoder requires a
548 // recovery frame (typically a key frame) to be
549 // decodable after a packet loss.
550 kResilientStream, // A stream produced by the encoder is resilient to
551 // packet losses, but packets within a frame subsequent
552 // to a loss can't be decoded.
553 kResilientFrames // Same as kResilientStream but with added resilience
554 // within a frame.
555};
556
557// VP8 specific
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000558struct VideoCodecVP8 {
559 bool pictureLossIndicationOn;
560 bool feedbackModeOn;
561 VideoCodecComplexity complexity;
562 VP8ResilienceMode resilience;
563 unsigned char numberOfTemporalLayers;
564 bool denoisingOn;
565 bool errorConcealmentOn;
566 bool automaticResizeOn;
567 bool frameDroppingOn;
568 int keyFrameInterval;
569
570 bool operator==(const VideoCodecVP8& other) const {
571 return pictureLossIndicationOn == other.pictureLossIndicationOn &&
572 feedbackModeOn == other.feedbackModeOn &&
573 complexity == other.complexity &&
574 resilience == other.resilience &&
575 numberOfTemporalLayers == other.numberOfTemporalLayers &&
576 denoisingOn == other.denoisingOn &&
577 errorConcealmentOn == other.errorConcealmentOn &&
578 automaticResizeOn == other.automaticResizeOn &&
579 frameDroppingOn == other.frameDroppingOn &&
580 keyFrameInterval == other.keyFrameInterval;
581 }
582
583 bool operator!=(const VideoCodecVP8& other) const {
584 return !(*this == other);
585 }
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000586};
587
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000588// Video codec types
589enum VideoCodecType
590{
591 kVideoCodecVP8,
592 kVideoCodecI420,
593 kVideoCodecRED,
594 kVideoCodecULPFEC,
pbos@webrtc.orga2e91242013-03-18 16:39:03 +0000595 kVideoCodecGeneric,
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000596 kVideoCodecUnknown
597};
598
599union VideoCodecUnion
600{
601 VideoCodecVP8 VP8;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000602};
603
604
605// Simulcast is when the same stream is encoded multiple times with different
606// settings such as resolution.
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000607struct SimulcastStream {
608 unsigned short width;
609 unsigned short height;
610 unsigned char numberOfTemporalLayers;
611 unsigned int maxBitrate; // kilobits/sec.
612 unsigned int targetBitrate; // kilobits/sec.
613 unsigned int minBitrate; // kilobits/sec.
614 unsigned int qpMax; // minimum quality
615
616 bool operator==(const SimulcastStream& other) const {
617 return width == other.width &&
618 height == other.height &&
619 numberOfTemporalLayers == other.numberOfTemporalLayers &&
620 maxBitrate == other.maxBitrate &&
621 targetBitrate == other.targetBitrate &&
622 minBitrate == other.minBitrate &&
623 qpMax == other.qpMax;
624 }
625
626 bool operator!=(const SimulcastStream& other) const {
627 return !(*this == other);
628 }
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000629};
630
stefan@webrtc.org85e2e0e2013-02-18 14:40:18 +0000631enum VideoCodecMode {
632 kRealtimeVideo,
633 kScreensharing
634};
635
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000636// Common video codec properties
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000637struct VideoCodec {
638 VideoCodecType codecType;
639 char plName[kPayloadNameSize];
640 unsigned char plType;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000641
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000642 unsigned short width;
643 unsigned short height;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000644
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000645 unsigned int startBitrate; // kilobits/sec.
646 unsigned int maxBitrate; // kilobits/sec.
647 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org5ca38d12014-03-24 12:36:52 +0000648 unsigned int targetBitrate; // kilobits/sec.
649
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000650 unsigned char maxFramerate;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000651
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000652 VideoCodecUnion codecSpecific;
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000653
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000654 unsigned int qpMax;
655 unsigned char numberOfSimulcastStreams;
656 SimulcastStream simulcastStream[kMaxSimulcastStreams];
stefan@webrtc.org85e2e0e2013-02-18 14:40:18 +0000657
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000658 VideoCodecMode mode;
andresp@webrtc.org1e8424f2013-05-14 08:02:25 +0000659
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000660 // When using an external encoder/decoder this allows to pass
661 // extra options without requiring webrtc to be aware of them.
662 Config* extra_options;
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000663
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000664 bool operator==(const VideoCodec& other) const {
665 bool ret = codecType == other.codecType &&
666 (STR_CASE_CMP(plName, other.plName) == 0) &&
667 plType == other.plType &&
668 width == other.width &&
669 height == other.height &&
670 startBitrate == other.startBitrate &&
671 maxBitrate == other.maxBitrate &&
672 minBitrate == other.minBitrate &&
pbos@webrtc.org5ca38d12014-03-24 12:36:52 +0000673 targetBitrate == other.targetBitrate &&
mallinath@webrtc.org40fee002014-03-21 00:41:28 +0000674 maxFramerate == other.maxFramerate &&
675 qpMax == other.qpMax &&
676 numberOfSimulcastStreams == other.numberOfSimulcastStreams &&
677 mode == other.mode;
678 if (ret && codecType == kVideoCodecVP8) {
679 ret &= (codecSpecific.VP8 == other.codecSpecific.VP8);
680 }
681
682 for (unsigned char i = 0; i < other.numberOfSimulcastStreams && ret; ++i) {
683 ret &= (simulcastStream[i] == other.simulcastStream[i]);
684 }
685 return ret;
686 }
687
688 bool operator!=(const VideoCodec& other) const {
689 return !(*this == other);
690 }
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000691};
692
693// Bandwidth over-use detector options. These are used to drive
694// experimentation with bandwidth estimation parameters.
695// See modules/remote_bitrate_estimator/overuse_detector.h
696struct OverUseDetectorOptions {
697 OverUseDetectorOptions()
698 : initial_slope(8.0/512.0),
699 initial_offset(0),
700 initial_e(),
701 initial_process_noise(),
702 initial_avg_noise(0.0),
703 initial_var_noise(50),
704 initial_threshold(25.0) {
705 initial_e[0][0] = 100;
706 initial_e[1][1] = 1e-1;
707 initial_e[0][1] = initial_e[1][0] = 0;
708 initial_process_noise[0] = 1e-10;
709 initial_process_noise[1] = 1e-2;
710 }
711 double initial_slope;
712 double initial_offset;
713 double initial_e[2][2];
714 double initial_process_noise[2];
715 double initial_avg_noise;
716 double initial_var_noise;
717 double initial_threshold;
718};
andrew@webrtc.org81c4d242013-09-09 17:50:10 +0000719
wu@webrtc.org3a4fc4b2013-12-13 00:21:03 +0000720// This structure will have the information about when packet is actually
721// received by socket.
722struct PacketTime {
723 PacketTime() : timestamp(-1), max_error_us(-1) {}
724 PacketTime(int64_t timestamp, int64_t max_error_us)
725 : timestamp(timestamp), max_error_us(max_error_us) {
726 }
727
728 int64_t timestamp; // Receive time after socket delivers the data.
729 int64_t max_error_us; // Earliest possible time the data could have arrived,
730 // indicating the potential error in the |timestamp|
731 // value,in case the system is busy.
732 // For example, the time of the last select() call.
733 // If unknown, this value will be set to zero.
734};
735
solenberg@webrtc.org5f804f82014-03-24 10:38:25 +0000736struct RTPHeaderExtension {
737 RTPHeaderExtension()
738 : hasTransmissionTimeOffset(false),
739 transmissionTimeOffset(0),
740 hasAbsoluteSendTime(false),
741 absoluteSendTime(0),
742 hasAudioLevel(false),
743 audioLevel(0) {}
744
745 bool hasTransmissionTimeOffset;
746 int32_t transmissionTimeOffset;
747 bool hasAbsoluteSendTime;
748 uint32_t absoluteSendTime;
749
750 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
751 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
752 bool hasAudioLevel;
753 uint8_t audioLevel;
754};
755
756struct RTPHeader {
757 RTPHeader()
758 : markerBit(false),
759 payloadType(0),
760 sequenceNumber(0),
761 timestamp(0),
762 ssrc(0),
763 numCSRCs(0),
764 paddingLength(0),
765 headerLength(0),
766 payload_type_frequency(0),
767 extension() {
768 memset(&arrOfCSRCs, 0, sizeof(arrOfCSRCs));
769 }
770
771 bool markerBit;
772 uint8_t payloadType;
773 uint16_t sequenceNumber;
774 uint32_t timestamp;
775 uint32_t ssrc;
776 uint8_t numCSRCs;
777 uint32_t arrOfCSRCs[kRtpCsrcSize];
778 uint8_t paddingLength;
779 uint16_t headerLength;
780 int payload_type_frequency;
781 RTPHeaderExtension extension;
782};
783
pbos@webrtc.orgf39df522014-03-19 08:43:57 +0000784struct VideoStream {
785 VideoStream()
786 : width(0),
787 height(0),
788 max_framerate(-1),
789 min_bitrate_bps(-1),
790 target_bitrate_bps(-1),
791 max_bitrate_bps(-1),
792 max_qp(-1) {}
793
794 size_t width;
795 size_t height;
796 int max_framerate;
797
798 int min_bitrate_bps;
799 int target_bitrate_bps;
800 int max_bitrate_bps;
801
802 int max_qp;
803
804 // Bitrate thresholds for enabling additional temporal layers.
805 std::vector<int> temporal_layers;
806};
807
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +0000808} // namespace webrtc
andrew@webrtc.org81c4d242013-09-09 17:50:10 +0000809
810#endif // WEBRTC_COMMON_TYPES_H_