niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 1 | /* |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 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 | |
| 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 |
| 22 | extern "C" |
| 23 | { |
| 24 | #endif |
| 25 | |
| 26 | /********************************************************** |
| 27 | * Definitions |
| 28 | */ |
| 29 | |
| 30 | enum WebRtcNetEQDecoder |
| 31 | { |
| 32 | kDecoderReservedStart, |
| 33 | kDecoderPCMu, |
| 34 | kDecoderPCMa, |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 | [diff] [blame] | 35 | kDecoderPCMu_2ch, |
| 36 | kDecoderPCMa_2ch, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 37 | kDecoderILBC, |
| 38 | kDecoderISAC, |
| 39 | kDecoderISACswb, |
turaj@webrtc.org | b0dff12 | 2012-12-03 17:43:52 | [diff] [blame] | 40 | kDecoderISACfb, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 41 | kDecoderPCM16B, |
| 42 | kDecoderPCM16Bwb, |
| 43 | kDecoderPCM16Bswb32kHz, |
| 44 | kDecoderPCM16Bswb48kHz, |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 | [diff] [blame] | 45 | kDecoderPCM16B_2ch, |
| 46 | kDecoderPCM16Bwb_2ch, |
| 47 | kDecoderPCM16Bswb32kHz_2ch, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 48 | kDecoderG722, |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 | [diff] [blame] | 49 | kDecoderG722_2ch, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 50 | 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.org | a7d8387 | 2012-10-18 10:00:52 | [diff] [blame] | 66 | kDecoderOpus, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 67 | kDecoderSPEEX_8, |
| 68 | kDecoderSPEEX_16, |
tina.legrand@webrtc.org | df69775 | 2012-02-08 10:22:21 | [diff] [blame] | 69 | kDecoderCELT_32, |
tina.legrand@webrtc.org | 4517585 | 2012-06-01 09:27:35 | [diff] [blame] | 70 | kDecoderCELT_32_2ch, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 71 | kDecoderGSMFR, |
| 72 | kDecoderAMR, |
| 73 | kDecoderAMRWB, |
| 74 | kDecoderReservedEnd |
| 75 | }; |
| 76 | |
| 77 | enum WebRtcNetEQNetworkType |
| 78 | { |
| 79 | kUDPNormal, |
| 80 | kUDPVideoSync, |
| 81 | kTCPNormal, |
| 82 | kTCPLargeJitter, |
| 83 | kTCPXLargeJitter |
| 84 | }; |
| 85 | |
| 86 | enum WebRtcNetEQOutputType |
| 87 | { |
| 88 | kOutputNormal, |
| 89 | kOutputPLC, |
| 90 | kOutputCNG, |
| 91 | kOutputPLCtoCNG, |
| 92 | kOutputVADPassive |
| 93 | }; |
| 94 | |
| 95 | enum WebRtcNetEQPlayoutMode |
| 96 | { |
| 97 | kPlayoutOn, kPlayoutOff, kPlayoutFax, kPlayoutStreaming |
| 98 | }; |
| 99 | |
| 100 | /* Available modes for background noise (inserted after long expands) */ |
| 101 | enum 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.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame^] | 114 | typedef int16_t (*WebRtcNetEQ_FuncDecode)(void* state, int16_t* encoded, |
| 115 | int16_t len, int16_t* decoded, |
| 116 | int16_t* speechType); |
| 117 | typedef int16_t (*WebRtcNetEQ_FuncDecodePLC)(void* state, int16_t* decoded, |
| 118 | int16_t frames); |
| 119 | typedef int16_t (*WebRtcNetEQ_FuncDecodeInit)(void* state); |
| 120 | typedef int16_t (*WebRtcNetEQ_FuncAddLatePkt)(void* state, int16_t* encoded, |
| 121 | int16_t len); |
| 122 | typedef int16_t (*WebRtcNetEQ_FuncGetMDinfo)(void* state); |
| 123 | typedef int16_t (*WebRtcNetEQ_FuncGetPitchInfo)(void* state, int16_t* encoded, |
| 124 | int16_t* length); |
| 125 | typedef 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.org | 5ac387c | 2012-11-19 08:02:55 | [diff] [blame] | 130 | typedef int (*WebRtcNetEQ_FuncDurationEst)(void* state, const uint8_t* payload, |
| 131 | int payload_length_bytes); |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame^] | 132 | typedef int16_t (*WebRtcNetEQ_FuncGetErrorCode)(void* state); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 133 | |
| 134 | /********************************************************** |
| 135 | * Structures |
| 136 | */ |
| 137 | |
| 138 | typedef struct |
| 139 | { |
| 140 | enum WebRtcNetEQDecoder codec; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame^] | 141 | int16_t payloadType; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 142 | 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.org | 5ac387c | 2012-11-19 08:02:55 | [diff] [blame] | 150 | WebRtcNetEQ_FuncDurationEst funcDurationEst; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 151 | WebRtcNetEQ_FuncGetErrorCode funcGetErrorCode; |
| 152 | void* codec_state; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame^] | 153 | uint16_t codec_fs; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 154 | } WebRtcNetEQ_CodecDef; |
| 155 | |
| 156 | typedef struct |
| 157 | { |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame^] | 158 | uint16_t fraction_lost; |
| 159 | uint32_t cum_lost; |
| 160 | uint32_t ext_max; |
| 161 | uint32_t jitter; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 162 | } WebRtcNetEQ_RTCPStat; |
| 163 | |
| 164 | /********************************************************** |
| 165 | * NETEQ Functions |
| 166 | */ |
| 167 | |
| 168 | /* Info functions */ |
| 169 | |
| 170 | #define WEBRTC_NETEQ_MAX_ERROR_NAME 40 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 171 | int WebRtcNetEQ_GetErrorCode(void *inst); |
leozwang@webrtc.org | 91b359e | 2012-02-28 17:26:14 | [diff] [blame] | 172 | int WebRtcNetEQ_GetErrorName(int errorCode, char *errorName, int maxStrLen); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 173 | |
| 174 | /* Instance memory assign functions */ |
| 175 | |
| 176 | int WebRtcNetEQ_AssignSize(int *sizeinbytes); |
| 177 | int WebRtcNetEQ_Assign(void **inst, void *NETEQ_inst_Addr); |
perkj@webrtc.org | 6b1bfd6 | 2011-12-02 12:48:19 | [diff] [blame] | 178 | int WebRtcNetEQ_GetRecommendedBufferSize(void *inst, const enum WebRtcNetEQDecoder *codec, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 179 | int noOfCodecs, enum WebRtcNetEQNetworkType nwType, |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 | [diff] [blame] | 180 | int *MaxNoOfPackets, int *sizeinbytes, |
| 181 | int* per_packet_overhead_bytes); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 182 | int WebRtcNetEQ_AssignBuffer(void *inst, int MaxNoOfPackets, void *NETEQ_Buffer_Addr, |
| 183 | int sizeinbytes); |
| 184 | |
| 185 | /* Init functions */ |
| 186 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame^] | 187 | int WebRtcNetEQ_Init(void *inst, uint16_t fs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 188 | int WebRtcNetEQ_SetAVTPlayout(void *inst, int PlayoutAVTon); |
| 189 | int WebRtcNetEQ_SetExtraDelay(void *inst, int DelayInMs); |
| 190 | int WebRtcNetEQ_SetPlayoutMode(void *inst, enum WebRtcNetEQPlayoutMode playoutMode); |
| 191 | int WebRtcNetEQ_SetBGNMode(void *inst, enum WebRtcNetEQBGNMode bgnMode); |
| 192 | int WebRtcNetEQ_GetBGNMode(const void *inst, enum WebRtcNetEQBGNMode *bgnMode); |
| 193 | |
| 194 | /* Codec Database functions */ |
| 195 | |
| 196 | int WebRtcNetEQ_CodecDbReset(void *inst); |
| 197 | int WebRtcNetEQ_CodecDbAdd(void *inst, WebRtcNetEQ_CodecDef *codecInst); |
| 198 | int WebRtcNetEQ_CodecDbRemove(void *inst, enum WebRtcNetEQDecoder codec); |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame^] | 199 | int WebRtcNetEQ_CodecDbGetSizeInfo(void *inst, int16_t *UsedEntries, |
| 200 | int16_t *MaxEntries); |
| 201 | int WebRtcNetEQ_CodecDbGetCodecInfo(void *inst, int16_t Entry, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 202 | enum WebRtcNetEQDecoder *codec); |
| 203 | |
| 204 | /* Real-time functions */ |
| 205 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame^] | 206 | int WebRtcNetEQ_RecIn(void *inst, int16_t *p_w16datagramstart, int16_t w16_RTPlen, |
| 207 | uint32_t uw32_timeRec); |
| 208 | int WebRtcNetEQ_RecOut(void *inst, int16_t *pw16_outData, int16_t *pw16_len); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 209 | int WebRtcNetEQ_GetRTCPStats(void *inst, WebRtcNetEQ_RTCPStat *RTCP_inst); |
| 210 | int WebRtcNetEQ_GetRTCPStatsNoReset(void *inst, WebRtcNetEQ_RTCPStat *RTCP_inst); |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame^] | 211 | int WebRtcNetEQ_GetSpeechTimeStamp(void *inst, uint32_t *timestamp); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 212 | int WebRtcNetEQ_GetSpeechOutputType(void *inst, enum WebRtcNetEQOutputType *outputType); |
| 213 | |
| 214 | /* VQmon related functions */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame^] | 215 | int WebRtcNetEQ_VQmonRecOutStatistics(void *inst, uint16_t *validVoiceDurationMs, |
| 216 | uint16_t *concealedVoiceDurationMs, |
| 217 | uint8_t *concealedVoiceFlags); |
| 218 | int WebRtcNetEQ_VQmonGetConfiguration(void *inst, uint16_t *absMaxDelayMs, |
| 219 | uint8_t *adaptationRate); |
| 220 | int WebRtcNetEQ_VQmonGetRxStatistics(void *inst, uint16_t *avgDelayMs, |
| 221 | uint16_t *maxDelayMs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 222 | |
| 223 | #ifdef __cplusplus |
| 224 | } |
| 225 | #endif |
| 226 | |
| 227 | #endif |