Example #1
0
        public GetProfilesResponse GetProfiles()
        {
            var rs = new GetProfilesResponse();

            try
            {
                var profiles            = this.Media.GetProfiles();
                List <ProfileInfo> list = new List <ProfileInfo>();

                foreach (OnvifServices.v10.Media.Profile profile in profiles)
                {
                    list.Add(new ProfileInfo
                    {
                        Token       = profile.token,
                        Description = string.Format("{0} - {1}x{2} fs{3}", profile.token, profile.VideoEncoderConfiguration.Resolution.Width, profile.VideoEncoderConfiguration.Resolution.Height, profile.VideoEncoderConfiguration.RateControl.FrameRateLimit),
                        Profile     = profile
                    });
                }

                rs.Profiles = list.ToArray();
            }
            catch (Exception ex)
            {
                rs.Exception = ex;
                rs.Message   = "Error recuperando lista de perfiles.";
            }

            if (!rs.IsSuccess)
            {
                RaiseOnLog(rs);
            }

            return(rs);
        }
Example #2
0
        public override async Task <bool> InitalizeAsync()
        {
            m_initialised = false;

            if (this.m_onVifDevice.ServicesResponse == null)
            {
                bool b = await this.m_onVifDevice.InitalizeDeviceAsync();

                if (this.m_onVifDevice.ServicesResponse == null)
                {
                    return(false);
                }
            }


            try
            {
                foreach (var service in this.m_onVifDevice.ServicesResponse.Service)
                {
                    if (service.Namespace == "http://www.onvif.org/ver20/media/wsdl")
                    {
                        string serviceAdress  = service.XAddr;
                        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(serviceAdress));

                        m_mediaClient.Endpoint.EndpointBehaviors.Add(this.m_onVifDevice.GetPasswordDigestBehavior);
                        m_mediaClient.Endpoint.EndpointBehaviors.Add(this.m_onVifDevice.GetBasicBasicAuthBehaviour);

                        var type = new List <string>();
                        type.Add("All");

                        m_profiles = await m_mediaClient.GetProfilesAsync(null, type.ToArray());

                        m_initialised = true;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                m_ErrorMessage = ex.Message;
                throw new OnVifException("OnVif2Media.InitalizeAsync", ex);
                //         return false;
            }

            return(m_initialised);
        }
Example #3
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;
 }
Example #4
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);
        }