blob: 02633ba87a481370e3fcb4dcfa8204b63fe35f8c [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
Erik Språng22c2b482016-03-01 08:40:4214#include <assert.h>
pbos@webrtc.orgf577ae92014-03-19 08:43:5715#include <stddef.h>
mallinath@webrtc.org0209e562014-03-21 00:41:2816#include <string.h>
pbos@webrtc.org1e92b0a2014-05-15 09:35:0617
18#include <string>
pbos@webrtc.orgf577ae92014-03-19 08:43:5719#include <vector>
20
andrew@webrtc.orgeda189b2013-09-09 17:50:1021#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:2522
andrew@webrtc.org88b8b0d2012-08-14 00:05:5623#if defined(_MSC_VER)
24// Disable "new behavior: elements of array will be default initialized"
25// warning. Affects OverUseDetectorOptions.
26#pragma warning(disable:4351)
27#endif
28
niklase@google.com470e71d2011-07-07 08:21:2529#ifdef WEBRTC_EXPORT
andrew@webrtc.org88b8b0d2012-08-14 00:05:5630#define WEBRTC_DLLEXPORT _declspec(dllexport)
niklase@google.com470e71d2011-07-07 08:21:2531#elif WEBRTC_DLL
andrew@webrtc.org88b8b0d2012-08-14 00:05:5632#define WEBRTC_DLLEXPORT _declspec(dllimport)
niklase@google.com470e71d2011-07-07 08:21:2533#else
andrew@webrtc.org88b8b0d2012-08-14 00:05:5634#define WEBRTC_DLLEXPORT
niklase@google.com470e71d2011-07-07 08:21:2535#endif
36
37#ifndef NULL
andrew@webrtc.org88b8b0d2012-08-14 00:05:5638#define NULL 0
niklase@google.com470e71d2011-07-07 08:21:2539#endif
40
Peter Boström8b79b072016-02-26 15:31:3741#define RTP_PAYLOAD_NAME_SIZE 32u
henrika@webrtc.orgf75901f2012-01-16 08:45:4242
mallinath@webrtc.org0209e562014-03-21 00:41:2843#if defined(WEBRTC_WIN) || defined(WIN32)
andrew@webrtc.orgeda189b2013-09-09 17:50:1044// Compares two strings without regard to case.
45#define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2)
46// Compares characters of two strings without regard to case.
47#define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n)
48#else
49#define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2)
50#define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n)
51#endif
52
niklase@google.com470e71d2011-07-07 08:21:2553namespace webrtc {
54
andresp@webrtc.org185bae42013-05-14 08:02:2555class Config;
56
niklase@google.com470e71d2011-07-07 08:21:2557class InStream
58{
59public:
kjellander@webrtc.org14665ff2015-03-04 12:58:3560 // Reads |length| bytes from file to |buf|. Returns the number of bytes read
61 // or -1 on error.
pkasting@chromium.org4591fbd2014-11-20 22:28:1462 virtual int Read(void *buf, size_t len) = 0;
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:2263 virtual int Rewind();
niklase@google.com470e71d2011-07-07 08:21:2564 virtual ~InStream() {}
65protected:
66 InStream() {}
67};
68
69class OutStream
70{
71public:
kjellander@webrtc.org14665ff2015-03-04 12:58:3572 // Writes |length| bytes from |buf| to file. The actual writing may happen
73 // some time later. Call Flush() to force a write.
pkasting@chromium.org4591fbd2014-11-20 22:28:1474 virtual bool Write(const void *buf, size_t len) = 0;
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:2275 virtual int Rewind();
niklase@google.com470e71d2011-07-07 08:21:2576 virtual ~OutStream() {}
77protected:
78 OutStream() {}
79};
80
81enum TraceModule
82{
pbos@webrtc.org5ab75672013-12-16 12:24:4483 kTraceUndefined = 0,
niklase@google.com470e71d2011-07-07 08:21:2584 // not a module, triggered from the engine code
pbos@webrtc.org5ab75672013-12-16 12:24:4485 kTraceVoice = 0x0001,
niklase@google.com470e71d2011-07-07 08:21:2586 // not a module, triggered from the engine code
pbos@webrtc.org5ab75672013-12-16 12:24:4487 kTraceVideo = 0x0002,
niklase@google.com470e71d2011-07-07 08:21:2588 // not a module, triggered from the utility code
pbos@webrtc.org5ab75672013-12-16 12:24:4489 kTraceUtility = 0x0003,
90 kTraceRtpRtcp = 0x0004,
91 kTraceTransport = 0x0005,
92 kTraceSrtp = 0x0006,
93 kTraceAudioCoding = 0x0007,
94 kTraceAudioMixerServer = 0x0008,
95 kTraceAudioMixerClient = 0x0009,
96 kTraceFile = 0x000a,
97 kTraceAudioProcessing = 0x000b,
98 kTraceVideoCoding = 0x0010,
99 kTraceVideoMixer = 0x0011,
100 kTraceAudioDevice = 0x0012,
101 kTraceVideoRenderer = 0x0014,
102 kTraceVideoCapture = 0x0015,
pbos@webrtc.org5ab75672013-12-16 12:24:44103 kTraceRemoteBitrateEstimator = 0x0017,
niklase@google.com470e71d2011-07-07 08:21:25104};
105
106enum TraceLevel
107{
108 kTraceNone = 0x0000, // no trace
109 kTraceStateInfo = 0x0001,
110 kTraceWarning = 0x0002,
111 kTraceError = 0x0004,
112 kTraceCritical = 0x0008,
113 kTraceApiCall = 0x0010,
114 kTraceDefault = 0x00ff,
115
116 kTraceModuleCall = 0x0020,
117 kTraceMemory = 0x0100, // memory info
118 kTraceTimer = 0x0200, // timing info
119 kTraceStream = 0x0400, // "continuous" stream of data
120
121 // used for debug purposes
122 kTraceDebug = 0x0800, // debug
123 kTraceInfo = 0x1000, // debug info
124
andrew@webrtc.org655d8f52012-11-20 07:34:45125 // Non-verbose level used by LS_INFO of logging.h. Do not use directly.
126 kTraceTerseInfo = 0x2000,
127
niklase@google.com470e71d2011-07-07 08:21:25128 kTraceAll = 0xffff
129};
130
131// External Trace API
andrew@webrtc.org23ec30b2012-11-15 05:33:25132class TraceCallback {
133 public:
134 virtual void Print(TraceLevel level, const char* message, int length) = 0;
niklase@google.com470e71d2011-07-07 08:21:25135
andrew@webrtc.org23ec30b2012-11-15 05:33:25136 protected:
137 virtual ~TraceCallback() {}
138 TraceCallback() {}
139};
niklase@google.com470e71d2011-07-07 08:21:25140
141enum FileFormats
142{
143 kFileFormatWavFile = 1,
144 kFileFormatCompressedFile = 2,
niklase@google.com470e71d2011-07-07 08:21:25145 kFileFormatPreencodedFile = 4,
146 kFileFormatPcm16kHzFile = 7,
147 kFileFormatPcm8kHzFile = 8,
148 kFileFormatPcm32kHzFile = 9
149};
150
niklase@google.com470e71d2011-07-07 08:21:25151enum ProcessingTypes
152{
153 kPlaybackPerChannel = 0,
154 kPlaybackAllChannelsMixed,
155 kRecordingPerChannel,
andrew@webrtc.org21ab3ba2012-10-19 17:30:56156 kRecordingAllChannelsMixed,
157 kRecordingPreprocessing
niklase@google.com470e71d2011-07-07 08:21:25158};
159
pbos22993e12015-10-19 09:39:06160enum FrameType {
161 kEmptyFrame = 0,
162 kAudioFrameSpeech = 1,
163 kAudioFrameCN = 2,
164 kVideoFrameKey = 3,
165 kVideoFrameDelta = 4,
sprang@webrtc.org71f055f2013-12-04 15:09:27166};
167
sprang@webrtc.orgdc50aae2013-11-20 16:47:07168// Statistics for an RTCP channel
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07169struct RtcpStatistics {
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07170 RtcpStatistics()
171 : fraction_lost(0),
172 cumulative_lost(0),
173 extended_max_sequence_number(0),
sprang@webrtc.orga6ad6e52013-12-05 09:48:44174 jitter(0) {}
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07175
176 uint8_t fraction_lost;
177 uint32_t cumulative_lost;
178 uint32_t extended_max_sequence_number;
179 uint32_t jitter;
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07180};
181
sprang@webrtc.orgdc50aae2013-11-20 16:47:07182class RtcpStatisticsCallback {
183 public:
184 virtual ~RtcpStatisticsCallback() {}
185
186 virtual void StatisticsUpdated(const RtcpStatistics& statistics,
187 uint32_t ssrc) = 0;
pbos@webrtc.orgce4e9a32014-12-18 13:50:16188 virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07189};
190
asapersson@webrtc.org8098e072014-02-19 11:59:02191// Statistics for RTCP packet types.
192struct RtcpPacketTypeCounter {
193 RtcpPacketTypeCounter()
asapersson@webrtc.orgd08d3892014-12-16 12:03:11194 : first_packet_time_ms(-1),
195 nack_packets(0),
asapersson@webrtc.org8098e072014-02-19 11:59:02196 fir_packets(0),
asapersson@webrtc.org2dd31342014-10-29 12:42:30197 pli_packets(0),
198 nack_requests(0),
199 unique_nack_requests(0) {}
asapersson@webrtc.org8098e072014-02-19 11:59:02200
201 void Add(const RtcpPacketTypeCounter& other) {
202 nack_packets += other.nack_packets;
203 fir_packets += other.fir_packets;
204 pli_packets += other.pli_packets;
asapersson@webrtc.org2dd31342014-10-29 12:42:30205 nack_requests += other.nack_requests;
206 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.orgd08d3892014-12-16 12:03:11207 if (other.first_packet_time_ms != -1 &&
208 (other.first_packet_time_ms < first_packet_time_ms ||
209 first_packet_time_ms == -1)) {
210 // Use oldest time.
211 first_packet_time_ms = other.first_packet_time_ms;
212 }
213 }
214
sprang07fb9be2016-02-24 15:55:00215 void Subtract(const RtcpPacketTypeCounter& other) {
216 nack_packets -= other.nack_packets;
217 fir_packets -= other.fir_packets;
218 pli_packets -= other.pli_packets;
219 nack_requests -= other.nack_requests;
220 unique_nack_requests -= other.unique_nack_requests;
221 if (other.first_packet_time_ms != -1 &&
222 (other.first_packet_time_ms > first_packet_time_ms ||
223 first_packet_time_ms == -1)) {
224 // Use youngest time.
225 first_packet_time_ms = other.first_packet_time_ms;
226 }
227 }
228
asapersson@webrtc.orgd08d3892014-12-16 12:03:11229 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
230 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
asapersson@webrtc.org8098e072014-02-19 11:59:02231 }
232
asapersson@webrtc.org2dd31342014-10-29 12:42:30233 int UniqueNackRequestsInPercent() const {
234 if (nack_requests == 0) {
235 return 0;
236 }
237 return static_cast<int>(
238 (unique_nack_requests * 100.0f / nack_requests) + 0.5f);
239 }
240
asapersson@webrtc.orgd08d3892014-12-16 12:03:11241 int64_t first_packet_time_ms; // Time when first packet is sent/received.
242 uint32_t nack_packets; // Number of RTCP NACK packets.
243 uint32_t fir_packets; // Number of RTCP FIR packets.
244 uint32_t pli_packets; // Number of RTCP PLI packets.
245 uint32_t nack_requests; // Number of NACKed RTP packets.
asapersson@webrtc.org2dd31342014-10-29 12:42:30246 uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
asapersson@webrtc.org8098e072014-02-19 11:59:02247};
248
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00249class RtcpPacketTypeCounterObserver {
250 public:
251 virtual ~RtcpPacketTypeCounterObserver() {}
252 virtual void RtcpPacketTypesCounterUpdated(
253 uint32_t ssrc,
254 const RtcpPacketTypeCounter& packet_counter) = 0;
255};
256
asapersson@webrtc.orgd08d3892014-12-16 12:03:11257// Rate statistics for a stream.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07258struct BitrateStatistics {
sprang@webrtc.org6811b6e2013-12-13 09:46:59259 BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
sprang@webrtc.orgdc50aae2013-11-20 16:47:07260
sprang@webrtc.org6811b6e2013-12-13 09:46:59261 uint32_t bitrate_bps; // Bitrate in bits per second.
262 uint32_t packet_rate; // Packet rate in packets per second.
263 uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07264};
265
266// Callback, used to notify an observer whenever new rates have been estimated.
267class BitrateStatisticsObserver {
268 public:
269 virtual ~BitrateStatisticsObserver() {}
270
stefan@webrtc.org0bae1fa2014-11-05 14:05:29271 virtual void Notify(const BitrateStatistics& total_stats,
272 const BitrateStatistics& retransmit_stats,
273 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07274};
275
pbos@webrtc.orgce4e9a32014-12-18 13:50:16276struct FrameCounts {
277 FrameCounts() : key_frames(0), delta_frames(0) {}
278 int key_frames;
279 int delta_frames;
280};
281
asapersson@webrtc.orgd08d3892014-12-16 12:03:11282// Callback, used to notify an observer whenever frame counts have been updated.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07283class FrameCountObserver {
284 public:
sprang@webrtc.org72964bd2013-11-21 09:09:54285 virtual ~FrameCountObserver() {}
pbos@webrtc.orgce4e9a32014-12-18 13:50:16286 virtual void FrameCountUpdated(const FrameCounts& frame_counts,
287 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07288};
289
stefan@webrtc.org168f23f2014-07-11 13:44:02290// Callback, used to notify an observer whenever the send-side delay is updated.
291class SendSideDelayObserver {
292 public:
293 virtual ~SendSideDelayObserver() {}
294 virtual void SendSideDelayUpdated(int avg_delay_ms,
295 int max_delay_ms,
296 uint32_t ssrc) = 0;
297};
298
asapersson35151f32016-05-03 06:44:01299// Callback, used to notify an observer whenever a packet is sent to the
300// transport.
301// TODO(asapersson): This class will remove the need for SendSideDelayObserver.
302// Remove SendSideDelayObserver once possible.
303class SendPacketObserver {
304 public:
305 virtual ~SendPacketObserver() {}
306 virtual void OnSendPacket(uint16_t packet_id,
307 int64_t capture_time_ms,
308 uint32_t ssrc) = 0;
309};
310
niklase@google.com470e71d2011-07-07 08:21:25311// ==================================================================
312// Voice specific types
313// ==================================================================
314
315// Each codec supported can be described by this structure.
mallinath@webrtc.org0209e562014-03-21 00:41:28316struct CodecInst {
317 int pltype;
318 char plname[RTP_PAYLOAD_NAME_SIZE];
319 int plfreq;
320 int pacsize;
Peter Kasting69558702016-01-13 00:26:35321 size_t channels;
mallinath@webrtc.org0209e562014-03-21 00:41:28322 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
323
324 bool operator==(const CodecInst& other) const {
325 return pltype == other.pltype &&
326 (STR_CASE_CMP(plname, other.plname) == 0) &&
327 plfreq == other.plfreq &&
328 pacsize == other.pacsize &&
329 channels == other.channels &&
330 rate == other.rate;
331 }
332
333 bool operator!=(const CodecInst& other) const {
334 return !(*this == other);
335 }
niklase@google.com470e71d2011-07-07 08:21:25336};
337
niklase@google.com470e71d2011-07-07 08:21:25338// RTP
339enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
340
niklase@google.com470e71d2011-07-07 08:21:25341enum PayloadFrequencies
342{
343 kFreq8000Hz = 8000,
344 kFreq16000Hz = 16000,
345 kFreq32000Hz = 32000
346};
347
348enum VadModes // degree of bandwidth reduction
349{
350 kVadConventional = 0, // lowest reduction
351 kVadAggressiveLow,
352 kVadAggressiveMid,
353 kVadAggressiveHigh // highest reduction
354};
355
356struct NetworkStatistics // NETEQ statistics
357{
358 // current jitter buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11359 uint16_t currentBufferSize;
niklase@google.com470e71d2011-07-07 08:21:25360 // preferred (optimal) buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11361 uint16_t preferredBufferSize;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55362 // adding extra delay due to "peaky jitter"
363 bool jitterPeaksFound;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45364 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11365 uint16_t currentPacketLossRate;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45366 // Late loss rate; fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11367 uint16_t currentDiscardRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13368 // fraction (of original stream) of synthesized audio inserted through
niklase@google.com470e71d2011-07-07 08:21:25369 // expansion (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11370 uint16_t currentExpandRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13371 // fraction (of original stream) of synthesized speech inserted through
372 // expansion (in Q14)
373 uint16_t currentSpeechExpandRate;
niklase@google.com470e71d2011-07-07 08:21:25374 // fraction of synthesized speech inserted through pre-emptive expansion
375 // (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11376 uint16_t currentPreemptiveRate;
niklase@google.com470e71d2011-07-07 08:21:25377 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11378 uint16_t currentAccelerateRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13379 // fraction of data coming from secondary decoding (in Q14)
380 uint16_t currentSecondaryDecodedRate;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55381 // clock-drift in parts-per-million (negative or positive)
382 int32_t clockDriftPPM;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05383 // average packet waiting time in the jitter buffer (ms)
384 int meanWaitingTimeMs;
385 // median packet waiting time in the jitter buffer (ms)
386 int medianWaitingTimeMs;
henrik.lundin@webrtc.org053c7992012-01-12 14:16:44387 // min packet waiting time in the jitter buffer (ms)
388 int minWaitingTimeMs;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05389 // max packet waiting time in the jitter buffer (ms)
390 int maxWaitingTimeMs;
roosa@google.comb8ba4d82012-12-14 00:06:18391 // added samples in off mode due to packet loss
Peter Kastingdce40cf2015-08-24 21:52:23392 size_t addedSamples;
niklase@google.com470e71d2011-07-07 08:21:25393};
394
wu@webrtc.org24301a62013-12-13 19:17:43395// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
396struct AudioDecodingCallStats {
397 AudioDecodingCallStats()
398 : calls_to_silence_generator(0),
399 calls_to_neteq(0),
400 decoded_normal(0),
401 decoded_plc(0),
402 decoded_cng(0),
403 decoded_plc_cng(0) {}
404
405 int calls_to_silence_generator; // Number of calls where silence generated,
406 // and NetEq was disengaged from decoding.
407 int calls_to_neteq; // Number of calls to NetEq.
408 int decoded_normal; // Number of calls where audio RTP packet decoded.
409 int decoded_plc; // Number of calls resulted in PLC.
410 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
411 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
412};
413
niklase@google.com470e71d2011-07-07 08:21:25414typedef struct
415{
416 int min; // minumum
417 int max; // maximum
418 int average; // average
419} StatVal;
420
421typedef struct // All levels are reported in dBm0
422{
423 StatVal speech_rx; // long-term speech levels on receiving side
424 StatVal speech_tx; // long-term speech levels on transmitting side
425 StatVal noise_rx; // long-term noise/silence levels on receiving side
426 StatVal noise_tx; // long-term noise/silence levels on transmitting side
427} LevelStatistics;
428
429typedef struct // All levels are reported in dB
430{
431 StatVal erl; // Echo Return Loss
432 StatVal erle; // Echo Return Loss Enhancement
433 StatVal rerl; // RERL = ERL + ERLE
434 // Echo suppression inside EC at the point just before its NLP
435 StatVal a_nlp;
436} EchoStatistics;
437
niklase@google.com470e71d2011-07-07 08:21:25438enum NsModes // type of Noise Suppression
439{
440 kNsUnchanged = 0, // previously set mode
441 kNsDefault, // platform default
442 kNsConference, // conferencing default
443 kNsLowSuppression, // lowest suppression
444 kNsModerateSuppression,
445 kNsHighSuppression,
446 kNsVeryHighSuppression, // highest suppression
447};
448
449enum AgcModes // type of Automatic Gain Control
450{
451 kAgcUnchanged = 0, // previously set mode
452 kAgcDefault, // platform default
453 // adaptive mode for use when analog volume control exists (e.g. for
454 // PC softphone)
455 kAgcAdaptiveAnalog,
456 // scaling takes place in the digital domain (e.g. for conference servers
457 // and embedded devices)
458 kAgcAdaptiveDigital,
andrew@webrtc.org80124742012-03-08 17:54:24459 // can be used on embedded devices where the capture signal level
niklase@google.com470e71d2011-07-07 08:21:25460 // is predictable
461 kAgcFixedDigital
462};
463
464// EC modes
465enum EcModes // type of Echo Control
466{
467 kEcUnchanged = 0, // previously set mode
468 kEcDefault, // platform default
469 kEcConference, // conferencing default (aggressive AEC)
470 kEcAec, // Acoustic Echo Cancellation
471 kEcAecm, // AEC mobile
472};
473
474// AECM modes
475enum AecmModes // mode of AECM
476{
477 kAecmQuietEarpieceOrHeadset = 0,
478 // Quiet earpiece or headset use
479 kAecmEarpiece, // most earpiece use
480 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
481 kAecmSpeakerphone, // most speakerphone use (default)
482 kAecmLoudSpeakerphone // Loud speakerphone
483};
484
485// AGC configuration
486typedef struct
487{
488 unsigned short targetLeveldBOv;
489 unsigned short digitalCompressionGaindB;
490 bool limiterEnable;
491} AgcConfig; // AGC configuration parameters
492
493enum StereoChannel
494{
495 kStereoLeft = 0,
496 kStereoRight,
497 kStereoBoth
498};
499
500// Audio device layers
501enum AudioLayers
502{
503 kAudioPlatformDefault = 0,
504 kAudioWindowsWave = 1,
505 kAudioWindowsCore = 2,
506 kAudioLinuxAlsa = 3,
507 kAudioLinuxPulse = 4
508};
509
henrika@webrtc.org66803482014-04-17 10:45:01510// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25511enum NetEqModes // NetEQ playout configurations
512{
513 // Optimized trade-off between low delay and jitter robustness for two-way
514 // communication.
515 kNetEqDefault = 0,
516 // Improved jitter robustness at the cost of increased delay. Can be
517 // used in one-way communication.
518 kNetEqStreaming = 1,
519 // Optimzed for decodability of fax signals rather than for perceived audio
520 // quality.
521 kNetEqFax = 2,
roosa@google.comb7186192012-12-12 21:59:14522 // Minimal buffer management. Inserts zeros for lost packets and during
523 // buffer increases.
524 kNetEqOff = 3,
niklase@google.com470e71d2011-07-07 08:21:25525};
526
henrika@webrtc.org66803482014-04-17 10:45:01527// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25528enum OnHoldModes // On Hold direction
529{
530 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
531 kHoldSendOnly, // Put only sending in on-hold state.
532 kHoldPlayOnly // Put only playing in on-hold state.
533};
534
henrika@webrtc.org66803482014-04-17 10:45:01535// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25536enum AmrMode
537{
538 kRfc3267BwEfficient = 0,
539 kRfc3267OctetAligned = 1,
540 kRfc3267FileStorage = 2,
541};
542
543// ==================================================================
544// Video specific types
545// ==================================================================
546
547// Raw video types
548enum RawVideoType
549{
550 kVideoI420 = 0,
551 kVideoYV12 = 1,
552 kVideoYUY2 = 2,
553 kVideoUYVY = 3,
554 kVideoIYUV = 4,
555 kVideoARGB = 5,
556 kVideoRGB24 = 6,
557 kVideoRGB565 = 7,
558 kVideoARGB4444 = 8,
559 kVideoARGB1555 = 9,
560 kVideoMJPEG = 10,
561 kVideoNV12 = 11,
562 kVideoNV21 = 12,
mikhal@webrtc.orgc00f91d2012-01-03 18:49:15563 kVideoBGRA = 13,
niklase@google.com470e71d2011-07-07 08:21:25564 kVideoUnknown = 99
565};
566
567// Video codec
568enum { kConfigParameterSize = 128};
569enum { kPayloadNameSize = 32};
pwestin@webrtc.org1da1ce02011-10-13 15:19:55570enum { kMaxSimulcastStreams = 4};
sprangce4aef12015-11-02 15:23:20571enum { kMaxSpatialLayers = 5 };
pwestin@webrtc.orgdb221d22011-12-02 11:31:08572enum { kMaxTemporalStreams = 4};
niklase@google.com470e71d2011-07-07 08:21:25573
niklase@google.com470e71d2011-07-07 08:21:25574enum VideoCodecComplexity
575{
576 kComplexityNormal = 0,
577 kComplexityHigh = 1,
578 kComplexityHigher = 2,
579 kComplexityMax = 3
580};
581
582enum VideoCodecProfile
583{
584 kProfileBase = 0x00,
585 kProfileMain = 0x01
586};
587
stefan@webrtc.orgefd0a482011-12-29 10:12:35588enum VP8ResilienceMode {
589 kResilienceOff, // The stream produced by the encoder requires a
590 // recovery frame (typically a key frame) to be
591 // decodable after a packet loss.
592 kResilientStream, // A stream produced by the encoder is resilient to
593 // packet losses, but packets within a frame subsequent
594 // to a loss can't be decoded.
595 kResilientFrames // Same as kResilientStream but with added resilience
596 // within a frame.
597};
598
Peter Boström7b971e72016-01-19 15:26:16599class TemporalLayersFactory;
niklase@google.com470e71d2011-07-07 08:21:25600// VP8 specific
mallinath@webrtc.org0209e562014-03-21 00:41:28601struct VideoCodecVP8 {
602 bool pictureLossIndicationOn;
603 bool feedbackModeOn;
604 VideoCodecComplexity complexity;
605 VP8ResilienceMode resilience;
606 unsigned char numberOfTemporalLayers;
607 bool denoisingOn;
608 bool errorConcealmentOn;
609 bool automaticResizeOn;
610 bool frameDroppingOn;
611 int keyFrameInterval;
Peter Boström7b971e72016-01-19 15:26:16612 const TemporalLayersFactory* tl_factory;
niklase@google.com470e71d2011-07-07 08:21:25613};
614
asaperssona9455ab2015-07-31 13:10:09615// VP9 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48616struct VideoCodecVP9 {
617 VideoCodecComplexity complexity;
618 int resilience;
619 unsigned char numberOfTemporalLayers;
620 bool denoisingOn;
621 bool frameDroppingOn;
622 int keyFrameInterval;
623 bool adaptiveQpMode;
Marcof3507202015-09-17 19:16:04624 bool automaticResizeOn;
asaperssona9455ab2015-07-31 13:10:09625 unsigned char numberOfSpatialLayers;
626 bool flexibleMode;
marpan@webrtc.org5b883172014-11-01 06:10:48627};
628
stefan@webrtc.orgb9f54532014-07-04 12:42:07629// H264 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48630struct VideoCodecH264 {
631 VideoCodecProfile profile;
632 bool frameDroppingOn;
633 int keyFrameInterval;
634 // These are NULL/0 if not externally negotiated.
635 const uint8_t* spsData;
636 size_t spsLen;
637 const uint8_t* ppsData;
638 size_t ppsLen;
stefan@webrtc.orgb9f54532014-07-04 12:42:07639};
640
niklase@google.com470e71d2011-07-07 08:21:25641// Video codec types
marpan@webrtc.org5b883172014-11-01 06:10:48642enum VideoCodecType {
643 kVideoCodecVP8,
644 kVideoCodecVP9,
645 kVideoCodecH264,
646 kVideoCodecI420,
647 kVideoCodecRED,
648 kVideoCodecULPFEC,
649 kVideoCodecGeneric,
650 kVideoCodecUnknown
niklase@google.com470e71d2011-07-07 08:21:25651};
652
marpan@webrtc.org5b883172014-11-01 06:10:48653union VideoCodecUnion {
654 VideoCodecVP8 VP8;
655 VideoCodecVP9 VP9;
656 VideoCodecH264 H264;
niklase@google.com470e71d2011-07-07 08:21:25657};
658
phoglund@webrtc.org8bfee842012-02-17 09:32:48659
660// Simulcast is when the same stream is encoded multiple times with different
661// settings such as resolution.
mallinath@webrtc.org0209e562014-03-21 00:41:28662struct SimulcastStream {
663 unsigned short width;
664 unsigned short height;
665 unsigned char numberOfTemporalLayers;
666 unsigned int maxBitrate; // kilobits/sec.
667 unsigned int targetBitrate; // kilobits/sec.
668 unsigned int minBitrate; // kilobits/sec.
669 unsigned int qpMax; // minimum quality
pwestin@webrtc.org1da1ce02011-10-13 15:19:55670};
671
sprangce4aef12015-11-02 15:23:20672struct SpatialLayer {
673 int scaling_factor_num;
674 int scaling_factor_den;
675 int target_bitrate_bps;
676 // TODO(ivica): Add max_quantizer and min_quantizer?
677};
678
stefan@webrtc.orgeb917922013-02-18 14:40:18679enum VideoCodecMode {
680 kRealtimeVideo,
681 kScreensharing
682};
683
niklase@google.com470e71d2011-07-07 08:21:25684// Common video codec properties
mallinath@webrtc.org0209e562014-03-21 00:41:28685struct VideoCodec {
686 VideoCodecType codecType;
687 char plName[kPayloadNameSize];
688 unsigned char plType;
niklase@google.com470e71d2011-07-07 08:21:25689
mallinath@webrtc.org0209e562014-03-21 00:41:28690 unsigned short width;
691 unsigned short height;
niklase@google.com470e71d2011-07-07 08:21:25692
mallinath@webrtc.org0209e562014-03-21 00:41:28693 unsigned int startBitrate; // kilobits/sec.
694 unsigned int maxBitrate; // kilobits/sec.
695 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org3c412b22014-03-24 12:36:52696 unsigned int targetBitrate; // kilobits/sec.
697
mallinath@webrtc.org0209e562014-03-21 00:41:28698 unsigned char maxFramerate;
niklase@google.com470e71d2011-07-07 08:21:25699
mallinath@webrtc.org0209e562014-03-21 00:41:28700 VideoCodecUnion codecSpecific;
niklase@google.com470e71d2011-07-07 08:21:25701
mallinath@webrtc.org0209e562014-03-21 00:41:28702 unsigned int qpMax;
703 unsigned char numberOfSimulcastStreams;
704 SimulcastStream simulcastStream[kMaxSimulcastStreams];
sprangce4aef12015-11-02 15:23:20705 SpatialLayer spatialLayers[kMaxSpatialLayers];
stefan@webrtc.orgeb917922013-02-18 14:40:18706
mallinath@webrtc.org0209e562014-03-21 00:41:28707 VideoCodecMode mode;
andresp@webrtc.org185bae42013-05-14 08:02:25708
Peter Boström7b971e72016-01-19 15:26:16709 bool operator==(const VideoCodec& other) const = delete;
710 bool operator!=(const VideoCodec& other) const = delete;
niklase@google.com470e71d2011-07-07 08:21:25711};
astor@webrtc.orgbd7aeba2012-06-26 10:47:04712
stefan64c0a0a2015-11-27 09:02:31713// Bandwidth over-use detector options. These are used to drive
714// experimentation with bandwidth estimation parameters.
715// See modules/remote_bitrate_estimator/overuse_detector.h
716struct OverUseDetectorOptions {
717 OverUseDetectorOptions()
718 : initial_slope(8.0/512.0),
719 initial_offset(0),
720 initial_e(),
721 initial_process_noise(),
722 initial_avg_noise(0.0),
723 initial_var_noise(50) {
724 initial_e[0][0] = 100;
725 initial_e[1][1] = 1e-1;
726 initial_e[0][1] = initial_e[1][0] = 0;
727 initial_process_noise[0] = 1e-13;
stefan1069cac2016-03-10 13:13:21728 initial_process_noise[1] = 1e-3;
stefan64c0a0a2015-11-27 09:02:31729 }
730 double initial_slope;
731 double initial_offset;
732 double initial_e[2][2];
733 double initial_process_noise[2];
734 double initial_avg_noise;
735 double initial_var_noise;
736};
737
wu@webrtc.orga9890802013-12-13 00:21:03738// This structure will have the information about when packet is actually
739// received by socket.
740struct PacketTime {
henrike@webrtc.org82d3cb62014-04-29 17:50:47741 PacketTime() : timestamp(-1), not_before(-1) {}
742 PacketTime(int64_t timestamp, int64_t not_before)
743 : timestamp(timestamp), not_before(not_before) {
wu@webrtc.orga9890802013-12-13 00:21:03744 }
745
henrike@webrtc.org82d3cb62014-04-29 17:50:47746 int64_t timestamp; // Receive time after socket delivers the data.
747 int64_t not_before; // Earliest possible time the data could have arrived,
748 // indicating the potential error in the |timestamp|
749 // value,in case the system is busy.
750 // For example, the time of the last select() call.
751 // If unknown, this value will be set to zero.
wu@webrtc.orga9890802013-12-13 00:21:03752};
753
isheriff6b4b5f32016-06-08 07:24:21754// Minimum and maximum playout delay values from capture to render.
755// These are best effort values.
756//
757// A value < 0 indicates no change from previous valid value.
758//
759// min = max = 0 indicates that the receiver should try and render
760// frame as soon as possible.
761//
762// min = x, max = y indicates that the receiver is free to adapt
763// in the range (x, y) based on network jitter.
764//
765// Note: Given that this gets embedded in a union, it is up-to the owner to
766// initialize these values.
767struct PlayoutDelay {
768 int min_ms;
769 int max_ms;
770};
771
solenberg@webrtc.orgb1f50102014-03-24 10:38:25772struct RTPHeaderExtension {
sprang@webrtc.org30933902015-03-17 14:33:12773 RTPHeaderExtension();
solenberg@webrtc.orgb1f50102014-03-24 10:38:25774
775 bool hasTransmissionTimeOffset;
776 int32_t transmissionTimeOffset;
777 bool hasAbsoluteSendTime;
778 uint32_t absoluteSendTime;
sprang@webrtc.org30933902015-03-17 14:33:12779 bool hasTransportSequenceNumber;
780 uint16_t transportSequenceNumber;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25781
782 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
783 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
784 bool hasAudioLevel;
Minyue4cee4192015-08-10 13:08:36785 bool voiceActivity;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25786 uint8_t audioLevel;
guoweis@webrtc.org45362892015-03-04 22:55:15787
788 // For Coordination of Video Orientation. See
789 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
790 // ts_126114v120700p.pdf
791 bool hasVideoRotation;
792 uint8_t videoRotation;
isheriff6b4b5f32016-06-08 07:24:21793
794 PlayoutDelay playout_delay = {-1, -1};
solenberg@webrtc.orgb1f50102014-03-24 10:38:25795};
796
797struct RTPHeader {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22798 RTPHeader();
solenberg@webrtc.orgb1f50102014-03-24 10:38:25799
800 bool markerBit;
801 uint8_t payloadType;
802 uint16_t sequenceNumber;
803 uint32_t timestamp;
804 uint32_t ssrc;
805 uint8_t numCSRCs;
806 uint32_t arrOfCSRCs[kRtpCsrcSize];
pkasting@chromium.org4591fbd2014-11-20 22:28:14807 size_t paddingLength;
808 size_t headerLength;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25809 int payload_type_frequency;
810 RTPHeaderExtension extension;
811};
812
asapersson@webrtc.org44149392015-02-04 08:34:47813struct RtpPacketCounter {
814 RtpPacketCounter()
815 : header_bytes(0),
816 payload_bytes(0),
817 padding_bytes(0),
818 packets(0) {}
819
820 void Add(const RtpPacketCounter& other) {
821 header_bytes += other.header_bytes;
822 payload_bytes += other.payload_bytes;
823 padding_bytes += other.padding_bytes;
824 packets += other.packets;
825 }
826
Erik Språng22c2b482016-03-01 08:40:42827 void Subtract(const RtpPacketCounter& other) {
828 assert(header_bytes >= other.header_bytes);
829 header_bytes -= other.header_bytes;
830 assert(payload_bytes >= other.payload_bytes);
831 payload_bytes -= other.payload_bytes;
832 assert(padding_bytes >= other.padding_bytes);
833 padding_bytes -= other.padding_bytes;
834 assert(packets >= other.packets);
835 packets -= other.packets;
836 }
837
asapersson@webrtc.org44149392015-02-04 08:34:47838 void AddPacket(size_t packet_length, const RTPHeader& header) {
839 ++packets;
840 header_bytes += header.headerLength;
841 padding_bytes += header.paddingLength;
842 payload_bytes +=
843 packet_length - (header.headerLength + header.paddingLength);
844 }
845
846 size_t TotalBytes() const {
847 return header_bytes + payload_bytes + padding_bytes;
848 }
849
850 size_t header_bytes; // Number of bytes used by RTP headers.
851 size_t payload_bytes; // Payload bytes, excluding RTP headers and padding.
852 size_t padding_bytes; // Number of padding bytes.
853 uint32_t packets; // Number of packets.
854};
855
856// Data usage statistics for a (rtp) stream.
857struct StreamDataCounters {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22858 StreamDataCounters();
asapersson@webrtc.org44149392015-02-04 08:34:47859
860 void Add(const StreamDataCounters& other) {
861 transmitted.Add(other.transmitted);
862 retransmitted.Add(other.retransmitted);
863 fec.Add(other.fec);
864 if (other.first_packet_time_ms != -1 &&
865 (other.first_packet_time_ms < first_packet_time_ms ||
866 first_packet_time_ms == -1)) {
867 // Use oldest time.
868 first_packet_time_ms = other.first_packet_time_ms;
869 }
870 }
871
Erik Språng22c2b482016-03-01 08:40:42872 void Subtract(const StreamDataCounters& other) {
873 transmitted.Subtract(other.transmitted);
874 retransmitted.Subtract(other.retransmitted);
875 fec.Subtract(other.fec);
876 if (other.first_packet_time_ms != -1 &&
877 (other.first_packet_time_ms > first_packet_time_ms ||
878 first_packet_time_ms == -1)) {
879 // Use youngest time.
880 first_packet_time_ms = other.first_packet_time_ms;
881 }
882 }
883
asapersson@webrtc.org44149392015-02-04 08:34:47884 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
885 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
886 }
887
888 // Returns the number of bytes corresponding to the actual media payload (i.e.
889 // RTP headers, padding, retransmissions and fec packets are excluded).
890 // Note this function does not have meaning for an RTX stream.
891 size_t MediaPayloadBytes() const {
892 return transmitted.payload_bytes - retransmitted.payload_bytes -
893 fec.payload_bytes;
894 }
895
896 int64_t first_packet_time_ms; // Time when first packet is sent/received.
897 RtpPacketCounter transmitted; // Number of transmitted packets/bytes.
898 RtpPacketCounter retransmitted; // Number of retransmitted packets/bytes.
899 RtpPacketCounter fec; // Number of redundancy packets/bytes.
900};
901
902// Callback, called whenever byte/packet counts have been updated.
903class StreamDataCountersCallback {
904 public:
905 virtual ~StreamDataCountersCallback() {}
906
907 virtual void DataCountersUpdated(const StreamDataCounters& counters,
908 uint32_t ssrc) = 0;
909};
pbosda903ea2015-10-02 09:36:56910
911// RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size
912// RTCP mode is described by RFC 5506.
913enum class RtcpMode { kOff, kCompound, kReducedSize };
914
pbos1ba8d392016-05-02 03:18:34915enum NetworkState {
916 kNetworkUp,
917 kNetworkDown,
918};
919
niklase@google.com470e71d2011-07-07 08:21:25920} // namespace webrtc
andrew@webrtc.orgeda189b2013-09-09 17:50:10921
922#endif // WEBRTC_COMMON_TYPES_H_