blob: a4fe9143520ac37968f83d2d9174b0b2e28b8148 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:251/*
phoglund@webrtc.org8bfee842012-02-17 09:32:482 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:253 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
andrew@webrtc.orgeda189b2013-09-09 17:50:1011#ifndef WEBRTC_COMMON_TYPES_H_
12#define WEBRTC_COMMON_TYPES_H_
niklase@google.com470e71d2011-07-07 08:21:2513
pbos@webrtc.orgf577ae92014-03-19 08:43:5714#include <stddef.h>
mallinath@webrtc.org0209e562014-03-21 00:41:2815#include <string.h>
pbos@webrtc.org1e92b0a2014-05-15 09:35:0616
17#include <string>
pbos@webrtc.orgf577ae92014-03-19 08:43:5718#include <vector>
19
andrew@webrtc.orgeda189b2013-09-09 17:50:1020#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:2521
andrew@webrtc.org88b8b0d2012-08-14 00:05:5622#if defined(_MSC_VER)
23// Disable "new behavior: elements of array will be default initialized"
24// warning. Affects OverUseDetectorOptions.
25#pragma warning(disable:4351)
26#endif
27
niklase@google.com470e71d2011-07-07 08:21:2528#ifdef WEBRTC_EXPORT
andrew@webrtc.org88b8b0d2012-08-14 00:05:5629#define WEBRTC_DLLEXPORT _declspec(dllexport)
niklase@google.com470e71d2011-07-07 08:21:2530#elif WEBRTC_DLL
andrew@webrtc.org88b8b0d2012-08-14 00:05:5631#define WEBRTC_DLLEXPORT _declspec(dllimport)
niklase@google.com470e71d2011-07-07 08:21:2532#else
andrew@webrtc.org88b8b0d2012-08-14 00:05:5633#define WEBRTC_DLLEXPORT
niklase@google.com470e71d2011-07-07 08:21:2534#endif
35
36#ifndef NULL
andrew@webrtc.org88b8b0d2012-08-14 00:05:5637#define NULL 0
niklase@google.com470e71d2011-07-07 08:21:2538#endif
39
henrika@webrtc.orgf75901f2012-01-16 08:45:4240#define RTP_PAYLOAD_NAME_SIZE 32
41
mallinath@webrtc.org0209e562014-03-21 00:41:2842#if defined(WEBRTC_WIN) || defined(WIN32)
andrew@webrtc.orgeda189b2013-09-09 17:50:1043// Compares two strings without regard to case.
44#define STR_CASE_CMP(s1, s2) ::_stricmp(s1, s2)
45// Compares characters of two strings without regard to case.
46#define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n)
47#else
48#define STR_CASE_CMP(s1, s2) ::strcasecmp(s1, s2)
49#define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n)
50#endif
51
niklase@google.com470e71d2011-07-07 08:21:2552namespace webrtc {
53
andresp@webrtc.org185bae42013-05-14 08:02:2554class Config;
55
niklase@google.com470e71d2011-07-07 08:21:2556class InStream
57{
58public:
pkasting@chromium.org4591fbd2014-11-20 22:28:1459 virtual int Read(void *buf, size_t len) = 0;
niklase@google.com470e71d2011-07-07 08:21:2560 virtual int Rewind() {return -1;}
61 virtual ~InStream() {}
62protected:
63 InStream() {}
64};
65
66class OutStream
67{
68public:
pkasting@chromium.org4591fbd2014-11-20 22:28:1469 virtual bool Write(const void *buf, size_t len) = 0;
niklase@google.com470e71d2011-07-07 08:21:2570 virtual int Rewind() {return -1;}
71 virtual ~OutStream() {}
72protected:
73 OutStream() {}
74};
75
76enum TraceModule
77{
pbos@webrtc.org5ab75672013-12-16 12:24:4478 kTraceUndefined = 0,
niklase@google.com470e71d2011-07-07 08:21:2579 // not a module, triggered from the engine code
pbos@webrtc.org5ab75672013-12-16 12:24:4480 kTraceVoice = 0x0001,
niklase@google.com470e71d2011-07-07 08:21:2581 // not a module, triggered from the engine code
pbos@webrtc.org5ab75672013-12-16 12:24:4482 kTraceVideo = 0x0002,
niklase@google.com470e71d2011-07-07 08:21:2583 // not a module, triggered from the utility code
pbos@webrtc.org5ab75672013-12-16 12:24:4484 kTraceUtility = 0x0003,
85 kTraceRtpRtcp = 0x0004,
86 kTraceTransport = 0x0005,
87 kTraceSrtp = 0x0006,
88 kTraceAudioCoding = 0x0007,
89 kTraceAudioMixerServer = 0x0008,
90 kTraceAudioMixerClient = 0x0009,
91 kTraceFile = 0x000a,
92 kTraceAudioProcessing = 0x000b,
93 kTraceVideoCoding = 0x0010,
94 kTraceVideoMixer = 0x0011,
95 kTraceAudioDevice = 0x0012,
96 kTraceVideoRenderer = 0x0014,
97 kTraceVideoCapture = 0x0015,
pbos@webrtc.org5ab75672013-12-16 12:24:4498 kTraceRemoteBitrateEstimator = 0x0017,
niklase@google.com470e71d2011-07-07 08:21:2599};
100
101enum TraceLevel
102{
103 kTraceNone = 0x0000, // no trace
104 kTraceStateInfo = 0x0001,
105 kTraceWarning = 0x0002,
106 kTraceError = 0x0004,
107 kTraceCritical = 0x0008,
108 kTraceApiCall = 0x0010,
109 kTraceDefault = 0x00ff,
110
111 kTraceModuleCall = 0x0020,
112 kTraceMemory = 0x0100, // memory info
113 kTraceTimer = 0x0200, // timing info
114 kTraceStream = 0x0400, // "continuous" stream of data
115
116 // used for debug purposes
117 kTraceDebug = 0x0800, // debug
118 kTraceInfo = 0x1000, // debug info
119
andrew@webrtc.org655d8f52012-11-20 07:34:45120 // Non-verbose level used by LS_INFO of logging.h. Do not use directly.
121 kTraceTerseInfo = 0x2000,
122
niklase@google.com470e71d2011-07-07 08:21:25123 kTraceAll = 0xffff
124};
125
126// External Trace API
andrew@webrtc.org23ec30b2012-11-15 05:33:25127class TraceCallback {
128 public:
129 virtual void Print(TraceLevel level, const char* message, int length) = 0;
niklase@google.com470e71d2011-07-07 08:21:25130
andrew@webrtc.org23ec30b2012-11-15 05:33:25131 protected:
132 virtual ~TraceCallback() {}
133 TraceCallback() {}
134};
niklase@google.com470e71d2011-07-07 08:21:25135
136enum FileFormats
137{
138 kFileFormatWavFile = 1,
139 kFileFormatCompressedFile = 2,
140 kFileFormatAviFile = 3,
141 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
sprang@webrtc.org71f055f2013-12-04 15:09:27156enum FrameType
157{
158 kFrameEmpty = 0,
159 kAudioFrameSpeech = 1,
160 kAudioFrameCN = 2,
161 kVideoFrameKey = 3, // independent frame
162 kVideoFrameDelta = 4, // depends on the previus frame
163};
164
niklase@google.com470e71d2011-07-07 08:21:25165// External transport callback interface
166class Transport
167{
168public:
pkasting@chromium.org4591fbd2014-11-20 22:28:14169 virtual int SendPacket(int channel, const void *data, size_t len) = 0;
170 virtual int SendRTCPPacket(int channel, const void *data, size_t len) = 0;
niklase@google.com470e71d2011-07-07 08:21:25171
172protected:
173 virtual ~Transport() {}
174 Transport() {}
175};
176
sprang@webrtc.orgdc50aae2013-11-20 16:47:07177// Statistics for an RTCP channel
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07178struct RtcpStatistics {
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07179 RtcpStatistics()
180 : fraction_lost(0),
181 cumulative_lost(0),
182 extended_max_sequence_number(0),
sprang@webrtc.orga6ad6e52013-12-05 09:48:44183 jitter(0) {}
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07184
185 uint8_t fraction_lost;
186 uint32_t cumulative_lost;
187 uint32_t extended_max_sequence_number;
188 uint32_t jitter;
sprang@webrtc.orgfe5d36b2013-10-28 09:21:07189};
190
sprang@webrtc.orgdc50aae2013-11-20 16:47:07191class RtcpStatisticsCallback {
192 public:
193 virtual ~RtcpStatisticsCallback() {}
194
195 virtual void StatisticsUpdated(const RtcpStatistics& statistics,
196 uint32_t ssrc) = 0;
pbos@webrtc.orgce4e9a32014-12-18 13:50:16197 virtual void CNameChanged(const char* cname, uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07198};
199
asapersson@webrtc.org8098e072014-02-19 11:59:02200// Statistics for RTCP packet types.
201struct RtcpPacketTypeCounter {
202 RtcpPacketTypeCounter()
asapersson@webrtc.orgd08d3892014-12-16 12:03:11203 : first_packet_time_ms(-1),
204 nack_packets(0),
asapersson@webrtc.org8098e072014-02-19 11:59:02205 fir_packets(0),
asapersson@webrtc.org2dd31342014-10-29 12:42:30206 pli_packets(0),
207 nack_requests(0),
208 unique_nack_requests(0) {}
asapersson@webrtc.org8098e072014-02-19 11:59:02209
210 void Add(const RtcpPacketTypeCounter& other) {
211 nack_packets += other.nack_packets;
212 fir_packets += other.fir_packets;
213 pli_packets += other.pli_packets;
asapersson@webrtc.org2dd31342014-10-29 12:42:30214 nack_requests += other.nack_requests;
215 unique_nack_requests += other.unique_nack_requests;
asapersson@webrtc.orgd08d3892014-12-16 12:03:11216 if (other.first_packet_time_ms != -1 &&
217 (other.first_packet_time_ms < first_packet_time_ms ||
218 first_packet_time_ms == -1)) {
219 // Use oldest time.
220 first_packet_time_ms = other.first_packet_time_ms;
221 }
222 }
223
224 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
225 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
asapersson@webrtc.org8098e072014-02-19 11:59:02226 }
227
asapersson@webrtc.org2dd31342014-10-29 12:42:30228 int UniqueNackRequestsInPercent() const {
229 if (nack_requests == 0) {
230 return 0;
231 }
232 return static_cast<int>(
233 (unique_nack_requests * 100.0f / nack_requests) + 0.5f);
234 }
235
asapersson@webrtc.orgd08d3892014-12-16 12:03:11236 int64_t first_packet_time_ms; // Time when first packet is sent/received.
237 uint32_t nack_packets; // Number of RTCP NACK packets.
238 uint32_t fir_packets; // Number of RTCP FIR packets.
239 uint32_t pli_packets; // Number of RTCP PLI packets.
240 uint32_t nack_requests; // Number of NACKed RTP packets.
asapersson@webrtc.org2dd31342014-10-29 12:42:30241 uint32_t unique_nack_requests; // Number of unique NACKed RTP packets.
asapersson@webrtc.org8098e072014-02-19 11:59:02242};
243
asapersson@webrtc.org97d04892014-12-09 09:47:53244// Data usage statistics for a (rtp) stream.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07245struct StreamDataCounters {
sprang@webrtc.orgdc50aae2013-11-20 16:47:07246 StreamDataCounters()
asapersson@webrtc.orgd08d3892014-12-16 12:03:11247 : first_packet_time_ms(-1),
248 bytes(0),
249 header_bytes(0),
250 padding_bytes(0),
251 packets(0),
252 retransmitted_bytes(0),
253 retransmitted_header_bytes(0),
254 retransmitted_padding_bytes(0),
255 retransmitted_packets(0),
256 fec_packets(0) {}
sprang@webrtc.orgdc50aae2013-11-20 16:47:07257
asapersson@webrtc.orgd952c402014-11-27 07:38:56258 void Add(const StreamDataCounters& other) {
259 bytes += other.bytes;
260 header_bytes += other.header_bytes;
261 padding_bytes += other.padding_bytes;
262 packets += other.packets;
asapersson@webrtc.org97d04892014-12-09 09:47:53263 retransmitted_bytes += other.retransmitted_bytes;
264 retransmitted_header_bytes += other.retransmitted_header_bytes;
265 retransmitted_padding_bytes += other.retransmitted_padding_bytes;
asapersson@webrtc.orgd952c402014-11-27 07:38:56266 retransmitted_packets += other.retransmitted_packets;
267 fec_packets += other.fec_packets;
asapersson@webrtc.orgd08d3892014-12-16 12:03:11268 if (other.first_packet_time_ms != -1 &&
269 (other.first_packet_time_ms < first_packet_time_ms ||
270 first_packet_time_ms == -1)) {
271 // Use oldest time.
272 first_packet_time_ms = other.first_packet_time_ms;
273 }
274 }
275
276 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
277 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
asapersson@webrtc.orgd952c402014-11-27 07:38:56278 }
279
asapersson@webrtc.org97d04892014-12-09 09:47:53280 size_t TotalBytes() const {
281 return bytes + header_bytes + padding_bytes;
282 }
283
284 size_t RetransmittedBytes() const {
285 return retransmitted_bytes + retransmitted_header_bytes +
286 retransmitted_padding_bytes;
287 }
288
289 size_t MediaPayloadBytes() const {
290 return bytes - retransmitted_bytes;
291 }
292
pbos@webrtc.org72491b92014-07-10 16:24:54293 // TODO(pbos): Rename bytes -> media_bytes.
asapersson@webrtc.orgd08d3892014-12-16 12:03:11294 int64_t first_packet_time_ms; // Time when first packet is sent/received.
pkasting@chromium.org4591fbd2014-11-20 22:28:14295 size_t bytes; // Payload bytes, excluding RTP headers and padding.
296 size_t header_bytes; // Number of bytes used by RTP headers.
297 size_t padding_bytes; // Number of padding bytes.
sprang@webrtc.orgebad7652013-12-05 14:29:02298 uint32_t packets; // Number of packets.
asapersson@webrtc.org97d04892014-12-09 09:47:53299 size_t retransmitted_bytes; // Number of retransmitted payload bytes.
300 size_t retransmitted_header_bytes; // Retransmitted bytes used by RTP header.
301 size_t retransmitted_padding_bytes; // Retransmitted padding bytes.
sprang@webrtc.orgebad7652013-12-05 14:29:02302 uint32_t retransmitted_packets; // Number of retransmitted packets.
303 uint32_t fec_packets; // Number of redundancy packets.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07304};
305
306// Callback, called whenever byte/packet counts have been updated.
307class StreamDataCountersCallback {
308 public:
309 virtual ~StreamDataCountersCallback() {}
310
311 virtual void DataCountersUpdated(const StreamDataCounters& counters,
312 uint32_t ssrc) = 0;
313};
314
asapersson@webrtc.orgd08d3892014-12-16 12:03:11315// Rate statistics for a stream.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07316struct BitrateStatistics {
sprang@webrtc.org6811b6e2013-12-13 09:46:59317 BitrateStatistics() : bitrate_bps(0), packet_rate(0), timestamp_ms(0) {}
sprang@webrtc.orgdc50aae2013-11-20 16:47:07318
sprang@webrtc.org6811b6e2013-12-13 09:46:59319 uint32_t bitrate_bps; // Bitrate in bits per second.
320 uint32_t packet_rate; // Packet rate in packets per second.
321 uint64_t timestamp_ms; // Ntp timestamp in ms at time of rate estimation.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07322};
323
324// Callback, used to notify an observer whenever new rates have been estimated.
325class BitrateStatisticsObserver {
326 public:
327 virtual ~BitrateStatisticsObserver() {}
328
stefan@webrtc.org0bae1fa2014-11-05 14:05:29329 virtual void Notify(const BitrateStatistics& total_stats,
330 const BitrateStatistics& retransmit_stats,
331 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07332};
333
pbos@webrtc.orgce4e9a32014-12-18 13:50:16334struct FrameCounts {
335 FrameCounts() : key_frames(0), delta_frames(0) {}
336 int key_frames;
337 int delta_frames;
338};
339
asapersson@webrtc.orgd08d3892014-12-16 12:03:11340// Callback, used to notify an observer whenever frame counts have been updated.
sprang@webrtc.orgdc50aae2013-11-20 16:47:07341class FrameCountObserver {
342 public:
sprang@webrtc.org72964bd2013-11-21 09:09:54343 virtual ~FrameCountObserver() {}
pbos@webrtc.orgce4e9a32014-12-18 13:50:16344 virtual void FrameCountUpdated(const FrameCounts& frame_counts,
345 uint32_t ssrc) = 0;
sprang@webrtc.orgdc50aae2013-11-20 16:47:07346};
347
stefan@webrtc.org168f23f2014-07-11 13:44:02348// Callback, used to notify an observer whenever the send-side delay is updated.
349class SendSideDelayObserver {
350 public:
351 virtual ~SendSideDelayObserver() {}
352 virtual void SendSideDelayUpdated(int avg_delay_ms,
353 int max_delay_ms,
354 uint32_t ssrc) = 0;
355};
356
niklase@google.com470e71d2011-07-07 08:21:25357// ==================================================================
358// Voice specific types
359// ==================================================================
360
361// Each codec supported can be described by this structure.
mallinath@webrtc.org0209e562014-03-21 00:41:28362struct CodecInst {
363 int pltype;
364 char plname[RTP_PAYLOAD_NAME_SIZE];
365 int plfreq;
366 int pacsize;
367 int channels;
368 int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
369
370 bool operator==(const CodecInst& other) const {
371 return pltype == other.pltype &&
372 (STR_CASE_CMP(plname, other.plname) == 0) &&
373 plfreq == other.plfreq &&
374 pacsize == other.pacsize &&
375 channels == other.channels &&
376 rate == other.rate;
377 }
378
379 bool operator!=(const CodecInst& other) const {
380 return !(*this == other);
381 }
niklase@google.com470e71d2011-07-07 08:21:25382};
383
niklase@google.com470e71d2011-07-07 08:21:25384// RTP
385enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
386
387enum RTPDirections
388{
389 kRtpIncoming = 0,
390 kRtpOutgoing
391};
392
393enum PayloadFrequencies
394{
395 kFreq8000Hz = 8000,
396 kFreq16000Hz = 16000,
397 kFreq32000Hz = 32000
398};
399
400enum VadModes // degree of bandwidth reduction
401{
402 kVadConventional = 0, // lowest reduction
403 kVadAggressiveLow,
404 kVadAggressiveMid,
405 kVadAggressiveHigh // highest reduction
406};
407
408struct NetworkStatistics // NETEQ statistics
409{
410 // current jitter buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11411 uint16_t currentBufferSize;
niklase@google.com470e71d2011-07-07 08:21:25412 // preferred (optimal) buffer size in ms
pbos@webrtc.org77f6b212013-05-03 12:02:11413 uint16_t preferredBufferSize;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55414 // adding extra delay due to "peaky jitter"
415 bool jitterPeaksFound;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45416 // Loss rate (network + late); fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11417 uint16_t currentPacketLossRate;
henrik.lundin@webrtc.org8768f162014-10-09 12:58:45418 // Late loss rate; fraction between 0 and 1, scaled to Q14.
pbos@webrtc.org77f6b212013-05-03 12:02:11419 uint16_t currentDiscardRate;
niklase@google.com470e71d2011-07-07 08:21:25420 // fraction (of original stream) of synthesized speech inserted through
421 // expansion (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11422 uint16_t currentExpandRate;
niklase@google.com470e71d2011-07-07 08:21:25423 // fraction of synthesized speech inserted through pre-emptive expansion
424 // (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11425 uint16_t currentPreemptiveRate;
niklase@google.com470e71d2011-07-07 08:21:25426 // fraction of data removed through acceleration (in Q14)
pbos@webrtc.org77f6b212013-05-03 12:02:11427 uint16_t currentAccelerateRate;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55428 // clock-drift in parts-per-million (negative or positive)
429 int32_t clockDriftPPM;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05430 // average packet waiting time in the jitter buffer (ms)
431 int meanWaitingTimeMs;
432 // median packet waiting time in the jitter buffer (ms)
433 int medianWaitingTimeMs;
henrik.lundin@webrtc.org053c7992012-01-12 14:16:44434 // min packet waiting time in the jitter buffer (ms)
435 int minWaitingTimeMs;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05436 // max packet waiting time in the jitter buffer (ms)
437 int maxWaitingTimeMs;
roosa@google.comb8ba4d82012-12-14 00:06:18438 // added samples in off mode due to packet loss
439 int addedSamples;
niklase@google.com470e71d2011-07-07 08:21:25440};
441
wu@webrtc.org24301a62013-12-13 19:17:43442// Statistics for calls to AudioCodingModule::PlayoutData10Ms().
443struct AudioDecodingCallStats {
444 AudioDecodingCallStats()
445 : calls_to_silence_generator(0),
446 calls_to_neteq(0),
447 decoded_normal(0),
448 decoded_plc(0),
449 decoded_cng(0),
450 decoded_plc_cng(0) {}
451
452 int calls_to_silence_generator; // Number of calls where silence generated,
453 // and NetEq was disengaged from decoding.
454 int calls_to_neteq; // Number of calls to NetEq.
455 int decoded_normal; // Number of calls where audio RTP packet decoded.
456 int decoded_plc; // Number of calls resulted in PLC.
457 int decoded_cng; // Number of calls where comfort noise generated due to DTX.
458 int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
459};
460
niklase@google.com470e71d2011-07-07 08:21:25461typedef struct
462{
463 int min; // minumum
464 int max; // maximum
465 int average; // average
466} StatVal;
467
468typedef struct // All levels are reported in dBm0
469{
470 StatVal speech_rx; // long-term speech levels on receiving side
471 StatVal speech_tx; // long-term speech levels on transmitting side
472 StatVal noise_rx; // long-term noise/silence levels on receiving side
473 StatVal noise_tx; // long-term noise/silence levels on transmitting side
474} LevelStatistics;
475
476typedef struct // All levels are reported in dB
477{
478 StatVal erl; // Echo Return Loss
479 StatVal erle; // Echo Return Loss Enhancement
480 StatVal rerl; // RERL = ERL + ERLE
481 // Echo suppression inside EC at the point just before its NLP
482 StatVal a_nlp;
483} EchoStatistics;
484
niklase@google.com470e71d2011-07-07 08:21:25485enum NsModes // type of Noise Suppression
486{
487 kNsUnchanged = 0, // previously set mode
488 kNsDefault, // platform default
489 kNsConference, // conferencing default
490 kNsLowSuppression, // lowest suppression
491 kNsModerateSuppression,
492 kNsHighSuppression,
493 kNsVeryHighSuppression, // highest suppression
494};
495
496enum AgcModes // type of Automatic Gain Control
497{
498 kAgcUnchanged = 0, // previously set mode
499 kAgcDefault, // platform default
500 // adaptive mode for use when analog volume control exists (e.g. for
501 // PC softphone)
502 kAgcAdaptiveAnalog,
503 // scaling takes place in the digital domain (e.g. for conference servers
504 // and embedded devices)
505 kAgcAdaptiveDigital,
andrew@webrtc.org80124742012-03-08 17:54:24506 // can be used on embedded devices where the capture signal level
niklase@google.com470e71d2011-07-07 08:21:25507 // is predictable
508 kAgcFixedDigital
509};
510
511// EC modes
512enum EcModes // type of Echo Control
513{
514 kEcUnchanged = 0, // previously set mode
515 kEcDefault, // platform default
516 kEcConference, // conferencing default (aggressive AEC)
517 kEcAec, // Acoustic Echo Cancellation
518 kEcAecm, // AEC mobile
519};
520
521// AECM modes
522enum AecmModes // mode of AECM
523{
524 kAecmQuietEarpieceOrHeadset = 0,
525 // Quiet earpiece or headset use
526 kAecmEarpiece, // most earpiece use
527 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
528 kAecmSpeakerphone, // most speakerphone use (default)
529 kAecmLoudSpeakerphone // Loud speakerphone
530};
531
532// AGC configuration
533typedef struct
534{
535 unsigned short targetLeveldBOv;
536 unsigned short digitalCompressionGaindB;
537 bool limiterEnable;
538} AgcConfig; // AGC configuration parameters
539
540enum StereoChannel
541{
542 kStereoLeft = 0,
543 kStereoRight,
544 kStereoBoth
545};
546
547// Audio device layers
548enum AudioLayers
549{
550 kAudioPlatformDefault = 0,
551 kAudioWindowsWave = 1,
552 kAudioWindowsCore = 2,
553 kAudioLinuxAlsa = 3,
554 kAudioLinuxPulse = 4
555};
556
henrika@webrtc.org66803482014-04-17 10:45:01557// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25558enum NetEqModes // NetEQ playout configurations
559{
560 // Optimized trade-off between low delay and jitter robustness for two-way
561 // communication.
562 kNetEqDefault = 0,
563 // Improved jitter robustness at the cost of increased delay. Can be
564 // used in one-way communication.
565 kNetEqStreaming = 1,
566 // Optimzed for decodability of fax signals rather than for perceived audio
567 // quality.
568 kNetEqFax = 2,
roosa@google.comb7186192012-12-12 21:59:14569 // Minimal buffer management. Inserts zeros for lost packets and during
570 // buffer increases.
571 kNetEqOff = 3,
niklase@google.com470e71d2011-07-07 08:21:25572};
573
henrika@webrtc.org66803482014-04-17 10:45:01574// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25575enum OnHoldModes // On Hold direction
576{
577 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
578 kHoldSendOnly, // Put only sending in on-hold state.
579 kHoldPlayOnly // Put only playing in on-hold state.
580};
581
henrika@webrtc.org66803482014-04-17 10:45:01582// TODO(henrika): to be removed.
niklase@google.com470e71d2011-07-07 08:21:25583enum AmrMode
584{
585 kRfc3267BwEfficient = 0,
586 kRfc3267OctetAligned = 1,
587 kRfc3267FileStorage = 2,
588};
589
590// ==================================================================
591// Video specific types
592// ==================================================================
593
594// Raw video types
595enum RawVideoType
596{
597 kVideoI420 = 0,
598 kVideoYV12 = 1,
599 kVideoYUY2 = 2,
600 kVideoUYVY = 3,
601 kVideoIYUV = 4,
602 kVideoARGB = 5,
603 kVideoRGB24 = 6,
604 kVideoRGB565 = 7,
605 kVideoARGB4444 = 8,
606 kVideoARGB1555 = 9,
607 kVideoMJPEG = 10,
608 kVideoNV12 = 11,
609 kVideoNV21 = 12,
mikhal@webrtc.orgc00f91d2012-01-03 18:49:15610 kVideoBGRA = 13,
niklase@google.com470e71d2011-07-07 08:21:25611 kVideoUnknown = 99
612};
613
614// Video codec
615enum { kConfigParameterSize = 128};
616enum { kPayloadNameSize = 32};
pwestin@webrtc.org1da1ce02011-10-13 15:19:55617enum { kMaxSimulcastStreams = 4};
pwestin@webrtc.orgdb221d22011-12-02 11:31:08618enum { kMaxTemporalStreams = 4};
niklase@google.com470e71d2011-07-07 08:21:25619
niklase@google.com470e71d2011-07-07 08:21:25620enum VideoCodecComplexity
621{
622 kComplexityNormal = 0,
623 kComplexityHigh = 1,
624 kComplexityHigher = 2,
625 kComplexityMax = 3
626};
627
628enum VideoCodecProfile
629{
630 kProfileBase = 0x00,
631 kProfileMain = 0x01
632};
633
stefan@webrtc.orgefd0a482011-12-29 10:12:35634enum VP8ResilienceMode {
635 kResilienceOff, // The stream produced by the encoder requires a
636 // recovery frame (typically a key frame) to be
637 // decodable after a packet loss.
638 kResilientStream, // A stream produced by the encoder is resilient to
639 // packet losses, but packets within a frame subsequent
640 // to a loss can't be decoded.
641 kResilientFrames // Same as kResilientStream but with added resilience
642 // within a frame.
643};
644
niklase@google.com470e71d2011-07-07 08:21:25645// VP8 specific
mallinath@webrtc.org0209e562014-03-21 00:41:28646struct VideoCodecVP8 {
647 bool pictureLossIndicationOn;
648 bool feedbackModeOn;
649 VideoCodecComplexity complexity;
650 VP8ResilienceMode resilience;
651 unsigned char numberOfTemporalLayers;
652 bool denoisingOn;
653 bool errorConcealmentOn;
654 bool automaticResizeOn;
655 bool frameDroppingOn;
656 int keyFrameInterval;
657
658 bool operator==(const VideoCodecVP8& other) const {
659 return pictureLossIndicationOn == other.pictureLossIndicationOn &&
660 feedbackModeOn == other.feedbackModeOn &&
661 complexity == other.complexity &&
662 resilience == other.resilience &&
663 numberOfTemporalLayers == other.numberOfTemporalLayers &&
664 denoisingOn == other.denoisingOn &&
665 errorConcealmentOn == other.errorConcealmentOn &&
666 automaticResizeOn == other.automaticResizeOn &&
667 frameDroppingOn == other.frameDroppingOn &&
668 keyFrameInterval == other.keyFrameInterval;
669 }
670
671 bool operator!=(const VideoCodecVP8& other) const {
672 return !(*this == other);
673 }
niklase@google.com470e71d2011-07-07 08:21:25674};
675
marpan@webrtc.org5b883172014-11-01 06:10:48676// VP9 specific
677struct VideoCodecVP9 {
678 VideoCodecComplexity complexity;
679 int resilience;
680 unsigned char numberOfTemporalLayers;
681 bool denoisingOn;
682 bool frameDroppingOn;
683 int keyFrameInterval;
684 bool adaptiveQpMode;
685};
686
stefan@webrtc.orgb9f54532014-07-04 12:42:07687// H264 specific.
marpan@webrtc.org5b883172014-11-01 06:10:48688struct VideoCodecH264 {
689 VideoCodecProfile profile;
690 bool frameDroppingOn;
691 int keyFrameInterval;
692 // These are NULL/0 if not externally negotiated.
693 const uint8_t* spsData;
694 size_t spsLen;
695 const uint8_t* ppsData;
696 size_t ppsLen;
stefan@webrtc.orgb9f54532014-07-04 12:42:07697};
698
niklase@google.com470e71d2011-07-07 08:21:25699// Video codec types
marpan@webrtc.org5b883172014-11-01 06:10:48700enum VideoCodecType {
701 kVideoCodecVP8,
702 kVideoCodecVP9,
703 kVideoCodecH264,
704 kVideoCodecI420,
705 kVideoCodecRED,
706 kVideoCodecULPFEC,
707 kVideoCodecGeneric,
708 kVideoCodecUnknown
niklase@google.com470e71d2011-07-07 08:21:25709};
710
marpan@webrtc.org5b883172014-11-01 06:10:48711union VideoCodecUnion {
712 VideoCodecVP8 VP8;
713 VideoCodecVP9 VP9;
714 VideoCodecH264 H264;
niklase@google.com470e71d2011-07-07 08:21:25715};
716
phoglund@webrtc.org8bfee842012-02-17 09:32:48717
718// Simulcast is when the same stream is encoded multiple times with different
719// settings such as resolution.
mallinath@webrtc.org0209e562014-03-21 00:41:28720struct SimulcastStream {
721 unsigned short width;
722 unsigned short height;
723 unsigned char numberOfTemporalLayers;
724 unsigned int maxBitrate; // kilobits/sec.
725 unsigned int targetBitrate; // kilobits/sec.
726 unsigned int minBitrate; // kilobits/sec.
727 unsigned int qpMax; // minimum quality
728
729 bool operator==(const SimulcastStream& other) const {
730 return width == other.width &&
731 height == other.height &&
732 numberOfTemporalLayers == other.numberOfTemporalLayers &&
733 maxBitrate == other.maxBitrate &&
734 targetBitrate == other.targetBitrate &&
735 minBitrate == other.minBitrate &&
736 qpMax == other.qpMax;
737 }
738
739 bool operator!=(const SimulcastStream& other) const {
740 return !(*this == other);
741 }
pwestin@webrtc.org1da1ce02011-10-13 15:19:55742};
743
stefan@webrtc.orgeb917922013-02-18 14:40:18744enum VideoCodecMode {
745 kRealtimeVideo,
746 kScreensharing
747};
748
niklase@google.com470e71d2011-07-07 08:21:25749// Common video codec properties
mallinath@webrtc.org0209e562014-03-21 00:41:28750struct VideoCodec {
751 VideoCodecType codecType;
752 char plName[kPayloadNameSize];
753 unsigned char plType;
niklase@google.com470e71d2011-07-07 08:21:25754
mallinath@webrtc.org0209e562014-03-21 00:41:28755 unsigned short width;
756 unsigned short height;
niklase@google.com470e71d2011-07-07 08:21:25757
mallinath@webrtc.org0209e562014-03-21 00:41:28758 unsigned int startBitrate; // kilobits/sec.
759 unsigned int maxBitrate; // kilobits/sec.
760 unsigned int minBitrate; // kilobits/sec.
pbos@webrtc.org3c412b22014-03-24 12:36:52761 unsigned int targetBitrate; // kilobits/sec.
762
mallinath@webrtc.org0209e562014-03-21 00:41:28763 unsigned char maxFramerate;
niklase@google.com470e71d2011-07-07 08:21:25764
mallinath@webrtc.org0209e562014-03-21 00:41:28765 VideoCodecUnion codecSpecific;
niklase@google.com470e71d2011-07-07 08:21:25766
mallinath@webrtc.org0209e562014-03-21 00:41:28767 unsigned int qpMax;
768 unsigned char numberOfSimulcastStreams;
769 SimulcastStream simulcastStream[kMaxSimulcastStreams];
stefan@webrtc.orgeb917922013-02-18 14:40:18770
mallinath@webrtc.org0209e562014-03-21 00:41:28771 VideoCodecMode mode;
andresp@webrtc.org185bae42013-05-14 08:02:25772
mallinath@webrtc.org0209e562014-03-21 00:41:28773 // When using an external encoder/decoder this allows to pass
774 // extra options without requiring webrtc to be aware of them.
775 Config* extra_options;
mallinath@webrtc.org0209e562014-03-21 00:41:28776
mallinath@webrtc.org0209e562014-03-21 00:41:28777 bool operator==(const VideoCodec& other) const {
778 bool ret = codecType == other.codecType &&
779 (STR_CASE_CMP(plName, other.plName) == 0) &&
780 plType == other.plType &&
781 width == other.width &&
782 height == other.height &&
783 startBitrate == other.startBitrate &&
784 maxBitrate == other.maxBitrate &&
785 minBitrate == other.minBitrate &&
pbos@webrtc.org3c412b22014-03-24 12:36:52786 targetBitrate == other.targetBitrate &&
mallinath@webrtc.org0209e562014-03-21 00:41:28787 maxFramerate == other.maxFramerate &&
788 qpMax == other.qpMax &&
789 numberOfSimulcastStreams == other.numberOfSimulcastStreams &&
790 mode == other.mode;
791 if (ret && codecType == kVideoCodecVP8) {
792 ret &= (codecSpecific.VP8 == other.codecSpecific.VP8);
793 }
794
795 for (unsigned char i = 0; i < other.numberOfSimulcastStreams && ret; ++i) {
796 ret &= (simulcastStream[i] == other.simulcastStream[i]);
797 }
798 return ret;
799 }
800
801 bool operator!=(const VideoCodec& other) const {
802 return !(*this == other);
803 }
niklase@google.com470e71d2011-07-07 08:21:25804};
astor@webrtc.orgbd7aeba2012-06-26 10:47:04805
806// Bandwidth over-use detector options. These are used to drive
807// experimentation with bandwidth estimation parameters.
808// See modules/remote_bitrate_estimator/overuse_detector.h
809struct OverUseDetectorOptions {
810 OverUseDetectorOptions()
811 : initial_slope(8.0/512.0),
812 initial_offset(0),
813 initial_e(),
814 initial_process_noise(),
815 initial_avg_noise(0.0),
stefan@webrtc.orgc58be0d2012-09-11 14:11:58816 initial_var_noise(50),
astor@webrtc.orgbd7aeba2012-06-26 10:47:04817 initial_threshold(25.0) {
818 initial_e[0][0] = 100;
819 initial_e[1][1] = 1e-1;
820 initial_e[0][1] = initial_e[1][0] = 0;
821 initial_process_noise[0] = 1e-10;
822 initial_process_noise[1] = 1e-2;
823 }
824 double initial_slope;
825 double initial_offset;
826 double initial_e[2][2];
827 double initial_process_noise[2];
828 double initial_avg_noise;
829 double initial_var_noise;
830 double initial_threshold;
831};
andrew@webrtc.orgeda189b2013-09-09 17:50:10832
wu@webrtc.orga9890802013-12-13 00:21:03833// This structure will have the information about when packet is actually
834// received by socket.
835struct PacketTime {
henrike@webrtc.org82d3cb62014-04-29 17:50:47836 PacketTime() : timestamp(-1), not_before(-1) {}
837 PacketTime(int64_t timestamp, int64_t not_before)
838 : timestamp(timestamp), not_before(not_before) {
wu@webrtc.orga9890802013-12-13 00:21:03839 }
840
henrike@webrtc.org82d3cb62014-04-29 17:50:47841 int64_t timestamp; // Receive time after socket delivers the data.
842 int64_t not_before; // Earliest possible time the data could have arrived,
843 // indicating the potential error in the |timestamp|
844 // value,in case the system is busy.
845 // For example, the time of the last select() call.
846 // If unknown, this value will be set to zero.
wu@webrtc.orga9890802013-12-13 00:21:03847};
848
solenberg@webrtc.orgb1f50102014-03-24 10:38:25849struct RTPHeaderExtension {
850 RTPHeaderExtension()
851 : hasTransmissionTimeOffset(false),
852 transmissionTimeOffset(0),
853 hasAbsoluteSendTime(false),
854 absoluteSendTime(0),
855 hasAudioLevel(false),
856 audioLevel(0) {}
857
858 bool hasTransmissionTimeOffset;
859 int32_t transmissionTimeOffset;
860 bool hasAbsoluteSendTime;
861 uint32_t absoluteSendTime;
862
863 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
864 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
865 bool hasAudioLevel;
866 uint8_t audioLevel;
867};
868
869struct RTPHeader {
870 RTPHeader()
871 : markerBit(false),
872 payloadType(0),
873 sequenceNumber(0),
874 timestamp(0),
875 ssrc(0),
876 numCSRCs(0),
877 paddingLength(0),
878 headerLength(0),
879 payload_type_frequency(0),
880 extension() {
881 memset(&arrOfCSRCs, 0, sizeof(arrOfCSRCs));
882 }
883
884 bool markerBit;
885 uint8_t payloadType;
886 uint16_t sequenceNumber;
887 uint32_t timestamp;
888 uint32_t ssrc;
889 uint8_t numCSRCs;
890 uint32_t arrOfCSRCs[kRtpCsrcSize];
pkasting@chromium.org4591fbd2014-11-20 22:28:14891 size_t paddingLength;
892 size_t headerLength;
solenberg@webrtc.orgb1f50102014-03-24 10:38:25893 int payload_type_frequency;
894 RTPHeaderExtension extension;
895};
896
niklase@google.com470e71d2011-07-07 08:21:25897} // namespace webrtc
andrew@webrtc.orgeda189b2013-09-09 17:50:10898
899#endif // WEBRTC_COMMON_TYPES_H_