正文
HikPlayM4.dll
using System;
using System.Runtime.InteropServices;
using System.Drawing;
namespace HikPlayer
{
#region struct
public struct FRAME_INFO
{
/// <summary>
/// 画面宽,单位像素。如果是音频数据则为0
///
/// long nWidth;
/// </summary>
public int nWidth;
/// <summary>
/// 画面高。如果是音频数据则为0
///
/// long nHeight;
/// </summary>
public int nHeight;
/// <summary>
/// 时标信息,单位毫秒。
///
/// long nStamp;
/// </summary>
public int nStamp;
/// <summary>
/// 数据类型,T_AUDIO16,T_RGB32, T_YV12
///
/// long nType;
/// </summary>
public int nType;
/// <summary>
/// 编码时产生的图像帧率。
///
/// long nFrameRate;
/// </summary>
public int nFrameRate;
}
/// <summary>
/// typedef struct{
/// long nFilePos; //文件位置;
/// long nFrameNum; //帧序号;
/// long nFrameTime; //帧时标(ms);
/// }FRAME_POS,*PFRAME_POS;
/// </summary>
public struct PFRAME_POS
{
/// <summary>
/// 出错的文件位置
///
/// long nFilePos;
/// </summary>
public int nFilePos;
/// <summary>
/// 出错后正常的帧号
///
/// long nFrameNum;
/// </summary>
public int nFrameNum;
/// <summary>
/// 出错后正常的时间(相对此文件开始时间)
///
/// long nFrameTime;
/// </summary>
public int nFrameTime;
/// <summary>
/// 出错时的帧号
///
/// long nErrorFrameNum;
/// </summary>
public int nErrorFrameNum;
/// <summary>
/// 出错的绝对时间(设备录象文件有用)
///
/// SYSTEMTIME *pErrorTime;
/// </summary>
public DateTime pErrorTime;
/// <summary>
/// 出错时丢失的帧数
///
/// long nErrorLostFrameNum;
/// </summary>
public int nErrorLostFrameNum;
/// <summary>
/// 出错时错误的数据大小
///
/// long nErrorFrameSize;
/// </summary>
public int nErrorFrameSize;
}
public struct FRAME_TYPE
{
/// <summary>
/// 数据帧首地址
///
/// char *pDataBuf;
/// </summary>
public byte[] pDataBuf;
/// <summary>
/// 数据帧的大小
/// long nSize;
/// </summary>
public int nSize;
/// <summary>
/// 数据帧的个数
///
/// long nFrameNum;
/// </summary>
public int nFrameNum;
/// <summary>
/// 是否音频帧
///
/// BOOL bIsAudio;
/// </summary>
public bool bIsAudio;
/// <summary>
/// 保留
///
/// long nReserved;
/// </summary>
public int nReserved;
}
#endregion
#region delegate
/// <summary>
/// void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nReserved1,long nReserved2)
///
/// 注意:关于回调函数。因为vb不支持多线程,所以当回调函数是VB声明的函数时,在vc的线程中调用
/// vb的函数,会有问题。详见:Microsoft Knowledge Base Article - Q198607 “PRB: Access Violation in VB
/// Run-Time Using AddressOf ”。
/// </summary>
/// <param name="nPort">播放器通道号</param>
/// <param name="pBuf">解码后的音视频数据</param>
/// <param name="nSize">解码后的音视频数据pBuf的长度</param>
/// <param name="pFrameInfo">图像和声音信息</param>
/// <param name="nReserved1">保留参数</param>
/// <param name="nReserved2">保留参数</param>
public delegate void DecCBFun(int nPort, IntPtr pBuf, int nSize, ref FRAME_INFO pFrameInfo, int nReserved1, int nReserved2);
/// <summary>
/// void (CALLBACK* DisplayCBFun)(long nPort,char * pBuf,long nSize,long nWidth,long nHeight,long nStamp,long nType,long nReceaved));
/// </summary>
/// <param name="nPort">通道号</param>
/// <param name="pBuf">返回图像数据</param>
/// <param name="nSize">返回图像数据大小</param>
/// <param name="nWidth">画面宽,单位像素</param>
/// <param name="nHeight">画面高</param>
/// <param name="nStamp">时标信息,单位毫秒</param>
/// <param name="nType">数据类型, T_YV12,T_RGB32,T_UYVY</param>
/// <param name="nReceaved">保留</param>
public delegate void DisplayCBFun(int nPort, IntPtr pBuf, int nSize, int nWidth, int nHeight, int nStamp, int nType, int nReceaved);
/// <summary>
/// void CALLBACK SourceBufCallBack(long nPort,DWORD nBufSize, DWORD dwUser,void*pContext)
/// </summary>
/// <param name="nPort">播放器通道号</param>
/// <param name="nBufSize">缓冲区中剩余数据</param>
/// <param name="dwUser">用户数据</param>
/// <param name="pContext">保留数据</param>
public delegate void SourceBufCallBack(int nPort, ushort nBufSize, ushort dwUser, IntPtr pContext);
/// <summary>
/// void FileRefDone(DWORD nPort,DWORD nUser)
/// </summary>
/// <param name="nPort">播放器通道号</param>
/// <param name="nUser">用户数据</param>
public delegate void FileRefDone(int nPort, ushort nUser);
/// <summary>
/// void CALLBACK DrawFun(long nPort,HDC hDc,LONG nUser);
/// </summary>
/// <param name="nPort">通道号</param>
/// <param name="hDc">hDc OffScreen表面设备上下文,你可以像操作显示窗口客户区DC那样操作它。</param>
/// <param name="nUser">用户数据,就是上面输入的用户数据</param>
public delegate void DrawFun(int nPort, IntPtr hDc, int nUser);
/// <summary>
/// void __stdcall Verify(long nPort, FRAME_POS * pFilePos, DWORD bIsVideo, DWORD nUser)
/// </summary>
/// <param name="nPort">通道号</param>
/// <param name="pFilePos">文件位置</param>
/// <param name="bIsVideo">是否视频数据,1视频,0音频</param>
/// <param name="nUser">用户数据</param>
public delegate void Verify(int nPort, ref PFRAME_POS pFilePos, ushort bIsVideo, ushort nUser);
using System.Runtime.InteropServices;
using System.Drawing;
namespace HikPlayer
{
#region struct
public struct FRAME_INFO
{
/// <summary>
/// 画面宽,单位像素。如果是音频数据则为0
///
/// long nWidth;
/// </summary>
public int nWidth;
/// <summary>
/// 画面高。如果是音频数据则为0
///
/// long nHeight;
/// </summary>
public int nHeight;
/// <summary>
/// 时标信息,单位毫秒。
///
/// long nStamp;
/// </summary>
public int nStamp;
/// <summary>
/// 数据类型,T_AUDIO16,T_RGB32, T_YV12
///
/// long nType;
/// </summary>
public int nType;
/// <summary>
/// 编码时产生的图像帧率。
///
/// long nFrameRate;
/// </summary>
public int nFrameRate;
}
/// <summary>
/// typedef struct{
/// long nFilePos; //文件位置;
/// long nFrameNum; //帧序号;
/// long nFrameTime; //帧时标(ms);
/// }FRAME_POS,*PFRAME_POS;
/// </summary>
public struct PFRAME_POS
{
/// <summary>
/// 出错的文件位置
///
/// long nFilePos;
/// </summary>
public int nFilePos;
/// <summary>
/// 出错后正常的帧号
///
/// long nFrameNum;
/// </summary>
public int nFrameNum;
/// <summary>
/// 出错后正常的时间(相对此文件开始时间)
///
/// long nFrameTime;
/// </summary>
public int nFrameTime;
/// <summary>
/// 出错时的帧号
///
/// long nErrorFrameNum;
/// </summary>
public int nErrorFrameNum;
/// <summary>
/// 出错的绝对时间(设备录象文件有用)
///
/// SYSTEMTIME *pErrorTime;
/// </summary>
public DateTime pErrorTime;
/// <summary>
/// 出错时丢失的帧数
///
/// long nErrorLostFrameNum;
/// </summary>
public int nErrorLostFrameNum;
/// <summary>
/// 出错时错误的数据大小
///
/// long nErrorFrameSize;
/// </summary>
public int nErrorFrameSize;
}
public struct FRAME_TYPE
{
/// <summary>
/// 数据帧首地址
///
/// char *pDataBuf;
/// </summary>
public byte[] pDataBuf;
/// <summary>
/// 数据帧的大小
/// long nSize;
/// </summary>
public int nSize;
/// <summary>
/// 数据帧的个数
///
/// long nFrameNum;
/// </summary>
public int nFrameNum;
/// <summary>
/// 是否音频帧
///
/// BOOL bIsAudio;
/// </summary>
public bool bIsAudio;
/// <summary>
/// 保留
///
/// long nReserved;
/// </summary>
public int nReserved;
}
#endregion
#region delegate
/// <summary>
/// void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nReserved1,long nReserved2)
///
/// 注意:关于回调函数。因为vb不支持多线程,所以当回调函数是VB声明的函数时,在vc的线程中调用
/// vb的函数,会有问题。详见:Microsoft Knowledge Base Article - Q198607 “PRB: Access Violation in VB
/// Run-Time Using AddressOf ”。
/// </summary>
/// <param name="nPort">播放器通道号</param>
/// <param name="pBuf">解码后的音视频数据</param>
/// <param name="nSize">解码后的音视频数据pBuf的长度</param>
/// <param name="pFrameInfo">图像和声音信息</param>
/// <param name="nReserved1">保留参数</param>
/// <param name="nReserved2">保留参数</param>
public delegate void DecCBFun(int nPort, IntPtr pBuf, int nSize, ref FRAME_INFO pFrameInfo, int nReserved1, int nReserved2);
/// <summary>
/// void (CALLBACK* DisplayCBFun)(long nPort,char * pBuf,long nSize,long nWidth,long nHeight,long nStamp,long nType,long nReceaved));
/// </summary>
/// <param name="nPort">通道号</param>
/// <param name="pBuf">返回图像数据</param>
/// <param name="nSize">返回图像数据大小</param>
/// <param name="nWidth">画面宽,单位像素</param>
/// <param name="nHeight">画面高</param>
/// <param name="nStamp">时标信息,单位毫秒</param>
/// <param name="nType">数据类型, T_YV12,T_RGB32,T_UYVY</param>
/// <param name="nReceaved">保留</param>
public delegate void DisplayCBFun(int nPort, IntPtr pBuf, int nSize, int nWidth, int nHeight, int nStamp, int nType, int nReceaved);
/// <summary>
/// void CALLBACK SourceBufCallBack(long nPort,DWORD nBufSize, DWORD dwUser,void*pContext)
/// </summary>
/// <param name="nPort">播放器通道号</param>
/// <param name="nBufSize">缓冲区中剩余数据</param>
/// <param name="dwUser">用户数据</param>
/// <param name="pContext">保留数据</param>
public delegate void SourceBufCallBack(int nPort, ushort nBufSize, ushort dwUser, IntPtr pContext);
/// <summary>
/// void FileRefDone(DWORD nPort,DWORD nUser)
/// </summary>
/// <param name="nPort">播放器通道号</param>
/// <param name="nUser">用户数据</param>
public delegate void FileRefDone(int nPort, ushort nUser);
/// <summary>
/// void CALLBACK DrawFun(long nPort,HDC hDc,LONG nUser);
/// </summary>
/// <param name="nPort">通道号</param>
/// <param name="hDc">hDc OffScreen表面设备上下文,你可以像操作显示窗口客户区DC那样操作它。</param>
/// <param name="nUser">用户数据,就是上面输入的用户数据</param>
public delegate void DrawFun(int nPort, IntPtr hDc, int nUser);
/// <summary>
/// void __stdcall Verify(long nPort, FRAME_POS * pFilePos, DWORD bIsVideo, DWORD nUser)
/// </summary>
/// <param name="nPort">通道号</param>
/// <param name="pFilePos">文件位置</param>
/// <param name="bIsVideo">是否视频数据,1视频,0音频</param>
/// <param name="nUser">用户数据</param>
public delegate void Verify(int nPort, ref PFRAME_POS pFilePos, ushort bIsVideo, ushort nUser);
本文转自over140 51CTO博客,原文链接:http://blog.51cto.com/over140/586635,如需转载请自行联系原作者