From 5c0a096126c71ae0ffe022163cb706bdd696cd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E8=82=87=E6=A3=AE?= Date: Mon, 20 Jul 2026 14:54:06 +0800 Subject: [PATCH] Add a way to get RTSP status --- src/SharpRTSPClient/RTSPClient.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/SharpRTSPClient/RTSPClient.cs b/src/SharpRTSPClient/RTSPClient.cs index 4ec9cad..58f15d2 100644 --- a/src/SharpRTSPClient/RTSPClient.cs +++ b/src/SharpRTSPClient/RTSPClient.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using Rtsp; using Rtsp.Messages; using Rtsp.Onvif; @@ -57,7 +57,7 @@ public class RTSPClient : IDisposable public bool AutoPlay { get; set; } = true; - private enum RtspStatus { WaitingToConnect, Connecting, ConnectFailed, Connected }; + public enum RtspStatus { WaitingToConnect, Connecting, ConnectFailed, Connected }; private IRtspTransport _rtspSocket; // RTSP connection private RtspStatus _rtspSocketStatus = RtspStatus.WaitingToConnect; @@ -353,6 +353,14 @@ public bool StreamingFinished() } } + /// + /// Returns the current RTSP status. + /// + /// The current RTSP status. + public RtspStatus GetRtspStatus() + { + return _rtspSocketStatus; + } /// /// Pause. /// @@ -451,6 +459,7 @@ public void Play(DateTime seekTimeFrom, DateTime seekTimeTo, double speed = 1.0) public void Stop() { StopClient(); + _rtspSocketStatus = RtspStatus.WaitingToConnect; } private void StopClient()