/** @File AUDIOINTERCOM.H * * @Note HangZhou Hikvision System Technology Co., Ltd. All Right Reserved. * * @Brief 音频对讲库 * * @Author zhangxinyf3 张欣 * * @Date 2012/4/9 * * @Remark */ #ifndef _AUDIO_INTERCOM_H_ #define _AUDIO_INTERCOM_H_ #ifdef WIN32 #if defined(_WINDLL) #define AUDIOCOM_API __declspec(dllexport) #else #define AUDIOCOM_API __declspec(dllimport) #endif #else #ifndef __stdcall #define __stdcall #endif #ifndef AUDIOCOM_API #define AUDIOCOM_API #endif #endif ///<错误码 #define ERROR_NO 1 ///<无错误 #define ERROR_ALLOC_MEMORY 2 ///<内存分配出错 #define ERROR_PARAMETER 3 ///<调用参数出错 #define ERROR_CALL_ORDER 4 ///<调用顺序出错 #define ERROR_FIND_DEVICE 5 ///<不能找到声卡设备 #define ERROR_OPEN_DEVICE 6 ///<不能打开声卡设备 #define ERROR_NO_CONTEXT 7 ///<设备音频引擎上下文出错 #define ERROR_NO_WAVEFILE 8 /// {1, 16, 16000, 64000, AUDIO_TYPE_MPEG2} AUDIO_TYPE_MP3_S16K <——> {1, 16, 16000, 64000, AUDIO_TYPE_MP3} AUDIO_TYPE_G726_S8K <——> {1, 16, 8000, 16000, AUDIO_TYPE_G726} AUDIO_TYPE_G722_S16K <——> {1, 16, 16000, 16000, AUDIO_TYPE_G722} AUDIO_TYPE_G711U_S8K <——> {1, 16, 8000, 64000, AUDIO_TYPE_G711U} AUDIO_TYPE_G711A_S8K <——> {1, 16, 8000, 64000, AUDIO_TYPE_G711A} AUDIO_TYPE_PCM_S32K <——> {1, 16, 32000, xxxxx, AUDIO_TYPE_PCM} AUDIO_TYPE_PCM_S8K <——> {1, 16, 8000, xxxxx, AUDIO_TYPE_PCM} AUDIO_TYPE_AAC_S16K <——> {1, 16, 16000, 32000, AUDIO_TYPE_AAC} AUDIO_TYPE_AAC_S32K <——> {1, 16, 32000, 32000, AUDIO_TYPE_AAC} *****************************************************************/ ///<回调函数输出数据信息结构体 typedef struct _OUTPUT_DATA_INFO_EX_ { unsigned char* pData; unsigned int dwDataLen; AudioEncodeTypeEx enDataTypeEx; }OutputDataInfoEx; typedef struct _OUTPUT_DATA_INFO_ { unsigned char* pData; unsigned int dwDataLen; AudioEncodeType enDataType; }OutputDataInfo; typedef void (__stdcall* OutputDataCallBack)(OutputDataInfo* pstDataInfo,void* pUser); typedef void (__stdcall* OutputDataCallBackEx)(OutputDataInfoEx* pstDataInfo,void* pUser); #ifdef __cplusplus extern "C" { #endif /**********************************获取声卡信息*******************************************************************************/ ///<获取声卡数量 AUDIOCOM_API int __stdcall AUDIOCOM_GetSoundCardNum(unsigned int* pdwDeviceNum); ///<获取指定声卡的设备信息 AUDIOCOM_API int __stdcall AUDIOCOM_GetOneSoundCardInfo(unsigned int dwDeviceIndex, SoundCardInfo* pstDeviceInfo); ///<获取采集设备的数量 AUDIOCOM_API int __stdcall AUDIOCOM_GetCaptureDeviceNum(unsigned int* pCaptureDeviceNum); ///<获取采集设备的名称 AUDIOCOM_API int __stdcall AUDIOCOM_GetOneCaptureDeviceName(unsigned int dwCaptureDeviceIndex, char* pCaptureDeviceName); ///<获取播放设备的数量 AUDIOCOM_API int __stdcall AUDIOCOM_GetPlayDeviceNum(unsigned int* pPlayDeviceNum); ///<获取播放设备的名称 AUDIOCOM_API int __stdcall AUDIOCOM_GetOnePlayDeviceName(unsigned int dwPlayDeviceIndex, char* pPlayDeviceName); /**********************************采集编码模块接口***************************************************************************/ ///<根据指定设备名称,创建采集编码模块端口号 AUDIOCOM_API int __stdcall AUDIOCOM_CreateCaptureHandle(int* pnCapturePort, const char* pDeviceName); ///<根据指定采集设备名称,创建采集编码模块端口号 AUDIOCOM_API int __stdcall AUDIOCOM_CreateCaptureHandleEx(int* pnCapturePort, const char* pCapDeviceName); ///<注册回调函数,可以指定不同格式的编码数据,并通过回调函数输出(旧接口) AUDIOCOM_API int __stdcall AUDIOCOM_RegisterOutputDataCallBack(int nCapturePort, AudioEncodeType enDataType, OutputDataCallBack pfnOutputDataCallBack, void* pUser); ///<注册回调函数,可以指定不同格式的编码数据,并通过回调函数输出 AUDIOCOM_API int __stdcall AUDIOCOM_RegisterOutputDataCallBackEx(int nCapturePort, AudioParam *pstAudioParam, OutputDataCallBackEx pfnOutputDataCallBack, void* pUser); ///<开始采集编码 AUDIOCOM_API int __stdcall AUDIOCOM_StartCapture(int nCapturePort); ///<停止采集编码 AUDIOCOM_API int __stdcall AUDIOCOM_StopCapture(int nCapturePort); ///<注册采集编码前回调函数(旧接口) AUDIOCOM_API int __stdcall AUDIOCOM_RegisterCaptureDataCallBack(int nCapturePort, OutputDataCallBack pfnCaptureDataCallBack, void* pUser); ///<注册采集编码前回调函数 AUDIOCOM_API int __stdcall AUDIOCOM_RegisterCaptureDataCallBackEx(int nCapturePort, OutputDataCallBackEx pfnCaptureDataCallBack, void* pUser); ///<释放采集编码模块端口号 AUDIOCOM_API int __stdcall AUDIOCOM_ReleaseCaptureHandle(int nCapturePort); ///<释放采集编码模块端口号 AUDIOCOM_API int __stdcall AUDIOCOM_ReleaseCaptureHandleEx(int nCapturePort); /**********************************播放解码模块接口**************************************************************************/ ///<根据指定设备名称,创建播放解码模块端口号 AUDIOCOM_API int __stdcall AUDIOCOM_CreatePlayHandle(int* pnPlayPort, const char* pDeviceName); ///<根据指定设备名称,创建播放解码模块端口号 AUDIOCOM_API int __stdcall AUDIOCOM_CreatePlayHandleEx(int* pnPlayPort, const char* pDeviceName); /* ///<指定文件路径,打开WAV文件 AUDIOCOM_API int __stdcall AUDIOCOM_OpenWaveFile(int nPlayPort, const char* pFilePath); */ ///<指定流类型,打开流 AUDIOCOM_API int __stdcall AUDIOCOM_OpenStream(int nPlayPort, AudioEncodeType enDataType); ///<指定流类型,打开流 AUDIOCOM_API int __stdcall AUDIOCOM_OpenStreamEx(int nPlayPort, AudioParam *pstAudioParam); ///<输入流数据 AUDIOCOM_API int __stdcall AUDIOCOM_InputStreamData(int nPlayPort, unsigned char* pData, unsigned int dwDataLen); ///<开始解码播放 AUDIOCOM_API int __stdcall AUDIOCOM_StartPlay(int nPlayPort); ///<停止解码播放 AUDIOCOM_API int __stdcall AUDIOCOM_StopPlay(int nPlayPort); ///<解码后数据回调(旧接口) AUDIOCOM_API int __stdcall AUDIOCOM_RegisterDecodeDataCallBack(int nPlayPort, OutputDataCallBack pfnDecodeDataCallBack, void* pUser); ///<解码后数据回调 AUDIOCOM_API int __stdcall AUDIOCOM_RegisterDecodeDataCallBackEx(int nPlayPort, OutputDataCallBackEx pfnDecodeDataCallBack, void* pUser); ///<设置音量 AUDIOCOM_API int __stdcall AUDIOCOM_SetVolume(int nPlayPort, float fVolume); ///<获取音量 AUDIOCOM_API int __stdcall AUDIOCOM_GetVolume(int nPlayPort, float* fVolume); ///<释放播放解码模块端口号 AUDIOCOM_API int __stdcall AUDIOCOM_ReleasePlayHandle(int nPlayPort); ///<释放声卡资源 //AUDIOCOM_API int __stdcall AUDIOCOM_Release /******************************************************************************************************************************/ ///<获取错误信息 AUDIOCOM_API int __stdcall AUDIOCOM_GetLastError(int nPort); ///<获取版本号 AUDIOCOM_API unsigned int __stdcall AUDIOCOM_GetVersion(); ///<设定采集状态 AUDIOCOM_API int __stdcall AUDIOCOM_SetCaptureStatus(int nCapturePort, bool isPlay); ///<获取剩余播放缓冲 AUDIOCOM_API int __stdcall AUDIOCOM_GetPlayBufferRemian(int nPlayPort, int *nBufferSize); ///<设定播放状态 AUDIOCOM_API int __stdcall AUDIOCOM_SetPlayStatus(int nPlayPort, bool isPlay); #ifdef __cplusplus } #endif #endif//_AUDIO_INTERCOM_H_