blob: bb29af0bebe0775054d5ec41dfe8365bb8084f13 [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
tommia6219cc2016-06-15 17:30:1457class RewindableStream {
58 public:
59 virtual ~RewindableStream() {}
60 virtual int Rewind() = 0;
niklase@google.com470e71d2011-07-07 08:21:2561};
62
tommia6219cc2016-06-15 17:30:1463class InStream : public RewindableStream {
64 public:
65 // Reads |len| bytes from file to |buf|. Returns the number of bytes read
66 // or -1 on error.
67 virtual int Read(void* buf, size_t len) = 0;
68};
69
70class OutStream : public RewindableStream {
71 public:
72 // Writes |len| bytes from |buf| to file. The actual writing may happen
73 // some time later. Call Flush() to force a write.
74 virtual bool Write(const void* buf, size_t len) = 0;
niklase@google.com470e71d2011-07-07 08:21:2575};
76
77enum TraceModule
78{
pbos@webrtc.org5ab75672013-12-16 12:24:4479 kTraceUndefined = 0,
niklase@google.com470e71d2011-07-07 08:21:2580 // not a module, triggered from the engine code
pbos@webrtc.org5ab75672013-12-16 12:24:4481 kTraceVoice = 0x0001,
niklase@google.com470e71d2011-07-07 08:21:2582 // not a module, triggered from the engine code
pbos@webrtc.org5ab75672013-12-16 12:24:4483 kTraceVideo = 0x0002,
niklase@google.com470e71d2011-07-07 08:21:2584 // not a module, triggered from the utility code
pbos@webrtc.org5ab75672013-12-16 12:24:4485 kTraceUtility = 0x0003,
86 kTraceRtpRtcp = 0x0004,
87 kTraceTransport = 0x0005,
88 kTraceSrtp = 0x0006,
89 kTraceAudioCoding = 0x0007,
90 kTraceAudioMixerServer = 0x0008,
91 kTraceAudioMixerClient = 0x0009,
92 kTraceFile = 0x000a,
93 kTraceAudioProcessing = 0x000b,
94 kTraceVideoCoding = 0x0010,
95 kTraceVideoMixer = 0x0011,
96 kTraceAudioDevice = 0x0012,
97 kTraceVideoRenderer = 0x0014,
98 kTraceVideoCapture = 0x0015,
pbos@webrtc.org5ab75672013-12-16 12:24:4499 kTraceRemoteBitrateEstimator = 0x0017,
niklase@google.com470e71d2011-07-07 08:21:25100};
101
102enum TraceLevel
103{
104 kTraceNone = 0x0000, // no trace
105 kTraceStateInfo = 0x0001,
106 kTraceWarning = 0x0002,
107 kTraceError = 0x0004,
108 kTraceCritical = 0x0008,
109 kTraceApiCall = 0x0010,
110 kTraceDefault = 0x00ff,
111
112 kTraceModuleCall = 0x0020,
113 kTraceMemory = 0x0100, // memory info
114 kTraceTimer = 0x0200, // timing info
115 kTraceStream = 0x0400, // "continuous" stream of data
116
117 // used for debug purposes
118 kTraceDebug = 0x0800, // debug
119 kTraceInfo = 0x1000, // debug info
120
andrew@webrtc.org655d8f52012-11-20 07:34:45121 // Non-verbose level used by LS_INFO of logging.h. Do not use directly.
122 kTraceTerseInfo = 0x2000,
123
niklase@google.com470e71d2011-07-07 08:21:25124 kTraceAll = 0xffff
125};
126
127// External Trace API
andrew@webrtc.org23ec30b2012-11-15 05:33:25128class TraceCallback {
129 public:
130 virtual void Print(TraceLevel level, const char* message, int length) = 0;
niklase@google.com470e71d2011-07-07 08:21:25131
andrew@webrtc.org23ec30b2012-11-15 05:33:25132 protected:
133 virtual ~TraceCallback() {}
134 TraceCallback() {}
135};
niklase@google.com470e71d2011-07-07 08:21:25136
137enum FileFormats
138{
139 kFileFormatWavFile = 1,
140 kFileFormatCompressedFile = 2,
niklase@google.com470e71d2011-07-07 08:21:25141 kFileFormatPreencodedFile = 4,
142 kFileFormatPcm16kHzFile = 7,
143 kFileFormatPcm8kHzFile = 8,
144 kFileFormatPcm32kHzFile = 9
145};
146
niklase@google.com470e71d2011-07-07 08:21:25147enum ProcessingTypes
148{
149 kPlaybackPerChannel = 0,
150 kPlaybackAllChannelsMixed,
151 kRecordingPerChannel,
andrew@webrtc.org21ab3ba2012-10-19 17:30:56152 kRecordingAllChannelsMixed,
153 kRecordingPreprocessing
niklase@google.com470e71d2011-07-07 08:21:25154};
155
pbos22993e12015-10-19 09:39:06156enum FrameType {
157 kEmptyFrame = 0,
158 kAudioFrameSpeech = 1,
159 kAudioFrameCN = 2,
160 kVideoFrameKey = 3,
161 kVideoFrameDelta = 4,
sprang@webrtc.org71f055f2013-12-04 15:09:27162};
163
sprang@webrtc.orgdc50aae2013-11-20 16:47:07164// Statistics for an RTCP channel
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07165struct RtcpStatistics {
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07166 RtcpStatistics()
167 : fraction_lost(0),
168 cumulative_lost(0),
169 extended_max_sequence_number(0),
sprang@webrtc.orga6ad6e52013-12-05 09:48:44170 jitter(0) {}
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07171
172 uint8_t fraction_lost;
173 uint32_t cumulative_lost;
174 uint32_t extended_max_sequence_number;
175 uint32_t jitter;
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07176};
177
sprang@webrtc.orgdc50aae2013-11-20 16:47:07178class RtcpStatisticsCallback {
179 public:
180 virtual ~RtcpStatisticsCallback() {}
181
182 virtual void StatisticsUpdated(const RtcpStatistics& statistics,
183 uint32_t ssrc) = 0;
pbos@webrtc.orgce4e9a32014-12-18 13:50:16184 virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07185};
186
asapersson@webrtc.org8098e072014-02-19 11:59:02187// Statistics for RTCP packet types.
188struct RtcpPacketTypeCounter {
189 RtcpPacketTypeCounter()
asapersson@webrtc.orgd08d3892014-12-16 12:03:11190 : first_packet_time_ms(-1),
191 nack_packets(0),
asapersson@webrtc.org8098e072014-02-19 11:59:02192 fir_packets(0),
asapersson@webrtc.org2dd31342014-10-29 12:42:30193 pli_packets(0),
194 nack_requests(0),
195 unique_nack_requests(0) {}
asapersson@webrtc.org8098e072014-02-19 11:59:02196
197 void Add(const RtcpPacketTypeCounter& other) {
198 nack_packets += other.nack_packets;
199 fir_packets += other.fir_packets;
200 pli_packets += other.pli_packets;
asapersson@webrtc.org2dd31342014-10-29 12:42:30201 nack_requests += other.nack_requests;
202 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.orgd08d3892014-12-16 12:03:11203 if (other.first_packet_time_ms != -1 &&
204 (other.first_packet_time_ms < first_packet_time_ms ||
205 first_packet_time_ms == -1)) {
206 // Use oldest time.
207 first_packet_time_ms = other.first_packet_time_ms;
208 }
209 }
210
sprang07fb9be2016-02-24 15:55:00211 void Subtract(const RtcpPacketTypeCounter& other) {
212 nack_packets -= other.nack_packets;
213 fir_packets -= other.fir_packets;
214 pli_packets -= other.pli_packets;
215 nack_requests -= other.nack_requests;
216 unique_nack_requests -= other.unique_nack_requests;
217 if (other.first_packet_time_ms != -1 &&
218 (other.first_packet_time_ms > first_packet_time_ms ||
219 first_packet_time_ms == -1)) {
220 // Use youngest time.
221 first_packet_time_ms = other.first_packet_time_ms;
222 }
223 }
224
asapersson@webrtc.orgd08d3892014-12-16 12:03:11225 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
226 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
asapersson@webrtc.org8098e072014-02-19 11:59:02227 }
228
asapersson@webrtc.org2dd31342014-10-29 12:42:30229 int UniqueNackRequestsInPercent() const {
230 if (nack_requests == 0) {
231 return 0;
232 }
233 return static_cast<int>(
234 (unique_nack_requests * 100.0f / nack_requests) + 0.5f);
235 }
236
asapersson@webrtc.orgd08d3892014-12-16 12:03:11237 int64_t first_packet_time_ms; // Time when first packet is sent/received.
238 uint32_t nack_packets; // Number of RTCP NACK packets.
239 uint32_t fir_packets; // Number of RTCP FIR packets.
240 uint32_t pli_packets; // Number of RTCP PLI packets.
241 uint32_t nack_requests; // Number of NACKed RTP packets.
asapersson@webrtc.org2dd31342014-10-29 12:42:30242 uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
asapersson@webrtc.org8098e072014-02-19 11:59:02243};
244
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00245class RtcpPacketTypeCounterObserver {
246 public:
247 virtual ~RtcpPacketTypeCounterObserver() {}
248 virtual void RtcpPacketTypesCounterUpdated(
249 uint32_t ssrc,
250 const RtcpPacketTypeCounter& packet_counter) = 0;
251};
252
asapersson@webrtc.orgd08d3892014-12-16 12:03:11253// Rate statistics for a stream.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07254struct BitrateStatistics {
sprangcd349d92016-07-13 16:11:28255 BitrateStatistics() : bitrate_bps(0), packet_rate(0) {}
sprang@webrtc.orgdc50aae2013-11-20 16:47:07256
sprang@webrtc.org6811b6e2013-12-13 09:46:59257 uint32_t bitrate_bps; // Bitrate in bits per second.
258 uint32_t packet_rate; // Packet rate in packets per second.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07259};
260
261// Callback, used to notify an observer whenever new rates have been estimated.
262class BitrateStatisticsObserver {
263 public:
264 virtual ~BitrateStatisticsObserver() {}
265
sprangcd349d92016-07-13 16:11:28266 virtual void Notify(uint32_t total_bitrate_bps,
267 uint32_t retransmit_bitrate_bps,
stefan@webrtc.org0bae1fa2014-11-05 14:05:29268 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07269};
270
pbos@webrtc.orgce4e9a32014-12-18 13:50:16271struct FrameCounts {
272 FrameCounts() : key_frames(0), delta_frames(0) {}
273 int key_frames;
274 int delta_frames;
275};
276
asapersson@webrtc.orgd08d3892014-12-16 12:03:11277// Callback, used to notify an observer whenever frame counts have been updated.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07278class FrameCountObserver {
279 public:
sprang@webrtc.org72964bd2013-11-21 09:09:54280 virtual ~FrameCountObserver() {}
pbos@webrtc.orgce4e9a32014-12-18 13:50:16281 virtual void FrameCountUpdated(const FrameCounts& frame_counts,
282 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07283};
284
stefan@webrtc.org168f23f2014-07-11 13:44:02285// Callback, used to notify an observer whenever the send-side delay is updated.
286class SendSideDelayObserver {
287 public:
288 virtual ~SendSideDelayObserver() {}
289 virtual void SendSideDelayUpdated(int avg_delay_ms,
290 int max_delay_ms,
291 uint32_t ssrc) = 0;
292};
293
asapersson35151f32016-05-03 06:44:01294// Callback, used to notify an observer whenever a packet is sent to the
295// transport.
296// TODO(asapersson): This class will remove the need for SendSideDelayObserver.
297// Remove SendSideDelayObserver once possible.
298class SendPacketObserver {
299 public:
300 virtual ~SendPacketObserver() {}
301 virtual void OnSendPacket(uint16_t packet_id,
302 int64_t capture_time_ms,
303 uint32_t ssrc) = 0;
304};
305
niklase@google.com470e71d2011-07-07 08:21:25306// ==================================================================
307// Voice specific types
308// ==================================================================
309
310// Each codec supported can be described by this structure.
mallinath@webrtc.org0209e562014-03-21 00:41:28311struct CodecInst {
312 int pltype;
313 char plname[RTP_PAYLOAD_NAME_SIZE];
314 int plfreq;
315 int pacsize;
Peter Kasting69558702016-01-13 00:26:35316 size_t channels;
mallinath@webrtc.org0209e562014-03-21 00:41:28317 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
318
319 bool operator==(const CodecInst& other) const {
320 return pltype == other.pltype &&
321 (STR_CASE_CMP(plname, other.plname) == 0) &&
322 plfreq == other.plfreq &&
323 pacsize == other.pacsize &&
324 channels == other.channels &&
325 rate == other.rate;
326 }
327
328 bool operator!=(const CodecInst& other) const {
329 return !(*this == other);
330 }
niklase@google.com470e71d2011-07-07 08:21:25331};
332
niklase@google.com470e71d2011-07-07 08:21:25333// RTP
334enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
335
niklase@google.com470e71d2011-07-07 08:21:25336enum PayloadFrequencies
337{
338 kFreq8000Hz = 8000,
339 kFreq16000Hz = 16000,
340 kFreq32000Hz = 32000
341};
342
343enum VadModes // degree of bandwidth reduction
344{
345 kVadConventional = 0, // lowest reduction
346 kVadAggressiveLow,
347 kVadAggressiveMid,
348 kVadAggressiveHigh // highest reduction
349};
350
351struct NetworkStatistics // NETEQ statistics
352{
353 // current jitter buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11354 uint16_t currentBufferSize;
niklase@google.com470e71d2011-07-07 08:21:25355 // preferred (optimal) buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11356 uint16_t preferredBufferSize;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55357 // adding extra delay due to "peaky jitter"
358 bool jitterPeaksFound;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45359 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11360 uint16_t currentPacketLossRate;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45361 // Late loss rate; fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11362 uint16_t currentDiscardRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13363 // fraction (of original stream) of synthesized audio inserted through
niklase@google.com470e71d2011-07-07 08:21:25364 // expansion (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11365 uint16_t currentExpandRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13366 // fraction (of original stream) of synthesized speech inserted through
367 // expansion (in Q14)
368 uint16_t currentSpeechExpandRate;
niklase@google.com470e71d2011-07-07 08:21:25369 // fraction of synthesized speech inserted through pre-emptive expansion
370 // (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11371 uint16_t currentPreemptiveRate;
niklase@google.com470e71d2011-07-07 08:21:25372 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11373 uint16_t currentAccelerateRate;
minyue@webrtc.orgc0bd7be2015-02-18 15:24:13374 // fraction of data coming from secondary decoding (in Q14)
375 uint16_t currentSecondaryDecodedRate;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55376 // clock-drift in parts-per-million (negative or positive)
377 int32_t clockDriftPPM;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05378 // average packet waiting time in the jitter buffer (ms)
379 int meanWaitingTimeMs;
380 // median packet waiting time in the jitter buffer (ms)
381 int medianWaitingTimeMs;
henrik.lundin@webrtc.org053c7992012-01-12 14:16:44382 // min packet waiting time in the jitter buffer (ms)
383 int minWaitingTimeMs;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05384 // max packet waiting time in the jitter buffer (ms)
385 int maxWaitingTimeMs;
roosa@google.comb8ba4d82012-12-14 00:06:18386 // added samples in off mode due to packet loss
Peter Kastingdce40cf2015-08-24 21:52:23387 size_t addedSamples;
niklase@google.com470e71d2011-07-07 08:21:25388};
389
wu@webrtc.org24301a62013-12-13 19:17:43390// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
391struct AudioDecodingCallStats {
392 AudioDecodingCallStats()
393 : calls_to_silence_generator(0),
394 calls_to_neteq(0),
395 decoded_normal(0),
396 decoded_plc(0),
397 decoded_cng(0),
398 decoded_plc_cng(0) {}
399
400 int calls_to_silence_generator; // Number of calls where silence generated,
401 // and NetEq was disengaged from decoding.
402 int calls_to_neteq; // Number of calls to NetEq.
403 int decoded_normal; // Number of calls where audio RTP packet decoded.
404 int decoded_plc; // Number of calls resulted in PLC.
405 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
406 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
407};
408
niklase@google.com470e71d2011-07-07 08:21:25409typedef struct
410{
411 int min; // minumum
412 int max; // maximum
413 int average; // average
414} StatVal;
415
416typedef struct // All levels are reported in dBm0
417{
418 StatVal speech_rx; // long-term speech levels on receiving side
419 StatVal speech_tx; // long-term speech levels on transmitting side
420 StatVal noise_rx; // long-term noise/silence levels on receiving side
421 StatVal noise_tx; // long-term noise/silence levels on transmitting side
422} LevelStatistics;
423
424typedef struct // All levels are reported in dB
425{
426 StatVal erl; // Echo Return Loss
427 StatVal erle; // Echo Return Loss Enhancement
428 StatVal rerl; // RERL = ERL + ERLE
429 // Echo suppression inside EC at the point just before its NLP
430 StatVal a_nlp;
431} EchoStatistics;
432
niklase@google.com470e71d2011-07-07 08:21:25433enum NsModes // type of Noise Suppression
434{
435 kNsUnchanged = 0, // previously set mode
436 kNsDefault, // platform default
437 kNsConference, // conferencing default
438 kNsLowSuppression, // lowest suppression
439 kNsModerateSuppression,
440 kNsHighSuppression,
441 kNsVeryHighSuppression, // highest suppression
442};
443
444enum AgcModes // type of Automatic Gain Control
445{
446 kAgcUnchanged = 0, // previously set mode
447 kAgcDefault, // platform default
448 // adaptive mode for use when analog volume control exists (e.g. for
449 // PC softphone)
450 kAgcAdaptiveAnalog,
451 // scaling takes place in the digital domain (e.g. for conference servers
452 // and embedded devices)
453 kAgcAdaptiveDigital,
andrew@webrtc.org80124742012-03-08 17:54:24454 // can be used on embedded devices where the capture signal level
niklase@google.com470e71d2011-07-07 08:21:25455 // is predictable
456 kAgcFixedDigital
457};
458
459// EC modes
460enum EcModes // type of Echo Control
461{
462 kEcUnchanged = 0, // previously set mode
463 kEcDefault, // platform default
464 kEcConference, // conferencing default (aggressive AEC)
465 kEcAec, // Acoustic Echo Cancellation
466 kEcAecm, // AEC mobile
467};
468
469// AECM modes
470enum AecmModes // mode of AECM
471{
472 kAecmQuietEarpieceOrHeadset = 0,
473 // Quiet earpiece or headset use
474 kAecmEarpiece, // most earpiece use
475 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
476 kAecmSpeakerphone, // most speakerphone use (default)
477 kAecmLoudSpeakerphone // Loud speakerphone
478};
479
480// AGC configuration
481typedef struct
482{
483 unsigned short targetLeveldBOv;
484 unsigned short digitalCompressionGaindB;
485 bool limiterEnable;
486} AgcConfig; // AGC configuration parameters
487
488enum StereoChannel
489{
490 kStereoLeft = 0,
491 kStereoRight,
492 kStereoBoth
493};
494
495// Audio device layers
496enum AudioLayers
497{
498 kAudioPlatformDefault = 0,
499 kAudioWindowsWave = 1,
500 kAudioWindowsCore = 2,
501 kAudioLinuxAlsa = 3,
502 kAudioLinuxPulse = 4
503};
504
henrika@webrtc.org66803482014-04-17 10:45:01505// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25506enum NetEqModes // NetEQ playout configurations
507{
508 // Optimized trade-off between low delay and jitter robustness for two-way
509 // communication.
510 kNetEqDefault = 0,
511 // Improved jitter robustness at the cost of increased delay. Can be
512 // used in one-way communication.
513 kNetEqStreaming = 1,
514 // Optimzed for decodability of fax signals rather than for perceived audio
515 // quality.
516 kNetEqFax = 2,
roosa@google.comb7186192012-12-12 21:59:14517 // Minimal buffer management. Inserts zeros for lost packets and during
518 // buffer increases.
519 kNetEqOff = 3,
niklase@google.com470e71d2011-07-07 08:21:25520};
521
henrika@webrtc.org66803482014-04-17 10:45:01522// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25523enum OnHoldModes // On Hold direction
524{
525 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
526 kHoldSendOnly, // Put only sending in on-hold state.
527 kHoldPlayOnly // Put only playing in on-hold state.
528};
529
henrika@webrtc.org66803482014-04-17 10:45:01530// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25531enum AmrMode
532{
533 kRfc3267BwEfficient = 0,
534 kRfc3267OctetAligned = 1,
535 kRfc3267FileStorage = 2,
536};
537
538// ==================================================================
539// Video specific types
540// ==================================================================
541
542// Raw video types
543enum RawVideoType
544{
545 kVideoI420 = 0,
546 kVideoYV12 = 1,
547 kVideoYUY2 = 2,
548 kVideoUYVY = 3,
549 kVideoIYUV = 4,
550 kVideoARGB = 5,
551 kVideoRGB24 = 6,
552 kVideoRGB565 = 7,
553 kVideoARGB4444 = 8,
554 kVideoARGB1555 = 9,
555 kVideoMJPEG = 10,
556 kVideoNV12 = 11,
557 kVideoNV21 = 12,
mikhal@webrtc.orgc00f91d2012-01-03 18:49:15558 kVideoBGRA = 13,
niklase@google.com470e71d2011-07-07 08:21:25559 kVideoUnknown = 99
560};
561
562// Video codec
563enum { kConfigParameterSize = 128};
564enum { kPayloadNameSize = 32};
pwestin@webrtc.org1da1ce02011-10-13 15:19:55565enum { kMaxSimulcastStreams = 4};
sprangce4aef12015-11-02 15:23:20566enum { kMaxSpatialLayers = 5 };
pwestin@webrtc.orgdb221d22011-12-02 11:31:08567enum { kMaxTemporalStreams = 4};
niklase@google.com470e71d2011-07-07 08:21:25568
niklase@google.com470e71d2011-07-07 08:21:25569enum VideoCodecComplexity
570{
571 kComplexityNormal = 0,
572 kComplexityHigh = 1,
573 kComplexityHigher = 2,
574 kComplexityMax = 3
575};
576
577enum VideoCodecProfile
578{
579 kProfileBase = 0x00,
580 kProfileMain = 0x01
581};
582
stefan@webrtc.orgefd0a482011-12-29 10:12:35583enum VP8ResilienceMode {
584 kResilienceOff, // The stream produced by the encoder requires a
585 // recovery frame (typically a key frame) to be
586 // decodable after a packet loss.
587 kResilientStream, // A stream produced by the encoder is resilient to
588 // packet losses, but packets within a frame subsequent
589 // to a loss can't be decoded.
590 kResilientFrames // Same as kResilientStream but with added resilience
591 // within a frame.
592};
593
Peter Boström7b971e72016-01-19 15:26:16594class TemporalLayersFactory;
niklase@google.com470e71d2011-07-07 08:21:25595// VP8 specific
mallinath@webrtc.org0209e562014-03-21 00:41:28596struct VideoCodecVP8 {
597 bool pictureLossIndicationOn;
598 bool feedbackModeOn;
599 VideoCodecComplexity complexity;
600 VP8ResilienceMode resilience;
601 unsigned char numberOfTemporalLayers;
602 bool denoisingOn;
603 bool errorConcealmentOn;
604 bool automaticResizeOn;
605 bool frameDroppingOn;
606 int keyFrameInterval;
Peter Boström7b971e72016-01-19 15:26:16607 const TemporalLayersFactory* tl_factory;
niklase@google.com470e71d2011-07-07 08:21:25608};
609
asaperssona9455ab2015-07-31 13:10:09610// VP9 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48611struct VideoCodecVP9 {
612 VideoCodecComplexity complexity;
613 int resilience;
614 unsigned char numberOfTemporalLayers;
615 bool denoisingOn;
616 bool frameDroppingOn;
617 int keyFrameInterval;
618 bool adaptiveQpMode;
Marcof3507202015-09-17 19:16:04619 bool automaticResizeOn;
asaperssona9455ab2015-07-31 13:10:09620 unsigned char numberOfSpatialLayers;
621 bool flexibleMode;
marpan@webrtc.org5b883172014-11-01 06:10:48622};
623
stefan@webrtc.orgb9f54532014-07-04 12:42:07624// H264 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48625struct VideoCodecH264 {
626 VideoCodecProfile profile;
627 bool frameDroppingOn;
628 int keyFrameInterval;
629 // These are NULL/0 if not externally negotiated.
630 const uint8_t* spsData;
631 size_t spsLen;
632 const uint8_t* ppsData;
633 size_t ppsLen;
stefan@webrtc.orgb9f54532014-07-04 12:42:07634};
635
niklase@google.com470e71d2011-07-07 08:21:25636// Video codec types
marpan@webrtc.org5b883172014-11-01 06:10:48637enum VideoCodecType {
638 kVideoCodecVP8,
639 kVideoCodecVP9,
640 kVideoCodecH264,
641 kVideoCodecI420,
642 kVideoCodecRED,
643 kVideoCodecULPFEC,
644 kVideoCodecGeneric,
645 kVideoCodecUnknown
niklase@google.com470e71d2011-07-07 08:21:25646};
647
marpan@webrtc.org5b883172014-11-01 06:10:48648union VideoCodecUnion {
649 VideoCodecVP8 VP8;
650 VideoCodecVP9 VP9;
651 VideoCodecH264 H264;
niklase@google.com470e71d2011-07-07 08:21:25652};
653
phoglund@webrtc.org8bfee842012-02-17 09:32:48654
655// Simulcast is when the same stream is encoded multiple times with different
656// settings such as resolution.
mallinath@webrtc.org0209e562014-03-21 00:41:28657struct SimulcastStream {
658 unsigned short width;
659 unsigned short height;
660 unsigned char numberOfTemporalLayers;
661 unsigned int maxBitrate; // kilobits/sec.
662 unsigned int targetBitrate; // kilobits/sec.
663 unsigned int minBitrate; // kilobits/sec.
664 unsigned int qpMax; // minimum quality
pwestin@webrtc.org1da1ce02011-10-13 15:19:55665};
666
sprangce4aef12015-11-02 15:23:20667struct SpatialLayer {
668 int scaling_factor_num;
669 int scaling_factor_den;
670 int target_bitrate_bps;
671 // TODO(ivica): Add max_quantizer and min_quantizer?
672};
673
stefan@webrtc.orgeb917922013-02-18 14:40:18674enum VideoCodecMode {
675 kRealtimeVideo,
676 kScreensharing
677};
678
niklase@google.com470e71d2011-07-07 08:21:25679// Common video codec properties
mallinath@webrtc.org0209e562014-03-21 00:41:28680struct VideoCodec {
681 VideoCodecType codecType;
682 char plName[kPayloadNameSize];
683 unsigned char plType;
niklase@google.com470e71d2011-07-07 08:21:25684
mallinath@webrtc.org0209e562014-03-21 00:41:28685 unsigned short width;
686 unsigned short height;
niklase@google.com470e71d2011-07-07 08:21:25687
mallinath@webrtc.org0209e562014-03-21 00:41:28688 unsigned int startBitrate; // kilobits/sec.
689 unsigned int maxBitrate; // kilobits/sec.
690 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org3c412b22014-03-24 12:36:52691 unsigned int targetBitrate; // kilobits/sec.
692
mallinath@webrtc.org0209e562014-03-21 00:41:28693 unsigned char maxFramerate;
niklase@google.com470e71d2011-07-07 08:21:25694
mallinath@webrtc.org0209e562014-03-21 00:41:28695 VideoCodecUnion codecSpecific;
niklase@google.com470e71d2011-07-07 08:21:25696
mallinath@webrtc.org0209e562014-03-21 00:41:28697 unsigned int qpMax;
698 unsigned char numberOfSimulcastStreams;
699 SimulcastStream simulcastStream[kMaxSimulcastStreams];
sprangce4aef12015-11-02 15:23:20700 SpatialLayer spatialLayers[kMaxSpatialLayers];
stefan@webrtc.orgeb917922013-02-18 14:40:18701
mallinath@webrtc.org0209e562014-03-21 00:41:28702 VideoCodecMode mode;
skvlad3abb7642016-06-16 19:08:03703 bool expect_encode_from_texture;
andresp@webrtc.org185bae42013-05-14 08:02:25704
Peter Boström7b971e72016-01-19 15:26:16705 bool operator==(const VideoCodec& other) const = delete;
706 bool operator!=(const VideoCodec& other) const = delete;
niklase@google.com470e71d2011-07-07 08:21:25707};
astor@webrtc.orgbd7aeba2012-06-26 10:47:04708
stefan64c0a0a2015-11-27 09:02:31709// Bandwidth over-use detector options. These are used to drive
710// experimentation with bandwidth estimation parameters.
711// See modules/remote_bitrate_estimator/overuse_detector.h
712struct OverUseDetectorOptions {
713 OverUseDetectorOptions()
714 : initial_slope(8.0/512.0),
715 initial_offset(0),
716 initial_e(),
717 initial_process_noise(),
718 initial_avg_noise(0.0),
719 initial_var_noise(50) {
720 initial_e[0][0] = 100;
721 initial_e[1][1] = 1e-1;
722 initial_e[0][1] = initial_e[1][0] = 0;
723 initial_process_noise[0] = 1e-13;
stefan1069cac2016-03-10 13:13:21724 initial_process_noise[1] = 1e-3;
stefan64c0a0a2015-11-27 09:02:31725 }
726 double initial_slope;
727 double initial_offset;
728 double initial_e[2][2];
729 double initial_process_noise[2];
730 double initial_avg_noise;
731 double initial_var_noise;
732};
733
wu@webrtc.orga9890802013-12-13 00:21:03734// This structure will have the information about when packet is actually
735// received by socket.
736struct PacketTime {
henrike@webrtc.org82d3cb62014-04-29 17:50:47737 PacketTime() : timestamp(-1), not_before(-1) {}
738 PacketTime(int64_t timestamp, int64_t not_before)
739 : timestamp(timestamp), not_before(not_before) {
wu@webrtc.orga9890802013-12-13 00:21:03740 }
741
henrike@webrtc.org82d3cb62014-04-29 17:50:47742 int64_t timestamp; // Receive time after socket delivers the data.
743 int64_t not_before; // Earliest possible time the data could have arrived,
744 // indicating the potential error in the |timestamp|
745 // value,in case the system is busy.
746 // For example, the time of the last select() call.
747 // If unknown, this value will be set to zero.
wu@webrtc.orga9890802013-12-13 00:21:03748};
749
isheriff6b4b5f32016-06-08 07:24:21750// Minimum and maximum playout delay values from capture to render.
751// These are best effort values.
752//
753// A value < 0 indicates no change from previous valid value.
754//
755// min = max = 0 indicates that the receiver should try and render
756// frame as soon as possible.
757//
758// min = x, max = y indicates that the receiver is free to adapt
759// in the range (x, y) based on network jitter.
760//
761// Note: Given that this gets embedded in a union, it is up-to the owner to
762// initialize these values.
763struct PlayoutDelay {
764 int min_ms;
765 int max_ms;
766};
767
solenberg@webrtc.orgb1f50102014-03-24 10:38:25768struct RTPHeaderExtension {
sprang@webrtc.org30933902015-03-17 14:33:12769 RTPHeaderExtension();
solenberg@webrtc.orgb1f50102014-03-24 10:38:25770
771 bool hasTransmissionTimeOffset;
772 int32_t transmissionTimeOffset;
773 bool hasAbsoluteSendTime;
774 uint32_t absoluteSendTime;
sprang@webrtc.org30933902015-03-17 14:33:12775 bool hasTransportSequenceNumber;
776 uint16_t transportSequenceNumber;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25777
778 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
779 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
780 bool hasAudioLevel;
Minyue4cee4192015-08-10 13:08:36781 bool voiceActivity;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25782 uint8_t audioLevel;
guoweis@webrtc.org45362892015-03-04 22:55:15783
784 // For Coordination of Video Orientation. See
785 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
786 // ts_126114v120700p.pdf
787 bool hasVideoRotation;
788 uint8_t videoRotation;
isheriff6b4b5f32016-06-08 07:24:21789
790 PlayoutDelay playout_delay = {-1, -1};
solenberg@webrtc.orgb1f50102014-03-24 10:38:25791};
792
793struct RTPHeader {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22794 RTPHeader();
solenberg@webrtc.orgb1f50102014-03-24 10:38:25795
796 bool markerBit;
797 uint8_t payloadType;
798 uint16_t sequenceNumber;
799 uint32_t timestamp;
800 uint32_t ssrc;
801 uint8_t numCSRCs;
802 uint32_t arrOfCSRCs[kRtpCsrcSize];
pkasting@chromium.org4591fbd2014-11-20 22:28:14803 size_t paddingLength;
804 size_t headerLength;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25805 int payload_type_frequency;
806 RTPHeaderExtension extension;
807};
808
asapersson@webrtc.org44149392015-02-04 08:34:47809struct RtpPacketCounter {
810 RtpPacketCounter()
811 : header_bytes(0),
812 payload_bytes(0),
813 padding_bytes(0),
814 packets(0) {}
815
816 void Add(const RtpPacketCounter& other) {
817 header_bytes += other.header_bytes;
818 payload_bytes += other.payload_bytes;
819 padding_bytes += other.padding_bytes;
820 packets += other.packets;
821 }
822
Erik Språng22c2b482016-03-01 08:40:42823 void Subtract(const RtpPacketCounter& other) {
824 assert(header_bytes >= other.header_bytes);
825 header_bytes -= other.header_bytes;
826 assert(payload_bytes >= other.payload_bytes);
827 payload_bytes -= other.payload_bytes;
828 assert(padding_bytes >= other.padding_bytes);
829 padding_bytes -= other.padding_bytes;
830 assert(packets >= other.packets);
831 packets -= other.packets;
832 }
833
asapersson@webrtc.org44149392015-02-04 08:34:47834 void AddPacket(size_t packet_length, const RTPHeader& header) {
835 ++packets;
836 header_bytes += header.headerLength;
837 padding_bytes += header.paddingLength;
838 payload_bytes +=
839 packet_length - (header.headerLength + header.paddingLength);
840 }
841
842 size_t TotalBytes() const {
843 return header_bytes + payload_bytes + padding_bytes;
844 }
845
846 size_t header_bytes; // Number of bytes used by RTP headers.
847 size_t payload_bytes; // Payload bytes, excluding RTP headers and padding.
848 size_t padding_bytes; // Number of padding bytes.
849 uint32_t packets; // Number of packets.
850};
851
852// Data usage statistics for a (rtp) stream.
853struct StreamDataCounters {
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22854 StreamDataCounters();
asapersson@webrtc.org44149392015-02-04 08:34:47855
856 void Add(const StreamDataCounters& other) {
857 transmitted.Add(other.transmitted);
858 retransmitted.Add(other.retransmitted);
859 fec.Add(other.fec);
860 if (other.first_packet_time_ms != -1 &&
861 (other.first_packet_time_ms < first_packet_time_ms ||
862 first_packet_time_ms == -1)) {
863 // Use oldest time.
864 first_packet_time_ms = other.first_packet_time_ms;
865 }
866 }
867
Erik Språng22c2b482016-03-01 08:40:42868 void Subtract(const StreamDataCounters& other) {
869 transmitted.Subtract(other.transmitted);
870 retransmitted.Subtract(other.retransmitted);
871 fec.Subtract(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 youngest time.
876 first_packet_time_ms = other.first_packet_time_ms;
877 }
878 }
879
asapersson@webrtc.org44149392015-02-04 08:34:47880 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};
pbosda903ea2015-10-02 09:36:56906
907// RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size
908// RTCP mode is described by RFC 5506.
909enum class RtcpMode { kOff, kCompound, kReducedSize };
910
pbos1ba8d392016-05-02 03:18:34911enum NetworkState {
912 kNetworkUp,
913 kNetworkDown,
914};
915
niklase@google.com470e71d2011-07-07 08:21:25916} // namespace webrtc
andrew@webrtc.orgeda189b2013-09-09 17:50:10917
918#endif // WEBRTC_COMMON_TYPES_H_