blob: ac56eb1cf14e1b958106cb63912dc4818be1e588 [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:
kjellander@webrtc.org14665ff2015-03-04 12:58:3559 // Reads |length| bytes from file to |buf|. Returns the number of bytes read
60 // or -1 on error.
pkasting@chromium.org4591fbd2014-11-20 22:28:1461 virtual int Read(void *buf, size_t len) = 0;
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:2262 virtual int Rewind();
niklase@google.com470e71d2011-07-07 08:21:2563 virtual ~InStream() {}
64protected:
65 InStream() {}
66};
67
68class OutStream
69{
70public:
kjellander@webrtc.org14665ff2015-03-04 12:58:3571 // Writes |length| bytes from |buf| to file. The actual writing may happen
72 // some time later. Call Flush() to force a write.
pkasting@chromium.org4591fbd2014-11-20 22:28:1473 virtual bool Write(const void *buf, size_t len) = 0;
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:2274 virtual int Rewind();
niklase@google.com470e71d2011-07-07 08:21:2575 virtual ~OutStream() {}
76protected:
77 OutStream() {}
78};
79
80enum TraceModule
81{
pbos@webrtc.org5ab75672013-12-16 12:24:4482 kTraceUndefined = 0,
niklase@google.com470e71d2011-07-07 08:21:2583 // not a module, triggered from the engine code
pbos@webrtc.org5ab75672013-12-16 12:24:4484 kTraceVoice = 0x0001,
niklase@google.com470e71d2011-07-07 08:21:2585 // not a module, triggered from the engine code
pbos@webrtc.org5ab75672013-12-16 12:24:4486 kTraceVideo = 0x0002,
niklase@google.com470e71d2011-07-07 08:21:2587 // not a module, triggered from the utility code
pbos@webrtc.org5ab75672013-12-16 12:24:4488 kTraceUtility = 0x0003,
89 kTraceRtpRtcp = 0x0004,
90 kTraceTransport = 0x0005,
91 kTraceSrtp = 0x0006,
92 kTraceAudioCoding = 0x0007,
93 kTraceAudioMixerServer = 0x0008,
94 kTraceAudioMixerClient = 0x0009,
95 kTraceFile = 0x000a,
96 kTraceAudioProcessing = 0x000b,
97 kTraceVideoCoding = 0x0010,
98 kTraceVideoMixer = 0x0011,
99 kTraceAudioDevice = 0x0012,
100 kTraceVideoRenderer = 0x0014,
101 kTraceVideoCapture = 0x0015,
pbos@webrtc.org5ab75672013-12-16 12:24:44102 kTraceRemoteBitrateEstimator = 0x0017,
niklase@google.com470e71d2011-07-07 08:21:25103};
104
105enum TraceLevel
106{
107 kTraceNone = 0x0000, // no trace
108 kTraceStateInfo = 0x0001,
109 kTraceWarning = 0x0002,
110 kTraceError = 0x0004,
111 kTraceCritical = 0x0008,
112 kTraceApiCall = 0x0010,
113 kTraceDefault = 0x00ff,
114
115 kTraceModuleCall = 0x0020,
116 kTraceMemory = 0x0100, // memory info
117 kTraceTimer = 0x0200, // timing info
118 kTraceStream = 0x0400, // "continuous" stream of data
119
120 // used for debug purposes
121 kTraceDebug = 0x0800, // debug
122 kTraceInfo = 0x1000, // debug info
123
andrew@webrtc.org655d8f52012-11-20 07:34:45124 // Non-verbose level used by LS_INFO of logging.h. Do not use directly.
125 kTraceTerseInfo = 0x2000,
126
niklase@google.com470e71d2011-07-07 08:21:25127 kTraceAll = 0xffff
128};
129
130// External Trace API
andrew@webrtc.org23ec30b2012-11-15 05:33:25131class TraceCallback {
132 public:
133 virtual void Print(TraceLevel level, const char* message, int length) = 0;
niklase@google.com470e71d2011-07-07 08:21:25134
andrew@webrtc.org23ec30b2012-11-15 05:33:25135 protected:
136 virtual ~TraceCallback() {}
137 TraceCallback() {}
138};
niklase@google.com470e71d2011-07-07 08:21:25139
140enum FileFormats
141{
142 kFileFormatWavFile = 1,
143 kFileFormatCompressedFile = 2,
niklase@google.com470e71d2011-07-07 08:21:25144 kFileFormatPreencodedFile = 4,
145 kFileFormatPcm16kHzFile = 7,
146 kFileFormatPcm8kHzFile = 8,
147 kFileFormatPcm32kHzFile = 9
148};
149
niklase@google.com470e71d2011-07-07 08:21:25150enum ProcessingTypes
151{
152 kPlaybackPerChannel = 0,
153 kPlaybackAllChannelsMixed,
154 kRecordingPerChannel,
andrew@webrtc.org21ab3ba2012-10-19 17:30:56155 kRecordingAllChannelsMixed,
156 kRecordingPreprocessing
niklase@google.com470e71d2011-07-07 08:21:25157};
158
sprang@webrtc.org71f055f2013-12-04 15:09:27159enum FrameType
160{
161 kFrameEmpty = 0,
162 kAudioFrameSpeech = 1,
163 kAudioFrameCN = 2,
164 kVideoFrameKey = 3, // independent frame
165 kVideoFrameDelta = 4, // depends on the previus frame
166};
167
niklase@google.com470e71d2011-07-07 08:21:25168// External transport callback interface
169class Transport
170{
171public:
pkasting@chromium.org4591fbd2014-11-20 22:28:14172 virtual int SendPacket(int channel, const void *data, size_t len) = 0;
173 virtual int SendRTCPPacket(int channel, const void *data, size_t len) = 0;
niklase@google.com470e71d2011-07-07 08:21:25174
175protected:
176 virtual ~Transport() {}
177 Transport() {}
178};
179
sprang@webrtc.orgdc50aae2013-11-20 16:47:07180// Statistics for an RTCP channel
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07181struct RtcpStatistics {
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07182 RtcpStatistics()
183 : fraction_lost(0),
184 cumulative_lost(0),
185 extended_max_sequence_number(0),
sprang@webrtc.orga6ad6e52013-12-05 09:48:44186 jitter(0) {}
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07187
188 uint8_t fraction_lost;
189 uint32_t cumulative_lost;
190 uint32_t extended_max_sequence_number;
191 uint32_t jitter;
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07192};
193
sprang@webrtc.orgdc50aae2013-11-20 16:47:07194class RtcpStatisticsCallback {
195 public:
196 virtual ~RtcpStatisticsCallback() {}
197
198 virtual void StatisticsUpdated(const RtcpStatistics& statistics,
199 uint32_t ssrc) = 0;
pbos@webrtc.orgce4e9a32014-12-18 13:50:16200 virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07201};
202
asapersson@webrtc.org8098e072014-02-19 11:59:02203// Statistics for RTCP packet types.
204struct RtcpPacketTypeCounter {
205 RtcpPacketTypeCounter()
asapersson@webrtc.orgd08d3892014-12-16 12:03:11206 : first_packet_time_ms(-1),
207 nack_packets(0),
asapersson@webrtc.org8098e072014-02-19 11:59:02208 fir_packets(0),
asapersson@webrtc.org2dd31342014-10-29 12:42:30209 pli_packets(0),
210 nack_requests(0),
211 unique_nack_requests(0) {}
asapersson@webrtc.org8098e072014-02-19 11:59:02212
213 void Add(const RtcpPacketTypeCounter& other) {
214 nack_packets += other.nack_packets;
215 fir_packets += other.fir_packets;
216 pli_packets += other.pli_packets;
asapersson@webrtc.org2dd31342014-10-29 12:42:30217 nack_requests += other.nack_requests;
218 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.orgd08d3892014-12-16 12:03:11219 if (other.first_packet_time_ms != -1 &&
220 (other.first_packet_time_ms < first_packet_time_ms ||
221 first_packet_time_ms == -1)) {
222 // Use oldest time.
223 first_packet_time_ms = other.first_packet_time_ms;
224 }
225 }
226
227 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
228 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
asapersson@webrtc.org8098e072014-02-19 11:59:02229 }
230
asapersson@webrtc.org2dd31342014-10-29 12:42:30231 int UniqueNackRequestsInPercent() const {
232 if (nack_requests == 0) {
233 return 0;
234 }
235 return static_cast<int>(
236 (unique_nack_requests * 100.0f / nack_requests) + 0.5f);
237 }
238
asapersson@webrtc.orgd08d3892014-12-16 12:03:11239 int64_t first_packet_time_ms; // Time when first packet is sent/received.
240 uint32_t nack_packets; // Number of RTCP NACK packets.
241 uint32_t fir_packets; // Number of RTCP FIR packets.
242 uint32_t pli_packets; // Number of RTCP PLI packets.
243 uint32_t nack_requests; // Number of NACKed RTP packets.
asapersson@webrtc.org2dd31342014-10-29 12:42:30244 uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
asapersson@webrtc.org8098e072014-02-19 11:59:02245};
246
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00247class RtcpPacketTypeCounterObserver {
248 public:
249 virtual ~RtcpPacketTypeCounterObserver() {}
250 virtual void RtcpPacketTypesCounterUpdated(
251 uint32_t ssrc,
252 const RtcpPacketTypeCounter& packet_counter) = 0;
253};
254
asapersson@webrtc.orgd08d3892014-12-16 12:03:11255// Rate statistics for a stream.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07256struct BitrateStatistics {
sprang@webrtc.org6811b6e2013-12-13 09:46:59257 BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
sprang@webrtc.orgdc50aae2013-11-20 16:47:07258
sprang@webrtc.org6811b6e2013-12-13 09:46:59259 uint32_t bitrate_bps; // Bitrate in bits per second.
260 uint32_t packet_rate; // Packet rate in packets per second.
261 uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07262};
263
264// Callback, used to notify an observer whenever new rates have been estimated.
265class BitrateStatisticsObserver {
266 public:
267 virtual ~BitrateStatisticsObserver() {}
268
stefan@webrtc.org0bae1fa2014-11-05 14:05:29269 virtual void Notify(const BitrateStatistics& total_stats,
270 const BitrateStatistics& retransmit_stats,
271 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07272};
273
pbos@webrtc.orgce4e9a32014-12-18 13:50:16274struct FrameCounts {
275 FrameCounts() : key_frames(0), delta_frames(0) {}
276 int key_frames;
277 int delta_frames;
278};
279
asapersson@webrtc.orgd08d3892014-12-16 12:03:11280// Callback, used to notify an observer whenever frame counts have been updated.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07281class FrameCountObserver {
282 public:
sprang@webrtc.org72964bd2013-11-21 09:09:54283 virtual ~FrameCountObserver() {}
pbos@webrtc.orgce4e9a32014-12-18 13:50:16284 virtual void FrameCountUpdated(const FrameCounts& frame_counts,
285 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07286};
287
stefan@webrtc.org168f23f2014-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
niklase@google.com470e71d2011-07-07 08:21:25297// ==================================================================
298// Voice specific types
299// ==================================================================
300
301// Each codec supported can be described by this structure.
mallinath@webrtc.org0209e562014-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 }
niklase@google.com470e71d2011-07-07 08:21:25322};
323
niklase@google.com470e71d2011-07-07 08:21:25324// 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.org77f6b212013-05-03 12:02:11351 uint16_t currentBufferSize;
niklase@google.com470e71d2011-07-07 08:21:25352 // preferred (optimal) buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11353 uint16_t preferredBufferSize;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55354 // adding extra delay due to "peaky jitter"
355 bool jitterPeaksFound;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45356 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11357 uint16_t currentPacketLossRate;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45358 // Late loss rate; fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11359 uint16_t currentDiscardRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13360 // fraction (of original stream) of synthesized audio inserted through
niklase@google.com470e71d2011-07-07 08:21:25361 // expansion (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11362 uint16_t currentExpandRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13363 // fraction (of original stream) of synthesized speech inserted through
364 // expansion (in Q14)
365 uint16_t currentSpeechExpandRate;
niklase@google.com470e71d2011-07-07 08:21:25366 // fraction of synthesized speech inserted through pre-emptive expansion
367 // (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11368 uint16_t currentPreemptiveRate;
niklase@google.com470e71d2011-07-07 08:21:25369 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11370 uint16_t currentAccelerateRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13371 // fraction of data coming from secondary decoding (in Q14)
372 uint16_t currentSecondaryDecodedRate;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55373 // clock-drift in parts-per-million (negative or positive)
374 int32_t clockDriftPPM;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05375 // average packet waiting time in the jitter buffer (ms)
376 int meanWaitingTimeMs;
377 // median packet waiting time in the jitter buffer (ms)
378 int medianWaitingTimeMs;
henrik.lundin@webrtc.org053c7992012-01-12 14:16:44379 // min packet waiting time in the jitter buffer (ms)
380 int minWaitingTimeMs;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05381 // max packet waiting time in the jitter buffer (ms)
382 int maxWaitingTimeMs;
roosa@google.comb8ba4d82012-12-14 00:06:18383 // added samples in off mode due to packet loss
384 int addedSamples;
niklase@google.com470e71d2011-07-07 08:21:25385};
386
wu@webrtc.org24301a62013-12-13 19:17:43387// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
388struct AudioDecodingCallStats {
389 AudioDecodingCallStats()
390 : calls_to_silence_generator(0),
391 calls_to_neteq(0),
392 decoded_normal(0),
393 decoded_plc(0),
394 decoded_cng(0),
395 decoded_plc_cng(0) {}
396
397 int calls_to_silence_generator; // Number of calls where silence generated,
398 // and NetEq was disengaged from decoding.
399 int calls_to_neteq; // Number of calls to NetEq.
400 int decoded_normal; // Number of calls where audio RTP packet decoded.
401 int decoded_plc; // Number of calls resulted in PLC.
402 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
403 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
404};
405
niklase@google.com470e71d2011-07-07 08:21:25406typedef struct
407{
408 int min; // minumum
409 int max; // maximum
410 int average; // average
411} StatVal;
412
413typedef struct // All levels are reported in dBm0
414{
415 StatVal speech_rx; // long-term speech levels on receiving side
416 StatVal speech_tx; // long-term speech levels on transmitting side
417 StatVal noise_rx; // long-term noise/silence levels on receiving side
418 StatVal noise_tx; // long-term noise/silence levels on transmitting side
419} LevelStatistics;
420
421typedef struct // All levels are reported in dB
422{
423 StatVal erl; // Echo Return Loss
424 StatVal erle; // Echo Return Loss Enhancement
425 StatVal rerl; // RERL = ERL + ERLE
426 // Echo suppression inside EC at the point just before its NLP
427 StatVal a_nlp;
428} EchoStatistics;
429
niklase@google.com470e71d2011-07-07 08:21:25430enum NsModes // type of Noise Suppression
431{
432 kNsUnchanged = 0, // previously set mode
433 kNsDefault, // platform default
434 kNsConference, // conferencing default
435 kNsLowSuppression, // lowest suppression
436 kNsModerateSuppression,
437 kNsHighSuppression,
438 kNsVeryHighSuppression, // highest suppression
439};
440
441enum AgcModes // type of Automatic Gain Control
442{
443 kAgcUnchanged = 0, // previously set mode
444 kAgcDefault, // platform default
445 // adaptive mode for use when analog volume control exists (e.g. for
446 // PC softphone)
447 kAgcAdaptiveAnalog,
448 // scaling takes place in the digital domain (e.g. for conference servers
449 // and embedded devices)
450 kAgcAdaptiveDigital,
andrew@webrtc.org80124742012-03-08 17:54:24451 // can be used on embedded devices where the capture signal level
niklase@google.com470e71d2011-07-07 08:21:25452 // is predictable
453 kAgcFixedDigital
454};
455
456// EC modes
457enum EcModes // type of Echo Control
458{
459 kEcUnchanged = 0, // previously set mode
460 kEcDefault, // platform default
461 kEcConference, // conferencing default (aggressive AEC)
462 kEcAec, // Acoustic Echo Cancellation
463 kEcAecm, // AEC mobile
464};
465
466// AECM modes
467enum AecmModes // mode of AECM
468{
469 kAecmQuietEarpieceOrHeadset = 0,
470 // Quiet earpiece or headset use
471 kAecmEarpiece, // most earpiece use
472 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
473 kAecmSpeakerphone, // most speakerphone use (default)
474 kAecmLoudSpeakerphone // Loud speakerphone
475};
476
477// AGC configuration
478typedef struct
479{
480 unsigned short targetLeveldBOv;
481 unsigned short digitalCompressionGaindB;
482 bool limiterEnable;
483} AgcConfig; // AGC configuration parameters
484
485enum StereoChannel
486{
487 kStereoLeft = 0,
488 kStereoRight,
489 kStereoBoth
490};
491
492// Audio device layers
493enum AudioLayers
494{
495 kAudioPlatformDefault = 0,
496 kAudioWindowsWave = 1,
497 kAudioWindowsCore = 2,
498 kAudioLinuxAlsa = 3,
499 kAudioLinuxPulse = 4
500};
501
henrika@webrtc.org66803482014-04-17 10:45:01502// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25503enum NetEqModes // NetEQ playout configurations
504{
505 // Optimized trade-off between low delay and jitter robustness for two-way
506 // communication.
507 kNetEqDefault = 0,
508 // Improved jitter robustness at the cost of increased delay. Can be
509 // used in one-way communication.
510 kNetEqStreaming = 1,
511 // Optimzed for decodability of fax signals rather than for perceived audio
512 // quality.
513 kNetEqFax = 2,
roosa@google.comb7186192012-12-12 21:59:14514 // Minimal buffer management. Inserts zeros for lost packets and during
515 // buffer increases.
516 kNetEqOff = 3,
niklase@google.com470e71d2011-07-07 08:21:25517};
518
henrika@webrtc.org66803482014-04-17 10:45:01519// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25520enum OnHoldModes // On Hold direction
521{
522 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
523 kHoldSendOnly, // Put only sending in on-hold state.
524 kHoldPlayOnly // Put only playing in on-hold state.
525};
526
henrika@webrtc.org66803482014-04-17 10:45:01527// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25528enum AmrMode
529{
530 kRfc3267BwEfficient = 0,
531 kRfc3267OctetAligned = 1,
532 kRfc3267FileStorage = 2,
533};
534
535// ==================================================================
536// Video specific types
537// ==================================================================
538
539// Raw video types
540enum RawVideoType
541{
542 kVideoI420 = 0,
543 kVideoYV12 = 1,
544 kVideoYUY2 = 2,
545 kVideoUYVY = 3,
546 kVideoIYUV = 4,
547 kVideoARGB = 5,
548 kVideoRGB24 = 6,
549 kVideoRGB565 = 7,
550 kVideoARGB4444 = 8,
551 kVideoARGB1555 = 9,
552 kVideoMJPEG = 10,
553 kVideoNV12 = 11,
554 kVideoNV21 = 12,
mikhal@webrtc.orgc00f91d2012-01-03 18:49:15555 kVideoBGRA = 13,
niklase@google.com470e71d2011-07-07 08:21:25556 kVideoUnknown = 99
557};
558
559// Video codec
560enum { kConfigParameterSize = 128};
561enum { kPayloadNameSize = 32};
pwestin@webrtc.org1da1ce02011-10-13 15:19:55562enum { kMaxSimulcastStreams = 4};
pwestin@webrtc.orgdb221d22011-12-02 11:31:08563enum { kMaxTemporalStreams = 4};
niklase@google.com470e71d2011-07-07 08:21:25564
niklase@google.com470e71d2011-07-07 08:21:25565enum VideoCodecComplexity
566{
567 kComplexityNormal = 0,
568 kComplexityHigh = 1,
569 kComplexityHigher = 2,
570 kComplexityMax = 3
571};
572
573enum VideoCodecProfile
574{
575 kProfileBase = 0x00,
576 kProfileMain = 0x01
577};
578
stefan@webrtc.orgefd0a482011-12-29 10:12:35579enum VP8ResilienceMode {
580 kResilienceOff, // The stream produced by the encoder requires a
581 // recovery frame (typically a key frame) to be
582 // decodable after a packet loss.
583 kResilientStream, // A stream produced by the encoder is resilient to
584 // packet losses, but packets within a frame subsequent
585 // to a loss can't be decoded.
586 kResilientFrames // Same as kResilientStream but with added resilience
587 // within a frame.
588};
589
niklase@google.com470e71d2011-07-07 08:21:25590// VP8 specific
mallinath@webrtc.org0209e562014-03-21 00:41:28591struct VideoCodecVP8 {
592 bool pictureLossIndicationOn;
593 bool feedbackModeOn;
594 VideoCodecComplexity complexity;
595 VP8ResilienceMode resilience;
596 unsigned char numberOfTemporalLayers;
597 bool denoisingOn;
598 bool errorConcealmentOn;
599 bool automaticResizeOn;
600 bool frameDroppingOn;
601 int keyFrameInterval;
602
603 bool operator==(const VideoCodecVP8& other) const {
604 return pictureLossIndicationOn == other.pictureLossIndicationOn &&
605 feedbackModeOn == other.feedbackModeOn &&
606 complexity == other.complexity &&
607 resilience == other.resilience &&
608 numberOfTemporalLayers == other.numberOfTemporalLayers &&
609 denoisingOn == other.denoisingOn &&
610 errorConcealmentOn == other.errorConcealmentOn &&
611 automaticResizeOn == other.automaticResizeOn &&
612 frameDroppingOn == other.frameDroppingOn &&
613 keyFrameInterval == other.keyFrameInterval;
614 }
615
616 bool operator!=(const VideoCodecVP8& other) const {
617 return !(*this == other);
618 }
niklase@google.com470e71d2011-07-07 08:21:25619};
620
asaperssona9455ab2015-07-31 13:10:09621// VP9 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48622struct VideoCodecVP9 {
623 VideoCodecComplexity complexity;
624 int resilience;
625 unsigned char numberOfTemporalLayers;
626 bool denoisingOn;
627 bool frameDroppingOn;
628 int keyFrameInterval;
629 bool adaptiveQpMode;
asaperssona9455ab2015-07-31 13:10:09630 unsigned char numberOfSpatialLayers;
631 bool flexibleMode;
marpan@webrtc.org5b883172014-11-01 06:10:48632};
633
stefan@webrtc.orgb9f54532014-07-04 12:42:07634// H264 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48635struct VideoCodecH264 {
636 VideoCodecProfile profile;
637 bool frameDroppingOn;
638 int keyFrameInterval;
639 // These are NULL/0 if not externally negotiated.
640 const uint8_t* spsData;
641 size_t spsLen;
642 const uint8_t* ppsData;
643 size_t ppsLen;
stefan@webrtc.orgb9f54532014-07-04 12:42:07644};
645
niklase@google.com470e71d2011-07-07 08:21:25646// Video codec types
marpan@webrtc.org5b883172014-11-01 06:10:48647enum VideoCodecType {
648 kVideoCodecVP8,
649 kVideoCodecVP9,
650 kVideoCodecH264,
651 kVideoCodecI420,
652 kVideoCodecRED,
653 kVideoCodecULPFEC,
654 kVideoCodecGeneric,
655 kVideoCodecUnknown
niklase@google.com470e71d2011-07-07 08:21:25656};
657
marpan@webrtc.org5b883172014-11-01 06:10:48658union VideoCodecUnion {
659 VideoCodecVP8 VP8;
660 VideoCodecVP9 VP9;
661 VideoCodecH264 H264;
niklase@google.com470e71d2011-07-07 08:21:25662};
663
phoglund@webrtc.org8bfee842012-02-17 09:32:48664
665// Simulcast is when the same stream is encoded multiple times with different
666// settings such as resolution.
mallinath@webrtc.org0209e562014-03-21 00:41:28667struct SimulcastStream {
668 unsigned short width;
669 unsigned short height;
670 unsigned char numberOfTemporalLayers;
671 unsigned int maxBitrate; // kilobits/sec.
672 unsigned int targetBitrate; // kilobits/sec.
673 unsigned int minBitrate; // kilobits/sec.
674 unsigned int qpMax; // minimum quality
675
676 bool operator==(const SimulcastStream& other) const {
677 return width == other.width &&
678 height == other.height &&
679 numberOfTemporalLayers == other.numberOfTemporalLayers &&
680 maxBitrate == other.maxBitrate &&
681 targetBitrate == other.targetBitrate &&
682 minBitrate == other.minBitrate &&
683 qpMax == other.qpMax;
684 }
685
686 bool operator!=(const SimulcastStream& other) const {
687 return !(*this == other);
688 }
pwestin@webrtc.org1da1ce02011-10-13 15:19:55689};
690
stefan@webrtc.orgeb917922013-02-18 14:40:18691enum VideoCodecMode {
692 kRealtimeVideo,
693 kScreensharing
694};
695
niklase@google.com470e71d2011-07-07 08:21:25696// Common video codec properties
mallinath@webrtc.org0209e562014-03-21 00:41:28697struct VideoCodec {
698 VideoCodecType codecType;
699 char plName[kPayloadNameSize];
700 unsigned char plType;
niklase@google.com470e71d2011-07-07 08:21:25701
mallinath@webrtc.org0209e562014-03-21 00:41:28702 unsigned short width;
703 unsigned short height;
niklase@google.com470e71d2011-07-07 08:21:25704
mallinath@webrtc.org0209e562014-03-21 00:41:28705 unsigned int startBitrate; // kilobits/sec.
706 unsigned int maxBitrate; // kilobits/sec.
707 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org3c412b22014-03-24 12:36:52708 unsigned int targetBitrate; // kilobits/sec.
709
mallinath@webrtc.org0209e562014-03-21 00:41:28710 unsigned char maxFramerate;
niklase@google.com470e71d2011-07-07 08:21:25711
mallinath@webrtc.org0209e562014-03-21 00:41:28712 VideoCodecUnion codecSpecific;
niklase@google.com470e71d2011-07-07 08:21:25713
mallinath@webrtc.org0209e562014-03-21 00:41:28714 unsigned int qpMax;
715 unsigned char numberOfSimulcastStreams;
716 SimulcastStream simulcastStream[kMaxSimulcastStreams];
stefan@webrtc.orgeb917922013-02-18 14:40:18717
mallinath@webrtc.org0209e562014-03-21 00:41:28718 VideoCodecMode mode;
andresp@webrtc.org185bae42013-05-14 08:02:25719
mallinath@webrtc.org0209e562014-03-21 00:41:28720 // When using an external encoder/decoder this allows to pass
721 // extra options without requiring webrtc to be aware of them.
722 Config* extra_options;
mallinath@webrtc.org0209e562014-03-21 00:41:28723
mallinath@webrtc.org0209e562014-03-21 00:41:28724 bool operator==(const VideoCodec& other) const {
725 bool ret = codecType == other.codecType &&
726 (STR_CASE_CMP(plName, other.plName) == 0) &&
727 plType == other.plType &&
728 width == other.width &&
729 height == other.height &&
730 startBitrate == other.startBitrate &&
731 maxBitrate == other.maxBitrate &&
732 minBitrate == other.minBitrate &&
pbos@webrtc.org3c412b22014-03-24 12:36:52733 targetBitrate == other.targetBitrate &&
mallinath@webrtc.org0209e562014-03-21 00:41:28734 maxFramerate == other.maxFramerate &&
735 qpMax == other.qpMax &&
736 numberOfSimulcastStreams == other.numberOfSimulcastStreams &&
737 mode == other.mode;
738 if (ret && codecType == kVideoCodecVP8) {
739 ret &= (codecSpecific.VP8 == other.codecSpecific.VP8);
740 }
741
742 for (unsigned char i = 0; i < other.numberOfSimulcastStreams && ret; ++i) {
743 ret &= (simulcastStream[i] == other.simulcastStream[i]);
744 }
745 return ret;
746 }
747
748 bool operator!=(const VideoCodec& other) const {
749 return !(*this == other);
750 }
niklase@google.com470e71d2011-07-07 08:21:25751};
astor@webrtc.orgbd7aeba2012-06-26 10:47:04752
753// Bandwidth over-use detector options. These are used to drive
754// experimentation with bandwidth estimation parameters.
755// See modules/remote_bitrate_estimator/overuse_detector.h
756struct OverUseDetectorOptions {
757 OverUseDetectorOptions()
758 : initial_slope(8.0/512.0),
759 initial_offset(0),
760 initial_e(),
761 initial_process_noise(),
762 initial_avg_noise(0.0),
Stefan Holmer86479222015-07-10 09:28:37763 initial_var_noise(50) {
astor@webrtc.orgbd7aeba2012-06-26 10:47:04764 initial_e[0][0] = 100;
765 initial_e[1][1] = 1e-1;
766 initial_e[0][1] = initial_e[1][0] = 0;
stefanc62642c2015-07-07 11:20:34767 initial_process_noise[0] = 1e-13;
Stefan Holmer86479222015-07-10 09:28:37768 initial_process_noise[1] = 1e-2;
astor@webrtc.orgbd7aeba2012-06-26 10:47:04769 }
770 double initial_slope;
771 double initial_offset;
772 double initial_e[2][2];
773 double initial_process_noise[2];
774 double initial_avg_noise;
775 double initial_var_noise;
astor@webrtc.orgbd7aeba2012-06-26 10:47:04776};
andrew@webrtc.orgeda189b2013-09-09 17:50:10777
wu@webrtc.orga9890802013-12-13 00:21:03778// This structure will have the information about when packet is actually
779// received by socket.
780struct PacketTime {
henrike@webrtc.org82d3cb62014-04-29 17:50:47781 PacketTime() : timestamp(-1), not_before(-1) {}
782 PacketTime(int64_t timestamp, int64_t not_before)
783 : timestamp(timestamp), not_before(not_before) {
wu@webrtc.orga9890802013-12-13 00:21:03784 }
785
henrike@webrtc.org82d3cb62014-04-29 17:50:47786 int64_t timestamp; // Receive time after socket delivers the data.
787 int64_t not_before; // Earliest possible time the data could have arrived,
788 // indicating the potential error in the |timestamp|
789 // value,in case the system is busy.
790 // For example, the time of the last select() call.
791 // If unknown, this value will be set to zero.
wu@webrtc.orga9890802013-12-13 00:21:03792};
793
solenberg@webrtc.orgb1f50102014-03-24 10:38:25794struct RTPHeaderExtension {
sprang@webrtc.org30933902015-03-17 14:33:12795 RTPHeaderExtension();
solenberg@webrtc.orgb1f50102014-03-24 10:38:25796
797 bool hasTransmissionTimeOffset;
798 int32_t transmissionTimeOffset;
799 bool hasAbsoluteSendTime;
800 uint32_t absoluteSendTime;
sprang@webrtc.org30933902015-03-17 14:33:12801 bool hasTransportSequenceNumber;
802 uint16_t transportSequenceNumber;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25803
804 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
805 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
806 bool hasAudioLevel;
807 uint8_t audioLevel;
guoweis@webrtc.org45362892015-03-04 22:55:15808
809 // For Coordination of Video Orientation. See
810 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
811 // ts_126114v120700p.pdf
812 bool hasVideoRotation;
813 uint8_t videoRotation;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25814};
815
816struct RTPHeader {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22817 RTPHeader();
solenberg@webrtc.orgb1f50102014-03-24 10:38:25818
819 bool markerBit;
820 uint8_t payloadType;
821 uint16_t sequenceNumber;
822 uint32_t timestamp;
823 uint32_t ssrc;
824 uint8_t numCSRCs;
825 uint32_t arrOfCSRCs[kRtpCsrcSize];
pkasting@chromium.org4591fbd2014-11-20 22:28:14826 size_t paddingLength;
827 size_t headerLength;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25828 int payload_type_frequency;
829 RTPHeaderExtension extension;
830};
831
asapersson@webrtc.org44149392015-02-04 08:34:47832struct RtpPacketCounter {
833 RtpPacketCounter()
834 : header_bytes(0),
835 payload_bytes(0),
836 padding_bytes(0),
837 packets(0) {}
838
839 void Add(const RtpPacketCounter& other) {
840 header_bytes += other.header_bytes;
841 payload_bytes += other.payload_bytes;
842 padding_bytes += other.padding_bytes;
843 packets += other.packets;
844 }
845
846 void AddPacket(size_t packet_length, const RTPHeader& header) {
847 ++packets;
848 header_bytes += header.headerLength;
849 padding_bytes += header.paddingLength;
850 payload_bytes +=
851 packet_length - (header.headerLength + header.paddingLength);
852 }
853
854 size_t TotalBytes() const {
855 return header_bytes + payload_bytes + padding_bytes;
856 }
857
858 size_t header_bytes; // Number of bytes used by RTP headers.
859 size_t payload_bytes; // Payload bytes, excluding RTP headers and padding.
860 size_t padding_bytes; // Number of padding bytes.
861 uint32_t packets; // Number of packets.
862};
863
864// Data usage statistics for a (rtp) stream.
865struct StreamDataCounters {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22866 StreamDataCounters();
asapersson@webrtc.org44149392015-02-04 08:34:47867
868 void Add(const StreamDataCounters& other) {
869 transmitted.Add(other.transmitted);
870 retransmitted.Add(other.retransmitted);
871 fec.Add(other.fec);
872 if (other.first_packet_time_ms != -1 &&
873 (other.first_packet_time_ms < first_packet_time_ms ||
874 first_packet_time_ms == -1)) {
875 // Use oldest time.
876 first_packet_time_ms = other.first_packet_time_ms;
877 }
878 }
879
880 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
881 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
882 }
883
884 // Returns the number of bytes corresponding to the actual media payload (i.e.
885 // RTP headers, padding, retransmissions and fec packets are excluded).
886 // Note this function does not have meaning for an RTX stream.
887 size_t MediaPayloadBytes() const {
888 return transmitted.payload_bytes - retransmitted.payload_bytes -
889 fec.payload_bytes;
890 }
891
892 int64_t first_packet_time_ms; // Time when first packet is sent/received.
893 RtpPacketCounter transmitted; // Number of transmitted packets/bytes.
894 RtpPacketCounter retransmitted; // Number of retransmitted packets/bytes.
895 RtpPacketCounter fec; // Number of redundancy packets/bytes.
896};
897
898// Callback, called whenever byte/packet counts have been updated.
899class StreamDataCountersCallback {
900 public:
901 virtual ~StreamDataCountersCallback() {}
902
903 virtual void DataCountersUpdated(const StreamDataCounters& counters,
904 uint32_t ssrc) = 0;
905};
niklase@google.com470e71d2011-07-07 08:21:25906} // namespace webrtc
andrew@webrtc.orgeda189b2013-09-09 17:50:10907
908#endif // WEBRTC_COMMON_TYPES_H_