blob: 43d1bd7060f1ea41caa2b4ee30acfddab7721c19 [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
andrew@webrtc.orgeda189b2013-09-09 17:50:1011#ifndef WEBRTC_COMMON_TYPES_H_
12#define WEBRTC_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
17#include <string>
pbos@webrtc.orgf577ae92014-03-19 08:43:5718#include <vector>
19
andrew@webrtc.orgeda189b2013-09-09 17:50:1020#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:2521
andrew@webrtc.org88b8b0d2012-08-14 00:05:5622#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
niklase@google.com470e71d2011-07-07 08:21:2528#ifdef WEBRTC_EXPORT
andrew@webrtc.org88b8b0d2012-08-14 00:05:5629#define WEBRTC_DLLEXPORT _declspec(dllexport)
niklase@google.com470e71d2011-07-07 08:21:2530#elif WEBRTC_DLL
andrew@webrtc.org88b8b0d2012-08-14 00:05:5631#define WEBRTC_DLLEXPORT _declspec(dllimport)
niklase@google.com470e71d2011-07-07 08:21:2532#else
andrew@webrtc.org88b8b0d2012-08-14 00:05:5633#define WEBRTC_DLLEXPORT
niklase@google.com470e71d2011-07-07 08:21:2534#endif
35
36#ifndef NULL
andrew@webrtc.org88b8b0d2012-08-14 00:05:5637#define NULL 0
niklase@google.com470e71d2011-07-07 08:21:2538#endif
39
henrika@webrtc.orgf75901f2012-01-16 08:45:4240#define RTP_PAYLOAD_NAME_SIZE 32
41
mallinath@webrtc.org0209e562014-03-21 00:41:2842#if defined(WEBRTC_WIN) || defined(WIN32)
andrew@webrtc.orgeda189b2013-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
niklase@google.com470e71d2011-07-07 08:21:2552namespace webrtc {
53
andresp@webrtc.org185bae42013-05-14 08:02:2554class Config;
55
niklase@google.com470e71d2011-07-07 08:21:2556class InStream
57{
58public:
pkasting@chromium.org4591fbd2014-11-20 22:28:1459 virtual int Read(void *buf, size_t len) = 0;
niklase@google.com470e71d2011-07-07 08:21:2560 virtual int Rewind() {return -1;}
61 virtual ~InStream() {}
62protected:
63 InStream() {}
64};
65
66class OutStream
67{
68public:
pkasting@chromium.org4591fbd2014-11-20 22:28:1469 virtual bool Write(const void *buf, size_t len) = 0;
niklase@google.com470e71d2011-07-07 08:21:2570 virtual int Rewind() {return -1;}
71 virtual ~OutStream() {}
72protected:
73 OutStream() {}
74};
75
76enum TraceModule
77{
pbos@webrtc.org5ab75672013-12-16 12:24:4478 kTraceUndefined = 0,
niklase@google.com470e71d2011-07-07 08:21:2579 // not a module, triggered from the engine code
pbos@webrtc.org5ab75672013-12-16 12:24:4480 kTraceVoice = 0x0001,
niklase@google.com470e71d2011-07-07 08:21:2581 // not a module, triggered from the engine code
pbos@webrtc.org5ab75672013-12-16 12:24:4482 kTraceVideo = 0x0002,
niklase@google.com470e71d2011-07-07 08:21:2583 // not a module, triggered from the utility code
pbos@webrtc.org5ab75672013-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.org5ab75672013-12-16 12:24:4498 kTraceRemoteBitrateEstimator = 0x0017,
niklase@google.com470e71d2011-07-07 08:21:2599};
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.org655d8f52012-11-20 07:34:45120 // Non-verbose level used by LS_INFO of logging.h. Do not use directly.
121 kTraceTerseInfo = 0x2000,
122
niklase@google.com470e71d2011-07-07 08:21:25123 kTraceAll = 0xffff
124};
125
126// External Trace API
andrew@webrtc.org23ec30b2012-11-15 05:33:25127class TraceCallback {
128 public:
129 virtual void Print(TraceLevel level, const char* message, int length) = 0;
niklase@google.com470e71d2011-07-07 08:21:25130
andrew@webrtc.org23ec30b2012-11-15 05:33:25131 protected:
132 virtual ~TraceCallback() {}
133 TraceCallback() {}
134};
niklase@google.com470e71d2011-07-07 08:21:25135
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
niklase@google.com470e71d2011-07-07 08:21:25147enum ProcessingTypes
148{
149 kPlaybackPerChannel = 0,
150 kPlaybackAllChannelsMixed,
151 kRecordingPerChannel,
andrew@webrtc.org21ab3ba2012-10-19 17:30:56152 kRecordingAllChannelsMixed,
153 kRecordingPreprocessing
niklase@google.com470e71d2011-07-07 08:21:25154};
155
sprang@webrtc.org71f055f2013-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
niklase@google.com470e71d2011-07-07 08:21:25165// External transport callback interface
166class Transport
167{
168public:
pkasting@chromium.org4591fbd2014-11-20 22:28:14169 virtual int SendPacket(int channel, const void *data, size_t len) = 0;
170 virtual int SendRTCPPacket(int channel, const void *data, size_t len) = 0;
niklase@google.com470e71d2011-07-07 08:21:25171
172protected:
173 virtual ~Transport() {}
174 Transport() {}
175};
176
sprang@webrtc.orgdc50aae2013-11-20 16:47:07177// Statistics for an RTCP channel
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07178struct RtcpStatistics {
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07179 RtcpStatistics()
180 : fraction_lost(0),
181 cumulative_lost(0),
182 extended_max_sequence_number(0),
sprang@webrtc.orga6ad6e52013-12-05 09:48:44183 jitter(0) {}
sprang@webrtc.orgfe5d36b2013-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.orgfe5d36b2013-10-28 09:21:07189};
190
sprang@webrtc.orgdc50aae2013-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.org8098e072014-02-19 11:59:02200// Statistics for RTCP packet types.
201struct RtcpPacketTypeCounter {
202 RtcpPacketTypeCounter()
203 : nack_packets(0),
204 fir_packets(0),
asapersson@webrtc.org2dd31342014-10-29 12:42:30205 pli_packets(0),
206 nack_requests(0),
207 unique_nack_requests(0) {}
asapersson@webrtc.org8098e072014-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.org2dd31342014-10-29 12:42:30213 nack_requests += other.nack_requests;
214 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.org8098e072014-02-19 11:59:02215 }
216
asapersson@webrtc.org2dd31342014-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.org8098e072014-02-19 11:59:02230};
231
asapersson@webrtc.org97d04892014-12-09 09:47:53232// Data usage statistics for a (rtp) stream.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07233struct StreamDataCounters {
sprang@webrtc.orgdc50aae2013-11-20 16:47:07234 StreamDataCounters()
235 : bytes(0),
sprang@webrtc.orgebad7652013-12-05 14:29:02236 header_bytes(0),
sprang@webrtc.orgdc50aae2013-11-20 16:47:07237 padding_bytes(0),
238 packets(0),
asapersson@webrtc.org97d04892014-12-09 09:47:53239 retransmitted_bytes(0),
240 retransmitted_header_bytes(0),
241 retransmitted_padding_bytes(0),
sprang@webrtc.orgdc50aae2013-11-20 16:47:07242 retransmitted_packets(0),
243 fec_packets(0) {}
244
asapersson@webrtc.orgd952c402014-11-27 07:38:56245 void Add(const StreamDataCounters& other) {
246 bytes += other.bytes;
247 header_bytes += other.header_bytes;
248 padding_bytes += other.padding_bytes;
249 packets += other.packets;
asapersson@webrtc.org97d04892014-12-09 09:47:53250 retransmitted_bytes += other.retransmitted_bytes;
251 retransmitted_header_bytes += other.retransmitted_header_bytes;
252 retransmitted_padding_bytes += other.retransmitted_padding_bytes;
asapersson@webrtc.orgd952c402014-11-27 07:38:56253 retransmitted_packets += other.retransmitted_packets;
254 fec_packets += other.fec_packets;
255 }
256
asapersson@webrtc.org97d04892014-12-09 09:47:53257 size_t TotalBytes() const {
258 return bytes + header_bytes + padding_bytes;
259 }
260
261 size_t RetransmittedBytes() const {
262 return retransmitted_bytes + retransmitted_header_bytes +
263 retransmitted_padding_bytes;
264 }
265
266 size_t MediaPayloadBytes() const {
267 return bytes - retransmitted_bytes;
268 }
269
pbos@webrtc.org72491b92014-07-10 16:24:54270 // TODO(pbos): Rename bytes -> media_bytes.
pkasting@chromium.org4591fbd2014-11-20 22:28:14271 size_t bytes; // Payload bytes, excluding RTP headers and padding.
272 size_t header_bytes; // Number of bytes used by RTP headers.
273 size_t padding_bytes; // Number of padding bytes.
sprang@webrtc.orgebad7652013-12-05 14:29:02274 uint32_t packets; // Number of packets.
asapersson@webrtc.org97d04892014-12-09 09:47:53275 size_t retransmitted_bytes; // Number of retransmitted payload bytes.
276 size_t retransmitted_header_bytes; // Retransmitted bytes used by RTP header.
277 size_t retransmitted_padding_bytes; // Retransmitted padding bytes.
sprang@webrtc.orgebad7652013-12-05 14:29:02278 uint32_t retransmitted_packets; // Number of retransmitted packets.
279 uint32_t fec_packets; // Number of redundancy packets.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07280};
281
282// Callback, called whenever byte/packet counts have been updated.
283class StreamDataCountersCallback {
284 public:
285 virtual ~StreamDataCountersCallback() {}
286
287 virtual void DataCountersUpdated(const StreamDataCounters& counters,
288 uint32_t ssrc) = 0;
289};
290
291// Rate statistics for a stream
292struct BitrateStatistics {
sprang@webrtc.org6811b6e2013-12-13 09:46:59293 BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
sprang@webrtc.orgdc50aae2013-11-20 16:47:07294
sprang@webrtc.org6811b6e2013-12-13 09:46:59295 uint32_t bitrate_bps; // Bitrate in bits per second.
296 uint32_t packet_rate; // Packet rate in packets per second.
297 uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07298};
299
300// Callback, used to notify an observer whenever new rates have been estimated.
301class BitrateStatisticsObserver {
302 public:
303 virtual ~BitrateStatisticsObserver() {}
304
stefan@webrtc.org0bae1fa2014-11-05 14:05:29305 virtual void Notify(const BitrateStatistics& total_stats,
306 const BitrateStatistics& retransmit_stats,
307 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07308};
309
310// Callback, used to notify an observer whenever frame counts have been updated
311class FrameCountObserver {
312 public:
sprang@webrtc.org72964bd2013-11-21 09:09:54313 virtual ~FrameCountObserver() {}
sprang@webrtc.org71f055f2013-12-04 15:09:27314 virtual void FrameCountUpdated(FrameType frame_type,
315 uint32_t frame_count,
316 const unsigned int ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07317};
318
stefan@webrtc.org168f23f2014-07-11 13:44:02319// Callback, used to notify an observer whenever the send-side delay is updated.
320class SendSideDelayObserver {
321 public:
322 virtual ~SendSideDelayObserver() {}
323 virtual void SendSideDelayUpdated(int avg_delay_ms,
324 int max_delay_ms,
325 uint32_t ssrc) = 0;
326};
327
niklase@google.com470e71d2011-07-07 08:21:25328// ==================================================================
329// Voice specific types
330// ==================================================================
331
332// Each codec supported can be described by this structure.
mallinath@webrtc.org0209e562014-03-21 00:41:28333struct CodecInst {
334 int pltype;
335 char plname[RTP_PAYLOAD_NAME_SIZE];
336 int plfreq;
337 int pacsize;
338 int channels;
339 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
340
341 bool operator==(const CodecInst& other) const {
342 return pltype == other.pltype &&
343 (STR_CASE_CMP(plname, other.plname) == 0) &&
344 plfreq == other.plfreq &&
345 pacsize == other.pacsize &&
346 channels == other.channels &&
347 rate == other.rate;
348 }
349
350 bool operator!=(const CodecInst& other) const {
351 return !(*this == other);
352 }
niklase@google.com470e71d2011-07-07 08:21:25353};
354
niklase@google.com470e71d2011-07-07 08:21:25355// RTP
356enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
357
358enum RTPDirections
359{
360 kRtpIncoming = 0,
361 kRtpOutgoing
362};
363
364enum PayloadFrequencies
365{
366 kFreq8000Hz = 8000,
367 kFreq16000Hz = 16000,
368 kFreq32000Hz = 32000
369};
370
371enum VadModes // degree of bandwidth reduction
372{
373 kVadConventional = 0, // lowest reduction
374 kVadAggressiveLow,
375 kVadAggressiveMid,
376 kVadAggressiveHigh // highest reduction
377};
378
379struct NetworkStatistics // NETEQ statistics
380{
381 // current jitter buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11382 uint16_t currentBufferSize;
niklase@google.com470e71d2011-07-07 08:21:25383 // preferred (optimal) buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11384 uint16_t preferredBufferSize;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55385 // adding extra delay due to "peaky jitter"
386 bool jitterPeaksFound;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45387 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11388 uint16_t currentPacketLossRate;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45389 // Late loss rate; fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11390 uint16_t currentDiscardRate;
niklase@google.com470e71d2011-07-07 08:21:25391 // fraction (of original stream) of synthesized speech inserted through
392 // expansion (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11393 uint16_t currentExpandRate;
niklase@google.com470e71d2011-07-07 08:21:25394 // fraction of synthesized speech inserted through pre-emptive expansion
395 // (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11396 uint16_t currentPreemptiveRate;
niklase@google.com470e71d2011-07-07 08:21:25397 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11398 uint16_t currentAccelerateRate;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55399 // clock-drift in parts-per-million (negative or positive)
400 int32_t clockDriftPPM;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05401 // average packet waiting time in the jitter buffer (ms)
402 int meanWaitingTimeMs;
403 // median packet waiting time in the jitter buffer (ms)
404 int medianWaitingTimeMs;
henrik.lundin@webrtc.org053c7992012-01-12 14:16:44405 // min packet waiting time in the jitter buffer (ms)
406 int minWaitingTimeMs;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05407 // max packet waiting time in the jitter buffer (ms)
408 int maxWaitingTimeMs;
roosa@google.comb8ba4d82012-12-14 00:06:18409 // added samples in off mode due to packet loss
410 int addedSamples;
niklase@google.com470e71d2011-07-07 08:21:25411};
412
wu@webrtc.org24301a62013-12-13 19:17:43413// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
414struct AudioDecodingCallStats {
415 AudioDecodingCallStats()
416 : calls_to_silence_generator(0),
417 calls_to_neteq(0),
418 decoded_normal(0),
419 decoded_plc(0),
420 decoded_cng(0),
421 decoded_plc_cng(0) {}
422
423 int calls_to_silence_generator; // Number of calls where silence generated,
424 // and NetEq was disengaged from decoding.
425 int calls_to_neteq; // Number of calls to NetEq.
426 int decoded_normal; // Number of calls where audio RTP packet decoded.
427 int decoded_plc; // Number of calls resulted in PLC.
428 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
429 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
430};
431
niklase@google.com470e71d2011-07-07 08:21:25432typedef struct
433{
434 int min; // minumum
435 int max; // maximum
436 int average; // average
437} StatVal;
438
439typedef struct // All levels are reported in dBm0
440{
441 StatVal speech_rx; // long-term speech levels on receiving side
442 StatVal speech_tx; // long-term speech levels on transmitting side
443 StatVal noise_rx; // long-term noise/silence levels on receiving side
444 StatVal noise_tx; // long-term noise/silence levels on transmitting side
445} LevelStatistics;
446
447typedef struct // All levels are reported in dB
448{
449 StatVal erl; // Echo Return Loss
450 StatVal erle; // Echo Return Loss Enhancement
451 StatVal rerl; // RERL = ERL + ERLE
452 // Echo suppression inside EC at the point just before its NLP
453 StatVal a_nlp;
454} EchoStatistics;
455
niklase@google.com470e71d2011-07-07 08:21:25456enum NsModes // type of Noise Suppression
457{
458 kNsUnchanged = 0, // previously set mode
459 kNsDefault, // platform default
460 kNsConference, // conferencing default
461 kNsLowSuppression, // lowest suppression
462 kNsModerateSuppression,
463 kNsHighSuppression,
464 kNsVeryHighSuppression, // highest suppression
465};
466
467enum AgcModes // type of Automatic Gain Control
468{
469 kAgcUnchanged = 0, // previously set mode
470 kAgcDefault, // platform default
471 // adaptive mode for use when analog volume control exists (e.g. for
472 // PC softphone)
473 kAgcAdaptiveAnalog,
474 // scaling takes place in the digital domain (e.g. for conference servers
475 // and embedded devices)
476 kAgcAdaptiveDigital,
andrew@webrtc.org80124742012-03-08 17:54:24477 // can be used on embedded devices where the capture signal level
niklase@google.com470e71d2011-07-07 08:21:25478 // is predictable
479 kAgcFixedDigital
480};
481
482// EC modes
483enum EcModes // type of Echo Control
484{
485 kEcUnchanged = 0, // previously set mode
486 kEcDefault, // platform default
487 kEcConference, // conferencing default (aggressive AEC)
488 kEcAec, // Acoustic Echo Cancellation
489 kEcAecm, // AEC mobile
490};
491
492// AECM modes
493enum AecmModes // mode of AECM
494{
495 kAecmQuietEarpieceOrHeadset = 0,
496 // Quiet earpiece or headset use
497 kAecmEarpiece, // most earpiece use
498 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
499 kAecmSpeakerphone, // most speakerphone use (default)
500 kAecmLoudSpeakerphone // Loud speakerphone
501};
502
503// AGC configuration
504typedef struct
505{
506 unsigned short targetLeveldBOv;
507 unsigned short digitalCompressionGaindB;
508 bool limiterEnable;
509} AgcConfig; // AGC configuration parameters
510
511enum StereoChannel
512{
513 kStereoLeft = 0,
514 kStereoRight,
515 kStereoBoth
516};
517
518// Audio device layers
519enum AudioLayers
520{
521 kAudioPlatformDefault = 0,
522 kAudioWindowsWave = 1,
523 kAudioWindowsCore = 2,
524 kAudioLinuxAlsa = 3,
525 kAudioLinuxPulse = 4
526};
527
henrika@webrtc.org66803482014-04-17 10:45:01528// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25529enum NetEqModes // NetEQ playout configurations
530{
531 // Optimized trade-off between low delay and jitter robustness for two-way
532 // communication.
533 kNetEqDefault = 0,
534 // Improved jitter robustness at the cost of increased delay. Can be
535 // used in one-way communication.
536 kNetEqStreaming = 1,
537 // Optimzed for decodability of fax signals rather than for perceived audio
538 // quality.
539 kNetEqFax = 2,
roosa@google.comb7186192012-12-12 21:59:14540 // Minimal buffer management. Inserts zeros for lost packets and during
541 // buffer increases.
542 kNetEqOff = 3,
niklase@google.com470e71d2011-07-07 08:21:25543};
544
henrika@webrtc.org66803482014-04-17 10:45:01545// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25546enum OnHoldModes // On Hold direction
547{
548 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
549 kHoldSendOnly, // Put only sending in on-hold state.
550 kHoldPlayOnly // Put only playing in on-hold state.
551};
552
henrika@webrtc.org66803482014-04-17 10:45:01553// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25554enum AmrMode
555{
556 kRfc3267BwEfficient = 0,
557 kRfc3267OctetAligned = 1,
558 kRfc3267FileStorage = 2,
559};
560
561// ==================================================================
562// Video specific types
563// ==================================================================
564
565// Raw video types
566enum RawVideoType
567{
568 kVideoI420 = 0,
569 kVideoYV12 = 1,
570 kVideoYUY2 = 2,
571 kVideoUYVY = 3,
572 kVideoIYUV = 4,
573 kVideoARGB = 5,
574 kVideoRGB24 = 6,
575 kVideoRGB565 = 7,
576 kVideoARGB4444 = 8,
577 kVideoARGB1555 = 9,
578 kVideoMJPEG = 10,
579 kVideoNV12 = 11,
580 kVideoNV21 = 12,
mikhal@webrtc.orgc00f91d2012-01-03 18:49:15581 kVideoBGRA = 13,
niklase@google.com470e71d2011-07-07 08:21:25582 kVideoUnknown = 99
583};
584
585// Video codec
586enum { kConfigParameterSize = 128};
587enum { kPayloadNameSize = 32};
pwestin@webrtc.org1da1ce02011-10-13 15:19:55588enum { kMaxSimulcastStreams = 4};
pwestin@webrtc.orgdb221d22011-12-02 11:31:08589enum { kMaxTemporalStreams = 4};
niklase@google.com470e71d2011-07-07 08:21:25590
niklase@google.com470e71d2011-07-07 08:21:25591enum VideoCodecComplexity
592{
593 kComplexityNormal = 0,
594 kComplexityHigh = 1,
595 kComplexityHigher = 2,
596 kComplexityMax = 3
597};
598
599enum VideoCodecProfile
600{
601 kProfileBase = 0x00,
602 kProfileMain = 0x01
603};
604
stefan@webrtc.orgefd0a482011-12-29 10:12:35605enum VP8ResilienceMode {
606 kResilienceOff, // The stream produced by the encoder requires a
607 // recovery frame (typically a key frame) to be
608 // decodable after a packet loss.
609 kResilientStream, // A stream produced by the encoder is resilient to
610 // packet losses, but packets within a frame subsequent
611 // to a loss can't be decoded.
612 kResilientFrames // Same as kResilientStream but with added resilience
613 // within a frame.
614};
615
niklase@google.com470e71d2011-07-07 08:21:25616// VP8 specific
mallinath@webrtc.org0209e562014-03-21 00:41:28617struct VideoCodecVP8 {
618 bool pictureLossIndicationOn;
619 bool feedbackModeOn;
620 VideoCodecComplexity complexity;
621 VP8ResilienceMode resilience;
622 unsigned char numberOfTemporalLayers;
623 bool denoisingOn;
624 bool errorConcealmentOn;
625 bool automaticResizeOn;
626 bool frameDroppingOn;
627 int keyFrameInterval;
628
629 bool operator==(const VideoCodecVP8& other) const {
630 return pictureLossIndicationOn == other.pictureLossIndicationOn &&
631 feedbackModeOn == other.feedbackModeOn &&
632 complexity == other.complexity &&
633 resilience == other.resilience &&
634 numberOfTemporalLayers == other.numberOfTemporalLayers &&
635 denoisingOn == other.denoisingOn &&
636 errorConcealmentOn == other.errorConcealmentOn &&
637 automaticResizeOn == other.automaticResizeOn &&
638 frameDroppingOn == other.frameDroppingOn &&
639 keyFrameInterval == other.keyFrameInterval;
640 }
641
642 bool operator!=(const VideoCodecVP8& other) const {
643 return !(*this == other);
644 }
niklase@google.com470e71d2011-07-07 08:21:25645};
646
marpan@webrtc.org5b883172014-11-01 06:10:48647// VP9 specific
648struct VideoCodecVP9 {
649 VideoCodecComplexity complexity;
650 int resilience;
651 unsigned char numberOfTemporalLayers;
652 bool denoisingOn;
653 bool frameDroppingOn;
654 int keyFrameInterval;
655 bool adaptiveQpMode;
656};
657
stefan@webrtc.orgb9f54532014-07-04 12:42:07658// H264 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48659struct VideoCodecH264 {
660 VideoCodecProfile profile;
661 bool frameDroppingOn;
662 int keyFrameInterval;
663 // These are NULL/0 if not externally negotiated.
664 const uint8_t* spsData;
665 size_t spsLen;
666 const uint8_t* ppsData;
667 size_t ppsLen;
stefan@webrtc.orgb9f54532014-07-04 12:42:07668};
669
niklase@google.com470e71d2011-07-07 08:21:25670// Video codec types
marpan@webrtc.org5b883172014-11-01 06:10:48671enum VideoCodecType {
672 kVideoCodecVP8,
673 kVideoCodecVP9,
674 kVideoCodecH264,
675 kVideoCodecI420,
676 kVideoCodecRED,
677 kVideoCodecULPFEC,
678 kVideoCodecGeneric,
679 kVideoCodecUnknown
niklase@google.com470e71d2011-07-07 08:21:25680};
681
marpan@webrtc.org5b883172014-11-01 06:10:48682union VideoCodecUnion {
683 VideoCodecVP8 VP8;
684 VideoCodecVP9 VP9;
685 VideoCodecH264 H264;
niklase@google.com470e71d2011-07-07 08:21:25686};
687
phoglund@webrtc.org8bfee842012-02-17 09:32:48688
689// Simulcast is when the same stream is encoded multiple times with different
690// settings such as resolution.
mallinath@webrtc.org0209e562014-03-21 00:41:28691struct SimulcastStream {
692 unsigned short width;
693 unsigned short height;
694 unsigned char numberOfTemporalLayers;
695 unsigned int maxBitrate; // kilobits/sec.
696 unsigned int targetBitrate; // kilobits/sec.
697 unsigned int minBitrate; // kilobits/sec.
698 unsigned int qpMax; // minimum quality
699
700 bool operator==(const SimulcastStream& other) const {
701 return width == other.width &&
702 height == other.height &&
703 numberOfTemporalLayers == other.numberOfTemporalLayers &&
704 maxBitrate == other.maxBitrate &&
705 targetBitrate == other.targetBitrate &&
706 minBitrate == other.minBitrate &&
707 qpMax == other.qpMax;
708 }
709
710 bool operator!=(const SimulcastStream& other) const {
711 return !(*this == other);
712 }
pwestin@webrtc.org1da1ce02011-10-13 15:19:55713};
714
stefan@webrtc.orgeb917922013-02-18 14:40:18715enum VideoCodecMode {
716 kRealtimeVideo,
717 kScreensharing
718};
719
niklase@google.com470e71d2011-07-07 08:21:25720// Common video codec properties
mallinath@webrtc.org0209e562014-03-21 00:41:28721struct VideoCodec {
722 VideoCodecType codecType;
723 char plName[kPayloadNameSize];
724 unsigned char plType;
niklase@google.com470e71d2011-07-07 08:21:25725
mallinath@webrtc.org0209e562014-03-21 00:41:28726 unsigned short width;
727 unsigned short height;
niklase@google.com470e71d2011-07-07 08:21:25728
mallinath@webrtc.org0209e562014-03-21 00:41:28729 unsigned int startBitrate; // kilobits/sec.
730 unsigned int maxBitrate; // kilobits/sec.
731 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org3c412b22014-03-24 12:36:52732 unsigned int targetBitrate; // kilobits/sec.
733
mallinath@webrtc.org0209e562014-03-21 00:41:28734 unsigned char maxFramerate;
niklase@google.com470e71d2011-07-07 08:21:25735
mallinath@webrtc.org0209e562014-03-21 00:41:28736 VideoCodecUnion codecSpecific;
niklase@google.com470e71d2011-07-07 08:21:25737
mallinath@webrtc.org0209e562014-03-21 00:41:28738 unsigned int qpMax;
739 unsigned char numberOfSimulcastStreams;
740 SimulcastStream simulcastStream[kMaxSimulcastStreams];
stefan@webrtc.orgeb917922013-02-18 14:40:18741
mallinath@webrtc.org0209e562014-03-21 00:41:28742 VideoCodecMode mode;
andresp@webrtc.org185bae42013-05-14 08:02:25743
mallinath@webrtc.org0209e562014-03-21 00:41:28744 // When using an external encoder/decoder this allows to pass
745 // extra options without requiring webrtc to be aware of them.
746 Config* extra_options;
mallinath@webrtc.org0209e562014-03-21 00:41:28747
mallinath@webrtc.org0209e562014-03-21 00:41:28748 bool operator==(const VideoCodec& other) const {
749 bool ret = codecType == other.codecType &&
750 (STR_CASE_CMP(plName, other.plName) == 0) &&
751 plType == other.plType &&
752 width == other.width &&
753 height == other.height &&
754 startBitrate == other.startBitrate &&
755 maxBitrate == other.maxBitrate &&
756 minBitrate == other.minBitrate &&
pbos@webrtc.org3c412b22014-03-24 12:36:52757 targetBitrate == other.targetBitrate &&
mallinath@webrtc.org0209e562014-03-21 00:41:28758 maxFramerate == other.maxFramerate &&
759 qpMax == other.qpMax &&
760 numberOfSimulcastStreams == other.numberOfSimulcastStreams &&
761 mode == other.mode;
762 if (ret && codecType == kVideoCodecVP8) {
763 ret &= (codecSpecific.VP8 == other.codecSpecific.VP8);
764 }
765
766 for (unsigned char i = 0; i < other.numberOfSimulcastStreams && ret; ++i) {
767 ret &= (simulcastStream[i] == other.simulcastStream[i]);
768 }
769 return ret;
770 }
771
772 bool operator!=(const VideoCodec& other) const {
773 return !(*this == other);
774 }
niklase@google.com470e71d2011-07-07 08:21:25775};
astor@webrtc.orgbd7aeba2012-06-26 10:47:04776
777// Bandwidth over-use detector options. These are used to drive
778// experimentation with bandwidth estimation parameters.
779// See modules/remote_bitrate_estimator/overuse_detector.h
780struct OverUseDetectorOptions {
781 OverUseDetectorOptions()
782 : initial_slope(8.0/512.0),
783 initial_offset(0),
784 initial_e(),
785 initial_process_noise(),
786 initial_avg_noise(0.0),
stefan@webrtc.orgc58be0d2012-09-11 14:11:58787 initial_var_noise(50),
astor@webrtc.orgbd7aeba2012-06-26 10:47:04788 initial_threshold(25.0) {
789 initial_e[0][0] = 100;
790 initial_e[1][1] = 1e-1;
791 initial_e[0][1] = initial_e[1][0] = 0;
792 initial_process_noise[0] = 1e-10;
793 initial_process_noise[1] = 1e-2;
794 }
795 double initial_slope;
796 double initial_offset;
797 double initial_e[2][2];
798 double initial_process_noise[2];
799 double initial_avg_noise;
800 double initial_var_noise;
801 double initial_threshold;
802};
andrew@webrtc.orgeda189b2013-09-09 17:50:10803
wu@webrtc.orga9890802013-12-13 00:21:03804// This structure will have the information about when packet is actually
805// received by socket.
806struct PacketTime {
henrike@webrtc.org82d3cb62014-04-29 17:50:47807 PacketTime() : timestamp(-1), not_before(-1) {}
808 PacketTime(int64_t timestamp, int64_t not_before)
809 : timestamp(timestamp), not_before(not_before) {
wu@webrtc.orga9890802013-12-13 00:21:03810 }
811
henrike@webrtc.org82d3cb62014-04-29 17:50:47812 int64_t timestamp; // Receive time after socket delivers the data.
813 int64_t not_before; // Earliest possible time the data could have arrived,
814 // indicating the potential error in the |timestamp|
815 // value,in case the system is busy.
816 // For example, the time of the last select() call.
817 // If unknown, this value will be set to zero.
wu@webrtc.orga9890802013-12-13 00:21:03818};
819
solenberg@webrtc.orgb1f50102014-03-24 10:38:25820struct RTPHeaderExtension {
821 RTPHeaderExtension()
822 : hasTransmissionTimeOffset(false),
823 transmissionTimeOffset(0),
824 hasAbsoluteSendTime(false),
825 absoluteSendTime(0),
826 hasAudioLevel(false),
827 audioLevel(0) {}
828
829 bool hasTransmissionTimeOffset;
830 int32_t transmissionTimeOffset;
831 bool hasAbsoluteSendTime;
832 uint32_t absoluteSendTime;
833
834 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
835 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
836 bool hasAudioLevel;
837 uint8_t audioLevel;
838};
839
840struct RTPHeader {
841 RTPHeader()
842 : markerBit(false),
843 payloadType(0),
844 sequenceNumber(0),
845 timestamp(0),
846 ssrc(0),
847 numCSRCs(0),
848 paddingLength(0),
849 headerLength(0),
850 payload_type_frequency(0),
851 extension() {
852 memset(&arrOfCSRCs, 0, sizeof(arrOfCSRCs));
853 }
854
855 bool markerBit;
856 uint8_t payloadType;
857 uint16_t sequenceNumber;
858 uint32_t timestamp;
859 uint32_t ssrc;
860 uint8_t numCSRCs;
861 uint32_t arrOfCSRCs[kRtpCsrcSize];
pkasting@chromium.org4591fbd2014-11-20 22:28:14862 size_t paddingLength;
863 size_t headerLength;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25864 int payload_type_frequency;
865 RTPHeaderExtension extension;
866};
867
niklase@google.com470e71d2011-07-07 08:21:25868} // namespace webrtc
andrew@webrtc.orgeda189b2013-09-09 17:50:10869
870#endif // WEBRTC_COMMON_TYPES_H_