public void TeardownAsync(RtspResponseCallback callback) { _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.TEARDOWN) .Uri(_baseUri) .Build(), callback); }
public void PlayAsync(RtspResponseCallback callback) { _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.PLAY) .Uri(_baseUri) .Build(), callback); }
public void SetUpAsync(RtspResponseCallback callback) { _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.SETUP) .Uri(_baseUri) .Build(), callback); }
public void GetParameterAsync(RtspResponseCallback callback) { _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.GET_PARAMETER) .Uri(_baseUri) .Build(), callback); }
public void OptionsAsync(RtspResponseCallback callback) { _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.OPTIONS) .Uri(_baseUri) .Build(), callback); }
public void DescribeAsync(RtspResponseCallback callback) { _client.SendAsync(_builder.Method(RtspRequest.RtspMethod.DESCRIBE) .Uri(_baseUri) .Build(), callback); }
public AsyncResponse(int cseq) { _cseq = cseq; _response = null; _callback = null; _event = new ManualResetEvent(false); }
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); }
/// <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; } }
public AsyncResponse(int cseq, RtspResponseCallback callback) : this(cseq) { _callback = callback; }