Beispiel #1
0
        /// <summary>
        /// Constructor. Performs initialization.
        /// </summary>
        /// <param name="param"></param>
        protected BaseTest(TestLaunchParam param)
        {
            _cameraAddress        = param.ServiceAddress;
            _cameraIp             = param.CameraIp;
            _cameraId             = param.CameraUUID;
            _nic                  = param.NIC;
            _username             = param.UserName;
            _password             = param.Password;
            _useUTCTimestamp      = param.UseUTCTimestamp;
            _operator             = param.Operator;
            _videoForm            = param.VideoForm;
            _environmentSettings  = param.EnvironmentSettings;
            _ptzNodeToken         = param.PTZNodeToken;
            _useEmbeddedPassword  = param.UseEmbeddedPassword;
            _password1            = param.Password1;
            _password2            = param.Password2;
            _operationDelay       = param.OperationDelay;
            _recoveryDelay        = param.RecoveryDelay;
            _relayOutputDelayTime = param.RelayOutputDelayTime;

            _rebootTimeout = param.RebootTimeout;

            _semaphore = new TestSemaphore();

            _trafficListener                   = new TrafficListener();
            _trafficListener.RequestSent      += LogRequest;
            _trafficListener.ResponseReceived += LogResponse;

            _endpointController = new EndpointController(new EndpointAddress(_cameraAddress));

            _credentialsProvider          = new CredentialsProvider();
            _credentialsProvider.Username = param.UserName;
            _credentialsProvider.Password = param.Password;
        }
        protected BaseOnvifTest(TestLaunchParam param)
            : base(param)
        {
            _features = param.Features;

            _cameraAddress       = param.ServiceAddress;
            _cameraIp            = param.CameraIp;
            _cameraId            = param.CameraUUID;
            _nic                 = param.NIC;
            _username            = param.UserName;
            _password            = param.Password;
            _useUTCTimestamp     = param.UseUTCTimestamp;
            _operator            = param.Operator;
            _videoForm           = param.VideoForm;
            _environmentSettings = param.EnvironmentSettings;

            _messageTimeout = param.MessageTimeout;

            _operationDelay = param.OperationDelay;
            _recoveryDelay  = param.RecoveryDelay;

            _rebootTimeout = param.RebootTimeout;

            _trafficListener                   = new TrafficListener();
            _trafficListener.RequestSent      += LogRequest;
            _trafficListener.ResponseReceived += LogResponse;

            _endpointController = new EndpointController(new EndpointAddress(_cameraAddress));

            _credentialsProvider          = new CredentialsProvider();
            _credentialsProvider.Username = param.UserName;
            _credentialsProvider.Password = param.Password;
            _credentialsProvider.Security = param.Security;
        }
        protected BaseOnvifTest(TestLaunchParam param) : base(param)
        {
            _features.Mode = param.FeatureDefinitionMode;
            if (param.FeatureDefinitionMode == FeatureDefinitionMode.Default)
            {
                _features.AddRange(param.Features);
            }

            _cameraAddress   = param.ServiceAddress;
            _cameraIp        = param.CameraIp;
            _cameraId        = param.CameraUUID;
            _nic             = param.NIC;
            _username        = param.UserName;
            _password        = param.Password;
            _useUTCTimestamp = param.UseUTCTimestamp;
            Operator         = param.Operator;

            if (param.VideoForm != null)
            {
                _videoForm = param.VideoForm;
                // reinitialize video window
                _videoForm.Reset();
                _videoForm.NICIndex  = param.NIC.Index;
                _videoForm.StopEvent = _semaphore.StopEvent;
            }

            _declaredScopes.AddRange(param.DeclaredScopes);

            _environmentSettings = param.EnvironmentSettings;

            _messageTimeout = param.MessageTimeout;

            _operationDelay = param.OperationDelay;
            _recoveryDelay  = param.RecoveryDelay;

            _rebootTimeout = param.RebootTimeout;

            // should be done in BaseTest.Initialize();
            //_trafficListener = new TrafficListener();
            //_trafficListener.RequestSent += LogRequest;
            //_trafficListener.ResponseReceived += LogResponse;

            _endpointController = new EndpointController(new EndpointAddress(_cameraAddress));

            _credentialsProvider          = new CredentialsProvider();
            _credentialsProvider.Username = param.UserName;
            _credentialsProvider.Password = param.Password;
            _credentialsProvider.Security = param.Security;
        }
Beispiel #4
0
        public static void AdjustVideo(
            IVideoForm form,
            string username,
            string password,
            int messageTimeout,
            TransportProtocol protocol,
            StreamType streamType,
            MediaUri streamUri,
            VideoEncoderConfiguration conf)
        {
            if (!string.IsNullOrEmpty(username))
            {
                form.User = username;
            }
            else
            {
                form.User = null;
            }
            if (!string.IsNullOrEmpty(password))
            {
                form.Password = password;
            }
            else
            {
                form.Password = null;
            }

            string uri = (streamUri != null) ? streamUri.Uri : null;

            //uri = "http://[195.145.107.77]:90/rtsp_tunnel?h26x=0&line=1&enableaudio=1";
            switch (protocol)
            {
            case TransportProtocol.UDP:
                form.HTTPPort = 0;
                form.TCP      = false;
                break;

            case TransportProtocol.TCP:
                form.HTTPPort = 0;
                form.TCP      = true;
                break;

            case TransportProtocol.RTSP:
                form.HTTPPort = 0;
                form.TCP      = true;
                break;

            case TransportProtocol.HTTP:
            {
                form.HTTPPort = 80;
                try
                {
                    int pos = uri.IndexOf(']', 8);
                    if (pos > 0)         // IPv6
                    {
                        pos++;
                    }
                    else
                    {
                        pos = uri.IndexOf(':', 8);
                    }
                    if (uri.Substring(pos, 1) == ":")         // port specified
                    {
                        pos++;
                        int pos2 = uri.IndexOf('/', pos);
                        pos = int.Parse(uri.Substring(pos, pos2 - pos));
                        if (pos > 0)
                        {
                            form.HTTPPort = pos;
                        }
                    }
                }
                catch (System.Exception)
                {
                }
                form.TCP = true;
            }
            break;
            }
            ;

            form.Multicast = streamType == StreamType.RTPMulticast;
            form.Address   = uri;
            form.RTSP      = !string.IsNullOrEmpty(uri);
            form.Timeout   = messageTimeout;
            if ((conf != null) && (conf.Resolution != null))
            {
                form.VideoWidth  = conf.Resolution.Width;
                form.VideoHeight = conf.Resolution.Height;
            }
        }
Beispiel #5
0
        protected BaseOnvifTest(TestLaunchParam param) : base(param)
        {
            _features.Mode = param.FeatureDefinitionMode;
            if (param.FeatureDefinitionMode == FeatureDefinitionMode.Default)
            {
                _features.AddRange(param.Features);
            }

            //_cameraAddress = param.ServiceAddress;
            FirmwareFilePath = param.FirmwareFilePath;

            CredentialIdentifierValueFirst  = param.CredentialIdentifierValueFirst;
            CredentialIdentifierValueSecond = param.CredentialIdentifierValueSecond;
            CredentialIdentifierValueThird  = param.CredentialIdentifierValueThird;

            _cameraIp = param.CameraIp;
            _cameraId = param.CameraUUID;
            _nic      = param.NIC;
            TestTool.HttpTransport.RequestNetworkStream.EndpointFrom = new IPEndPoint(_nic.IP, 0);
            _username        = param.UserName;
            _password        = param.Password;
            _useUTCTimestamp = param.UseUTCTimestamp;
            Operator         = param.Operator;

            if (param.VideoForm != null)
            {
                _videoForm = param.VideoForm;
                // reinitialize video window
                _videoForm.Reset();
                _videoForm.NICIndex  = param.NIC.Index;
                _videoForm.StopEvent = _semaphore.StopEvent;
            }

            _declaredScopes.AddRange(param.DeclaredScopes);

            _environmentSettings = param.EnvironmentSettings;

            _messageTimeout = param.MessageTimeout;

            _operationDelay = param.OperationDelay;
            _recoveryDelay  = param.RecoveryDelay;

            _rebootTimeout = param.RebootTimeout;

            // should be done in BaseTest.Initialize();
            //_trafficListener = new TrafficListener();
            //_trafficListener.RequestSent += LogRequest;
            //_trafficListener.ResponseReceived += LogResponse;

            _endpointController = new EndpointController(new EndpointAddress(param.ServiceAddress));

            _credentialsProvider = new CredentialsProvider
            {
                Username = param.UserName,
                Password = param.Password,
                Security = param.Security
            };

            NetworkSettingsChangedEvent += address =>
            {
                var uri = new EndpointAddress(address);

                var       addresses = Dns.GetHostAddresses(uri.Uri.Host);
                IPAddress newAddr   = null;
                switch (uri.Uri.HostNameType)
                {
                case UriHostNameType.IPv4:
                    newAddr = addresses.FirstOrDefault(u => u.AddressFamily == AddressFamily.InterNetwork);
                    break;

                case UriHostNameType.IPv6:
                    newAddr = addresses.FirstOrDefault(u => u.AddressFamily == AddressFamily.InterNetworkV6);
                    break;

                case UriHostNameType.Dns:
                    newAddr = addresses.FirstOrDefault(u => u.AddressFamily == AddressFamily.InterNetwork);
                    if (null == _cameraIp)
                    {
                        newAddr = addresses.FirstOrDefault(u => u.AddressFamily == AddressFamily.InterNetworkV6);
                    }
                    break;
                }

                if (null != newAddr)
                {
                    _endpointController.UpdateAddress(uri);
                    _cameraIp = newAddr;
                }
            };
        }