git-svn-id: http://webrtc.googlecode.com/svn/trunk@4 4adac7df-926f-26a2-2b94-8c16560cd09d

This commit is contained in:
niklase@google.com
2011-05-30 11:22:19 +00:00
parent 01813fe945
commit 77ae29bc81
1153 changed files with 404089 additions and 0 deletions

View File

@@ -0,0 +1,215 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* This is the main API for NetEQ. Helper macros are located in webrtc_neteq_help_macros.h,
* while some internal API functions are found in webrtc_neteq_internal.h.
*/
#include "typedefs.h"
#ifndef WEBRTC_NETEQ_H
#define WEBRTC_NETEQ_H
#ifdef __cplusplus
extern "C"
{
#endif
/**********************************************************
* Definitions
*/
enum WebRtcNetEQDecoder
{
kDecoderReservedStart,
kDecoderPCMu,
kDecoderPCMa,
kDecoderILBC,
kDecoderISAC,
kDecoderISACswb,
kDecoderPCM16B,
kDecoderPCM16Bwb,
kDecoderPCM16Bswb32kHz,
kDecoderPCM16Bswb48kHz,
kDecoderG722,
kDecoderRED,
kDecoderAVT,
kDecoderCNG,
kDecoderArbitrary,
kDecoderG729,
kDecoderG729_1,
kDecoderG726_16,
kDecoderG726_24,
kDecoderG726_32,
kDecoderG726_40,
kDecoderG722_1_16,
kDecoderG722_1_24,
kDecoderG722_1_32,
kDecoderG722_1C_24,
kDecoderG722_1C_32,
kDecoderG722_1C_48,
kDecoderSPEEX_8,
kDecoderSPEEX_16,
kDecoderGSMFR,
kDecoderAMR,
kDecoderAMRWB,
kDecoderReservedEnd
};
enum WebRtcNetEQNetworkType
{
kUDPNormal,
kUDPVideoSync,
kTCPNormal,
kTCPLargeJitter,
kTCPXLargeJitter
};
enum WebRtcNetEQOutputType
{
kOutputNormal,
kOutputPLC,
kOutputCNG,
kOutputPLCtoCNG,
kOutputVADPassive
};
enum WebRtcNetEQPlayoutMode
{
kPlayoutOn, kPlayoutOff, kPlayoutFax, kPlayoutStreaming
};
/* Available modes for background noise (inserted after long expands) */
enum WebRtcNetEQBGNMode
{
kBGNOn, /* default "normal" behavior with eternal noise */
kBGNFade, /* noise fades to zero after some time */
kBGNOff
/* background noise is always zero */
};
/*************************************************
* Definitions of decoder calls and the default
* API function calls for each codec
*/
typedef WebRtc_Word16 (*WebRtcNetEQ_FuncDecode)(void* state, WebRtc_Word16* encoded,
WebRtc_Word16 len, WebRtc_Word16* decoded,
WebRtc_Word16* speechType);
typedef WebRtc_Word16 (*WebRtcNetEQ_FuncDecodePLC)(void* state, WebRtc_Word16* decoded,
WebRtc_Word16 frames);
typedef WebRtc_Word16 (*WebRtcNetEQ_FuncDecodeInit)(void* state);
typedef WebRtc_Word16 (*WebRtcNetEQ_FuncAddLatePkt)(void* state, WebRtc_Word16* encoded,
WebRtc_Word16 len);
typedef WebRtc_Word16 (*WebRtcNetEQ_FuncGetMDinfo)(void* state);
typedef WebRtc_Word16 (*WebRtcNetEQ_FuncGetPitchInfo)(void* state, WebRtc_Word16* encoded,
WebRtc_Word16* length);
typedef WebRtc_Word16 (*WebRtcNetEQ_FuncUpdBWEst)(void* state, const WebRtc_UWord16 *encoded,
WebRtc_Word32 packet_size,
WebRtc_UWord16 rtp_seq_number,
WebRtc_UWord32 send_ts,
WebRtc_UWord32 arr_ts);
typedef WebRtc_Word16 (*WebRtcNetEQ_FuncGetErrorCode)(void* state);
/**********************************************************
* Structures
*/
typedef struct
{
enum WebRtcNetEQDecoder codec;
WebRtc_Word16 payloadType;
WebRtcNetEQ_FuncDecode funcDecode;
WebRtcNetEQ_FuncDecode funcDecodeRCU;
WebRtcNetEQ_FuncDecodePLC funcDecodePLC;
WebRtcNetEQ_FuncDecodeInit funcDecodeInit;
WebRtcNetEQ_FuncAddLatePkt funcAddLatePkt;
WebRtcNetEQ_FuncGetMDinfo funcGetMDinfo;
WebRtcNetEQ_FuncGetPitchInfo funcGetPitch;
WebRtcNetEQ_FuncUpdBWEst funcUpdBWEst;
WebRtcNetEQ_FuncGetErrorCode funcGetErrorCode;
void* codec_state;
WebRtc_UWord16 codec_fs;
} WebRtcNetEQ_CodecDef;
typedef struct
{
WebRtc_UWord16 fraction_lost;
WebRtc_UWord32 cum_lost;
WebRtc_UWord32 ext_max;
WebRtc_UWord32 jitter;
} WebRtcNetEQ_RTCPStat;
/**********************************************************
* NETEQ Functions
*/
/* Info functions */
#define WEBRTC_NETEQ_MAX_ERROR_NAME 40
int WebRtcNetEQ_GetVersion(WebRtc_Word8 *version);
int WebRtcNetEQ_GetErrorCode(void *inst);
int WebRtcNetEQ_GetErrorName(int errorCode, WebRtc_Word8 *errorName, int maxStrLen);
/* Instance memory assign functions */
int WebRtcNetEQ_AssignSize(int *sizeinbytes);
int WebRtcNetEQ_Assign(void **inst, void *NETEQ_inst_Addr);
int WebRtcNetEQ_GetRecommendedBufferSize(void *inst, enum WebRtcNetEQDecoder *codec,
int noOfCodecs, enum WebRtcNetEQNetworkType nwType,
int *MaxNoOfPackets, int *sizeinbytes);
int WebRtcNetEQ_AssignBuffer(void *inst, int MaxNoOfPackets, void *NETEQ_Buffer_Addr,
int sizeinbytes);
/* Init functions */
int WebRtcNetEQ_Init(void *inst, WebRtc_UWord16 fs);
int WebRtcNetEQ_SetAVTPlayout(void *inst, int PlayoutAVTon);
int WebRtcNetEQ_SetExtraDelay(void *inst, int DelayInMs);
int WebRtcNetEQ_SetPlayoutMode(void *inst, enum WebRtcNetEQPlayoutMode playoutMode);
int WebRtcNetEQ_SetBGNMode(void *inst, enum WebRtcNetEQBGNMode bgnMode);
int WebRtcNetEQ_GetBGNMode(const void *inst, enum WebRtcNetEQBGNMode *bgnMode);
/* Codec Database functions */
int WebRtcNetEQ_CodecDbReset(void *inst);
int WebRtcNetEQ_CodecDbAdd(void *inst, WebRtcNetEQ_CodecDef *codecInst);
int WebRtcNetEQ_CodecDbRemove(void *inst, enum WebRtcNetEQDecoder codec);
int WebRtcNetEQ_CodecDbGetSizeInfo(void *inst, WebRtc_Word16 *UsedEntries,
WebRtc_Word16 *MaxEntries);
int WebRtcNetEQ_CodecDbGetCodecInfo(void *inst, WebRtc_Word16 Entry,
enum WebRtcNetEQDecoder *codec);
/* Real-time functions */
int WebRtcNetEQ_RecIn(void *inst, WebRtc_Word16 *p_w16datagramstart, WebRtc_Word16 w16_RTPlen,
WebRtc_UWord32 uw32_timeRec);
int WebRtcNetEQ_RecOut(void *inst, WebRtc_Word16 *pw16_outData, WebRtc_Word16 *pw16_len);
int WebRtcNetEQ_GetRTCPStats(void *inst, WebRtcNetEQ_RTCPStat *RTCP_inst);
int WebRtcNetEQ_GetRTCPStatsNoReset(void *inst, WebRtcNetEQ_RTCPStat *RTCP_inst);
int WebRtcNetEQ_GetSpeechTimeStamp(void *inst, WebRtc_UWord32 *timestamp);
int WebRtcNetEQ_GetSpeechOutputType(void *inst, enum WebRtcNetEQOutputType *outputType);
/* VQmon related functions */
int WebRtcNetEQ_VQmonRecOutStatistics(void *inst, WebRtc_UWord16 *validVoiceDurationMs,
WebRtc_UWord16 *concealedVoiceDurationMs,
WebRtc_UWord8 *concealedVoiceFlags);
int WebRtcNetEQ_VQmonGetConfiguration(void *inst, WebRtc_UWord16 *absMaxDelayMs,
WebRtc_UWord8 *adaptationRate);
int WebRtcNetEQ_VQmonGetRxStatistics(void *inst, WebRtc_UWord16 *avgDelayMs,
WebRtc_UWord16 *maxDelayMs);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,365 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* This file contains some helper macros that can be used when loading the
* NetEQ codec database.
*/
#ifndef WEBRTC_NETEQ_HELP_MACROS_H
#define WEBRTC_NETEQ_HELP_MACROS_H
#ifndef NULL
#define NULL 0
#endif
/**********************************************************
* Help macros for NetEQ initialization
*/
#define SET_CODEC_PAR(inst,decoder,pt,state,fs) \
inst.codec=decoder; \
inst.payloadType=pt; \
inst.codec_state=state; \
inst.codec_fs=fs;
#define SET_PCMU_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG711_DecodeU; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=NULL; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_PCMA_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG711_DecodeA; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=NULL; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_ILBC_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcIlbcfix_Decode; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcIlbcfix_NetEqPlc; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcIlbcfix_Decoderinit30Ms; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_ISAC_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcIsac_Decode; \
inst.funcDecodeRCU=(WebRtcNetEQ_FuncDecode)WebRtcIsac_DecodeRcu; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcIsac_DecoderInit; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=(WebRtcNetEQ_FuncUpdBWEst)WebRtcIsac_UpdateBwEstimate; \
inst.funcGetErrorCode=(WebRtcNetEQ_FuncGetErrorCode)WebRtcIsac_GetErrorCode;
#define SET_ISACfix_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcIsacfix_Decode; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcIsacfix_DecoderInit; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=(WebRtcNetEQ_FuncUpdBWEst)WebRtcIsacfix_UpdateBwEstimate; \
inst.funcGetErrorCode=(WebRtcNetEQ_FuncGetErrorCode)WebRtcIsacfix_GetErrorCode;
#define SET_ISACSWB_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcIsac_Decode; \
inst.funcDecodeRCU=(WebRtcNetEQ_FuncDecode)WebRtcIsac_DecodeRcu; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcIsac_DecoderInit; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=(WebRtcNetEQ_FuncUpdBWEst)WebRtcIsac_UpdateBwEstimate; \
inst.funcGetErrorCode=(WebRtcNetEQ_FuncGetErrorCode)WebRtcIsac_GetErrorCode;
#define SET_G729_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG729_Decode; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcG729_DecodePlc; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG729_DecoderInit; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G729_1_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG7291_Decode; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG7291_DecoderInit; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=(WebRtcNetEQ_FuncUpdBWEst)WebRtcG7291_DecodeBwe; \
inst.funcGetErrorCode=NULL;
#define SET_PCM16B_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcPcm16b_DecodeW16; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=NULL; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_PCM16B_WB_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcPcm16b_DecodeW16; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=NULL; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_PCM16B_SWB32_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcPcm16b_DecodeW16; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=NULL; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_PCM16B_SWB48_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcPcm16b_DecodeW16; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=NULL; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G722_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG722_Decode; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG722_DecoderInit;\
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G722_1_16_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG7221_Decode16; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcG7221_DecodePlc16; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG7221_DecoderInit16; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G722_1_24_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG7221_Decode24; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcG7221_DecodePlc24; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG7221_DecoderInit24; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G722_1_32_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG7221_Decode32; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcG7221_DecodePlc32; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG7221_DecoderInit32; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G722_1C_24_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG7221C_Decode24; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcG7221C_DecodePlc24; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG7221C_DecoderInit24; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G722_1C_32_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG7221C_Decode32; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcG7221C_DecodePlc32; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG7221C_DecoderInit32; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G722_1C_48_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG7221C_Decode48; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcG7221C_DecodePlc48; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG7221C_DecoderInit48; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_AMR_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcAmr_Decode; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcAmr_DecodePlc; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcAmr_DecoderInit; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_AMRWB_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcAmrWb_Decode; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcAmrWb_DecodePlc; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcAmrWb_DecoderInit; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_GSMFR_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcGSMFR_Decode; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcGSMFR_DecodePlc; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcGSMFR_DecoderInit; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G726_16_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG726_decode16; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG726_decoderinit16; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G726_24_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG726_decode24; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG726_decoderinit24; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G726_32_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG726_decode32; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG726_decoderinit32; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_G726_40_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcG726_decode40; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcG726_decoderinit40; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_SPEEX_FUNCTIONS(inst) \
inst.funcDecode=(WebRtcNetEQ_FuncDecode)WebRtcSpeex_Decode; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=(WebRtcNetEQ_FuncDecodePLC)WebRtcSpeex_DecodePlc; \
inst.funcDecodeInit=(WebRtcNetEQ_FuncDecodeInit)WebRtcSpeex_DecoderInit; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_RED_FUNCTIONS(inst) \
inst.funcDecode=NULL; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=NULL; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_AVT_FUNCTIONS(inst) \
inst.funcDecode=NULL; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=NULL; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#define SET_CNG_FUNCTIONS(inst) \
inst.funcDecode=NULL; \
inst.funcDecodeRCU=NULL; \
inst.funcDecodePLC=NULL; \
inst.funcDecodeInit=NULL; \
inst.funcAddLatePkt=NULL; \
inst.funcGetMDinfo=NULL; \
inst.funcGetPitch=NULL; \
inst.funcUpdBWEst=NULL; \
inst.funcGetErrorCode=NULL;
#endif /* WEBRTC_NETEQ_HELP_MACROS_H */

View File

@@ -0,0 +1,274 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* This file contains the internal API functions.
*/
#include "typedefs.h"
#ifndef WEBRTC_NETEQ_INTERNAL_H
#define WEBRTC_NETEQ_INTERNAL_H
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct
{
WebRtc_UWord8 payloadType;
WebRtc_UWord16 sequenceNumber;
WebRtc_UWord32 timeStamp;
WebRtc_UWord32 SSRC;
WebRtc_UWord8 markerBit;
} WebRtcNetEQ_RTPInfo;
/****************************************************************************
* WebRtcNetEQ_RecInRTPStruct(...)
*
* Alternative RecIn function, used when the RTP data has already been
* parsed into an RTP info struct (WebRtcNetEQ_RTPInfo).
*
* Input:
* - inst : NetEQ instance
* - rtpInfo : Pointer to RTP info
* - payloadPtr : Pointer to the RTP payload (first byte after header)
* - payloadLenBytes : Length (in bytes) of the payload in payloadPtr
* - timeRec : Receive time (in timestamps of the used codec)
*
* Return value : 0 - Ok
* -1 - Error
*/
int WebRtcNetEQ_RecInRTPStruct(void *inst, WebRtcNetEQ_RTPInfo *rtpInfo,
const WebRtc_UWord8 *payloadPtr, WebRtc_Word16 payloadLenBytes,
WebRtc_UWord32 timeRec);
/****************************************************************************
* WebRtcNetEQ_GetMasterSlaveInfoSize(...)
*
* Get size in bytes for master/slave struct msInfo used in
* WebRtcNetEQ_RecOutMasterSlave.
*
* Return value : Struct size in bytes
*
*/
int WebRtcNetEQ_GetMasterSlaveInfoSize();
/****************************************************************************
* WebRtcNetEQ_RecOutMasterSlave(...)
*
* RecOut function for running several NetEQ instances in master/slave mode.
* One master can be used to control several slaves.
* The MasterSlaveInfo struct must be allocated outside NetEQ.
* Use function WebRtcNetEQ_GetMasterSlaveInfoSize to get the size needed.
*
* Input:
* - inst : NetEQ instance
* - isMaster : Non-zero indicates that this is the master channel
* - msInfo : (slave only) Information from master
*
* Output:
* - inst : Updated NetEQ instance
* - pw16_outData : Pointer to vector where output should be written
* - pw16_len : Pointer to variable where output length is returned
* - msInfo : (master only) Information to slave(s)
*
* Return value : 0 - Ok
* -1 - Error
*/
int WebRtcNetEQ_RecOutMasterSlave(void *inst, WebRtc_Word16 *pw16_outData,
WebRtc_Word16 *pw16_len, void *msInfo,
WebRtc_Word16 isMaster);
typedef struct
{
WebRtc_UWord16 currentBufferSize; /* current jitter buffer size in ms */
WebRtc_UWord16 preferredBufferSize; /* preferred (optimal) buffer size in ms */
WebRtc_UWord16 currentPacketLossRate; /* loss rate (network + late) (in Q14) */
WebRtc_UWord16 currentDiscardRate; /* late loss rate (in Q14) */
WebRtc_UWord16 currentExpandRate; /* fraction (of original stream) of synthesized speech
* inserted through expansion (in Q14) */
WebRtc_UWord16 currentPreemptiveRate; /* fraction of synthesized speech inserted through
* pre-emptive expansion (in Q14) */
WebRtc_UWord16 currentAccelerateRate; /* fraction of data removed through acceleration
* (in Q14) */
} WebRtcNetEQ_NetworkStatistics;
typedef struct
{
WebRtc_UWord32 jbMinSize; /* smallest Jitter Buffer size during call in ms */
WebRtc_UWord32 jbMaxSize; /* largest Jitter Buffer size during call in ms */
WebRtc_UWord32 jbAvgSize; /* the average JB size, measured over time - ms */
WebRtc_UWord32 jbChangeCount; /* number of times the Jitter Buffer changed
* (using Accelerate or Pre-emptive Expand) */
WebRtc_UWord32 lateLossMs; /* amount (in ms) of audio data received late */
WebRtc_UWord32 accelerateMs; /* milliseconds removed to reduce jitter buffer size */
WebRtc_UWord32 flushedMs; /* milliseconds discarded through buffer flushing */
WebRtc_UWord32 generatedSilentMs; /* milliseconds of generated silence */
WebRtc_UWord32 interpolatedVoiceMs; /* milliseconds of synthetic audio data
* (non-background noise) */
WebRtc_UWord32 interpolatedSilentMs; /* milliseconds of synthetic audio data
* (background noise level) */
WebRtc_UWord32 countExpandMoreThan120ms; /* count of tiny expansions in output audio */
WebRtc_UWord32 countExpandMoreThan250ms; /* count of small expansions in output audio */
WebRtc_UWord32 countExpandMoreThan500ms; /* count of medium expansions in output audio */
WebRtc_UWord32 countExpandMoreThan2000ms; /* count of long expansions in output audio */
WebRtc_UWord32 longestExpandDurationMs; /* duration of longest audio drop-out */
WebRtc_UWord32 countIAT500ms; /* count of times we got small network outage (inter-arrival
* time in [500, 1000) ms) */
WebRtc_UWord32 countIAT1000ms; /* count of times we got medium network outage
* (inter-arrival time in [1000, 2000) ms) */
WebRtc_UWord32 countIAT2000ms; /* count of times we got large network outage
* (inter-arrival time >= 2000 ms) */
WebRtc_UWord32 longestIATms; /* longest packet inter-arrival time in ms */
WebRtc_UWord32 minPacketDelayMs; /* min time incoming Packet "waited" to be played */
WebRtc_UWord32 maxPacketDelayMs; /* max time incoming Packet "waited" to be played */
WebRtc_UWord32 avgPacketDelayMs; /* avg time incoming Packet "waited" to be played */
} WebRtcNetEQ_JitterStatistics;
/*
* Get the "in-call" statistics from NetEQ.
* The statistics are reset after the query.
*/
int WebRtcNetEQ_GetNetworkStatistics(void *inst, WebRtcNetEQ_NetworkStatistics *stats);
/*
* Get the optimal buffer size calculated for the current network conditions.
*/
int WebRtcNetEQ_GetPreferredBufferSize(void *inst, WebRtc_UWord16 *preferredBufferSize);
/*
* Get the current buffer size in ms. Return value is 0 if ok, -1 if error.
*/
int WebRtcNetEQ_GetCurrentDelay(const void *inst, WebRtc_UWord16 *currentDelayMs);
/*
* Get the "post-call" jitter statistics from NetEQ.
* The statistics are not reset by the query. Use the function
* WebRtcNetEQ_ResetJitterStatistics to reset the statistics.
*/
int WebRtcNetEQ_GetJitterStatistics(void *inst, WebRtcNetEQ_JitterStatistics *jitterStats);
/*
* Reset "post-call" jitter statistics.
*/
int WebRtcNetEQ_ResetJitterStatistics(void *inst);
/***********************************************/
/* Functions for post-decode VAD functionality */
/***********************************************/
/* NetEQ must be compiled with the flag NETEQ_VAD enabled for these functions to work. */
/*
* VAD function pointer types
*
* These function pointers match the definitions of webrtc VAD functions WebRtcVad_Init,
* WebRtcVad_set_mode and WebRtcVad_Process, respectively, all found in webrtc_vad.h.
*/
typedef WebRtc_Word16 (*WebRtcNetEQ_VADInitFunction)(void *VAD_inst);
typedef WebRtc_Word16 (*WebRtcNetEQ_VADSetmodeFunction)(void *VAD_inst, WebRtc_Word16 mode);
typedef WebRtc_Word16 (*WebRtcNetEQ_VADFunction)(void *VAD_inst, WebRtc_Word16 fs,
WebRtc_Word16 *frame, WebRtc_Word16 frameLen);
/****************************************************************************
* WebRtcNetEQ_SetVADInstance(...)
*
* Provide a pointer to an allocated VAD instance. If function is never
* called or it is called with NULL pointer as VAD_inst, the post-decode
* VAD functionality is disabled. Also provide pointers to init, setmode
* and VAD functions. These are typically pointers to WebRtcVad_Init,
* WebRtcVad_set_mode and WebRtcVad_Process, respectively, all found in the
* interface file webrtc_vad.h.
*
* Input:
* - NetEQ_inst : NetEQ instance
* - VADinst : VAD instance
* - initFunction : Pointer to VAD init function
* - setmodeFunction : Pointer to VAD setmode function
* - VADfunction : Pointer to VAD function
*
* Output:
* - NetEQ_inst : Updated NetEQ instance
*
* Return value : 0 - Ok
* -1 - Error
*/
int WebRtcNetEQ_SetVADInstance(void *NetEQ_inst, void *VAD_inst,
WebRtcNetEQ_VADInitFunction initFunction,
WebRtcNetEQ_VADSetmodeFunction setmodeFunction,
WebRtcNetEQ_VADFunction VADFunction);
/****************************************************************************
* WebRtcNetEQ_SetVADMode(...)
*
* Pass an aggressiveness mode parameter to the post-decode VAD instance.
* If this function is never called, mode 0 (quality mode) is used as default.
*
* Input:
* - inst : NetEQ instance
* - mode : mode parameter (same range as WebRtc VAD mode)
*
* Output:
* - inst : Updated NetEQ instance
*
* Return value : 0 - Ok
* -1 - Error
*/
int WebRtcNetEQ_SetVADMode(void *NetEQ_inst, WebRtc_Word16 mode);
/****************************************************************************
* WebRtcNetEQ_RecOutNoDecode(...)
*
* Special RecOut that does not do any decoding.
*
* Input:
* - inst : NetEQ instance
*
* Output:
* - inst : Updated NetEQ instance
* - pw16_outData : Pointer to vector where output should be written
* - pw16_len : Pointer to variable where output length is returned
*
* Return value : 0 - Ok
* -1 - Error
*/
int WebRtcNetEQ_RecOutNoDecode(void *inst, WebRtc_Word16 *pw16_outData,
WebRtc_Word16 *pw16_len);
/****************************************************************************
* WebRtcNetEQ_FlushBuffers(...)
*
* Flush packet and speech buffers. Does not reset codec database or
* jitter statistics.
*
* Input:
* - inst : NetEQ instance
*
* Output:
* - inst : Updated NetEQ instance
*
* Return value : 0 - Ok
* -1 - Error
*/
int WebRtcNetEQ_FlushBuffers(void *inst);
#ifdef __cplusplus
}
#endif
#endif