Esempio n. 1
0
        /// <summary>
        /// Build device discovery probe message
        /// </summary>
        /// <param name="scopes">Scopes to probe</param>
        /// <param name="matchRule">Scope matching rule</param>
        /// <returns>Probe message</returns>
        protected byte[] BuildProbeMessage(string[] scopes, string matchRule)
        {
            WSD.ProbeType probe = new WSD.ProbeType();
            //Scope.MatchBy = string.IsNullOrEmpty(matchRule) ? SCOPE_MATCH_BY_URL : matchRule;
            probe.Scopes         = new WSD.ScopesType();
            probe.Scopes.MatchBy = matchRule;
            if (scopes != null)
            {
                string strScopes = string.Empty;
                for (int i = 0; i < scopes.Length; i++)
                {
                    strScopes += scopes[i];
                    if (i < (scopes.Length - 1))
                    {
                        strScopes += " ";
                    }
                }
                probe.Scopes.Text = new string[] { strScopes };
            }
            probe.Types = "dn:" + DiscoveryUtils.ONVIF_DISCOVER_TYPES;
            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();

            namespaces.Add("dn", DiscoveryUtils.ONVIF_NETWORK_WSDL_URL);
            return(SoapBuilder.BuildMessage(probe, Encoding.UTF8, new DiscoveryHeaderBuilder(), namespaces));
        }
Esempio n. 2
0
        /// <summary>
        /// Build device discovery probe message
        /// </summary>
        /// <param name="scopes">Scopes to probe</param>
        /// <param name="matchRule">Scope matching rule</param>
        /// <returns>Probe message</returns>
        protected byte[] BuildProbeMessage(DiscoveryUtils.DiscoveryType[] types, string[] scopes, string matchRule)
        {
            WSD.ProbeType probe = new WSD.ProbeType();
            //Scope.MatchBy = string.IsNullOrEmpty(matchRule) ? SCOPE_MATCH_BY_URL : matchRule;
            probe.Scopes         = new WSD.ScopesType();
            probe.Scopes.MatchBy = matchRule;
            if (scopes != null)
            {
                string strScopes = string.Empty;
                for (int i = 0; i < scopes.Length; i++)
                {
                    strScopes += scopes[i];
                    if (i < (scopes.Length - 1))
                    {
                        strScopes += " ";
                    }
                }
                probe.Scopes.Text = new string[] { strScopes };
            }

            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
            int    j          = 0;
            string probeTypes = string.Empty;
            bool   first      = true;

            if (types != null)
            {
                foreach (DiscoveryUtils.DiscoveryType type in types)
                {
                    string ns = type.Namespace;
                    string t  = type.Type;
                    string prefix;
                    if (string.IsNullOrEmpty(type.Prefix))
                    {
                        prefix = string.Format("ns{0}", j);
                        j++;
                    }
                    else
                    {
                        prefix = type.Prefix;
                    }

                    namespaces.Add(prefix, ns);
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        probeTypes += " ";
                    }
                    probeTypes += prefix + ":" + t;
                }
            }
            probe.Types = probeTypes;
            //probe.Types = "dn:" + DiscoveryUtils.ONVIF_DISCOVER_TYPES;
            //namespaces.Add("dn", DiscoveryUtils.ONVIF_NETWORK_WSDL_URL);

            return(DiscoverySoapBuilder.BuildMessage(probe, Encoding.UTF8, new DiscoveryHeaderBuilder(), namespaces));
        }
Esempio n. 3
0
        public WSD.ProbeMatchesType BuildProbeMatches(WSD.ProbeType probe)
        {
            WSD.ProbeMatchType match = new WSD.ProbeMatchType();
            match.EndpointReference               = new WSD.EndpointReferenceType();
            match.EndpointReference.Address       = new WSD.AttributedURI();
            match.EndpointReference.Address.Value = _uuid;
            match.Types       = "dn:NetworkVideoTransmitter";
            match.Scopes      = new WSD.ScopesType();
            match.Scopes.Text = _scopes;
            match.XAddrs      = ServiceAddress;

            WSD.ProbeMatchesType matches = new WSD.ProbeMatchesType();
            matches.ProbeMatch = new WSD.ProbeMatchType[] { match };
            return(matches);
        }