public RtspClient(Uri uri, Credentials creds = null)
        {
            _uri            = uri ?? throw new ArgumentNullException("Cannot create RTSP client from null uri");
            _cseq           = 0;
            _credentials    = creds;
            _defaultTimeout = TimeSpan.FromSeconds(20);
            _callbacks      = new ConcurrentDictionary <int, AsyncResponse>();
            _sources        = new ConcurrentDictionary <int, RtpInterleaveMediaSource>();
            _connection     = new RtspConnection(IPAddress.Parse(uri.Host), uri.Port == -1 ? DEFAULT_RTSP_PORT : uri.Port);
            _listener       = new RtspListener(_connection, OnRtspChunk);
            _rtpQueue       = new BlockingCollection <ByteBuffer>();

            LOG.Info($"Created RTSP client for '{_connection.Endpoint}'");

            Task.Run(() => ProcessInterleavedData());

            _listener.Start();
        }
Exemple #2
0
        private void Accept(object state)
        {
            while (!_stop.WaitOne(0))
            {
                try
                {
                    var client   = _listener.AcceptTcpClient();
                    var conn     = new RtspConnection(client);
                    var listener = new RtspListener(conn, OnRtspRequest);

                    LOG.Debug($"Accepted client connection from '{conn.RemoteAddress}'");

                    listener.Start();

                    _listeners.Add(conn.RemoteAddress, listener);
                }
                catch (Exception e)
                {
                    LOG.Error(e, $"Caught exception while accepting client connection, message={e.Message}");
                }
            }
        }