コード例 #1
0
 /// <summary>
 /// Gets media profiles with PTZ configuration
 /// </summary>
 public void AddPTZConfiguration(Onvif.Profile profile)
 {
     _ptzClientWorking = true;
     IntializePtzClient(View.PTZAddress);
     _profile = profile;
     _ptzClient.GetConfigurations();
 }
コード例 #2
0
ファイル: PtzPage.cs プロジェクト: kudrinyaroslav/ON-0110
 private void ContinuousMove(bool panTilt, bool zoom)
 {
     Onvif.Profile profile = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
     if (profile == null)
     {
         ShowPrompt("Select profile with PTZ configuration", "Error");
     }
     else
     {
         int timeout = -1;
         if (chkUseTimeout.Checked && (!int.TryParse(tbTimeout.Text, out timeout) || (timeout < 0)))
         {
             ShowPrompt("Incorrect timeout", "Error");
         }
         else
         {
             try
             {
                 Controller.ContinuousMove(profile.token, panTilt, zoom, nudVx.Value, nudVy.Value, nudVzoom.Value, timeout);
             }
             catch (Exception ex)
             {
                 ShowError(ex);
             }
         }
     }
 }
コード例 #3
0
ファイル: PtzPage.cs プロジェクト: kudrinyaroslav/ON-0110
 private void IncrementalAbsoluteRelativeMove(bool x, bool y, bool z)
 {
     Onvif.Profile profile = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
     if (profile == null)
     {
         ShowPrompt("Select profile with PTZ configuration", "Error");
     }
     else
     {
         try
         {
             Controller.AbosuteRelativeIncrementalMove(
                 rbAbsoluteMove.Checked,
                 profile.token,
                 x ? -1 : nudX.Value,
                 x ? 1 : nudX.Value,
                 y ? -1 : nudY.Value,
                 y ? 1 : nudY.Value,
                 z ? 0 : nudZoom.Value,
                 z ? 1 : nudZoom.Value);
         }
         catch (Exception ex)
         {
             ShowError(ex);
         }
     }
     //rbAbsoluteMove.Checked = true; //why it loses selection?
 }
コード例 #4
0
        /// <summary>
        /// Get stream uri for specified profile
        /// </summary>
        /// <param name="profile">Media profile</param>
        /// <param name="protocol"></param>
        public void GetMediaUri(Onvif.Profile profile, Onvif.TransportProtocol protocol)
        {
            string address = View.MediaAddress;

            _mediaClientWorking = true;
            InitializeMediaClient(address);
            _mediaClient.GetMediaUri(profile, protocol);
        }
コード例 #5
0
ファイル: PtzPage.cs プロジェクト: kudrinyaroslav/ON-0110
        private void cmbPTZProfiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            Onvif.Profile          profile = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
            Onvif.PTZConfiguration config  = profile != null ? profile.PTZConfiguration : null;
            btnAddPTZConfig.Enabled = (config == null);

            panelAbsoluteMove.Enabled  = (rbAbsoluteMove.Checked || rbRelativeMove.Checked) && !string.IsNullOrEmpty(PTZAddress) && (config != null);
            panelContiniusMove.Enabled = rbContuniousMove.Checked && !string.IsNullOrEmpty(PTZAddress) && (config != null);
            rbAbsoluteMove.Enabled     = !string.IsNullOrEmpty(PTZAddress) && (config != null);
            rbRelativeMove.Enabled     = !string.IsNullOrEmpty(PTZAddress) && (config != null);
            rbContuniousMove.Enabled   = !string.IsNullOrEmpty(PTZAddress) && (config != null);
        }
コード例 #6
0
ファイル: PtzPage.cs プロジェクト: kudrinyaroslav/ON-0110
 private void btnAddPTZConfig_Click(object sender, EventArgs e)
 {
     try
     {
         Onvif.Profile profile = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
         Controller.AddPTZConfiguration(profile);
     }
     catch (Exception ex)
     {
         ShowError(ex);
     }
 }
コード例 #7
0
ファイル: PtzPage.cs プロジェクト: kudrinyaroslav/ON-0110
 public void OnPTZConfigurationAdded(string profile, string config)
 {
     Invoke(new Action(() =>
     {
         foreach (object item in cmbPTZProfiles.Items)
         {
             Onvif.Profile mediaProfile = (item as ProfileWrapper).Profile;
             if (mediaProfile.token == profile)
             {
                 //this is for disabling Add config button
                 mediaProfile.PTZConfiguration = new Onvif.PTZConfiguration();
                 break;
             }
         }
     }));
 }
コード例 #8
0
        /// <summary>
        /// Get stream uri with specified configurations
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="videoSourceConfig">Video source configuration</param>
        /// <param name="videoEncoderConfig">Video encoder configuration</param>
        /// <param name="audioSourceConfig">Audio source configuration</param>
        /// <param name="audioEncoderConfig">Audio encoder configuration</param>
        /// <param name="protocol"></param>
        public void GetMediaUri(
            Onvif.Profile profile,
            Onvif.VideoSourceConfiguration videoSourceConfig,
            Onvif.VideoEncoderConfiguration videoEncoderConfig,
            Onvif.AudioSourceConfiguration audioSourceConfig,
            Onvif.AudioEncoderConfiguration audioEncoderConfig,
            Onvif.TransportProtocol protocol)
        {
            if ((videoEncoderConfig == null) || (videoSourceConfig == null))
            {
                throw new ArgumentNullException();
            }
            string address = View.MediaAddress;

            _mediaClientWorking = true;
            InitializeMediaClient(address);
            _mediaClient.GetMediaUri(profile, videoSourceConfig, videoEncoderConfig, audioSourceConfig, audioEncoderConfig, protocol);
        }
コード例 #9
0
ファイル: PtzPage.cs プロジェクト: kudrinyaroslav/ON-0110
 private void Stop(bool panTilt, bool zoom)
 {
     Onvif.Profile profile = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
     if (profile == null)
     {
         ShowPrompt("Select profile with PTZ configuration", "Error");
     }
     else
     {
         try
         {
             Controller.Stop(profile.token, panTilt, zoom);
         }
         catch (Exception ex)
         {
             ShowError(ex);
         }
     }
 }
コード例 #10
0
ファイル: PtzPage.cs プロジェクト: kudrinyaroslav/ON-0110
 private void Stop(bool panTilt, bool zoom)
 {
     Onvif.Profile profile = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
     if (profile == null)
     {
         MessageBox.Show(this, "Select profile with PTZ configuration", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             Controller.Stop(profile.token, panTilt, zoom);
         }
         catch (Exception ex)
         {
             ShowError(ex);
         }
     }
 }
コード例 #11
0
ファイル: PtzPage.cs プロジェクト: kudrinyaroslav/ON-0110
 private void AbsoluteRelativeMove()
 {
     Onvif.Profile profile = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
     if (profile == null)
     {
         MessageBox.Show(this, "Select profile with PTZ configuration", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             Controller.AbosuteRelativeMove(rbAbsoluteMove.Checked, profile.token, nudX.Value, nudY.Value, nudZoom.Value);
         }
         catch (Exception ex)
         {
             ShowError(ex);
         }
     }
     //rbAbsoluteMove.Checked = true; //why it loses selection?
 }
コード例 #12
0
ファイル: PtzPage.cs プロジェクト: kudrinyaroslav/ON-0110
        public void EnableControls(bool enable)
        {
            Invoke(new Action(() =>
            {
                DiscoveredDevices devices = ContextController.GetDiscoveredDevices();
                string address            = devices != null ? devices.ServiceAddress : string.Empty;

                Onvif.Profile profile         = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
                Onvif.PTZConfiguration config = profile != null ? profile.PTZConfiguration : null;

                btnGetPtzUrl.Enabled       = enable && !string.IsNullOrEmpty(address);
                btnGetProfiles.Enabled     = enable && !string.IsNullOrEmpty(MediaAddress);
                btnVideo.Enabled           = (enable && !string.IsNullOrEmpty(MediaAddress)) || (_videoWindow != null);
                rbAbsoluteMove.Enabled     = enable && !string.IsNullOrEmpty(PTZAddress) && (config != null);
                rbRelativeMove.Enabled     = enable && !string.IsNullOrEmpty(PTZAddress) && (config != null);
                rbContuniousMove.Enabled   = enable && !string.IsNullOrEmpty(PTZAddress) && (config != null);
                panelAbsoluteMove.Enabled  = enable && (rbAbsoluteMove.Checked || rbRelativeMove.Checked) && !string.IsNullOrEmpty(PTZAddress) && (config != null);
                panelContiniusMove.Enabled = enable && rbContuniousMove.Checked && !string.IsNullOrEmpty(PTZAddress) && (config != null);
                btnAddPTZConfig.Enabled    = enable && (profile != null) && (config == null);

                cmbPTZProfiles.Enabled = enable;
            }));
        }
コード例 #13
0
        private void cmbMediaProfile_SelectedIndexChanged(object sender, EventArgs e)
        {
            Media.Profile profile             = ((MediaProfileWrapper)cmbMediaProfile.SelectedItem).Profile;
            bool          testProfileSelected = IsTestProfile(profile);

            cmbAudioCodec.Items.Clear();
            cmbAudioEncoder.Items.Clear();
            cmbAudioSource.Items.Clear();
            cmbVideoCodec.Items.Clear();
            cmbVideoEncoder.Items.Clear();
            cmbVideoResolution.Items.Clear();
            cmbVideoSource.Items.Clear();
            cmbAudioBitrate.Items.Clear();
            txtVideoBitrate.Text   = null;
            txtVideoFramerate.Text = null;
            if (!testProfileSelected)
            {
                if (profile.VideoSourceConfiguration != null)
                {
                    cmbVideoSource.Items.Add(new VideoSourceConfigurationWrapper()
                    {
                        Configuration = profile.VideoSourceConfiguration
                    });
                    cmbVideoSource.SelectedIndex = 0;
                }
                if (profile.VideoEncoderConfiguration != null)
                {
                    cmbVideoEncoder.Items.Add(new VideoEncoderConfigurationWrapper()
                    {
                        Configuration = profile.VideoEncoderConfiguration
                    });
                    cmbVideoEncoder.SelectedIndex = 0;

                    cmbVideoCodec.Items.Add(profile.VideoEncoderConfiguration.Encoding);
                    cmbVideoCodec.SelectedIndex = 0;

                    cmbVideoResolution.Items.Add(new VideoResolutionWrapper()
                    {
                        Resolution = profile.VideoEncoderConfiguration.Resolution
                    });
                    cmbVideoResolution.SelectedIndex = 0;

                    if (profile.VideoEncoderConfiguration.RateControl != null)
                    {
                        txtVideoBitrate.Text   = profile.VideoEncoderConfiguration.RateControl.BitrateLimit.ToString();
                        txtVideoFramerate.Text = profile.VideoEncoderConfiguration.RateControl.FrameRateLimit.ToString();
                    }
                }
                if (profile.AudioSourceConfiguration != null)
                {
                    cmbAudioSource.Items.Add(new AudioSourceConfigurationWrapper()
                    {
                        Configuration = profile.AudioSourceConfiguration
                    });
                    cmbAudioSource.SelectedIndex = 0;
                }
                if (profile.AudioEncoderConfiguration != null)
                {
                    cmbAudioEncoder.Items.Add(new AudioEncoderConfigurationWrapper()
                    {
                        Configuration = profile.AudioEncoderConfiguration
                    });
                    cmbAudioEncoder.SelectedIndex = 0;

                    cmbAudioCodec.Items.Add(profile.AudioEncoderConfiguration.Encoding);
                    cmbAudioCodec.SelectedIndex = 0;

                    cmbAudioBitrate.Items.Add(profile.AudioEncoderConfiguration.Bitrate);
                    cmbAudioBitrate.SelectedIndex = 0;
                }
            }

            EnableControls(true); //refresh controls disabling
        }
コード例 #14
0
 protected bool IsTestProfile(Media.Profile profile)
 {
     return(profile.Name == MediaServiceProvider.TestMediaProfileName);
 }