Exemple #1
0
        public static void Main()
        {
            var xm = new XMCameraConnection(CAM_IP, CAM_PORT, "admin", "gCnGEDW7");

            xm.HeartBeatWorker();
            // while (true)
            // {
            //     var m = xm.PtzControl(XMConstants.PTZ.RIGHT, true);
            //     System.Threading.Thread.Sleep(2000);
            //     xm.PtzControl(CamController.XMConstants.PTZ.LEFT);
            //     System.Threading.Thread.Sleep(2000);
            // }
        }
Exemple #2
0
        public XMCameraConnection(IPAddress ip, int port, string username, string password, XMCameraConnection instance = null, uint sid = 0)
        {
            camIp         = ip;
            camPort       = port;
            cameraUser    = username;
            camPassword   = password;
            this.instance = instance;
            camSid        = sid;

            try
            {
                mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
                {
                    ReceiveTimeout = socketTimeout,
                    SendTimeout    = socketTimeout
                };
                mainSocket.Connect(camIp, camPort);
                var pkt = new Dictionary <string, object>
                {
                    { "EncryptType", "MD5" },
                    { "UserName", cameraUser },
                    { "PassWord", camPassword },
                    { "LoginType", "DVRIP-Web" }
                };
                var response = _getResponse(XMConstants.User.LOGIN_REQ2, pkt);
                var respdict = JsonConvert.DeserializeObject <Dictionary <string, object> >(response);
                Console.WriteLine(response);
                if (!IsSubConnection && respdict != null && respdict.ContainsKey("Ret") && (long)respdict["Ret"] == 100)
                {
                    StartHeartBeat();
                }
                else
                {
                    Console.WriteLine("XMCameraConnection: Cannot start keepalive");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #3
0
        public XMCameraConnection CreateSubConnection()
        {
            var subconn = new XMCameraConnection(camIp, camPort, cameraUser, camPassword, sid: camSid, instance: this);

            return(subconn);
        }