Пример #1
0
        public void H264_DVR_Check_Device_Exist_V2Test()
        {
            int  iLogin    = -1;
            int  intResult = 0;
            bool bolResult = false;

            SDKState.XMSDK_Init();
            H264_DVR_DEVICEINFO OutDev;
            int       nError = 0;
            VideoInfo v      = TestDataSource.TestDataSource.XMDataSource2();

            SDK_XMSDK.SDK_SDevicesState state = new SDK_XMSDK.SDK_SDevicesState();
            state.nun          = 2;
            state.state        = new int[32];
            state.state[0]     = 1;
            state.state[1]     = 1;
            state.uuid         = new SDK_XMSDK.SDK_UUID[32];
            state.uuid[0].uuid = v.DVSAddress;
            state.uuid[1].uuid = "4bba3f71cdd143cb";
            IntPtr iUserData = Marshal.StringToHGlobalAnsi("hongdongcheng");

            SDK_XMSDK.OnFoundDevCB callBack = new SDK_XMSDK.OnFoundDevCB(OnFoundDevCB);
            Ezviz_gchMsgBack = GCHandle.Alloc(callBack);
            IntPtr iData = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDK_XMSDK.SDK_SDevicesState)));

            Marshal.StructureToPtr(state, iData, true);

            int intResut = SDK_XMSDK.H264_DVR_Check_Device_Exist_V2(ref iData, 3, callBack, iUserData);
            var result   = Marshal.PtrToStructure(iData, typeof(SDK_XMSDK.SDK_SDevicesState));

            SDK_XMSDK.SDK_SDevicesState A = (SDK_XMSDK.SDK_SDevicesState)result;
            int error = SDK_XMSDK.H264_DVR_GetLastError();

            iLogin = SDK_XMSDK.H264_DVR_Login_Cloud(v.DVSAddress, 34567, v.UserName, v.Password, out OutDev, out nError, "");

            //H264_DVR_CLIENTINFO playstru = new H264_DVR_CLIENTINFO();
            //playstru.nChannel = 0;
            //playstru.nStream = 0;
            //playstru.nMode = 1;
            //playstru.hWnd = IntPtr.Zero;
            //int m_iPlayhandle = SDK_XMSDK.H264_DVR_RealPlay(Convert.ToInt32(iLogin), ref playstru);
            bolResult = SDK_XMSDK.H264_DVR_PTZControlEx(iLogin, 0, Convert.ToInt32(SDK_XMSDK.PTZ_ControlType.EXTPTZ_POINT_MOVE_CONTROL), 1, 0, 0, false);
            SDK_XMSDK.H264_DVR_Logout(Convert.ToInt32(intResult));
            SDKState.XMSDK_Release();
            Assert.IsTrue(bolResult);
        }
Пример #2
0
        private void VideoRealPlay()
        {
            H264_DVR_CLIENTINFO playstru = new H264_DVR_CLIENTINFO();

            playstru.nChannel       = CurrentCameraInfo.Channel - 1;
            playstru.nStream        = 1;
            playstru.nMode          = 0;
            playstru.hWnd           = intptrPlayMain;
            bolRequestRealVideoFlag = true;
            int Temp_intCount = 0;

            while (bolRequestRealVideoFlag)
            {
                VideoPlayCallback(new VideoPlayCallbackValue {
                    evType = Enum_VideoPlayEventType.RequestConn
                });
                m_iPlayhandle = SDK_XMSDK.H264_DVR_RealPlay(Convert.ToInt32(lLogin), ref playstru);
                if (m_iPlayhandle > 0)
                {
                    CurrentVideoInfo.NetworkState = 1;//在线
                    VideoPlayState = Enum_VideoPlayState.InPlayState;
                    VideoPlayCallback(new VideoPlayCallbackValue {
                        evType = Enum_VideoPlayEventType.VideoPlay
                    });                                                                                          //开始播放
                    bolRequestRealVideoFlag = false;
                    if (CurrentVideoPlaySet.VideoRecordEnable)
                    {
                        XMVideo_VideoRecordStart(CurrentVideoPlaySet.VideoRecordFilePath);
                    }
                }
                else
                {
                    VideoPlayState = Enum_VideoPlayState.NotInPlayState;
                    int intResult = SDK_XMSDK.H264_DVR_GetLastError();
                    //视频播放异常,后期根据 H264_DVR_GetLastError 获取错误码进行操作及 提示
                    switch (intResult)
                    {
                    case (int)SDK_RET_CODE.H264_DVR_NATCONNET_REACHED_MAX:
                        VideoPlayCallback(new VideoPlayCallbackValue {
                            evType = Enum_VideoPlayEventType.ConnNumMax
                        });                                                                                               //达到最大连接数量
                        break;

                    case (int)SDK_RET_CODE.H264_DVR_INVALID_HANDLE:     //句柄错误
                        VideoPlayCallback(new VideoPlayCallbackValue {
                            evType = Enum_VideoPlayEventType.VideoPlayException, EventContent = intResult.ToString() + "句柄错误"
                        });                                                                                                                                                     //视频播放异常
                        //退出,重新登陆
                        //注意: 有可能是后台登陆成功后触发这个错误 重新调用登陆接口打开新线程进行登陆
                        //将重连播放的标签置为Flase 结束前一个登陆线程
                        int Temp_intResult = SDK_XMSDK.H264_DVR_Logout(lLogin);
                        CurrentVideoInfo.LoginHandle = -1;
                        CurrentVideoInfo.LoginState  = 0;
                        SDK_XMSDK.DeviceLogin(CurrentVideoInfo);
                        bolRequestRealVideoFlag = false;
                        break;

                    default:
                        VideoPlayCallback(new VideoPlayCallbackValue {
                            evType = Enum_VideoPlayEventType.VideoPlayException, EventContent = intResult.ToString()
                        });                                                                                                                                            //视频播放异常
                        break;
                    }
                    Thread.Sleep(2000);
                }
                if (Temp_intCount > c_intMaxRealPlayNum || m_iPlayhandle > 0)
                {
                    bolRequestRealVideoFlag = false;
                }
                Temp_intCount++;
            }
        }