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(); }
private void ListCameras(IEnumerable <ManufacturersManufacturer> m, string login, string password) { int i = 0; try { string addr = txtIPAddress.Text.Trim(); var nPort = (int)numPort.Value; var uri = new Uri("http://" + addr + ":" + nPort); var onvifurl = uri + "onvif/device_service"; var dev = new ONVIFDevice(onvifurl, Username, Password); if (dev.Profiles != null) { foreach (var p in dev.Profiles) { var b = p?.VideoSourceConfiguration?.Bounds; if (b != null && b.width > 0) { dev.SelectProfile(i); var co = new ConnectionOption(onvifurl, null, 9, -1, null) { MediaIndex = i }; AddONVIF(onvifurl, co); } i++; } } } catch (Exception ex) { Logger.LogException(ex); } foreach (var s in m) { var cand = s.url.ToList(); cand = cand.OrderBy(p => p.Source).ToList(); foreach (var u in cand) { Uri addr = GetAddr(u); UISync.Execute(() => tsslCurrent.Text = addr.ToString()); bool found = Helper.TestAddress(addr, u, login, password); if (found) { AddCamera(addr.ToString(), s, u); } if (_quiturlscanner) { break; } } if (_quiturlscanner) { break; } } }