Ejemplo n.º 1
0
        public int ConnectRealPlay(ref DEV_INFO pDev, int nChannel)
        {
            H264_DVR_CLIENTINFO playstru = new H264_DVR_CLIENTINFO();

            playstru.nChannel = nChannel;
            playstru.nStream  = 0;
            playstru.nMode    = 0;
            playstru.hWnd     = this.Handle;
            m_iPlayhandle     = XMSDK.H264_DVR_RealPlay(pDev.lLoginID, ref playstru);

            return(m_iPlayhandle);
        }
Ejemplo n.º 2
0
        // Reconnect to camera
        public void ReConnect(object source, System.Timers.ElapsedEventArgs e)
        {
            foreach (DEV_INFO devinfo in dictDiscontDev.Values)
            {
                H264_DVR_DEVICEINFO OutDev = new H264_DVR_DEVICEINFO();
                int nError = 0; // DVR out parameter

                // Login to camera
                int lLogin = XMSDK.H264_DVR_Login(devinfo.szIpaddress, (ushort)devinfo.nPort, devinfo.szUserName, devinfo.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET);

                // If login info is invalid
                if (lLogin <= 0)
                {
                    // Error messages
                    int nErr = XMSDK.H264_DVR_GetLastError();
                    if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID)
                    {
                        MessageBox.Show("Password Error");
                    }
                    else if (nErr == (int)SDK_RET_CODE.H264_DVR_LOGIN_USER_NOEXIST)
                    {
                        MessageBox.Show("User Not Exist");
                    }

                    return;
                }
                dictDiscontDev.Remove(devinfo.lLoginID);    // Remove disconnected device from dictionary

                LoginForm loginForm = new LoginForm();

                DEV_INFO devAdd = new DEV_INFO();
                devAdd          = devinfo;
                devAdd.lLoginID = lLogin;

                // Connect to video feed
                loginForm.m_videoform.ConnectRealPlay(ref devAdd, 0);
                Thread.Sleep(10);

                dictDevInfo.Add(lLogin, devAdd);       // Add connected device to dictionary
                XMSDK.H264_DVR_SetupAlarmChan(lLogin); // Subscribe to alarm message
            }

            // If there is no record of any disconnected devices, cease the reconnect attempt
            if (0 == dictDiscontDev.Count)
            {
                timerDisconnect.Enabled = false;
                timerDisconnect.Stop();
            }
        }