Beispiel #1
0
        private SpecificInfo SpecificInfoDeserialize(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }

            SpecificInfo info = null;

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(new StringReader(xml));

                info          = new SpecificInfo();
                info.User     = ReadXML(doc, "/HTTP/User");
                info.Password = ReadXML(doc, "/HTTP/Password");
                info.Host     = ReadXML(doc, "/HTTP/Host");
                info.Port     = ReadXML(doc, "/HTTP/Port");
                info.Path     = ReadXML(doc, "/HTTP/Path");
                info.Format   = ReadXML(doc, "/HTTP/Format");
            }
            catch (Exception e)
            {
                log.ErrorFormat(e.Message);
            }

            return(info);
        }
Beispiel #2
0
        public string BuildURL(SpecificInfo specific)
        {
            string url = "";

            if (string.IsNullOrEmpty(specific.User) && string.IsNullOrEmpty(specific.Password))
            {
                if (string.IsNullOrEmpty(specific.Port) || specific.Port == "80")
                {
                    url = string.Format("http://{0}{1}", specific.Host, specific.Path);
                }
                else
                {
                    url = string.Format("http://{0}:{1}{2}", specific.Host, specific.Port, specific.Path);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(specific.Port) || specific.Port == "80")
                {
                    url = string.Format("http://{0}:{1}@{2}{3}", specific.User, specific.Password, specific.Host, specific.Path);
                }
                else
                {
                    url = string.Format("http://{0}:{1}@{2}:{3}{4}", specific.User, specific.Password, specific.Host, specific.Port, specific.Path);
                }
            }

            return(url);
        }
Beispiel #3
0
        public FrameGrabber(CameraSummary summary, CameraManagerHTTP manager)
        {
            this.summary = summary;
            this.manager = manager;

            SpecificInfo specific = summary.Specific as SpecificInfo;

            if (specific == null)
            {
                return;
            }

            string url = URLHelper.BuildURL(specific);

            this.format = specific.Format;

            if (format == "MJPEG")
            {
                device = new CameraHTTPClientMJPEG(url, specific.User, specific.Password);
            }
            else if (format == "JPEG")
            {
                device = new CameraHTTPClientJPEG(url, specific.User, specific.Password);
            }
        }
        public override bool Equals(object obj)
        {
            SpecificInfo other = obj as SpecificInfo;

            if (other == null)
            {
                return(false);
            }
            return(this.User == other.User && this.Password == other.Password && this.Host == other.Host && this.Port == other.Port && this.Path == other.Path && this.Format == other.Format);
        }
Beispiel #5
0
        private SpecificInfo CreateSpecific()
        {
            SpecificInfo specific = new SpecificInfo();

            specific.User     = user;
            specific.Password = password;
            specific.Host     = host;
            specific.Port     = port;
            specific.Path     = path;
            specific.Format   = format;
            return(specific);
        }
        public SpecificInfo Clone()
        {
            SpecificInfo specific = new SpecificInfo();

            specific.User     = this.User;
            specific.Password = this.Password;
            specific.Host     = this.Host;
            specific.Port     = this.Port;
            specific.Path     = this.Path;
            specific.Format   = this.Format;
            return(specific);
        }
Beispiel #7
0
        public void Populate(SpecificInfo specific)
        {
            // This is used in the context of reconfiguring an existing camera.
            host     = specific.Host;
            port     = specific.Port;
            user     = specific.User;
            password = specific.Password;
            path     = specific.Path;
            format   = specific.Format;

            urlImport   = true;
            paramImport = true;
            PopulateFields();
            PopulateURL();
            urlImport   = false;
            paramImport = false;
        }
Beispiel #8
0
        public SnapshotRetriever(CameraManagerHTTP manager, CameraSummary summary)
        {
            this.summary = summary;

            string       url      = "";
            SpecificInfo specific = summary.Specific as SpecificInfo;

            if (specific != null)
            {
                url = manager.BuildURL(specific);
            }

            if (specific.Format == "MJPEG")
            {
                device = new CameraHTTPClientMJPEG(url);
            }
            else if (specific.Format == "JPEG")
            {
                device = new CameraHTTPClientJPEG(url);
            }
        }
Beispiel #9
0
        private string SpecificInfoSerialize(CameraSummary summary)
        {
            SpecificInfo info = summary.Specific as SpecificInfo;

            if (info == null)
            {
                return(null);
            }

            XmlDocument doc     = new XmlDocument();
            XmlElement  xmlRoot = doc.CreateElement("HTTP");

            AppendXML(doc, xmlRoot, "User", info.User);
            AppendXML(doc, xmlRoot, "Password", info.Password);
            AppendXML(doc, xmlRoot, "Host", info.Host);
            AppendXML(doc, xmlRoot, "Port", info.Port);
            AppendXML(doc, xmlRoot, "Path", info.Path);
            AppendXML(doc, xmlRoot, "Format", info.Format);

            doc.AppendChild(xmlRoot);
            return(doc.OuterXml);
        }