private void create_profile_btn_Click(object sender, RoutedEventArgs e) { bool createMode = true; cd = new ConfigDashboard(createMode); cd.setMedia(media); cd.ShowDialog(); bool res = cd.DialogResult; if (res) { this.media = cd.media; profiles = media.GetProfiles(null, null); // Make sure that the list is empty before adding new items listBox.Items.Clear(); if (profiles != null) { foreach (MediaProfile p in profiles) { listBox.Items.Add(p.Name); } } } }
private void video_source_btn_Click(object sender, RoutedEventArgs e) { if (this.profileToken != null) { cvs = new ConfigVideoSource(profileName); cvs.profileToken = this.profileToken; } else { cvs = new ConfigVideoSource(profileName); } cvs.setMedia(media); cvs.ShowDialog(); bool res = cvs.DialogResult; // Done if (res) { this.media = cvs.media; this.profileToken = this.cvs.profileToken; profiles = media.GetProfiles(this.profileToken, new string[] { "All" }); video_source_btn.Background = new SolidColorBrush(System.Windows.Media.Colors.LawnGreen); // Next btn to active video_encode_btn.IsEnabled = true; } }
private void ConnectCam() { bool inError = false; deviceUri = new UriBuilder("http:/onvif/device_service"); string[] addr = address.Text.Split(':'); deviceUri.Host = addr[0]; if (addr.Length == 2) { deviceUri.Port = Convert.ToInt16(addr[1]); } System.ServiceModel.Channels.Binding binding; HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Digest; binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, Encoding.UTF8), httpTransport); try { DeviceClient device = new DeviceClient(binding, new EndpointAddress(deviceUri.ToString())); Service[] services = device.GetServices(false); Service xmedia2 = services.FirstOrDefault(s => s.Namespace == "http://www.onvif.org/ver20/media/wsdl"); if (xmedia2 != null) { media = new Media2Client(binding, new EndpointAddress(deviceUri.ToString())); media.ClientCredentials.HttpDigest.ClientCredential.UserName = user.Text; media.ClientCredentials.HttpDigest.ClientCredential.Password = password.Password; media.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; profiles = media.GetProfiles(null, null); // Make sure that the list is empty before adding new items listBox.Items.Clear(); if (profiles != null) { foreach (MediaProfile p in profiles) { listBox.Items.Add(p.Name); } } // Enable Manage Profile btn create_profile_btn.IsEnabled = true; } listBox.SelectionChanged += OnSelectionChanged; video.MediaPlayer.VlcLibDirectoryNeeded += OnVlcControlNeedsLibDirectory; video.MediaPlayer.Log += MediaPlayer_Log; video.MediaPlayer.EndInit(); } catch (Exception ex) { textBox.Text = ex.Message; inError = true; } changeErrorLogColor(inError); }
private void delete_profile_btn_Click(object sender, RoutedEventArgs e) { // Remove selected profile if (listBox.SelectedIndex >= 0) { media.DeleteProfile(profiles[listBox.SelectedIndex].token); profiles = media.GetProfiles(null, null); refreshProfileList(); textBox.Text = ""; } }
internal void setMedia(Media2Client media) { this.media = media; profiles = media.GetProfiles(null, null); }