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);
                    }
                }
            }
        }
Beispiel #2
0
        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);
        }
 internal void setMedia(Media2Client media)
 {
     this.media = media;
     configs    = media.GetVideoSourceConfigurations(null, null);
     // Disable edit config
     if (configs == null)
     {
         info_config.IsReadOnly = true;
     }
     setComboxItem();
 }
Beispiel #5
0
        public ConfigAudioEncoder(Media2Client media, string token, string profileName)
        {
            InitializeComponent();

            this.media        = media;
            this.profileToken = token;
            this.profileName  = profileName;
            setConfigs();
            // handle closing event
            this.Closing += Window_Closing;
        }
Beispiel #6
0
 public Media20Services(string Hostname, string User, string Password)
 {
     m_services                = null;
     m_mediaClient             = null;
     m_profiles                = null;
     m_Hostname                = Hostname;
     m_User                    = User;
     m_Password                = Password;
     m_BasicBasicAuthBehaviour = new BasicAuthBehaviour(m_User, m_Password);
     m_PasswordDigestBehavior  = new PasswordDigestBehavior(m_User, m_Password, 0);
     m_ErrorMessage            = "";
     m_deviceInformations      = null;
     m_HostnameInformation     = null;
 }
        public static ServiceReference1.Media2Client GetMedia2Client(string uri, string username = "", string password = "", double devideviceTimeOffset = 0)
        {
            UriBuilder deviceUri = new UriBuilder("");

            System.ServiceModel.Channels.Binding binding;
            HttpTransportBindingElement          httpTransport = new HttpTransportBindingElement();

            httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Digest;
            binding        = new System.ServiceModel.Channels.CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap12, Encoding.UTF8), httpTransport);
            deviceUri.Host = uri;
            Media2Client media2Client = new Media2Client(binding, new EndpointAddress(deviceUri.ToString()));

            return(media2Client);
        }
Beispiel #8
0
        private void audio_src_btn_Click(object sender, RoutedEventArgs e)
        {
            cas = new ConfigAudioSource(media, this.profiles[0].token, profileName);
            cas.ShowDialog();
            bool res = cas.DialogResult;

            // Done
            if (res)
            {
                this.media = cas.media;

                audio_src_btn.Background = new SolidColorBrush(System.Windows.Media.Colors.LawnGreen);
                // Next btn to active
                audio_encode_btn.IsEnabled = true;
            }
        }
        public ConfigVideoEncoder(Media2Client media, string token, string profileName)
        {
            InitializeComponent();
            this.media        = media;
            this.profileToken = token;
            this.profileName  = profileName;

            this.Closing += Window_Closing;

            configs = media.GetVideoEncoderConfigurations(null, profileToken);
            // Disable edit config
            if (configs == null)
            {
                info_config.IsReadOnly = true;
            }
            setComboxItem();
        }
Beispiel #10
0
        public async Task <bool> InitalizeMediaAsync()
        {
            try
            {
                if (m_profiles != null)
                {
                    return(true);
                }

                if (m_services == null)
                {
                    bool b = await this.GetServicesAsync();

                    if (m_services != null)
                    {
                        return(false);
                    }
                }



                foreach (var service in m_services.Service)
                {
                    if (service.Namespace == "http://www.onvif.org/ver10/media/wsdl")
                    {
                        var messageElement = new TextMessageEncodingBindingElement();
                        messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None);
                        HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
                        httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest;
                        CustomBinding bind = new CustomBinding(messageElement, httpBinding);
                        m_mediaClient = new Media2Client(bind, new EndpointAddress($"http://{m_Hostname}/onvif/Media"));
                        m_mediaClient.Endpoint.EndpointBehaviors.Add(m_PasswordDigestBehavior);
                        m_mediaClient.Endpoint.EndpointBehaviors.Add(m_BasicBasicAuthBehaviour);

                        m_profiles = await m_mediaClient.GetProfilesAsync(null, null);
                    }
                }
            }
            catch (Exception ex)
            {
                m_ErrorMessage = ex.Message;
                return(false);
            }
            return(m_profiles != null);
        }
Beispiel #11
0
 internal void setMedia(Media2Client media)
 {
     this.media = media;
     profiles   = media.GetProfiles(null, null);
 }