using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace TSDome
{
    class PlaySDK
    {
        public PlaySDK()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        public const int PLAY_SDK_MAX_PORT = 100;			//< 最大播放通道数 Maximum number of playback channels

        //波形调整因子最大最小值宏定义Waveform adjustment factor maximum and minimum macro definition
        public const int PLAY_SDK_MIN_WAVE_COEF = -100;			//< 最小波形调整因子 Minimum waveform adjustment factor
        public const int PLAY_SDK_MAX_WAVE_COEF = 100;			//< 最大波形调整因子 Maximum waveform adjustment factor

        //定时器类型宏定义 Timer type macro definition
        public const int PLAY_SDK_TIMER_1 = 1;				//< 默认定时器, 精确定时，但一个进程中只有16个 Default timer, precise timing, but only 16 in a process
        public const int PLAY_SDK_TIMER_2 = 2;				//< 不精确定时、个数不限制 Inaccurate timing, unlimited number

        //缓冲类型宏定义 Buffer type macro definition
        public const int PLAY_SDK_BUF_VIDEO_SRC = 1;				//< 视频源缓冲 Video source buffer        
        public const int PLAY_SDK_BUF_AUDIO_SRC = 2;				//< 音频源缓冲 Audio source buffer
        public const int PLAY_SDK_BUF_VIDEO_RENDER = 3;				//< 解码后视频数据缓冲 Decoded video data buffer
        public const int PLAY_SDK_BUF_AUDIO_RENDER = 4;				//< 解码后音频数据缓冲 Decoded audio data buffer

        //错误类型宏定义 Error type macro definition
        public const int PLAY_SDK_NOERROR = 0;          	//< 没有错误; No errors;
        public const int PLAY_SDK_PARA_OVER = 1;           	//< 输入参数非法; The input parameters are illegal;
        public const int PLAY_SDK_ORDER_ERROR = 2;          	//< 调用顺序出错; Incorrect call sequence;
        public const int PLAY_SDK_TIMER_ERROR = 3;          	//< 多媒体时钟设置失败; Multimedia clock setting failed;
        public const int PLAY_SDK_DEC_VIDEO_ERROR = 4;	        	//< 视频解码失败; Video decoding failed;
        public const int PLAY_SDK_DEC_AUDIO_ERROR = 5;	        	//< 音频解码失败; Audio decoding failed;
        public const int PLAY_SDK_ALLOC_MEMORY_ERROR = 6;		    	//< 分配内存失败 ; Failed to allocate memory
        public const int PLAY_SDK_OPEN_FILE_ERROR = 7;				//< 文件操作失败; File operation failed
        public const int PLAY_SDK_CREATE_OBJ_ERROR = 8;	        	//< 创建线程事件等失败;Failed to create a thread event, etc.
        public const int PLAY_SDK_CREATE_DDRAW_ERROR = 9;		    	//< 创建directDraw失败;Failed to create directDraw;
        public const int PLAY_SDK_CREATE_OFFSCREEN_ERROR = 10;		    	//< 创建后端缓存失败; Failed to create backend cache;
        public const int PLAY_SDK_BUF_OVER = 11;	        	//< 缓冲区满, 输入流失败; The buffer is full and the input stream fails.
        public const int PLAY_SDK_CREATE_SOUND_ERROR = 12;		    	//< 创建音频设备失败; Failed to create an audio device;
        public const int PLAY_SDK_SET_VOLUME_ERROR = 13;	        	//< 设置音量失败; Failed to set the volume;
        public const int PLAY_SDK_SUPPORT_FILE_ONLY = 14;		    	//< 只能在播放文件时才能使用此接口; This interface can only be used when playing a file;
        public const int PLAY_SDK_SUPPORT_STREAM_ONLY = 15;		    	//< 只能在播放流时才能使用此接口;This interface can only be used when playing a stream
        public const int PLAY_SDK_SYS_NOT_SUPPORT = 16;		    	//< 系统不支持, 解码器只能工作在Pentium 3以上;The system does not support, the decoder can only work on Pentium 3 or above;
        public const int PLAY_SDK_FILEHEADER_UNKNOWN = 17;		    	//< 没有文件头; No file headers;
        public const int PLAY_SDK_VERSION_INCORRECT = 18;	        	//< 解码器和编码器版本不对应; The decoder and encoder versions do not correspond;
        public const int PLAY_SDK_INIT_DECODER_ERROR = 19;		    	//< 初始化解码器失败; Initialization of the decoder failed;
        public const int PLAY_SDK_CHECK_FILE_ERROR = 20;		    	//< 文件太短或码流无法识别; The file is too short or the stream is unrecognizable;
        public const int PLAY_SDK_INIT_TIMER_ERROR = 21;				//< 初始化多媒体时钟失败; Failed to initialize the multimedia clock;
        public const int PLAY_SDK_BLT_ERROR = 22;				//< 位拷贝失败; Bit copy failed;
        public const int PLAY_SDK_UPDATE_ERROR = 23;				//< 显示overlay失败; Display overlay failed;

        public const int PLAY_SDK_MAX_DISPLAY_WND = 4;				//< 同时最多打开4个区域显示窗口;Open up to 4 area display windows at the same time;

        //显示类型宏定义 Display type macro definition
        public const int PLAY_SDK_DISPLAY_NORMAL = 1;				//< 以正常分辨率显示;Displayed at normal resolution;
        public const int PLAY_SDK_DISPLAY_QUARTER = 2;				//< 以1/4分辨率显示;Displayed at 1/4 resolution;

        //解码缓冲帧数最大最小值宏定义 Decoding buffer frame number maximum and minimum macro definition
        public const int PLAY_SDK_MAX_DIS_FRAMES = 50;				//< 最大解码缓冲帧数 Maximum decoding buffer number
        public const int PLAY_SDK_MIN_DIS_FRAMES = 6;				//< 最小解码缓冲帧数 Minimum decoding buffer number

        //定位类型宏定义 Positioning type macro definition
        public const int PLAY_SDK_BY_FRAMENUM = 1;				//< 按帧号定位 Position by frame number
        public const int PLAY_SDK_BY_FRAMETIME = 2;				//< 按时间定位 Position by time

        //数据流原始缓冲最大最小值宏定义 Data stream raw buffer maximum and minimum macro definition
        public const int PLAY_SDK_SOURCE_BUF_MAX = (1024 * 100000); //< 最大原始缓冲 Maximum raw buffer
        public const int PLAY_SDK_SOURCE_BUF_MIN = (1024 * 50);		//< 最小原始缓冲 Minimum raw buffer

        //数据流播放模式宏定义 tream play mode macro definition
        public const int PLAY_SDK_STREAME_REALTIME = 0;				//< 数据流模式 会尽量保正实时性, 防止数据阻塞; 而且数据检查严格; The data flow mode will try to keep the real-time performance as much as possible to prevent data blocking; and the data check is strict;
        public const int PLAY_SDK_STREAME_FILE = 1;				//< 文件模式 则不然.(按帧率播放) File mode is not. (play by frame rate)

        //解码音频回调帧类型宏定义 Decode audio callback frame type macro definition
        public const int PLAY_SDK_AUDIO16 = 101;				//< 采样率16khz单声道, 每个采样点16 位表示 Sample rate 16khz mono, 16 bits per sample point
        public const int PLAY_SDK_AUDIO8 = 100;				//< 采样率8khz,单声道,每个采样点8位表示 Sampling rate 8khz, mono, 8 bits per sample point

        public const int PLAY_SDK_UYVY = 1;				//< uyvy 格式“U0-Y0-V0-Y1-U2-Y2-V2-Y3….”,第一个像素位于图像左上角;Uyvy format "U0-Y0-V0-Y1-U2-Y2-V2-Y3....", the first pixel is located in the upper left corner of the image;
        public const int PLAY_SDK_YV12 = 3;				//< yv12 格式。排列顺序“Y0-Y1-……”,“V0-V1….”,“U0-U1-…..”;Yv12 format. Arrange the order "Y0-Y1-...", "V0-V1....", "U0-U1-.....";
        public const int PLAY_SDK_RGB32 = 7;				//< 每个像素4 个字节,排列方式与位图相似,“B-G-R-0 …”,第一个像素位于图像左下角;4 bytes per pixel, arranged in a similar way to the bitmap, "B-G-R-0 ...", the first pixel is located in the lower left corner of the image;

        //系统支持的功能宏定义，用于按位表示系统功能 Function macro definitions supported by the system for representing system functions in bits
        public const int PLAY_SDK_SUPPORT_DDRAW = 0x0001;			//< 支持DIRECTDRAW；如果不支持，则播放器不能工作。DIRECTDRAW is supported; if it is not supported, the player will not work.
        public const int PLAY_SDK_SUPPORT_BLT = 0x0002;			//< 显卡支持BLT操作；如果不支持，则播放器不能工作 The graphics card supports BLT operation; if it is not supported, the player will not work.
        public const int PLAY_SDK_SUPPORT_BLTFOURCC = 0x0004;			//< 显卡BLT支持颜色转换；Graphics card BLT supports color conversion;
        public const int PLAY_SDK_SUPPORT_BLTSHRINKX = 0x0008;			//< 显卡BLT支持X轴缩小；The graphics card BLT supports X-axis reduction;
        public const int PLAY_SDK_SUPPORT_BLTSHRINKY = 0x0010;			//< 显卡BLT支持Y轴缩小； The graphics card BLT supports X-axis reduction;
        public const int PLAY_SDK_SUPPORT_BLTSTRETCHX = 0x0020;			//< 显卡BLT支持X轴放大；The graphics card BLT supports X-axis amplification;
        public const int PLAY_SDK_SUPPORT_BLTSTRETCHY = 0x0040;			//< 显卡BLT支持Y轴放大；The graphics card BLT supports Y-axis amplification;
        public const int PLAY_SDK_SUPPORT_SSE = 0x0080;			//< CPU支持SSE指令,Intel Pentium3以上支持SSE指令；The CPU supports SSE instructions, and Intel Pentium 3 supports SSE instructions.
        public const int PLAY_SDK_SUPPORT_MMX = 0x0100;			//< CPU支持MMX指令集。The CPU supports the MMX instruction set.

        //查询信息命令宏定义 Query information command macro definition
        public const int PLAY_SDK_QUERYINFO_CMD_GETTIME = 1;
        public const int PLAY_SDK_QUERYINFO_CMD_GETFILERATE = 2;

        //文件类型 ile type
        enum PLAY_SDK_MEDIA_FILE_TYPE
        {
            PLAY_SDK_MEDIA_FILE_NONE = 0,			//< 无文件 No file
            PLAY_SDK_MEDIA_FILE_H264 = 1,			//< H264文件 H264 file
            PLAY_SDK_MEDIA_FILE_AVI = 2,			//< AVI文件 AVI file
            PLAY_SDK_MEDIA_FILE_RMVB = 3,			//< RMVB文件 RMVB file
            PLAY_SDK_MEDIA_FILE_MPG4 = 4,			//< MP4文件 MP4file
            PLAY_SDK_MEDIA_FILE_NUM
        }
        struct SYSTEMTIME
        {
            int wYear;
            int wMonth;
            int wDayOfWeek;
            int wDay;
            int wHour;
            int wMinute;
            int wSecond;
            int wMilliseconds;
        } ;
        //出差帧信息 Travel frame information
        public struct PLAY_SDK_FRAME_POS
        {
            int nFilePos;							//< 指定帧在文件中的偏移位置 Specify the offset position of the frame in the file
            int nFrameNum;							//< 帧序号 Frame number
            int nFrameTime;							//< 帧时间 Frame time
            int nErrorFrameNum;						//< 错误帧号 Error frame number
            SYSTEMTIME pErrorTime;							//< 错误帧时间 Error frame time
            int nErrorLostFrameNum;					//< 错误帧帧号 Error frame number
            int nErrorFrameSize;					//< 错误帧大小 Error frame size
        };

        //播放帧信息 Play frame information
        public struct PLAY_SDK_FRAME_INFO
        {
            int nWidth;								//< 画面宽，单位像素。如果是音频数据则为0； The picture is wide, in pixels. 0 if it is audio data;
            int nHeight;							//< 画面高。如果是音频数据则为0；The picture is high. 0 if it is audio data;
            int nStamp;								//< 时标信息，单位毫秒。Time stamp information, in ms
            int nType;								//< 数据类型，PLAY_SDK_AUDIO16，PLAY_SDK_RGB32， PLAY_SDK_YV12，详见宏定义说明。Data type, PLAY_SDK_AUDIO16, PLAY_SDK_RGB32, PLAY_SDK_YV12, see macro definition description
            int nFrameRate;							//< 编码时产生的图像帧率。Image frame rate generated during encoding
        };

        //帧类型 Frame type
        struct PLAY_SDK_FRAME_TYPE
        {
            string pDataBuf;							//< 帧数据 Frame data
            int nSize;								//< 帧大小 Frame size
            int nFrameNum;							//< 帧序号 Frame number 
            int bIsAudio;							//< 是否音频帧 Whether audio frame
            int nReserved;							//< 保留字 Reserved word
        };

        //码流类型 Code stream type
        enum PLAY_SDK_ENCODE_TYPE
        {
            StreamEmpty = 0,			//< 空码流 Empty stream
            StreamH264 = 2,			//< H264码流 H264 stream
            StreamJpeg = 3,			//< JPEG码流 JPEG stream
            StreamGeneral = 4,			//< 普通码流 Normal stream
            StreamPCM8 = 7,			//< PCM8码流 PCM8 code stream
            StreamStd = 8				//< 标准码流 Standard stream
        };

        //图像帧类型 Image frame type
        enum PLAY_SDK_VIDEO_FRAME_TYPE
        {
            FrameUnknown = 0,			//< 位置类型 Location type
            FrameVideo = 1,			//< 视频帧 Video frame
            FrameAudio = 2,			//< 音频帧 Audio frame
	        FrameData						= 3				//< 
        };

        //图像帧子类型 Image frame subtype
        enum PLAY_SDK_VIDEO_FRAME_SUB_TYPE
        {
	        FrameSubIFrame					= 0,			//< 
	        FrameSubPFrame					= 1,			//<
	        FrameSubBFrame					= 2,			//< 
        	FrameSubSFrame					= 3,			//< 
        	FrameSubDataText				= 5,			//< 
	        FrameSubDataIntl				= 6				//< 
        };

        //视频帧信息 Video frame information
        public struct PLAY_SDK_VIDEO_FRAME_INFO
        {
            string pHeader;						//< 帧数据缓冲起始地址 Frame data buffer start address
	        string		pContent;						//< 
	        uint		nLength;						//< 
	        uint		nFrameLength;					//< 
	        uint		nType;							//< 见VIDEO_FRAME_TYPE
	        uint		nSubType;						//< 见VIDEO_FRAME_SUB_TYPE
	        uint		nEncodeType;					// 见ENCODE_TYPE
            uint nYear;							//< 帧时间戳 - 年 Frame timestamp - year
            uint nMonth;							//< 帧时间戳 - 月 Frame timestamp - month
            uint nDay;							//< 帧时间戳 - 日 Frame timestamp - day
            uint nHour;							//< 帧时间戳 - 时 Frame timestamp - hour
            uint nMinute;						//< 帧时间戳 - 分 Frame timestamp - minute
            uint nSecond;						//< 帧时间戳 - 秒 Frame timestamp - seconds
            uint nTimeStamp;						//< 帧时间戳, 格式: Frame timestamp, format:
            uint nFrameRate;						//< 视频图像帧率 Video image frame rate
            int nWidth;							//< 视频图像宽度 Video image width
            int nHeight;						//< 视频图像高度 Video image height
            uint nRequence;						//< 
            uint nChannels;						//< 
            uint nBitsPerSample;					//< 音频采样位深 Audio sampling bit depth
            uint nSamplesPerSecond;				//< 音频采样率 Audio sample rate
            uint nParam1;						//< 预留字段1, 扩展用 Reserved field 1, extended
            uint nParam2;						//< 预留字段2, 扩展用 Reserved field 2, extended
        } ;

        //字体类型，目前只支持这些 Font type, currently only supports these
        enum PLAY_SDK_DEFAULT_OSD_TXT_FONT 
        {
            PLAY_SDK_OSD_TXT_FONT_ARIAL = 1,			//< Arial字体Arial font
            PLAY_SDK_OSD_TXT_FONT_SERIF,									//< Serif字体 Serif font
            PLAY_SDK_OSD_TXT_FONT_SANS,									//< Sans字体 Sans font
            PLAY_SDK_OSD_TXT_FONT_SIMSUN = 101,			//<Chinese font, Song
            PLAY_SDK_OSD_TXT_FONT_SIMHEI									//< 黑体 Black body
        } ;

        //文本信息 Text information
        public struct PLAY_SDK_OSD_INFO_TXT
        {
            int pos_x;						//< x轴相对位置(百分比) X-axis relative position (percentage)
            int pos_y;						//< y轴相对位置(百分比) Y-axis relative position (percentage)
            uint color;						//< 字体颜色 font color
            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst=256, ArraySubType = UnmanagedType.I1)]
            char[] text;					//< 文本内容 Text content
            PLAY_SDK_DEFAULT_OSD_TXT_FONT font_type;					//< 字体类型 Font type 
            int font_size;					//< 字体大小, 以窗口的百分比来表示 Font size, expressed as a percentage of the window
            IntPtr out_ft;						//< 创建的字体对象 Created font object
            int isBold;						//< 是否粗体 Is it bold?
            int isTransparent;				//< 是否透明底色 Whether transparent background
            uint bkColor;					//< 背景色 Background color
        };
        [global::System.AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
        sealed class BitfieldLengthAttribute : Attribute
        {
            uint length;

            public BitfieldLengthAttribute(uint length)
            {
                this.length = length;
            }

            public uint Length { get { return length; } }
        }

        static class PrimitiveConversion
        {
            public static int ToLong<T>(T t) where T : struct
            {
                int r = 0;
                int offset = 0;

            // For every field suitably attributed with a BitfieldLength
                foreach (System.Reflection.FieldInfo f in t.GetType().GetFields())
                {
                    object[] attrs = f.GetCustomAttributes(typeof(BitfieldLengthAttribute), false);
                    if (attrs.Length == 1)
                    {
                        uint fieldLength  = ((BitfieldLengthAttribute)attrs[0]).Length;

                    // Calculate a bitmask of the desired length
                        int mask = 0;
                        for (int i = 0; i < fieldLength; i++)
                            mask |= 1 << i;

                        r |= ((int)f.GetValue(t) & mask) << offset;

                        offset += (int)fieldLength;
                    }
                }

                return r;
            }
        }

        struct 	VIDEDATETIME							
        {
            [BitfieldLength( 6)]
	        public uint  second;		//	秒	0-59 
	        [BitfieldLength( 6)]	
	        public uint minute;			//	分	0-59	
	        [BitfieldLength( 5)]	
	        public uint hour;			//	时	0-23
	        [BitfieldLength( 5)]	
	        public uint day;			//	日	1-31
	        [BitfieldLength( 4)]	
	        public uint month;			//	月	1-12
	        [BitfieldLength( 6)]	
        	public uint year;			//	年	2000-2063	
        };

        public struct Videofilehdr 
        {
            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 5, ArraySubType = UnmanagedType.I1)]
            char[] mark;	/// 标示 Mark
            char alarm;		/// 报警类型 alarm type
	        ushort   resv;
            VIDEDATETIME DirStartTime;	/// 文件开始时间 File start time
            VIDEDATETIME DirEndTime;		/// 文件结束时间 File end time
            uint dwChanMask;		/// 支持的通道掩码 Supported channel mask
            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 64, ArraySubType = UnmanagedType.I1)]
	        char[]		startTitle;
	        uint		startSec;
	        uint		startColor;
            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 64, ArraySubType = UnmanagedType.I1)]
	        char[]		endTitle;
	        uint		endSec;
	        uint		endColor;
            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst =1024 -164, ArraySubType = UnmanagedType.I1)]
	        char[]		Reserved; 
        };

        public struct RECT
        {
            int    left;
            int    top;
            int    right;
            int    bottom;
        } ;
/*----------------------以下为SDK的API, 供用作二次开发调用--------------------------*/
        /*---------------------- The following is the SDK API for use as a secondary development call -------------- ------------*/

/*
 * @func:   PLAY_SDK_OpenFile
 * @brief:  打开播放文件
 * @parm:   LONG nPort 播放通道号
 * @parm:   LPCSTR sFileName 播放文件名
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   文件不能大于4G Byte或者小于4K Byte
 */
        /*
  * @func: PLAY_SDK_OpenFile
  * @brief: Open play file
  * @parm: LONG nPort playback channel number
  * @parm: LPCSTR sFileName play file name
  * @return: BOOL TRUE -- success FALSE -- failure
  * @note: The file cannot be larger than 4G Byte or less than 4K Byte
  */
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int PLAY_SDK_OpenFile(int nPort, string sFileName);

/*
 * @func:   PLAY_SDK_CloseFile
 * @brief:  关闭播放文件
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_CloseFile
* @brief: Close play file
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_CloseFile(int nPort);

/*
 * @func:   PlAY_SDK_WatermarkInfo
 * @brief:  得到水印信息
 * @parm:   LONG nPort 播放通道号
 * @parm:   unsigned char* Watermark  水印信息
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PlAY_SDK_WatermarkInfo
* @brief: Get watermark information
* @parm: LONG nPort playback channel number
* @parm: unsigned char* Watermark Watermark Information
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int PlAY_SDK_SetWaterInfoCallBack(int nPort,IntPtr pvFunc,int useData);

/*
 * @func:   PLAY_SDK_Play
 * @brief:  开始播放
 * @parm:   LONG nPort 播放通道号
 * @parm:   HWND hWnd  播放的窗口句柄
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_Play
* @brief: Start playing
* @parm: LONG nPort playback channel number
* @parm: HWND hWnd window handle for playback
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_Play(int nPort, IntPtr hWnd);

/*
 * @func:   PLAY_SDK_Stop
 * @brief:  停止播放
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note: PLAY_SDK_Stop与PLAY_SDK_CloseStream的顺序一定要是先Stop再Close
 */
/*
* @func: PLAY_SDK_Stop
* @brief: Stop playing
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
* @note: The order of PLAY_SDK_Stop and PLAY_SDK_CloseStream must be Stop and then Close
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_Stop(int nPort);

/*
 * @func:   PLAY_SDK_Pause
 * @brief:  暂停/恢复播放
 * @parm:   LONG nPort 播放通道号
 * @parm:   DWORD nPause 1 -- 暂停播放 0 -- 恢复播放,输入这2者之外的任何值, 返回失败
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_Pause
* @brief: Pause / resume playback
* @parm: LONG nPort playback channel number
* @parm: DWORD nPause 1 -- Pause playback 0 -- Resume playback, enter any value other than 2, return failed
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_Pause(int nPort,int nPause);

/*
 * @func:   PLAY_SDK_Fast
 * @brief:  快进 播放速度分为九级, 播放速度分别为每秒播放1,3,6,12,25,50,75,100,125帧图像。
 *		    每次调用播放速度提升一级最多调 用4次,
 *		    要恢复正常播放调用PLAY_SDK_Play,从当前位置开始正常播放
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_Fast
* @brief: Fast forward The playback speed is divided into nine levels, and the playback speed is 1, 3, 6, 12, 25, 50, 75, 100, 125 frames per second.
* Up to 4 times of playback speed increase each time.
* To resume normal play, call PLAY_SDK_Play and start normal playback from the current position.
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_Fast(int nPort);

/*
 * @func:   PLAY_SDK_Slow
 * @brief:  慢放 播放速度分为九级, 播放速度分别为每秒播放1,3,6,12,25,50,75,100,125帧图像。
		    每次调用播放速度降低一级最多调 用4次,
		    要恢复正常播放调用PLAY_SDK_Play,从当前位置开始正常播放。
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_Slow
* @brief: Slow playback The playback speed is divided into nine levels, and the playback speed is 1, 3, 6, 12, 25, 50, 75, 100, 125 frames per second.
Each call is played at a reduced speed of up to 4 times.
To resume normal play, call PLAY_SDK_Play and start normal playback from the current position.
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_Slow(int nPort);

/*
 * @func:   PLAY_SDK_NextFrame
 * @brief:  单帧往后播放, 要恢复正常播放调用PLAY_SDK_Play,从当前位置开始正常播放
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_NextFrame
* @brief: Play back in a single frame. To resume normal playback, call PLAY_SDK_Play and start normal playback from the current position.
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_NextFrame(int nPort);

/*
 * @func:   PLAY_SDK_PrevFrame
 * @brief:  单帧往前播放, 要恢复正常播放调用PLAY_SDK_Play,从当前位置开始正常播放。
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
        /*
  * @func: PLAY_SDK_PrevFrame
  * @brief: Play back in a single frame. To resume normal playback, call PLAY_SDK_Play and start normal playback from the current position.
  * @parm: LONG nPort playback channel number
  * @return: BOOL TRUE -- success FALSE -- failure
  */
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_PrevFrame(int nPort);

/*
 * @func:   PLAY_SDK_SetPlayPos
 * @brief:  设置文件播放指针的相对位置
 * @parm:   LONG nPort 播放通道号
 * @parm:   FLOAT fRelativePos 播放位置百分比,取值范围 [0.00, 100.00]
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
        /*
  * @func: PLAY_SDK_PrevFrame
  * @brief: Play back in a single frame. To resume normal playback, call PLAY_SDK_Play and start normal playback from the current position.
  * @parm: LONG nPort playback channel number
  * @return: BOOL TRUE -- success FALSE -- failure
  */
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_SetPlayPos(int nPort, float fRelativePos);

/*
 * @func:   PLAY_SDK_GetPlayPos
 * @brief:  获取文件播放指针的相对位置
 * @parm:   LONG nPort
 * @return: FLOAT 文件播放指针的相对百分比位置, 范围[0.00, 100.00]
 */
/*
* @func: PLAY_SDK_GetPlayPos
* @brief: Get the relative position of the file play pointer
* @parm: LONG nPort
* @return: Relative percentage position of the FLOAT file playback pointer, range [0.00, 100.00]
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern float 	PLAY_SDK_GetPlayPos(int nPort);

/*
 * @func:   PLAY_SDK_SetFileEndMsg
 * @brief:  设置文件播放结束时要发送的消息
 * @parm:   LONG nPort 播放通道号
 * @parm:   HWND hWnd  消息发往东窗口
 * @parm:   UINT nMsg  用户输入的消息, 当播放到文件结束时用户在hWnd窗口过程中收到这个消息
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetFileEndMsg
* @brief: Set the message to be sent when the file ends.
* @parm: LONG nPort playback channel number
* @parm: HWND hWnd message sent to the east window
* @parm: UINT nMsg User-entered message, the user receives this message during the hWnd window when playing to the end of the file
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_SetFileEndMsg(int nPort,IntPtr hWnd,uint nMsg);

/*
 * @func:   PLAY_SDK_SetFileEndCallBack
 * @brief:  设置文件播放结束回调
 * @parm:   LONG nPort 播放通道号
 * @parm:   fFileCallBack pProc 回调函数
 * @parm:   LONG nUser 用户自定义数据
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetFileEndCallBack
* @brief: Set file playback end callback
* @parm: LONG nPort playback channel number
* @parm: fFileCallBack pProc callback function
* @parm: LONG nUser user-defined data
* @return: BOOL TRUE -- success FALSE -- failure
*/
public delegate void fFileCallBack(int nPort,						//播放通道号 Play channel number
                                       int nUser);						//用户数据 User data
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_SetFileEndCallBack(int nPort, fFileCallBack pProc,int nUser);

/*
 * @func:   PLAY_SDK_SetVolume
 * @brief:  设置播放时声音
 * @parm:   LONG nPort 播放通道号
 * @parm:   WORD nVolume 音量, 取值范围[0, 0xFFFF]
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetVolume
* @brief: Set the sound during playback
* @parm: LONG nPort playback channel number
* @parm: WORD nVolume volume, range of values [0, 0xFFFF]
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_SetVolume(int nPort,int nVolume);

/*
 * @func:   PLAY_SDK_StopSound
 * @brief:  关闭以独占方式打开播放的声音
 * @parm:   无
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_StopSound
* @brief: Turn off the sound of playing in exclusive mode
* @parm: none
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_StopSound();

/*
 * @func:   PLAY_SDK_PlaySound
 * @brief:  以独占方式打开播放声音
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   同一时刻只能有一路声音。如果现在已经有声音打开，则自动关闭原来已经打开的声音
 */
/*
* @func: PLAY_SDK_PlaySound
* @brief: Open playback sound exclusively
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
* @note: There can only be one sound at a time. If the sound is now turned on, the sound that was already turned on is automatically turned off.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_PlaySound(int nPort);

/*
 * @func:   PLAY_SDK_OpenStream
 * @brief:  打开媒体流
 * @parm:   LONG nPort 播放通道号
 * @parm:   PBYTE pFileHeadBuf 目前不使用, 设置为NULL
 * @parm:   DWORD nSize		   目前不使用, 设置为0
 * @parm:   DWORD nBufPoolSize 设置播放器中存放数据流的缓冲区大小, 一般设为900K ,如果数据送过来相对均匀,
 *							   可调小该值, 如果数据传输不均匀, 可增大该值
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_OpenStream
* @brief: Open media stream
* @parm: LONG nPort playback channel number
* @parm: PBYTE pFileHeadBuf is not currently used, set to NULL
* @parm: DWORD nSize is not currently used, set to 0
* @parm: DWORD nBufPoolSize Sets the buffer size of the data stream stored in the player, generally set to 900K, if the data is sent relatively evenly,
* Adjust this value small, if the data transmission is uneven, increase the value
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_OpenStream(int nPort,IntPtr pFileHeadBuf,int nSize,int nBufPoolSize);

/*
 * @func:   PLAY_SDK_InputData
 * @brief:  输入待解码数据
 * @parm:   LONG nPort 播放通道号
 * @parm:   PBYTE pBuf 存放数据缓冲区地址
 * @parm:   DWORD nSize 缓冲区长度
 * @return: BOOL TRUE -- 输入数据成功  FALSE -- 输入数据失败
 * @note:   打开流并调用PLAY_SDK_Play之后才能输入数据, 如果失败, 通常原因是缓冲区已满
 */
/*
* @func: PLAY_SDK_InputData
* @brief: Enter the data to be decoded
* @parm: LONG nPort playback channel number
* @parm: PBYTE pBuf stores the data buffer address
* @parm: DWORD nSize buffer length
* @return: BOOL TRUE -- Input data succeeded FALSE -- Input data failed
* @note: Open the stream and call PLAY_SDK_Play before you can enter data. If it fails, the usual reason is that the buffer is full.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_InputData(int nPort,IntPtr pBuf,int nSize);

/*
 * @func:   PLAY_SDK_CloseStream
 * @brief:  关闭数据流
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   PLAY_SDK_Stop与PLAY_SDK_CloseStream的顺序一定要是先Stop再Close
 */
/*
* @func: PLAY_SDK_CloseStream
* @brief: Turn off data flow
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
* @note: The order of PLAY_SDK_Stop and PLAY_SDK_CloseStream must be Stop and then Close
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_CloseStream(int nPort);

/*
 * @func:   PLAY_SDK_GetCaps
 * @brief:  获取当前系统信息, 通常用于测试播放器需要的一些系统功能
 * @parm:   无
 * @return: LONG 系统功能位
 */
/*
* @func: PLAY_SDK_GetCaps
* @brief: Get current system information, usually used to test some system functions required by the player
* @parm: none
* @return: LONG system function bit
*/

[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_GetCaps();

/*
 * @func:   PLAY_SDK_GetFileTime
 * @brief:  获得文件总的时间长度, 单位: 秒
 * @parm:   LONG nPort 播放通道号
 * @return: DWORD 文件总的时间长度
 */
/*
* @func: PLAY_SDK_GetFileTime
* @brief: Total length of time to get the file, in seconds
* @parm: LONG nPort playback channel number
* @return: Total length of time for DWORD files
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetFileTime(int nPort);

/*
 * @func:   PLAY_SDK_GetPlayedTime
 * @brief:  获取文件当前播放的时间, 单位: 秒
 * @parm:   LONG nPort 播放通道号
 * @return: DWORD 文件当前播放的时间
 */
/*
* @func: PLAY_SDK_GetPlayedTime
* @brief: Get the current playback time of the file, in seconds
* @parm: LONG nPort playback channel number
* @return: DWORD file currently playing time
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_GetPlayedTime(int nPort);

/*
 * @func:   PLAY_SDK_GetPlayedTimeEx
 * @brief:  获取文件当前播放的时间, 单位: 毫秒
 * @parm:   LONG nPort 播放通道号
 * @return: DWORD 文件当前播放的时间
 */
/*
* @func: PLAY_SDK_GetPlayedTimeEx
* @brief: Get the current playback time of the file, in milliseconds
* @parm: LONG nPort playback channel number
* @return: DWORD file currently playing time
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_GetPlayedTimeEx(int nPort);

/*
 * @func:   PLAY_SDK_GetPlayedFrames
 * @brief:  获取已播放的帧数
 * @parm:   LONG nPort 播放通道号
 * @return: DWORD 已播放的帧数
 */
/*
* @func: PLAY_SDK_GetPlayedFrames
* @brief: Get the number of frames played
* @parm: LONG nPort playback channel number
* @return: DWORD Number of frames played
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_GetPlayedFrames(int nPort);

/*
 * @func:   PLAY_SDK_Back
 * @brief:  反向回放
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_Back
* @brief: Reverse playback
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_Back(int nPort);

/*
 * @func:   PLAY_SDK_SetDecCallBack
 * @brief:  设置解码回调
 * @parm:   LONG nPort 播放通道号
 * @parm:   fDecodeCallBack pProc 解码回调函数
 * @return: BOOL TRUE -- 设置成功  FALSE -- 设置失败
 */
       /* @func: PLAY_SDK_SetDecCallBack
  * @brief: Set the decoding callback
  * @parm: LONG nPort playback channel number
  * @parm: fDecodeCallBack pProc decode callback function
  * @return: BOOL TRUE -- Set success FALSE -- Setup failed
  */
public delegate void fDecodeCallBack(int nPort,					//播放通道号 Play channel number
                                         string pBuf,					//码流缓冲区 Code stream buffer
                                         int nSize,					//缓冲区大小 Buffer size
                                         ref PLAY_SDK_FRAME_INFO pFrameInfo,		//帧信息 Frame information
                                         int nPlayedFrames);			//已解码的帧数 Number of decoded frames
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int  	PLAY_SDK_SetDecCallBack(int nPort, fDecodeCallBack pProc);

/*
 * @func:   PLAY_SDK_SetDisplayCallBack
 * @brief:  设置图像显示回调函数
 * @parm:   LONG nPort 播放通道号
 * @parm:   fDisplayCallBack pProc 显示回调函数
 * @parm:   LONG nUser用户自定义数据
 * @return: BOOL TRUE -- 设置成功  FALSE -- 设置失败
 */
/*
* @func: PLAY_SDK_SetDisplayCallBack
* @brief: Set image display callback function
* @parm: LONG nPort playback channel number
* @parm: fDisplayCallBack pProc display callback function
* @parm: LONG nUser user-defined data
* @return: BOOL TRUE -- Set success FALSE -- Setup failed
*/
public delegate void fDisplayCallBack(int nPort,					//播放通道号 Play channel number
                                          string pBuf,					//数据缓冲区 Data buffer
                                          int nSize,					//缓冲区大小 Buffer size
                                          int nWidth,					//图像宽度 Image width
                                          int nHeight,					//图像高度 Image height
                                          int nStamp,					//时间戳 Timestamp
                                          int nType,					//类型, 按帧还是按时间 Type, by frame or by time
                                          int nUser);					//用户数据 User data
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int PLAY_SDK_SetDisplayCallBack(int nPort, fDisplayCallBack pProc, int nUser);

/*
 * @func:   PLAY_SDK_ConvertToBmpFile
 * @brief:  图像数据转为BMP 格式
 * @parm:   PBYTE pBuf   抓图回调函数中图像缓冲区
 * @parm:   LONG nSize   抓图回调函数中图像缓冲区大小
 * @parm:   LONG nWidth  抓图回调函数中图像宽度
 * @parm:   LONG nHeight 抓图回调函数中图像高度
 * @parm:   LPCSTR sFileName 要保存的文件名。最好以BMP 作为文件扩展名
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   图像数据可从解码回调或者显示回调中获取,可在播放库回调函数中使用.
 *			转换函数占用的cpu资源, 如果不需要保存图片, 则不要调用
 */
/*
* @func: PLAY_SDK_ConvertToBmpFile
* @brief: Image data is converted to BMP format
* @parm: PBYTE pBuf capture image callback function image buffer
* @parm: LONG nSize image buffer size in the capture callback function
* @parm: LONG nWidth image width in the capture callback function
* @parm: LONG nHeight image height in the capture callback function
* @parm: LPCSTR sFileName The name of the file to save. Best to use BMP as a file extension
* @return: BOOL TRUE -- success FALSE -- failure
* @note: Image data can be obtained from the decode callback or display callback, which can be used in the playback library callback function.
* The cpu resource occupied by the conversion function, if you do not need to save the picture, do not call
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_ConvertToBmpFile(ref byte pBuf,int nSize,int nWidth,int nHeight, string sFileName);

/*
 * @func:   PLAY_SDK_ConvertToJpgFile
 * @brief:  图像数据转为JPG 格式
 * @parm:   PBYTE pBuf   抓图回调函数中图像缓冲区
 * @parm:   LONG nSize   抓图回调函数中图像缓冲区大小
 * @parm:   LONG nWidth  抓图回调函数中图像宽度
 * @parm:   LONG nHeight 抓图回调函数中图像高度
 * @parm:   LPCSTR sFileName 要保存的文件名。最好以JPG 作为文件扩展名
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   图像数据可从解码回调或者显示回调中获取,可在播放库回调函数中使用.
 *			转换函数占用的cpu资源, 如果不需要保存图片, 则不要调用
 */
/*
* @func: PLAY_SDK_ConvertToJpgFile
* @brief: Image data is converted to JPG format
* @parm: PBYTE pBuf capture image callback function image buffer
* @parm: LONG nSize image buffer size in the capture callback function
* @parm: LONG nWidth image width in the capture callback function
* @parm: LONG nHeight image height in the capture callback function
* @parm: LPCSTR sFileName The name of the file to save. It is best to use JPG as the file extension
* @return: BOOL TRUE -- success FALSE -- failure
* @note: Image data can be obtained from the decode callback or display callback, which can be used in the playback library callback function.
* The cpu resource occupied by the conversion function, if you do not need to save the picture, do not call
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int PLAY_SDK_ConvertToJpgFile(ref byte pBuf, int nSize,int nWidth,int nHeight,string sFileName);
/*
 * @func:   PLAY_SDK_GetFileTotalFrames
 * @brief:  获取文件总帧数
 * @parm:   LONG nPort 播放通道号
 * @return: DWORD 文件总帧数
 * @note:   不支持对正在写入的文件进行帧数的读取
 */
/*
* @func: PLAY_SDK_GetFileTotalFrames
* @brief: Get the total number of frames in the file
* @parm: LONG nPort playback channel number
* @return: DWORD total number of frames
* @note: Does not support reading the number of frames of the file being written
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetFileTotalFrames(int nPort);

/*
 * @func:   PLAY_SDK_SetPlayedTimeEx
 * @brief:  根据时间设置文件播放位置,此接口比PLAY_SDK_SetPlayedPos费时
 *			但如果用时间来控制进度条(与PLAY_SDK_GetPlayedTimeEx配合使用),那么可以使进度条平滑滚动
 * @parm:   LONG nPort 播放通道号
 * @parm:   DWORD nTime 要设置的播放时间
 * @return: BOOL TRUE -- 设置成功  FALSE -- 设置失败
 */
/*
* @func: PLAY_SDK_SetPlayedTimeEx
* @brief: Set the file playback position according to the time, this interface is more time-consuming than PLAY_SDK_SetPlayedPos
* But if you use time to control the progress bar (used with PLAY_SDK_GetPlayedTimeEx), you can make the progress bar scroll smoothly
* @parm: LONG nPort playback channel number
* @parm: DWORD nTime The playback time to be set
* @return: BOOL TRUE -- Set success FALSE -- Setup failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetPlayedTimeEx(int nPort,int nTime);

/*
 * @func:   PLAY_SDK_GetCurrentFrameNum
 * @brief:  得到当前播放的帧序号。
 * @parm:   LONG nPort 播放通道号
 * @return: 当前播放的帧序号
 * @note:   如果文件播放位置不被改变，那么这两个函数的返回值应该非常接近,除非码流丢失数据
 */
/*
* @func: PLAY_SDK_GetCurrentFrameNum
* @brief: Get the frame number of the currently playing frame.
* @parm: LONG nPort playback channel number
* @return: The frame number of the currently playing frame
* @note: If the file playback position is not changed, the return values of these two functions should be very close, unless the stream loses data.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_GetCurrentFrameNum(int nPort);

/*
 * @func:   PLAY_SDK_SetStreamOpenMode
 * @brief:  设置流播放的模式, 必须在播放之前设置
 * @parm:   LONG nPort 播放通道号
 * @parm:   DWORD nMode 数据流播放模式, 取值为PLAY_SDK_STREAME_REALTIME或者PLAY_SDK_STREAME_FILE
 * @return: PBOOL TRUE -- 设置成功  FALSE -- 设置失败
 */
/*
* @func: PLAY_SDK_GetCurrentFrameNum
* @brief: Get the frame number of the currently playing frame.
* @parm: LONG nPort playback channel number
* @return: The frame number of the currently playing frame
* @note: If the file playback position is not changed, the return values of these two functions should be very close, unless the stream loses data.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetStreamOpenMode(int nPort,int nMode);

/*
 * @func:   PLAY_SDK_GetSdkVersion
 * @brief:  获取播放库的版本号
 * @parm:   无
 * @return: 版本号, 高16位表示当前的主版本号。9~16位表示次版本号，1~8位表示次补丁号。
 *			如：返回值0x00010101表示：主版本号是1，次版本号是1，补丁号是1
 */
/*
* @func: PLAY_SDK_GetSdkVersion
* @brief: Get the version number of the play library
* @parm: none
* @return: Version number, the upper 16 bits indicate the current major version number. 9~16 digits indicate the minor version number, and 1~8 digits indicate the minor patch number.
* For example, the return value 0x00010101 means: the major version number is 1, the minor version number is 1, and the patch number is 1.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_GetSdkVersion();

/*
 * @func:   PLAY_SDK_GetLastError
 * @brief:  获得最后一次出错的错误码
 * @parm:   LONG nPort 播放通道号
 * @return: 错误码 
 * @note:   应该在调用某个函数失败时，调用此函数以获得错误的详细信息
 */
/*
* @func: PLAY_SDK_GetLastError
* @brief: Get the error code of the last error
* @parm: LONG nPort playback channel number
* @return: error code
* @note: This function should be called to get the error details when a function call fails.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_GetLastError(int nPort);

/*
 * @func:   PLAY_SDK_RefreshPlay
 * @brief:  刷新显示的图像
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   当用户暂停时如果刷新了窗口,则窗口中的图像因为刷新而消失，
 *			此时调用这个接口可以重新把图像显示出来。只有在暂停和单帧播放时才会执行,
 *			其它情况会直接返回
 */
/*
* @func: PLAY_SDK_RefreshPlay
* @brief: Refresh the displayed image
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
* @note: If the window is refreshed when the user pauses, the image in the window disappears due to refreshing.
* Call this interface to redisplay the image. It will only be executed during pause and single frame playback.
* Other situations will return directly
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_RefreshPlay(int nPort);

/*
 * @func:   PLAY_SDK_SetOverlayMode
 * @brief:  设置Overlay模式
 * @parm:   LONG nPort 播放通道号
 * @parm:   BOOL bOverlay 
 *			TRUE	表示将首先尝试使用OVERLAY模式，如果不行再使用其他模式
 *			FALSE	不进行OVERLAY模式的尝试
 * @parm:   uint colorKey 用户设置的透明色，透明色相当于一层透视膜，显示画面只
 *			能穿过这种颜色，其他颜色将挡住显示的画面。用户应该在
 *			显示窗口中涂上这种颜色，才能看到显示画面。一般应该使
 *			用一种不常用的颜色作为透明色。这是一个双字节值
 *			0x00bbggrr,最高字节为0，后三个字节分别表示r,g,b 的值
 * @return: BOOL TRUE -- 设置成功  FALSE -- 设置失败
 */
/*
* @func: PLAY_SDK_SetOverlayMode
* @brief: Set the Overlay mode
* @parm: LONG nPort playback channel number
* @parm: BOOL bOverlay
* TRUE means that OVERLAY mode will be tried first, if no other mode is used
* FALSE does not attempt OVERLAY mode
* @parm: uint colorKey The transparent color set by the user. The transparent color is equivalent to a layer of transparency film.
* Can pass through this color, other colors will block the displayed picture. User should be at
* Apply this color to the display window to see the display. Generally should make
* Use a color that is not commonly used as a transparent color. This is a double-byte value
* 0x00bbggrr, the highest byte is 0, the last three bytes represent the values of r, g, b respectively
* @return: BOOL TRUE -- Set success FALSE -- Setup failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetOverlayMode(int nPort, int bOverlay, uint colorKey);

/*
 * @func:   PLAY_SDK_GetPictureSize
 * @brief:  获得码流中原始图像的大小
 * @parm:   LONG nPort 播放通道号
 * @parm:   LONG* pWidth  获取到的图像宽度
 * @parm:   LONG* pHeight 获取到的图像高度
 * @return: BOOL TRUE -- 获取成功  FALSE -- 获取失败
 */
/*
* @func: PLAY_SDK_GetPictureSize
* @brief: Get the size of the original image in the stream
* @parm: LONG nPort playback channel number
* @parm: LONG* pWidth Get the width of the image
* @parm: LONG* pHeight Get the height of the image
* @return: BOOL TRUE -- Get success FALSE -- Get failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetPictureSize(int nPort, ref int pWidth,ref int pHeight);

/*
 * @func:   PLAY_SDK_SetPicQuality
 * @brief:  设置图像质量
 * @parm:   LONG nPort 播放通道号
 * @parm:   BOOL bHighQuality 等于1 时图像高质量,等于0 时低质量, 默认为1。
 * @return: BOOL TRUE -- 设置成功  FALSE -- 设置失败
 * @note:   当设置成高质量时画面效果好,但CPU 利用率高。
 *			在支持多路播放时,可以设为低质量,以降低CPU 利用率
 *			当某路放大播放时将该路设置成高质量,以达到好的画面效果。
 */
/*
* @func: PLAY_SDK_SetPicQuality
* @brief: Set image quality
* @parm: LONG nPort playback channel number
* @parm: BOOL bHighQuality is equal to 1 for high quality image, equal to 0 for low quality, default is 1.
* @return: BOOL TRUE -- Set success FALSE -- Setup failed
* @note: The screen works well when set to high quality, but the CPU utilization is high.
* Can be set to low quality when supporting multi-channel playback to reduce CPU utilization
* Set the path to high quality when a certain way is enlarged to achieve a good picture.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_SetPicQuality(int nPort,int bHighQuality);

/*
 * @func:   PLAY_SDK_PlaySoundShare
 * @brief:  以共享方式打开播放声音，播放本路声音而不去关闭其它路声音
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_PlaySoundShare
* @brief: Open the play sound in shared mode, play the local sound without turning off other road sounds
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_PlaySoundShare(int nPort);

/*
 * @func:   PLAY_SDK_StopSoundShare
 * @brief:  关闭以以共享方式打开的声音
 * @parm:   LONG nPort 播放通道号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   PLAY_SDK_PlaySound和PLAY_SDK_StopSound是以独占方式播放声音的，
 *          在同一个进程中，所有通道必须使用相同的方式播放或关闭声音
 */
/*
* @func: PLAY_SDK_StopSoundShare
* @brief: Turn off the sound to open in shared mode
* @parm: LONG nPort playback channel number
* @return: BOOL TRUE -- success FALSE -- failure
* @note: PLAY_SDK_PlaySound and PLAY_SDK_StopSound play the sound exclusively.
* All channels must play or turn off the sound in the same way in the same process
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_StopSoundShare(int nPort);

/*
 * @func:   PLAY_SDK_GetStreamOpenMode
 * @brief:  获得流模式类型
 * @parm:   LONG nPort 播放通道号
 * @return: LONG 流播放模式: PLAY_SDK_STREAME_REALTIME、PLAY_SDK_STREAME_FILE
 */
/*
* @func: PLAY_SDK_GetStreamOpenMode
* @brief: Get stream mode type
* @parm: LONG nPort playback channel number
* @return: LONG stream playback mode: PLAY_SDK_STREAME_REALTIME, PLAY_SDK_STREAME_FILE
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetStreamOpenMode(int nPort);

/*
 * @func:   PLAY_SDK_GetOverlayMode
 * @brief:  获得当前使用的overlay模式
 * @parm:   LONG nPort 播放通道号
 * @return: 0 -- 没有使用Overlay模式 1 -- 使用了Overlay模式
 */
/*
* @func: PLAY_SDK_GetOverlayMode
* @brief: Get the currently used overlay mode
* @parm: LONG nPort playback channel number
* @return: 0 -- no Overlay mode is used 1 -- Overlay mode is used
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetOverlayMode(int nPort);

/*
 * @func:   PLAY_SDK_GetVolume
 * @brief:  获取音量大小
 * @parm:   LONG nPort 播放通道号
 * @return: 音量大小
 */
/*
* @func: PLAY_SDK_GetVolume
* @brief: Get the volume
* @parm: LONG nPort playback channel number
* @return: volume
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetVolume(int nPort);

/*
 * @func:   PLAY_SDK_GetPictureQuality
 * @brief:  获取图像质量参数
 * @parm:   LONG nPort 播放通道号
 * @parm:   BOOL* bHighQuality 获取到的质量 1 -- 表示高质量, 0 -- 表示低质量
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_GetPictureQuality
* @brief: Get image quality parameters
* @parm: LONG nPort playback channel number
* @parm: BOOL* bHighQuality The quality obtained 1 -- means high quality, 0 -- means low quality
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetPictureQuality(int nPort,ref int bHighQuality);

/*
 * @func:   PLAY_SDK_GetSourceBufferRemain
 * @brief:  获得流播放模式下源缓冲剩余数据大小
 * @parm:   LONG nPort 播放通道号
 * @return: 源缓冲剩余数据大小
 */
/*
* @func: PLAY_SDK_GetSourceBufferRemain
* @brief: Get the size of the remaining data in the source buffer in streaming mode
* @parm: LONG nPort playback channel number
* @return: source buffer remaining data size
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_GetSourceBufferRemain(int nPort);

/*
 * @func:   PLAY_SDK_ResetSourceBuffer
 * @brief:  重置回调标志为有效状态
 * @parm:   LONG nPort
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_ResetSourceBuffer
* @brief: Reset callback flag to active status
* @parm: LONG nPort
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_ResetSourceBuffer(int nPort);

/*
 * @func:   PLAY_SDK_SetSourceBufCallBack
 * @brief:  设置源缓冲区阀值和剩余数据小于等于阀值时的回调函数指针。
 *			只有在数据量从大到小"越过"指定阈值的时候, 才会触发回调;
 * @parm:   LONG nPort					播放通道号
 * @parm:   DWORD nThreShold			阈值
 * @parm:   fSourceBufCallBack pProc	回调函数
 * @parm:   LONG nUser					用户自定义数据
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   一次触发后需要调用PlayM4_ResetSourceBufFlag 接口重置参数, 使得再次有效
 */
/*
* @func: PLAY_SDK_SetSourceBufCallBack
* @brief: Sets the callback function pointer when the source buffer threshold and remaining data are less than or equal to the threshold.
* Callbacks are only triggered when the amount of data "goes over" the specified threshold from large to small;
* @parm: LONG nPort playback channel number
* @parm: DWORD nThreShold threshold
* @parm: fSourceBufCallBack pProc callback function
* @parm: LONG nUser user-defined data
* @return: BOOL TRUE -- success FALSE -- failure
* @note: After a trigger, you need to call the PlayM4_ResetSourceBufFlag interface to reset the parameters, making it valid again.
*/
public delegate void fSourceBufCallBack(int nPort,					//播放通道号 Play channel number
                                            int nBufSize,				//剩余数据大小 Remaining data size
                                            int nUser);				//用户数据 User data
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_SetSourceBufCallBack(int nPort,int nThreShold, fSourceBufCallBack pProc, int nUser);

/*
 * @func:   PLAY_SDK_ResetSourceBufFlag
 * @brief:  重置回调标志位为有效状态
 * @parm:   LONG nPort
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_ResetSourceBufFlag
* @brief: Reset callback flag is valid
* @parm: LONG nPort
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_ResetSourceBufFlag(int nPort);

/*
 * @func:   PLAY_SDK_SetDisplayBuf
 * @brief:  播放缓冲区最大缓冲帧数
 * @parm:   LONG nPort 播放通道号
 * @parm:   DWORD nNum 播放缓冲区最大缓冲帧数。范围：PLAY_SDK_MIN_DIS_FRAMES ~PLAY_SDK_MAX_DIS_FRAMES。
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetDisplayBuf
* @brief: Maximum number of buffered frames in the play buffer
* @parm: LONG nPort playback channel number
* @parm: DWORD nNum The maximum number of buffered frames in the play buffer. Range: PLAY_SDK_MIN_DIS_FRAMES ~PLAY_SDK_MAX_DIS_FRAMES.
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetDisplayBuf(int nPort,int nNum);

/*
 * @func:   PLAY_SDK_GetDisplayBuf
 * @brief:  获取播放缓冲区最大缓冲帧数
 * @parm:   LONG nPort 播放通道号
 * @return: 播放缓冲区最大缓冲帧数
 */
/*
* @func: PLAY_SDK_GetDisplayBuf
* @brief: Get the maximum number of buffered frames in the play buffer
* @parm: LONG nPort playback channel number
* @return: Maximum number of buffered frames in the play buffer
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetDisplayBuf(int nPort);

/*
 * @func:   PLAY_SDK_SetFileRefCallBack
 * @brief:  建立文件索引回调。
 * @parm:   LONG nPort 播放通道号
 * @parm:   fFileCallBack pProc 回调函数
 * @parm:   LONG nUser 用户自定义数据
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   为了能在文件中准确快速的定位，在文件打开的时候生成文件索引。这个过程耗
 *			时比较长，大约每秒处理40M 左右的数据，主要是因为从硬盘读数据比较慢。建
 *			立索引的过程是在后台完成，需要使用索引的函数要等待这个过程结束，而其他
 *			接口不会受到影响。打开文件时是否建立文件的关键帧索引, 如果索引回调未触
 *			发, 表明录像文件异常。
 */
/*
* @func: PLAY_SDK_SetFileRefCallBack
* @brief: Create a file index callback.
* @parm: LONG nPort playback channel number
* @parm: fFileCallBack pProc callback function
* @parm: LONG nUser user-defined data
* @return: BOOL TRUE -- success FALSE -- failure
* @note: In order to be able to locate accurately and quickly in the file, the file index is generated when the file is opened. This process consumes
* It is relatively long, about 40M per second is processed, mainly because reading data from the hard disk is slow. build
* The process of indexing is done in the background, the function that needs to use the index has to wait for the end of the process, and the other
* The interface will not be affected. Whether to establish the key frame index of the file when opening the file, if the index callback is not touched
* Send, indicating that the video file is abnormal.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_SetFileRefCallBack(int nPort, fFileCallBack pProc, int nUser);

/*
 * @func:   PLAY_SDK_SetCurrentFrameNum
 * @brief:  设置当前播放播放位置到指定帧号；根据帧号来定位播放位置
 * @parm:   LONG nPort 播放通道号
 * @parm:   DWORD nFrameNum 帧号
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   如果在建立文件索引的前提下使用, 为精确定位, 否则即为粗略定位,在PlayM4_Play 之后调用才有效。
 */
/*
* @func: PLAY_SDK_SetCurrentFrameNum
* @brief: Set the current playback position to the specified frame number; locate the playback position according to the frame number
* @parm: LONG nPort playback channel number
* @parm: DWORD nFrameNum frame number
* @return: BOOL TRUE -- success FALSE -- failure
* @note: If used under the premise of creating a file index, it is for precise positioning, otherwise it is coarse positioning, and the call is valid after PlayM4_Play.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_SetCurrentFrameNum(int nPort,int nFrameNum);

/*
 * @func:   PLAY_SDK_GetKeyFramePos
 * @brief:  查找指定位置前的关键帧
 * @parm:   LONG nPort   播放通道号
 * @parm:   DWORD nValue 当前位置,可以是时间或帧号,类型由nType 指定
 * @parm:   DWORD nType  见【定位类型宏定义】
 * @parm:   PFRAME_POS pFramePos 查找到的关键帧的文件位置、帧序号、时标信息
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 * @note:   图像解码必须从关键帧开始，如果用户保存的文件不是从关键帧开始的,那么到下
			一个关键帧之前的数据会被忽略。如果用户要截取文件中的一段数据，则应该考虑
			从关键帧开始截取。结束位置则关系不大,最多丢失3 帧数据。
 */
/*
* @func: PLAY_SDK_GetKeyFramePos
* @brief: Find keyframes before the specified location
* @parm: LONG nPort playback channel number
* @parm: DWORD nValue Current position, which can be time or frame number, type specified by nType
* @parm: DWORD nType See [Location Type Macro Definition]
* @parm: PFRAME_POS pFramePos Find the file location, frame number, and time stamp information of the key frame.
* @return: BOOL TRUE -- success FALSE -- failure
* @note: Image decoding must start from a keyframe, if the user saves the file not from the keyframe, then to the next
Data before a keyframe is ignored. If the user wants to intercept a piece of data in the file, it should be considered
Intercept from the key frame. The end position is not relevant, and up to 3 frames of data are lost.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
public static extern int PLAY_SDK_GetKeyFramePos(int nPort, int nValue, int nType,ref PLAY_SDK_FRAME_POS pFramePos);

/*
 * @func:   PLAY_SDK_GetNextKeyFramePos
 * @brief:  查找指定位置之后的关键帧位置
 * @parm:   LONG nPort    播放通道号
 * @parm:   DWORD nValue  当前位置，可以是时间或帧号，类型由nType 指定
 * @parm:   DWORD nType   见【定位类型宏定义】
 * @parm:   PFRAME_POS pFramePos  查找到的关键帧的文件位置、帧序号、时标信息
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_GetNextKeyFramePos
* @brief: Find the keyframe position after the specified position
* @parm: LONG nPort playback channel number
* @parm: DWORD nValue Current position, which can be time or frame number, type specified by nType
* @parm: DWORD nType See [Location Type Macro Definition]
* @parm: PFRAME_POS pFramePos Find the file location, frame number, and time stamp information of the key frame.
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetNextKeyFramePos(int nPort,int nValue, int nType,ref PLAY_SDK_FRAME_POS pFramePos);

/*
 * @func:   PLAY_SDK_InitDDrawDevice
 * @brief:  初始化多显卡显示设备
 * @param:  无
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_InitDDrawDevice
* @brief: Initialize multiple graphics display devices
* @param: none
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_InitDDrawDevice();

/*
 * @func:   PLAY_SDK_ReleaseDDrawDevice
 * @brief:  释放枚举显示设备的过程中分配的资源
 * @param:  无
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_ReleaseDDrawDevice
* @brief: Releases the resources allocated during the enumeration of the display device
* @param: none
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_ReleaseDDrawDevice();

/*
 * @func:   PLAY_SDK_GetDDrawDeviceTotalNums
 * @brief:  获得系统中与windows 桌面绑定的总的显示设备数目(这里主要是指显卡)
 * @param:  无
 * @return: 如果返回0，则表示系统中只有主显示设备。如果返回1，则表示系统中安装了多
 *			块显卡，但只有一块显卡与Windows 桌面绑定。返回其他值，则表示系统中与桌
 *			面绑定的显卡数目。在多显卡的系统中可以通过设置显示属性，而指定任意一块
 *			显卡作为主显示设备
 */
/*
* @func: PLAY_SDK_GetDDrawDeviceTotalNums
* @brief: Get the total number of display devices in the system that are bound to the windows desktop (here mainly refers to the graphics card)
* @param: none
* @return: If 0 is returned, it means that there is only the main display device in the system. If it returns 1, it means that there are many installed in the system.
* Block graphics, but only one graphics card is bundled with the Windows desktop. Returning other values means the system is in the table
* The number of graphics cards bound to the face. In a system with multiple graphics cards, you can specify any one by setting the display properties.
* Graphics card as the main display device
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetDDrawDeviceTotalNums();

/*
 * @func:   PLAY_SDK_SetDisplayType
 * @brief:  设置显示的模式，在小画面显示时，采用DISPLAY_QUARTER 可以减小显卡工作量,
 *			从而支持更多路显示，但画面显示质量有下降。在正常和大画面显示时应该使用
 *			PLAY_SDK_DISPLAY_NORMAL
 * @parm:   LONG nPort 播放通道号
 * @parm:   LONG nType 取值PLAY_SDK_DISPLAY_NORMAL 或者 PLAY_SDK_DISPLAY_QUARTER
 * @return: BOOL TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetDisplayType
* @brief: Set the display mode. When the small screen is displayed, use DISPLAY_QUARTER to reduce the workload of the graphics card.
* This supports more display, but the quality of the display is degraded. Should be used when displaying normal and large screens
* PLAY_SDK_DISPLAY_NORMAL
* @parm: LONG nPort playback channel number
* @parm: LONG nType takes the value PLAY_SDK_DISPLAY_NORMAL or PLAY_SDK_DISPLAY_QUARTER
* @return: BOOL TRUE -- success FALSE -- failure
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetDisplayType(int nPort,int nType);

/*
 * @func:   PLAY_SDK_GetDisplayType
 * @brief:  获取显示模式
 * @parm:   LONG nPort 播放通道号
 * @return: PLAY_SDK_DISPLAY_NORMAL 或者 PLAY_SDK_DISPLAY_QUARTER
 */
/*
* @func: PLAY_SDK_GetDisplayType
* @brief: Get display mode
* @parm: LONG nPort playback channel number
* @return: PLAY_SDK_DISPLAY_NORMAL or PLAY_SDK_DISPLAY_QUARTER
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_GetDisplayType(int nPort);

/*
 * @func:   PLAY_SDK_SetDecCBStream
 * @brief:  设置解码回调的码流类型
 * @parm:   LONG nPort   播放通道号
 * @parm:   DWORD nStream 1 -- 视频流, 2 -- 音频流, 3 -- 复合流
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetDecCBStream
* @brief: Set the stream type of the decoding callback
* @parm: LONG nPort playback channel number
* @parm: DWORD nStream 1 -- video stream, 2 -- audio stream, 3 -- composite stream
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_SetDecCBStream(int nPort,int nStream);

/*
 * @func:   PLAY_SDK_SetDisplayRegion
 * @brief:  设置或增加显示区域, 可以做局部放大显示
 * @parm:   LONG nPort 播放通道号
 * @parm:   DWORD nRegionNum 显示区域序号，0~(PLAY_SDK_MAX_DISPLAY_WND-1)。如果nRegionNum 为0, 表示对主要显示窗口
 *			(PlayM4_Play 中设置的窗口) 进行设置, 将忽略hDestWnd 和bEnable 的设置
 * @parm[in]:   RECT* pSrcRect 设置在要显示的原始图像上的区域，如：如果原始图像是352*288,那么pSrcRect 
 *			可设置的范围只能在（0, 0, 352, 288）之中。如果pSrcRect=NULL,将显示整个图像。
 * @parm:   HWND hDestWnd  设置显示窗口。如果该区域的窗口已经设置过(打开过), 那么该参数被忽略。
 * @parm:   BOOL bEnable   打开(设置)或关闭显示区域
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetDisplayRegion
* @brief: Set or increase the display area, you can do partial zoom display
* @parm: LONG nPort playback channel number
* @parm: DWORD nRegionNum Display area number, 0~(PLAY_SDK_MAX_DISPLAY_WND-1). If nRegionNum is 0, it means to the main display window.
* (Window set in PlayM4_Play) Settings are made, the settings of hDestWnd and bEnable are ignored
* @parm[in]: RECT* pSrcRect Sets the area on the original image to be displayed, eg if the original image is 352*288, then pSrcRect
* The range that can be set can only be in (0, 0, 352, 288). If pSrcRect=NULL, the entire image will be displayed.
* @parm: HWND hDestWnd Sets the display window. This parameter is ignored if the window for this area has been set (opened).
* @parm: BOOL bEnable Open (set) or close the display area
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetDisplayRegion(int nPort,int nRegionNum,ref RECT pSrcRect, IntPtr hDestWnd, bool bEnable);

/*
 * @func:   PLAY_SDK_RefreshPlayEx
 * @brief:  刷新显示, 同PLAY_SDK_RefreshPlay。为支持PLAY_SDK_SetDisplayRegion 而增加一个参数
 * @parm:   LONG nPort			播放通道号
 * @parm:   DWORD nRegionNum	[0, PLAY_SDK_MAX_DISPLAY_WND-1]
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_RefreshPlayEx
* @brief: Refresh display, same as PLAY_SDK_RefreshPlay. Add a parameter to support PLAY_SDK_SetDisplayRegion
* @parm: LONG nPort playback channel number
* @parm: DWORD nRegionNum [0, PLAY_SDK_MAX_DISPLAY_WND-1]
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_RefreshPlayEx(int nPort,int nRegionNum);

/*
 * @func:   PLAY_SDK_GetRefValue
 * @brief:  获取文件索引信息，以便下次打开同一个文件时直接使用这个信息。必须在索引建成后才能获得信息。
 * @parm:   LONG   nPort     播放通道号
 * @parm:   BYTE*  pBuffer   索引信息
 * @parm[out]:   DWORD* pSize     输入pBuffer 的大小，输出索引信息大小
 * @return: TRUE -- 成功  FALSE -- 失败
 * @note:   可以在第一次指定pSize=0,pBuffer=NULL,从pSize的返回值获得需要的缓冲区大小。然后分配足够的缓冲,再调用一次。
 */
/*
* @func: PLAY_SDK_GetRefValue
* @brief: Get file index information so that this information can be used directly the next time you open the same file. Information must be obtained after the index is built.
* @parm: LONG nPort playback channel number
* @parm: BYTE* pBuffer index information
* @parm[out]: DWORD* pSize Enter the size of pBuffer and output the size of the index information.
* @return: TRUE -- success FALSE -- failed
* @note: You can specify pSize=0, pBuffer=NULL for the first time, and get the required buffer size from the return value of pSize. Then allocate enough buffers and call them again.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_GetRefValue(int nPort,ref byte pBuffer, ref int pSize);

/*
 * @func:   PLAY_SDK_SetRefValue
 * @brief:  设置文件索引。如果已经有了文件索引信息，可以不再调用生成索引的回调函数
 *			PLAY_SDK_SetFileRefCallBack, 直接输入索引信息。
 * @parm[in]:   LONG nPort     播放通道号
 * @parm[in]:   BYTE* pBuffer  索引信息
 * @parm[in]:   DWORD nSize    索引信息的长度
 * @return: TRUE -- 成功  FALSE -- 失败
 * @note:   索引信息及其长度必须准确，在PLAY_SDK_OpenFile 之后调用
 */
/*
* @func: PLAY_SDK_SetRefValue
* @brief: Set the file index. If you already have file index information, you can no longer call the callback function that generates the index.
* PLAY_SDK_SetFileRefCallBack, directly enter the index information.
* @parm[in]: LONG nPort playback channel number
* @parm[in]: BYTE* pBuffer index information
* @parm[in]: DWORD nSize length of index information
* @return: TRUE -- success FALSE -- failed
* @note: Index information and its length must be accurate, called after PLAY_SDK_OpenFile
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_SetRefValue(int nPort,ref byte pBuffer, int nSize);

/*
 * @func:   PLAY_SDK_InputVideoData
 * @brief:  输入视频流(可以是复合流，但音频数据会被忽略), 打开流之后才能输入数据
 * @parm:   LONG nPort  播放通道号
 * @parm:   PBYTE pBuf  缓冲区地址
 * @parm:   DWORD nSize 缓冲区大小
 * @return: TRUE -- 输入数据成功  FALSE -- 失败, 数据没有输入
 * @note1:  失败一般是由于内部缓冲区满,建议暂停输入数据线程,再次输入数据,确保播放库不丢失数据。
 * @note2:  在实时流情况下, 因数据满而无法送入播放库, 可以选择丢弃, 后果是画面可能跳帧或者花屏,
 *			若无法接受,则sleep 几毫秒后,再尝试多送几次.
 * @note3:	文件流回放模式下，数据满而导致无法送入播放库，需要不断尝试，直到送成功为止。
 */
/*
  * @func: PLAY_SDK_InputVideoData
  * @brief: Input video stream (can be a composite stream, but the audio data will be ignored), you can enter data after opening the stream
  * @parm: LONG nPort playback channel number
  * @parm: PBYTE pBuf buffer address
  * @parm: DWORD nSize buffer size
  * @return: TRUE -- Input data is successful FALSE -- Failed, data is not entered
  * @note1: The failure is generally due to the internal buffer being full. It is recommended to pause the input data thread and enter the data again to ensure that the playback library does not lose data.
  * @note2: In the case of real-time streaming, because the data is too full to be sent to the playback library, you can choose to discard it. The consequence is that the screen may skip frames or screen.
  * If it is unacceptable, sleep for a few milliseconds and try to send it a few more times.
  * @note3: In the file stream playback mode, the data is too full and cannot be sent to the playback library. It needs to be tried continuously until it is sent successfully.
  */
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_InputVideoData(int nPort, ref byte pBuf, int nSize);

/*
 * @func:   PLAY_SDK_InputAudioData
 * @brief:  输入音频流, 打开声音之后才能输入数据
 * @parm:   LONG nPort 播放通道号
 * @parm:   PBYTE pBuf 缓冲区地址
 * @parm:   DWORD nSize 缓冲区大小
 * @return: TRUE -- 输入数据成功  FALSE -- 失败, 数据没有输入
 * @note:   见PLAY_SDK_InputVideoData的note事项
 */
/*
* @func: PLAY_SDK_InputAudioData
* @brief: Input audio stream, open the sound before you can enter data
* @parm: LONG nPort playback channel number
* @parm: PBYTE pBuf buffer address
* @parm: DWORD nSize buffer size
* @return: TRUE -- Input data is successful FALSE -- Failed, data is not entered
* @note: See the note for PLAY_SDK_InputVideoData
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_InputAudioData(int nPort, ref byte pBuf, int nSize);

/*
 * @func:   PLAY_SDK_RigisterDrawFun
 * @brief:  注册画图回调函数
 * @parm:   LONG nPort			播放通道号
 * @parm:   fDrawCallBack pProc 画图回调函数
 * @parm:   LONG nUser			用户自定义数据
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_RigisterDrawFun
* @brief: Register drawing callback function
* @parm: LONG nPort playback channel number
* @parm: fDrawCallBack pProc drawing callback function
* @parm: LONG nUser user-defined data
* @return: TRUE -- success FALSE -- failed
*/
public delegate void fDrawCallBack(int nPort,						//播放通道号 Play channel number
                                       IntPtr hDc,							//设备句柄 Device handle
                                       int nUser);						//用户数据 User data
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_RigisterDrawFun(int nPort, fDrawCallBack pProc, int nUser);

/*
 * @func:   PLAY_SDK_SetTimerType
 * @brief:  设置播放使用的定时器类型
 * @parm:   LONG nPort  播放通道号
 * @parm:   DWORD nTimerType PLAY_SDK_TIMER_1 或者 PLAY_SDK_TIMER_2
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetTimerType
* @brief: Set the type of timer used for playback
* @parm: LONG nPort playback channel number
* @parm: DWORD nTimerType PLAY_SDK_TIMER_1 or PLAY_SDK_TIMER_2
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetTimerType(int nPort,int nTimerType);

/*
 * @func:   PLAY_SDK_GetTimerType
 * @brief:  获取播放使用的定时器类型
 * @parm[in]:   LONG nPort 播放通道号
 * @parm[out]:   DWORD * pTimerType  PLAY_SDK_TIMER_1 或者 PLAY_SDK_TIMER_2
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
 * @func: PLAY_SDK_GetTimerType
 * @brief: Get the type of timer used for playback
 * @parm[in]: LONG nPort playback channel number
 * @parm[out]: DWORD * pTimerType PLAY_SDK_TIMER_1 or PLAY_SDK_TIMER_2
 * @return: TRUE -- success FALSE -- failed
 */
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetTimerType(int nPort,ref int pTimerType);

/*
 * @func:   PLAY_SDK_ResetBuffer
 * @brief:  清空指定缓冲区的剩余数据
 * @parm:   LONG nPort      播放通道号
 * @parm:   DWORD nBufType  缓冲区类型, 见 【缓冲类型宏定义】
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_ResetBuffer
* @brief: Clear the remaining data of the specified buffer
* @parm: LONG nPort playback channel number
* @parm: DWORD nBufType buffer type, see [buffer type macro definition]
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_ResetBuffer(int nPort,int nBufType);

/*
 * @func:   PLAY_SDK_GetBufferValue
 * @brief:  根据参数不同, 返回缓冲区值, 源缓冲区返回byte,解码后缓冲区返回帧数。
 * @parm:   LONG nPort       播放通道号
 * @parm:   DWORD nBufType   缓冲区类型, 见 【缓冲类型宏定义】
 * @return: 源缓冲区返回byte,解码后缓冲区返回帧数
 * @note:   这个接口可以帮助用户了解缓冲区中的数据,从而在网络延时方面有所估计
 */
/*
* @func: PLAY_SDK_GetBufferValue
* @brief: Depending on the parameter, the buffer value is returned, the source buffer returns byte, and the decoded buffer returns the number of frames.
* @parm: LONG nPort playback channel number
* @parm: DWORD nBufType buffer type, see [buffer type macro definition]
* @return: The source buffer returns byte, the number of frames returned by the buffer after decoding
* @note: This interface helps users understand the data in the buffer and thus estimates the network latency.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetBufferValue(int nPort,int nBufType);

/*
 * @func:   PLAY_SDK_AdjustWaveAudio
 * @brief:  调整WAVE 波形, 可以改变声音的大小。和PLAY_SDK_SetVolume 的不同在于, 它是调整声音数据, 只对该路其作用， 而
 *			PLAY_SDK_SetVolume 是调整声卡音量，对整个系统起作用。
 * @parm:   LONG nPort         播放通道号
 * @parm:   LONG nCoefficient  调整参数，0 是不调整，范围见【波形调整因子最大最小值宏定义】
 * @return: TRUE -- 成功  FALSE -- 失败
 * @note:   用这个函数会破坏音质, 除非想每路单独调整音量,否则请谨慎使用。
 */
/*
* @func: PLAY_SDK_AdjustWaveAudio
* @brief: Adjust the WAVE waveform to change the size of the sound. The difference with PLAY_SDK_SetVolume is that it adjusts the sound data and only works for it.
* PLAY_SDK_SetVolume is to adjust the sound card volume to work on the entire system.
* @parm: LONG nPort playback channel number
* @parm: LONG nCoefficient Adjust the parameter, 0 is not adjusted, the range see [waveform adjustment factor maximum and minimum macro definition]
* @return: TRUE -- success FALSE -- failed
* @note: Using this function will destroy the sound quality, unless you want to adjust the volume separately for each channel, please use it with caution.
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_AdjustWaveAudio(int nPort,int nCoefficient);

/*
 * @func:   PLAY_SDK_SetVerifyCallBack
 * @brief:  设置数据校验
 * @parm:   LONG nPort 播放通道号
 * @parm:   DWORD nBeginTime		校验开始时间，单位ms
 * @parm:   DWORD nEndTime			校验结束时间，单位ms
 * @parm:   fVerifyCallBack pProc	当发现数据被修改时回调的函数, 详细参数信息见回调函数类型定义
 * @parm:   LONG nUser				用户自定义数据
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetVerifyCallBack
* @brief: Set data check
* @parm: LONG nPort playback channel number
* @parm: DWORD nBeginTime Check start time, in ms
* @parm: DWORD nEndTime Verification end time in ms
* @parm: fVerifyCallBack pProc Callback function when it finds that the data is modified. See the callback function type definition for detailed parameter information.
* @parm: LONG nUser user-defined data
* @return: TRUE -- success FALSE -- failed
*/
public delegate void fVerifyCallBack(int nPort,					//播放通道号 Play channel number
                                         ref PLAY_SDK_FRAME_POS pFilePos,			//出错信息 Error message
                                         int bIsVideo,				//是否视频数据，1 视频，0 音频 Whether video data, 1 video, 0 audio
                                         int nUser);					//用户数据  User data
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_SetVerifyCallBack(int nPort, int nBeginTime, int nEndTime, fVerifyCallBack pProc, int nUser);

/*
 * @func:   PLAY_SDK_SetAudioCallBack
 * @brief:  设置音频解码回调
 * @parm:   LONG nPort 播放通道号
 * @parm:   fAudioCallBack pProc 音频解码回调函数，若不需要回调函数则置为NULL,否则不能为NULL
 * @parm:   LONG nUser  用户数据
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetAudioCallBack
* @brief: Set audio decoding callback
* @parm: LONG nPort playback channel number
* @parm: fAudioCallBack pProc audio decoding callback function, set to NULL if no callback function is required, otherwise it cannot be NULL
* @parm: LONG nUser user data
* @return: TRUE -- success FALSE -- failed
*/
public delegate void fAudioCallBack(int nPort,						//播放通道号 Play channel number
                                        ref byte pAudioBuf,				//wave 格式音频数据指针 Wave format audio data pointer
                                        int nSize,						//音频数据长度 Audio data length
                                        int nStamp,					//时标(ms) Time scale (ms)
                                        int nType,						//音频类型 Audio type
                                        int nUser);					//用户数据User data
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetAudioCallBack(int nPort, fAudioCallBack pProc, int nUser);

/*
 * @func:   PLAY_SDK_SetImageSizeChangeCallBack
 * @brief:  设置分辨率改变通知回调
 * @parm:   LONG nPort 播放通道号
 * @parm:   fImageSizeChangeCallBack pProc 分辨率发生改变时通知用户的回调函数
 * @parm:   LONG nUser 用户数据
 * @return: TRUE -- 成功  FALSE -- 失败
 * @note:   不推荐与PLAY_SDK_SetImageSizeChangeMsg同时使用
 */
/*
* @func: PLAY_SDK_SetImageSizeChangeCallBack
* @brief: Set resolution change notification callback
* @parm: LONG nPort playback channel number
* @parm: fImageSizeChangeCallBack pProc Callback function to notify the user when the resolution changes
* @parm: LONG nUser user data
* @return: TRUE -- success FALSE -- failed
* @note: Not recommended for use with PLAY_SDK_SetImageSizeChangeMsg
*/
public delegate void fImageSizeChangeCallBack(int nPort,			//播放通道号 Play channel number
                                                  int nUser);			//用户数据 User data
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetImageSizeChangeCallBack(int nPort,fImageSizeChangeCallBack pProc,int nUser);

/*
 * @func:   PLAY_SDK_SetImageSizeChangeMsg
 * @brief:  设置分辨改变通知消息
 * @parm:   LONG nPort 播放通道号
 * @parm:   HWND hWnd 消息发送的窗口
 * @parm:   UINT nMsg 用户输入的消息；当设置解码时编码格式发生改变时要发送
			此定义的消息。消息函数中的wParam 参数值是返回nPort的值
 * @return: TRUE -- 成功  FALSE -- 失败
 * @note:   回调与消息不能同时使用
 */
/*
* @func: PLAY_SDK_SetImageSizeChangeMsg
* @brief: Set resolution change notification message
* @parm: LONG nPort playback channel number
* @parm: HWND hWnd message sending window
* @parm: UINT nMsg User input message; send when the encoding format changes when setting decoding
This defined message. The value of the wParam parameter in the message function is the value that returns nPort
* @return: TRUE -- success FALSE -- failed
* @note: Callbacks and messages cannot be used at the same time
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetImageSizeChangeMsg(int nPort,IntPtr hWnd,uint nMsg);

/*
 * @func:   PLAY_SDK_SetColor
 * @brief:  设置视频的图像参数, 即刻起作用
 * @parm:   LONG nPort 播放通道号
 * @parm:   DWORD nRegionNum   显示区域，参考PlayM4_SetDisplayRegion；如果只有一个显示区域(通常情况)设为0
 * @parm:   LONG nBrightness   亮度,默认64, 范围0-128
 * @parm:   LONG nContrast     对比度,默认64, 范围0-128
 * @parm:   LONG nSaturation   饱和度,默认64,范围0-128
 * @parm:   LONG nHue          色调,默认64, 范围0-128
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetColor
* @brief: Set the image parameters of the video to work immediately
* @parm: LONG nPort playback channel number
* @parm: DWORD nRegionNum display area, refer to PlayM4_SetDisplayRegion; if only one display area (normal case) is set to 0
* @parm: LONG nBrightness brightness, default 64, range 0-128
* @parm: LONG nContrast Contrast, default 64, range 0-128
* @parm: LONG nSaturation Saturation, default 64, range 0-128
* @parm: LONG nHue Tone, default 64, range 0-128
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetColor(int nPort, int nRegionNum, int nBrightness, int nContrast, int nSaturation, int nHue);

/*
 * @func:   PLAY_SDK_GetColor
 * @brief:  获取当前视频图像的参数信息
 * @parm[in] :   LONG nPort			播放通道号
 * @parm[in] :   DWORD nRegionNum	显示区域
 * @parm[out]:   LONG* pBrightness  亮度
 * @parm[out]:   LONG* pContrast    对比度
 * @parm[out]:   LONG* pSaturation  饱和度
 * @parm[out]:   LONG* pHue         色调
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_GetColor
* @brief: Get the parameter information of the current video image
* @parm[in] : LONG nPort playback channel number
* @parm[in] : DWORD nRegionNum display area
* @parm[out]: LONG* pBrightness brightness
* @parm[out]: LONG* pContrast contrast
* @parm[out]: LONG* pSaturation saturation
* @parm[out]: LONG* pHue tone
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_GetColor(int nPort, uint nRegionNum, ref int pBrightness, ref int pContrast, ref int pSaturation, ref int pHue);

/*
 * @func:   PLAY_SDK_SetMDRange
 * @brief:  设置动检区域及范围
 * @parm:   LONG nPort 播放通道号
 * @parm[in]:   RECT* rc 动态检测的区域
 * @parm:   DWORD nVauleBegin  搜索范围上限，可以是时间或帧号，具体取决于nType
 * @parm:   DWORD nValueEnd    搜索范围下限，可以是时间或帧号，具体取决于nType
 * @parm:   DWORD nType        见【定位类型宏定义】
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetMDRange
* @brief: Set the motion detection area and range
* @parm: LONG nPort playback channel number
* @parm[in]: RECT* rc dynamically detected area
* @parm: DWORD nVauleBegin The upper limit of the search range, which can be the time or frame number, depending on the nType
* @parm: DWORD nValueEnd The lower limit of the search range, which can be the time or frame number, depending on the nType
* @parm: DWORD nType See [Location Type Macro Definition]
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetMDRange(int nPort,ref RECT rc,uint nVauleBegin,uint nValueEnd,uint nType);

/*
 * @func:   PLAY_SDK_SetMDThreShold
 * @brief:  设置动态检测搜索的阀值
 * @parm:   LONG nPort      播放通道号
 * @parm:   DWORD ThreShold 阈值 取值范围[0, 255]
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetMDThreShold
* @brief: Set the threshold for dynamic detection search
* @parm: LONG nPort playback channel number
* @parm: DWORD ThreShold Threshold Range [0, 255]
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_SetMDThreShold(int nPort, uint ThreShold);

/*
 * @func:   PLAY_SDK_GetMDPosition
 * @brief:  获得搜索到的动检帧的帧序号
 * @parm:   LONG nPort      播放通道号
 * @parm:   DWORD Direction 搜索方向, 0 -- 向前搜索, 1 -- 向后搜索
 * @parm:   DWORD nFrame    参考帧
 * @parm:   DWORD* MDValue  搜索到的动检帧的阀值
 * @return: 搜索到的动检帧的帧序号
 */
/*
* @func: PLAY_SDK_GetMDPosition
* @brief: Get the frame number of the searched motion check frame
* @parm: LONG nPort playback channel number
* @parm: DWORD Direction search direction, 0 -- forward search, 1 -- backward search
* @parm: DWORD nFrame reference frame
* @parm: DWORD* MDValue Searched for the threshold of the motion check frame
* @return: Frame number of the searched motion frame
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_GetMDPosition(int nPort, uint Direction, uint nFrame,ref uint MDValue) ;

/*
 * @func:   PLAY_SDK_CatchPic
 * @brief:  抓图
 * @parm:   LONG nPort		  播放通道号
 * @parm:   LPCSTR sFileName  图片保存的名字
 * @parm:   int    Pictype    图片保存的类型 0:jpeg 1:bmp
 * @return: TRUE -- 成功  FALSE -- 失败
 * @note:   PLAY_SDK_SetDisplayCallBack设置的视频数据回调函数,只有在有视频数据解码出来时才调用,
 *			并由用户处理视频数据(如抓图)，如果不断有解码的数据,就不断调用这个回调函数,当然也就耗资源。
 *			而PLAY_SDK_CatchPic一次只抓一幅图，并能在暂停和单帧播放时实现抓图。
 *			建议:如果用户想实现抓图(一次抓一幅图),调用PLAY_SDK_CatchPic,
 *			而如果想得到一段时间内的视频数据，调用PLAY_SDK_SetDisplayCallBack
 */
/*
* @func: PLAY_SDK_CatchPic
* @brief: Capture
* @parm: LONG nPort playback channel number
* @parm: LPCSTR sFileName name saved in the picture
* @parm: int Pictype Image save type 0:jpeg 1:bmp
* @return: TRUE -- success FALSE -- failed
* @note: The video data callback function set by PLAY_SDK_SetDisplayCallBack is called only when there is video data decoded.
* And the user processes the video data (such as the capture). If there is continuous decoding data, the callback function is called continuously, which of course consumes resources.
* PLAY_SDK_CatchPic only captures one picture at a time, and can capture images during pause and single frame playback.
* Suggestion: If the user wants to capture the picture (once one picture at a time), call PLAY_SDK_CatchPic,
* If you want to get video data for a while, call PLAY_SDK_SetDisplayCallBack
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_CatchPic(int nPort, string sFileName, int Pictype) ;

/*
 * @func:   PLAY_SDK_StartDataRecord
 * @brief:  开始流数据录像, 只对流模式有用, 在调用PLAY_SDK_Play之后才能调用
 * @parm:   LONG nPort			播放通道号
 * @parm:   LPCSTR sFileName	录像文件保存名称
 * @parm:   LONG nType			保存的文件类型, 见文件类型枚举定义		
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_StartDataRecord
* @brief: Start streaming data recording, only useful for streaming mode, can be called after calling PLAY_SDK_Play
* @parm: LONG nPort playback channel number
* @parm: LPCSTR sFileName Record file save name
* @parm: LONG nType The type of file saved, see file type enumeration definition
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_StartDataRecord(int nPort,  string sFileName, int nType);

[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_StartDataRecord_V2(int nPort, string sFileName, ref Videofilehdr pHeader);

/*
 * @func:   PLAY_SDK_StopDataRecord
 * @brief:  停止录像
 * @parm:   LONG nPort  播放通道号
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_StopDataRecord
* @brief: Stop recording
* @parm: LONG nPort playback channel number
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_StopDataRecord(int nPort);

/*
 * @func:   PLAY_SDK_AdjustFluency
 * @brief:  调整视频播放的流畅性, 即刻起作用
 * @parm:   LONG nPort 播放通道号
 * @parm:   int level 调整图象播放的流畅性。流畅性和实时性是一对平衡体。当level为0时,
 *			图象最流畅; 当level为6时,图象实时性最好。Level的默认值为3。
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_AdjustFluency
* @brief: Adjust the smoothness of video playback, instantly
* @parm: LONG nPort playback channel number
* @parm: int level Adjusts the smoothness of image playback. Fluency and real-time are a pair of balances. When level is 0,
* The image is the smoothest; when the level is 6, the image is the best in real time. The default value of Level is 3.
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_AdjustFluency(int nPort, int level);

/*
 * @func:   PLAY_SDK_SetPlayFPS
 * @brief:  改变视频播放的帧率 
 * @parm:   LONG nPort 播放通道号
 * @parm:   LONG nFPS  取值[0, 250]
 * @return: PLAY_SDK_API BOOL 	CALLMETHOD
 */
       /*
  * @func: PLAY_SDK_SetPlayFPS
  * @brief: Change the frame rate of video playback
  * @parm: LONG nPort playback channel number
  * @parm: LONG nFPS value [0, 250]
  * @return: PLAY_SDK_API BOOL CALLMETHOD
  */
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_SetPlayFPS(int nPort, int nFPS);

/*
 * @func:   PLAY_SDK_GetPlayFPS
 * @brief:  得到当前码流中编码时的帧率
 * @parm:   LONG nPort  播放通道号
 * @return: 当前码流中当前编码帧率 注意： 如果码流中的帧率小于1，则返回0
 */
/*
* @func: PLAY_SDK_GetPlayFPS
* @brief: Get the frame rate when encoding in the current stream
* @parm: LONG nPort playback channel number
* @return: Current encoding frame rate in the current stream Note: If the frame rate in the stream is less than 1, then return 0
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_GetPlayFPS(int nPort);

/*
 * @func:   PLAY_SDK_SetDemuxCallBack
 * @brief:  设置源数据分析完的数据回调
 * @parm:   LONG nPort   播放通道号
 * @parm:   fDemuxCallBack pProc  分析数据回调函数指针
 * @parm:   LONG nUser   用户自定义参数
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_SetDemuxCallBack
* @brief: Set the data callback analysis of the source data
* @parm: LONG nPort playback channel number
* @parm: fDemuxCallBack pProc analysis data callback function pointer
* @parm: LONG nUser user-defined parameter
* @return: TRUE -- success FALSE -- failed
*/
public delegate void fDemuxCallBack(int nPort,						//播放通道号
										ref PLAY_SDK_VIDEO_FRAME_INFO pFrameInfo,	//视频帧信息地址
										int nUser);					//用户数据 
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern bool	PLAY_SDK_SetDemuxCallBack(int nPort, fDemuxCallBack pProc, int nUser);

/*
 * @func:   PLAY_SDK_StartAudioCapture
 * @brief:  打开音频采集功能
 * @parm:   fAudioCaptureCallBack pProc  音频采集回调函数，当采集到音频数据时该函数将被调用
 * @parm:   LONG nBitsPerSample  采样位深度
 * @parm:   LONG nSamplesPerSec  采样率
 * @parm:   LONG nLength         音频数据包长度
 * @parm:   LONG nUser			 自定义参数
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_StartAudioCapture
* @brief: Turn on audio capture
* @parm: fAudioCaptureCallBack pProc audio capture callback function, this function will be called when audio data is collected
* @parm: LONG nBitsPerSample Sample bit depth
* @parm: LONG nSamplesPerSec sample rate
* @parm: LONG nLength audio packet length
* @parm: LONG nUser custom parameters
* @return: TRUE -- success FALSE -- failed
*/
public delegate void fAudioCaptureCallBack(ref byte pDataBuffer,		//音频数据 Audio data
                                               int DataLength,		//数据长度 Data length
                                               int nUser);				//用户数据 User data
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern bool	PLAY_SDK_StartAudioCapture(fAudioCaptureCallBack pProc, int nBitsPerSample, int nSamplesPerSec, int nLength, int nUser);

/*
 * @func:   PLAY_SDK_StopAudioCapture
 * @brief:  关闭音频采集功能
 * @parm:   无
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_StopAudioCapture
* @brief: Turn off audio capture
* @parm: none
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int 	PLAY_SDK_StopAudioCapture();

/*
 * @func:   PLAY_SDK_GetPort
 * @brief:  获取未使用的通道号
 * @parm[out]:   LONG * nPort, 未使用的通道号, 上限为FUNC_MAX_PORT
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
  * @func: PLAY_SDK_GetPort
  * @brief: Get unused channel number
  * @parm[out]: LONG * nPort, unused channel number, upper limit is FUNC_MAX_PORT
  * @return: TRUE -- success FALSE -- failed
  */
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern bool	PLAY_SDK_GetPort(ref int nPort);

/*
 * @func:   PLAY_SDK_FreePort
 * @brief:  释放已使用的通道号, 释放成功后，最好将nPort 置为-1
 * @parm:   LONG nPort 要释放的通道号
 * @return: TRUE -- 成功  FALSE -- 失败
 */
/*
* @func: PLAY_SDK_FreePort
* @brief: Release the used channel number. After the release is successful, it is best to set nPort to -1.
* @parm: LONG nPort channel number to be released
* @return: TRUE -- success FALSE -- failed
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int	PLAY_SDK_FreePort(int nPort);

/*
 * @func:   PLAY_SDK_GetColorKey
 * @brief:  获取OVERLAY 关键色
 * @parm:   LONG nPort 播放通道号
 * @return: OVERLAY 关键色
 */
/*
* @func: PLAY_SDK_GetColorKey
* @brief: Get OVERLAY key color
* @parm: LONG nPort playback channel number
* @return: OVERLAY key color
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern  uint 	PLAY_SDK_GetColorKey(int nPort);

/*
 * @func:   PLAY_SDK_GetFileHeadLength
 * @brief:  得到当前版本播放库能播放的文件的文件头长度, 主要应用在流播放器的
			PLAY_SDK_STREAME_FILE 模式下。以便读出文件头作为Play_SDK_OpenStream()的输入参数
 * @parm:   无
 * @return: PLAY_SDK_API LONG	CALLMETHOD
 */
/*
  * @func: PLAY_SDK_GetFileHeadLength
  * @brief: Get the file header length of the file that the current version of the playback library can play, mainly used in streaming players.
In PLAY_SDK_STREAME_FILE mode. In order to read the file header as an input parameter of Play_SDK_OpenStream()
  * @parm: none
  * @return: PLAY_SDK_API LONG CALLMETHOD
  */
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int PLAY_SDK_GetFileHeadLength();

/*
 * @func:   PLAY_SDK_GetCurTimeStamp
 * @brief:  获取当前播放帧的时间戳 单位: 秒(s)
 * @parm:   LONG nPort  播放通道号
 * @return: 当前播放帧的时间戳
 */
/*
* @func: PLAY_SDK_GetCurTimeStamp
* @brief: Get the timestamp of the current playback frame Unit: Seconds (s)
* @parm: LONG nPort playback channel number
* @return: timestamp of the current playback frame
*/
 [DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern Int64  PLAY_SDK_GetCurTimeStamp(int nPort);

/*
 * @func:   PLAY_SDK_SetOsdTex
 * @brief:  设置osd叠加信息,必须在openstream后，play之前设置，否则无效
 * @parm:   LONG nPort  播放通道号
 * @parm:   OSD_INFO_TXT* txt 叠加的文本信息
 * @return: 返回osd叠加索引
 */
 /*
* @func: PLAY_SDK_SetOsdTex
* @brief: Set osd overlay information, must be set after openstream, before play, otherwise invalid
* @parm: LONG nPort playback channel number
* @parm: OSD_INFO_TXT* txt superimposed text information
* @return: return osd overlay index
*/

[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int PLAY_SDK_SetOsdTex(int nPort,ref PLAY_SDK_OSD_INFO_TXT txt);

/*
 * @func:   PLAY_SDK_DeleteOsdTex
 * @brief:  删除osd叠加信息,nIndex是PLAY_SDK_SetOsdTex的返回值
 * @parm:   LONG nPort 播放通道号
 * @parm:   int nIndex osd叠加索引
 * @return: PLAY_SDK_API int	CALLMETHOD
 */
/*
* @func: PLAY_SDK_DeleteOsdTex
* @brief: Delete osd overlay information, nIndex is the return value of PLAY_SDK_SetOsdTex
* @parm: LONG nPort playback channel number
* @parm: int nIndex osd overlay index
* @return: PLAY_SDK_API int CALLMETHOD
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int PLAY_SDK_DeleteOsdTex(int nPort, int nIndex);

/*
 * @func:   PLAY_SDK_ConvertFile
 * @brief:  H264录像文件转Avi录像文件
 * @parm:   const char* pSourceFile 源文件
 * @parm:   const char* pDestFile	目标文件
 * @parm:   LONG nType              
 * @parm:   fCoverFileCallBack coverPosCallback 转码回调函数
 * @parm:   DWORD dwUser			用户自定义参数
 * @return: PLAY_SDK_API int	CALLMETHOD
 */
/*
* @func: PLAY_SDK_ConvertFile
* @brief: H264 video file to Avi video file
* @parm: const char* pSourceFile source file
* @parm: const char* pDestFile object file
* @parm: LONG nType
* @parm: fCoverFileCallBack coverPosCallback transcode callback function
* @parm: DWORD dwUser user-defined parameter
* @return: PLAY_SDK_API int CALLMETHOD
*/
public delegate void fCoverFileCallBack(int CurrentPos,			//当前的帧序, 或者说进度 Current frame order, or progress
                                             int TotoalPos,			//总的帧数 Total number of frames
                                             int dwUser);				//用户自定义数据 User-defined data
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int PLAY_SDK_ConvertFile(string pSourceFile,string pDestFile,  int nType, fCoverFileCallBack coverPosCallback, int dwUser);

/*
 * @func:   PLAY_SDK_QueryInfo
 * @brief:  查询信息
 * @parm:   LONG nPort		播放通道号
 * @parm:   int cmdType		查询命令类型
 * @parm:   char * buf		结果存放缓冲区
 * @parm:   int buflen		缓冲区长度
 * @parm:   int * returnlen 返回的结果长度
 * @return: PLAY_SDK_API BOOL CALLMETHOD
 */
/*
* @func: PLAY_SDK_QueryInfo
* @brief: Query information
* @parm: LONG nPort playback channel number
* @parm: int cmdType query command type
* @parm: char * buf result storage buffer
* @parm: int buflen buffer length
* @parm: int * returnlen returned result length
* @return: PLAY_SDK_API BOOL CALLMETHOD
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int PLAY_SDK_QueryInfo(int nPort, int cmdType, string buf, int buflen, ref int returnlen);

/*
 *  @func:    	 PLAY_SDK_ChangeWnd
 *  @brief:   	 切换播放通道的播放窗口
 *  @param[in]:  LONG nPort  播放通道号
 *  @param[in]:  HWND hWnd   窗口句柄
 *  @return:  	 BOOL TRUE -- 切换成功 -- FALSE -- 切换失败
 *  @note:    	 none   
 */
/*
* @func: PLAY_SDK_ChangeWnd
* @brief: Switch the playback window of the playback channel
* @param[in]: LONG nPort playback channel number
* @param[in]: HWND hWnd window handle
* @return: BOOL TRUE -- Switch successful -- FALSE -- Switch failed
* @note: none
*/
[DllImport(@"..\bin\PlaySdkModule.dll")]
 public static extern int PLAY_SDK_ChangeWnd(int nPort, IntPtr hWnd);

    }
}
