Exemple #1
0
        private void ListCameras(IEnumerable <ManufacturersManufacturer> m, ref List <Uri> lp)
        {
            foreach (var s in m)
            {
                var cand = s.url.ToList();
                cand = cand.OrderBy(p => p.Source).ToList();

                foreach (var u in cand)
                {
                    Uri addr;
                    Uri audioUri          = null;
                    int audioSourceTypeID = -1;
                    addr = Conf.GetAddr(u, Uri, Channel, Username, Password);
                    if (!lp.Contains(addr))
                    {
                        lp.Add(addr);
                        URLScan?.Invoke(addr, EventArgs.Empty);

                        bool found = Helper.TestAddress(addr, u, Username, Password);
                        if (found)
                        {
                            if (!string.IsNullOrEmpty(u.AudioSource))
                            {
                                audioUri          = Conf.GetAddr(u, Uri, Channel, Username, Password, true);
                                audioSourceTypeID = Conf.GetSourceType(u.AudioSource, 1);
                            }
                            ManufacturersManufacturerUrl u1 = u;

                            URLFound?.Invoke(this,
                                             new ConnectionOptionEventArgs(new ConnectionOption(addr, audioUri,
                                                                                                Conf.GetSourceType(u1.Source, 2), audioSourceTypeID, u1)));
                        }
                    }
                    if (Quiturlscanner)
                    {
                        ScanComplete?.Invoke(this, EventArgs.Empty);
                        return;
                    }
                }
            }
            ScanComplete?.Invoke(this, EventArgs.Empty);
        }
Exemple #2
0
        private void Scan(List <ManufacturersManufacturerUrl> cand)
        {
            if (_quit || cand.Count == 0)
            {
                return;
            }

            var un  = Uri.EscapeDataString(Username);
            var pwd = Uri.EscapeDataString(Password);

            foreach (var s in cand)
            {
                Uri audioUri          = null;
                int audioSourceTypeID = -1;
                var addr = _discoverer.GetAddr(s, Channel, un, pwd);
                if (addr != null && !_lp.Contains(addr))
                {
                    _lp.Add(addr);
                    URLScan?.Invoke(addr, EventArgs.Empty);
                    bool found = _discoverer.TestAddress(addr, s, un, pwd);
                    if (found)
                    {
                        if (!string.IsNullOrEmpty(s.AudioSource))
                        {
                            audioUri          = _discoverer.GetAddr(s, Channel, un, pwd, true);
                            audioSourceTypeID = Helper.GetSourceType(s.AudioSource, 1);
                        }
                        ManufacturersManufacturerUrl s1 = s;

                        URLFound?.Invoke(this,
                                         new ConnectionOptionEventArgs(new ConnectionOption(addr, audioUri,
                                                                                            Helper.GetSourceType(s1.Source, 2), audioSourceTypeID, s1)));
                    }
                }

                if (_quit)
                {
                    return;
                }
            }
        }
Exemple #3
0
        private void ListCameras(IEnumerable <ManufacturersManufacturer> m, ref List <Uri> lp)
        {
            foreach (var s in m)
            {
                var cand = s.url.ToList();
                cand = cand.OrderBy(p => p.Source).ToList();

                foreach (var u in cand)
                {
                    Uri addr;
                    Uri audioUri          = null;
                    int audioSourceTypeID = -1;
                    switch (u.prefix.ToUpper())
                    {
                    default:
                        addr = Conf.GetAddr(u, Uri, Channel, Username, Password);
                        if (!lp.Contains(addr))
                        {
                            lp.Add(addr);
                            URLScan?.Invoke(addr, EventArgs.Empty);
                            if (Helper.TestHttpurl(addr.ToString(), u.cookies, Username, Password))
                            {
                                if (!string.IsNullOrEmpty(u.AudioSource))
                                {
                                    audioUri          = Conf.GetAddr(u, Uri, Channel, Username, Password, true);
                                    audioSourceTypeID = Conf.GetSourceType(u.AudioSource, 1);
                                }

                                ManufacturersManufacturerUrl u1 = u;
                                URLFound?.Invoke(this,
                                                 new ConnectionOptionEventArgs(new ConnectionOption(addr, audioUri, Conf.GetSourceType(u1.Source, 2), audioSourceTypeID, u1)));
                            }
                        }

                        break;

                    case "RTSP://":
                        addr = Conf.GetAddr(u, Uri, Channel, Username, Password);
                        if (!lp.Contains(addr))
                        {
                            lp.Add(addr);
                            URLScan?.Invoke(addr, EventArgs.Empty);
                            if (Helper.TestRtspurl(addr, Username, Password))
                            {
                                if (!string.IsNullOrEmpty(u.AudioSource))
                                {
                                    audioUri          = Conf.GetAddr(u, Uri, Channel, Username, Password, true);
                                    audioSourceTypeID = Conf.GetSourceType(u.AudioSource, 1);
                                }
                                ManufacturersManufacturerUrl u1 = u;

                                URLFound?.Invoke(this,
                                                 new ConnectionOptionEventArgs(new ConnectionOption(addr, audioUri,
                                                                                                    Conf.GetSourceType(u1.Source, 2), audioSourceTypeID, u1)));
                            }
                        }
                        break;
                    }
                    if (Quiturlscanner)
                    {
                        break;
                    }
                }
                if (Quiturlscanner)
                {
                    break;
                }
            }
            ScanComplete?.Invoke(this, EventArgs.Empty);
        }
Exemple #4
0
        private void ListCameras(IEnumerable <ManufacturersManufacturer> mm, string model)
        {
            model = (model ?? "").ToLowerInvariant();
            //find http port
            _discoverer = new URLDiscovery(Uri);

            //check for onvif support first
            int i = 0;

            try
            {
                var httpUri = _discoverer.BaseUri.SetPort(_discoverer.HttpPort);

                //check for this devices
                foreach (var d in Discovery.DiscoveredDevices)
                {
                    if (d.DnsSafeHost == Uri.DnsSafeHost)
                    {
                        httpUri = _discoverer.BaseUri.SetPort(d.Port);
                        break;
                    }
                }

                var onvifurl = httpUri + "onvif/device_service";
                var dev      = new ONVIFDevice(onvifurl, Username, Password);
                if (dev.Profiles != null)
                {
                    foreach (var p in dev.Profiles)
                    {
                        var b = p?.VideoEncoderConfiguration?.Resolution;
                        if (b != null && b.Width > 0)
                        {
                            dev.SelectProfile(i);
                            var co = new ConnectionOption(onvifurl, null, 9, -1, null)
                            {
                                MediaIndex = i
                            };
                            URLFound?.Invoke(this,
                                             new ConnectionOptionEventArgs(co));
                        }
                        i++;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            foreach (var m in mm)
            {
                //scan selected model first
                var cand = m.url.Where(p => p.version.ToLowerInvariant() == model).ToList();
                Scan(cand);
                cand = m.url.Where(p => p.version.ToLowerInvariant() != model).ToList();
                Scan(cand);
                if (_quit)
                {
                    break;
                }
            }

            ScanComplete?.Invoke(this, EventArgs.Empty);
            Finished.Set();
        }