blob: 13d0c3f8089cd48c73ec91612c4d6583ef0d79dd [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:231/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
andrew@webrtc.org5cf83f42013-09-09 17:50:1011#ifndef WEBRTC_COMMON_TYPES_H_
12#define WEBRTC_COMMON_TYPES_H_
andrew@webrtc.orgb015cbe2012-10-22 18:19:2313
Erik Språng01cff722016-03-01 08:40:4214#include <assert.h>
pbos@webrtc.orge2a7a772014-03-19 08:43:5715#include <stddef.h>
mallinath@webrtc.org18c29452014-03-21 00:41:2816#include <string.h>
pbos@webrtc.org7e686932014-05-15 09:35:0617
18#include <string>
pbos@webrtc.orge2a7a772014-03-19 08:43:5719#include <vector>
20
andrew@webrtc.org5cf83f42013-09-09 17:50:1021#include "webrtc/typedefs.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:2322
23#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
29#ifdef WEBRTC_EXPORT
30#define WEBRTC_DLLEXPORT _declspec(dllexport)
31#elif WEBRTC_DLL
32#define WEBRTC_DLLEXPORT _declspec(dllimport)
33#else
34#define WEBRTC_DLLEXPORT
35#endif
36
37#ifndef NULL
38#define NULL 0
39#endif
40
Peter Boströmcd71dc62016-02-26 15:31:3741#define RTP_PAYLOAD_NAME_SIZE 32u
andrew@webrtc.orgb015cbe2012-10-22 18:19:2342
mallinath@webrtc.org18c29452014-03-21 00:41:2843#if defined(WEBRTC_WIN) || defined(WIN32)
andrew@webrtc.org5cf83f42013-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
andrew@webrtc.orgb015cbe2012-10-22 18:19:2353namespace webrtc {
54
andresp@webrtc.orgee6f8a22013-05-14 08:02:2555class Config;
56
tommia6d985c2016-06-15 17:30:1457class RewindableStream {
58 public:
59 virtual ~RewindableStream() {}
60 virtual int Rewind() = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2361};
62
tommia6d985c2016-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;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2375};
76
77enum TraceModule
78{
pbos@webrtc.org46f72882013-12-16 12:24:4479 kTraceUndefined = 0,
andrew@webrtc.orgb015cbe2012-10-22 18:19:2380 // not a module, triggered from the engine code
pbos@webrtc.org46f72882013-12-16 12:24:4481 kTraceVoice = 0x0001,
andrew@webrtc.orgb015cbe2012-10-22 18:19:2382 // not a module, triggered from the engine code
pbos@webrtc.org46f72882013-12-16 12:24:4483 kTraceVideo = 0x0002,
andrew@webrtc.orgb015cbe2012-10-22 18:19:2384 // not a module, triggered from the utility code
pbos@webrtc.org46f72882013-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.org46f72882013-12-16 12:24:4499 kTraceRemoteBitrateEstimator = 0x0017,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23100};
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.orgbc687c52012-11-20 07:34:45121 // Non-verbose level used by LS_INFO of logging.h. Do not use directly.
122 kTraceTerseInfo = 0x2000,
123
andrew@webrtc.orgb015cbe2012-10-22 18:19:23124 kTraceAll = 0xffff
125};
126
127// External Trace API
andrew@webrtc.orgd75680a2012-11-15 05:33:25128class TraceCallback {
129 public:
130 virtual void Print(TraceLevel level, const char* message, int length) = 0;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23131
andrew@webrtc.orgd75680a2012-11-15 05:33:25132 protected:
133 virtual ~TraceCallback() {}
134 TraceCallback() {}
135};
andrew@webrtc.orgb015cbe2012-10-22 18:19:23136
137enum FileFormats
138{
139 kFileFormatWavFile = 1,
140 kFileFormatCompressedFile = 2,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23141 kFileFormatPreencodedFile = 4,
142 kFileFormatPcm16kHzFile = 7,
143 kFileFormatPcm8kHzFile = 8,
144 kFileFormatPcm32kHzFile = 9
145};
146
andrew@webrtc.orgb015cbe2012-10-22 18:19:23147enum ProcessingTypes
148{
149 kPlaybackPerChannel = 0,
150 kPlaybackAllChannelsMixed,
151 kRecordingPerChannel,
152 kRecordingAllChannelsMixed,
153 kRecordingPreprocessing
154};
155
pbosb63d8ad2015-10-19 09:39:06156enum FrameType {
157 kEmptyFrame = 0,
158 kAudioFrameSpeech = 1,
159 kAudioFrameCN = 2,
160 kVideoFrameKey = 3,
161 kVideoFrameDelta = 4,
sprang@webrtc.org5fdd10a2013-12-04 15:09:27162};
163
sprang@webrtc.org46736742013-11-20 16:47:07164// Statistics for an RTCP channel
sprang@webrtc.org2714c792013-10-28 09:21:07165struct RtcpStatistics {
sprang@webrtc.org2714c792013-10-28 09:21:07166 RtcpStatistics()
167 : fraction_lost(0),
168 cumulative_lost(0),
169 extended_max_sequence_number(0),
sprang@webrtc.org9b30fd32013-12-05 09:48:44170 jitter(0) {}
sprang@webrtc.org2714c792013-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.org2714c792013-10-28 09:21:07176};
177
sprang@webrtc.org46736742013-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.org1a36f782014-12-18 13:50:16184 virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0;
sprang@webrtc.org46736742013-11-20 16:47:07185};
186
asapersson@webrtc.org4a155602014-02-19 11:59:02187// Statistics for RTCP packet types.
188struct RtcpPacketTypeCounter {
189 RtcpPacketTypeCounter()
asapersson@webrtc.orgc76c5532014-12-16 12:03:11190 : first_packet_time_ms(-1),
191 nack_packets(0),
asapersson@webrtc.org4a155602014-02-19 11:59:02192 fir_packets(0),
asapersson@webrtc.org2ba45ee2014-10-29 12:42:30193 pli_packets(0),
194 nack_requests(0),
195 unique_nack_requests(0) {}
asapersson@webrtc.org4a155602014-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.org2ba45ee2014-10-29 12:42:30201 nack_requests += other.nack_requests;
202 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.orgc76c5532014-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
sprang22c956d2016-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.orgc76c5532014-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.org4a155602014-02-19 11:59:02227 }
228
asapersson@webrtc.org2ba45ee2014-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.orgc76c5532014-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.org2ba45ee2014-10-29 12:42:30242 uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
asapersson@webrtc.org4a155602014-02-19 11:59:02243};
244
pbos@webrtc.orgeb1c2b52015-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.orgc76c5532014-12-16 12:03:11253// Rate statistics for a stream.
sprang@webrtc.org46736742013-11-20 16:47:07254struct BitrateStatistics {
sprang@webrtc.orgb70db6d2013-12-13 09:46:59255 BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
sprang@webrtc.org46736742013-11-20 16:47:07256
sprang@webrtc.orgb70db6d2013-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.
259 uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation.
sprang@webrtc.org46736742013-11-20 16:47:07260};
261
262// Callback, used to notify an observer whenever new rates have been estimated.
263class BitrateStatisticsObserver {
264 public:
265 virtual ~BitrateStatisticsObserver() {}
266
stefan@webrtc.org52322672014-11-05 14:05:29267 virtual void Notify(const BitrateStatistics& total_stats,
268 const BitrateStatistics& retransmit_stats,
269 uint32_t ssrc) = 0;
sprang@webrtc.org46736742013-11-20 16:47:07270};
271
pbos@webrtc.org1a36f782014-12-18 13:50:16272struct FrameCounts {
273 FrameCounts() : key_frames(0), delta_frames(0) {}
274 int key_frames;
275 int delta_frames;
276};
277
asapersson@webrtc.orgc76c5532014-12-16 12:03:11278// Callback, used to notify an observer whenever frame counts have been updated.
sprang@webrtc.org46736742013-11-20 16:47:07279class FrameCountObserver {
280 public:
sprang@webrtc.org21dc10d2013-11-21 09:09:54281 virtual ~FrameCountObserver() {}
pbos@webrtc.org1a36f782014-12-18 13:50:16282 virtual void FrameCountUpdated(const FrameCounts& frame_counts,
283 uint32_t ssrc) = 0;
sprang@webrtc.org46736742013-11-20 16:47:07284};
285
stefan@webrtc.org55b0f2e2014-07-11 13:44:02286// Callback, used to notify an observer whenever the send-side delay is updated.
287class SendSideDelayObserver {
288 public:
289 virtual ~SendSideDelayObserver() {}
290 virtual void SendSideDelayUpdated(int avg_delay_ms,
291 int max_delay_ms,
292 uint32_t ssrc) = 0;
293};
294
asapersson86a285e2016-05-03 06:44:01295// Callback, used to notify an observer whenever a packet is sent to the
296// transport.
297// TODO(asapersson): This class will remove the need for SendSideDelayObserver.
298// Remove SendSideDelayObserver once possible.
299class SendPacketObserver {
300 public:
301 virtual ~SendPacketObserver() {}
302 virtual void OnSendPacket(uint16_t packet_id,
303 int64_t capture_time_ms,
304 uint32_t ssrc) = 0;
305};
306
andrew@webrtc.orgb015cbe2012-10-22 18:19:23307// ==================================================================
308// Voice specific types
309// ==================================================================
310
311// Each codec supported can be described by this structure.
mallinath@webrtc.org18c29452014-03-21 00:41:28312struct CodecInst {
313 int pltype;
314 char plname[RTP_PAYLOAD_NAME_SIZE];
315 int plfreq;
316 int pacsize;
Peter Kasting80590d92016-01-13 00:26:35317 size_t channels;
mallinath@webrtc.org18c29452014-03-21 00:41:28318 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
319
320 bool operator==(const CodecInst& other) const {
321 return pltype == other.pltype &&
322 (STR_CASE_CMP(plname, other.plname) == 0) &&
323 plfreq == other.plfreq &&
324 pacsize == other.pacsize &&
325 channels == other.channels &&
326 rate == other.rate;
327 }
328
329 bool operator!=(const CodecInst& other) const {
330 return !(*this == other);
331 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:23332};
333
andrew@webrtc.orgb015cbe2012-10-22 18:19:23334// RTP
335enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
336
andrew@webrtc.orgb015cbe2012-10-22 18:19:23337enum PayloadFrequencies
338{
339 kFreq8000Hz = 8000,
340 kFreq16000Hz = 16000,
341 kFreq32000Hz = 32000
342};
343
344enum VadModes // degree of bandwidth reduction
345{
346 kVadConventional = 0, // lowest reduction
347 kVadAggressiveLow,
348 kVadAggressiveMid,
349 kVadAggressiveHigh // highest reduction
350};
351
352struct NetworkStatistics // NETEQ statistics
353{
354 // current jitter buffer size in ms
pbos@webrtc.org52b2ee52013-05-03 12:02:11355 uint16_t currentBufferSize;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23356 // preferred (optimal) buffer size in ms
pbos@webrtc.org52b2ee52013-05-03 12:02:11357 uint16_t preferredBufferSize;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23358 // adding extra delay due to "peaky jitter"
359 bool jitterPeaksFound;
henrik.lundin@webrtc.org6e7480a2014-10-09 12:58:45360 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org52b2ee52013-05-03 12:02:11361 uint16_t currentPacketLossRate;
henrik.lundin@webrtc.org6e7480a2014-10-09 12:58:45362 // Late loss rate; fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org52b2ee52013-05-03 12:02:11363 uint16_t currentDiscardRate;
minyue@webrtc.org5f8d2882015-02-18 15:24:13364 // fraction (of original stream) of synthesized audio inserted through
andrew@webrtc.orgb015cbe2012-10-22 18:19:23365 // expansion (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11366 uint16_t currentExpandRate;
minyue@webrtc.org5f8d2882015-02-18 15:24:13367 // fraction (of original stream) of synthesized speech inserted through
368 // expansion (in Q14)
369 uint16_t currentSpeechExpandRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23370 // fraction of synthesized speech inserted through pre-emptive expansion
371 // (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11372 uint16_t currentPreemptiveRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23373 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.org52b2ee52013-05-03 12:02:11374 uint16_t currentAccelerateRate;
minyue@webrtc.org5f8d2882015-02-18 15:24:13375 // fraction of data coming from secondary decoding (in Q14)
376 uint16_t currentSecondaryDecodedRate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23377 // clock-drift in parts-per-million (negative or positive)
378 int32_t clockDriftPPM;
379 // average packet waiting time in the jitter buffer (ms)
380 int meanWaitingTimeMs;
381 // median packet waiting time in the jitter buffer (ms)
382 int medianWaitingTimeMs;
383 // min packet waiting time in the jitter buffer (ms)
384 int minWaitingTimeMs;
385 // max packet waiting time in the jitter buffer (ms)
386 int maxWaitingTimeMs;
roosa@google.com0049a762012-12-14 00:06:18387 // added samples in off mode due to packet loss
Peter Kastinga0ad2482015-08-24 21:52:23388 size_t addedSamples;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23389};
390
wu@webrtc.org79d6daf2013-12-13 19:17:43391// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
392struct AudioDecodingCallStats {
393 AudioDecodingCallStats()
394 : calls_to_silence_generator(0),
395 calls_to_neteq(0),
396 decoded_normal(0),
397 decoded_plc(0),
398 decoded_cng(0),
399 decoded_plc_cng(0) {}
400
401 int calls_to_silence_generator; // Number of calls where silence generated,
402 // and NetEq was disengaged from decoding.
403 int calls_to_neteq; // Number of calls to NetEq.
404 int decoded_normal; // Number of calls where audio RTP packet decoded.
405 int decoded_plc; // Number of calls resulted in PLC.
406 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
407 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
408};
409
andrew@webrtc.orgb015cbe2012-10-22 18:19:23410typedef struct
411{
412 int min; // minumum
413 int max; // maximum
414 int average; // average
415} StatVal;
416
417typedef struct // All levels are reported in dBm0
418{
419 StatVal speech_rx; // long-term speech levels on receiving side
420 StatVal speech_tx; // long-term speech levels on transmitting side
421 StatVal noise_rx; // long-term noise/silence levels on receiving side
422 StatVal noise_tx; // long-term noise/silence levels on transmitting side
423} LevelStatistics;
424
425typedef struct // All levels are reported in dB
426{
427 StatVal erl; // Echo Return Loss
428 StatVal erle; // Echo Return Loss Enhancement
429 StatVal rerl; // RERL = ERL + ERLE
430 // Echo suppression inside EC at the point just before its NLP
431 StatVal a_nlp;
432} EchoStatistics;
433
andrew@webrtc.orgb015cbe2012-10-22 18:19:23434enum NsModes // type of Noise Suppression
435{
436 kNsUnchanged = 0, // previously set mode
437 kNsDefault, // platform default
438 kNsConference, // conferencing default
439 kNsLowSuppression, // lowest suppression
440 kNsModerateSuppression,
441 kNsHighSuppression,
442 kNsVeryHighSuppression, // highest suppression
443};
444
445enum AgcModes // type of Automatic Gain Control
446{
447 kAgcUnchanged = 0, // previously set mode
448 kAgcDefault, // platform default
449 // adaptive mode for use when analog volume control exists (e.g. for
450 // PC softphone)
451 kAgcAdaptiveAnalog,
452 // scaling takes place in the digital domain (e.g. for conference servers
453 // and embedded devices)
454 kAgcAdaptiveDigital,
455 // can be used on embedded devices where the capture signal level
456 // is predictable
457 kAgcFixedDigital
458};
459
460// EC modes
461enum EcModes // type of Echo Control
462{
463 kEcUnchanged = 0, // previously set mode
464 kEcDefault, // platform default
465 kEcConference, // conferencing default (aggressive AEC)
466 kEcAec, // Acoustic Echo Cancellation
467 kEcAecm, // AEC mobile
468};
469
470// AECM modes
471enum AecmModes // mode of AECM
472{
473 kAecmQuietEarpieceOrHeadset = 0,
474 // Quiet earpiece or headset use
475 kAecmEarpiece, // most earpiece use
476 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
477 kAecmSpeakerphone, // most speakerphone use (default)
478 kAecmLoudSpeakerphone // Loud speakerphone
479};
480
481// AGC configuration
482typedef struct
483{
484 unsigned short targetLeveldBOv;
485 unsigned short digitalCompressionGaindB;
486 bool limiterEnable;
487} AgcConfig; // AGC configuration parameters
488
489enum StereoChannel
490{
491 kStereoLeft = 0,
492 kStereoRight,
493 kStereoBoth
494};
495
496// Audio device layers
497enum AudioLayers
498{
499 kAudioPlatformDefault = 0,
500 kAudioWindowsWave = 1,
501 kAudioWindowsCore = 2,
502 kAudioLinuxAlsa = 3,
503 kAudioLinuxPulse = 4
504};
505
henrika@webrtc.org692224a2014-04-17 10:45:01506// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23507enum NetEqModes // NetEQ playout configurations
508{
509 // Optimized trade-off between low delay and jitter robustness for two-way
510 // communication.
511 kNetEqDefault = 0,
512 // Improved jitter robustness at the cost of increased delay. Can be
513 // used in one-way communication.
514 kNetEqStreaming = 1,
515 // Optimzed for decodability of fax signals rather than for perceived audio
516 // quality.
517 kNetEqFax = 2,
roosa@google.com90d333e2012-12-12 21:59:14518 // Minimal buffer management. Inserts zeros for lost packets and during
519 // buffer increases.
520 kNetEqOff = 3,
andrew@webrtc.orgb015cbe2012-10-22 18:19:23521};
522
henrika@webrtc.org692224a2014-04-17 10:45:01523// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23524enum OnHoldModes // On Hold direction
525{
526 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
527 kHoldSendOnly, // Put only sending in on-hold state.
528 kHoldPlayOnly // Put only playing in on-hold state.
529};
530
henrika@webrtc.org692224a2014-04-17 10:45:01531// TODO(henrika): to be removed.
andrew@webrtc.orgb015cbe2012-10-22 18:19:23532enum AmrMode
533{
534 kRfc3267BwEfficient = 0,
535 kRfc3267OctetAligned = 1,
536 kRfc3267FileStorage = 2,
537};
538
539// ==================================================================
540// Video specific types
541// ==================================================================
542
543// Raw video types
544enum RawVideoType
545{
546 kVideoI420 = 0,
547 kVideoYV12 = 1,
548 kVideoYUY2 = 2,
549 kVideoUYVY = 3,
550 kVideoIYUV = 4,
551 kVideoARGB = 5,
552 kVideoRGB24 = 6,
553 kVideoRGB565 = 7,
554 kVideoARGB4444 = 8,
555 kVideoARGB1555 = 9,
556 kVideoMJPEG = 10,
557 kVideoNV12 = 11,
558 kVideoNV21 = 12,
559 kVideoBGRA = 13,
560 kVideoUnknown = 99
561};
562
563// Video codec
564enum { kConfigParameterSize = 128};
565enum { kPayloadNameSize = 32};
566enum { kMaxSimulcastStreams = 4};
sprang0ba16d12015-11-02 15:23:20567enum { kMaxSpatialLayers = 5 };
andrew@webrtc.orgb015cbe2012-10-22 18:19:23568enum { kMaxTemporalStreams = 4};
569
570enum VideoCodecComplexity
571{
572 kComplexityNormal = 0,
573 kComplexityHigh = 1,
574 kComplexityHigher = 2,
575 kComplexityMax = 3
576};
577
578enum VideoCodecProfile
579{
580 kProfileBase = 0x00,
581 kProfileMain = 0x01
582};
583
584enum VP8ResilienceMode {
585 kResilienceOff, // The stream produced by the encoder requires a
586 // recovery frame (typically a key frame) to be
587 // decodable after a packet loss.
588 kResilientStream, // A stream produced by the encoder is resilient to
589 // packet losses, but packets within a frame subsequent
590 // to a loss can't be decoded.
591 kResilientFrames // Same as kResilientStream but with added resilience
592 // within a frame.
593};
594
Peter Boströmd1460022016-01-19 15:26:16595class TemporalLayersFactory;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23596// VP8 specific
mallinath@webrtc.org18c29452014-03-21 00:41:28597struct VideoCodecVP8 {
598 bool pictureLossIndicationOn;
599 bool feedbackModeOn;
600 VideoCodecComplexity complexity;
601 VP8ResilienceMode resilience;
602 unsigned char numberOfTemporalLayers;
603 bool denoisingOn;
604 bool errorConcealmentOn;
605 bool automaticResizeOn;
606 bool frameDroppingOn;
607 int keyFrameInterval;
Peter Boströmd1460022016-01-19 15:26:16608 const TemporalLayersFactory* tl_factory;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23609};
610
asapersson62407972015-07-31 13:10:09611// VP9 specific.
marpan@webrtc.org66373882014-11-01 06:10:48612struct VideoCodecVP9 {
613 VideoCodecComplexity complexity;
614 int resilience;
615 unsigned char numberOfTemporalLayers;
616 bool denoisingOn;
617 bool frameDroppingOn;
618 int keyFrameInterval;
619 bool adaptiveQpMode;
Marcoe8b7e112015-09-17 19:16:04620 bool automaticResizeOn;
asapersson62407972015-07-31 13:10:09621 unsigned char numberOfSpatialLayers;
622 bool flexibleMode;
marpan@webrtc.org66373882014-11-01 06:10:48623};
624
stefan@webrtc.org2d4a80c2014-07-04 12:42:07625// H264 specific.
marpan@webrtc.org66373882014-11-01 06:10:48626struct VideoCodecH264 {
627 VideoCodecProfile profile;
628 bool frameDroppingOn;
629 int keyFrameInterval;
630 // These are NULL/0 if not externally negotiated.
631 const uint8_t* spsData;
632 size_t spsLen;
633 const uint8_t* ppsData;
634 size_t ppsLen;
stefan@webrtc.org2d4a80c2014-07-04 12:42:07635};
636
andrew@webrtc.orgb015cbe2012-10-22 18:19:23637// Video codec types
marpan@webrtc.org66373882014-11-01 06:10:48638enum VideoCodecType {
639 kVideoCodecVP8,
640 kVideoCodecVP9,
641 kVideoCodecH264,
642 kVideoCodecI420,
643 kVideoCodecRED,
644 kVideoCodecULPFEC,
645 kVideoCodecGeneric,
646 kVideoCodecUnknown
andrew@webrtc.orgb015cbe2012-10-22 18:19:23647};
648
marpan@webrtc.org66373882014-11-01 06:10:48649union VideoCodecUnion {
650 VideoCodecVP8 VP8;
651 VideoCodecVP9 VP9;
652 VideoCodecH264 H264;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23653};
654
655
656// Simulcast is when the same stream is encoded multiple times with different
657// settings such as resolution.
mallinath@webrtc.org18c29452014-03-21 00:41:28658struct SimulcastStream {
659 unsigned short width;
660 unsigned short height;
661 unsigned char numberOfTemporalLayers;
662 unsigned int maxBitrate; // kilobits/sec.
663 unsigned int targetBitrate; // kilobits/sec.
664 unsigned int minBitrate; // kilobits/sec.
665 unsigned int qpMax; // minimum quality
andrew@webrtc.orgb015cbe2012-10-22 18:19:23666};
667
sprang0ba16d12015-11-02 15:23:20668struct SpatialLayer {
669 int scaling_factor_num;
670 int scaling_factor_den;
671 int target_bitrate_bps;
672 // TODO(ivica): Add max_quantizer and min_quantizer?
673};
674
stefan@webrtc.orgf4d37882013-02-18 14:40:18675enum VideoCodecMode {
676 kRealtimeVideo,
677 kScreensharing
678};
679
andrew@webrtc.orgb015cbe2012-10-22 18:19:23680// Common video codec properties
mallinath@webrtc.org18c29452014-03-21 00:41:28681struct VideoCodec {
682 VideoCodecType codecType;
683 char plName[kPayloadNameSize];
684 unsigned char plType;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23685
mallinath@webrtc.org18c29452014-03-21 00:41:28686 unsigned short width;
687 unsigned short height;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23688
mallinath@webrtc.org18c29452014-03-21 00:41:28689 unsigned int startBitrate; // kilobits/sec.
690 unsigned int maxBitrate; // kilobits/sec.
691 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org3d6910c2014-03-24 12:36:52692 unsigned int targetBitrate; // kilobits/sec.
693
mallinath@webrtc.org18c29452014-03-21 00:41:28694 unsigned char maxFramerate;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23695
mallinath@webrtc.org18c29452014-03-21 00:41:28696 VideoCodecUnion codecSpecific;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23697
mallinath@webrtc.org18c29452014-03-21 00:41:28698 unsigned int qpMax;
699 unsigned char numberOfSimulcastStreams;
700 SimulcastStream simulcastStream[kMaxSimulcastStreams];
sprang0ba16d12015-11-02 15:23:20701 SpatialLayer spatialLayers[kMaxSpatialLayers];
stefan@webrtc.orgf4d37882013-02-18 14:40:18702
mallinath@webrtc.org18c29452014-03-21 00:41:28703 VideoCodecMode mode;
skvlad48be0542016-06-16 19:08:03704 bool expect_encode_from_texture;
andresp@webrtc.orgee6f8a22013-05-14 08:02:25705
Peter Boströmd1460022016-01-19 15:26:16706 bool operator==(const VideoCodec& other) const = delete;
707 bool operator!=(const VideoCodec& other) const = delete;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23708};
709
stefan12764bc2015-11-27 09:02:31710// Bandwidth over-use detector options. These are used to drive
711// experimentation with bandwidth estimation parameters.
712// See modules/remote_bitrate_estimator/overuse_detector.h
713struct OverUseDetectorOptions {
714 OverUseDetectorOptions()
715 : initial_slope(8.0/512.0),
716 initial_offset(0),
717 initial_e(),
718 initial_process_noise(),
719 initial_avg_noise(0.0),
720 initial_var_noise(50) {
721 initial_e[0][0] = 100;
722 initial_e[1][1] = 1e-1;
723 initial_e[0][1] = initial_e[1][0] = 0;
724 initial_process_noise[0] = 1e-13;
stefan84d41a32016-03-10 13:13:21725 initial_process_noise[1] = 1e-3;
stefan12764bc2015-11-27 09:02:31726 }
727 double initial_slope;
728 double initial_offset;
729 double initial_e[2][2];
730 double initial_process_noise[2];
731 double initial_avg_noise;
732 double initial_var_noise;
733};
734
wu@webrtc.orgefeb8ce2013-12-13 00:21:03735// This structure will have the information about when packet is actually
736// received by socket.
737struct PacketTime {
henrike@webrtc.org93ae8212014-04-29 17:50:47738 PacketTime() : timestamp(-1), not_before(-1) {}
739 PacketTime(int64_t timestamp, int64_t not_before)
740 : timestamp(timestamp), not_before(not_before) {
wu@webrtc.orgefeb8ce2013-12-13 00:21:03741 }
742
henrike@webrtc.org93ae8212014-04-29 17:50:47743 int64_t timestamp; // Receive time after socket delivers the data.
744 int64_t not_before; // Earliest possible time the data could have arrived,
745 // indicating the potential error in the |timestamp|
746 // value,in case the system is busy.
747 // For example, the time of the last select() call.
748 // If unknown, this value will be set to zero.
wu@webrtc.orgefeb8ce2013-12-13 00:21:03749};
750
isheriff00cc0452016-06-08 07:24:21751// Minimum and maximum playout delay values from capture to render.
752// These are best effort values.
753//
754// A value < 0 indicates no change from previous valid value.
755//
756// min = max = 0 indicates that the receiver should try and render
757// frame as soon as possible.
758//
759// min = x, max = y indicates that the receiver is free to adapt
760// in the range (x, y) based on network jitter.
761//
762// Note: Given that this gets embedded in a union, it is up-to the owner to
763// initialize these values.
764struct PlayoutDelay {
765 int min_ms;
766 int max_ms;
767};
768
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25769struct RTPHeaderExtension {
sprang@webrtc.org25ec20f2015-03-17 14:33:12770 RTPHeaderExtension();
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25771
772 bool hasTransmissionTimeOffset;
773 int32_t transmissionTimeOffset;
774 bool hasAbsoluteSendTime;
775 uint32_t absoluteSendTime;
sprang@webrtc.org25ec20f2015-03-17 14:33:12776 bool hasTransportSequenceNumber;
777 uint16_t transportSequenceNumber;
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25778
779 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
780 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
781 bool hasAudioLevel;
Minyueda4c0f02015-08-10 13:08:36782 bool voiceActivity;
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25783 uint8_t audioLevel;
guoweis@webrtc.org5f74fcf2015-03-04 22:55:15784
785 // For Coordination of Video Orientation. See
786 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
787 // ts_126114v120700p.pdf
788 bool hasVideoRotation;
789 uint8_t videoRotation;
isheriff00cc0452016-06-08 07:24:21790
791 PlayoutDelay playout_delay = {-1, -1};
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25792};
793
794struct RTPHeader {
kwiberg@webrtc.orgc4e2cd02015-02-26 13:59:22795 RTPHeader();
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25796
797 bool markerBit;
798 uint8_t payloadType;
799 uint16_t sequenceNumber;
800 uint32_t timestamp;
801 uint32_t ssrc;
802 uint8_t numCSRCs;
803 uint32_t arrOfCSRCs[kRtpCsrcSize];
pkasting@chromium.org0ab923a2014-11-20 22:28:14804 size_t paddingLength;
805 size_t headerLength;
solenberg@webrtc.orgfec6b6e2014-03-24 10:38:25806 int payload_type_frequency;
807 RTPHeaderExtension extension;
808};
809
asapersson@webrtc.org1a8794b2015-02-04 08:34:47810struct RtpPacketCounter {
811 RtpPacketCounter()
812 : header_bytes(0),
813 payload_bytes(0),
814 padding_bytes(0),
815 packets(0) {}
816
817 void Add(const RtpPacketCounter& other) {
818 header_bytes += other.header_bytes;
819 payload_bytes += other.payload_bytes;
820 padding_bytes += other.padding_bytes;
821 packets += other.packets;
822 }
823
Erik Språng01cff722016-03-01 08:40:42824 void Subtract(const RtpPacketCounter& other) {
825 assert(header_bytes >= other.header_bytes);
826 header_bytes -= other.header_bytes;
827 assert(payload_bytes >= other.payload_bytes);
828 payload_bytes -= other.payload_bytes;
829 assert(padding_bytes >= other.padding_bytes);
830 padding_bytes -= other.padding_bytes;
831 assert(packets >= other.packets);
832 packets -= other.packets;
833 }
834
asapersson@webrtc.org1a8794b2015-02-04 08:34:47835 void AddPacket(size_t packet_length, const RTPHeader& header) {
836 ++packets;
837 header_bytes += header.headerLength;
838 padding_bytes += header.paddingLength;
839 payload_bytes +=
840 packet_length - (header.headerLength + header.paddingLength);
841 }
842
843 size_t TotalBytes() const {
844 return header_bytes + payload_bytes + padding_bytes;
845 }
846
847 size_t header_bytes; // Number of bytes used by RTP headers.
848 size_t payload_bytes; // Payload bytes, excluding RTP headers and padding.
849 size_t padding_bytes; // Number of padding bytes.
850 uint32_t packets; // Number of packets.
851};
852
853// Data usage statistics for a (rtp) stream.
854struct StreamDataCounters {
kwiberg@webrtc.orgc4e2cd02015-02-26 13:59:22855 StreamDataCounters();
asapersson@webrtc.org1a8794b2015-02-04 08:34:47856
857 void Add(const StreamDataCounters& other) {
858 transmitted.Add(other.transmitted);
859 retransmitted.Add(other.retransmitted);
860 fec.Add(other.fec);
861 if (other.first_packet_time_ms != -1 &&
862 (other.first_packet_time_ms < first_packet_time_ms ||
863 first_packet_time_ms == -1)) {
864 // Use oldest time.
865 first_packet_time_ms = other.first_packet_time_ms;
866 }
867 }
868
Erik Språng01cff722016-03-01 08:40:42869 void Subtract(const StreamDataCounters& other) {
870 transmitted.Subtract(other.transmitted);
871 retransmitted.Subtract(other.retransmitted);
872 fec.Subtract(other.fec);
873 if (other.first_packet_time_ms != -1 &&
874 (other.first_packet_time_ms > first_packet_time_ms ||
875 first_packet_time_ms == -1)) {
876 // Use youngest time.
877 first_packet_time_ms = other.first_packet_time_ms;
878 }
879 }
880
asapersson@webrtc.org1a8794b2015-02-04 08:34:47881 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
882 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
883 }
884
885 // Returns the number of bytes corresponding to the actual media payload (i.e.
886 // RTP headers, padding, retransmissions and fec packets are excluded).
887 // Note this function does not have meaning for an RTX stream.
888 size_t MediaPayloadBytes() const {
889 return transmitted.payload_bytes - retransmitted.payload_bytes -
890 fec.payload_bytes;
891 }
892
893 int64_t first_packet_time_ms; // Time when first packet is sent/received.
894 RtpPacketCounter transmitted; // Number of transmitted packets/bytes.
895 RtpPacketCounter retransmitted; // Number of retransmitted packets/bytes.
896 RtpPacketCounter fec; // Number of redundancy packets/bytes.
897};
898
899// Callback, called whenever byte/packet counts have been updated.
900class StreamDataCountersCallback {
901 public:
902 virtual ~StreamDataCountersCallback() {}
903
904 virtual void DataCountersUpdated(const StreamDataCounters& counters,
905 uint32_t ssrc) = 0;
906};
pbosba01e952015-10-02 09:36:56907
908// RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size
909// RTCP mode is described by RFC 5506.
910enum class RtcpMode { kOff, kCompound, kReducedSize };
911
pbos47a40a32016-05-02 03:18:34912enum NetworkState {
913 kNetworkUp,
914 kNetworkDown,
915};
916
andrew@webrtc.orgb015cbe2012-10-22 18:19:23917} // namespace webrtc
andrew@webrtc.org5cf83f42013-09-09 17:50:10918
919#endif // WEBRTC_COMMON_TYPES_H_