blob: e647aadd346973578a5cfffd0bd0915a7d28bd7c [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:
pkasting@chromium.org0ab923a2014-11-20 22:28:1459 virtual int Read(void *buf, size_t len) = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2360 virtual int Rewind() {return -1;}
61 virtual ~InStream() {}
62protected:
63 InStream() {}
64};
65
66class OutStream
67{
68public:
pkasting@chromium.org0ab923a2014-11-20 22:28:1469 virtual bool Write(const void *buf, size_t len) = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2370 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:
pkasting@chromium.org0ab923a2014-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;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23171
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()
asapersson@webrtc.orgc76c5532014-12-16 12:03:11203 : first_packet_time_ms(-1),
204 nack_packets(0),
asapersson@webrtc.org4a155602014-02-19 11:59:02205 fir_packets(0),
asapersson@webrtc.org2ba45ee2014-10-29 12:42:30206 pli_packets(0),
207 nack_requests(0),
208 unique_nack_requests(0) {}
asapersson@webrtc.org4a155602014-02-19 11:59:02209
210 void Add(const RtcpPacketTypeCounter& other) {
211 nack_packets += other.nack_packets;
212 fir_packets += other.fir_packets;
213 pli_packets += other.pli_packets;
asapersson@webrtc.org2ba45ee2014-10-29 12:42:30214 nack_requests += other.nack_requests;
215 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.orgc76c5532014-12-16 12:03:11216 if (other.first_packet_time_ms != -1 &&
217 (other.first_packet_time_ms < first_packet_time_ms ||
218 first_packet_time_ms == -1)) {
219 // Use oldest time.
220 first_packet_time_ms = other.first_packet_time_ms;
221 }
222 }
223
224 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
225 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
asapersson@webrtc.org4a155602014-02-19 11:59:02226 }
227
asapersson@webrtc.org2ba45ee2014-10-29 12:42:30228 int UniqueNackRequestsInPercent() const {
229 if (nack_requests == 0) {
230 return 0;
231 }
232 return static_cast<int>(
233 (unique_nack_requests * 100.0f / nack_requests) + 0.5f);
234 }
235
asapersson@webrtc.orgc76c5532014-12-16 12:03:11236 int64_t first_packet_time_ms; // Time when first packet is sent/received.
237 uint32_t nack_packets; // Number of RTCP NACK packets.
238 uint32_t fir_packets; // Number of RTCP FIR packets.
239 uint32_t pli_packets; // Number of RTCP PLI packets.
240 uint32_t nack_requests; // Number of NACKed RTP packets.
asapersson@webrtc.org2ba45ee2014-10-29 12:42:30241 uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
asapersson@webrtc.org4a155602014-02-19 11:59:02242};
243
asapersson@webrtc.org96568c22014-12-09 09:47:53244// Data usage statistics for a (rtp) stream.
sprang@webrtc.org46736742013-11-20 16:47:07245struct StreamDataCounters {
sprang@webrtc.org46736742013-11-20 16:47:07246 StreamDataCounters()
asapersson@webrtc.orgc76c5532014-12-16 12:03:11247 : first_packet_time_ms(-1),
248 bytes(0),
249 header_bytes(0),
250 padding_bytes(0),
251 packets(0),
252 retransmitted_bytes(0),
253 retransmitted_header_bytes(0),
254 retransmitted_padding_bytes(0),
255 retransmitted_packets(0),
256 fec_packets(0) {}
sprang@webrtc.org46736742013-11-20 16:47:07257
asapersson@webrtc.org2755e822014-11-27 07:38:56258 void Add(const StreamDataCounters& other) {
259 bytes += other.bytes;
260 header_bytes += other.header_bytes;
261 padding_bytes += other.padding_bytes;
262 packets += other.packets;
asapersson@webrtc.org96568c22014-12-09 09:47:53263 retransmitted_bytes += other.retransmitted_bytes;
264 retransmitted_header_bytes += other.retransmitted_header_bytes;
265 retransmitted_padding_bytes += other.retransmitted_padding_bytes;
asapersson@webrtc.org2755e822014-11-27 07:38:56266 retransmitted_packets += other.retransmitted_packets;
267 fec_packets += other.fec_packets;
asapersson@webrtc.orgc76c5532014-12-16 12:03:11268 if (other.first_packet_time_ms != -1 &&
269 (other.first_packet_time_ms < first_packet_time_ms ||
270 first_packet_time_ms == -1)) {
271 // Use oldest time.
272 first_packet_time_ms = other.first_packet_time_ms;
273 }
274 }
275
276 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
277 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
asapersson@webrtc.org2755e822014-11-27 07:38:56278 }
279
asapersson@webrtc.org96568c22014-12-09 09:47:53280 size_t TotalBytes() const {
281 return bytes + header_bytes + padding_bytes;
282 }
283
284 size_t RetransmittedBytes() const {
285 return retransmitted_bytes + retransmitted_header_bytes +
286 retransmitted_padding_bytes;
287 }
288
289 size_t MediaPayloadBytes() const {
290 return bytes - retransmitted_bytes;
291 }
292
pbos@webrtc.org9aa34972014-07-10 16:24:54293 // TODO(pbos): Rename bytes -> media_bytes.
asapersson@webrtc.orgc76c5532014-12-16 12:03:11294 int64_t first_packet_time_ms; // Time when first packet is sent/received.
pkasting@chromium.org0ab923a2014-11-20 22:28:14295 size_t bytes; // Payload bytes, excluding RTP headers and padding.
296 size_t header_bytes; // Number of bytes used by RTP headers.
297 size_t padding_bytes; // Number of padding bytes.
sprang@webrtc.orgb1139812013-12-05 14:29:02298 uint32_t packets; // Number of packets.
asapersson@webrtc.org96568c22014-12-09 09:47:53299 size_t retransmitted_bytes; // Number of retransmitted payload bytes.
300 size_t retransmitted_header_bytes; // Retransmitted bytes used by RTP header.
301 size_t retransmitted_padding_bytes; // Retransmitted padding bytes.
sprang@webrtc.orgb1139812013-12-05 14:29:02302 uint32_t retransmitted_packets; // Number of retransmitted packets.
303 uint32_t fec_packets; // Number of redundancy packets.
sprang@webrtc.org46736742013-11-20 16:47:07304};
305
306// Callback, called whenever byte/packet counts have been updated.
307class StreamDataCountersCallback {
308 public:
309 virtual ~StreamDataCountersCallback() {}
310
311 virtual void DataCountersUpdated(const StreamDataCounters& counters,
312 uint32_t ssrc) = 0;
313};
314
asapersson@webrtc.orgc76c5532014-12-16 12:03:11315// Rate statistics for a stream.
sprang@webrtc.org46736742013-11-20 16:47:07316struct BitrateStatistics {
sprang@webrtc.orgb70db6d2013-12-13 09:46:59317 BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
sprang@webrtc.org46736742013-11-20 16:47:07318
sprang@webrtc.orgb70db6d2013-12-13 09:46:59319 uint32_t bitrate_bps; // Bitrate in bits per second.
320 uint32_t packet_rate; // Packet rate in packets per second.
321 uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation.
sprang@webrtc.org46736742013-11-20 16:47:07322};
323
324// Callback, used to notify an observer whenever new rates have been estimated.
325class BitrateStatisticsObserver {
326 public:
327 virtual ~BitrateStatisticsObserver() {}
328
stefan@webrtc.org52322672014-11-05 14:05:29329 virtual void Notify(const BitrateStatistics& total_stats,
330 const BitrateStatistics& retransmit_stats,
331 uint32_t ssrc) = 0;
sprang@webrtc.org46736742013-11-20 16:47:07332};
333
asapersson@webrtc.orgc76c5532014-12-16 12:03:11334// Callback, used to notify an observer whenever frame counts have been updated.
sprang@webrtc.org46736742013-11-20 16:47:07335class FrameCountObserver {
336 public:
sprang@webrtc.org21dc10d2013-11-21 09:09:54337 virtual ~FrameCountObserver() {}
sprang@webrtc.org5fdd10a2013-12-04 15:09:27338 virtual void FrameCountUpdated(FrameType frame_type,
339 uint32_t frame_count,
340 const unsigned int ssrc) = 0;
sprang@webrtc.org46736742013-11-20 16:47:07341};
342
stefan@webrtc.org55b0f2e2014-07-11 13:44:02343// Callback, used to notify an observer whenever the send-side delay is updated.
344class SendSideDelayObserver {
345 public:
346 virtual ~SendSideDelayObserver() {}
347 virtual void SendSideDelayUpdated(int avg_delay_ms,
348 int max_delay_ms,
349 uint32_t ssrc) = 0;
350};
351
andrew@webrtc.orgb015cbe2012-10-22 18:19:23352// ==================================================================
353// Voice specific types
354// ==================================================================
355
356// Each codec supported can be described by this structure.
mallinath@webrtc.org18c29452014-03-21 00:41:28357struct CodecInst {
358 int pltype;
359 char plname[RTP_PAYLOAD_NAME_SIZE];
360 int plfreq;
361 int pacsize;
362 int channels;
363 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
364
365 bool operator==(const CodecInst& other) const {
366 return pltype == other.pltype &&
367 (STR_CASE_CMP(plname, other.plname) == 0) &&
368 plfreq == other.plfreq &&
369 pacsize == other.pacsize &&
370 channels == other.channels &&
371 rate == other.rate;
372 }
373
374 bool operator!=(const CodecInst& other) const {
375 return !(*this == other);
376 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23377};
378
andrew@webrtc.orgb015cbe2012-10-22 18:19:23379// RTP
380enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
381
382enum RTPDirections
383{
384 kRtpIncoming = 0,
385 kRtpOutgoing
386};
387
388enum PayloadFrequencies
389{
390 kFreq8000Hz = 8000,
391 kFreq16000Hz = 16000,
392 kFreq32000Hz = 32000
393};
394
395enum VadModes // degree of bandwidth reduction
396{
397 kVadConventional = 0, // lowest reduction
398 kVadAggressiveLow,
399 kVadAggressiveMid,
400 kVadAggressiveHigh // highest reduction
401};
402
403struct NetworkStatistics // NETEQ statistics
404{
405 // current jitter buffer size in ms
pbos@webrtc.org52b2ee52013-05-03 12:02:11406 uint16_t currentBufferSize;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23407 // preferred (optimal) buffer size in ms
pbos@webrtc.org52b2ee52013-05-03 12:02:11408 uint16_t preferredBufferSize;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23409 // adding extra delay due to "peaky jitter"
410 bool jitterPeaksFound;
henrik.lundin@webrtc.org6e7480a2014-10-09 12:58:45411 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org52b2ee52013-05-03 12:02:11412 uint16_t currentPacketLossRate;
henrik.lundin@webrtc.org6e7480a2014-10-09 12:58:45413 // Late loss rate; fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org52b2ee52013-05-03 12:02:11414 uint16_t currentDiscardRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23415 // fraction (of original stream) of synthesized speech inserted through
416 // expansion (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11417 uint16_t currentExpandRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23418 // fraction of synthesized speech inserted through pre-emptive expansion
419 // (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11420 uint16_t currentPreemptiveRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23421 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11422 uint16_t currentAccelerateRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23423 // clock-drift in parts-per-million (negative or positive)
424 int32_t clockDriftPPM;
425 // average packet waiting time in the jitter buffer (ms)
426 int meanWaitingTimeMs;
427 // median packet waiting time in the jitter buffer (ms)
428 int medianWaitingTimeMs;
429 // min packet waiting time in the jitter buffer (ms)
430 int minWaitingTimeMs;
431 // max packet waiting time in the jitter buffer (ms)
432 int maxWaitingTimeMs;
roosa@google.com0049a762012-12-14 00:06:18433 // added samples in off mode due to packet loss
434 int addedSamples;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23435};
436
wu@webrtc.org79d6daf2013-12-13 19:17:43437// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
438struct AudioDecodingCallStats {
439 AudioDecodingCallStats()
440 : calls_to_silence_generator(0),
441 calls_to_neteq(0),
442 decoded_normal(0),
443 decoded_plc(0),
444 decoded_cng(0),
445 decoded_plc_cng(0) {}
446
447 int calls_to_silence_generator; // Number of calls where silence generated,
448 // and NetEq was disengaged from decoding.
449 int calls_to_neteq; // Number of calls to NetEq.
450 int decoded_normal; // Number of calls where audio RTP packet decoded.
451 int decoded_plc; // Number of calls resulted in PLC.
452 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
453 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
454};
455
andrew@webrtc.orgb015cbe2012-10-22 18:19:23456typedef struct
457{
458 int min; // minumum
459 int max; // maximum
460 int average; // average
461} StatVal;
462
463typedef struct // All levels are reported in dBm0
464{
465 StatVal speech_rx; // long-term speech levels on receiving side
466 StatVal speech_tx; // long-term speech levels on transmitting side
467 StatVal noise_rx; // long-term noise/silence levels on receiving side
468 StatVal noise_tx; // long-term noise/silence levels on transmitting side
469} LevelStatistics;
470
471typedef struct // All levels are reported in dB
472{
473 StatVal erl; // Echo Return Loss
474 StatVal erle; // Echo Return Loss Enhancement
475 StatVal rerl; // RERL = ERL + ERLE
476 // Echo suppression inside EC at the point just before its NLP
477 StatVal a_nlp;
478} EchoStatistics;
479
andrew@webrtc.orgb015cbe2012-10-22 18:19:23480enum NsModes // type of Noise Suppression
481{
482 kNsUnchanged = 0, // previously set mode
483 kNsDefault, // platform default
484 kNsConference, // conferencing default
485 kNsLowSuppression, // lowest suppression
486 kNsModerateSuppression,
487 kNsHighSuppression,
488 kNsVeryHighSuppression, // highest suppression
489};
490
491enum AgcModes // type of Automatic Gain Control
492{
493 kAgcUnchanged = 0, // previously set mode
494 kAgcDefault, // platform default
495 // adaptive mode for use when analog volume control exists (e.g. for
496 // PC softphone)
497 kAgcAdaptiveAnalog,
498 // scaling takes place in the digital domain (e.g. for conference servers
499 // and embedded devices)
500 kAgcAdaptiveDigital,
501 // can be used on embedded devices where the capture signal level
502 // is predictable
503 kAgcFixedDigital
504};
505
506// EC modes
507enum EcModes // type of Echo Control
508{
509 kEcUnchanged = 0, // previously set mode
510 kEcDefault, // platform default
511 kEcConference, // conferencing default (aggressive AEC)
512 kEcAec, // Acoustic Echo Cancellation
513 kEcAecm, // AEC mobile
514};
515
516// AECM modes
517enum AecmModes // mode of AECM
518{
519 kAecmQuietEarpieceOrHeadset = 0,
520 // Quiet earpiece or headset use
521 kAecmEarpiece, // most earpiece use
522 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
523 kAecmSpeakerphone, // most speakerphone use (default)
524 kAecmLoudSpeakerphone // Loud speakerphone
525};
526
527// AGC configuration
528typedef struct
529{
530 unsigned short targetLeveldBOv;
531 unsigned short digitalCompressionGaindB;
532 bool limiterEnable;
533} AgcConfig; // AGC configuration parameters
534
535enum StereoChannel
536{
537 kStereoLeft = 0,
538 kStereoRight,
539 kStereoBoth
540};
541
542// Audio device layers
543enum AudioLayers
544{
545 kAudioPlatformDefault = 0,
546 kAudioWindowsWave = 1,
547 kAudioWindowsCore = 2,
548 kAudioLinuxAlsa = 3,
549 kAudioLinuxPulse = 4
550};
551
henrika@webrtc.org692224a2014-04-17 10:45:01552// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23553enum NetEqModes // NetEQ playout configurations
554{
555 // Optimized trade-off between low delay and jitter robustness for two-way
556 // communication.
557 kNetEqDefault = 0,
558 // Improved jitter robustness at the cost of increased delay. Can be
559 // used in one-way communication.
560 kNetEqStreaming = 1,
561 // Optimzed for decodability of fax signals rather than for perceived audio
562 // quality.
563 kNetEqFax = 2,
roosa@google.com90d333e2012-12-12 21:59:14564 // Minimal buffer management. Inserts zeros for lost packets and during
565 // buffer increases.
566 kNetEqOff = 3,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23567};
568
henrika@webrtc.org692224a2014-04-17 10:45:01569// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23570enum OnHoldModes // On Hold direction
571{
572 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
573 kHoldSendOnly, // Put only sending in on-hold state.
574 kHoldPlayOnly // Put only playing in on-hold state.
575};
576
henrika@webrtc.org692224a2014-04-17 10:45:01577// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23578enum AmrMode
579{
580 kRfc3267BwEfficient = 0,
581 kRfc3267OctetAligned = 1,
582 kRfc3267FileStorage = 2,
583};
584
585// ==================================================================
586// Video specific types
587// ==================================================================
588
589// Raw video types
590enum RawVideoType
591{
592 kVideoI420 = 0,
593 kVideoYV12 = 1,
594 kVideoYUY2 = 2,
595 kVideoUYVY = 3,
596 kVideoIYUV = 4,
597 kVideoARGB = 5,
598 kVideoRGB24 = 6,
599 kVideoRGB565 = 7,
600 kVideoARGB4444 = 8,
601 kVideoARGB1555 = 9,
602 kVideoMJPEG = 10,
603 kVideoNV12 = 11,
604 kVideoNV21 = 12,
605 kVideoBGRA = 13,
606 kVideoUnknown = 99
607};
608
609// Video codec
610enum { kConfigParameterSize = 128};
611enum { kPayloadNameSize = 32};
612enum { kMaxSimulcastStreams = 4};
613enum { kMaxTemporalStreams = 4};
614
615enum VideoCodecComplexity
616{
617 kComplexityNormal = 0,
618 kComplexityHigh = 1,
619 kComplexityHigher = 2,
620 kComplexityMax = 3
621};
622
623enum VideoCodecProfile
624{
625 kProfileBase = 0x00,
626 kProfileMain = 0x01
627};
628
629enum VP8ResilienceMode {
630 kResilienceOff, // The stream produced by the encoder requires a
631 // recovery frame (typically a key frame) to be
632 // decodable after a packet loss.
633 kResilientStream, // A stream produced by the encoder is resilient to
634 // packet losses, but packets within a frame subsequent
635 // to a loss can't be decoded.
636 kResilientFrames // Same as kResilientStream but with added resilience
637 // within a frame.
638};
639
640// VP8 specific
mallinath@webrtc.org18c29452014-03-21 00:41:28641struct VideoCodecVP8 {
642 bool pictureLossIndicationOn;
643 bool feedbackModeOn;
644 VideoCodecComplexity complexity;
645 VP8ResilienceMode resilience;
646 unsigned char numberOfTemporalLayers;
647 bool denoisingOn;
648 bool errorConcealmentOn;
649 bool automaticResizeOn;
650 bool frameDroppingOn;
651 int keyFrameInterval;
652
653 bool operator==(const VideoCodecVP8& other) const {
654 return pictureLossIndicationOn == other.pictureLossIndicationOn &&
655 feedbackModeOn == other.feedbackModeOn &&
656 complexity == other.complexity &&
657 resilience == other.resilience &&
658 numberOfTemporalLayers == other.numberOfTemporalLayers &&
659 denoisingOn == other.denoisingOn &&
660 errorConcealmentOn == other.errorConcealmentOn &&
661 automaticResizeOn == other.automaticResizeOn &&
662 frameDroppingOn == other.frameDroppingOn &&
663 keyFrameInterval == other.keyFrameInterval;
664 }
665
666 bool operator!=(const VideoCodecVP8& other) const {
667 return !(*this == other);
668 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23669};
670
marpan@webrtc.org66373882014-11-01 06:10:48671// VP9 specific
672struct VideoCodecVP9 {
673 VideoCodecComplexity complexity;
674 int resilience;
675 unsigned char numberOfTemporalLayers;
676 bool denoisingOn;
677 bool frameDroppingOn;
678 int keyFrameInterval;
679 bool adaptiveQpMode;
680};
681
stefan@webrtc.org2d4a80c2014-07-04 12:42:07682// H264 specific.
marpan@webrtc.org66373882014-11-01 06:10:48683struct VideoCodecH264 {
684 VideoCodecProfile profile;
685 bool frameDroppingOn;
686 int keyFrameInterval;
687 // These are NULL/0 if not externally negotiated.
688 const uint8_t* spsData;
689 size_t spsLen;
690 const uint8_t* ppsData;
691 size_t ppsLen;
stefan@webrtc.org2d4a80c2014-07-04 12:42:07692};
693
andrew@webrtc.orgb015cbe2012-10-22 18:19:23694// Video codec types
marpan@webrtc.org66373882014-11-01 06:10:48695enum VideoCodecType {
696 kVideoCodecVP8,
697 kVideoCodecVP9,
698 kVideoCodecH264,
699 kVideoCodecI420,
700 kVideoCodecRED,
701 kVideoCodecULPFEC,
702 kVideoCodecGeneric,
703 kVideoCodecUnknown
andrew@webrtc.orgb015cbe2012-10-22 18:19:23704};
705
marpan@webrtc.org66373882014-11-01 06:10:48706union VideoCodecUnion {
707 VideoCodecVP8 VP8;
708 VideoCodecVP9 VP9;
709 VideoCodecH264 H264;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23710};
711
712
713// Simulcast is when the same stream is encoded multiple times with different
714// settings such as resolution.
mallinath@webrtc.org18c29452014-03-21 00:41:28715struct SimulcastStream {
716 unsigned short width;
717 unsigned short height;
718 unsigned char numberOfTemporalLayers;
719 unsigned int maxBitrate; // kilobits/sec.
720 unsigned int targetBitrate; // kilobits/sec.
721 unsigned int minBitrate; // kilobits/sec.
722 unsigned int qpMax; // minimum quality
723
724 bool operator==(const SimulcastStream& other) const {
725 return width == other.width &&
726 height == other.height &&
727 numberOfTemporalLayers == other.numberOfTemporalLayers &&
728 maxBitrate == other.maxBitrate &&
729 targetBitrate == other.targetBitrate &&
730 minBitrate == other.minBitrate &&
731 qpMax == other.qpMax;
732 }
733
734 bool operator!=(const SimulcastStream& other) const {
735 return !(*this == other);
736 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23737};
738
stefan@webrtc.orgf4d37882013-02-18 14:40:18739enum VideoCodecMode {
740 kRealtimeVideo,
741 kScreensharing
742};
743
andrew@webrtc.orgb015cbe2012-10-22 18:19:23744// Common video codec properties
mallinath@webrtc.org18c29452014-03-21 00:41:28745struct VideoCodec {
746 VideoCodecType codecType;
747 char plName[kPayloadNameSize];
748 unsigned char plType;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23749
mallinath@webrtc.org18c29452014-03-21 00:41:28750 unsigned short width;
751 unsigned short height;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23752
mallinath@webrtc.org18c29452014-03-21 00:41:28753 unsigned int startBitrate; // kilobits/sec.
754 unsigned int maxBitrate; // kilobits/sec.
755 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org3d6910c2014-03-24 12:36:52756 unsigned int targetBitrate; // kilobits/sec.
757
mallinath@webrtc.org18c29452014-03-21 00:41:28758 unsigned char maxFramerate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23759
mallinath@webrtc.org18c29452014-03-21 00:41:28760 VideoCodecUnion codecSpecific;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23761
mallinath@webrtc.org18c29452014-03-21 00:41:28762 unsigned int qpMax;
763 unsigned char numberOfSimulcastStreams;
764 SimulcastStream simulcastStream[kMaxSimulcastStreams];
stefan@webrtc.orgf4d37882013-02-18 14:40:18765
mallinath@webrtc.org18c29452014-03-21 00:41:28766 VideoCodecMode mode;
andresp@webrtc.orgee6f8a22013-05-14 08:02:25767
mallinath@webrtc.org18c29452014-03-21 00:41:28768 // When using an external encoder/decoder this allows to pass
769 // extra options without requiring webrtc to be aware of them.
770 Config* extra_options;
mallinath@webrtc.org18c29452014-03-21 00:41:28771
mallinath@webrtc.org18c29452014-03-21 00:41:28772 bool operator==(const VideoCodec& other) const {
773 bool ret = codecType == other.codecType &&
774 (STR_CASE_CMP(plName, other.plName) == 0) &&
775 plType == other.plType &&
776 width == other.width &&
777 height == other.height &&
778 startBitrate == other.startBitrate &&
779 maxBitrate == other.maxBitrate &&
780 minBitrate == other.minBitrate &&
pbos@webrtc.org3d6910c2014-03-24 12:36:52781 targetBitrate == other.targetBitrate &&
mallinath@webrtc.org18c29452014-03-21 00:41:28782 maxFramerate == other.maxFramerate &&
783 qpMax == other.qpMax &&
784 numberOfSimulcastStreams == other.numberOfSimulcastStreams &&
785 mode == other.mode;
786 if (ret && codecType == kVideoCodecVP8) {
787 ret &= (codecSpecific.VP8 == other.codecSpecific.VP8);
788 }
789
790 for (unsigned char i = 0; i < other.numberOfSimulcastStreams && ret; ++i) {
791 ret &= (simulcastStream[i] == other.simulcastStream[i]);
792 }
793 return ret;
794 }
795
796 bool operator!=(const VideoCodec& other) const {
797 return !(*this == other);
798 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23799};
800
801// Bandwidth over-use detector options. These are used to drive
802// experimentation with bandwidth estimation parameters.
803// See modules/remote_bitrate_estimator/overuse_detector.h
804struct OverUseDetectorOptions {
805 OverUseDetectorOptions()
806 : initial_slope(8.0/512.0),
807 initial_offset(0),
808 initial_e(),
809 initial_process_noise(),
810 initial_avg_noise(0.0),
811 initial_var_noise(50),
812 initial_threshold(25.0) {
813 initial_e[0][0] = 100;
814 initial_e[1][1] = 1e-1;
815 initial_e[0][1] = initial_e[1][0] = 0;
816 initial_process_noise[0] = 1e-10;
817 initial_process_noise[1] = 1e-2;
818 }
819 double initial_slope;
820 double initial_offset;
821 double initial_e[2][2];
822 double initial_process_noise[2];
823 double initial_avg_noise;
824 double initial_var_noise;
825 double initial_threshold;
826};
andrew@webrtc.org5cf83f42013-09-09 17:50:10827
wu@webrtc.orgefeb8ce2013-12-13 00:21:03828// This structure will have the information about when packet is actually
829// received by socket.
830struct PacketTime {
henrike@webrtc.org93ae8212014-04-29 17:50:47831 PacketTime() : timestamp(-1), not_before(-1) {}
832 PacketTime(int64_t timestamp, int64_t not_before)
833 : timestamp(timestamp), not_before(not_before) {
wu@webrtc.orgefeb8ce2013-12-13 00:21:03834 }
835
henrike@webrtc.org93ae8212014-04-29 17:50:47836 int64_t timestamp; // Receive time after socket delivers the data.
837 int64_t not_before; // Earliest possible time the data could have arrived,
838 // indicating the potential error in the |timestamp|
839 // value,in case the system is busy.
840 // For example, the time of the last select() call.
841 // If unknown, this value will be set to zero.
wu@webrtc.orgefeb8ce2013-12-13 00:21:03842};
843
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25844struct RTPHeaderExtension {
845 RTPHeaderExtension()
846 : hasTransmissionTimeOffset(false),
847 transmissionTimeOffset(0),
848 hasAbsoluteSendTime(false),
849 absoluteSendTime(0),
850 hasAudioLevel(false),
851 audioLevel(0) {}
852
853 bool hasTransmissionTimeOffset;
854 int32_t transmissionTimeOffset;
855 bool hasAbsoluteSendTime;
856 uint32_t absoluteSendTime;
857
858 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
859 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
860 bool hasAudioLevel;
861 uint8_t audioLevel;
862};
863
864struct RTPHeader {
865 RTPHeader()
866 : markerBit(false),
867 payloadType(0),
868 sequenceNumber(0),
869 timestamp(0),
870 ssrc(0),
871 numCSRCs(0),
872 paddingLength(0),
873 headerLength(0),
874 payload_type_frequency(0),
875 extension() {
876 memset(&arrOfCSRCs, 0, sizeof(arrOfCSRCs));
877 }
878
879 bool markerBit;
880 uint8_t payloadType;
881 uint16_t sequenceNumber;
882 uint32_t timestamp;
883 uint32_t ssrc;
884 uint8_t numCSRCs;
885 uint32_t arrOfCSRCs[kRtpCsrcSize];
pkasting@chromium.org0ab923a2014-11-20 22:28:14886 size_t paddingLength;
887 size_t headerLength;
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25888 int payload_type_frequency;
889 RTPHeaderExtension extension;
890};
891
andrew@webrtc.orgb015cbe2012-10-22 18:19:23892} // namespace webrtc
andrew@webrtc.org5cf83f42013-09-09 17:50:10893
894#endif // WEBRTC_COMMON_TYPES_H_