blob: 6892a83f084e21dc33efc26e03cae23094cfcc6a [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +00001/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
andrew@webrtc.org5cf83f42013-09-09 17:50:10 +000011#ifndef WEBRTC_COMMON_TYPES_H_
12#define WEBRTC_COMMON_TYPES_H_
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000013
pbos@webrtc.orge2a7a772014-03-19 08:43:57 +000014#include <stddef.h>
mallinath@webrtc.org18c29452014-03-21 00:41:28 +000015#include <string.h>
pbos@webrtc.org7e686932014-05-15 09:35:06 +000016
17#include <string>
pbos@webrtc.orge2a7a772014-03-19 08:43:57 +000018#include <vector>
19
andrew@webrtc.org5cf83f42013-09-09 17:50:10 +000020#include "webrtc/typedefs.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000021
22#if defined(_MSC_VER)
23// Disable "new behavior: elements of array will be default initialized"
24// warning. Affects OverUseDetectorOptions.
25#pragma warning(disable:4351)
26#endif
27
28#ifdef WEBRTC_EXPORT
29#define WEBRTC_DLLEXPORT _declspec(dllexport)
30#elif WEBRTC_DLL
31#define WEBRTC_DLLEXPORT _declspec(dllimport)
32#else
33#define WEBRTC_DLLEXPORT
34#endif
35
36#ifndef NULL
37#define NULL 0
38#endif
39
40#define RTP_PAYLOAD_NAME_SIZE 32
41
mallinath@webrtc.org18c29452014-03-21 00:41:28 +000042#if defined(WEBRTC_WIN) || defined(WIN32)
andrew@webrtc.org5cf83f42013-09-09 17:50:10 +000043// Compares two strings without regard to case.
44#define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2)
45// Compares characters of two strings without regard to case.
46#define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n)
47#else
48#define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2)
49#define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n)
50#endif
51
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000052namespace webrtc {
53
andresp@webrtc.orgee6f8a22013-05-14 08:02:25 +000054class Config;
55
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000056class InStream
57{
58public:
59 virtual int Read(void *buf,int len) = 0;
60 virtual int Rewind() {return -1;}
61 virtual ~InStream() {}
62protected:
63 InStream() {}
64};
65
66class OutStream
67{
68public:
69 virtual bool Write(const void *buf,int len) = 0;
70 virtual int Rewind() {return -1;}
71 virtual ~OutStream() {}
72protected:
73 OutStream() {}
74};
75
76enum TraceModule
77{
pbos@webrtc.org46f72882013-12-16 12:24:44 +000078 kTraceUndefined = 0,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000079 // not a module, triggered from the engine code
pbos@webrtc.org46f72882013-12-16 12:24:44 +000080 kTraceVoice = 0x0001,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000081 // not a module, triggered from the engine code
pbos@webrtc.org46f72882013-12-16 12:24:44 +000082 kTraceVideo = 0x0002,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000083 // not a module, triggered from the utility code
pbos@webrtc.org46f72882013-12-16 12:24:44 +000084 kTraceUtility = 0x0003,
85 kTraceRtpRtcp = 0x0004,
86 kTraceTransport = 0x0005,
87 kTraceSrtp = 0x0006,
88 kTraceAudioCoding = 0x0007,
89 kTraceAudioMixerServer = 0x0008,
90 kTraceAudioMixerClient = 0x0009,
91 kTraceFile = 0x000a,
92 kTraceAudioProcessing = 0x000b,
93 kTraceVideoCoding = 0x0010,
94 kTraceVideoMixer = 0x0011,
95 kTraceAudioDevice = 0x0012,
96 kTraceVideoRenderer = 0x0014,
97 kTraceVideoCapture = 0x0015,
pbos@webrtc.org46f72882013-12-16 12:24:44 +000098 kTraceRemoteBitrateEstimator = 0x0017,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000099};
100
101enum TraceLevel
102{
103 kTraceNone = 0x0000, // no trace
104 kTraceStateInfo = 0x0001,
105 kTraceWarning = 0x0002,
106 kTraceError = 0x0004,
107 kTraceCritical = 0x0008,
108 kTraceApiCall = 0x0010,
109 kTraceDefault = 0x00ff,
110
111 kTraceModuleCall = 0x0020,
112 kTraceMemory = 0x0100, // memory info
113 kTraceTimer = 0x0200, // timing info
114 kTraceStream = 0x0400, // "continuous" stream of data
115
116 // used for debug purposes
117 kTraceDebug = 0x0800, // debug
118 kTraceInfo = 0x1000, // debug info
119
andrew@webrtc.orgbc687c52012-11-20 07:34:45 +0000120 // Non-verbose level used by LS_INFO of logging.h. Do not use directly.
121 kTraceTerseInfo = 0x2000,
122
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000123 kTraceAll = 0xffff
124};
125
126// External Trace API
andrew@webrtc.orgd75680a2012-11-15 05:33:25 +0000127class TraceCallback {
128 public:
129 virtual void Print(TraceLevel level, const char* message, int length) = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000130
andrew@webrtc.orgd75680a2012-11-15 05:33:25 +0000131 protected:
132 virtual ~TraceCallback() {}
133 TraceCallback() {}
134};
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000135
136enum FileFormats
137{
138 kFileFormatWavFile = 1,
139 kFileFormatCompressedFile = 2,
140 kFileFormatAviFile = 3,
141 kFileFormatPreencodedFile = 4,
142 kFileFormatPcm16kHzFile = 7,
143 kFileFormatPcm8kHzFile = 8,
144 kFileFormatPcm32kHzFile = 9
145};
146
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000147enum ProcessingTypes
148{
149 kPlaybackPerChannel = 0,
150 kPlaybackAllChannelsMixed,
151 kRecordingPerChannel,
152 kRecordingAllChannelsMixed,
153 kRecordingPreprocessing
154};
155
sprang@webrtc.org5fdd10a2013-12-04 15:09:27 +0000156enum FrameType
157{
158 kFrameEmpty = 0,
159 kAudioFrameSpeech = 1,
160 kAudioFrameCN = 2,
161 kVideoFrameKey = 3, // independent frame
162 kVideoFrameDelta = 4, // depends on the previus frame
163};
164
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000165// External transport callback interface
166class Transport
167{
168public:
169 virtual int SendPacket(int channel, const void *data, int len) = 0;
170 virtual int SendRTCPPacket(int channel, const void *data, int len) = 0;
171
172protected:
173 virtual ~Transport() {}
174 Transport() {}
175};
176
sprang@webrtc.org46736742013-11-20 16:47:07 +0000177// Statistics for an RTCP channel
sprang@webrtc.org2714c792013-10-28 09:21:07 +0000178struct RtcpStatistics {
sprang@webrtc.org2714c792013-10-28 09:21:07 +0000179 RtcpStatistics()
180 : fraction_lost(0),
181 cumulative_lost(0),
182 extended_max_sequence_number(0),
sprang@webrtc.org9b30fd32013-12-05 09:48:44 +0000183 jitter(0) {}
sprang@webrtc.org2714c792013-10-28 09:21:07 +0000184
185 uint8_t fraction_lost;
186 uint32_t cumulative_lost;
187 uint32_t extended_max_sequence_number;
188 uint32_t jitter;
sprang@webrtc.org2714c792013-10-28 09:21:07 +0000189};
190
sprang@webrtc.org46736742013-11-20 16:47:07 +0000191// Callback, called whenever a new rtcp report block is transmitted.
192class RtcpStatisticsCallback {
193 public:
194 virtual ~RtcpStatisticsCallback() {}
195
196 virtual void StatisticsUpdated(const RtcpStatistics& statistics,
197 uint32_t ssrc) = 0;
198};
199
asapersson@webrtc.org4a155602014-02-19 11:59:02 +0000200// Statistics for RTCP packet types.
201struct RtcpPacketTypeCounter {
202 RtcpPacketTypeCounter()
203 : nack_packets(0),
204 fir_packets(0),
205 pli_packets(0) {}
206
207 void Add(const RtcpPacketTypeCounter& other) {
208 nack_packets += other.nack_packets;
209 fir_packets += other.fir_packets;
210 pli_packets += other.pli_packets;
211 }
212
213 uint32_t nack_packets;
214 uint32_t fir_packets;
215 uint32_t pli_packets;
216};
217
sprang@webrtc.org46736742013-11-20 16:47:07 +0000218// Data usage statistics for a (rtp) stream
219struct StreamDataCounters {
sprang@webrtc.org46736742013-11-20 16:47:07 +0000220 StreamDataCounters()
221 : bytes(0),
sprang@webrtc.orgb1139812013-12-05 14:29:02 +0000222 header_bytes(0),
sprang@webrtc.org46736742013-11-20 16:47:07 +0000223 padding_bytes(0),
224 packets(0),
225 retransmitted_packets(0),
226 fec_packets(0) {}
227
sprang@webrtc.orgb1139812013-12-05 14:29:02 +0000228 uint32_t bytes; // Payload bytes, excluding RTP headers and padding.
229 uint32_t header_bytes; // Number of bytes used by RTP headers.
230 uint32_t padding_bytes; // Number of padding bytes.
231 uint32_t packets; // Number of packets.
232 uint32_t retransmitted_packets; // Number of retransmitted packets.
233 uint32_t fec_packets; // Number of redundancy packets.
sprang@webrtc.org46736742013-11-20 16:47:07 +0000234};
235
236// Callback, called whenever byte/packet counts have been updated.
237class StreamDataCountersCallback {
238 public:
239 virtual ~StreamDataCountersCallback() {}
240
241 virtual void DataCountersUpdated(const StreamDataCounters& counters,
242 uint32_t ssrc) = 0;
243};
244
245// Rate statistics for a stream
246struct BitrateStatistics {
sprang@webrtc.orgb70db6d2013-12-13 09:46:59 +0000247 BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
sprang@webrtc.org46736742013-11-20 16:47:07 +0000248
sprang@webrtc.orgb70db6d2013-12-13 09:46:59 +0000249 uint32_t bitrate_bps; // Bitrate in bits per second.
250 uint32_t packet_rate; // Packet rate in packets per second.
251 uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation.
sprang@webrtc.org46736742013-11-20 16:47:07 +0000252};
253
254// Callback, used to notify an observer whenever new rates have been estimated.
255class BitrateStatisticsObserver {
256 public:
257 virtual ~BitrateStatisticsObserver() {}
258
259 virtual void Notify(const BitrateStatistics& stats, uint32_t ssrc) = 0;
260};
261
262// Callback, used to notify an observer whenever frame counts have been updated
263class FrameCountObserver {
264 public:
sprang@webrtc.org21dc10d2013-11-21 09:09:54 +0000265 virtual ~FrameCountObserver() {}
sprang@webrtc.org5fdd10a2013-12-04 15:09:27 +0000266 virtual void FrameCountUpdated(FrameType frame_type,
267 uint32_t frame_count,
268 const unsigned int ssrc) = 0;
sprang@webrtc.org46736742013-11-20 16:47:07 +0000269};
270
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000271// ==================================================================
272// Voice specific types
273// ==================================================================
274
275// Each codec supported can be described by this structure.
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000276struct CodecInst {
277 int pltype;
278 char plname[RTP_PAYLOAD_NAME_SIZE];
279 int plfreq;
280 int pacsize;
281 int channels;
282 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
283
284 bool operator==(const CodecInst& other) const {
285 return pltype == other.pltype &&
286 (STR_CASE_CMP(plname, other.plname) == 0) &&
287 plfreq == other.plfreq &&
288 pacsize == other.pacsize &&
289 channels == other.channels &&
290 rate == other.rate;
291 }
292
293 bool operator!=(const CodecInst& other) const {
294 return !(*this == other);
295 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000296};
297
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000298// RTP
299enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
300
301enum RTPDirections
302{
303 kRtpIncoming = 0,
304 kRtpOutgoing
305};
306
307enum PayloadFrequencies
308{
309 kFreq8000Hz = 8000,
310 kFreq16000Hz = 16000,
311 kFreq32000Hz = 32000
312};
313
314enum VadModes // degree of bandwidth reduction
315{
316 kVadConventional = 0, // lowest reduction
317 kVadAggressiveLow,
318 kVadAggressiveMid,
319 kVadAggressiveHigh // highest reduction
320};
321
322struct NetworkStatistics // NETEQ statistics
323{
324 // current jitter buffer size in ms
pbos@webrtc.org52b2ee52013-05-03 12:02:11 +0000325 uint16_t currentBufferSize;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000326 // preferred (optimal) buffer size in ms
pbos@webrtc.org52b2ee52013-05-03 12:02:11 +0000327 uint16_t preferredBufferSize;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000328 // adding extra delay due to "peaky jitter"
329 bool jitterPeaksFound;
330 // loss rate (network + late) in percent (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11 +0000331 uint16_t currentPacketLossRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000332 // late loss rate in percent (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11 +0000333 uint16_t currentDiscardRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000334 // fraction (of original stream) of synthesized speech inserted through
335 // expansion (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11 +0000336 uint16_t currentExpandRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000337 // fraction of synthesized speech inserted through pre-emptive expansion
338 // (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11 +0000339 uint16_t currentPreemptiveRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000340 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11 +0000341 uint16_t currentAccelerateRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000342 // clock-drift in parts-per-million (negative or positive)
343 int32_t clockDriftPPM;
344 // average packet waiting time in the jitter buffer (ms)
345 int meanWaitingTimeMs;
346 // median packet waiting time in the jitter buffer (ms)
347 int medianWaitingTimeMs;
348 // min packet waiting time in the jitter buffer (ms)
349 int minWaitingTimeMs;
350 // max packet waiting time in the jitter buffer (ms)
351 int maxWaitingTimeMs;
roosa@google.com0049a762012-12-14 00:06:18 +0000352 // added samples in off mode due to packet loss
353 int addedSamples;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000354};
355
wu@webrtc.org79d6daf2013-12-13 19:17:43 +0000356// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
357struct AudioDecodingCallStats {
358 AudioDecodingCallStats()
359 : calls_to_silence_generator(0),
360 calls_to_neteq(0),
361 decoded_normal(0),
362 decoded_plc(0),
363 decoded_cng(0),
364 decoded_plc_cng(0) {}
365
366 int calls_to_silence_generator; // Number of calls where silence generated,
367 // and NetEq was disengaged from decoding.
368 int calls_to_neteq; // Number of calls to NetEq.
369 int decoded_normal; // Number of calls where audio RTP packet decoded.
370 int decoded_plc; // Number of calls resulted in PLC.
371 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
372 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
373};
374
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000375typedef struct
376{
377 int min; // minumum
378 int max; // maximum
379 int average; // average
380} StatVal;
381
382typedef struct // All levels are reported in dBm0
383{
384 StatVal speech_rx; // long-term speech levels on receiving side
385 StatVal speech_tx; // long-term speech levels on transmitting side
386 StatVal noise_rx; // long-term noise/silence levels on receiving side
387 StatVal noise_tx; // long-term noise/silence levels on transmitting side
388} LevelStatistics;
389
390typedef struct // All levels are reported in dB
391{
392 StatVal erl; // Echo Return Loss
393 StatVal erle; // Echo Return Loss Enhancement
394 StatVal rerl; // RERL = ERL + ERLE
395 // Echo suppression inside EC at the point just before its NLP
396 StatVal a_nlp;
397} EchoStatistics;
398
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000399enum NsModes // type of Noise Suppression
400{
401 kNsUnchanged = 0, // previously set mode
402 kNsDefault, // platform default
403 kNsConference, // conferencing default
404 kNsLowSuppression, // lowest suppression
405 kNsModerateSuppression,
406 kNsHighSuppression,
407 kNsVeryHighSuppression, // highest suppression
408};
409
410enum AgcModes // type of Automatic Gain Control
411{
412 kAgcUnchanged = 0, // previously set mode
413 kAgcDefault, // platform default
414 // adaptive mode for use when analog volume control exists (e.g. for
415 // PC softphone)
416 kAgcAdaptiveAnalog,
417 // scaling takes place in the digital domain (e.g. for conference servers
418 // and embedded devices)
419 kAgcAdaptiveDigital,
420 // can be used on embedded devices where the capture signal level
421 // is predictable
422 kAgcFixedDigital
423};
424
425// EC modes
426enum EcModes // type of Echo Control
427{
428 kEcUnchanged = 0, // previously set mode
429 kEcDefault, // platform default
430 kEcConference, // conferencing default (aggressive AEC)
431 kEcAec, // Acoustic Echo Cancellation
432 kEcAecm, // AEC mobile
433};
434
435// AECM modes
436enum AecmModes // mode of AECM
437{
438 kAecmQuietEarpieceOrHeadset = 0,
439 // Quiet earpiece or headset use
440 kAecmEarpiece, // most earpiece use
441 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
442 kAecmSpeakerphone, // most speakerphone use (default)
443 kAecmLoudSpeakerphone // Loud speakerphone
444};
445
446// AGC configuration
447typedef struct
448{
449 unsigned short targetLeveldBOv;
450 unsigned short digitalCompressionGaindB;
451 bool limiterEnable;
452} AgcConfig; // AGC configuration parameters
453
454enum StereoChannel
455{
456 kStereoLeft = 0,
457 kStereoRight,
458 kStereoBoth
459};
460
461// Audio device layers
462enum AudioLayers
463{
464 kAudioPlatformDefault = 0,
465 kAudioWindowsWave = 1,
466 kAudioWindowsCore = 2,
467 kAudioLinuxAlsa = 3,
468 kAudioLinuxPulse = 4
469};
470
henrika@webrtc.org692224a2014-04-17 10:45:01 +0000471// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000472enum NetEqModes // NetEQ playout configurations
473{
474 // Optimized trade-off between low delay and jitter robustness for two-way
475 // communication.
476 kNetEqDefault = 0,
477 // Improved jitter robustness at the cost of increased delay. Can be
478 // used in one-way communication.
479 kNetEqStreaming = 1,
480 // Optimzed for decodability of fax signals rather than for perceived audio
481 // quality.
482 kNetEqFax = 2,
roosa@google.com90d333e2012-12-12 21:59:14 +0000483 // Minimal buffer management. Inserts zeros for lost packets and during
484 // buffer increases.
485 kNetEqOff = 3,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000486};
487
henrika@webrtc.org692224a2014-04-17 10:45:01 +0000488// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000489enum OnHoldModes // On Hold direction
490{
491 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
492 kHoldSendOnly, // Put only sending in on-hold state.
493 kHoldPlayOnly // Put only playing in on-hold state.
494};
495
henrika@webrtc.org692224a2014-04-17 10:45:01 +0000496// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000497enum AmrMode
498{
499 kRfc3267BwEfficient = 0,
500 kRfc3267OctetAligned = 1,
501 kRfc3267FileStorage = 2,
502};
503
504// ==================================================================
505// Video specific types
506// ==================================================================
507
508// Raw video types
509enum RawVideoType
510{
511 kVideoI420 = 0,
512 kVideoYV12 = 1,
513 kVideoYUY2 = 2,
514 kVideoUYVY = 3,
515 kVideoIYUV = 4,
516 kVideoARGB = 5,
517 kVideoRGB24 = 6,
518 kVideoRGB565 = 7,
519 kVideoARGB4444 = 8,
520 kVideoARGB1555 = 9,
521 kVideoMJPEG = 10,
522 kVideoNV12 = 11,
523 kVideoNV21 = 12,
524 kVideoBGRA = 13,
525 kVideoUnknown = 99
526};
527
528// Video codec
529enum { kConfigParameterSize = 128};
530enum { kPayloadNameSize = 32};
531enum { kMaxSimulcastStreams = 4};
532enum { kMaxTemporalStreams = 4};
533
534enum VideoCodecComplexity
535{
536 kComplexityNormal = 0,
537 kComplexityHigh = 1,
538 kComplexityHigher = 2,
539 kComplexityMax = 3
540};
541
542enum VideoCodecProfile
543{
544 kProfileBase = 0x00,
545 kProfileMain = 0x01
546};
547
548enum VP8ResilienceMode {
549 kResilienceOff, // The stream produced by the encoder requires a
550 // recovery frame (typically a key frame) to be
551 // decodable after a packet loss.
552 kResilientStream, // A stream produced by the encoder is resilient to
553 // packet losses, but packets within a frame subsequent
554 // to a loss can't be decoded.
555 kResilientFrames // Same as kResilientStream but with added resilience
556 // within a frame.
557};
558
559// VP8 specific
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000560struct VideoCodecVP8 {
561 bool pictureLossIndicationOn;
562 bool feedbackModeOn;
563 VideoCodecComplexity complexity;
564 VP8ResilienceMode resilience;
565 unsigned char numberOfTemporalLayers;
566 bool denoisingOn;
567 bool errorConcealmentOn;
568 bool automaticResizeOn;
569 bool frameDroppingOn;
570 int keyFrameInterval;
571
572 bool operator==(const VideoCodecVP8& other) const {
573 return pictureLossIndicationOn == other.pictureLossIndicationOn &&
574 feedbackModeOn == other.feedbackModeOn &&
575 complexity == other.complexity &&
576 resilience == other.resilience &&
577 numberOfTemporalLayers == other.numberOfTemporalLayers &&
578 denoisingOn == other.denoisingOn &&
579 errorConcealmentOn == other.errorConcealmentOn &&
580 automaticResizeOn == other.automaticResizeOn &&
581 frameDroppingOn == other.frameDroppingOn &&
582 keyFrameInterval == other.keyFrameInterval;
583 }
584
585 bool operator!=(const VideoCodecVP8& other) const {
586 return !(*this == other);
587 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000588};
589
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000590// Video codec types
591enum VideoCodecType
592{
593 kVideoCodecVP8,
594 kVideoCodecI420,
595 kVideoCodecRED,
596 kVideoCodecULPFEC,
pbos@webrtc.orge3339fc2013-03-18 16:39:03 +0000597 kVideoCodecGeneric,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000598 kVideoCodecUnknown
599};
600
601union VideoCodecUnion
602{
603 VideoCodecVP8 VP8;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000604};
605
606
607// Simulcast is when the same stream is encoded multiple times with different
608// settings such as resolution.
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000609struct SimulcastStream {
610 unsigned short width;
611 unsigned short height;
612 unsigned char numberOfTemporalLayers;
613 unsigned int maxBitrate; // kilobits/sec.
614 unsigned int targetBitrate; // kilobits/sec.
615 unsigned int minBitrate; // kilobits/sec.
616 unsigned int qpMax; // minimum quality
617
618 bool operator==(const SimulcastStream& other) const {
619 return width == other.width &&
620 height == other.height &&
621 numberOfTemporalLayers == other.numberOfTemporalLayers &&
622 maxBitrate == other.maxBitrate &&
623 targetBitrate == other.targetBitrate &&
624 minBitrate == other.minBitrate &&
625 qpMax == other.qpMax;
626 }
627
628 bool operator!=(const SimulcastStream& other) const {
629 return !(*this == other);
630 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000631};
632
stefan@webrtc.orgf4d37882013-02-18 14:40:18 +0000633enum VideoCodecMode {
634 kRealtimeVideo,
635 kScreensharing
636};
637
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000638// Common video codec properties
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000639struct VideoCodec {
640 VideoCodecType codecType;
641 char plName[kPayloadNameSize];
642 unsigned char plType;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000643
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000644 unsigned short width;
645 unsigned short height;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000646
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000647 unsigned int startBitrate; // kilobits/sec.
648 unsigned int maxBitrate; // kilobits/sec.
649 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org3d6910c2014-03-24 12:36:52 +0000650 unsigned int targetBitrate; // kilobits/sec.
651
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000652 unsigned char maxFramerate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000653
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000654 VideoCodecUnion codecSpecific;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000655
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000656 unsigned int qpMax;
657 unsigned char numberOfSimulcastStreams;
658 SimulcastStream simulcastStream[kMaxSimulcastStreams];
stefan@webrtc.orgf4d37882013-02-18 14:40:18 +0000659
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000660 VideoCodecMode mode;
andresp@webrtc.orgee6f8a22013-05-14 08:02:25 +0000661
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000662 // When using an external encoder/decoder this allows to pass
663 // extra options without requiring webrtc to be aware of them.
664 Config* extra_options;
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000665
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000666 bool operator==(const VideoCodec& other) const {
667 bool ret = codecType == other.codecType &&
668 (STR_CASE_CMP(plName, other.plName) == 0) &&
669 plType == other.plType &&
670 width == other.width &&
671 height == other.height &&
672 startBitrate == other.startBitrate &&
673 maxBitrate == other.maxBitrate &&
674 minBitrate == other.minBitrate &&
pbos@webrtc.org3d6910c2014-03-24 12:36:52 +0000675 targetBitrate == other.targetBitrate &&
mallinath@webrtc.org18c29452014-03-21 00:41:28 +0000676 maxFramerate == other.maxFramerate &&
677 qpMax == other.qpMax &&
678 numberOfSimulcastStreams == other.numberOfSimulcastStreams &&
679 mode == other.mode;
680 if (ret && codecType == kVideoCodecVP8) {
681 ret &= (codecSpecific.VP8 == other.codecSpecific.VP8);
682 }
683
684 for (unsigned char i = 0; i < other.numberOfSimulcastStreams && ret; ++i) {
685 ret &= (simulcastStream[i] == other.simulcastStream[i]);
686 }
687 return ret;
688 }
689
690 bool operator!=(const VideoCodec& other) const {
691 return !(*this == other);
692 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000693};
694
695// Bandwidth over-use detector options. These are used to drive
696// experimentation with bandwidth estimation parameters.
697// See modules/remote_bitrate_estimator/overuse_detector.h
698struct OverUseDetectorOptions {
699 OverUseDetectorOptions()
700 : initial_slope(8.0/512.0),
701 initial_offset(0),
702 initial_e(),
703 initial_process_noise(),
704 initial_avg_noise(0.0),
705 initial_var_noise(50),
706 initial_threshold(25.0) {
707 initial_e[0][0] = 100;
708 initial_e[1][1] = 1e-1;
709 initial_e[0][1] = initial_e[1][0] = 0;
710 initial_process_noise[0] = 1e-10;
711 initial_process_noise[1] = 1e-2;
712 }
713 double initial_slope;
714 double initial_offset;
715 double initial_e[2][2];
716 double initial_process_noise[2];
717 double initial_avg_noise;
718 double initial_var_noise;
719 double initial_threshold;
720};
andrew@webrtc.org5cf83f42013-09-09 17:50:10 +0000721
wu@webrtc.orgefeb8ce2013-12-13 00:21:03 +0000722// This structure will have the information about when packet is actually
723// received by socket.
724struct PacketTime {
henrike@webrtc.org93ae8212014-04-29 17:50:47 +0000725 PacketTime() : timestamp(-1), not_before(-1) {}
726 PacketTime(int64_t timestamp, int64_t not_before)
727 : timestamp(timestamp), not_before(not_before) {
wu@webrtc.orgefeb8ce2013-12-13 00:21:03 +0000728 }
729
henrike@webrtc.org93ae8212014-04-29 17:50:47 +0000730 int64_t timestamp; // Receive time after socket delivers the data.
731 int64_t not_before; // Earliest possible time the data could have arrived,
732 // indicating the potential error in the |timestamp|
733 // value,in case the system is busy.
734 // For example, the time of the last select() call.
735 // If unknown, this value will be set to zero.
wu@webrtc.orgefeb8ce2013-12-13 00:21:03 +0000736};
737
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25 +0000738struct RTPHeaderExtension {
739 RTPHeaderExtension()
740 : hasTransmissionTimeOffset(false),
741 transmissionTimeOffset(0),
742 hasAbsoluteSendTime(false),
743 absoluteSendTime(0),
744 hasAudioLevel(false),
745 audioLevel(0) {}
746
747 bool hasTransmissionTimeOffset;
748 int32_t transmissionTimeOffset;
749 bool hasAbsoluteSendTime;
750 uint32_t absoluteSendTime;
751
752 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
753 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
754 bool hasAudioLevel;
755 uint8_t audioLevel;
756};
757
758struct RTPHeader {
759 RTPHeader()
760 : markerBit(false),
761 payloadType(0),
762 sequenceNumber(0),
763 timestamp(0),
764 ssrc(0),
765 numCSRCs(0),
766 paddingLength(0),
767 headerLength(0),
768 payload_type_frequency(0),
769 extension() {
770 memset(&arrOfCSRCs, 0, sizeof(arrOfCSRCs));
771 }
772
773 bool markerBit;
774 uint8_t payloadType;
775 uint16_t sequenceNumber;
776 uint32_t timestamp;
777 uint32_t ssrc;
778 uint8_t numCSRCs;
779 uint32_t arrOfCSRCs[kRtpCsrcSize];
780 uint8_t paddingLength;
781 uint16_t headerLength;
782 int payload_type_frequency;
783 RTPHeaderExtension extension;
784};
785
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000786} // namespace webrtc
andrew@webrtc.org5cf83f42013-09-09 17:50:10 +0000787
788#endif // WEBRTC_COMMON_TYPES_H_