public override bool StartPreview(CameraInfo camera, VideoControl vc, int StreamIndex = 0)
        {
            VideoSourceInfo videoSourceInfo = camera.VideoSourceInfo;
            int             loginID         = Hik_Open8200API.GetLoginID(videoSourceInfo.IP, (int)videoSourceInfo.Port, videoSourceInfo.User, videoSourceInfo.Password);

            if (loginID == -1)
            {
                string error = Hik_Open8200API.GetLastError();
                this.LogModule.Error($"初始化登录服务器失败, 错误码:{error}, 设备{videoSourceInfo.IP}:{videoSourceInfo.Port} ");
                return(false);
            }

            int playHandle = Hik_Open8200API.Std_StartRealPlay(loginID, camera.CameraCode, vc.VControl.Handle, StreamIndex, null, IntPtr.Zero);

            if (playHandle < 0)
            {
                string error = Hik_Open8200API.GetLastError();
                Hik_Open8200API.Std_StopRealPlay(playHandle);
                vc.VControl.Refresh();
                this.LogModule.Error($"打开图像失败: 错误码:{error}, 摄像机标识: {camera.CameraCode}");
                Hik_Open8200API.Std_StopRealPlay(playHandle);
                return(false);
            }

            ControlInfo_Preview cm = new ControlInfo_Preview()
            {
                LoginHandle = loginID, Camera = camera, PlayHandle = playHandle, VideoSource = videoSourceInfo, VC = vc, StreamIndex = StreamIndex
            };

            this.m_ControlTable[vc] = cm;
            return(true);
        }
        public override bool Ptz_DirCamera(VideoControl vc, PTZ.DirDirection dirDirection, int hSpeed, int vSpeed)
        {
            ControlInfo_Preview info = this.m_ControlTable[vc] as ControlInfo_Preview;

            if (info == null)
            {
                return(false);
            }

            int    hspeed = hSpeed * 64 / 256;
            int    vspeed = vSpeed * 64 / 256;
            string ptzCmd = "";

            PTZ.DirDirection d = dirDirection;
            if (d == PTZ.DirDirection.Stop)
            {
                d = (PTZ.DirDirection)info.LastDirection;
            }
            switch (d)
            {
            case PTZ.DirDirection.Left:
                ptzCmd = "LEFT";
                break;

            case PTZ.DirDirection.Right:
                ptzCmd = "RIGHT";
                break;

            case PTZ.DirDirection.Down:
                ptzCmd = "DOWN";
                break;

            case PTZ.DirDirection.Up:
                ptzCmd = "UP";
                break;

            case PTZ.DirDirection.LeftUp:
                ptzCmd = "LEFT_UP";
                break;

            case PTZ.DirDirection.LeftDown:
                ptzCmd = "LEFT_DOWN";
                break;

            case PTZ.DirDirection.RightUp:
                ptzCmd = "RIGHT_UP";
                break;

            case PTZ.DirDirection.RightDown:
                ptzCmd = "RIGHT_DOWN";
                break;
            }
            if (dirDirection == PTZ.DirDirection.Stop)
            {
                ptzCmd += "_STOP";
            }
            info.LastDirection = (int)dirDirection;

            return(Hik_Open8200API.Std_PtzCtrl((int)info.LoginHandle, info.Camera.CameraCode, ptzCmd, hspeed, 0, 0) >= 0 ? true : false);
        }
        public override bool OpenSound(VideoControl vc)
        {
            ControlInfo_Preview info = this.m_ControlTable[vc] as ControlInfo_Preview;

            if (info == null)
            {
                return(false);
            }

            return(Hik_Open8200API.Std_OpenSound((int)info.PlayHandle) >= 0 ? true : false);
        }
        public override void StopPreview(VideoControl vc)
        {
            ControlInfo_Preview info = this.m_ControlTable[vc] as ControlInfo_Preview;

            if (info == null)
            {
                return;
            }
            bool ret = Hik_Open8200API.Std_StopRealPlay((int)info.PlayHandle) >= 0 ? true : false;

            vc.VControl.Refresh();
            return;
        }
        public override bool Snap(VideoControl vc, string fileName, string ext = "jpg")
        {
            ControlInfo_Preview info = this.m_ControlTable[vc] as ControlInfo_Preview;

            if (info == null)
            {
                return(false);
            }
            if (fileName.EndsWith(".jpg") == true)
            {
                fileName = fileName.Replace(".jpg", "");
            }
            IntPtr pFileName = Hik_Open8200API.GetUTF8StringPtr(fileName);
            int    ret       = Hik_Open8200API.Std_Capture2((int)info.PlayHandle, pFileName, 0);

            Marshal.FreeHGlobal(pFileName);
            return(ret >= 0 ? true : false);
        }
        public override bool PTZ_CameraAutoFindDirection(VideoControl vc, int oldWidth, int oldHeight, int newX, int newY, int newWidth, int newHeight)
        {
            ControlInfo_Preview info = this.m_ControlTable[vc] as ControlInfo_Preview;

            if (info == null)
            {
                return(false);
            }
            int height = 288, width = 352;
            //HikPlayAPI.PlayM4_GetPictureSize(cm.PlayHandle, ref width, ref height);
            int xTop    = width * newX / oldWidth;
            int yTop    = height * newY / oldHeight;
            int xBottom = width * (newX + newWidth) / oldWidth;
            int yBottom = height * (newY + newHeight) / oldHeight;

            Hik_Open8200API.Std_PtzCtrl3D((int)info.LoginHandle, info.Camera.CameraCode, xTop, yTop, xBottom, yBottom, 4);
            return(true);
        }
        public override bool Ptz_LenCamera(VideoControl vc, PTZ.LenType lenType)
        {
            ControlInfo_Preview info = this.m_ControlTable[vc] as ControlInfo_Preview;

            if (info == null)
            {
                return(false);
            }


            string ptzCmd = "";

            PTZ.LenType d = lenType;
            if (d == PTZ.LenType.Stop)
            {
                d = (PTZ.LenType)info.LastLenType;
            }
            switch (d)
            {
            case PTZ.LenType.LensTele:
                ptzCmd = "ZOOMIN";
                break;

            case PTZ.LenType.LensWide:
                ptzCmd = "ZOOMOUT";
                break;

            default:
                break;
            }
            if (lenType == PTZ.LenType.Stop)
            {
                ptzCmd += "_STOP";
            }
            info.LastLenType = (int)lenType;

            return(Hik_Open8200API.Std_PtzCtrl((int)info.LoginHandle, info.Camera.CameraCode, ptzCmd, 49, 0, 0) >= 0 ? true : false);
        }