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

namespace CSharpPlayerDemo
{
    public partial class CLS_PlaySDK
    {
        //发送消息API
        [DllImport("User32.dll")]
        private static extern bool PostMessage(IntPtr _hWnd, Int32 _msg, Int32 _wParam, Int32 _lParam);
        //系统创建与释放
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_CreateSystem(IntPtr _hWnd);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_DeleteSystem();

        //创建和关闭播放实例
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_CreatePlayerFromFile(IntPtr _hWnd, String _pcFileName, Int32 _iDownloadBufSz,
            Int32 _iFileTrueSz, ref Int32 _piNowSz, Int32 _iLastFrmNo, ref Int32 _piCompleteFlag);
        //IntPtr形式
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_CreatePlayerFromFile(IntPtr _hWnd, String _pcFileName, Int32 _iDownloadBufSz,
            Int32 _iFileTrueSz, IntPtr _piNowSz, Int32 _iLastFrmNo, IntPtr _piCompleteFlag);

        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_DeletePlayer(Int32 _iID);


        //注册消息和回调
        [DllImport("PlaySdkM4.dll")]
        private static extern void TC_RegisterEventMsg(IntPtr _hEventWnd, UInt32 _uiEventMsg);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_RegisterNotifyPlayToEnd(delegatePlayEndFun _PlayEndFun);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_RegisterNotifyGetDecAV(Int32 _iID,IntPtr _GetDecAVCbk,bool _blDisplay);

        //播放控制
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_Play(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_Pause(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_Stop(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_FastForward(Int32 _iID, Int32 _iSpeed);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_FastBackward(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GoBegin(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GoEnd(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_PlayAudio(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_StopAudio(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_Seek(Int32 _iID, Int32 _iFrameNO);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_SeekEx(Int32 _iID, Int32 _iFrameNo);//按帧精确定位，速度比TC_Seek快
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_SetAudioVolumn(UInt16 _ustVolumn);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_SetPlayRect(Int32 _iID,ref RECT _pDrawRect);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_SetPlayRectEx(Int32 _iID,ref RECT _pDrawRect,Int32 _dwMask);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_SlowForward(Int32 _iID, Int32 _iSpeed);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_StepBackward(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_StepForward(Int32 _iID);

       //获取播放信息
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GetBeginEnd(Int32 _iID, ref Int32 _piBegin, ref Int32 _piEnd);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GetFileName(Int32 _iID, String _pcFileName);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GetFrameCount(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GetFrameRate(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GetPlayingFrameNum(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GetPlayTime(Int32 _iID);//单位ms,得到当前播放的时间
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GetVideoParam(Int32 _iID,IntPtr _pWidth, IntPtr _pHeight, 
            IntPtr _pFrameRate);
        //重载
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GetVideoParam(Int32 _iID, ref Int32 _pWidth, ref Int32 _pHeight,
            ref Int32 _pFrameRate);


        //抓拍
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_CaptureBmpPic(Int32 _iID, String _pcSaveFile);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_CapturePic(Int32 _iID,[In,Out]Byte[] _ppucYUV);

        //流播放
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_PutStreamToPlayer(Int32 _iID, Byte[] _pucStreamData, Int32 _iSize);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_CreatePlayerFromStreamEx(IntPtr _hWnd, Byte[] _pucVideoHeadBuf, 
            Int32 _iHeadSize, Int32 _iStreamBufferSize);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_CreatePlayerFromStream(IntPtr _hWnd, Byte[] _pucVideoHeadBuf, 
            Int32 _iHeadSize);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_CleanStreamBuffer(Int32 _iID);

        //电子放大
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_SetEZoom(Int32 _iID, Int32 _iZoomID, RECT _pRectInVideo);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_ResetEZoom(Int32 _iID, Int32 _iZoomID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_AddEZoom(Int32 _iID, IntPtr _hWnd, ref RECT _rcZoom, Int32 _iCount);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_RemoveEZoom(Int32 _iID, Int32 _iZoomID);


        //CPU监控
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_StartMonitorCPU();
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_StopMonitorCPU();

        //视频文件编辑
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_VECleanup();
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_VEAbort();
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_SegmentToFile(String _pcSaveFile,String _pcSourceFile,
            Int32 _iBeginFrmNo,Int32 _iEndFrmNo);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_RemoveAudio(String _pcSaveFile, String _pcSourceFile,
            Int32 _iBeginFrmNo, Int32 _iEndFrmNo);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_RegisterVECallBack(IntPtr _VECallBack);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_Locate(Int32 _iID, ref Int32 _piFrameNo);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GetVEState(ref Int32 _piState, ref Int32 _piProgress);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_Combine(String _pcSaveFile, String _pcSource1,
            Int32 _iBeginFrmNo1, Int32 _iEndFrmNo1, String _pcSource2, Int32 _iBeginFrmNo2, Int32 _iEndFrmNo2);

        //版本信息
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_GetVersion(ref SDK_VERSION _pVer);

        //VoD播放控制
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_CreatePlayerFromVoD(IntPtr _hWnd, Byte[] _pucVideoHeadBuf, Int32 _iHeadSize);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_SetVoDPlayerOver(Int32 _iID);
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_SetCleanVoDBuffer(Int32 _iID);

        //画框
        [DllImport("PlaySdkM4.dll")]
        private static extern Int32 TC_DrawRect(Int32 _iID, ref RECT _rcDraw, Int32 _iCount);
    }
}
