public void RemovePreset()
        {
            string presetToken = null;

            Media.Profile profile     = null;
            bool          presetAdded = false;

            RunTest(() =>
            {
                PTZConfigurationOptions options;
                profile = GetPTZProfile(_ptzNodeToken, out options);
                Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);

                string presetName   = "Test";
                presetToken         = SetPreset(profile.token, presetName, null);
                presetAdded         = true;
                PTZPreset[] presets = GetPresets(profile.token);
                CheckPreset(presets, presetToken, presetName, null);

                RemovePreset(profile.token, presetToken);
                presetAdded = false;
                presets     = GetPresets(profile.token);
                CheckNoPreset(presets, presetToken);
            },
                    () =>
            {
                if (presetAdded)
                {
                    RemovePreset(profile.token, presetToken);
                }
            });
        }
Exemplo n.º 2
0
 private void IncrementalAbsoluteRelativeMove(bool x, bool y, bool z)
 {
     Media.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.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?
 }
Exemplo n.º 3
0
 /// <summary>
 /// Gets media profiles with PTZ configuration
 /// </summary>
 public void AddPTZConfiguration(Media.Profile profile)
 {
     _ptzClientWorking = true;
     IntializePtzClient(View.PTZAddress);
     _profile = profile;
     _ptzClient.GetConfigurations();
 }
Exemplo n.º 4
0
        public void ContinuousMoveStopTest()
        {
            RunTest(() =>
            {
                PTZConfigurationOptions options;
                Media.Profile profile = GetPTZProfile(_ptzNodeToken, out options);
                Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);
                string reason = null;
                //TODO add validation
                //Assert(ValidatePTZConfiguration(profile.PTZConfiguration, out reason), reason, Resources.StepValidatePTZConfig_Title);

                Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title);

                //check pan\tilt movement
                PTZSpeed velocity      = new PTZSpeed();
                velocity.PanTilt       = new Vector2D();
                velocity.PanTilt.space = options.Spaces.ContinuousPanTiltVelocitySpace[0].URI;
                velocity.PanTilt.x     = options.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Max;
                velocity.PanTilt.y     = options.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Max;
                CheckContinuousMove(profile.token, velocity, null, options);

                if ((options.Spaces.ContinuousZoomVelocitySpace != null) && (options.Spaces.ContinuousZoomVelocitySpace.Length > 0))
                {
                    //check zoom movement if supported
                    PTZSpeed zoomVelocity   = new PTZSpeed();
                    zoomVelocity.Zoom       = new Vector1D();
                    zoomVelocity.Zoom.space = options.Spaces.ContinuousZoomVelocitySpace[0].URI;
                    zoomVelocity.Zoom.x     = options.Spaces.ContinuousZoomVelocitySpace[0].XRange.Max;
                    CheckContinuousMove(profile.token, zoomVelocity, null, options);
                }
            });
        }
Exemplo n.º 5
0
 private void ContinuousMove(bool panTilt, bool zoom)
 {
     Media.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
     {
         int timeout = -1;
         if (chkUseTimeout.Checked && (!int.TryParse(tbTimeout.Text, out timeout) || (timeout < 0)))
         {
             MessageBox.Show(this, "Incorrect timeout", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             try
             {
                 Controller.ContinuousMove(profile.token, panTilt, zoom, nudVx.Value, nudVy.Value, nudVzoom.Value, timeout);
             }
             catch (Exception ex)
             {
                 ShowError(ex);
             }
         }
     }
 }
Exemplo n.º 6
0
        public void AbsoluteMoveFaultTest()
        {
            RunTest(() =>
            {
                PTZConfigurationOptions options;
                Media.Profile profile = GetPTZProfile(_ptzNodeToken, out options);
                Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);

                string reason = null;
                Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title);

                if (Features.Contains(Feature.PTZAbsolutePanTilt))
                {
                    PTZVector pantilt     = new PTZVector();
                    pantilt.PanTilt       = new Vector2D();
                    pantilt.PanTilt.space = options.Spaces.AbsolutePanTiltPositionSpace[0].URI;
                    pantilt.PanTilt.x     = options.Spaces.AbsolutePanTiltPositionSpace[0].XRange.Max + 1;
                    pantilt.PanTilt.y     = options.Spaces.AbsolutePanTiltPositionSpace[0].YRange.Max + 1;
                    AbsoluteInvalidMove(profile.token, pantilt);
                }
                else if (Features.Contains(Feature.PTZAbsoluteZoom))
                {
                    PTZVector zoom  = new PTZVector();
                    zoom.Zoom       = new Vector1D();
                    zoom.Zoom.space = options.Spaces.AbsoluteZoomPositionSpace[0].URI;
                    zoom.Zoom.x     = options.Spaces.AbsoluteZoomPositionSpace[0].XRange.Max + 1;
                    AbsoluteInvalidMove(profile.token, zoom);
                }
            });
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get stream uri for specified profile
        /// </summary>
        /// <param name="profile">Media profile</param>
        /// <param name="protocol"></param>
        public void GetMediaUri(Media.Profile profile, Media.TransportProtocol protocol)
        {
            string address = View.MediaAddress;

            _mediaClientWorking = true;
            InitializeMediaClient(address);
            _mediaClient.GetMediaUri(profile, protocol);
        }
Exemplo n.º 8
0
 private void btnAddPTZConfig_Click(object sender, EventArgs e)
 {
     try
     {
         Media.Profile profile = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
         Controller.AddPTZConfiguration(profile);
     }
     catch (Exception ex)
     {
         ShowError(ex);
     }
 }
Exemplo n.º 9
0
        private void cmbPTZProfiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            Media.Profile          profile = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
            Media.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);
        }
Exemplo n.º 10
0
 public void OnPTZConfigurationAdded(string profile, string config)
 {
     Invoke(new Action(() =>
     {
         foreach (object item in cmbPTZProfiles.Items)
         {
             Media.Profile mediaProfile = (item as ProfileWrapper).Profile;
             if (mediaProfile.token == profile)
             {
                 //this is for disabling Add config button
                 mediaProfile.PTZConfiguration = new Media.PTZConfiguration();
                 break;
             }
         }
     }));
 }
Exemplo n.º 11
0
        public void GenericPanTiltVelocity()
        {
            RunTest(() =>
            {
                PTZNode[] nodes = GetNodes();
                foreach (PTZNode node in nodes)
                {
                    string reason = null;
                    Assert(ValidatePTZNode(node, out reason), reason, Resources.StepValidatePTZNode_Title);

                    Space2DDescription[] spaces = node.SupportedPTZSpaces.ContinuousPanTiltVelocitySpace;
                    Space2DDescription generic  = spaces != null ?
                                                  spaces.FirstOrDefault(space => string.Compare(space.URI, _continuousPanTiltSpace) == 0) :
                                                  null;

                    Assert((generic != null) && (generic.XRange != null) && (generic.YRange != null),
                           "Node does not support generic continuous pan/tilt velocity space or space ranges are missing",
                           "Validating generic continuous pan/tilt velocity space");

                    PTZConfigurationOptions options;
                    Media.Profile profile = GetPTZProfile(node, out options);
                    Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);

                    //PTZNode node = GetNode(profile.PTZConfiguration.NodeToken);

                    //check max ranges
                    PTZSpeed velocity      = new PTZSpeed();
                    velocity.PanTilt       = new Vector2D();
                    velocity.PanTilt.space = generic.URI;
                    velocity.PanTilt.x     = generic.XRange.Max;
                    velocity.PanTilt.y     = generic.YRange.Max;

                    ContinuousMove(profile.token, velocity, null);
                    RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move"));

                    //check min ranges
                    velocity.PanTilt.x = generic.XRange.Min;
                    velocity.PanTilt.y = generic.YRange.Min;

                    ContinuousMove(profile.token, velocity, null);
                    RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move"));

                    Stop(profile.token, true, false);
                }
            });
        }
Exemplo n.º 12
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(
            Media.Profile profile,
            Media.VideoSourceConfiguration videoSourceConfig,
            Media.VideoEncoderConfiguration videoEncoderConfig,
            Media.AudioSourceConfiguration audioSourceConfig,
            Media.AudioEncoderConfiguration audioEncoderConfig,
            Media.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);
        }
Exemplo n.º 13
0
        public void ContinuousMoveTest()
        {
            RunTest(() =>
            {
                PTZConfigurationOptions options;
                Media.Profile profile = GetPTZProfile(_ptzNodeToken, out options);
                Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);

                string reason = null;
                Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title);

                string timeout = "PT60S";//60 seconds by default
                //check ranges
                TimeSpan min = System.Xml.XmlConvert.ToTimeSpan(options.PTZTimeout.Min);
                TimeSpan max = System.Xml.XmlConvert.ToTimeSpan(options.PTZTimeout.Max);
                if (min.TotalMinutes > 1)
                {
                    timeout = options.PTZTimeout.Min;
                }
                else if (max.TotalMinutes < 1)
                {
                    timeout = options.PTZTimeout.Max;
                }

                //check pan\tilt movement
                PTZSpeed velocity      = new PTZSpeed();
                velocity.PanTilt       = new Vector2D();
                velocity.PanTilt.space = options.Spaces.ContinuousPanTiltVelocitySpace[0].URI;
                velocity.PanTilt.x     = options.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Max;
                velocity.PanTilt.y     = options.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Max;
                CheckContinuousMove(profile.token, velocity, timeout, options);

                if (Features.Contains(Feature.PTZContiniousZoom))
                {
                    //check zoom movement if supported
                    PTZSpeed zoomVelocity   = new PTZSpeed();
                    zoomVelocity.Zoom       = new Vector1D();
                    zoomVelocity.Zoom       = new Vector1D();
                    zoomVelocity.Zoom.space = options.Spaces.ContinuousZoomVelocitySpace[0].URI;
                    zoomVelocity.Zoom.x     = options.Spaces.ContinuousZoomVelocitySpace[0].XRange.Max;
                    CheckContinuousMove(profile.token, zoomVelocity, timeout, options);
                }
            });
        }
Exemplo n.º 14
0
 private void Stop(bool panTilt, bool zoom)
 {
     Media.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);
         }
     }
 }
Exemplo n.º 15
0
        public void GenericPanTiltTranslation()
        {
            RunTest(() =>
            {
                PTZNode[] nodes = GetNodes();
                foreach (PTZNode node in nodes)
                {
                    string reason = null;
                    Assert(ValidatePTZNode(node, out reason), reason, Resources.StepValidatePTZNode_Title);

                    Space2DDescription[] spaces = node.SupportedPTZSpaces.RelativePanTiltTranslationSpace;
                    Space2DDescription generic  = spaces != null ?
                                                  spaces.FirstOrDefault(space => string.Compare(space.URI, _relativePanTiltSpace) == 0) :
                                                  null;

                    Assert((generic != null) && (generic.XRange != null) && (generic.YRange != null),
                           "Node does not support generic relative pan/tilt translation space or space ranges are missing",
                           "Validating generic relative pan/tilt translation space");

                    PTZConfigurationOptions options;
                    Media.Profile profile = GetPTZProfile(node, out options);
                    Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);

                    //PTZNode node = GetNode(profile.PTZConfiguration.NodeToken);

                    //check max ranges
                    PTZVector vector     = new PTZVector();
                    vector.PanTilt       = new Vector2D();
                    vector.PanTilt.space = generic.URI;
                    vector.PanTilt.x     = generic.XRange.Max;
                    vector.PanTilt.y     = generic.YRange.Max;

                    RelativeMove(profile.token, vector, null);

                    //check min ranges
                    vector.PanTilt.x = generic.XRange.Min;
                    vector.PanTilt.y = generic.YRange.Min;

                    RelativeMove(profile.token, vector, null);
                }
            });
        }
        public void AuxiliaryCommand()
        {
            RunTest(() =>
            {
                PTZConfigurationOptions options;
                Media.Profile profile = GetPTZProfile(_ptzNodeToken, out options);
                Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);

                PTZNode node = GetNode(profile.PTZConfiguration.NodeToken);

                Assert((node.AuxiliaryCommands != null) && (node.AuxiliaryCommands.Length > 0),
                       string.Format("Node [token={0}] does not contain auxiliary commands", node.token),
                       "Checking auxiliary commands list");

                foreach (string command in node.AuxiliaryCommands)
                {
                    SendAuxiliaryCommnad(profile.token, command);
                }
            });
        }
Exemplo n.º 17
0
        public void GenericZoomPosition()
        {
            RunTest(() =>
            {
                PTZNode[] nodes = GetNodes();
                foreach (PTZNode node in nodes)
                {
                    string reason = null;
                    Assert(ValidatePTZNode(node, out reason), reason, Resources.StepValidatePTZNode_Title);

                    Space1DDescription[] spaces = node.SupportedPTZSpaces.AbsoluteZoomPositionSpace;
                    Space1DDescription generic  = spaces != null ?
                                                  spaces.FirstOrDefault(space => string.Compare(space.URI, _absoluteZoomSpace) == 0) :
                                                  null;

                    Assert((generic != null) && (generic.XRange != null),
                           "Node does not support generic absolute zoom position space or space ranges are missing",
                           "Validating generic absolute zoom position space");

                    PTZConfigurationOptions options;
                    Media.Profile profile = GetPTZProfile(node, out options);
                    Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);

                    //check max ranges
                    PTZVector vector  = new PTZVector();
                    vector.Zoom       = new Vector1D();
                    vector.Zoom.space = generic.URI;
                    vector.Zoom.x     = generic.XRange.Max;

                    AbsoluteMove(profile.token, vector, null);

                    //check min ranges
                    vector.Zoom.x = generic.XRange.Min;

                    AbsoluteMove(profile.token, vector, null);
                }
            });
        }
Exemplo n.º 18
0
        public void EnableControls(bool enable)
        {
            Invoke(new Action(() =>
            {
                DiscoveredDevices devices = ContextController.GetDiscoveredDevices();
                string address            = devices != null ? devices.ServiceAddress : string.Empty;

                Media.Profile profile         = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
                Media.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;
            }));
        }
        public void FixedHome()
        {
            RunTest(() =>
            {
                PTZConfigurationOptions options;
                Media.Profile profile = GetPTZProfile(_ptzNodeToken, out options);
                Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);

                string reason;
                Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.token, out reason), reason, Resources.StepValidatePTZConfigOptions_Title);

                GotoHomePosition(profile.token, null, _homeMoveTimeout);

                //absolute or relative move should be supported - use generic space for position or translation
                bool absoulteMoveSupported      = Features.Contains(Feature.PTZAbsolute);
                PTZVector vector                = new PTZVector();
                Space2DDescription pantiltSpace = null;
                Space1DDescription zoomSpace    = null;

                if (Features.Contains(Feature.PTZAbsolutePanTilt) || Features.Contains(Feature.PTZRelativePanTilt))
                {
                    pantiltSpace = absoulteMoveSupported ? options.Spaces.AbsolutePanTiltPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absolutePanTiltSpace, true) == 0) :
                                   options.Spaces.RelativePanTiltTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativePanTiltSpace, true) == 0);

                    vector.PanTilt       = new Vector2D();
                    vector.PanTilt.space = pantiltSpace.URI;
                    vector.PanTilt.x     = pantiltSpace.XRange.Max;
                    vector.PanTilt.y     = pantiltSpace.YRange.Max;
                }
                if (Features.Contains(Feature.PTZAbsoluteZoom) || Features.Contains(Feature.PTZRelativeZoom))
                {
                    zoomSpace = absoulteMoveSupported ? options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0) :
                                options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0);

                    vector.Zoom       = new Vector1D();
                    vector.Zoom.space = zoomSpace.URI;
                    vector.Zoom.x     = zoomSpace.XRange.Max;
                }

                //make sure current position is different to destination
                PTZStatus status       = GetPTZStatus(profile.token);
                PTZVector homePosition = status.Position;
                if ((homePosition != null) && (EqualPositions(homePosition, vector)))
                {
                    if (vector.PanTilt != null)
                    {
                        vector.PanTilt.x = 0;
                    }
                    else if (vector.Zoom != null)
                    {
                        vector.Zoom.x = 0;
                    }
                }
                if (absoulteMoveSupported)
                {
                    AbsoluteMove(profile.token, vector, null);
                }
                else
                {
                    RelativeMove(profile.token, vector, null);
                }

                SetFixedHomePosition(profile.token);

                GotoHomePosition(profile.token, null, _homeMoveTimeout);
                status = GetPTZStatus(profile.token);
                if (status.Position != null)
                {
                    CheckPTZPosition(status.Position, homePosition, homePosition);
                }
                else
                {
                    OpenVideo();
                    Assert(_operator.GetYesNoAnswer(string.Format("Is camera in position [{0}]?", PositionToString(homePosition))),
                           "Camera is in wrong position",
                           "Camera position check (manual)");
                    CloseVideo();
                }
            },
                    () =>
            {
                CloseVideo();
            });
        }
Exemplo n.º 20
0
 protected bool IsTestProfile(Media.Profile profile)
 {
     return(profile.Name == MediaServiceProvider.TestMediaProfileName);
 }
Exemplo n.º 21
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
        }
Exemplo n.º 22
0
        public void RelativeMoveTest()
        {
            RunTest(() =>
            {
                PTZConfigurationOptions options;
                Media.Profile profile = GetPTZProfile(_ptzNodeToken, out options);
                Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);
                string reason = null;

                Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title);

                //Set default spaces to generic, if they are not. We need it to get position in generic spaces
                bool changed = false;
                if (Features.Contains(Feature.PTZRelativePanTilt) && !EqualSpaces(_absolutePanTiltSpace, profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace))
                {
                    profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace = _absolutePanTiltSpace;
                    changed = true;
                }
                if (Features.Contains(Feature.PTZRelativeZoom) && !EqualSpaces(_absoluteZoomSpace, profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace))
                {
                    profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace = _absoluteZoomSpace;
                    changed = true;
                }
                if (changed)
                {
                    SetConfiguration(profile.PTZConfiguration, false, string.Format("DefaultAbsolutePantTiltPositionSpace={0}, DefaultAbsoluteZoomPositionSpace={1}", profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace, profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace));
                }

                PTZStatus status      = GetPTZStatus(profile.token);
                PTZVector oldPosition = status.Position;
                PTZVector pantilt     = null;
                PTZVector zoom        = null;

                Space1DDescription zoomOptions    = options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(o => string.Compare(o.URI, _relativeZoomSpace, true) == 0);
                Space2DDescription pantiltOptions = options.Spaces.RelativePanTiltTranslationSpace.FirstOrDefault(o => string.Compare(o.URI, _relativePanTiltSpace, true) == 0);

                if (Features.Contains(Feature.PTZRelativePanTilt))
                {
                    PTZSpeed speed = null;
                    if ((options.Spaces.PanTiltSpeedSpace != null) && (options.Spaces.PanTiltSpeedSpace.Length > 0))
                    {
                        Space1DDescription space = options.Spaces.PanTiltSpeedSpace[0];
                        speed               = new PTZSpeed();
                        speed.PanTilt       = new Vector2D();
                        speed.PanTilt.space = space.URI;
                        speed.PanTilt.x     = space.XRange.Max;
                        speed.PanTilt.y     = space.XRange.Max;
                    }
                    pantilt         = new PTZVector();
                    pantilt.PanTilt = new Vector2D();
                    //use generic space, so we can calculate new position
                    pantilt.PanTilt.space = pantiltOptions.URI;        //options.Spaces.RelativePanTiltTranslationSpace[0].URI;
                    pantilt.PanTilt.x     = pantiltOptions.XRange.Max; // options.Spaces.RelativePanTiltTranslationSpace[0].XRange.Max;
                    pantilt.PanTilt.y     = pantiltOptions.YRange.Max; // options.Spaces.RelativePanTiltTranslationSpace[0].YRange.Max;
                    RelativeMove(profile.token, pantilt, speed);
                }
                if (Features.Contains(Feature.PTZRelativeZoom))
                {
                    PTZSpeed speed = null;
                    if ((options.Spaces.ZoomSpeedSpace != null) && (options.Spaces.ZoomSpeedSpace.Length > 0))
                    {
                        Space1DDescription space = options.Spaces.ZoomSpeedSpace[0];
                        speed            = new PTZSpeed();
                        speed.Zoom       = new Vector1D();
                        speed.Zoom.space = space.URI;
                        speed.Zoom.x     = space.XRange.Max;
                    }
                    zoom            = new PTZVector();
                    zoom.Zoom       = new Vector1D();
                    zoom.Zoom.space = zoomOptions.URI;
                    zoom.Zoom.x     = zoomOptions.XRange.Max;
                    RelativeMove(profile.token, zoom, speed);
                }

                status = GetPTZStatus(profile.token);
                if ((status.Position != null) && (oldPosition != null))
                {
                    //translate position
                    if ((oldPosition.PanTilt != null) && (pantilt != null))
                    {
                        pantilt.PanTilt.x = pantilt.PanTilt.x + oldPosition.PanTilt.x > 1 ? 1 : pantilt.PanTilt.x + oldPosition.PanTilt.x;
                        pantilt.PanTilt.y = pantilt.PanTilt.y + oldPosition.PanTilt.y > 1 ? 1 : pantilt.PanTilt.y + oldPosition.PanTilt.y;
                    }
                    if ((oldPosition.Zoom != null) && (zoom != null))
                    {
                        zoom.Zoom.x = zoom.Zoom.x + oldPosition.Zoom.x > 1 ? 1 : zoom.Zoom.x + oldPosition.Zoom.x;
                    }

                    //change relative spaces to absolute spaces, because status returns position in absolute space
                    if (pantilt != null)
                    {
                        pantilt.PanTilt.space = _absolutePanTiltSpace;
                    }
                    if (zoom != null)
                    {
                        zoom.Zoom.space = _absoluteZoomSpace;
                    }
                    CheckPTZPosition(status.Position, pantilt, zoom);
                }
            });
        }
Exemplo n.º 23
0
        public void AbsoluteMoveTest()
        {
            RunTest(() =>
            {
                PTZConfigurationOptions options;
                Media.Profile profile = GetPTZProfile(_ptzNodeToken, out options);
                Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);
                string reason = null;

                Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title);

                //select pantilt and zoom spaces
                Space2DDescription pantiltSpace = null;
                Space1DDescription zoomSpace    = null;
                if (Features.Contains(Feature.PTZAbsolutePanTilt))
                {
                    pantiltSpace = options.Spaces.AbsolutePanTiltPositionSpace[0];
                }
                if (Features.Contains(Feature.PTZAbsoluteZoom))
                {
                    zoomSpace = options.Spaces.AbsoluteZoomPositionSpace[0];
                }

                //set selected spaces as default if they are not (we need it to get position in these spaces)
                if (((pantiltSpace != null) && !EqualSpaces(pantiltSpace.URI, profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace)) ||
                    ((zoomSpace != null) && !EqualSpaces(zoomSpace.URI, profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace)))
                {
                    profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace = pantiltSpace != null ? pantiltSpace.URI : null;
                    profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace     = zoomSpace != null ? zoomSpace.URI : null;
                    SetConfiguration(profile.PTZConfiguration, false, string.Format("DefaultAbsolutePantTiltPositionSpace={0}, DefaultAbsoluteZoomPositionSpace={1}", profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace, profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace));
                }

                PTZStatus status  = GetPTZStatus(profile.token);
                PTZVector pantilt = null;
                PTZVector zoom    = null;
                if (pantiltSpace != null)
                {
                    PTZSpeed speed = null;
                    if ((options.Spaces.PanTiltSpeedSpace != null) && (options.Spaces.PanTiltSpeedSpace.Length > 0))
                    {
                        Space1DDescription space = options.Spaces.PanTiltSpeedSpace[0];
                        speed               = new PTZSpeed();
                        speed.PanTilt       = new Vector2D();
                        speed.PanTilt.space = space.URI;
                        speed.PanTilt.x     = space.XRange.Max;
                        speed.PanTilt.y     = space.XRange.Max;
                    }
                    pantilt               = new PTZVector();
                    pantilt.PanTilt       = new Vector2D();
                    pantilt.PanTilt.space = pantiltSpace.URI;
                    pantilt.PanTilt.x     = pantiltSpace.XRange.Max;
                    pantilt.PanTilt.y     = pantiltSpace.YRange.Max;
                    AbsoluteMove(profile.token, pantilt, speed);
                }
                if (zoomSpace != null)
                {
                    PTZSpeed speed = null;
                    if ((options.Spaces.ZoomSpeedSpace != null) && (options.Spaces.ZoomSpeedSpace.Length > 0))
                    {
                        Space1DDescription space = options.Spaces.ZoomSpeedSpace[0];
                        speed            = new PTZSpeed();
                        speed.Zoom       = new Vector1D();
                        speed.Zoom.space = space.URI;
                        speed.Zoom.x     = space.XRange.Max;
                    }
                    zoom            = new PTZVector();
                    zoom.Zoom       = new Vector1D();
                    zoom.Zoom.space = zoomSpace.URI;
                    zoom.Zoom.x     = zoomSpace.XRange.Max;
                    AbsoluteMove(profile.token, zoom, speed);
                }

                status = GetPTZStatus(profile.token);
                if (status.Position != null)
                {
                    CheckPTZPosition(status.Position, pantilt, zoom);
                }
            });
        }
        public void GotoPreset()
        {
            string presetToken = null;

            Media.Profile profile = null;
            RunTest(() =>
            {
                PTZConfigurationOptions options;
                profile = GetPTZProfile(_ptzNodeToken, out options);
                Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);

                string reason;
                Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.token, out reason), reason, Resources.StepValidatePTZConfigOptions_Title);

                //absolute or relative move should be supported - use generic space for position or translation
                bool absoulteMoveSupported = Features.Contains(Feature.PTZAbsolute);
                PTZVector vector           = new PTZVector();

                Space2DDescription pantiltSpace = null;
                Space1DDescription zoomSpace    = null;
                if (Features.Contains(Feature.PTZAbsolutePanTilt) || Features.Contains(Feature.PTZRelativePanTilt))
                {
                    pantiltSpace = absoulteMoveSupported ? options.Spaces.AbsolutePanTiltPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absolutePanTiltSpace, true) == 0) :
                                   options.Spaces.RelativePanTiltTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativePanTiltSpace, true) == 0);
                    vector.PanTilt       = new Vector2D();
                    vector.PanTilt.space = pantiltSpace.URI;
                    vector.PanTilt.x     = pantiltSpace.XRange.Min;
                    vector.PanTilt.y     = pantiltSpace.YRange.Min;
                }
                if (Features.Contains(Feature.PTZAbsoluteZoom) || Features.Contains(Feature.PTZRelativeZoom))
                {
                    zoomSpace = absoulteMoveSupported ? options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0) :
                                options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0);
                    vector.Zoom       = new Vector1D();
                    vector.Zoom.space = zoomSpace.URI;
                    vector.Zoom.x     = zoomSpace.XRange.Min;
                }

                if (absoulteMoveSupported)
                {
                    AbsoluteMove(profile.token, vector, null);
                }
                else
                {
                    RelativeMove(profile.token, vector, null);
                }
                RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move"));

                string presetName = "Test";
                presetToken       = SetPreset(profile.token, presetName, null);

                //move to another position
                Vector2D oldPanTilt = vector.PanTilt;
                if (oldPanTilt != null)
                {
                    vector.PanTilt       = new Vector2D();
                    vector.PanTilt.space = oldPanTilt.space;
                    vector.PanTilt.x     = pantiltSpace.XRange.Max;
                    vector.PanTilt.y     = pantiltSpace.YRange.Max;
                }
                Vector1D oldZoom = vector.Zoom;
                if (oldZoom != null)
                {
                    vector.Zoom       = new Vector1D();
                    vector.Zoom.space = oldZoom.space;
                    vector.Zoom.x     = zoomSpace.XRange.Max;
                }
                if (absoulteMoveSupported)
                {
                    AbsoluteMove(profile.token, vector, null);
                }
                else
                {
                    RelativeMove(profile.token, vector, null);
                }
                RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move"));

                GotoPreset(profile.token, presetToken, null);
                RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move"));

                PTZStatus status = GetPTZStatus(profile.token);
                vector.PanTilt   = oldPanTilt;
                vector.Zoom      = oldZoom;
                if (status.Position != null)
                {
                    CheckPTZPosition(status.Position, vector, vector);
                }
                else
                {
                    OpenVideo();
                    Assert(_operator.GetYesNoAnswer(string.Format("Is camera in position [{0}]?", PositionToString(vector))),
                           "Camera is in wrong position",
                           "Camera position check (manual)");
                    CloseVideo();
                }

                RemovePreset(profile.token, presetToken);
                presetToken = null;
            },
                    () =>
            {
                CloseVideo();

                if ((presetToken != null) && (profile != null))
                {
                    RemovePreset(profile.token, presetToken);
                }
            });
        }
        public void SetGetPreset()
        {
            string presetToken = null;

            Media.Profile profile = null;
            RunTest(() =>
            {
                PTZConfigurationOptions options;
                profile = GetPTZProfile(_ptzNodeToken, out options);
                Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);
                string reason;
                Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.token, out reason), reason, Resources.StepValidatePTZConfigOptions_Title);
                //absolute or relative move should be supported - use generic space for position or translation
                bool absoulteMoveSupported = Features.Contains(Feature.PTZAbsolute);
                PTZVector vector           = new PTZVector();

                Space2DDescription pantiltSpace = null;
                Space1DDescription zoomSpace    = null;
                if (Features.Contains(Feature.PTZAbsolutePanTilt) || Features.Contains(Feature.PTZRelativePanTilt))
                {
                    pantiltSpace = absoulteMoveSupported ? options.Spaces.AbsolutePanTiltPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absolutePanTiltSpace, true) == 0) :
                                   options.Spaces.RelativePanTiltTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativePanTiltSpace, true) == 0);
                    vector.PanTilt       = new Vector2D();
                    vector.PanTilt.space = pantiltSpace.URI;
                    vector.PanTilt.x     = pantiltSpace.XRange.Min / 2;
                    vector.PanTilt.y     = pantiltSpace.YRange.Min / 2;
                }
                if (Features.Contains(Feature.PTZAbsoluteZoom) || Features.Contains(Feature.PTZRelativeZoom))
                {
                    zoomSpace = absoulteMoveSupported ? options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0) :
                                options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0);
                    vector.Zoom       = new Vector1D();
                    vector.Zoom.space = zoomSpace.URI;
                    vector.Zoom.x     = zoomSpace.XRange.Min;
                }

                if (absoulteMoveSupported)
                {
                    AbsoluteMove(profile.token, vector, null);
                }
                else
                {
                    RelativeMove(profile.token, vector, null);
                }
                RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move"));


                string presetName   = "Test";
                presetToken         = SetPreset(profile.token, presetName, null);
                PTZPreset[] presets = GetPresets(profile.token);
                CheckPreset(presets, presetToken, presetName, vector);

                //move to another position
                if (vector.PanTilt != null)
                {
                    vector.PanTilt.x = pantiltSpace.XRange.Max / 2;
                    vector.PanTilt.y = pantiltSpace.YRange.Max / 2;
                }
                if (vector.Zoom != null)
                {
                    vector.Zoom.x = zoomSpace.XRange.Max;
                }
                if (absoulteMoveSupported)
                {
                    AbsoluteMove(profile.token, vector, null);
                }
                else
                {
                    RelativeMove(profile.token, vector, null);
                }
                RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move"));

                SetPreset(profile.token, presetName, presetToken);
                presets = GetPresets(profile.token);

                if (!absoulteMoveSupported && (vector.PanTilt != null))
                {
                    //in case of relative move consider camera should return to 0,0
                    vector.PanTilt.x = 0;
                    vector.PanTilt.y = 0;
                }
                CheckPreset(presets, presetToken, presetName, vector);

                RemovePreset(profile.token, presetToken);
                presetToken = null;
            },
                    () =>
            {
                if ((presetToken != null) && (profile != null))
                {
                    RemovePreset(profile.token, presetToken);
                }
            });
        }
Exemplo n.º 26
0
        public void GenericZoomSpeed()
        {
            RunTest(() =>
            {
                PTZNode[] nodes = GetNodes();
                foreach (PTZNode node in nodes)
                {
                    string reason = null;
                    Assert(ValidatePTZNode(node, out reason), reason, Resources.StepValidatePTZNode_Title);

                    Space1DDescription[] spaces = node.SupportedPTZSpaces.ZoomSpeedSpace;
                    Space1DDescription generic  = spaces != null ?
                                                  spaces.FirstOrDefault(space => string.Compare(space.URI, _speedZoomSpace) == 0) :
                                                  null;

                    Assert((generic != null) && (generic.XRange != null),
                           "Node does not support generic zoom speed space or space ranges are missing",
                           "Validating generic zoom speed space");

                    PTZConfigurationOptions options;
                    Media.Profile profile = GetPTZProfile(node, out options);
                    Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile);

                    Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.token, out reason), reason, Resources.StepValidatePTZConfigOptions_Title);

                    //check max ranges
                    bool absoulteMoveSupported = Features.Contains(Feature.PTZAbsoluteZoom);
                    PTZVector vector           = new PTZVector();
                    vector.Zoom = new Vector1D();
                    //absolute or relative move should be supported - use generic space for position or translation
                    Space1DDescription zoomSpace = absoulteMoveSupported ? options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0) :
                                                   options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0);

                    vector.Zoom.space = zoomSpace.URI;
                    vector.Zoom.x     = zoomSpace.XRange.Min;

                    PTZSpeed speed   = new PTZSpeed();
                    speed.Zoom       = new Vector1D();
                    speed.Zoom.space = generic.URI;
                    speed.Zoom.x     = generic.XRange.Max;

                    if (absoulteMoveSupported)
                    {
                        AbsoluteMove(profile.token, vector, speed);
                    }
                    else
                    {
                        RelativeMove(profile.token, vector, speed);
                    }

                    //check min ranges
                    speed.Zoom.x = generic.XRange.Min;
                    if (absoulteMoveSupported)
                    {
                        AbsoluteMove(profile.token, vector, speed);
                    }
                    else
                    {
                        RelativeMove(profile.token, vector, speed);
                    }
                }
            });
        }