/////////////////////////////////////////////////////////////////// //File: PlayMpeg4.h //Date: 2004-07-10 //Description: Interface for PlayM4.dll /////////////////////////////////////////////////////////////////// #ifndef PLAY_M4 #define PLAY_M4 #if defined( _WINDLL) #define PLAYM4_API extern "C"__declspec(dllexport) #else #define PLAYM4_API extern "C" __declspec(dllimport) #endif //Max channel numbers #define PLAYM4_MAX_SUPPORTS 500 //Wave coef range; #define MIN_WAVE_COEF -100 #define MAX_WAVE_COEF 100 //Timer type #define TIMER_1 1 //Only 16 timers for every process.Default TIMER; #define TIMER_2 2 //Not limit;But the precision less than TIMER_1; //BUFFER TYPE #define BUF_VIDEO_SRC 1 #define BUF_AUDIO_SRC 2 #define BUF_VIDEO_RENDER 3 #define BUF_AUDIO_RENDER 4 //Error code #define PLAYM4_NOERROR 0 //no error #define PLAYM4_PARA_OVER 1 //input parameter is invalid; #define PLAYM4_ORDER_ERROR 2 //The order of the function to be called is error. #define PLAYM4_TIMER_ERROR 3 //Create multimedia clock failed; #define PLAYM4_DEC_VIDEO_ERROR 4 //Decode video data failed. #define PLAYM4_DEC_AUDIO_ERROR 5 //Decode audio data failed. #define PLAYM4_ALLOC_MEMORY_ERROR 6 //Allocate memory failed. #define PLAYM4_OPEN_FILE_ERROR 7 //Open the file failed. #define PLAYM4_CREATE_OBJ_ERROR 8 //Create thread or event failed #define PLAYM4_CREATE_DDRAW_ERROR 9 //Create DirectDraw object failed. #define PLAYM4_CREATE_OFFSCREEN_ERROR 10 //failed when creating off-screen surface. #define PLAYM4_BUF_OVER 11 //buffer is overflow #define PLAYM4_CREATE_SOUND_ERROR 12 //failed when creating audio device. #define PLAYM4_SET_VOLUME_ERROR 13 //Set volume failed #define PLAYM4_SUPPORT_FILE_ONLY 14 //The function only support play file. #define PLAYM4_SUPPORT_STREAM_ONLY 15 //The function only support play stream. #define PLAYM4_SYS_NOT_SUPPORT 16 //System not support. #define PLAYM4_FILEHEADER_UNKNOWN 17 //No file header. #define PLAYM4_VERSION_INCORRECT 18 //The version of decoder and encoder is not adapted. #define PLAYM4_INIT_DECODER_ERROR 19 //Initialize decoder failed. #define PLAYM4_CHECK_FILE_ERROR 20 //The file data is unknown. #define PLAYM4_INIT_TIMER_ERROR 21 //Initialize multimedia clock failed. #define PLAYM4_BLT_ERROR 22 //Blt failed. #define PLAYM4_UPDATE_ERROR 23 //Update failed. #define PLAYM4_OPEN_FILE_ERROR_MULTI 24 //openfile error, streamtype is multi #define PLAYM4_OPEN_FILE_ERROR_VIDEO 25 //openfile error, streamtype is video #define PLAYM4_JPEG_COMPRESS_ERROR 26 //JPEG compress error #define PLAYM4_EXTRACT_NOT_SUPPORT 27 //Don't support the version of this file. #define PLAYM4_EXTRACT_DATA_ERROR 28 //extract video data failed. #define PLAYM4_SECRET_KEY_ERROR 29 //Secret key is error //add 20071218 //Max display regions. #define MAX_DISPLAY_WND 4 //Display type #define DISPLAY_NORMAL 1 #define DISPLAY_QUARTER 2 //Display buffers #define MAX_DIS_FRAMES 50 #define MIN_DIS_FRAMES 6 //Locate by #define BY_FRAMENUM 1 #define BY_FRAMETIME 2 //Source buffer #define SOURCE_BUF_MAX 1024*100000 #define SOURCE_BUF_MIN 1024*50 //Stream type #define STREAME_REALTIME 0 #define STREAME_FILE 1 //frame type #define T_AUDIO16 101 #define T_AUDIO8 100 #define T_UYVY 1 #define T_YV12 3 #define T_RGB32 7 //capability #define SUPPORT_DDRAW 1 #define SUPPORT_BLT 2 #define SUPPORT_BLTFOURCC 4 #define SUPPORT_BLTSHRINKX 8 #define SUPPORT_BLTSHRINKY 16 #define SUPPORT_BLTSTRETCHX 32 #define SUPPORT_BLTSTRETCHY 64 #define SUPPORT_SSE 128 #define SUPPORT_MMX 256 // 以下宏定义用于HIK_MEDIAINFO结构 #define FOURCC_HKMI 0x484B4D49 // "HKMI" HIK_MEDIAINFO结构标记 // 系统封装格式 #define SYSTEM_NULL 0x0 // 没有系统层,纯音频流或视频流 #define SYSTEM_HIK 0x1 // 海康文件层 #define SYSTEM_MPEG2_PS 0x2 // PS封装 #define SYSTEM_MPEG2_TS 0x3 // TS封装 #define SYSTEM_RTP 0x4 // rtp封装 // 视频编码类型 #define VIDEO_NULL 0x0 // 没有视频 #define VIDEO_H264 0x1 // 标准H.264和海康H.264都可以用这个定义 #define VIDEO_MPEG2 0x2 // 标准MPEG2 #define VIDEO_MPEG4 0x3 // 标准MPEG4 // 音频编码类型 #define AUDIO_NULL 0x0000 // 没有音频 #define AUDIO_ADPCM 0x1000 // ADPCM #define AUDIO_MPEG 0x2000 // MPEG 系列音频,解码器能自适应各种MPEG音频 // G系列音频 #define AUDIO_G711_U 0x7110 #define AUDIO_G711_A 0x7111 #define AUDIO_G722_1 0x7221 #define AUDIO_G723_1 0x7231 #define AUDIO_G726 0x7260 #define AUDIO_G729 0x7290 //Frame position typedef struct{ long nFilePos; long nFrameNum; long nFrameTime; long nErrorFrameNum; SYSTEMTIME *pErrorTime; long nErrorLostFrameNum; long nErrorFrameSize; }FRAME_POS,*PFRAME_POS; //Frame Info typedef struct{ long nWidth; long nHeight; long nStamp; long nType; long nFrameRate; DWORD dwFrameNum; }FRAME_INFO; //Frame typedef struct{ char *pDataBuf; long nSize; long nFrameNum; BOOL bIsAudio; long nReserved; }FRAME_TYPE; //Watermark Info //add by gb 080119 typedef struct{ char *pDataBuf; long nSize; long nFrameNum; BOOL bRsaRight; long nReserved; }WATERMARK_INFO; #ifndef _HIK_MEDIAINFO_FLAG_ #define _HIK_MEDIAINFO_FLAG_ typedef struct _HIK_MEDIAINFO_ // modified by gb 080425 { unsigned int media_fourcc; // "HKMI": 0x484B4D49 Hikvision Media Information unsigned short media_version; // 版本号:指本信息结构版本号,目前为0x0101,即1.01版本,01:主版本号;01:子版本号。 unsigned short device_id; // 设备ID,便于跟踪/分析 unsigned short system_format; // 系统封装层 unsigned short video_format; // 视频编码类型 unsigned short audio_format; // 音频编码类型 unsigned char audio_channels; // 通道数 unsigned char audio_bits_per_sample; // 样位率 unsigned int audio_samplesrate; // 采样率 unsigned int audio_bitrate; // 压缩音频码率,单位:bit unsigned int reserved[4]; // 保留 }HIK_MEDIAINFO; #endif ////////////////////////////////////////////////////////////////////////////// //API ////////////////////////////////////////////////////////////////////////////// ////////////////ver 1.0/////////////////////////////////////// //Initialize DirecDraw.Now invalid. PLAYM4_API BOOL __stdcall PlayM4_InitDDraw(HWND hWnd); //Release directDraw; Now invalid. PLAYM4_API BOOL __stdcall PlayM4_RealeseDDraw(); PLAYM4_API BOOL __stdcall PlayM4_OpenFile(LONG nPort,LPSTR sFileName); PLAYM4_API BOOL __stdcall PlayM4_CloseFile(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_Play(LONG nPort, HWND hWnd); PLAYM4_API BOOL __stdcall PlayM4_Stop(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_Pause(LONG nPort,DWORD nPause); PLAYM4_API BOOL __stdcall PlayM4_Fast(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_Slow(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_OneByOne(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_SetPlayPos(LONG nPort,float fRelativePos); PLAYM4_API float __stdcall PlayM4_GetPlayPos(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_SetFileEndMsg(LONG nPort,HWND hWnd,UINT nMsg); PLAYM4_API BOOL __stdcall PlayM4_SetVolume(LONG nPort,WORD nVolume); PLAYM4_API BOOL __stdcall PlayM4_StopSound(); PLAYM4_API BOOL __stdcall PlayM4_PlaySound(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_OpenStream(LONG nPort,PBYTE pFileHeadBuf,DWORD nSize,DWORD nBufPoolSize); PLAYM4_API BOOL __stdcall PlayM4_InputData(LONG nPort,PBYTE pBuf,DWORD nSize); PLAYM4_API BOOL __stdcall PlayM4_CloseStream(LONG nPort); PLAYM4_API int __stdcall PlayM4_GetCaps(); PLAYM4_API DWORD __stdcall PlayM4_GetFileTime(LONG nPort); PLAYM4_API DWORD __stdcall PlayM4_GetPlayedTime(LONG nPort); PLAYM4_API DWORD __stdcall PlayM4_GetPlayedFrames(LONG nPort); ////////////////ver 2.0 added/////////////////////////////////////// PLAYM4_API BOOL __stdcall PlayM4_SetDecCallBack(LONG nPort,void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nReserved1,long nReserved2)); PLAYM4_API BOOL __stdcall PlayM4_SetDisplayCallBack(LONG nPort,void (CALLBACK* DisplayCBFun)(long nPort,char * pBuf,long nSize,long nWidth,long nHeight,long nStamp,long nType,long nReserved)); PLAYM4_API BOOL __stdcall PLayM4_ConvertToBmpFile(char * pBuf,long nSize,long nWidth,long nHeight,long nType,char *sFileName); PLAYM4_API BOOL __stdcall PlayM4_ConvertToBmpFile(char * pBuf,long nSize,long nWidth,long nHeight,long nType,char *sFileName); PLAYM4_API BOOL __stdcall PLayM4_ConvertToBmpFile(char * pBuf,long nSize,long nWidth,long nHeight,long nType,char *sFileName); PLAYM4_API DWORD __stdcall PlayM4_GetFileTotalFrames(LONG nPort); PLAYM4_API DWORD __stdcall PlayM4_GetCurrentFrameRate(LONG nPort); PLAYM4_API DWORD __stdcall PlayM4_GetPlayedTimeEx(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_SetPlayedTimeEx(LONG nPort,DWORD nTime); PLAYM4_API DWORD __stdcall PlayM4_GetCurrentFrameNum(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_SetStreamOpenMode(LONG nPort,DWORD nMode); PLAYM4_API DWORD __stdcall PlayM4_GetFileHeadLength(); PLAYM4_API DWORD __stdcall PlayM4_GetSdkVersion(); ////////////////ver 2.2 added/////////////////////////////////////// PLAYM4_API DWORD __stdcall PlayM4_GetLastError(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_RefreshPlay(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_SetOverlayMode(LONG nPort,BOOL bOverlay,COLORREF colorKey); PLAYM4_API BOOL __stdcall PlayM4_GetPictureSize(LONG nPort,LONG *pWidth,LONG *pHeight); PLAYM4_API BOOL __stdcall PlayM4_SetPicQuality(LONG nPort,BOOL bHighQuality); PLAYM4_API BOOL __stdcall PlayM4_PlaySoundShare(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_StopSoundShare(LONG nPort); ////////////////ver 2.4 added/////////////////////////////////////// PLAYM4_API LONG __stdcall PlayM4_GetStreamOpenMode(LONG nPort); PLAYM4_API LONG __stdcall PlayM4_GetOverlayMode(LONG nPort); PLAYM4_API COLORREF __stdcall PlayM4_GetColorKey(LONG nPort); PLAYM4_API WORD __stdcall PlayM4_GetVolume(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_GetPictureQuality(LONG nPort,BOOL *bHighQuality); PLAYM4_API DWORD __stdcall PlayM4_GetSourceBufferRemain(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_ResetSourceBuffer(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_SetSourceBufCallBack(LONG nPort,DWORD nThreShold,void (CALLBACK * SourceBufCallBack)(long nPort,DWORD nBufSize,DWORD dwUser,void*pResvered),DWORD dwUser,void *pReserved); PLAYM4_API BOOL __stdcall PlayM4_ResetSourceBufFlag(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_SetDisplayBuf(LONG nPort,DWORD nNum); PLAYM4_API DWORD __stdcall PlayM4_GetDisplayBuf(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_OneByOneBack(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_SetFileRefCallBack(LONG nPort, void (__stdcall *pFileRefDone)(DWORD nPort,DWORD nUser),DWORD nUser); PLAYM4_API BOOL __stdcall PlayM4_SetCurrentFrameNum(LONG nPort,DWORD nFrameNum); PLAYM4_API BOOL __stdcall PlayM4_GetKeyFramePos(LONG nPort,DWORD nValue, DWORD nType, PFRAME_POS pFramePos); PLAYM4_API BOOL __stdcall PlayM4_GetNextKeyFramePos(LONG nPort,DWORD nValue, DWORD nType, PFRAME_POS pFramePos); #if (WINVER >= 0x0400) //Note: These funtion must be builded under win2000 or above with Microsoft Platform sdk. // You can download the sdk from "http://www.microsoft.com/msdownload/platformsdk/sdkupdate/"; PLAYM4_API BOOL __stdcall PlayM4_InitDDrawDevice(); PLAYM4_API void __stdcall PlayM4_ReleaseDDrawDevice(); PLAYM4_API DWORD __stdcall PlayM4_GetDDrawDeviceTotalNums(); PLAYM4_API BOOL __stdcall PlayM4_SetDDrawDevice(LONG nPort,DWORD nDeviceNum); //PLAYM4_API BOOL __stdcall PlayM4_GetDDrawDeviceInfo(DWORD nDeviceNum,LPSTR lpDriverDescription,DWORD nDespLen,LPSTR lpDriverName ,DWORD nNameLen,HMONITOR *hhMonitor); PLAYM4_API int __stdcall PlayM4_GetCapsEx(DWORD nDDrawDeviceNum); #endif PLAYM4_API BOOL __stdcall PlayM4_ThrowBFrameNum(LONG nPort,DWORD nNum); ////////////////ver 2.5 added/////////////////////////////////////// PLAYM4_API BOOL __stdcall PlayM4_SetDisplayType(LONG nPort,LONG nType); PLAYM4_API long __stdcall PlayM4_GetDisplayType(LONG nPort); ////////////////ver 3.0 added/////////////////////////////////////// PLAYM4_API BOOL __stdcall PlayM4_SetDecCBStream(LONG nPort,DWORD nStream); PLAYM4_API BOOL __stdcall PlayM4_SetDisplayRegion(LONG nPort,DWORD nRegionNum, RECT *pSrcRect, HWND hDestWnd, BOOL bEnable); PLAYM4_API BOOL __stdcall PlayM4_RefreshPlayEx(LONG nPort,DWORD nRegionNum); #if (WINVER >= 0x0400) //Note: The funtion must be builded under win2000 or above with Microsoft Platform sdk. // You can download the sdk from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/; PLAYM4_API BOOL __stdcall PlayM4_SetDDrawDeviceEx(LONG nPort,DWORD nRegionNum,DWORD nDeviceNum); #endif /////////////////v3.2 added///////////////////////////////////////// PLAYM4_API BOOL __stdcall PlayM4_GetRefValue(LONG nPort,BYTE *pBuffer, DWORD *pSize); PLAYM4_API BOOL __stdcall PlayM4_SetRefValue(LONG nPort,BYTE *pBuffer, DWORD nSize); PLAYM4_API BOOL __stdcall PlayM4_OpenStreamEx(LONG nPort,PBYTE pFileHeadBuf,DWORD nSize,DWORD nBufPoolSize); PLAYM4_API BOOL __stdcall PlayM4_CloseStreamEx(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_InputVideoData(LONG nPort,PBYTE pBuf,DWORD nSize); PLAYM4_API BOOL __stdcall PlayM4_InputAudioData(LONG nPort,PBYTE pBuf,DWORD nSize); PLAYM4_API BOOL __stdcall PlayM4_RigisterDrawFun(LONG nPort,void (CALLBACK* DrawFun)(long nPort,HDC hDc,LONG nUser),LONG nUser); PLAYM4_API BOOL __stdcall PlayM4_RegisterDrawFun(LONG nPort,void (CALLBACK* DrawFun)(long nPort,HDC hDc,LONG nUser),LONG nUser); //////////////////v3.4///////////////////////////////////////////////////// PLAYM4_API BOOL __stdcall PlayM4_SetTimerType(LONG nPort,DWORD nTimerType,DWORD nReserved); PLAYM4_API BOOL __stdcall PlayM4_GetTimerType(LONG nPort,DWORD *pTimerType,DWORD *pReserved); PLAYM4_API BOOL __stdcall PlayM4_ResetBuffer(LONG nPort,DWORD nBufType); PLAYM4_API DWORD __stdcall PlayM4_GetBufferValue(LONG nPort,DWORD nBufType); //////////////////V3.6///////////////////////////////////////////////////////// PLAYM4_API BOOL __stdcall PlayM4_AdjustWaveAudio(LONG nPort,LONG nCoefficient); PLAYM4_API BOOL __stdcall PlayM4_SetVerifyCallBack(LONG nPort, DWORD nBeginTime, DWORD nEndTime, void (__stdcall * funVerify)(long nPort, FRAME_POS * pFilePos, DWORD bIsVideo, DWORD nUser), DWORD nUser); PLAYM4_API BOOL __stdcall PlayM4_SetAudioCallBack(LONG nPort, void (__stdcall * funAudio)(long nPort, char * pAudioBuf, long nSize, long nStamp, long nType, long nUser), long nUser); PLAYM4_API BOOL __stdcall PlayM4_SetEncTypeChangeCallBack(LONG nPort,void(CALLBACK *funEncChange)(long nPort,long nUser),long nUser); PLAYM4_API BOOL __stdcall PlayM4_SetColor(LONG nPort, DWORD nRegionNum, int nBrightness, int nContrast, int nSaturation, int nHue); PLAYM4_API BOOL __stdcall PlayM4_GetColor(LONG nPort, DWORD nRegionNum, int *pBrightness, int *pContrast, int *pSaturation, int *pHue); PLAYM4_API BOOL __stdcall PlayM4_SetEncChangeMsg(LONG nPort,HWND hWnd,UINT nMsg); PLAYM4_API BOOL __stdcall PlayM4_GetOriginalFrameCallBack(LONG nPort, BOOL bIsChange,BOOL bNormalSpeed,long nStartFrameNum,long nStartStamp,long nFileHeader,void(CALLBACK *funGetOrignalFrame)(long nPort,FRAME_TYPE *frameType, long nUser),long nUser); PLAYM4_API BOOL __stdcall PlayM4_GetFileSpecialAttr(LONG nPort, DWORD *pTimeStamp,DWORD *pFileNum ,DWORD *pReserved); PLAYM4_API DWORD __stdcall PlayM4_GetSpecialData(LONG nPort); PLAYM4_API BOOL __stdcall PlayM4_SetCheckWatermarkCallBack(LONG nPort,void(CALLBACK* funCheckWatermark)(long nPort,WATERMARK_INFO* pWatermarkInfo,DWORD nUser),DWORD nUser); PLAYM4_API BOOL __stdcall PlayM4_SetImageSharpen(LONG nPort,DWORD nLevel); PLAYM4_API BOOL __stdcall PlayM4_GetThrowBFrameCallBack(LONG nPort,void(CALLBACK* funThrowBFrame)(long nPort,DWORD nBFrame,DWORD nUser),DWORD nUser); PLAYM4_API BOOL __stdcall PlayM4_SetDecodeFrameType(LONG nPort,DWORD nFrameType); PLAYM4_API BOOL __stdcall PlayM4_SetPlayMode(LONG nPort,BOOL bNormal); PLAYM4_API BOOL __stdcall PlayM4_SetGetUserDataCallBack(LONG nPort,void(CALLBACK* funGetUserData)(long nPort,BYTE *pUserBuf,DWORD nBufLen,DWORD nUser),DWORD nUser); PLAYM4_API BOOL __stdcall PlayM4_SetOverlayFlipMode(LONG nPort,BOOL bTrue); PLAYM4_API DWORD __stdcall PlayM4_GetAbsFrameNum(LONG nPort); //////////////////V4.7.0.0////////////////////////////////////////////////////// ////convert yuv to jpeg PLAYM4_API BOOL __stdcall PlayM4_ConvertToJpegFile(char * pBuf,long nSize,long nWidth,long nHeight,long nType,char *sFileName); PLAYM4_API BOOL __stdcall PlayM4_SetJpegQuality(long nQuality); //set deflash PLAYM4_API BOOL __stdcall PlayM4_SetDeflash(LONG nPort,BOOL bDefalsh); //////////////////V4.8.0.0///////////////////////////////////////////////////////// //check discontinuous frame number as error data? PLAYM4_API BOOL __stdcall PlayM4_CheckDiscontinuousFrameNum(LONG nPort, BOOL bCheck); //get bmp or jpeg PLAYM4_API BOOL __stdcall PlayM4_GetBMP(LONG nPort,PBYTE pBitmap,DWORD nBufSize,DWORD* pBmpSize); PLAYM4_API BOOL __stdcall PlayM4_GetJPEG(LONG nPort,PBYTE pJpeg,DWORD nBufSize,DWORD* pJpegSize); //dec call back mend PLAYM4_API BOOL __stdcall PlayM4_SetDecCallBackMend(LONG nPort,void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nUser,long nReserved2), long nUser); PLAYM4_API BOOL __stdcall PlayM4_SetSecretKey(LONG nPort, LONG lKeyType, char *pSecretKey, LONG lKeyLen); // add by gb 2007-12-23 PLAYM4_API BOOL __stdcall PlayM4_SetFileEndCallback(LONG nPort, void(CALLBACK*FileEndCallback)(long nPort, void *pUser), void *pUser); // add by gb 080131 version 4.9.0.1 PLAYM4_API BOOL __stdcall PlayM4_GetPort(LONG* nPort); PLAYM4_API BOOL __stdcall PlayM4_FreePort(LONG nPort); #endif