コード例 #1
0
ファイル: Log.cs プロジェクト: Gordon-M/PTZCamera
        // Set Disconnect callback function. It is to callback disconnect device; excluding device logout successfully
        void DisConnectBackCallFunc(int lLoginID, string pchDVRIP, int nDVRPort, IntPtr dwUser)
        {
            if (lLoginID == m_videoform.GetLoginHandle())
            {
                m_videoform.OnDisconnect();
            }

            foreach (DEV_INFO devinfo in dictDevInfo.Values)
            {
                if (devinfo.lLoginID == lLoginID)
                {
                    XMSDK.H264_DVR_Logout(lLoginID);
                    dictDevInfo.Remove(devinfo.lLoginID);
                    dictDiscontDev.Add(devinfo.lLoginID, devinfo);
                    break;
                }
            }

            // If device is disconnected, activate the timer to reconnect
            if (dictDiscontDev.Count > 0)
            {
                timerDisconnect.Enabled = true; // Default value is true
                timerDisconnect.Start();
            }
        }
コード例 #2
0
ファイル: PTZForm.cs プロジェクト: Gordon-M/PTZCamera
        private void PTZControl(int nCommand, bool bStop, int nSpeed)
        {
            //DEV_INFO m_devinfo = clientForm.devInfo;
            //int nLoginID = m_devinfo.lLoginID;
            int nChannel = 0;

            XMSDK.H264_DVR_PTZControl(nLoginID, nChannel, (int)nCommand, bStop, nSpeed);
        }
コード例 #3
0
ファイル: Video.cs プロジェクト: Gordon-M/PTZCamera
 public bool OnCloseSound()
 {
     if (XMSDK.H264_DVR_CloseSound(m_iPlayhandle))
     {
         m_bSound = false;
         return(true);
     }
     return(false);
 }
コード例 #4
0
ファイル: Video.cs プロジェクト: Gordon-M/PTZCamera
 public bool OnOpenSound()
 {
     if (XMSDK.H264_DVR_OpenSound(m_iPlayhandle))
     {
         m_bSound = true;
         return(true);
     }
     return(false);
 }
コード例 #5
0
ファイル: Video.cs プロジェクト: Gordon-M/PTZCamera
        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);
        }
コード例 #6
0
ファイル: Video.cs プロジェクト: Gordon-M/PTZCamera
 public void OnDisconnect()
 {
     if (m_iPlayhandle > 0)
     {
         XMSDK.H264_DVR_StopRealPlay(m_iPlayhandle, (uint)this.Handle);
         m_iPlayhandle = -1;
     }
     if (m_bSound)
     {
         OnCloseSound();
     }
     m_lLogin = -1;
 }
コード例 #7
0
ファイル: Log.cs プロジェクト: Gordon-M/PTZCamera
        // 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();
            }
        }
コード例 #8
0
ファイル: Log.cs プロジェクト: Gordon-M/PTZCamera
        public int InitSDK()
        {
            VideoForm m_videoform = new VideoForm();

            // Initialize
            disCallback = new XMSDK.fDisConnect(DisConnectBackCallFunc);
            GC.KeepAlive(disCallback);  // Keep the disconnect callback object alive
            int bResult = XMSDK.H264_DVR_Init(disCallback, this.Handle);

            // The messages received in SDK from DVR, which need to upload such as alarm information diary information, may go through callback function
            msgcallback = new XMSDK.fMessCallBack(MessCallBack);
            XMSDK.H264_DVR_SetDVRMessCallBack(msgcallback, this.Handle);
            XMSDK.H264_DVR_SetConnectTime(5000, 3);

            return(bResult);
        }
コード例 #9
0
ファイル: Log.cs プロジェクト: Gordon-M/PTZCamera
        private void buttonExit_Click(object sender, EventArgs e)
        {
            foreach (DEV_INFO devinfo in dictDevInfo.Values)
            {
                XMSDK.H264_DVR_Logout(devinfo.lLoginID);
            }

            timerDisconnect.Stop();

            ExitSDk();

            this.Close();
            //ptzForm.Close();
            m_videoform.Close();
            //m_videoform.VideoExit();
        }
コード例 #10
0
ファイル: Log.cs プロジェクト: Gordon-M/PTZCamera
        // 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!");
            }
        }
コード例 #11
0
ファイル: Log.cs プロジェクト: Gordon-M/PTZCamera
 public bool ExitSDk()
 {
     return(XMSDK.H264_DVR_Cleanup());
 }