/// 注册一个回调函数,获得当前表面的device context, 你可以在这个DC上画图(或写字),就好
/// 像在窗口的客户区DC上绘图,但这个DC不是窗口客户区的DC,而是DirectDraw里的
/// Off-Screen表面的DC。注意,如果是使用overlay表面,这个接口无效,你可以直接在窗口上绘图,只要不是透明色就不会被覆盖。
///
/// 75.BOOL __stdcall Hik_PlayM4_RigisterDrawFun(LONG nPort,void (CALLBACK* DrawFun)(long nPort,HDC hDc,LONG nUser),LONG nUser);
/// </summary>
/// <param name="nPort"></param>
/// <param name="df">回调函数句柄。 </param>
/// <param name="nUser">用户数据</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_RigisterDrawFun(int nPort, DrawFun df, int nUser);
/// <summary>
/// 获取文件索引信息,以便下次打开同一个文件时直接使用这个信息。必须在索引建成后才能获得信息。
///
/// 76.BOOL __stdcall Hik_PlayM4_GetRefValue(LONG nPort,BYTE *pBuffer, DWORD *pSize);
/// </summary>
/// <param name="nPort"></param>
/// <param name="pBuffer">索引信息</param>
/// <param name="pSize">
/// 输入/输出参数:输入pBuffer的大小,输出索引信息大小。
/// 注:可以在第一次指定pSize=0,pBuffer=NULL
/// 从pSize的返回值获得需要的缓冲区大小。然后分配足够的缓冲,再调用一次
/// </param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_GetRefValue(int nPort, IntPtr pBuffer, ref ushort pSize);
/// <summary>
/// 设置文件索引。如果已经有了文件索引信息,可以不再调用生成索引的回调函数(53.Hik_PlayM4_SetFileRefCallBack),直接输入索引信息。
/// 注:索引信息及其长度必须准确
///
/// 77.BOOL __stdcall Hik_PlayM4_SetRefValue(LONG nPort,BYTE *pBuffer, DWORD nSize);
/// </summary>
/// <param name="nPort"></param>
/// <param name="pBuffer">索引信息。</param>
/// <param name="nSize">索引信息的长度</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_SetRefValue(int nPort, IntPtr pBuffer, ushort nSize);
/// <summary>
/// 设置播放器使用的定时器;注意:必须在Open之前调用
///
/// 78.BOOL __stdcall Hik_PlayM4_SetTimerType(LONG nPort,DWORD nTimerType,DWORD nReserved);
/// </summary>
/// <param name="nPort"></param>
/// <param name="nTimerType">TIMER_1或TIMER_2,见宏定义。默认情况下0~15路使用TIMER_1,其余使用TIMER_2。</param>
/// <param name="nReserved">保留</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_SetTimerType(int nPort, ushort nTimerType, ushort nReserved);
/// <summary>
/// 获得当前通道使用的定时器。
///
/// 79.BOOL __stdcall Hik_PlayM4_GetTimerType(LONG nPort,DWORD *pTimerType,DWORD *pReserved);
/// </summary>
/// <param name="nPort"></param>
/// <param name="pTimerType">TIMER_1或TIMER_2</param>
/// <param name="pReserved">保留</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_GetTimerType(int nPort, out ushort pTimerType, out ushort pReserved);
/// <summary>
/// 清空播放器中的缓冲区。
///
/// 80.BOOL __stdcall Hik_PlayM4_ResetBuffer(LONG nPort,DWORD nBufType);
/// </summary>
/// <param name="nPort"></param>
/// <param name="nBufType">缓冲区类型</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_ResetBuffer(int nPort, int nBufType);
#endregion
/// <summary>
/// 获取播放器中的缓冲区大小(帧数或者byte)。这个接口可以帮助用户了解缓冲区中的数据,从而在网络延时方面有所估计。
///
/// 81.DWORD __stdcall Hik_PlayM4_GetBufferValue(LONG nPort,DWORD nBufType);
/// </summary>
/// <param name="nPort"></param>
/// <param name="nBufType">缓冲区类型</param>
/// <returns>根据参数不同,返回缓冲区值,源缓冲区返回byte,解码后缓冲区返回帧数。</returns>
[DllImport("HikPlayM4.dll")]
public static extern ushort Hik_PlayM4_GetBufferValue(int nPort, ushort nBufType);
/// <summary>
/// 调整WAVE波形,可以改变声音的大小。它和Hik_PlayM4_SetVolume的不同在于,它是调整声音数据,
/// 只对该路其作用,而Hik_PlayM4_SetVolume是调整声卡音量,对整个系统起作用。
/// 注意,用这个函数会破坏音质,除非想每路单独调整音量,否则请谨慎使用。
///
/// 82.BOOL __stdcall Hik_PlayM4_AdjustWaveAudio(LONG nPort,LONG nCoefficient);
/// </summary>
/// <param name="nPort"></param>
/// <param name="nCoefficient">调整的参数,范围从MIN_WAVE_COEF 到 MAX_WAVE_COEF,0是不调整。</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_AdjustWaveAudio(int nPort, int nCoefficient);
/// <summary>
/// 注册一个回调函数,校验数据是否被修改,实现水印功能。现在可以发现数据丢失情况。
/// 注意,该校验在建立文件索引的时候进行,所以必须建文件索引才能校验。在openfile之前使用。
///
/// 83.BOOL __stdcall Hik_PlayM4_SetVerifyCallBack(LONG nPort, DWORD nBeginTime, DWORD nEndTime, void (__stdcall* funVerify)(long nPort, FRAME_POS * pFilePos, DWORD bIsVideo, DWORD nUser), DWORD nUser);
/// </summary>
/// <param name="nPort"></param>
/// <param name="nBeginTime">校验开始时间,单位ms</param>
/// <param name="nEndTime">校验结束时间,单位ms</param>
/// <param name="vfy">当发现数据被修改时回调的函数</param>
/// <param name="nUser">用户数据</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_SetVerifyCallBack(int nPort, uint nBeginTime, uint nEndTime, Verify vfy, uint nUser);
/// <summary>
/// 音频帧解码后的wave数据回调
///
/// 84.BOOL __stdcall Hik_PlayM4_SetAudioCallBack(LONG nPort, void (__stdcall * funAudio)(long nPort, char * pAudioBuf, long nSize, long nStamp, long nType, long nUser), long nUser);
/// </summary>
/// <param name="nPort"></param>
/// <param name="nBufType"></param>
/// <param name="ado">音频回调函数</param>
/// <param name="nUser">用户自定义数据</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_SetAudioCallBack(int nPort, Audio ado, int nUser);
/// <summary>
/// 解码时图象格式发生改变通知用户的回调函数;在打开文件前使用
///
/// 85. BOOL __stdcall Hik_PlayM4_SetEncTypeChangeCallBack(LONG nPort,void(CALLBACK *funEncChange)(long nPort,long nUser),long nUser);
/// </summary>
/// <param name="nPort"></param>
/// <param name="ec">回调函数</param>
/// <param name="nUser">用户自定义数据</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_SetEncTypeChangeCallBack(int nPort, EncChange ec, int nUser);
/// <summary>
/// 设置图象的视频参数,即时起作用
/// 注意: 如果全部为默认值将不进行颜色调节
///
/// 86.BOOL __stdcall Hik_PlayM4_SetColor(LONG nPort, DWORD nRegionNum, int nBrightness, int nContrast, int nSaturation, int nHue);
/// </summary>
/// <param name="nPort"></param>
/// <param name="nRegionNum">显示区域,参考Hik_PlayM4_SetDisplayRegion;如果只有一个显示区域(通常情况)设为0</param>
/// <param name="nBrightness">亮度,默认64; 范围0-128</param>
/// <param name="nContrast">对比度,默认64; 范围0-128</param>
/// <param name="nSaturation">饱和度,默认64; 范围0-128</param>
/// <param name="nHue">色调,默认64; 范围0-128</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_SetColor(int nPort, ushort nRegionNum, int nBrightness, int nContrast, int nSaturation, int nHue);
/// <summary>
/// 相应的获得颜色值,参数同上
///
/// 87.BOOL __stdcall Hik_PlayM4_GetColor(LONG nPort, DWORD nRegionNum, int *pBrightness, int *pContrast, int *pSaturation, int *pHue);
/// </summary>
/// <param name="nPort"></param>
/// <param name="nRegionNum">显示区域,参考Hik_PlayM4_SetDisplayRegion;如果只有一个显示区域(通常情况)设为0</param>
/// <param name="nBrightness">亮度,默认64; 范围0-128</param>
/// <param name="nContrast">对比度,默认64; 范围0-128</param>
/// <param name="nSaturation">饱和度,默认64; 范围0-128</param>
/// <param name="nHue">色调,默认64; 范围0-128</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_GetColor(int nPort, ushort nRegionNum, out int pBrightness, out int pContrast, out int pSaturation, out int pHue);
/// <summary>
/// 设置解码时编码格式发生改变时要发送的消息。
///
/// 88.BOOL __stdcall Hik_PlayM4_SetEncChangeMsg(LONG nPort,HWND hWnd,UINT nMsg)
/// </summary>
/// <param name="nPort"></param>
/// <param name="hWnd">消息发送的窗口。</param>
/// <param name="nMsg">用户输入的消息,当设置解码时编码格式发生改变时要发送此定义的消息。消息函数中的wParam参数值是返回nPort的值。 </param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_SetEncChangeMsg(int nPort, IntPtr hWnd, uint nMsg);
/// <summary>
/// 创建得到原始帧数据的回调函数,可以改变每帧的时标和帧号,在文件打开之后调用。用于将两个文件拼接在一起。
///
/// 89. BOOL _stdcall Hik_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)
/// </summary>
/// <param name="nPort"></param>
/// <param name="bIsChange">是否要改变每帧的参数</param>
/// <param name="bNormalSpeed">是否要以正常速度得到原始帧</param>
/// <param name="nStartFrameNum">如要改变原始帧帧号,则是此文件的开始帧号</param>
/// <param name="nStartStamp">如要改变原始帧时标,则是此文件的开始时标</param>
/// <param name="nFileHeader">输出参数:文件头版本信息,如果版本不匹配,返回不成功</param>
/// <param name="gof"></param>
/// <param name="nUser">用户数据</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_GetOriginalFrameCallBack(int nPort, bool bIsChange, bool bNormalSpeed, int nStartFrameNum, int nStartStamp, out int nFileHeader, GetOrignalFrame gof, int nUser);
/// <summary>
/// 得到文件最后的时标和帧号,在文件打开之后调用。与上个文件一起使用,用于文件拼接。
///
/// 90.BOOL _stdcall Hik_PlayM4_GetFileSpecialAttr(LONG nPort, DWORD *pTimeStamp,DWORD *pFileNum ,DWORD *nFileHeader)
/// </summary>
/// <param name="nPort"></param>
/// <param name="pTimeStamp">文件结束时标</param>
/// <param name="pFileNum">文件结束帧号</param>
/// <param name="nFileHeader">文件头信息</param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_GetFileSpecialAttr(int nPort, ref ushort pTimeStamp, ref ushort pFileNum, ref ushort nFileHeader);
#region 以下为4.7版(build0711)新增接口
/// <summary>
/// 抓图存为JPEG文件, 该函数可在显示回调函数中使用, 用法参见Hik_PlayM4_ConvertToBmpFile();
///
/// 91. BOOL _stdcall Hik_PlayM4_ConvertToJpegFile(char *pBuf, long nSize, long nWidth, int nHeight, long nType, char *sFileName)
/// </summary>
/// <param name="pBuf">图像数据缓存</param>
/// <param name="nSize">图像大小</param>
/// <param name="nWidth">图像宽</param>
/// <param name="nHeight">图像高</param>
/// <param name="nType">图像类型YV12</param>
/// <param name="sFileName">保存jpeg文件路径 </param>
/// <returns>
/// TRUE: 保存Jpeg文件成功
/// FALSE: 失败, 可调用Hik_PlayM4_GetLastError()获取错误类型
/// </returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_ConvertToJpegFile(byte[] pBuf, int nSize, int nWidth, int nHeight, int nType, string sFileName);
/// <summary>
/// 设置抓取的jpeg图像质量, 设置范围0~100, 建议使用75~90, 若不调用该函数, 则采用默认图像质量, 目前默认为80
///
/// 92. BOOL _stdcall Hik_PlayM4_SetJpegQuality(long nQuality)
/// </summary>
/// <param name="nQuality">
/// 质量参数, 范围0~100
/// 0: 图像质量最差, 但抓取的图像大小最小
/// 100: 图像质量最好, 但抓取的图像大小最大
/// </param>
/// <returns>
/// TRUE: 设置成功, 采用设置的质量
/// FALSE: 设置失败, 采用默认值, 可调用Hik_PlayM4_GetLastError()获取错误类型
/// </returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_SetJpegQuality(int nQuality);
/// <summary>
/// 设置是否去闪烁功能, 原先在静止图像区域有噪声情况下, 图像会产生闪烁现象(或称刷新或跳动),
/// 启动去闪烁功能后,闪烁效果可消除或减轻,同时也能降低噪声
///
/// 93. BOOL _stdcall Hik_PlayM4_SetDeflash(LONG nPort,BOOL bDeflash)
/// </summary>
/// <param name="nPort">通道号</param>
/// <param name="bDeflash"> TRUE表示设置去闪烁,FALSE表示不设置,默认为不设置</param>
/// <returns>TRUE: 设置成功;FALSE: 设置失败, 采用默认值, 可调用Hik_PlayM4_GetLastError()获取错误类型 </returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_SetDeflash(int nPort, bool bDeflash);
#endregion
#region 以下为4.8版(build0813)新增接口
/// <summary>
/// 帧号不连续时是否跳下一个I帧
///
/// 94. BOOL __stdcall Hik_PlayM4_CheckDiscontinuousFrameNum(LONG nPort, BOOL bCheck)
/// </summary>
/// <param name="nPort">通道号</param>
/// <param name="bCheck">帧号不连续时是否跳下一个I帧</param>
/// <returns>TRUE: 设置成功 FALSE: 设置失败 </returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_CheckDiscontinuousFrameNum(int nPort, bool bCheck);
/// <summary>
/// 抓取bmp图像
///
/// 95. BOOL __stdcall Hik_PlayM4_GetBMP(LONG nPort,PBYTE pBitmap,DWORD nBufSize,DWORD* pBmpSize);
/// </summary>
/// <param name="nPort">通道号</param>
/// <param name="pBitmap">
/// 存放BMP图像数据地址,由用户分配,不得小于bmp图像大小
/// sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + w * h * 4, 其中w和h分别为图像宽高。
/// </param>
/// <param name="nBufSize">申请的缓冲区大小</param>
/// <param name="pBmpSize">获取到的实际bmp图像大小</param>
/// <returns>TRUE: 获取成功 FALSE: 获取失败 </returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_GetBMP(int nPort, string pBitmap, ushort nBufSize, out ushort pBmpSize);
/// <summary>
/// 抓取jpeg图像
///
/// 96. BOOL __stdcall Hik_PlayM4_GetJPEG(LONG nPort,PBYTE pJpeg,DWORD nBufSize,DWORD* pJpegSize);
/// </summary>
/// <param name="nPort">通道号</param>
/// <param name="pJpeg">存放JEPG图像数据地址,由用户分配,不得小于JPEG图像大小,建议大小w * h * 3/2, 其中w和h分别为图像宽高。</param>
/// <param name="nBufSize">申请的缓冲区大小。</param>
/// <param name="pJpegSize">获取到的实际bmp图像大小。</param>
/// <returns>TRUE: 获取成功 FALSE: 获取失败</returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_GetJPEG(int nPort, string pJpeg, ushort nBufSize, out ushort pJpegSize);
/// <summary>
/// 设置回调函数,替换播放器中的显示部分,有用户自己控制显示,该函数在Hik_PlayM4_Play之前调用,
/// 在Hik_PlayM4_Stop时自动失效,下次调用Hik_PlayM4_Play之前需要重新设置。
/// 注意解码部分不控制速度,只要用户从回调函数中返回,解码器就会解码下一部分数据。这个功能
/// 的使用需要用户对视频显示和声音播放有足够的了解,否则请慎重使用,有关知识请参阅directx开发包。
///
/// 97. BOOL __stdcall Hik_PlayM4_SetDecCallBackMend(LONG nPort,void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nUser, long nReserved2), long nUser);
/// </summary>
/// <param name="nPort"></param>
/// <param name="dcbf">DecCBFun回调函数指针,不能为NULL</param>
/// <param name="nUser"></param>
/// <returns></returns>
[DllImport("HikPlayM4.dll")]
public static extern bool Hik_PlayM4_SetDecCallBackMend(int nPort, DecCBFun dcbf, int nUser);
#endregion
}
}
本文转自over140 51CTO博客,原文链接:http://blog.51cto.com/over140/586649,如需转载请自行联系原作者