Esempio n. 1
0
        public RtspServer(IAppConfigurationFacade appConfigurationFacade,
                          IRequestUrlVideoSourceResolverStrategy requestUrlVideoSourceResolverStrategy)
        {
            _portNumber = appConfigurationFacade.RtspServerPort;
            _requestUrlVideoSourceResolverStrategy = requestUrlVideoSourceResolverStrategy;
            if (_portNumber < System.Net.IPEndPoint.MinPort || _portNumber > System.Net.IPEndPoint.MaxPort)
            {
                throw new ArgumentOutOfRangeException("aPortNumber", _portNumber, "Port number must be between System.Net.IPEndPoint.MinPort and System.Net.IPEndPoint.MaxPort");
            }
            Contract.EndContractBlock();

            if (String.IsNullOrEmpty(appConfigurationFacade.RtspServerLogin) == false &&
                String.IsNullOrEmpty(appConfigurationFacade.RtspServerPassword) == false)
            {
                String realm = "SharpRTSPServer";
                var    authenticationParameters = new AuthenticationParameters()
                {
                    username           = appConfigurationFacade.RtspServerLogin,
                    password           = appConfigurationFacade.RtspServerPassword,
                    realm              = realm,
                    authenticationType = AuthenticationType.Digest,
                };
                _authentication = new Authentication(authenticationParameters, _logger);
            }
            else
            {
                _authentication = null;
            }

            RtspUtils.RegisterUri();

            Exception getIPException;

            _ipAddress = IPUtils.GetIPAddressFromString(appConfigurationFacade.RtspServerAddress, out getIPException);


            if (getIPException != null)
            {
                _logger.Error("Setting RtspServerAddress failed: " + getIPException);
            }

            _RTSPServerListener = new TcpListener(_ipAddress, _portNumber);

            try
            {
                StartListen();
            }
            catch (Exception ex)
            {
                _logger.Error($"Error: Could not start rtsp server on {_ipAddress}:{_portNumber} : " + ex.ToString());
                throw;
            }
        }
Esempio n. 2
0
 public RtspClientFactory(IAppConfigurationFacade appConfigurationFacade)
 {
     _appConfigurationFacade = appConfigurationFacade;
 }