blob: d6c68fd08575f6d63297eb0943ee72748d9eb1f8 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:251/*
tina.legrand@webrtc.orgdf697752012-02-08 10:22:212 * 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
11/*
12 * This is the main API for NetEQ. Helper macros are located in webrtc_neteq_help_macros.h,
13 * while some internal API functions are found in webrtc_neteq_internal.h.
14 */
15
16#include "typedefs.h"
17
18#ifndef WEBRTC_NETEQ_H
19#define WEBRTC_NETEQ_H
20
21#ifdef __cplusplus
22extern "C"
23{
24#endif
25
26/**********************************************************
27 * Definitions
28 */
29
30enum WebRtcNetEQDecoder
31{
32 kDecoderReservedStart,
33 kDecoderPCMu,
34 kDecoderPCMa,
tina.legrand@webrtc.org45175852012-06-01 09:27:3535 kDecoderPCMu_2ch,
36 kDecoderPCMa_2ch,
niklase@google.com470e71d2011-07-07 08:21:2537 kDecoderILBC,
38 kDecoderISAC,
39 kDecoderISACswb,
turaj@webrtc.orgb0dff122012-12-03 17:43:5240 kDecoderISACfb,
niklase@google.com470e71d2011-07-07 08:21:2541 kDecoderPCM16B,
42 kDecoderPCM16Bwb,
43 kDecoderPCM16Bswb32kHz,
44 kDecoderPCM16Bswb48kHz,
tina.legrand@webrtc.org45175852012-06-01 09:27:3545 kDecoderPCM16B_2ch,
46 kDecoderPCM16Bwb_2ch,
47 kDecoderPCM16Bswb32kHz_2ch,
niklase@google.com470e71d2011-07-07 08:21:2548 kDecoderG722,
tina.legrand@webrtc.org45175852012-06-01 09:27:3549 kDecoderG722_2ch,
niklase@google.com470e71d2011-07-07 08:21:2550 kDecoderRED,
51 kDecoderAVT,
52 kDecoderCNG,
53 kDecoderArbitrary,
54 kDecoderG729,
55 kDecoderG729_1,
56 kDecoderG726_16,
57 kDecoderG726_24,
58 kDecoderG726_32,
59 kDecoderG726_40,
60 kDecoderG722_1_16,
61 kDecoderG722_1_24,
62 kDecoderG722_1_32,
63 kDecoderG722_1C_24,
64 kDecoderG722_1C_32,
65 kDecoderG722_1C_48,
tina.legrand@webrtc.orga7d83872012-10-18 10:00:5266 kDecoderOpus,
niklase@google.com470e71d2011-07-07 08:21:2567 kDecoderSPEEX_8,
68 kDecoderSPEEX_16,
tina.legrand@webrtc.orgdf697752012-02-08 10:22:2169 kDecoderCELT_32,
tina.legrand@webrtc.org45175852012-06-01 09:27:3570 kDecoderCELT_32_2ch,
niklase@google.com470e71d2011-07-07 08:21:2571 kDecoderGSMFR,
72 kDecoderAMR,
73 kDecoderAMRWB,
74 kDecoderReservedEnd
75};
76
77enum WebRtcNetEQNetworkType
78{
79 kUDPNormal,
80 kUDPVideoSync,
81 kTCPNormal,
82 kTCPLargeJitter,
83 kTCPXLargeJitter
84};
85
86enum WebRtcNetEQOutputType
87{
88 kOutputNormal,
89 kOutputPLC,
90 kOutputCNG,
91 kOutputPLCtoCNG,
92 kOutputVADPassive
93};
94
95enum WebRtcNetEQPlayoutMode
96{
97 kPlayoutOn, kPlayoutOff, kPlayoutFax, kPlayoutStreaming
98};
99
100/* Available modes for background noise (inserted after long expands) */
101enum WebRtcNetEQBGNMode
102{
103 kBGNOn, /* default "normal" behavior with eternal noise */
104 kBGNFade, /* noise fades to zero after some time */
105 kBGNOff
106/* background noise is always zero */
107};
108
109/*************************************************
110 * Definitions of decoder calls and the default
111 * API function calls for each codec
112 */
113
pbos@webrtc.org0946a562013-04-09 00:28:06114typedef int16_t (*WebRtcNetEQ_FuncDecode)(void* state, int16_t* encoded,
115 int16_t len, int16_t* decoded,
116 int16_t* speechType);
117typedef int16_t (*WebRtcNetEQ_FuncDecodePLC)(void* state, int16_t* decoded,
118 int16_t frames);
119typedef int16_t (*WebRtcNetEQ_FuncDecodeInit)(void* state);
120typedef int16_t (*WebRtcNetEQ_FuncAddLatePkt)(void* state, int16_t* encoded,
121 int16_t len);
122typedef int16_t (*WebRtcNetEQ_FuncGetMDinfo)(void* state);
123typedef int16_t (*WebRtcNetEQ_FuncGetPitchInfo)(void* state, int16_t* encoded,
124 int16_t* length);
125typedef int16_t (*WebRtcNetEQ_FuncUpdBWEst)(void* state, const uint16_t *encoded,
126 int32_t packet_size,
127 uint16_t rtp_seq_number,
128 uint32_t send_ts,
129 uint32_t arr_ts);
tina.legrand@webrtc.org5ac387c2012-11-19 08:02:55130typedef int (*WebRtcNetEQ_FuncDurationEst)(void* state, const uint8_t* payload,
131 int payload_length_bytes);
pbos@webrtc.org0946a562013-04-09 00:28:06132typedef int16_t (*WebRtcNetEQ_FuncGetErrorCode)(void* state);
niklase@google.com470e71d2011-07-07 08:21:25133
134/**********************************************************
135 * Structures
136 */
137
138typedef struct
139{
140 enum WebRtcNetEQDecoder codec;
pbos@webrtc.org0946a562013-04-09 00:28:06141 int16_t payloadType;
niklase@google.com470e71d2011-07-07 08:21:25142 WebRtcNetEQ_FuncDecode funcDecode;
143 WebRtcNetEQ_FuncDecode funcDecodeRCU;
144 WebRtcNetEQ_FuncDecodePLC funcDecodePLC;
145 WebRtcNetEQ_FuncDecodeInit funcDecodeInit;
146 WebRtcNetEQ_FuncAddLatePkt funcAddLatePkt;
147 WebRtcNetEQ_FuncGetMDinfo funcGetMDinfo;
148 WebRtcNetEQ_FuncGetPitchInfo funcGetPitch;
149 WebRtcNetEQ_FuncUpdBWEst funcUpdBWEst;
tina.legrand@webrtc.org5ac387c2012-11-19 08:02:55150 WebRtcNetEQ_FuncDurationEst funcDurationEst;
niklase@google.com470e71d2011-07-07 08:21:25151 WebRtcNetEQ_FuncGetErrorCode funcGetErrorCode;
152 void* codec_state;
pbos@webrtc.org0946a562013-04-09 00:28:06153 uint16_t codec_fs;
niklase@google.com470e71d2011-07-07 08:21:25154} WebRtcNetEQ_CodecDef;
155
156typedef struct
157{
pbos@webrtc.org0946a562013-04-09 00:28:06158 uint16_t fraction_lost;
159 uint32_t cum_lost;
160 uint32_t ext_max;
161 uint32_t jitter;
niklase@google.com470e71d2011-07-07 08:21:25162} WebRtcNetEQ_RTCPStat;
163
164/**********************************************************
165 * NETEQ Functions
166 */
167
168/* Info functions */
169
170#define WEBRTC_NETEQ_MAX_ERROR_NAME 40
niklase@google.com470e71d2011-07-07 08:21:25171int WebRtcNetEQ_GetErrorCode(void *inst);
leozwang@webrtc.org91b359e2012-02-28 17:26:14172int WebRtcNetEQ_GetErrorName(int errorCode, char *errorName, int maxStrLen);
niklase@google.com470e71d2011-07-07 08:21:25173
174/* Instance memory assign functions */
175
176int WebRtcNetEQ_AssignSize(int *sizeinbytes);
177int WebRtcNetEQ_Assign(void **inst, void *NETEQ_inst_Addr);
perkj@webrtc.org6b1bfd62011-12-02 12:48:19178int WebRtcNetEQ_GetRecommendedBufferSize(void *inst, const enum WebRtcNetEQDecoder *codec,
niklase@google.com470e71d2011-07-07 08:21:25179 int noOfCodecs, enum WebRtcNetEQNetworkType nwType,
turaj@webrtc.org6388c3e2013-02-12 21:42:18180 int *MaxNoOfPackets, int *sizeinbytes,
181 int* per_packet_overhead_bytes);
niklase@google.com470e71d2011-07-07 08:21:25182int WebRtcNetEQ_AssignBuffer(void *inst, int MaxNoOfPackets, void *NETEQ_Buffer_Addr,
183 int sizeinbytes);
184
185/* Init functions */
186
pbos@webrtc.org0946a562013-04-09 00:28:06187int WebRtcNetEQ_Init(void *inst, uint16_t fs);
niklase@google.com470e71d2011-07-07 08:21:25188int WebRtcNetEQ_SetAVTPlayout(void *inst, int PlayoutAVTon);
189int WebRtcNetEQ_SetExtraDelay(void *inst, int DelayInMs);
190int WebRtcNetEQ_SetPlayoutMode(void *inst, enum WebRtcNetEQPlayoutMode playoutMode);
191int WebRtcNetEQ_SetBGNMode(void *inst, enum WebRtcNetEQBGNMode bgnMode);
192int WebRtcNetEQ_GetBGNMode(const void *inst, enum WebRtcNetEQBGNMode *bgnMode);
193
194/* Codec Database functions */
195
196int WebRtcNetEQ_CodecDbReset(void *inst);
197int WebRtcNetEQ_CodecDbAdd(void *inst, WebRtcNetEQ_CodecDef *codecInst);
198int WebRtcNetEQ_CodecDbRemove(void *inst, enum WebRtcNetEQDecoder codec);
pbos@webrtc.org0946a562013-04-09 00:28:06199int WebRtcNetEQ_CodecDbGetSizeInfo(void *inst, int16_t *UsedEntries,
200 int16_t *MaxEntries);
201int WebRtcNetEQ_CodecDbGetCodecInfo(void *inst, int16_t Entry,
niklase@google.com470e71d2011-07-07 08:21:25202 enum WebRtcNetEQDecoder *codec);
203
204/* Real-time functions */
205
pbos@webrtc.org0946a562013-04-09 00:28:06206int WebRtcNetEQ_RecIn(void *inst, int16_t *p_w16datagramstart, int16_t w16_RTPlen,
207 uint32_t uw32_timeRec);
208int WebRtcNetEQ_RecOut(void *inst, int16_t *pw16_outData, int16_t *pw16_len);
niklase@google.com470e71d2011-07-07 08:21:25209int WebRtcNetEQ_GetRTCPStats(void *inst, WebRtcNetEQ_RTCPStat *RTCP_inst);
210int WebRtcNetEQ_GetRTCPStatsNoReset(void *inst, WebRtcNetEQ_RTCPStat *RTCP_inst);
pbos@webrtc.org0946a562013-04-09 00:28:06211int WebRtcNetEQ_GetSpeechTimeStamp(void *inst, uint32_t *timestamp);
niklase@google.com470e71d2011-07-07 08:21:25212int WebRtcNetEQ_GetSpeechOutputType(void *inst, enum WebRtcNetEQOutputType *outputType);
213
214/* VQmon related functions */
pbos@webrtc.org0946a562013-04-09 00:28:06215int WebRtcNetEQ_VQmonRecOutStatistics(void *inst, uint16_t *validVoiceDurationMs,
216 uint16_t *concealedVoiceDurationMs,
217 uint8_t *concealedVoiceFlags);
218int WebRtcNetEQ_VQmonGetConfiguration(void *inst, uint16_t *absMaxDelayMs,
219 uint8_t *adaptationRate);
220int WebRtcNetEQ_VQmonGetRxStatistics(void *inst, uint16_t *avgDelayMs,
221 uint16_t *maxDelayMs);
niklase@google.com470e71d2011-07-07 08:21:25222
223#ifdef __cplusplus
224}
225#endif
226
227#endif