public bool StartVideo()
        {
            UInt32 iResult = 0;

            videoRes = new SDK_HuaMai.OPEN_VIDEO_RES();
            iResult  = SDK_HuaMai.hm_pu_start_video(iOpenVideo, ref videoRes);
            if (Convert.ToUInt32(0) == iResult)
            {
                return(true);
            }
            return(false);
        }
Example #2
0
        public bool VideoPlay()
        {
            UInt32 iResult = 0;

            iResult = SDK_HuaMai.hm_server_find_device_by_sn(ProgParameter.HuaMai_iTree, CurrentVideoInfo.DVSAddress, ref iNode);
            if (iResult != ProgConstants.c_iHuaMaiSDK_Result_Success ||
                iNode == IntPtr.Zero)
            {
                //查询不到设备
                VideoPlayCallback(new VideoPlayCallbackValue {
                    evType = Enum_VideoPlayEventType.DeviceNotExist
                });
                return(false);
            }

            SDK_HuaMai._CONNECT_INFO config = new SDK_HuaMai._CONNECT_INFO();
            config.ct = SDK_HuaMai.CLIENT_TYPE.CT_PC;
            config.cp = SDK_HuaMai.CONNECT_PRI.CPI_DEF;
            config.cm = SDK_HuaMai.CONNECT_MODE.CM_DEF;
            iResult   = SDK_HuaMai.hm_pu_login_ex(iNode, ref config, ref iDev);
            if (iResult != ProgConstants.c_iHuaMaiSDK_Result_Success)
            {
                //登录设备失败
                VideoPlayCallback(new VideoPlayCallbackValue {
                    evType = Enum_VideoPlayEventType.DevLoginException
                });
                return(false);
            }

            SDK_HuaMai._OPEN_VIDEO_PARAM para = new SDK_HuaMai._OPEN_VIDEO_PARAM();
            para.channel = Convert.ToUInt32(CurrentCameraInfo.Channel) - 1;
            para.cs_type = SDK_HuaMai.CODE_STREAM.HMS_CS_MAJOR;
            IntPtr iUserData = Marshal.StringToHGlobalAnsi("123");

            para.data    = iUserData;
            para.vs_type = SDK_HuaMai.VIDEO_STREAM.HMS_VS_REAL;
            para.cb_data = new SDK_HuaMai.cb_pu_data(HuaMaiVideo_OnRecvRealTimeVideo);
            para.iWnd    = picPlayMain.Handle;
            iResult      = SDK_HuaMai.hm_pu_open_video(iDev, ref para, ref iOpenVideo);
            if (iResult != ProgConstants.c_iHuaMaiSDK_Result_Success)
            {
                //打开视频失败
                VideoPlayCallback(new VideoPlayCallbackValue {
                    evType = Enum_VideoPlayEventType.ConnFailed
                });
                return(false);
            }

            SDK_HuaMai.OPEN_VIDEO_RES videoRes = new SDK_HuaMai.OPEN_VIDEO_RES();
            iResult = SDK_HuaMai.hm_pu_start_video(iOpenVideo, ref videoRes);
            if (iResult != ProgConstants.c_iHuaMaiSDK_Result_Success)
            {
                //开始播放视频异常
                VideoPlayCallback(new VideoPlayCallbackValue {
                    evType = Enum_VideoPlayEventType.VideoPlayException
                });
                return(false);
            }
            SDK_HuaMai.DISPLAY_OPTION disp_op = new SDK_HuaMai.DISPLAY_OPTION();
            disp_op.dm = SDK_HuaMai.DISPLAY_MODE.HME_DM_DX;
            disp_op.pq = SDK_HuaMai.PIC_QUALITY.HME_PQ_HIGHT;
            //IntPtr iWnd = pictureBox1.Handle;
            iPort   = IntPtr.Zero;
            iResult = SDK_HuaMai.hm_video_display_open_port(this.intptrPlayMain, ref disp_op, ref iPort);
            iResult = SDK_HuaMai.hm_video_display_start(iPort, 0, 0, 25);
            VideoPlayCallback(new VideoPlayCallbackValue {
                evType = Enum_VideoPlayEventType.VideoPlay
            });
            VideoPlayState = Enum_VideoPlayState.InPlayState;
            return(true);
        }