blob: 0b4af26e6a3dc31cb0ab889e3f91f719c890ea18 [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:231/*
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:1011#ifndef WEBRTC_COMMON_TYPES_H_
12#define WEBRTC_COMMON_TYPES_H_
andrew@webrtc.orgb015cbe2012-10-22 18:19:2313
pbos@webrtc.orge2a7a772014-03-19 08:43:5714#include <stddef.h>
mallinath@webrtc.org18c29452014-03-21 00:41:2815#include <string.h>
pbos@webrtc.org7e686932014-05-15 09:35:0616
17#include <string>
pbos@webrtc.orge2a7a772014-03-19 08:43:5718#include <vector>
19
andrew@webrtc.org5cf83f42013-09-09 17:50:1020#include "webrtc/typedefs.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:2321
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:2842#if defined(WEBRTC_WIN) || defined(WIN32)
andrew@webrtc.org5cf83f42013-09-09 17:50:1043// 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:2352namespace webrtc {
53
andresp@webrtc.orgee6f8a22013-05-14 08:02:2554class Config;
55
andrew@webrtc.orgb015cbe2012-10-22 18:19:2356class 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:4478 kTraceUndefined = 0,
andrew@webrtc.orgb015cbe2012-10-22 18:19:2379 // not a module, triggered from the engine code
pbos@webrtc.org46f72882013-12-16 12:24:4480 kTraceVoice = 0x0001,
andrew@webrtc.orgb015cbe2012-10-22 18:19:2381 // not a module, triggered from the engine code
pbos@webrtc.org46f72882013-12-16 12:24:4482 kTraceVideo = 0x0002,
andrew@webrtc.orgb015cbe2012-10-22 18:19:2383 // not a module, triggered from the utility code
pbos@webrtc.org46f72882013-12-16 12:24:4484 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:4498 kTraceRemoteBitrateEstimator = 0x0017,
andrew@webrtc.orgb015cbe2012-10-22 18:19:2399};
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:45120 // 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:23123 kTraceAll = 0xffff
124};
125
126// External Trace API
andrew@webrtc.orgd75680a2012-11-15 05:33:25127class TraceCallback {
128 public:
129 virtual void Print(TraceLevel level, const char* message, int length) = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23130
andrew@webrtc.orgd75680a2012-11-15 05:33:25131 protected:
132 virtual ~TraceCallback() {}
133 TraceCallback() {}
134};
andrew@webrtc.orgb015cbe2012-10-22 18:19:23135
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:23147enum ProcessingTypes
148{
149 kPlaybackPerChannel = 0,
150 kPlaybackAllChannelsMixed,
151 kRecordingPerChannel,
152 kRecordingAllChannelsMixed,
153 kRecordingPreprocessing
154};
155
sprang@webrtc.org5fdd10a2013-12-04 15:09:27156enum 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:23165// 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:07177// Statistics for an RTCP channel
sprang@webrtc.org2714c792013-10-28 09:21:07178struct RtcpStatistics {
sprang@webrtc.org2714c792013-10-28 09:21:07179 RtcpStatistics()
180 : fraction_lost(0),
181 cumulative_lost(0),
182 extended_max_sequence_number(0),
sprang@webrtc.org9b30fd32013-12-05 09:48:44183 jitter(0) {}
sprang@webrtc.org2714c792013-10-28 09:21:07184
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:07189};
190
sprang@webrtc.org46736742013-11-20 16:47:07191// 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:02200// Statistics for RTCP packet types.
201struct RtcpPacketTypeCounter {
202 RtcpPacketTypeCounter()
203 : nack_packets(0),
204 fir_packets(0),
asapersson@webrtc.org2ba45ee2014-10-29 12:42:30205 pli_packets(0),
206 nack_requests(0),
207 unique_nack_requests(0) {}
asapersson@webrtc.org4a155602014-02-19 11:59:02208
209 void Add(const RtcpPacketTypeCounter& other) {
210 nack_packets += other.nack_packets;
211 fir_packets += other.fir_packets;
212 pli_packets += other.pli_packets;
asapersson@webrtc.org2ba45ee2014-10-29 12:42:30213 nack_requests += other.nack_requests;
214 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.org4a155602014-02-19 11:59:02215 }
216
asapersson@webrtc.org2ba45ee2014-10-29 12:42:30217 int UniqueNackRequestsInPercent() const {
218 if (nack_requests == 0) {
219 return 0;
220 }
221 return static_cast<int>(
222 (unique_nack_requests * 100.0f / nack_requests) + 0.5f);
223 }
224
225 uint32_t nack_packets; // Number of RTCP NACK packets.
226 uint32_t fir_packets; // Number of RTCP FIR packets.
227 uint32_t pli_packets; // Number of RTCP PLI packets.
228 uint32_t nack_requests; // Number of NACKed RTP packets.
229 uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
asapersson@webrtc.org4a155602014-02-19 11:59:02230};
231
sprang@webrtc.org46736742013-11-20 16:47:07232// Data usage statistics for a (rtp) stream
233struct StreamDataCounters {
sprang@webrtc.org46736742013-11-20 16:47:07234 StreamDataCounters()
235 : bytes(0),
sprang@webrtc.orgb1139812013-12-05 14:29:02236 header_bytes(0),
sprang@webrtc.org46736742013-11-20 16:47:07237 padding_bytes(0),
238 packets(0),
239 retransmitted_packets(0),
240 fec_packets(0) {}
241
pbos@webrtc.org9aa34972014-07-10 16:24:54242 // TODO(pbos): Rename bytes -> media_bytes.
sprang@webrtc.orgb1139812013-12-05 14:29:02243 uint32_t bytes; // Payload bytes, excluding RTP headers and padding.
244 uint32_t header_bytes; // Number of bytes used by RTP headers.
245 uint32_t padding_bytes; // Number of padding bytes.
246 uint32_t packets; // Number of packets.
247 uint32_t retransmitted_packets; // Number of retransmitted packets.
248 uint32_t fec_packets; // Number of redundancy packets.
sprang@webrtc.org46736742013-11-20 16:47:07249};
250
251// Callback, called whenever byte/packet counts have been updated.
252class StreamDataCountersCallback {
253 public:
254 virtual ~StreamDataCountersCallback() {}
255
256 virtual void DataCountersUpdated(const StreamDataCounters& counters,
257 uint32_t ssrc) = 0;
258};
259
260// Rate statistics for a stream
261struct BitrateStatistics {
sprang@webrtc.orgb70db6d2013-12-13 09:46:59262 BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
sprang@webrtc.org46736742013-11-20 16:47:07263
sprang@webrtc.orgb70db6d2013-12-13 09:46:59264 uint32_t bitrate_bps; // Bitrate in bits per second.
265 uint32_t packet_rate; // Packet rate in packets per second.
266 uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation.
sprang@webrtc.org46736742013-11-20 16:47:07267};
268
269// Callback, used to notify an observer whenever new rates have been estimated.
270class BitrateStatisticsObserver {
271 public:
272 virtual ~BitrateStatisticsObserver() {}
273
stefan@webrtc.org52322672014-11-05 14:05:29274 virtual void Notify(const BitrateStatistics& total_stats,
275 const BitrateStatistics& retransmit_stats,
276 uint32_t ssrc) = 0;
sprang@webrtc.org46736742013-11-20 16:47:07277};
278
279// Callback, used to notify an observer whenever frame counts have been updated
280class FrameCountObserver {
281 public:
sprang@webrtc.org21dc10d2013-11-21 09:09:54282 virtual ~FrameCountObserver() {}
sprang@webrtc.org5fdd10a2013-12-04 15:09:27283 virtual void FrameCountUpdated(FrameType frame_type,
284 uint32_t frame_count,
285 const unsigned int ssrc) = 0;
sprang@webrtc.org46736742013-11-20 16:47:07286};
287
stefan@webrtc.org55b0f2e2014-07-11 13:44:02288// Callback, used to notify an observer whenever the send-side delay is updated.
289class SendSideDelayObserver {
290 public:
291 virtual ~SendSideDelayObserver() {}
292 virtual void SendSideDelayUpdated(int avg_delay_ms,
293 int max_delay_ms,
294 uint32_t ssrc) = 0;
295};
296
andrew@webrtc.orgb015cbe2012-10-22 18:19:23297// ==================================================================
298// Voice specific types
299// ==================================================================
300
301// Each codec supported can be described by this structure.
mallinath@webrtc.org18c29452014-03-21 00:41:28302struct CodecInst {
303 int pltype;
304 char plname[RTP_PAYLOAD_NAME_SIZE];
305 int plfreq;
306 int pacsize;
307 int channels;
308 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
309
310 bool operator==(const CodecInst& other) const {
311 return pltype == other.pltype &&
312 (STR_CASE_CMP(plname, other.plname) == 0) &&
313 plfreq == other.plfreq &&
314 pacsize == other.pacsize &&
315 channels == other.channels &&
316 rate == other.rate;
317 }
318
319 bool operator!=(const CodecInst& other) const {
320 return !(*this == other);
321 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23322};
323
andrew@webrtc.orgb015cbe2012-10-22 18:19:23324// RTP
325enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
326
327enum RTPDirections
328{
329 kRtpIncoming = 0,
330 kRtpOutgoing
331};
332
333enum PayloadFrequencies
334{
335 kFreq8000Hz = 8000,
336 kFreq16000Hz = 16000,
337 kFreq32000Hz = 32000
338};
339
340enum VadModes // degree of bandwidth reduction
341{
342 kVadConventional = 0, // lowest reduction
343 kVadAggressiveLow,
344 kVadAggressiveMid,
345 kVadAggressiveHigh // highest reduction
346};
347
348struct NetworkStatistics // NETEQ statistics
349{
350 // current jitter buffer size in ms
pbos@webrtc.org52b2ee52013-05-03 12:02:11351 uint16_t currentBufferSize;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23352 // preferred (optimal) buffer size in ms
pbos@webrtc.org52b2ee52013-05-03 12:02:11353 uint16_t preferredBufferSize;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23354 // adding extra delay due to "peaky jitter"
355 bool jitterPeaksFound;
henrik.lundin@webrtc.org6e7480a2014-10-09 12:58:45356 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org52b2ee52013-05-03 12:02:11357 uint16_t currentPacketLossRate;
henrik.lundin@webrtc.org6e7480a2014-10-09 12:58:45358 // Late loss rate; fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org52b2ee52013-05-03 12:02:11359 uint16_t currentDiscardRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23360 // fraction (of original stream) of synthesized speech inserted through
361 // expansion (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11362 uint16_t currentExpandRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23363 // fraction of synthesized speech inserted through pre-emptive expansion
364 // (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11365 uint16_t currentPreemptiveRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23366 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11367 uint16_t currentAccelerateRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23368 // clock-drift in parts-per-million (negative or positive)
369 int32_t clockDriftPPM;
370 // average packet waiting time in the jitter buffer (ms)
371 int meanWaitingTimeMs;
372 // median packet waiting time in the jitter buffer (ms)
373 int medianWaitingTimeMs;
374 // min packet waiting time in the jitter buffer (ms)
375 int minWaitingTimeMs;
376 // max packet waiting time in the jitter buffer (ms)
377 int maxWaitingTimeMs;
roosa@google.com0049a762012-12-14 00:06:18378 // added samples in off mode due to packet loss
379 int addedSamples;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23380};
381
wu@webrtc.org79d6daf2013-12-13 19:17:43382// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
383struct AudioDecodingCallStats {
384 AudioDecodingCallStats()
385 : calls_to_silence_generator(0),
386 calls_to_neteq(0),
387 decoded_normal(0),
388 decoded_plc(0),
389 decoded_cng(0),
390 decoded_plc_cng(0) {}
391
392 int calls_to_silence_generator; // Number of calls where silence generated,
393 // and NetEq was disengaged from decoding.
394 int calls_to_neteq; // Number of calls to NetEq.
395 int decoded_normal; // Number of calls where audio RTP packet decoded.
396 int decoded_plc; // Number of calls resulted in PLC.
397 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
398 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
399};
400
andrew@webrtc.orgb015cbe2012-10-22 18:19:23401typedef struct
402{
403 int min; // minumum
404 int max; // maximum
405 int average; // average
406} StatVal;
407
408typedef struct // All levels are reported in dBm0
409{
410 StatVal speech_rx; // long-term speech levels on receiving side
411 StatVal speech_tx; // long-term speech levels on transmitting side
412 StatVal noise_rx; // long-term noise/silence levels on receiving side
413 StatVal noise_tx; // long-term noise/silence levels on transmitting side
414} LevelStatistics;
415
416typedef struct // All levels are reported in dB
417{
418 StatVal erl; // Echo Return Loss
419 StatVal erle; // Echo Return Loss Enhancement
420 StatVal rerl; // RERL = ERL + ERLE
421 // Echo suppression inside EC at the point just before its NLP
422 StatVal a_nlp;
423} EchoStatistics;
424
andrew@webrtc.orgb015cbe2012-10-22 18:19:23425enum NsModes // type of Noise Suppression
426{
427 kNsUnchanged = 0, // previously set mode
428 kNsDefault, // platform default
429 kNsConference, // conferencing default
430 kNsLowSuppression, // lowest suppression
431 kNsModerateSuppression,
432 kNsHighSuppression,
433 kNsVeryHighSuppression, // highest suppression
434};
435
436enum AgcModes // type of Automatic Gain Control
437{
438 kAgcUnchanged = 0, // previously set mode
439 kAgcDefault, // platform default
440 // adaptive mode for use when analog volume control exists (e.g. for
441 // PC softphone)
442 kAgcAdaptiveAnalog,
443 // scaling takes place in the digital domain (e.g. for conference servers
444 // and embedded devices)
445 kAgcAdaptiveDigital,
446 // can be used on embedded devices where the capture signal level
447 // is predictable
448 kAgcFixedDigital
449};
450
451// EC modes
452enum EcModes // type of Echo Control
453{
454 kEcUnchanged = 0, // previously set mode
455 kEcDefault, // platform default
456 kEcConference, // conferencing default (aggressive AEC)
457 kEcAec, // Acoustic Echo Cancellation
458 kEcAecm, // AEC mobile
459};
460
461// AECM modes
462enum AecmModes // mode of AECM
463{
464 kAecmQuietEarpieceOrHeadset = 0,
465 // Quiet earpiece or headset use
466 kAecmEarpiece, // most earpiece use
467 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
468 kAecmSpeakerphone, // most speakerphone use (default)
469 kAecmLoudSpeakerphone // Loud speakerphone
470};
471
472// AGC configuration
473typedef struct
474{
475 unsigned short targetLeveldBOv;
476 unsigned short digitalCompressionGaindB;
477 bool limiterEnable;
478} AgcConfig; // AGC configuration parameters
479
480enum StereoChannel
481{
482 kStereoLeft = 0,
483 kStereoRight,
484 kStereoBoth
485};
486
487// Audio device layers
488enum AudioLayers
489{
490 kAudioPlatformDefault = 0,
491 kAudioWindowsWave = 1,
492 kAudioWindowsCore = 2,
493 kAudioLinuxAlsa = 3,
494 kAudioLinuxPulse = 4
495};
496
henrika@webrtc.org692224a2014-04-17 10:45:01497// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23498enum NetEqModes // NetEQ playout configurations
499{
500 // Optimized trade-off between low delay and jitter robustness for two-way
501 // communication.
502 kNetEqDefault = 0,
503 // Improved jitter robustness at the cost of increased delay. Can be
504 // used in one-way communication.
505 kNetEqStreaming = 1,
506 // Optimzed for decodability of fax signals rather than for perceived audio
507 // quality.
508 kNetEqFax = 2,
roosa@google.com90d333e2012-12-12 21:59:14509 // Minimal buffer management. Inserts zeros for lost packets and during
510 // buffer increases.
511 kNetEqOff = 3,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23512};
513
henrika@webrtc.org692224a2014-04-17 10:45:01514// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23515enum OnHoldModes // On Hold direction
516{
517 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
518 kHoldSendOnly, // Put only sending in on-hold state.
519 kHoldPlayOnly // Put only playing in on-hold state.
520};
521
henrika@webrtc.org692224a2014-04-17 10:45:01522// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23523enum AmrMode
524{
525 kRfc3267BwEfficient = 0,
526 kRfc3267OctetAligned = 1,
527 kRfc3267FileStorage = 2,
528};
529
530// ==================================================================
531// Video specific types
532// ==================================================================
533
534// Raw video types
535enum RawVideoType
536{
537 kVideoI420 = 0,
538 kVideoYV12 = 1,
539 kVideoYUY2 = 2,
540 kVideoUYVY = 3,
541 kVideoIYUV = 4,
542 kVideoARGB = 5,
543 kVideoRGB24 = 6,
544 kVideoRGB565 = 7,
545 kVideoARGB4444 = 8,
546 kVideoARGB1555 = 9,
547 kVideoMJPEG = 10,
548 kVideoNV12 = 11,
549 kVideoNV21 = 12,
550 kVideoBGRA = 13,
551 kVideoUnknown = 99
552};
553
554// Video codec
555enum { kConfigParameterSize = 128};
556enum { kPayloadNameSize = 32};
557enum { kMaxSimulcastStreams = 4};
558enum { kMaxTemporalStreams = 4};
559
560enum VideoCodecComplexity
561{
562 kComplexityNormal = 0,
563 kComplexityHigh = 1,
564 kComplexityHigher = 2,
565 kComplexityMax = 3
566};
567
568enum VideoCodecProfile
569{
570 kProfileBase = 0x00,
571 kProfileMain = 0x01
572};
573
574enum VP8ResilienceMode {
575 kResilienceOff, // The stream produced by the encoder requires a
576 // recovery frame (typically a key frame) to be
577 // decodable after a packet loss.
578 kResilientStream, // A stream produced by the encoder is resilient to
579 // packet losses, but packets within a frame subsequent
580 // to a loss can't be decoded.
581 kResilientFrames // Same as kResilientStream but with added resilience
582 // within a frame.
583};
584
585// VP8 specific
mallinath@webrtc.org18c29452014-03-21 00:41:28586struct VideoCodecVP8 {
587 bool pictureLossIndicationOn;
588 bool feedbackModeOn;
589 VideoCodecComplexity complexity;
590 VP8ResilienceMode resilience;
591 unsigned char numberOfTemporalLayers;
592 bool denoisingOn;
593 bool errorConcealmentOn;
594 bool automaticResizeOn;
595 bool frameDroppingOn;
596 int keyFrameInterval;
597
598 bool operator==(const VideoCodecVP8& other) const {
599 return pictureLossIndicationOn == other.pictureLossIndicationOn &&
600 feedbackModeOn == other.feedbackModeOn &&
601 complexity == other.complexity &&
602 resilience == other.resilience &&
603 numberOfTemporalLayers == other.numberOfTemporalLayers &&
604 denoisingOn == other.denoisingOn &&
605 errorConcealmentOn == other.errorConcealmentOn &&
606 automaticResizeOn == other.automaticResizeOn &&
607 frameDroppingOn == other.frameDroppingOn &&
608 keyFrameInterval == other.keyFrameInterval;
609 }
610
611 bool operator!=(const VideoCodecVP8& other) const {
612 return !(*this == other);
613 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23614};
615
marpan@webrtc.org66373882014-11-01 06:10:48616// VP9 specific
617struct VideoCodecVP9 {
618 VideoCodecComplexity complexity;
619 int resilience;
620 unsigned char numberOfTemporalLayers;
621 bool denoisingOn;
622 bool frameDroppingOn;
623 int keyFrameInterval;
624 bool adaptiveQpMode;
625};
626
stefan@webrtc.org2d4a80c2014-07-04 12:42:07627// H264 specific.
marpan@webrtc.org66373882014-11-01 06:10:48628struct VideoCodecH264 {
629 VideoCodecProfile profile;
630 bool frameDroppingOn;
631 int keyFrameInterval;
632 // These are NULL/0 if not externally negotiated.
633 const uint8_t* spsData;
634 size_t spsLen;
635 const uint8_t* ppsData;
636 size_t ppsLen;
stefan@webrtc.org2d4a80c2014-07-04 12:42:07637};
638
andrew@webrtc.orgb015cbe2012-10-22 18:19:23639// Video codec types
marpan@webrtc.org66373882014-11-01 06:10:48640enum VideoCodecType {
641 kVideoCodecVP8,
642 kVideoCodecVP9,
643 kVideoCodecH264,
644 kVideoCodecI420,
645 kVideoCodecRED,
646 kVideoCodecULPFEC,
647 kVideoCodecGeneric,
648 kVideoCodecUnknown
andrew@webrtc.orgb015cbe2012-10-22 18:19:23649};
650
marpan@webrtc.org66373882014-11-01 06:10:48651union VideoCodecUnion {
652 VideoCodecVP8 VP8;
653 VideoCodecVP9 VP9;
654 VideoCodecH264 H264;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23655};
656
657
658// Simulcast is when the same stream is encoded multiple times with different
659// settings such as resolution.
mallinath@webrtc.org18c29452014-03-21 00:41:28660struct SimulcastStream {
661 unsigned short width;
662 unsigned short height;
663 unsigned char numberOfTemporalLayers;
664 unsigned int maxBitrate; // kilobits/sec.
665 unsigned int targetBitrate; // kilobits/sec.
666 unsigned int minBitrate; // kilobits/sec.
667 unsigned int qpMax; // minimum quality
668
669 bool operator==(const SimulcastStream& other) const {
670 return width == other.width &&
671 height == other.height &&
672 numberOfTemporalLayers == other.numberOfTemporalLayers &&
673 maxBitrate == other.maxBitrate &&
674 targetBitrate == other.targetBitrate &&
675 minBitrate == other.minBitrate &&
676 qpMax == other.qpMax;
677 }
678
679 bool operator!=(const SimulcastStream& other) const {
680 return !(*this == other);
681 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23682};
683
stefan@webrtc.orgf4d37882013-02-18 14:40:18684enum VideoCodecMode {
685 kRealtimeVideo,
686 kScreensharing
687};
688
andrew@webrtc.orgb015cbe2012-10-22 18:19:23689// Common video codec properties
mallinath@webrtc.org18c29452014-03-21 00:41:28690struct VideoCodec {
691 VideoCodecType codecType;
692 char plName[kPayloadNameSize];
693 unsigned char plType;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23694
mallinath@webrtc.org18c29452014-03-21 00:41:28695 unsigned short width;
696 unsigned short height;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23697
mallinath@webrtc.org18c29452014-03-21 00:41:28698 unsigned int startBitrate; // kilobits/sec.
699 unsigned int maxBitrate; // kilobits/sec.
700 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org3d6910c2014-03-24 12:36:52701 unsigned int targetBitrate; // kilobits/sec.
702
mallinath@webrtc.org18c29452014-03-21 00:41:28703 unsigned char maxFramerate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23704
mallinath@webrtc.org18c29452014-03-21 00:41:28705 VideoCodecUnion codecSpecific;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23706
mallinath@webrtc.org18c29452014-03-21 00:41:28707 unsigned int qpMax;
708 unsigned char numberOfSimulcastStreams;
709 SimulcastStream simulcastStream[kMaxSimulcastStreams];
stefan@webrtc.orgf4d37882013-02-18 14:40:18710
mallinath@webrtc.org18c29452014-03-21 00:41:28711 VideoCodecMode mode;
andresp@webrtc.orgee6f8a22013-05-14 08:02:25712
mallinath@webrtc.org18c29452014-03-21 00:41:28713 // When using an external encoder/decoder this allows to pass
714 // extra options without requiring webrtc to be aware of them.
715 Config* extra_options;
mallinath@webrtc.org18c29452014-03-21 00:41:28716
mallinath@webrtc.org18c29452014-03-21 00:41:28717 bool operator==(const VideoCodec& other) const {
718 bool ret = codecType == other.codecType &&
719 (STR_CASE_CMP(plName, other.plName) == 0) &&
720 plType == other.plType &&
721 width == other.width &&
722 height == other.height &&
723 startBitrate == other.startBitrate &&
724 maxBitrate == other.maxBitrate &&
725 minBitrate == other.minBitrate &&
pbos@webrtc.org3d6910c2014-03-24 12:36:52726 targetBitrate == other.targetBitrate &&
mallinath@webrtc.org18c29452014-03-21 00:41:28727 maxFramerate == other.maxFramerate &&
728 qpMax == other.qpMax &&
729 numberOfSimulcastStreams == other.numberOfSimulcastStreams &&
730 mode == other.mode;
731 if (ret && codecType == kVideoCodecVP8) {
732 ret &= (codecSpecific.VP8 == other.codecSpecific.VP8);
733 }
734
735 for (unsigned char i = 0; i < other.numberOfSimulcastStreams && ret; ++i) {
736 ret &= (simulcastStream[i] == other.simulcastStream[i]);
737 }
738 return ret;
739 }
740
741 bool operator!=(const VideoCodec& other) const {
742 return !(*this == other);
743 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23744};
745
746// Bandwidth over-use detector options. These are used to drive
747// experimentation with bandwidth estimation parameters.
748// See modules/remote_bitrate_estimator/overuse_detector.h
749struct OverUseDetectorOptions {
750 OverUseDetectorOptions()
751 : initial_slope(8.0/512.0),
752 initial_offset(0),
753 initial_e(),
754 initial_process_noise(),
755 initial_avg_noise(0.0),
756 initial_var_noise(50),
757 initial_threshold(25.0) {
758 initial_e[0][0] = 100;
759 initial_e[1][1] = 1e-1;
760 initial_e[0][1] = initial_e[1][0] = 0;
761 initial_process_noise[0] = 1e-10;
762 initial_process_noise[1] = 1e-2;
763 }
764 double initial_slope;
765 double initial_offset;
766 double initial_e[2][2];
767 double initial_process_noise[2];
768 double initial_avg_noise;
769 double initial_var_noise;
770 double initial_threshold;
771};
andrew@webrtc.org5cf83f42013-09-09 17:50:10772
wu@webrtc.orgefeb8ce2013-12-13 00:21:03773// This structure will have the information about when packet is actually
774// received by socket.
775struct PacketTime {
henrike@webrtc.org93ae8212014-04-29 17:50:47776 PacketTime() : timestamp(-1), not_before(-1) {}
777 PacketTime(int64_t timestamp, int64_t not_before)
778 : timestamp(timestamp), not_before(not_before) {
wu@webrtc.orgefeb8ce2013-12-13 00:21:03779 }
780
henrike@webrtc.org93ae8212014-04-29 17:50:47781 int64_t timestamp; // Receive time after socket delivers the data.
782 int64_t not_before; // Earliest possible time the data could have arrived,
783 // indicating the potential error in the |timestamp|
784 // value,in case the system is busy.
785 // For example, the time of the last select() call.
786 // If unknown, this value will be set to zero.
wu@webrtc.orgefeb8ce2013-12-13 00:21:03787};
788
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25789struct RTPHeaderExtension {
790 RTPHeaderExtension()
791 : hasTransmissionTimeOffset(false),
792 transmissionTimeOffset(0),
793 hasAbsoluteSendTime(false),
794 absoluteSendTime(0),
795 hasAudioLevel(false),
796 audioLevel(0) {}
797
798 bool hasTransmissionTimeOffset;
799 int32_t transmissionTimeOffset;
800 bool hasAbsoluteSendTime;
801 uint32_t absoluteSendTime;
802
803 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
804 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
805 bool hasAudioLevel;
806 uint8_t audioLevel;
807};
808
809struct RTPHeader {
810 RTPHeader()
811 : markerBit(false),
812 payloadType(0),
813 sequenceNumber(0),
814 timestamp(0),
815 ssrc(0),
816 numCSRCs(0),
817 paddingLength(0),
818 headerLength(0),
819 payload_type_frequency(0),
820 extension() {
821 memset(&arrOfCSRCs, 0, sizeof(arrOfCSRCs));
822 }
823
824 bool markerBit;
825 uint8_t payloadType;
826 uint16_t sequenceNumber;
827 uint32_t timestamp;
828 uint32_t ssrc;
829 uint8_t numCSRCs;
830 uint32_t arrOfCSRCs[kRtpCsrcSize];
831 uint8_t paddingLength;
832 uint16_t headerLength;
833 int payload_type_frequency;
834 RTPHeaderExtension extension;
835};
836
andrew@webrtc.orgb015cbe2012-10-22 18:19:23837} // namespace webrtc
andrew@webrtc.org5cf83f42013-09-09 17:50:10838
839#endif // WEBRTC_COMMON_TYPES_H_