blob: 9b3a0ceee4a4346129b0244846548adc0cefba89 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
11#ifndef WEBRTC_COMMON_TYPES_H
12#define WEBRTC_COMMON_TYPES_H
13
14#include "typedefs.h"
15
16#ifdef WEBRTC_EXPORT
17 #define WEBRTC_DLLEXPORT _declspec(dllexport)
18#elif WEBRTC_DLL
19 #define WEBRTC_DLLEXPORT _declspec(dllimport)
20#else
21 #define WEBRTC_DLLEXPORT
22#endif
23
24#ifndef NULL
25 #define NULL 0
26#endif
27
henrika@webrtc.orgf75901f2012-01-16 08:45:42 +000028#define RTP_PAYLOAD_NAME_SIZE 32
29
niklase@google.com470e71d2011-07-07 08:21:25 +000030namespace webrtc {
31
32class InStream
33{
34public:
35 virtual int Read(void *buf,int len) = 0;
36 virtual int Rewind() {return -1;}
37 virtual ~InStream() {}
38protected:
39 InStream() {}
40};
41
42class OutStream
43{
44public:
45 virtual bool Write(const void *buf,int len) = 0;
46 virtual int Rewind() {return -1;}
47 virtual ~OutStream() {}
48protected:
49 OutStream() {}
50};
51
52enum TraceModule
53{
54 // not a module, triggered from the engine code
55 kTraceVoice = 0x0001,
56 // not a module, triggered from the engine code
57 kTraceVideo = 0x0002,
58 // not a module, triggered from the utility code
59 kTraceUtility = 0x0003,
60 kTraceRtpRtcp = 0x0004,
61 kTraceTransport = 0x0005,
62 kTraceSrtp = 0x0006,
63 kTraceAudioCoding = 0x0007,
64 kTraceAudioMixerServer = 0x0008,
65 kTraceAudioMixerClient = 0x0009,
66 kTraceFile = 0x000a,
67 kTraceAudioProcessing = 0x000b,
68 kTraceVideoCoding = 0x0010,
69 kTraceVideoMixer = 0x0011,
70 kTraceAudioDevice = 0x0012,
71 kTraceVideoRenderer = 0x0014,
72 kTraceVideoCapture = 0x0015,
73 kTraceVideoPreocessing = 0x0016
74};
75
76enum TraceLevel
77{
78 kTraceNone = 0x0000, // no trace
79 kTraceStateInfo = 0x0001,
80 kTraceWarning = 0x0002,
81 kTraceError = 0x0004,
82 kTraceCritical = 0x0008,
83 kTraceApiCall = 0x0010,
84 kTraceDefault = 0x00ff,
85
86 kTraceModuleCall = 0x0020,
87 kTraceMemory = 0x0100, // memory info
88 kTraceTimer = 0x0200, // timing info
89 kTraceStream = 0x0400, // "continuous" stream of data
90
91 // used for debug purposes
92 kTraceDebug = 0x0800, // debug
93 kTraceInfo = 0x1000, // debug info
94
95 kTraceAll = 0xffff
96};
97
98// External Trace API
99class TraceCallback
100{
101public:
102 virtual void Print(const TraceLevel level,
103 const char *traceString,
104 const int length) = 0;
105protected:
106 virtual ~TraceCallback() {}
107 TraceCallback() {}
108};
109
110
111enum FileFormats
112{
113 kFileFormatWavFile = 1,
114 kFileFormatCompressedFile = 2,
115 kFileFormatAviFile = 3,
116 kFileFormatPreencodedFile = 4,
117 kFileFormatPcm16kHzFile = 7,
118 kFileFormatPcm8kHzFile = 8,
119 kFileFormatPcm32kHzFile = 9
120};
121
122
123enum ProcessingTypes
124{
125 kPlaybackPerChannel = 0,
126 kPlaybackAllChannelsMixed,
127 kRecordingPerChannel,
128 kRecordingAllChannelsMixed
129};
130
131// Encryption enums
132enum CipherTypes
133{
134 kCipherNull = 0,
135 kCipherAes128CounterMode = 1
136};
137
138enum AuthenticationTypes
139{
140 kAuthNull = 0,
141 kAuthHmacSha1 = 3
142};
143
144enum SecurityLevels
145{
146 kNoProtection = 0,
147 kEncryption = 1,
148 kAuthentication = 2,
149 kEncryptionAndAuthentication = 3
150};
151
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000152// Interface for encrypting and decrypting regular data and rtp/rtcp packets.
153// Implement this interface if you wish to provide an encryption scheme to
154// the voice or video engines.
niklase@google.com470e71d2011-07-07 08:21:25 +0000155class Encryption
156{
157public:
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000158 // Encrypt the given data.
159 //
160 // Args:
161 // channel: The channel to encrypt data for.
162 // in_data: The data to encrypt. This data is bytes_in bytes long.
163 // out_data: The buffer to write the encrypted data to. You may write more
164 // bytes of encrypted data than what you got as input, up to a maximum
165 // of webrtc::kViEMaxMtu if you are encrypting in the video engine, or
166 // webrtc::kVoiceEngineMaxIpPacketSizeBytes for the voice engine.
167 // bytes_in: The number of bytes in the input buffer.
168 // bytes_out: The number of bytes written in out_data.
niklase@google.com470e71d2011-07-07 08:21:25 +0000169 virtual void encrypt(
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000170 int channel,
niklase@google.com470e71d2011-07-07 08:21:25 +0000171 unsigned char* in_data,
172 unsigned char* out_data,
173 int bytes_in,
174 int* bytes_out) = 0;
175
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000176 // Decrypts the given data. This should reverse the effects of encrypt().
177 //
178 // Args:
179 // channel_no: The channel to decrypt data for.
180 // in_data: The data to decrypt. This data is bytes_in bytes long.
181 // out_data: The buffer to write the decrypted data to. You may write more
182 // bytes of decrypted data than what you got as input, up to a maximum
183 // of webrtc::kViEMaxMtu if you are encrypting in the video engine, or
184 // webrtc::kVoiceEngineMaxIpPacketSizeBytes for the voice engine.
185 // bytes_in: The number of bytes in the input buffer.
186 // bytes_out: The number of bytes written in out_data.
niklase@google.com470e71d2011-07-07 08:21:25 +0000187 virtual void decrypt(
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000188 int channel,
niklase@google.com470e71d2011-07-07 08:21:25 +0000189 unsigned char* in_data,
190 unsigned char* out_data,
191 int bytes_in,
192 int* bytes_out) = 0;
193
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000194 // Encrypts a RTCP packet. Otherwise, this method has the same contract as
195 // encrypt().
niklase@google.com470e71d2011-07-07 08:21:25 +0000196 virtual void encrypt_rtcp(
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000197 int channel,
niklase@google.com470e71d2011-07-07 08:21:25 +0000198 unsigned char* in_data,
199 unsigned char* out_data,
200 int bytes_in,
201 int* bytes_out) = 0;
202
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000203 // Decrypts a RTCP packet. Otherwise, this method has the same contract as
204 // decrypt().
niklase@google.com470e71d2011-07-07 08:21:25 +0000205 virtual void decrypt_rtcp(
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000206 int channel,
niklase@google.com470e71d2011-07-07 08:21:25 +0000207 unsigned char* in_data,
208 unsigned char* out_data,
209 int bytes_in,
210 int* bytes_out) = 0;
211
212protected:
213 virtual ~Encryption() {}
214 Encryption() {}
215};
216
217// External transport callback interface
218class Transport
219{
220public:
221 virtual int SendPacket(int channel, const void *data, int len) = 0;
222 virtual int SendRTCPPacket(int channel, const void *data, int len) = 0;
223
224protected:
225 virtual ~Transport() {}
226 Transport() {}
227};
228
229// ==================================================================
230// Voice specific types
231// ==================================================================
232
233// Each codec supported can be described by this structure.
234struct CodecInst
235{
236 int pltype;
henrika@webrtc.orgf75901f2012-01-16 08:45:42 +0000237 char plname[RTP_PAYLOAD_NAME_SIZE];
niklase@google.com470e71d2011-07-07 08:21:25 +0000238 int plfreq;
239 int pacsize;
240 int channels;
241 int rate;
242};
243
244enum FrameType
245{
246 kFrameEmpty = 0,
247 kAudioFrameSpeech = 1,
248 kAudioFrameCN = 2,
249 kVideoFrameKey = 3, // independent frame
250 kVideoFrameDelta = 4, // depends on the previus frame
251 kVideoFrameGolden = 5, // depends on a old known previus frame
252 kVideoFrameAltRef = 6
253};
254
255// RTP
256enum {kRtpCsrcSize = 15}; // RFC 3550 page 13
257
258enum RTPDirections
259{
260 kRtpIncoming = 0,
261 kRtpOutgoing
262};
263
264enum PayloadFrequencies
265{
266 kFreq8000Hz = 8000,
267 kFreq16000Hz = 16000,
268 kFreq32000Hz = 32000
269};
270
271enum VadModes // degree of bandwidth reduction
272{
273 kVadConventional = 0, // lowest reduction
274 kVadAggressiveLow,
275 kVadAggressiveMid,
276 kVadAggressiveHigh // highest reduction
277};
278
279struct NetworkStatistics // NETEQ statistics
280{
281 // current jitter buffer size in ms
282 WebRtc_UWord16 currentBufferSize;
283 // preferred (optimal) buffer size in ms
284 WebRtc_UWord16 preferredBufferSize;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55 +0000285 // adding extra delay due to "peaky jitter"
286 bool jitterPeaksFound;
niklase@google.com470e71d2011-07-07 08:21:25 +0000287 // loss rate (network + late) in percent (in Q14)
288 WebRtc_UWord16 currentPacketLossRate;
289 // late loss rate in percent (in Q14)
290 WebRtc_UWord16 currentDiscardRate;
291 // fraction (of original stream) of synthesized speech inserted through
292 // expansion (in Q14)
293 WebRtc_UWord16 currentExpandRate;
294 // fraction of synthesized speech inserted through pre-emptive expansion
295 // (in Q14)
296 WebRtc_UWord16 currentPreemptiveRate;
297 // fraction of data removed through acceleration (in Q14)
298 WebRtc_UWord16 currentAccelerateRate;
henrik.lundin@webrtc.orgd4398702012-01-04 13:09:55 +0000299 // clock-drift in parts-per-million (negative or positive)
300 int32_t clockDriftPPM;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05 +0000301 // average packet waiting time in the jitter buffer (ms)
302 int meanWaitingTimeMs;
303 // median packet waiting time in the jitter buffer (ms)
304 int medianWaitingTimeMs;
henrik.lundin@webrtc.org053c7992012-01-12 14:16:44 +0000305 // min packet waiting time in the jitter buffer (ms)
306 int minWaitingTimeMs;
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05 +0000307 // max packet waiting time in the jitter buffer (ms)
308 int maxWaitingTimeMs;
niklase@google.com470e71d2011-07-07 08:21:25 +0000309};
310
niklase@google.com470e71d2011-07-07 08:21:25 +0000311typedef struct
312{
313 int min; // minumum
314 int max; // maximum
315 int average; // average
316} StatVal;
317
318typedef struct // All levels are reported in dBm0
319{
320 StatVal speech_rx; // long-term speech levels on receiving side
321 StatVal speech_tx; // long-term speech levels on transmitting side
322 StatVal noise_rx; // long-term noise/silence levels on receiving side
323 StatVal noise_tx; // long-term noise/silence levels on transmitting side
324} LevelStatistics;
325
326typedef struct // All levels are reported in dB
327{
328 StatVal erl; // Echo Return Loss
329 StatVal erle; // Echo Return Loss Enhancement
330 StatVal rerl; // RERL = ERL + ERLE
331 // Echo suppression inside EC at the point just before its NLP
332 StatVal a_nlp;
333} EchoStatistics;
334
335enum TelephoneEventDetectionMethods
336{
337 kInBand = 0,
338 kOutOfBand = 1,
339 kInAndOutOfBand = 2
340};
341
342enum NsModes // type of Noise Suppression
343{
344 kNsUnchanged = 0, // previously set mode
345 kNsDefault, // platform default
346 kNsConference, // conferencing default
347 kNsLowSuppression, // lowest suppression
348 kNsModerateSuppression,
349 kNsHighSuppression,
350 kNsVeryHighSuppression, // highest suppression
351};
352
353enum AgcModes // type of Automatic Gain Control
354{
355 kAgcUnchanged = 0, // previously set mode
356 kAgcDefault, // platform default
357 // adaptive mode for use when analog volume control exists (e.g. for
358 // PC softphone)
359 kAgcAdaptiveAnalog,
360 // scaling takes place in the digital domain (e.g. for conference servers
361 // and embedded devices)
362 kAgcAdaptiveDigital,
363 // can be used on embedded devices where the the capture signal is level
364 // is predictable
365 kAgcFixedDigital
366};
367
368// EC modes
369enum EcModes // type of Echo Control
370{
371 kEcUnchanged = 0, // previously set mode
372 kEcDefault, // platform default
373 kEcConference, // conferencing default (aggressive AEC)
374 kEcAec, // Acoustic Echo Cancellation
375 kEcAecm, // AEC mobile
376};
377
378// AECM modes
379enum AecmModes // mode of AECM
380{
381 kAecmQuietEarpieceOrHeadset = 0,
382 // Quiet earpiece or headset use
383 kAecmEarpiece, // most earpiece use
384 kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use
385 kAecmSpeakerphone, // most speakerphone use (default)
386 kAecmLoudSpeakerphone // Loud speakerphone
387};
388
389// AGC configuration
390typedef struct
391{
392 unsigned short targetLeveldBOv;
393 unsigned short digitalCompressionGaindB;
394 bool limiterEnable;
395} AgcConfig; // AGC configuration parameters
396
397enum StereoChannel
398{
399 kStereoLeft = 0,
400 kStereoRight,
401 kStereoBoth
402};
403
404// Audio device layers
405enum AudioLayers
406{
407 kAudioPlatformDefault = 0,
408 kAudioWindowsWave = 1,
409 kAudioWindowsCore = 2,
410 kAudioLinuxAlsa = 3,
411 kAudioLinuxPulse = 4
412};
413
414enum NetEqModes // NetEQ playout configurations
415{
416 // Optimized trade-off between low delay and jitter robustness for two-way
417 // communication.
418 kNetEqDefault = 0,
419 // Improved jitter robustness at the cost of increased delay. Can be
420 // used in one-way communication.
421 kNetEqStreaming = 1,
422 // Optimzed for decodability of fax signals rather than for perceived audio
423 // quality.
424 kNetEqFax = 2,
425};
426
427enum NetEqBgnModes // NetEQ Background Noise (BGN) configurations
428{
429 // BGN is always on and will be generated when the incoming RTP stream
430 // stops (default).
431 kBgnOn = 0,
432 // The BGN is faded to zero (complete silence) after a few seconds.
433 kBgnFade = 1,
434 // BGN is not used at all. Silence is produced after speech extrapolation
435 // has faded.
436 kBgnOff = 2,
437};
438
439enum OnHoldModes // On Hold direction
440{
441 kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state.
442 kHoldSendOnly, // Put only sending in on-hold state.
443 kHoldPlayOnly // Put only playing in on-hold state.
444};
445
446enum AmrMode
447{
448 kRfc3267BwEfficient = 0,
449 kRfc3267OctetAligned = 1,
450 kRfc3267FileStorage = 2,
451};
452
453// ==================================================================
454// Video specific types
455// ==================================================================
456
457// Raw video types
458enum RawVideoType
459{
460 kVideoI420 = 0,
461 kVideoYV12 = 1,
462 kVideoYUY2 = 2,
463 kVideoUYVY = 3,
464 kVideoIYUV = 4,
465 kVideoARGB = 5,
466 kVideoRGB24 = 6,
467 kVideoRGB565 = 7,
468 kVideoARGB4444 = 8,
469 kVideoARGB1555 = 9,
470 kVideoMJPEG = 10,
471 kVideoNV12 = 11,
472 kVideoNV21 = 12,
mikhal@webrtc.orgc00f91d2012-01-03 18:49:15 +0000473 kVideoBGRA = 13,
niklase@google.com470e71d2011-07-07 08:21:25 +0000474 kVideoUnknown = 99
475};
476
477// Video codec
478enum { kConfigParameterSize = 128};
479enum { kPayloadNameSize = 32};
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +0000480enum { kMaxSimulcastStreams = 4};
pwestin@webrtc.orgdb221d22011-12-02 11:31:08 +0000481enum { kMaxTemporalStreams = 4};
niklase@google.com470e71d2011-07-07 08:21:25 +0000482
niklase@google.com470e71d2011-07-07 08:21:25 +0000483enum VideoCodecComplexity
484{
485 kComplexityNormal = 0,
486 kComplexityHigh = 1,
487 kComplexityHigher = 2,
488 kComplexityMax = 3
489};
490
491enum VideoCodecProfile
492{
493 kProfileBase = 0x00,
494 kProfileMain = 0x01
495};
496
stefan@webrtc.orgefd0a482011-12-29 10:12:35 +0000497enum VP8ResilienceMode {
498 kResilienceOff, // The stream produced by the encoder requires a
499 // recovery frame (typically a key frame) to be
500 // decodable after a packet loss.
501 kResilientStream, // A stream produced by the encoder is resilient to
502 // packet losses, but packets within a frame subsequent
503 // to a loss can't be decoded.
504 kResilientFrames // Same as kResilientStream but with added resilience
505 // within a frame.
506};
507
niklase@google.com470e71d2011-07-07 08:21:25 +0000508// VP8 specific
509struct VideoCodecVP8
510{
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +0000511 bool pictureLossIndicationOn;
512 bool feedbackModeOn;
513 VideoCodecComplexity complexity;
stefan@webrtc.orgefd0a482011-12-29 10:12:35 +0000514 VP8ResilienceMode resilience;
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +0000515 unsigned char numberOfTemporalLayers;
niklase@google.com470e71d2011-07-07 08:21:25 +0000516};
517
niklase@google.com470e71d2011-07-07 08:21:25 +0000518// Unknown specific
519struct VideoCodecGeneric
520{
521};
522
523// Video codec types
524enum VideoCodecType
525{
niklase@google.com470e71d2011-07-07 08:21:25 +0000526 kVideoCodecVP8,
niklase@google.com470e71d2011-07-07 08:21:25 +0000527 kVideoCodecI420,
528 kVideoCodecRED,
529 kVideoCodecULPFEC,
530 kVideoCodecUnknown
531};
532
533union VideoCodecUnion
534{
niklase@google.com470e71d2011-07-07 08:21:25 +0000535 VideoCodecVP8 VP8;
niklase@google.com470e71d2011-07-07 08:21:25 +0000536 VideoCodecGeneric Generic;
537};
538
phoglund@webrtc.org8bfee842012-02-17 09:32:48 +0000539
540// Simulcast is when the same stream is encoded multiple times with different
541// settings such as resolution.
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +0000542struct SimulcastStream
543{
544 unsigned short width;
545 unsigned short height;
546 unsigned char numberOfTemporalLayers;
547 unsigned int maxBitrate;
548 unsigned int qpMax; // minimum quality
549};
550
niklase@google.com470e71d2011-07-07 08:21:25 +0000551// Common video codec properties
552struct VideoCodec
553{
554 VideoCodecType codecType;
555 char plName[kPayloadNameSize];
556 unsigned char plType;
557
558 unsigned short width;
559 unsigned short height;
560
561 unsigned int startBitrate;
562 unsigned int maxBitrate;
563 unsigned int minBitrate;
564 unsigned char maxFramerate;
565
566 VideoCodecUnion codecSpecific;
567
568 unsigned int qpMax;
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +0000569 unsigned char numberOfSimulcastStreams;
570 SimulcastStream simulcastStream[kMaxSimulcastStreams];
niklase@google.com470e71d2011-07-07 08:21:25 +0000571};
niklase@google.com470e71d2011-07-07 08:21:25 +0000572} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000573#endif // WEBRTC_COMMON_TYPES_H