コード例 #1
0
        int DevLogin(ref DEV_INFO pdev)
        {
            if (Convert.ToBoolean(pdev.bSerialID)) //
            {
                int         maxDeviceNum = 100;    //
                DDNS_INFO[] pDDNSInfo    = new DDNS_INFO[maxDeviceNum];
                SearchMode  searchmode;
                int         nReNum = 0; //
                searchmode.nType        = (int)SearchModeType.DDNS_SERIAL;
                searchmode.szSerIP      = pdev.szSerIP;
                searchmode.nSerPort     = pdev.nSerPort;
                searchmode.szSerialInfo = pdev.szSerialInfo;
                bool bret = Convert.ToBoolean(NETSDK.H264_DVR_GetDDNSInfo(ref searchmode, out pDDNSInfo, maxDeviceNum, out nReNum));
                if (!bret)
                {
                    return(0);
                }
                pdev.szIpaddress = pDDNSInfo[0].IP;
                pdev.nPort       = pDDNSInfo[0].MediaPort;
            }

            H264_DVR_DEVICEINFO OutDev;
            int nError = 0;

            //
            NETSDK.H264_DVR_SetConnectTime(3000, 1);//

            int lLogin = NETSDK.H264_DVR_Login(pdev.szIpaddress, Convert.ToUInt16(pdev.nPort), pdev.szUserName,
                                               pdev.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET);

            if (lLogin <= 0)
            {
                int nErr = NETSDK.H264_DVR_GetLastError();
                if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID)
                {
                    MessageBox.Show("Error.PwdErr");
                }
                else
                {
                    MessageBox.Show("Error.NotFound");
                }
                return(lLogin);
            }
            NETSDK.H264_DVR_SetupAlarmChan(lLogin);
            return(lLogin);
        }
コード例 #2
0
        public int Connect(ref DEV_INFO pDev, int nChannel, int nWndIndex)
        {
            int nRet = 0;

            //if device did not login, login first
            if (pDev.lLoginID <= 0)
            {
                H264_DVR_DEVICEINFO OutDev;
                int nError = 0;
                //
                int lLogin = NETSDK.H264_DVR_Login(pDev.szIpaddress, (ushort)pDev.nPort, pDev.szUserName, pDev.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET);
                if (lLogin <= 0)
                {
                    int nErr = NETSDK.H264_DVR_GetLastError();
                    if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID)
                    {
                        MessageBox.Show(("Error.PwdErr"));
                    }
                    else
                    {
                        MessageBox.Show(("Error.NotFound"));
                    }

                    return(nRet);
                }

                pDev.lLoginID = lLogin;
                NETSDK.H264_DVR_SetupAlarmChan(lLogin);
            }

            int nWnd = m_nCurIndex;

            if (nWndIndex >= 0)
            {
                nWnd = nWndIndex;
            }

            if (nWnd >= m_nTotalWnd)
            {
                return(nRet);
            }

            return(m_videoform[nWnd].ConnectRealPlay(ref pDev, nChannel));
        }
コード例 #3
0
        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;

                int lLogin = NETSDK.H264_DVR_Login(devinfo.szIpaddress, (ushort)devinfo.nPort, devinfo.szUserName, devinfo.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET);
                if (lLogin <= 0)
                {
                    int nErr = NETSDK.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);

                ClientDemo clientForm = new ClientDemo();

                foreach (Form form in Application.OpenForms)
                {
                    if (form.Name == "ClientDemo")
                    {
                        clientForm = (ClientDemo)form;
                        break;
                    }
                }
                DEV_INFO devAdd = new DEV_INFO();
                devAdd          = devinfo;
                devAdd.lLoginID = lLogin;


                foreach (TreeNode node in clientForm.devForm.DevTree.Nodes)
                {
                    if (node.Name == "Device")
                    {
                        DEV_INFO dev = (DEV_INFO)node.Tag;
                        if (dev.lLoginID == devinfo.lLoginID)
                        {
                            node.Text = devAdd.szDevName;
                            node.Tag  = devAdd;
                            node.Name = "Device";

                            foreach (TreeNode channelnode in node.Nodes)
                            {
                                CHANNEL_INFO chInfo = (CHANNEL_INFO)channelnode.Tag;
                                if (chInfo.nWndIndex > -1)
                                {
                                    clientForm.m_videoform[chInfo.nWndIndex].ConnectRealPlay(ref devAdd, chInfo.nChannelNo);
                                    Thread.Sleep(10);
                                }
                            }
                            break;
                        }
                    }
                }

                dictDevInfo.Add(lLogin, devAdd);
                NETSDK.H264_DVR_SetupAlarmChan(lLogin);
            }
            if (0 == dictDiscontDev.Count)
            {
                timerDisconnect.Enabled = false;
                timerDisconnect.Stop();
            }
        }
コード例 #4
0
 public void SetDevInfo(ref DEV_INFO pDev)
 {
     m_devInfo = pDev;
 }
コード例 #5
0
        // public void PtzControl(uint dwBtn, bool dwStop)
        // {
        //  long lPlayHandle = m_videoform[m_nCurIndex].GetHandle();
        //  if (lPlayHandle <= 0)
        //  {
        //      return;
        //  }
        // }

        DEV_INFO ReadXML()
        {
            XmlReader xml     = XmlReader.Create("");
            DEV_INFO  devInfo = new DEV_INFO();

            devInfo.nPort    = 0;
            devInfo.lLoginID = 0;
            devInfo.lID      = 0;

            while (xml.ReadToFollowing("ip"))
            {
                //read the information from XML
                string strIP, strUserName, strPsw, strDevName;
                uint   nPort;
                int    byChanNum = 0, lID = 0;

                uint   bSerialID, nSerPort;
                string szSerIP, szSerialInfo;
                xml = xml.ReadSubtree();


                strIP = xml.ReadElementString("ip2");

                strDevName = xml.ReadElementString("DEVICENAME");

                strUserName = xml.ReadElementString("username");

                nPort = Convert.ToUInt32(xml.ReadElementString("port"));

                strPsw = xml.ReadElementString("pwd");

                byChanNum = Convert.ToInt32(xml.ReadElementString("byChanNum"));

                lID = Convert.ToInt32(xml.ReadElementString("lID"));


                bSerialID = Convert.ToByte(xml.ReadElementString("bSerialID"));

                szSerIP = xml.ReadElementString("szSerIP");

                nSerPort = Convert.ToUInt32(xml.ReadElementString("nSerPort"));

                szSerialInfo = xml.ReadElementString("szSerialInfo");      //����ddns��¼

                devInfo.nTotalChannel = byChanNum;
                devInfo.nPort         = (int)nPort;

                devInfo.bSerialID    = Convert.ToByte(bSerialID);
                devInfo.nSerPort     = (int)nSerPort;
                devInfo.szSerIP      = szSerIP;
                devInfo.szSerialInfo = szSerialInfo;      //����ddns��¼
                devInfo.szDevName    = strDevName;
                devInfo.szUserName   = strUserName;
                devInfo.szPsw        = strPsw;
                devInfo.szIpaddress  = strIP;
                DEV_INFO pDev = new DEV_INFO();
                pDev = devInfo;
                IntPtr ptr = new IntPtr();
                Marshal.StructureToPtr(pDev, ptr, false);
                pDev.lID           = ptr.ToInt32();
                m_devMap[pDev.lID] = pDev;
                String   strName;
                TreeNode node = new  TreeNode();
                node.Text = strDevName;
                for (int i = 0; i < byChanNum; i++)
                {
                    strName = String.Format("CAM {0}", i + 1);
                    node.Nodes.Add(strName);
                }
                DevTree.Nodes.Add(node);
            }
            return(devInfo);
        }