blob: 2999bc95bc82a353fd820e87506059c29d552d8c [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
pbos22993e12015-10-19 09:39:06159enum FrameType {
160 kEmptyFrame = 0,
161 kAudioFrameSpeech = 1,
162 kAudioFrameCN = 2,
163 kVideoFrameKey = 3,
164 kVideoFrameDelta = 4,
sprang@webrtc.org71f055f2013-12-04 15:09:27165};
166
sprang@webrtc.orgdc50aae2013-11-20 16:47:07167// Statistics for an RTCP channel
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07168struct RtcpStatistics {
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07169 RtcpStatistics()
170 : fraction_lost(0),
171 cumulative_lost(0),
172 extended_max_sequence_number(0),
sprang@webrtc.orga6ad6e52013-12-05 09:48:44173 jitter(0) {}
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07174
175 uint8_t fraction_lost;
176 uint32_t cumulative_lost;
177 uint32_t extended_max_sequence_number;
178 uint32_t jitter;
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07179};
180
sprang@webrtc.orgdc50aae2013-11-20 16:47:07181class RtcpStatisticsCallback {
182 public:
183 virtual ~RtcpStatisticsCallback() {}
184
185 virtual void StatisticsUpdated(const RtcpStatistics& statistics,
186 uint32_t ssrc) = 0;
pbos@webrtc.orgce4e9a32014-12-18 13:50:16187 virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07188};
189
asapersson@webrtc.org8098e072014-02-19 11:59:02190// Statistics for RTCP packet types.
191struct RtcpPacketTypeCounter {
192 RtcpPacketTypeCounter()
asapersson@webrtc.orgd08d3892014-12-16 12:03:11193 : first_packet_time_ms(-1),
194 nack_packets(0),
asapersson@webrtc.org8098e072014-02-19 11:59:02195 fir_packets(0),
asapersson@webrtc.org2dd31342014-10-29 12:42:30196 pli_packets(0),
197 nack_requests(0),
198 unique_nack_requests(0) {}
asapersson@webrtc.org8098e072014-02-19 11:59:02199
200 void Add(const RtcpPacketTypeCounter& other) {
201 nack_packets += other.nack_packets;
202 fir_packets += other.fir_packets;
203 pli_packets += other.pli_packets;
asapersson@webrtc.org2dd31342014-10-29 12:42:30204 nack_requests += other.nack_requests;
205 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.orgd08d3892014-12-16 12:03:11206 if (other.first_packet_time_ms != -1 &&
207 (other.first_packet_time_ms < first_packet_time_ms ||
208 first_packet_time_ms == -1)) {
209 // Use oldest time.
210 first_packet_time_ms = other.first_packet_time_ms;
211 }
212 }
213
sprang07fb9be2016-02-24 15:55:00214 void Subtract(const RtcpPacketTypeCounter& other) {
215 nack_packets -= other.nack_packets;
216 fir_packets -= other.fir_packets;
217 pli_packets -= other.pli_packets;
218 nack_requests -= other.nack_requests;
219 unique_nack_requests -= other.unique_nack_requests;
220 if (other.first_packet_time_ms != -1 &&
221 (other.first_packet_time_ms > first_packet_time_ms ||
222 first_packet_time_ms == -1)) {
223 // Use youngest time.
224 first_packet_time_ms = other.first_packet_time_ms;
225 }
226 }
227
asapersson@webrtc.orgd08d3892014-12-16 12:03:11228 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
229 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
asapersson@webrtc.org8098e072014-02-19 11:59:02230 }
231
asapersson@webrtc.org2dd31342014-10-29 12:42:30232 int UniqueNackRequestsInPercent() const {
233 if (nack_requests == 0) {
234 return 0;
235 }
236 return static_cast<int>(
237 (unique_nack_requests * 100.0f / nack_requests) + 0.5f);
238 }
239
asapersson@webrtc.orgd08d3892014-12-16 12:03:11240 int64_t first_packet_time_ms; // Time when first packet is sent/received.
241 uint32_t nack_packets; // Number of RTCP NACK packets.
242 uint32_t fir_packets; // Number of RTCP FIR packets.
243 uint32_t pli_packets; // Number of RTCP PLI packets.
244 uint32_t nack_requests; // Number of NACKed RTP packets.
asapersson@webrtc.org2dd31342014-10-29 12:42:30245 uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
asapersson@webrtc.org8098e072014-02-19 11:59:02246};
247
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00248class RtcpPacketTypeCounterObserver {
249 public:
250 virtual ~RtcpPacketTypeCounterObserver() {}
251 virtual void RtcpPacketTypesCounterUpdated(
252 uint32_t ssrc,
253 const RtcpPacketTypeCounter& packet_counter) = 0;
254};
255
asapersson@webrtc.orgd08d3892014-12-16 12:03:11256// Rate statistics for a stream.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07257struct BitrateStatistics {
sprang@webrtc.org6811b6e2013-12-13 09:46:59258 BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
sprang@webrtc.orgdc50aae2013-11-20 16:47:07259
sprang@webrtc.org6811b6e2013-12-13 09:46:59260 uint32_t bitrate_bps; // Bitrate in bits per second.
261 uint32_t packet_rate; // Packet rate in packets per second.
262 uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07263};
264
265// Callback, used to notify an observer whenever new rates have been estimated.
266class BitrateStatisticsObserver {
267 public:
268 virtual ~BitrateStatisticsObserver() {}
269
stefan@webrtc.org0bae1fa2014-11-05 14:05:29270 virtual void Notify(const BitrateStatistics& total_stats,
271 const BitrateStatistics& retransmit_stats,
272 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07273};
274
pbos@webrtc.orgce4e9a32014-12-18 13:50:16275struct FrameCounts {
276 FrameCounts() : key_frames(0), delta_frames(0) {}
277 int key_frames;
278 int delta_frames;
279};
280
asapersson@webrtc.orgd08d3892014-12-16 12:03:11281// Callback, used to notify an observer whenever frame counts have been updated.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07282class FrameCountObserver {
283 public:
sprang@webrtc.org72964bd2013-11-21 09:09:54284 virtual ~FrameCountObserver() {}
pbos@webrtc.orgce4e9a32014-12-18 13:50:16285 virtual void FrameCountUpdated(const FrameCounts& frame_counts,
286 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07287};
288
stefan@webrtc.org168f23f2014-07-11 13:44:02289// Callback, used to notify an observer whenever the send-side delay is updated.
290class SendSideDelayObserver {
291 public:
292 virtual ~SendSideDelayObserver() {}
293 virtual void SendSideDelayUpdated(int avg_delay_ms,
294 int max_delay_ms,
295 uint32_t ssrc) = 0;
296};
297
niklase@google.com470e71d2011-07-07 08:21:25298// ==================================================================
299// Voice specific types
300// ==================================================================
301
302// Each codec supported can be described by this structure.
mallinath@webrtc.org0209e562014-03-21 00:41:28303struct CodecInst {
304 int pltype;
305 char plname[RTP_PAYLOAD_NAME_SIZE];
306 int plfreq;
307 int pacsize;
Peter Kasting69558702016-01-13 00:26:35308 size_t channels;
mallinath@webrtc.org0209e562014-03-21 00:41:28309 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
310
311 bool operator==(const CodecInst& other) const {
312 return pltype == other.pltype &&
313 (STR_CASE_CMP(plname, other.plname) == 0) &&
314 plfreq == other.plfreq &&
315 pacsize == other.pacsize &&
316 channels == other.channels &&
317 rate == other.rate;
318 }
319
320 bool operator!=(const CodecInst& other) const {
321 return !(*this == other);
322 }
niklase@google.com470e71d2011-07-07 08:21:25323};
324
niklase@google.com470e71d2011-07-07 08:21:25325// RTP
326enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
327
niklase@google.com470e71d2011-07-07 08:21:25328enum PayloadFrequencies
329{
330 kFreq8000Hz = 8000,
331 kFreq16000Hz = 16000,
332 kFreq32000Hz = 32000
333};
334
335enum VadModes // degree of bandwidth reduction
336{
337 kVadConventional = 0, // lowest reduction
338 kVadAggressiveLow,
339 kVadAggressiveMid,
340 kVadAggressiveHigh // highest reduction
341};
342
343struct NetworkStatistics // NETEQ statistics
344{
345 // current jitter buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11346 uint16_t currentBufferSize;
niklase@google.com470e71d2011-07-07 08:21:25347 // preferred (optimal) buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11348 uint16_t preferredBufferSize;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55349 // adding extra delay due to "peaky jitter"
350 bool jitterPeaksFound;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45351 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11352 uint16_t currentPacketLossRate;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45353 // Late loss rate; fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11354 uint16_t currentDiscardRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13355 // fraction (of original stream) of synthesized audio inserted through
niklase@google.com470e71d2011-07-07 08:21:25356 // expansion (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11357 uint16_t currentExpandRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13358 // fraction (of original stream) of synthesized speech inserted through
359 // expansion (in Q14)
360 uint16_t currentSpeechExpandRate;
niklase@google.com470e71d2011-07-07 08:21:25361 // fraction of synthesized speech inserted through pre-emptive expansion
362 // (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11363 uint16_t currentPreemptiveRate;
niklase@google.com470e71d2011-07-07 08:21:25364 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11365 uint16_t currentAccelerateRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13366 // fraction of data coming from secondary decoding (in Q14)
367 uint16_t currentSecondaryDecodedRate;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55368 // clock-drift in parts-per-million (negative or positive)
369 int32_t clockDriftPPM;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05370 // average packet waiting time in the jitter buffer (ms)
371 int meanWaitingTimeMs;
372 // median packet waiting time in the jitter buffer (ms)
373 int medianWaitingTimeMs;
henrik.lundin@webrtc.org053c7992012-01-12 14:16:44374 // min packet waiting time in the jitter buffer (ms)
375 int minWaitingTimeMs;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05376 // max packet waiting time in the jitter buffer (ms)
377 int maxWaitingTimeMs;
roosa@google.comb8ba4d82012-12-14 00:06:18378 // added samples in off mode due to packet loss
Peter Kastingdce40cf2015-08-24 21:52:23379 size_t addedSamples;
niklase@google.com470e71d2011-07-07 08:21:25380};
381
wu@webrtc.org24301a62013-12-13 19:17:43382// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
383struct AudioDecodingCallStats {
384 AudioDecodingCallStats()
385 : calls_to_silence_generator(0),
386 calls_to_neteq(0),
387 decoded_normal(0),
388 decoded_plc(0),
389 decoded_cng(0),
390 decoded_plc_cng(0) {}
391
392 int calls_to_silence_generator; // Number of calls where silence generated,
393 // and NetEq was disengaged from decoding.
394 int calls_to_neteq; // Number of calls to NetEq.
395 int decoded_normal; // Number of calls where audio RTP packet decoded.
396 int decoded_plc; // Number of calls resulted in PLC.
397 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
398 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
399};
400
niklase@google.com470e71d2011-07-07 08:21:25401typedef struct
402{
403 int min; // minumum
404 int max; // maximum
405 int average; // average
406} StatVal;
407
408typedef struct // All levels are reported in dBm0
409{
410 StatVal speech_rx; // long-term speech levels on receiving side
411 StatVal speech_tx; // long-term speech levels on transmitting side
412 StatVal noise_rx; // long-term noise/silence levels on receiving side
413 StatVal noise_tx; // long-term noise/silence levels on transmitting side
414} LevelStatistics;
415
416typedef struct // All levels are reported in dB
417{
418 StatVal erl; // Echo Return Loss
419 StatVal erle; // Echo Return Loss Enhancement
420 StatVal rerl; // RERL = ERL + ERLE
421 // Echo suppression inside EC at the point just before its NLP
422 StatVal a_nlp;
423} EchoStatistics;
424
niklase@google.com470e71d2011-07-07 08:21:25425enum NsModes // type of Noise Suppression
426{
427 kNsUnchanged = 0, // previously set mode
428 kNsDefault, // platform default
429 kNsConference, // conferencing default
430 kNsLowSuppression, // lowest suppression
431 kNsModerateSuppression,
432 kNsHighSuppression,
433 kNsVeryHighSuppression, // highest suppression
434};
435
436enum AgcModes // type of Automatic Gain Control
437{
438 kAgcUnchanged = 0, // previously set mode
439 kAgcDefault, // platform default
440 // adaptive mode for use when analog volume control exists (e.g. for
441 // PC softphone)
442 kAgcAdaptiveAnalog,
443 // scaling takes place in the digital domain (e.g. for conference servers
444 // and embedded devices)
445 kAgcAdaptiveDigital,
andrew@webrtc.org80124742012-03-08 17:54:24446 // can be used on embedded devices where the capture signal level
niklase@google.com470e71d2011-07-07 08:21:25447 // is predictable
448 kAgcFixedDigital
449};
450
451// EC modes
452enum EcModes // type of Echo Control
453{
454 kEcUnchanged = 0, // previously set mode
455 kEcDefault, // platform default
456 kEcConference, // conferencing default (aggressive AEC)
457 kEcAec, // Acoustic Echo Cancellation
458 kEcAecm, // AEC mobile
459};
460
461// AECM modes
462enum AecmModes // mode of AECM
463{
464 kAecmQuietEarpieceOrHeadset = 0,
465 // Quiet earpiece or headset use
466 kAecmEarpiece, // most earpiece use
467 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
468 kAecmSpeakerphone, // most speakerphone use (default)
469 kAecmLoudSpeakerphone // Loud speakerphone
470};
471
472// AGC configuration
473typedef struct
474{
475 unsigned short targetLeveldBOv;
476 unsigned short digitalCompressionGaindB;
477 bool limiterEnable;
478} AgcConfig; // AGC configuration parameters
479
480enum StereoChannel
481{
482 kStereoLeft = 0,
483 kStereoRight,
484 kStereoBoth
485};
486
487// Audio device layers
488enum AudioLayers
489{
490 kAudioPlatformDefault = 0,
491 kAudioWindowsWave = 1,
492 kAudioWindowsCore = 2,
493 kAudioLinuxAlsa = 3,
494 kAudioLinuxPulse = 4
495};
496
henrika@webrtc.org66803482014-04-17 10:45:01497// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25498enum NetEqModes // NetEQ playout configurations
499{
500 // Optimized trade-off between low delay and jitter robustness for two-way
501 // communication.
502 kNetEqDefault = 0,
503 // Improved jitter robustness at the cost of increased delay. Can be
504 // used in one-way communication.
505 kNetEqStreaming = 1,
506 // Optimzed for decodability of fax signals rather than for perceived audio
507 // quality.
508 kNetEqFax = 2,
roosa@google.comb7186192012-12-12 21:59:14509 // Minimal buffer management. Inserts zeros for lost packets and during
510 // buffer increases.
511 kNetEqOff = 3,
niklase@google.com470e71d2011-07-07 08:21:25512};
513
henrika@webrtc.org66803482014-04-17 10:45:01514// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25515enum OnHoldModes // On Hold direction
516{
517 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
518 kHoldSendOnly, // Put only sending in on-hold state.
519 kHoldPlayOnly // Put only playing in on-hold state.
520};
521
henrika@webrtc.org66803482014-04-17 10:45:01522// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25523enum AmrMode
524{
525 kRfc3267BwEfficient = 0,
526 kRfc3267OctetAligned = 1,
527 kRfc3267FileStorage = 2,
528};
529
530// ==================================================================
531// Video specific types
532// ==================================================================
533
534// Raw video types
535enum RawVideoType
536{
537 kVideoI420 = 0,
538 kVideoYV12 = 1,
539 kVideoYUY2 = 2,
540 kVideoUYVY = 3,
541 kVideoIYUV = 4,
542 kVideoARGB = 5,
543 kVideoRGB24 = 6,
544 kVideoRGB565 = 7,
545 kVideoARGB4444 = 8,
546 kVideoARGB1555 = 9,
547 kVideoMJPEG = 10,
548 kVideoNV12 = 11,
549 kVideoNV21 = 12,
mikhal@webrtc.orgc00f91d2012-01-03 18:49:15550 kVideoBGRA = 13,
niklase@google.com470e71d2011-07-07 08:21:25551 kVideoUnknown = 99
552};
553
554// Video codec
555enum { kConfigParameterSize = 128};
556enum { kPayloadNameSize = 32};
pwestin@webrtc.org1da1ce02011-10-13 15:19:55557enum { kMaxSimulcastStreams = 4};
sprangce4aef12015-11-02 15:23:20558enum { kMaxSpatialLayers = 5 };
pwestin@webrtc.orgdb221d22011-12-02 11:31:08559enum { kMaxTemporalStreams = 4};
niklase@google.com470e71d2011-07-07 08:21:25560
niklase@google.com470e71d2011-07-07 08:21:25561enum VideoCodecComplexity
562{
563 kComplexityNormal = 0,
564 kComplexityHigh = 1,
565 kComplexityHigher = 2,
566 kComplexityMax = 3
567};
568
569enum VideoCodecProfile
570{
571 kProfileBase = 0x00,
572 kProfileMain = 0x01
573};
574
stefan@webrtc.orgefd0a482011-12-29 10:12:35575enum VP8ResilienceMode {
576 kResilienceOff, // The stream produced by the encoder requires a
577 // recovery frame (typically a key frame) to be
578 // decodable after a packet loss.
579 kResilientStream, // A stream produced by the encoder is resilient to
580 // packet losses, but packets within a frame subsequent
581 // to a loss can't be decoded.
582 kResilientFrames // Same as kResilientStream but with added resilience
583 // within a frame.
584};
585
Peter Boström7b971e72016-01-19 15:26:16586class TemporalLayersFactory;
niklase@google.com470e71d2011-07-07 08:21:25587// VP8 specific
mallinath@webrtc.org0209e562014-03-21 00:41:28588struct VideoCodecVP8 {
589 bool pictureLossIndicationOn;
590 bool feedbackModeOn;
591 VideoCodecComplexity complexity;
592 VP8ResilienceMode resilience;
593 unsigned char numberOfTemporalLayers;
594 bool denoisingOn;
595 bool errorConcealmentOn;
596 bool automaticResizeOn;
597 bool frameDroppingOn;
598 int keyFrameInterval;
Peter Boström7b971e72016-01-19 15:26:16599 const TemporalLayersFactory* tl_factory;
niklase@google.com470e71d2011-07-07 08:21:25600};
601
asaperssona9455ab2015-07-31 13:10:09602// VP9 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48603struct VideoCodecVP9 {
604 VideoCodecComplexity complexity;
605 int resilience;
606 unsigned char numberOfTemporalLayers;
607 bool denoisingOn;
608 bool frameDroppingOn;
609 int keyFrameInterval;
610 bool adaptiveQpMode;
Marcof3507202015-09-17 19:16:04611 bool automaticResizeOn;
asaperssona9455ab2015-07-31 13:10:09612 unsigned char numberOfSpatialLayers;
613 bool flexibleMode;
marpan@webrtc.org5b883172014-11-01 06:10:48614};
615
stefan@webrtc.orgb9f54532014-07-04 12:42:07616// H264 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48617struct VideoCodecH264 {
618 VideoCodecProfile profile;
619 bool frameDroppingOn;
620 int keyFrameInterval;
621 // These are NULL/0 if not externally negotiated.
622 const uint8_t* spsData;
623 size_t spsLen;
624 const uint8_t* ppsData;
625 size_t ppsLen;
stefan@webrtc.orgb9f54532014-07-04 12:42:07626};
627
niklase@google.com470e71d2011-07-07 08:21:25628// Video codec types
marpan@webrtc.org5b883172014-11-01 06:10:48629enum VideoCodecType {
630 kVideoCodecVP8,
631 kVideoCodecVP9,
632 kVideoCodecH264,
633 kVideoCodecI420,
634 kVideoCodecRED,
635 kVideoCodecULPFEC,
636 kVideoCodecGeneric,
637 kVideoCodecUnknown
niklase@google.com470e71d2011-07-07 08:21:25638};
639
marpan@webrtc.org5b883172014-11-01 06:10:48640union VideoCodecUnion {
641 VideoCodecVP8 VP8;
642 VideoCodecVP9 VP9;
643 VideoCodecH264 H264;
niklase@google.com470e71d2011-07-07 08:21:25644};
645
phoglund@webrtc.org8bfee842012-02-17 09:32:48646
647// Simulcast is when the same stream is encoded multiple times with different
648// settings such as resolution.
mallinath@webrtc.org0209e562014-03-21 00:41:28649struct SimulcastStream {
650 unsigned short width;
651 unsigned short height;
652 unsigned char numberOfTemporalLayers;
653 unsigned int maxBitrate; // kilobits/sec.
654 unsigned int targetBitrate; // kilobits/sec.
655 unsigned int minBitrate; // kilobits/sec.
656 unsigned int qpMax; // minimum quality
pwestin@webrtc.org1da1ce02011-10-13 15:19:55657};
658
sprangce4aef12015-11-02 15:23:20659struct SpatialLayer {
660 int scaling_factor_num;
661 int scaling_factor_den;
662 int target_bitrate_bps;
663 // TODO(ivica): Add max_quantizer and min_quantizer?
664};
665
stefan@webrtc.orgeb917922013-02-18 14:40:18666enum VideoCodecMode {
667 kRealtimeVideo,
668 kScreensharing
669};
670
niklase@google.com470e71d2011-07-07 08:21:25671// Common video codec properties
mallinath@webrtc.org0209e562014-03-21 00:41:28672struct VideoCodec {
673 VideoCodecType codecType;
674 char plName[kPayloadNameSize];
675 unsigned char plType;
niklase@google.com470e71d2011-07-07 08:21:25676
mallinath@webrtc.org0209e562014-03-21 00:41:28677 unsigned short width;
678 unsigned short height;
niklase@google.com470e71d2011-07-07 08:21:25679
mallinath@webrtc.org0209e562014-03-21 00:41:28680 unsigned int startBitrate; // kilobits/sec.
681 unsigned int maxBitrate; // kilobits/sec.
682 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org3c412b22014-03-24 12:36:52683 unsigned int targetBitrate; // kilobits/sec.
684
mallinath@webrtc.org0209e562014-03-21 00:41:28685 unsigned char maxFramerate;
niklase@google.com470e71d2011-07-07 08:21:25686
mallinath@webrtc.org0209e562014-03-21 00:41:28687 VideoCodecUnion codecSpecific;
niklase@google.com470e71d2011-07-07 08:21:25688
mallinath@webrtc.org0209e562014-03-21 00:41:28689 unsigned int qpMax;
690 unsigned char numberOfSimulcastStreams;
691 SimulcastStream simulcastStream[kMaxSimulcastStreams];
sprangce4aef12015-11-02 15:23:20692 SpatialLayer spatialLayers[kMaxSpatialLayers];
stefan@webrtc.orgeb917922013-02-18 14:40:18693
mallinath@webrtc.org0209e562014-03-21 00:41:28694 VideoCodecMode mode;
andresp@webrtc.org185bae42013-05-14 08:02:25695
Peter Boström7b971e72016-01-19 15:26:16696 bool operator==(const VideoCodec& other) const = delete;
697 bool operator!=(const VideoCodec& other) const = delete;
niklase@google.com470e71d2011-07-07 08:21:25698};
astor@webrtc.orgbd7aeba2012-06-26 10:47:04699
stefan64c0a0a2015-11-27 09:02:31700// Bandwidth over-use detector options. These are used to drive
701// experimentation with bandwidth estimation parameters.
702// See modules/remote_bitrate_estimator/overuse_detector.h
703struct OverUseDetectorOptions {
704 OverUseDetectorOptions()
705 : initial_slope(8.0/512.0),
706 initial_offset(0),
707 initial_e(),
708 initial_process_noise(),
709 initial_avg_noise(0.0),
710 initial_var_noise(50) {
711 initial_e[0][0] = 100;
712 initial_e[1][1] = 1e-1;
713 initial_e[0][1] = initial_e[1][0] = 0;
714 initial_process_noise[0] = 1e-13;
715 initial_process_noise[1] = 1e-2;
716 }
717 double initial_slope;
718 double initial_offset;
719 double initial_e[2][2];
720 double initial_process_noise[2];
721 double initial_avg_noise;
722 double initial_var_noise;
723};
724
wu@webrtc.orga9890802013-12-13 00:21:03725// This structure will have the information about when packet is actually
726// received by socket.
727struct PacketTime {
henrike@webrtc.org82d3cb62014-04-29 17:50:47728 PacketTime() : timestamp(-1), not_before(-1) {}
729 PacketTime(int64_t timestamp, int64_t not_before)
730 : timestamp(timestamp), not_before(not_before) {
wu@webrtc.orga9890802013-12-13 00:21:03731 }
732
henrike@webrtc.org82d3cb62014-04-29 17:50:47733 int64_t timestamp; // Receive time after socket delivers the data.
734 int64_t not_before; // Earliest possible time the data could have arrived,
735 // indicating the potential error in the |timestamp|
736 // value,in case the system is busy.
737 // For example, the time of the last select() call.
738 // If unknown, this value will be set to zero.
wu@webrtc.orga9890802013-12-13 00:21:03739};
740
solenberg@webrtc.orgb1f50102014-03-24 10:38:25741struct RTPHeaderExtension {
sprang@webrtc.org30933902015-03-17 14:33:12742 RTPHeaderExtension();
solenberg@webrtc.orgb1f50102014-03-24 10:38:25743
744 bool hasTransmissionTimeOffset;
745 int32_t transmissionTimeOffset;
746 bool hasAbsoluteSendTime;
747 uint32_t absoluteSendTime;
sprang@webrtc.org30933902015-03-17 14:33:12748 bool hasTransportSequenceNumber;
749 uint16_t transportSequenceNumber;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25750
751 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
752 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
753 bool hasAudioLevel;
Minyue4cee4192015-08-10 13:08:36754 bool voiceActivity;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25755 uint8_t audioLevel;
guoweis@webrtc.org45362892015-03-04 22:55:15756
757 // For Coordination of Video Orientation. See
758 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
759 // ts_126114v120700p.pdf
760 bool hasVideoRotation;
761 uint8_t videoRotation;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25762};
763
764struct RTPHeader {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22765 RTPHeader();
solenberg@webrtc.orgb1f50102014-03-24 10:38:25766
767 bool markerBit;
768 uint8_t payloadType;
769 uint16_t sequenceNumber;
770 uint32_t timestamp;
771 uint32_t ssrc;
772 uint8_t numCSRCs;
773 uint32_t arrOfCSRCs[kRtpCsrcSize];
pkasting@chromium.org4591fbd2014-11-20 22:28:14774 size_t paddingLength;
775 size_t headerLength;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25776 int payload_type_frequency;
777 RTPHeaderExtension extension;
778};
779
asapersson@webrtc.org44149392015-02-04 08:34:47780struct RtpPacketCounter {
781 RtpPacketCounter()
782 : header_bytes(0),
783 payload_bytes(0),
784 padding_bytes(0),
785 packets(0) {}
786
787 void Add(const RtpPacketCounter& other) {
788 header_bytes += other.header_bytes;
789 payload_bytes += other.payload_bytes;
790 padding_bytes += other.padding_bytes;
791 packets += other.packets;
792 }
793
794 void AddPacket(size_t packet_length, const RTPHeader& header) {
795 ++packets;
796 header_bytes += header.headerLength;
797 padding_bytes += header.paddingLength;
798 payload_bytes +=
799 packet_length - (header.headerLength + header.paddingLength);
800 }
801
802 size_t TotalBytes() const {
803 return header_bytes + payload_bytes + padding_bytes;
804 }
805
806 size_t header_bytes; // Number of bytes used by RTP headers.
807 size_t payload_bytes; // Payload bytes, excluding RTP headers and padding.
808 size_t padding_bytes; // Number of padding bytes.
809 uint32_t packets; // Number of packets.
810};
811
812// Data usage statistics for a (rtp) stream.
813struct StreamDataCounters {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22814 StreamDataCounters();
asapersson@webrtc.org44149392015-02-04 08:34:47815
816 void Add(const StreamDataCounters& other) {
817 transmitted.Add(other.transmitted);
818 retransmitted.Add(other.retransmitted);
819 fec.Add(other.fec);
820 if (other.first_packet_time_ms != -1 &&
821 (other.first_packet_time_ms < first_packet_time_ms ||
822 first_packet_time_ms == -1)) {
823 // Use oldest time.
824 first_packet_time_ms = other.first_packet_time_ms;
825 }
826 }
827
828 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
829 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
830 }
831
832 // Returns the number of bytes corresponding to the actual media payload (i.e.
833 // RTP headers, padding, retransmissions and fec packets are excluded).
834 // Note this function does not have meaning for an RTX stream.
835 size_t MediaPayloadBytes() const {
836 return transmitted.payload_bytes - retransmitted.payload_bytes -
837 fec.payload_bytes;
838 }
839
840 int64_t first_packet_time_ms; // Time when first packet is sent/received.
841 RtpPacketCounter transmitted; // Number of transmitted packets/bytes.
842 RtpPacketCounter retransmitted; // Number of retransmitted packets/bytes.
843 RtpPacketCounter fec; // Number of redundancy packets/bytes.
844};
845
846// Callback, called whenever byte/packet counts have been updated.
847class StreamDataCountersCallback {
848 public:
849 virtual ~StreamDataCountersCallback() {}
850
851 virtual void DataCountersUpdated(const StreamDataCounters& counters,
852 uint32_t ssrc) = 0;
853};
pbosda903ea2015-10-02 09:36:56854
855// RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size
856// RTCP mode is described by RFC 5506.
857enum class RtcpMode { kOff, kCompound, kReducedSize };
858
niklase@google.com470e71d2011-07-07 08:21:25859} // namespace webrtc
andrew@webrtc.orgeda189b2013-09-09 17:50:10860
861#endif // WEBRTC_COMMON_TYPES_H_