Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
0
        // Connect to device and display video feed
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (textBoxDevName.Text.Trim() != "" &&
                textBoxIP.Text.Trim() != "" &&
                textBoxport.Text.Trim() != "" &&
                textBoxUsername.Text.Trim() != "")
            {
                H264_DVR_DEVICEINFO dvrdevInfo = new H264_DVR_DEVICEINFO();
                int nError;
                int nLoginID = XMSDK.H264_DVR_Login(textBoxIP.Text.Trim(), ushort.Parse(textBoxport.Text.Trim()), textBoxUsername.Text, textBoxPassword.Text, out dvrdevInfo, out nError, SocketStyle.TCPSOCKET);

                if (nLoginID > 0)
                {
                    LoginForm loginForm = new LoginForm();
                    PTZForm   ptzForm   = new PTZForm(this, nLoginID);
                    m_videoform.Show();
                    ptzForm.Show();
                    // this.Close();

                    // Save device info into dictionary
                    devInfo.szDevName     = textBoxDevName.Text;
                    devInfo.lLoginID      = nLoginID;
                    devInfo.nPort         = Int32.Parse(textBoxport.Text.Trim());
                    devInfo.szIpaddress   = textBoxIP.Text.Trim();
                    devInfo.szUserName    = textBoxUsername.Text;
                    devInfo.szPsw         = textBoxPassword.Text;
                    devInfo.NetDeviceInfo = dvrdevInfo;
                    dictDevInfo.Add(devInfo.lLoginID, devInfo);
                    XMSDK.H264_DVR_SetupAlarmChan(nLoginID);
                    m_videoform.ConnectRealPlay(ref devInfo, 0);
                }
                else
                {
                    MessageBox.Show("Invalid Login Info!");
                }
            }
            else
            {
                MessageBox.Show("Please input all data!");
            }
        }
Ejemplo n.º 3
0
 public static extern Int32 H264_DVR_Login(StringBuilder sDVRIP, ushort wDVRPort, StringBuilder sUserName, StringBuilder sPassword,
                                           out H264_DVR_DEVICEINFO lpDeviceInfo, out short error, SocketStyle socketstyle);
Ejemplo n.º 4
0
 public static extern Int32 H264_DVR_Login(string sDVRIP, ushort wDVRPort, string sUserName, string sPassword,
                                           out H264_DVR_DEVICEINFO lpDeviceInfo, out int error, SocketStyle socketstyle);