private Uri GetAddr(ManufacturersManufacturerUrl s, bool audio = false) { Username = txtUsername.Text; Password = txtPassword.Text; Channel = txtChannel.Text.Trim(); string addr = txtIPAddress.Text.Trim(); Flags = s.flags; Cookies = s.cookies; var nPort = (int)numPort.Value; if (!string.IsNullOrEmpty(s.port)) { nPort = Convert.ToInt32(s.port); } else { if (s.prefix.ToLowerInvariant().StartsWith("rtsp")) { nPort = 554; } } int channel; var uri = new Uri(s.prefix + addr + ":" + nPort); int.TryParse(txtChannel.Text.Trim(), out channel); return(Conf.GetAddr(s, uri, channel, Username, Password, audio)); }
public bool TestAddress(Uri addr, ManufacturersManufacturerUrl u, string username, string password) { if (!TestPort(addr.Port)) { return(false); } bool found; switch (u.prefix.ToLowerInvariant()) { case "http://": case "https://": found = TestHttpUrl(addr, "", username, password); break; case "rtsp://": found = TestRtspUrl(addr, username, password); break; default: found = true; break; } return(found); }
private void AddCamera(string addr, ManufacturersManufacturer m, ManufacturersManufacturerUrl u) { string st = m.name + ":"; if (!String.IsNullOrEmpty(u.version)) { st += u.version; } else { st += "Other"; } string source = u.Source; if (source == "VLC" && !_vlc) { source = "FFMPEG"; } st += ": " + source + " " + addr.Replace("&", "&&"); var rb = new RadioButton { Text = st, AutoSize = true, Tag = u }; if (u.Source == "FFMPEG" || u.Source == "VLC") { rb.Font = new Font(rb.Font, FontStyle.Bold); } UISync.Execute(() => pnlOptions.Controls.Add(rb)); }
public ConnectionOption(Uri url, Uri audioUrl, int videoSourceTypeID, int audioSourceTypeID, ManufacturersManufacturerUrl mmUrl) { _url = url; _audioUrl = audioUrl; _videoSourceTypeID = videoSourceTypeID; _audioSourceTypeID = audioSourceTypeID; MmUrl = mmUrl; }
public ConnectionOption(string url, Uri audioUrl, int videoSourceTypeID, int audioSourceTypeID, ManufacturersManufacturerUrl mmUrl) { _url = null; _audioUrl = audioUrl; _videoSourceTypeID = videoSourceTypeID; _audioSourceTypeID = audioSourceTypeID; MmUrl = mmUrl; _overrideURL = url; }
private string GetAddr(ManufacturersManufacturerUrl s) { Username = txtUsername.Text.Trim(); Password = txtPassword.Text.Trim(); Channel = txtChannel.Text.Trim(); string addr = txtIPAddress.Text.Trim(); Flags = s.flags; Cookies = s.cookies; var nPort = (int)numPort.Value; if (s.Port == 0 && s.prefix == "rtsp://") { s.Port = 554; } if (s.Port > 0) { nPort = s.Port; } string connectUrl = s.prefix; if (!String.IsNullOrEmpty(Username)) { connectUrl += Username; if (!String.IsNullOrEmpty(Password)) { connectUrl += ":" + Password; } connectUrl += "@"; } connectUrl += addr + ":" + nPort + "/"; string url = s.url; url = url.Replace("[USERNAME]", Username).Replace("[PASSWORD]", Password); url = url.Replace("[CHANNEL]", txtChannel.Text.Trim()); //defaults: url = url.Replace("[WIDTH]", "320"); url = url.Replace("[HEIGHT]", "240"); if (url.IndexOf("[AUTH]") != -1) { string credentials = String.Format("{0}:{1}", Username, Password); byte[] bytes = Encoding.ASCII.GetBytes(credentials); url = url.Replace("[AUTH]", Convert.ToBase64String(bytes)); } connectUrl += url; return(connectUrl); }
private string GetAddr(ManufacturersManufacturerUrl s, bool audio = false) { Username = txtUsername.Text; Password = txtPassword.Text; Channel = txtChannel.Text.Trim(); string addr = txtIPAddress.Text.Trim(); Flags = s.flags; Cookies = s.cookies; var nPort = (int)numPort.Value; if (!String.IsNullOrEmpty(s.port)) { nPort = Convert.ToInt32(s.port); } string connectUrl = s.prefix; if (!String.IsNullOrEmpty(Username)) { connectUrl += Uri.EscapeDataString(Username); if (!String.IsNullOrEmpty(Password)) { connectUrl += ":" + Uri.EscapeDataString(Password); } connectUrl += "@"; } connectUrl += addr + ":" + nPort; string url = !audio?s.url:s.AudioURL; if (!url.StartsWith("/")) { url = "/" + url; } url = url.Replace("[USERNAME]", Uri.EscapeDataString(Username)).Replace("[PASSWORD]", Uri.EscapeDataString(Password)); url = url.Replace("[CHANNEL]", txtChannel.Text.Trim()); //defaults: url = url.Replace("[WIDTH]", "320"); url = url.Replace("[HEIGHT]", "240"); if (url.IndexOf("[AUTH]", StringComparison.Ordinal) != -1) { string credentials = String.Format("{0}:{1}", Uri.EscapeDataString(Username), Uri.EscapeDataString(Password)); byte[] bytes = Encoding.ASCII.GetBytes(credentials); url = url.Replace("[AUTH]", Convert.ToBase64String(bytes)); } connectUrl += url; return(connectUrl); }
public Uri GetAddr(ManufacturersManufacturerUrl s, int channel, string username, string password, bool audio = false) { string urlStart = s.prefix; username = username ?? ""; password = password ?? ""; if (!string.IsNullOrEmpty(username) && s.url.IndexOf("[TOKEN]", StringComparison.Ordinal) == -1) { urlStart += Uri.EscapeDataString(username); if (!string.IsNullOrEmpty(password)) { urlStart += ":" + Uri.EscapeDataString(password); } else { urlStart += ":"; } urlStart += "@"; } string url = !audio ? s.url : s.AudioURL; if (!url.StartsWith("/")) { url = "/" + url; } url = url.Replace("[USERNAME]", Uri.EscapeDataString(username)).Replace("[PASSWORD]", Uri.EscapeDataString(password)); url = url.Replace("[CHANNEL]", channel.ToString(CultureInfo.InvariantCulture).Trim()); //defaults: url = url.Replace("[WIDTH]", "320"); url = url.Replace("[HEIGHT]", "240"); if (url.IndexOf("[AUTH]", StringComparison.Ordinal) != -1) { string credentials = $"{username}:{password}"; byte[] bytes = Encoding.ASCII.GetBytes(credentials); url = url.Replace("[AUTH]", Convert.ToBase64String(bytes)); } var connectUrl = urlStart + BaseUri.DnsSafeHost + ":" + GetPort(s); connectUrl += url; Uri uri = null; Uri.TryCreate(connectUrl, UriKind.Absolute, out uri); return(uri); }
public static Uri GetAddr(ManufacturersManufacturerUrl s, Uri addr, int channel, string username, string password, bool audio = false) { var nPort = addr.Port; if (!string.IsNullOrEmpty(s.port)) { nPort = Convert.ToInt32(s.port); } string connectUrl = s.prefix; if (!string.IsNullOrEmpty(username)) { connectUrl += username; if (!string.IsNullOrEmpty(password)) { connectUrl += ":" + password; } connectUrl += "@"; } connectUrl += addr.DnsSafeHost + ":" + nPort; string url = !audio ? s.url : s.AudioURL; if (!url.StartsWith("/")) { url = "/" + url; } url = url.Replace("[USERNAME]", username).Replace("[PASSWORD]", password); url = url.Replace("[CHANNEL]", channel.ToString(CultureInfo.InvariantCulture).Trim()); //defaults: url = url.Replace("[WIDTH]", "320"); url = url.Replace("[HEIGHT]", "240"); if (url.IndexOf("[AUTH]", StringComparison.Ordinal) != -1) { string credentials = $"{username}:{password}"; byte[] bytes = Encoding.ASCII.GetBytes(credentials); url = url.Replace("[AUTH]", Convert.ToBase64String(bytes)); } connectUrl += url; Uri uri; Uri.TryCreate(connectUrl, UriKind.Absolute, out uri); return(uri); }
public static bool TestAddress(Uri addr, ManufacturersManufacturerUrl u, string Username, string Password) { switch (u.prefix.ToUpper()) { case "HTTP://": case "HTTPS://": return(TestHttpUrl(addr, u.cookies, Username, Password)); case "RTSP://": return(TestRtspUrl(addr, Username, Password)); default: return(TestSocket(addr)); } }
public static Uri GetAddr(ManufacturersManufacturerUrl s, Uri addr, int channel, string username, string password, bool audio = false) { var nPort = addr.Port; if (!string.IsNullOrEmpty(s.port)) nPort = Convert.ToInt32(s.port); string connectUrl = s.prefix; if (!string.IsNullOrEmpty(username)) { connectUrl += username; if (!string.IsNullOrEmpty(password)) connectUrl += ":" + password; connectUrl += "@"; } connectUrl += addr.DnsSafeHost + ":" + nPort; string url = !audio ? s.url : s.AudioURL; if (!url.StartsWith("/")) url = "/" + url; url = url.Replace("[USERNAME]", username).Replace("[PASSWORD]", password); url = url.Replace("[CHANNEL]", channel.ToString(CultureInfo.InvariantCulture).Trim()); //defaults: url = url.Replace("[WIDTH]", "320"); url = url.Replace("[HEIGHT]", "240"); if (url.IndexOf("[AUTH]", StringComparison.Ordinal) != -1) { string credentials = $"{username}:{password}"; byte[] bytes = Encoding.ASCII.GetBytes(credentials); url = url.Replace("[AUTH]", Convert.ToBase64String(bytes)); } connectUrl += url; Uri uri; Uri.TryCreate(connectUrl, UriKind.Absolute, out uri); return uri; }
public bool TestAddress(Uri addr, ManufacturersManufacturerUrl u, string username, string password) { if (!TestPort(addr.Port)) { return(false); } switch (u.prefix.ToLowerInvariant()) { case "http://": case "https://": return(TestHttpUrl(addr, "", username, password)); case "rtsp://": return(TestRtspUrl(addr, username, password)); default: return(true); } }
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); }
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; } } }
public static bool TestAddress(Uri addr, ManufacturersManufacturerUrl u, string Username, string Password) { bool found; switch (u.prefix.ToUpper()) { case "HTTP://": case "HTTPS://": found = TestHttpUrl(addr, u.cookies, Username, Password); break; case "RTSP://": found = TestRtspUrl(addr, Username, Password); break; default: found = TestSocket(addr); break; } return(found); }
private int GetPort(ManufacturersManufacturerUrl s) { if (s.prefix.ToLowerInvariant().StartsWith("http")) { if (s.portSpecified && s.port != HttpPort) { if (TestPort(s.port)) { return(s.port); } } return(HttpPort); } if (s.portSpecified && s.port != MediaPort) { if (TestPort(s.port)) { return(s.port); } } return(MediaPort); }
private int GetPort(ManufacturersManufacturerUrl s) => s.prefix.ToLowerInvariant().StartsWith("http") ? s.portSpecified && s.port != HttpPort && TestPort(s.port) ? s.port : HttpPort : s.portSpecified && s.port != MediaPort && TestPort(s.port) ? s.port : MediaPort;
private void btnNext_Click(object sender, EventArgs e) { if (pnlConfig.Visible) { if (ddlMake.SelectedIndex == 0) { MessageBox.Show(this, "Please choose a make"); return; } ShowPanel(pnlFindNetwork); return; } if (pnlFindNetwork.Visible) { string addr = txtIPAddress.Text.Trim(); if (addr == "") { MessageBox.Show(this, "Please select or enter an IP address"); return; } IPAddress ip; if (!IPAddress.TryParse(addr, out ip)) { MessageBox.Show(this, "Please enter an IP address only (excluding http://)"); return; } AddConnections(); return; } if (pnlConnect.Visible) { if (ddlMake.SelectedIndex == 0) { ShowPanel(pnlConfig); return; } string make = ddlMake.SelectedItem.ToString(); ManufacturersManufacturerUrl s = null; for (int j = 0; j < pnlOptions.Controls.Count; j++) { if (pnlOptions.Controls[j] is RadioButton) { if (((RadioButton)pnlOptions.Controls[j]).Checked) { s = (ManufacturersManufacturerUrl)((RadioButton)pnlOptions.Controls[j]).Tag; break; } } } if (s == null) //should never happen { return; } FinalUrl = GetAddr(s); switch (s.Source) { case "JPEG": VideoSourceType = 0; break; case "MJPEG": VideoSourceType = 1; break; case "FFMPEG": VideoSourceType = 2; break; case "VLC": VideoSourceType = 5; break; } Ptzid = -1; if (!s.@fixed) { string n = make.ToLower(); bool quit = false; foreach (var ptz in MainForm.PTZs) { int j = 0; foreach (var m in ptz.Makes) { if (m.Name.ToLower() == n) { Ptzid = ptz.id; Ptzentryid = j; if (m.Model == s.version) { Ptzid = ptz.id; Ptzentryid = j; quit = true; break; } } j++; } if (quit) { break; } } } MainForm.IPUN = txtUsername.Text; MainForm.IPPASS = txtPassword.Text; MainForm.IPTYPE = ddlMake.SelectedItem.ToString(); MainForm.IPADDR = txtIPAddress.Text; MainForm.IPPORTS = txtPorts.Text; MainForm.IPPORT = (int)numPort.Value; MainForm.IPCHANNEL = txtChannel.Text.Trim(); AudioModel = s.AudioModel; if (_dt != null) { MainForm.IPTABLE = _dt.Copy(); } DialogResult = DialogResult.OK; Close(); } }
private void Next() { if (pnlConfig.Visible) { MainForm.IPLISTED = tbl1.Enabled; MainForm.IPRTSP = chkRTSP.Checked; MainForm.IPHTTP = chkHTTP.Checked; if (MainForm.IPLISTED) { if (ddlMake.SelectedIndex == -1) { MessageBox.Show(this, LocRm.GetString("ChooseMake")); return; } } else { if (!MainForm.IPRTSP && !MainForm.IPHTTP) { MessageBox.Show(this, LocRm.GetString("ChooseOption")); return; } } ShowPanel(pnlLogin); return; } if (pnlLogin.Visible) { ShowPanel(pnlFindNetwork); return; } if (pnlFindNetwork.Visible) { string addr = txtIPAddress.Text.Trim(); if (String.IsNullOrEmpty(addr)) { MessageBox.Show(this, LocRm.GetString("EnterIPAddress")); return; } Uri nUrl = null; if (!Uri.TryCreate("http://" + addr, UriKind.Absolute, out nUrl)) { MessageBox.Show(this, LocRm.GetString("EnterIPDNSOnly")); return; } AddConnections(); return; } if (pnlConnect.Visible) { if (MainForm.IPLISTED && ddlMake.SelectedIndex == 0) { ShowPanel(pnlConfig); return; } string make = txtMake.Text; string model = txtModel.Text; if (MainForm.IPLISTED) { make = ddlMake.SelectedItem.ToString(); if (ddlModel.SelectedIndex > 0) { model = ddlModel.SelectedItem.ToString().ToUpper(); } } ManufacturersManufacturerUrl s = null; for (int j = 0; j < pnlOptions.Controls.Count; j++) { if (pnlOptions.Controls[j] is RadioButton) { if (((RadioButton)pnlOptions.Controls[j]).Checked) { s = (ManufacturersManufacturerUrl)(pnlOptions.Controls[j]).Tag; break; } } } if (s == null) { MessageBox.Show(this, LocRm.GetString("SelectURL")); return; } FinalUrl = GetAddr(s); string source = s.Source; if (source == "VLC" && !_vlc) { source = "FFMPEG"; } switch (source) { case "JPEG": VideoSourceType = 0; break; case "MJPEG": VideoSourceType = 1; break; case "FFMPEG": VideoSourceType = 2; break; case "VLC": VideoSourceType = 5; break; } AudioSourceType = -1; if (!String.IsNullOrEmpty(s.AudioSource)) { switch (s.AudioSource) { case "FFMPEG": AudioSourceType = 3; break; case "VLC": AudioSourceType = 2; if (!_vlc) { AudioSourceType = 3; } break; } AudioUrl = GetAddr(s, true); } Ptzid = -1; if (!s.@fixed) { string modellc = model.ToLower(); string n = make.ToLower(); bool quit = false; foreach (var ptz in MainForm.PTZs) { int j = 0; foreach (var m in ptz.Makes) { if (m.Name.ToLower() == n) { Ptzid = ptz.id; Ptzentryid = j; string mdl = m.Model.ToLower(); if (mdl == modellc || s.version.ToLower() == mdl) { Ptzid = ptz.id; Ptzentryid = j; quit = true; break; } } j++; } if (quit) { break; } } } MainForm.IPUN = txtUsername.Text; MainForm.IPPASS = txtPassword.Text; MainForm.IPTYPE = make; MainForm.IPMODEL = model; MainForm.IPADDR = txtIPAddress.Text; MainForm.IPPORTS = txtPorts.Text; MainForm.IPPORT = (int)numPort.Value; MainForm.IPCHANNEL = txtChannel.Text.Trim(); AudioModel = s.AudioModel; LastConfig.PromptSave = !MainForm.IPLISTED && MainForm.IPMODEL.Trim() != ""; LastConfig.Iptype = MainForm.IPTYPE; LastConfig.Ipmodel = MainForm.IPMODEL; LastConfig.Prefix = s.prefix; LastConfig.Source = s.Source; LastConfig.URL = s.url; LastConfig.Cookies = s.cookies; LastConfig.Flags = s.flags; if (!String.IsNullOrEmpty(s.port)) { LastConfig.Port = Convert.ToInt32(s.port); } if (_dt != null) { MainForm.IPTABLE = _dt.Copy(); } DialogResult = DialogResult.OK; Close(); } }
private string GetAddr(ManufacturersManufacturerUrl s, bool audio = false) { Username = txtUsername.Text; Password = txtPassword.Text; Channel = txtChannel.Text.Trim(); string addr = txtIPAddress.Text.Trim(); Flags = s.flags; Cookies = s.cookies; var nPort = (int)numPort.Value; if (!String.IsNullOrEmpty(s.port)) nPort = Convert.ToInt32(s.port); string connectUrl = s.prefix; if (!String.IsNullOrEmpty(Username)) { connectUrl += Uri.EscapeDataString(Username); if (!String.IsNullOrEmpty(Password)) connectUrl += ":" + Uri.EscapeDataString(Password); connectUrl += "@"; } connectUrl += addr + ":" + nPort; string url = !audio?s.url:s.AudioURL; if (!url.StartsWith("/")) url = "/" + url; url = url.Replace("[USERNAME]", Uri.EscapeDataString(Username)).Replace("[PASSWORD]", Uri.EscapeDataString(Password)); url = url.Replace("[CHANNEL]", txtChannel.Text.Trim()); //defaults: url = url.Replace("[WIDTH]", "320"); url = url.Replace("[HEIGHT]", "240"); if (url.IndexOf("[AUTH]", StringComparison.Ordinal)!=-1) { string credentials = String.Format("{0}:{1}", Uri.EscapeDataString(Username), Uri.EscapeDataString(Password)); byte[] bytes = Encoding.ASCII.GetBytes(credentials); url = url.Replace("[AUTH]", Convert.ToBase64String(bytes)); } connectUrl += url; return connectUrl; }
private void AddCamera(string addr, ManufacturersManufacturer m, ManufacturersManufacturerUrl u) { string st = m.name+":"; if (!String.IsNullOrEmpty(u.version)) st += u.version; else st += "Other"; string source = u.Source; if (source == "VLC" && !_vlc) source = "FFMPEG"; st += ": " + source +" " + addr.Replace("&", "&&"); var rb = new RadioButton { Text = st, AutoSize = true, Tag = u }; if (u.Source == "FFMPEG" || u.Source == "VLC") rb.Font = new Font(rb.Font, FontStyle.Bold); UISync.Execute(() => pnlOptions.Controls.Add(rb)); }
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); }
private string GetAddr(ManufacturersManufacturerUrl s) { Username = txtUsername.Text.Trim(); Password = txtPassword.Text.Trim(); Channel = txtChannel.Text.Trim(); string addr = txtIPAddress.Text.Trim(); Flags = s.flags; Cookies = s.cookies; var nPort = (int)numPort.Value; if (s.Port == 0 && s.prefix == "rtsp://") s.Port = 554; if (s.Port > 0) nPort = s.Port; string connectUrl = s.prefix; if (!String.IsNullOrEmpty(Username)) { connectUrl += Username; if (!String.IsNullOrEmpty(Password)) connectUrl += ":" + Password; connectUrl += "@"; } connectUrl += addr + ":" + nPort + "/"; string url = s.url; url = url.Replace("[USERNAME]", Username).Replace("[PASSWORD]", Password); url = url.Replace("[CHANNEL]", txtChannel.Text.Trim()); //defaults: url = url.Replace("[WIDTH]", "320"); url = url.Replace("[HEIGHT]", "240"); if (url.IndexOf("[AUTH]", StringComparison.Ordinal)!=-1) { string credentials = String.Format("{0}:{1}", Username, Password); byte[] bytes = Encoding.ASCII.GetBytes(credentials); url = url.Replace("[AUTH]", Convert.ToBase64String(bytes)); } connectUrl += url; return connectUrl; }