public RtspHandler(Uri uri) { _rtspClient = new RtspClient(uri, RtspClient.ClientProtocolType.Udp) { AutomaticallyReconnect = true, /*ConfigureSocket = (s) => { * s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); * }*/ }; _videoStreamInfo = new StreamInfo(OnVideoPacket); _audioStreamInfo = new StreamInfo(OnAudioPacket); _playStarted = new BehaviorSubject <bool>(false); _lastVideoSample = null; #if DEBUG _rtspClient.Logger = new DebuggingLogger(); _rtspClient.OnConnect += (s, o) => Trace.WriteLine("RtspClient::OnConnect()"); _rtspClient.OnDisconnect += (s, o) => Trace.WriteLine("RtspClient::OnDisconnect()"); _rtspClient.OnPause += (s, o) => Trace.WriteLine("RtspClient::OnPause()"); _rtspClient.OnPlay += (s, o) => Trace.WriteLine("RtspClient::OnPlay()"); _rtspClient.OnRequest += (s, req) => Trace.WriteLine("RtspClient::OnRequest(): " + req.HeaderEncoding.GetString(req.PrepareStatusLine(false).ToArray())); _rtspClient.OnResponse += (s, req, res) => Trace.WriteLine($"RtspClient::OnResponse(): {req.MethodString} => {res?.StatusCode} {res?.HttpStatusCode}\n{res?.Body}"); _rtspClient.OnStop += (s, a) => Trace.WriteLine("RtspClient::OnStop()"); #endif }
private void PlayButton_Click(object sender, EventArgs e) { if (ClientThreadProc != null) { if (m_rtspClient != null) { m_rtspClient.StopPlaying(); m_rtspClient = null; } Media.Common.Extensions.Thread.ThreadExtensions.TryAbortAndFree(ref ClientThreadProc); ClientThreadProc = null; GC.WaitForPendingFinalizers(); PlayButton.Text = "Start"; } else { m_rtspClient = new RtspClient(URLTextBox.Text, RtspClient.ClientProtocolType.Tcp); //Client.DisableKeepAliveRequest = checkBox1.Checked; m_rtspClient.OnConnect += RTSPClient_OnConnect; ClientThreadProc = new Thread(() => m_rtspClient.Connect()); ClientThreadProc.Start(); PlayButton.Text = "Stop"; } }
public override void Dispose() { if (IsDisposed) { return; } base.Dispose(); if (Common.IDisposedExtensions.IsNullOrDisposed(RtspClient).Equals(false)) { RtspClient.OnConnect -= RtspClient_OnConnect; RtspClient.OnDisconnect -= RtspClient_OnDisconnect; RtspClient.OnPlay -= RtspClient_OnPlay; RtspClient.OnPause -= RtspClient_OnPausing; RtspClient.OnStop -= RtspClient_OnStop; RtspClient.Dispose(); RtspClient = null; } }
/// <summary> /// Stops streaming from the source /// </summary> public override void Stop() { if (IsDisposed || State < StreamState.Started) { return; } if (Common.IDisposedExtensions.IsNullOrDisposed(RtspClient).Equals(false)) { if (RtspClient.IsPlaying) { RtspClient.StopPlaying(); } else if (RtspClient.IsConnected) { RtspClient.Disconnect(); } //Client Dispose } base.Stop(); m_StartedTimeUtc = null; }
void RtspClient_OnConnect(RtspClient sender, object args) { if (RtspClient.IsConnected.Equals(false) || State == StreamState.StartRequested) { return; } //Not quite ready yet. State = StreamState.StartRequested; try { //Start playing RtspClient.StartPlaying(MediaStartTime, MediaEndTime, SpecificMediaTypes); } catch (Exception ex) { //StoPlaying and Disconnect when an exception occurs. RtspClient.Disconnect(true); Common.ILoggingExtensions.LogException(RtspClient.Logger, ex); State = StreamState.Started; } }
void RtspClient_OnConnect(RtspClient sender, object args) { if (RtspClient != sender || false == RtspClient.IsConnected || RtspClient.IsPlaying) { return; } RtspClient.OnConnect -= RtspClient_OnConnect; try { //Start listening is not already playing if (false == RtspClient.IsPlaying) { RtspClient.StartPlaying(MediaStartTime, MediaEndTime, SpecificMediaType); } //Set the time for stats m_StartedTimeUtc = DateTime.UtcNow; //Call base to set started etc. base.Start(); } catch { //Indicate not ready Ready = false; } }
/// <summary> /// Stops streaming from the source /// </summary> public override void Stop() { if (RtspClient != null) { if (RtspClient.IsPlaying) { RtspClient.StopPlaying(); } else if (RtspClient.IsConnected) { RtspClient.Disconnect(); } RtspClient.OnConnect -= RtspClient_OnConnect; RtspClient.OnDisconnect -= RtspClient_OnDisconnect; RtspClient.OnPlay -= RtspClient_OnPlay; RtspClient.OnStop -= RtspClient_OnStop; } base.Stop(); m_StartedTimeUtc = null; }
/// <summary> /// Beings streaming from the source /// </summary> public override void Start() { if (IsDisposed) { return; } if (false == RtspClient.IsConnected) { RtspClient.OnConnect += RtspClient_OnConnect; RtspClient.OnDisconnect += RtspClient_OnDisconnect; RtspClient.OnPlay += RtspClient_OnPlay; RtspClient.OnPause += RtspClient_OnPausing; RtspClient.OnStop += RtspClient_OnStop; try { RtspClient.Connect(); } catch { RtspClient.StopPlaying(); } //Stop stop } else if (false == RtspClient.IsPlaying) { try { //Start the playing again RtspClient.StartPlaying(MediaStartTime, MediaEndTime, SpecificMediaType); //Indicate when the stream was started. m_StartedTimeUtc = DateTime.UtcNow; //Call base to set started etc. base.Start(); } catch { RtspClient.StopPlaying(); } //Not stop } }
void RtspClient_OnPlay(RtspClient sender, object args) { if ((base.Ready = RtspClient.IsPlaying)) // && RtspClient.PlayingMedia.Count is equal to what is supposed to be playing { RtspClient.Client.FrameChangedEventsEnabled = PerPacket == false; } }
public RaopClient(IPEndPoint endpoint, string userAgent) : base(true) { string n = "59dE8qLieItsH1WgjrcFRKj6eUWqi+bGLOX1HL3U3GhC/j0Qg90u3sG/1CUtwC" + "5vOYvfDmFI6oSFXi5ELabWJmT2dKHzBJKa3k9ok+8t9ucRqMd6DZHJ2YCCLlDR" + "KSKv6kDqnw4UwPdpOMXziC/AMj3Z/lUVX1G7WSHCAWKf1zNS1eLvqr+boEjXuB" + "OitnZ/bDzPHrTOZz0Dew0uowxf/+sG+NCK3eQJVxqcaJ/vEHKIVd2M+5qL71yJ" + "Q+87X6oV3eaYvt3zWZYD6z5vYTcrtij2VZ9Zmni/UAaHqn9JdsBWLUEpVviYnh" + "imNVvYFZeCXg/IdTQ+x4IRdiXNv5hEew=="; string e = "AQAB"; rtsp = new RtspClient("zeroClient"); RSAParameters key = new RSAParameters(); key.Modulus = Convert.FromBase64String(n); key.Exponent = Convert.FromBase64String(e); rsa = new RSACryptoServiceProvider(); rsa.ImportParameters(key); dataCrypto = Rijndael.Create(); dataCrypto.Mode = CipherMode.CBC; dataCrypto.Padding = PaddingMode.None; dataCrypto.KeySize = 128; dataCrypto.GenerateKey(); dataCrypto.GenerateIV(); StartTcp(endpoint); }
void sender_OnDisconnect(RtspClient sender, object args) { if (sender == null || sender.IsDisposed) { return; } sender.Client.RtpPacketReceieved -= ShowRtpPacket; sender.Client.RtcpPacketReceieved -= ShowRtcpPacket; sender.OnPlay -= sender_OnPlay; sender.OnResponse -= sender_OnResponse; sender.OnRequest -= sender_OnRequest; sender.OnDisconnect -= sender_OnDisconnect; sender.Client.RtpPacketReceieved -= ShowRtpPacket; sender.Client.RtcpPacketReceieved -= ShowRtcpPacket; sender.Client.RtcpPacketSent -= ShowRtcpPacket; sender.OnStop -= sender_OnStop; sender.Dispose(); button1_Click(this, EventArgs.Empty); }
private void RTSPClient_OnDisconnect(RtspClient sender, object args) { if (sender == null || sender.IsDisposed) { return; } // sender.Client.RtpPacketReceieved -= RTSPClient_RtpPacketReceieved; // sender.Client.RtcpPacketReceieved -= RTSPClient_RtcpPacketReceieved; sender.OnPlay -= RTSPClient_OnPlay; sender.OnResponse -= RTSPClient_OnResponse; sender.OnRequest -= RTSPClient_OnRequest; sender.OnDisconnect -= RTSPClient_OnDisconnect; sender.Client.RtpPacketReceieved -= RTSPClient_RtpPacketReceieved; sender.Client.RtcpPacketReceieved -= RTSPClient_RtcpPacketReceieved; sender.Client.RtcpPacketSent -= RTSPClient_RtcpPacketSent; sender.OnStop -= RTSPClient_OnStop; sender.Dispose(); PlayButton_Click(this, EventArgs.Empty); }
/************************************************************************/ #region Private methods private async void StartVideoRtsp() { int tryCount = 0; string requestUri = string.Empty; while (tryCount < Parms.ConnectionAttempts) { try { tokenSource = new CancellationTokenSource(); token = tokenSource.Token; requestUri = $"{GetDeviceRoot(TransportProtocol.Rtsp)}/{VideoStreams[VideoStreamIndex].Path}"; /* if retrying, wait before another attempt */ if (tryCount > 0) { await Task.Delay(Parms.RetryWaitTime, token); } var serverUri = new Uri(requestUri); var credentials = new NetworkCredential(Parms.UserId, Parms.Password); var connectionParms = new RtspClientSharp.ConnectionParameters(serverUri, credentials) { RtpTransport = RtpTransportProtocol.TCP, ConnectTimeout = TimeSpan.FromMilliseconds(Parms.Timeout), }; using (var rtspClient = new RtspClient(connectionParms)) { rtspClient.FrameReceived += RtspFrameRecieved; await rtspClient.ConnectAsync(token).ConfigureAwait(false); /* Once connected, reset the try count. If there's a network problem * while receiving, we get another full set of retries */ tryCount = 0; await rtspClient.ReceiveAsync(token).ConfigureAwait(false); } } catch (OperationCanceledException) { /* when canceled, no more attempts */ tryCount = Parms.ConnectionAttempts; } catch (InvalidCredentialException ex) { /* bad credentials, no more attempts */ OnPluginException(new PluginException(requestUri, ex)); tryCount = Parms.ConnectionAttempts; } catch (Exception ex) { OnPluginException(new PluginException(requestUri, ex)); tryCount++; } } }
private void _client_OnPlay(RtspClient sender, object args) { byte[] data = getH264HeaderData(); if (data != null && data.Length > 0) { fireVideoDataEvent(data); } }
public async void rtspClientStart() { rtspClient = new RtspClientSharp.RtspClient(new RtspClientSharp.ConnectionParameters(new Uri("rtsp://192.168.0.10:8554/H264Video")) { RtpTransport = RtpTransportProtocol.TCP, ConnectTimeout = TimeSpan.FromSeconds(3), ReceiveTimeout = TimeSpan.FromSeconds(3) }); rtspClient.FrameReceived += RtspClient_FrameReceived; rtspCancel = new CancellationTokenSource(); int delay = 200; using (rtspClient) while (true) { if (rtspCancel.Token.IsCancellationRequested) { return; } try { await rtspClient.ConnectAsync(rtspCancel.Token); iframestart = true; } catch (OperationCanceledException) { return; } catch (RtspClientException e) { Console.WriteLine(e.ToString()); await Task.Delay(delay, rtspCancel.Token); continue; } Console.WriteLine("Connected."); try { await rtspClient.ReceiveAsync(rtspCancel.Token); } catch (OperationCanceledException) { return; } catch (RtspClientException e) { Console.WriteLine(e.ToString()); await Task.Delay(delay, rtspCancel.Token); } } }
private static async Task MakeSnapshotsAsync(Options options, CancellationToken token) { try { if (!Directory.Exists(options.Path)) { Directory.CreateDirectory(options.Path); } int intervalMs = options.Interval * 1000; int lastTimeSnapshotSaved = Environment.TickCount - intervalMs; var connectionParameters = new ConnectionParameters(options.Uri); using (var rtspClient = new RtspClient(connectionParameters)) { rtspClient.FrameReceived += (sender, frame) => { if (!(frame is RawJpegFrame)) { return; } int ticksNow = Environment.TickCount; if (Math.Abs(ticksNow - lastTimeSnapshotSaved) < intervalMs) { return; } lastTimeSnapshotSaved = ticksNow; string snapshotName = frame.Timestamp.ToString("O").Replace(":", "_") + ".jpg"; string path = Path.Combine(options.Path, snapshotName); ArraySegment <byte> frameSegment = frame.FrameSegment; using (var stream = File.OpenWrite(path)) stream.Write(frameSegment.Array, frameSegment.Offset, frameSegment.Count); Console.WriteLine($"[{DateTime.UtcNow}] Snapshot is saved to {snapshotName}"); }; Console.WriteLine("Connecting..."); await rtspClient.ConnectAsync(token); Console.WriteLine("Receiving..."); await rtspClient.ReceiveAsync(token); } } catch (OperationCanceledException) { } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public async Task ReceiveAsync_InterleavedModeAndOneRtcpByePacketInStream_SuccessfullyFinished() { var transportClient = new RtspTransportClientEmulator(); var rtspClient = new RtspClient(ConnectionParameters, () => transportClient); await rtspClient.ConnectAsync(CancellationToken.None); await rtspClient.ReceiveAsync(CancellationToken.None); }
private void Client_OnPlay(RtspClient sender, object args) { Console.WriteLine("OnPlay"); byte[] data = getHeaderData(); if (data != null && data.Length > 0) { onHeader(new StandardHeaderPacket((int)Constants.AVCodecID.AV_CODEC_ID_H264, data)); } }
public async Task ConnectAsync_ConnectionTimeout_ThrowsException() { var transportClientMock = new Mock <IRtspTransportClient>(); transportClientMock.Setup(x => x.ConnectAsync(It.IsAny <CancellationToken>())).Returns(Task.Delay(10)); var rtspClient = new RtspClient(ConnectionParameters, () => transportClientMock.Object); await rtspClient.ConnectAsync(CancellationToken.None); }
public RtspSource(string url) { _client = new RtspClient(url, RtspClient.ClientProtocolType.Tcp); _client.OnConnect += _client_OnConnect; _client.OnPlay += _client_OnPlay; _client.Client.RtpFrameChanged += Client_RtpFrameChanged;; }
public RtspSource(string name, Uri source, bool perPacket, RtspClient client) : base(name, source, perPacket) { if (Common.IDisposedExtensions.IsNullOrDisposed(client)) { throw new ArgumentNullException("client"); } RtspClient = client; }
public override void Dispose() { _disposeEvent.Set(); _thread.Join(500); if (_client != null) { _client.StopPlaying(); } _client = null; }
private async Task ReceiveAsync(CancellationToken token) { try { _connectionParameters.ConnectTimeout = new System.TimeSpan(0, 0, 60); _connectionParameters.ReceiveTimeout = new System.TimeSpan(0, 0, 30); _connectionParameters.RtpTransport = RtpTransportProtocol.TCP; using (var rtspClient = new RtspClient(_connectionParameters)) { rtspClient.FrameReceived += RtspClientOnFrameReceived; while (true) { OnStatusChanged("Connecting..."); try { await rtspClient.ConnectAsync(token); } catch (InvalidCredentialException) { OnStatusChanged("Invalid login and/or password"); await Task.Delay(RetryDelay, token); continue; } catch (RtspClientException e) { OnStatusChanged(e.ToString()); await Task.Delay(RetryDelay, token); continue; } OnStatusChanged("Receiving frames..."); try { await rtspClient.ReceiveAsync(token); } catch (RtspClientException e) { OnStatusChanged(e.ToString()); await Task.Delay(RetryDelay, token); } } } } catch (OperationCanceledException) { } }
void RtspClient_OnPlay(RtspClient sender, object args) { State = StreamState.Started; if ((base.Ready = RtspClient.IsPlaying)) // && RtspClient.PlayingMedia.Count is equal to what is supposed to be playing { RtspClient.Client.FrameChangedEventsEnabled = PerPacket == false; m_StartedTimeUtc = RtspClient.StartedPlaying; } }
internal void sender_OnPlay(RtspClient sender, object args) { sender.OnDisconnect += sender_OnDisconnect; sender.Client.RtpPacketReceieved += ShowRtpPacket; sender.Client.RtcpPacketReceieved += ShowRtcpPacket; sender.Client.RtcpPacketSent += ShowRtcpPacket; sender.Client.AverageMaximumRtcpBandwidthPercentage = (double)numericUpDown2.Value; sender.OnStop += sender_OnStop; }
public async Task ConnectAsync_CancellationRequested_ThrowsOperationCanceledException() { var transportClientMock = new Mock <IRtspTransportClient>(); transportClientMock.Setup(x => x.ConnectAsync(It.IsAny <CancellationToken>())).Returns(Task.Delay(10)); var cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource.Cancel(); var rtspClient = new RtspClient(ConnectionParameters, () => transportClientMock.Object); await rtspClient.ConnectAsync(cancellationTokenSource.Token); }
public void Initialize(string path, IRequestHandler handler) { using (var mutex = new Mutex(false, GlobalMutexId)) { bool mutexAcquired = false; try { // Because the tests can run on multiple threads we must synchronize // to ensure that we don't start different test servers on the same port. if ((mutexAcquired = mutex.WaitOne(5000, false))) { if (!Initialized) { ServerPort = NetworkUnil.FindAvailableTcpPort(); var dispatcher = new DefaultRequestDispatcher(); dispatcher.RegisterHandler(path, handler); _path = path; _server = new RtspServer(ServerPort, dispatcher); _server.Start(); // Wait until the serer port is not available. while (NetworkUnil.IsTcpPortAvailable(ServerPort)) { Thread.Sleep(1000); } Client = new RtspClient(ServerUriEndpoint); Initialized = true; } } } catch (AbandonedMutexException) { // do nothing } catch (Exception) { // Do nothing since this is just a test, and if we fail here the tests // are going to fail also. } finally { if (mutexAcquired) { mutex.ReleaseMutex(); } } } }
private static async Task ConnectAsync(ConnectionParameters connectionParameters, CancellationToken token) { try { TimeSpan delay = TimeSpan.FromSeconds(5); using (var rtspClient = new RtspClient(connectionParameters)) { rtspClient.FrameReceived += (sender, frame) => Console.WriteLine($"New frame {frame.Timestamp}: {frame.GetType().Name}"); while (true) { Console.WriteLine("Connecting..."); try { await rtspClient.ConnectAsync(token); } catch (OperationCanceledException) { return; } catch (RtspClientException e) { Console.WriteLine(e.ToString()); await Task.Delay(delay, token); continue; } Console.WriteLine("Connected."); try { await rtspClient.ReceiveAsync(token); } catch (OperationCanceledException) { return; } catch (RtspClientException e) { Console.WriteLine(e.ToString()); await Task.Delay(delay, token); } } } } catch (OperationCanceledException) { } }
private Uri DetermineRealUri() { // The VideoXpert system does some non-standard RTSP redirecting so that it can determine the intent of // the client (intent being live or playback). It stats off by creating a spoofed SDP and then will // redirect on play. What we will do it write a wrapper that does some of the RTSP calls to first // determine what the actual live RTSP uri is. using (RtspClient client = new RtspClient(_uri)) { try { var method = RtspRequest.RtspMethod.OPTIONS; CheckResponse(client.Send(RtspRequest.CreateBuilder() .Method(method) .Uri(_uri) .Build()), method); method = RtspRequest.RtspMethod.DESCRIBE; var res = CheckResponse(client.Send(RtspRequest.CreateBuilder() .Method(method) .Uri(_uri) .Build()), method); var sdp = res.GetBodyAsSdp(); if (!sdp.SessionName.Contains("Spoofed session")) { // We are not working with a spoofed session just return // the current uri. return(_uri); } Uri controlUri = null; var tracks = MediaTracks.FromSdp(sdp, _uri); foreach (var track in tracks) { if (track.Type.Is(MimeType.ANY_VIDEO)) { if (GetRedirectUri(client, track, out controlUri)) { return(controlUri); } } } throw new RtspClientException($"Unable to retrieve usable uri from server at endpoint '{_uri}'"); } catch (Exception e) { LOG.Error(e, $"Failed while communicating with RTSP server at '{_uri}'"); throw e; } } }
public async Task ReceiveAsync_CancellationRequested_ImmediateReturn() { var transportClient = new RtspTransportClientEmulator(); var rtspClient = new RtspClient(ConnectionParameters, () => transportClient); var cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource.Cancel(); await rtspClient.ConnectAsync(CancellationToken.None); await rtspClient.ReceiveAsync(cancellationTokenSource.Token); }
void sender_OnResponse(RtspClient sender, RtspMessage request, RtspMessage response) { if (request != null && response != null) { //Disable keep alives if indicated Client.DisableKeepAliveRequest = checkBox1.Checked; if (this.InvokeRequired) { Invoke(new FillTextRtsp(UpdateRtsp), request); Invoke(new FillTextRtsp(UpdateRtsp), response); } else { textBox2.AppendText(string.Format(TestingFormat, request.ToString(), response.ToString())); } } }
void sender_OnStop(RtspClient sender, object args) { }
public RtspSource(string name, string location, RtspClient.ClientProtocolType rtpProtocolType, int bufferSize = RtspClient.DefaultBufferSize, Sdp.MediaType? specificMedia = null, TimeSpan? startTime = null, TimeSpan? endTime = null) : this(name, location, null, AuthenticationSchemes.None, rtpProtocolType, bufferSize, specificMedia, startTime, endTime) { }
/// <summary> /// Constructs a RtspStream for use in a RtspServer /// </summary> /// <param name="name">The name given to the stream on the RtspServer</param> /// <param name="sourceLocation">The rtsp uri to the media</param> /// <param name="credential">The network credential the stream requires</param> /// /// <param name="authType">The AuthenticationSchemes the stream requires</param> public RtspSource(string name, Uri sourceLocation, NetworkCredential credential = null, AuthenticationSchemes authType = AuthenticationSchemes.None, Rtsp.RtspClient.ClientProtocolType? rtpProtocolType = null, int bufferSize = RtspClient.DefaultBufferSize, Sdp.MediaType? specificMedia = null, TimeSpan? startTime = null, TimeSpan? endTime = null, bool perPacket = false) : base(name, sourceLocation, perPacket) { //Create the listener if we are the top level stream (Parent) if (IsParent) { RtspClient = new RtspClient(m_Source, rtpProtocolType, bufferSize); } //else it is already assigned via the child if (credential != null) { RtspClient.Credential = SourceCredential = credential; if (authType != AuthenticationSchemes.None) RtspClient.AuthenticationScheme = SourceAuthenticationScheme = authType; } //If only certain media should be setup if (specificMedia.HasValue) SpecificMediaType = specificMedia; //If there was a start time given if (startTime.HasValue) MediaStartTime = startTime; if (endTime.HasValue) MediaEndTime = endTime; }
void sender_OnPlay(RtspClient sender, object args) { sender.OnDisconnect += sender_OnDisconnect; sender.Client.RtpPacketReceieved += ShowRtpPacket; sender.Client.RtcpPacketReceieved += ShowRtcpPacket; sender.Client.RtcpPacketSent += ShowRtcpPacket; sender.Client.AverageMaximumRtcpBandwidthPercentage = (double)numericUpDown2.Value; sender.OnStop += sender_OnStop; }
void RtspClient_OnConnect(RtspClient sender, object args) { if (RtspClient != sender || false == RtspClient.IsConnected || RtspClient.IsPlaying) return; RtspClient.OnConnect -= RtspClient_OnConnect; try { //Start listening is not already playing if(false == RtspClient.IsPlaying) RtspClient.StartPlaying(MediaStartTime, MediaEndTime, SpecificMediaType); //Set the time for stats m_StartedTimeUtc = DateTime.UtcNow; //Call base to set started etc. base.Start(); } catch { //Indicate not ready Ready = false; } }
void RtspClient_OnDisconnect(RtspClient sender, object args) { base.Ready = false; }
void RtspClient_OnStop(RtspClient sender, object args) { base.Ready = RtspClient.IsPlaying; }
void client_OnConnect(RtspClient sender, object args) { sender.OnPlay += sender_OnPlay; sender.OnRequest += sender_OnRequest; sender.OnResponse += sender_OnResponse; try { if (numericUpDown1.Value == 0) sender.StartPlaying(); else sender.StartPlaying(TimeSpan.FromSeconds((double)numericUpDown1.Value)); } catch { return; } }
void sender_OnDisconnect(RtspClient sender, object args) { if (sender == null || sender.IsDisposed) return; sender.Client.RtpPacketReceieved -= ShowRtpPacket; sender.Client.RtcpPacketReceieved -= ShowRtcpPacket; sender.OnPlay -= sender_OnPlay; sender.OnResponse -= sender_OnResponse; sender.OnRequest -= sender_OnRequest; sender.OnDisconnect -= sender_OnDisconnect; sender.Client.RtpPacketReceieved -= ShowRtpPacket; sender.Client.RtcpPacketReceieved -= ShowRtcpPacket; sender.Client.RtcpPacketSent -= ShowRtcpPacket; sender.OnStop -= sender_OnStop; sender.Dispose(); button1_Click(this, EventArgs.Empty); }