예제 #1
0
        /// <summary>
        /// Creates client for media service
        /// </summary>
        /// <param name="address">Media service address</param>
        void InitializeMediaClient(string address)
        {
            DeviceEnvironment env = ContextController.GetDeviceEnvironment();

            _mediaClient = new MediaServiceProvider(address, env.Timeouts.Message);
            _mediaClient.ExceptionThrown         += new Action <string, Exception>(OnExceptionThrown);
            _mediaClient.OperationCompleted      += new Action(OnOperationCompleted);
            _mediaClient.OperationStarted        += new Action(OnOperationStarted);
            _mediaClient.OnMediaUriReceived      += OnMediaUriReceived;
            _mediaClient.Timeout                  = env.Timeouts.Message;
            _mediaClient.ResponseReceived        += OnResponseReceived;
            _mediaClient.OnProfilesReceived      += OnProfilesReceived;
            _mediaClient.OnPTZConfigurationAdded += OnPTZConfigurationAdded;
        }
예제 #2
0
        /// <summary>
        /// Creates client for media service
        /// </summary>
        /// <param name="address">Media service address</param>
        void InitializeMediaClient(string address)
        {
            DeviceEnvironment env = ContextController.GetDeviceEnvironment();

            _mediaClient = new MediaServiceProvider(address, env.Timeouts.Message);
            _mediaClient.ExceptionThrown    += OnExceptionThrown;
            _mediaClient.OperationCompleted += OnOperationCompleted;
            _mediaClient.OperationStarted   += OnOperationStarted;
            _mediaClient.OnProfilesReceived += OnProfilesReceived;
            _mediaClient.OnVideoSourceConfigurationsReceived += OnSourceConfigsReceived;
            _mediaClient.OnVideoEncoderConfigurationReceived += OnVideoEncoderConfigsReceived;
            _mediaClient.OnVideoEncoderConfigOptionsReceived += OnVideoEncoderConfigOptionsReceived;
            _mediaClient.OnAudioSourceConfigurationsReceived += OnAudioSourceConfigsReceived;
            _mediaClient.OnAudioEncoderConfigurationReceived += OnAudioEncoderConfigsReceived;
            _mediaClient.OnAudioEncoderConfigOptionsReceived += OnAudioEncoderConfigOptionsReceived;
            _mediaClient.OnMediaUriReceived += OnMediaUriReceived;
            _mediaClient.Timeout             = env.Timeouts.Message;
            _mediaClient.ResponseReceived   += OnResponseReceived;

            _mediaClient.Security = ContextController.GetDebugInfo().Security;
        }
예제 #3
0
        public void QueryVideoSources()
        {
            DiscoveredDevices         devices      = ContextController.GetDiscoveredDevices();
            string                    address      = devices != null ? devices.ServiceAddress : string.Empty;
            DeviceEnvironment         env          = ContextController.GetDeviceEnvironment();
            ManagementServiceProvider deviceClient = new ManagementServiceProvider(address, env.Timeouts.Message);

            ReportOperationStarted();
            Thread thread = new Thread(new ThreadStart(new Action(() =>
            {
                try
                {
                    DeviceServicesInfo info         = deviceClient.GetCapabilitiesDefineSecurity(new Onvif.CapabilityCategory[] { Onvif.CapabilityCategory.Media });
                    Onvif.Capabilities capabilities = info.Capabilities;

                    string mediaAddress = string.Empty;

                    if (capabilities != null)
                    {
                        if (capabilities.Media != null)
                        {
                            mediaAddress = capabilities.Media.XAddr;
                        }
                        else
                        {
                            throw new Exception("Device does not support Media service");
                        }
                    }
                    else
                    {
                        if (info.Services != null)
                        {
                            Onvif.Service mediaService = Tests.Common.CommonUtils.Extensions.FindService(
                                info.Services, OnvifService.MEDIA);
                            if (mediaService != null)
                            {
                                mediaAddress = mediaService.XAddr;
                            }
                            else
                            {
                                throw new Exception("Device does not support Media service");
                            }
                        }
                        else
                        {
                            throw new Exception("Unable to get service address");
                        }
                    }

                    MediaServiceProvider client = new MediaServiceProvider(mediaAddress, env.Timeouts.Message);
                    client.Security             = deviceClient.Security;
                    Onvif.VideoSource[] sources = client.GetVideoSources();
                    if ((sources != null) && (sources.Length > 0))
                    {
                        View.SettingsView.SetVideoSources(sources);
                    }
                    else
                    {
                        throw new Exception("No Video Sources returned by device");
                    }
                }
                catch (System.Exception ex)
                {
                    View.ShowError(ex);
                }
                finally
                {
                    ReportOperationCompleted();
                }
            })));

            thread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
            thread.Start();
        }