/// <summary> /// Initializes a new instance of the <see cref="RTSPServer"/> class. /// </summary> /// <param name="aPortNumber">A numero port.</param> /// <param name="username">username.</param> /// <param name="password">password.</param> public RtspServer(int portNumber, string username, string password, string nvrHost, int nvrPort, int nvrChannel, string nvrUsername, string nvrPassword) { 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(username) == false && string.IsNullOrEmpty(password) == false) { string realm = "RtspForZR04RN"; auth = new Authentication(username, password, realm, Authentication.Type.Digest); } else { auth = null; } this.nvrHost = nvrHost; this.nvrPort = nvrPort; this.nvrChannel = nvrChannel; this.nvrUsername = nvrUsername; this.nvrPassword = nvrPassword; RtspUtils.RegisterUri(); rtspServerListener = new TcpListener(IPAddress.Any, portNumber); nvr = new DeviceConnection(); nvr.StreamFrameReceived += Nvr_StreamFrameReceived; nvr.Disconnected += Nvr_Disconnected; }
/// <summary> /// Initializes a new instance of the <see cref="RTSPServer"/> class. /// </summary> /// <param name="aPortNumber">A numero port.</param> public RtspServer(int portNumber) { 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(); RtspUtils.RegisterUri(); _RTSPServerListener = new TcpListener(IPAddress.Any, portNumber); }
public void RegisterUri() { RtspUtils.RegisterUri(); // Check that rtsp is well registred Assert.IsTrue(Uri.CheckSchemeName("rtsp")); // Check that the default port is well defined. Uri testUri = new Uri("rtsp://exemple.com/test"); Assert.AreEqual(554, testUri.Port); }
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; } }
public RTSPClient(string ipAddress, uint port, string username, string password) { _url = $"rtsp://{username}:{password}@{ipAddress}:{port}/Streaming/channels/1/"; RtspUtils.RegisterUri(); RtspTcpTransport socket = new RtspTcpTransport(ipAddress, (int)port); _client = new RtspListener(socket); _client.MessageReceived += MessageReceived; _client.DataReceived += DataReceived; }
/// <summary> /// Initializes a new instance of the <see cref="RTSPServer"/> class. /// </summary> /// <param name="aPortNumber">A numero port.</param> /// <param name="username">username.</param> /// <param name="password">password.</param> public RtspServer(int portNumber, String username, String password) { 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(username) == false && String.IsNullOrEmpty(password) == false) { String realm = "SharpRTSPServer"; auth = new Authentication(username, password, realm, Authentication.Type.Digest); } else { auth = null; } RtspUtils.RegisterUri(); _RTSPServerListener = new TcpListener(IPAddress.Any, portNumber); }