Example #1
0
 public void TeardownAsync(RtspResponseCallback callback)
 {
     _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.TEARDOWN)
                       .Uri(_baseUri)
                       .Build(),
                       callback);
 }
Example #2
0
 public void PlayAsync(RtspResponseCallback callback)
 {
     _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.PLAY)
                       .Uri(_baseUri)
                       .Build(),
                       callback);
 }
Example #3
0
 public void SetUpAsync(RtspResponseCallback callback)
 {
     _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.SETUP)
                       .Uri(_baseUri)
                       .Build(),
                       callback);
 }
Example #4
0
 public void GetParameterAsync(RtspResponseCallback callback)
 {
     _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.GET_PARAMETER)
                       .Uri(_baseUri)
                       .Build(),
                       callback);
 }
Example #5
0
 public void OptionsAsync(RtspResponseCallback callback)
 {
     _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.OPTIONS)
                       .Uri(_baseUri)
                       .Build(),
                       callback);
 }
Example #6
0
 public void DescribeAsync(RtspResponseCallback callback)
 {
     _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.DESCRIBE)
                       .Uri(_baseUri)
                       .Build(),
                       callback);
 }
Example #7
0
 public AsyncResponse(int cseq)
 {
     _cseq     = cseq;
     _response = null;
     _callback = null;
     _event    = new ManualResetEvent(false);
 }
Example #8
0
        private AsyncResponse DoSend(RtspRequest request, RtspResponseCallback resCallback = null)
        {
            int cseq = GetNextCSeq();

            request.CSeq = _cseq;

            AsyncResponse callback = new AsyncResponse(cseq, resCallback);

            if (!_connection.WriteMessage(request))
            {
                callback.Dispose();
                throw new RtspClientException("Unable to send request to client");
            }

            _callbacks[cseq] = callback;

            return(callback);
        }
Example #9
0
        /// <summary>
        /// Asynchronously sends RTSP request.  Invokes callback if a response is received
        /// from the server.
        /// </summary>
        /// <param name="request">The request to send</param>
        /// <param name="callback">Callback to be called when a response is available</param>
        public void SendAsync(RtspRequest request, RtspResponseCallback callback)
        {
            AsyncResponse asyncRes = null;

            try
            {
                if (_authResponse != null && _credentials != null)
                {
                    // Set the authorization header if we have a cached auth response.
                    request.Authorization = _authResponse.Generate(request.Method, request.URI);
                }

                asyncRes = DoSend(request, (res) =>
                {
                    var status = res.ResponseStatus;
                    if (status.Is(RtspResponse.Status.Unauthorized) && _credentials != null)
                    {
                        _authResponse = AuthChallenge.Parse(_credentials, res.WWWAuthenticate);

                        if (_authResponse != null)
                        {
                            LOG.Warn($"Received RTSP Unauthorized response re-trying with creds {_credentials.Username}:{_credentials.Password}");

                            request.Authorization = _authResponse.Generate(request.Method, request.URI);
                            asyncRes = DoSend(request, callback);
                        }
                    }
                    else
                    {
                        callback.Invoke(res);
                    }
                });
            }
            catch (Exception e)
            {
                if (asyncRes != null)
                {
                    RemoveCallback(asyncRes.CSeq);
                }
                throw e;
            }
        }
Example #10
0
 public AsyncResponse(int cseq, RtspResponseCallback callback) : this(cseq)
 {
     _callback = callback;
 }