From ec970f81b1f74fa12b5115d60a5591d5017b8608 Mon Sep 17 00:00:00 2001 From: zoey jodon Date: Sun, 3 Dec 2023 14:42:37 -0500 Subject: [PATCH 1/3] Use the ping timeout for launch event timeouts --- src/rtsp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rtsp.cpp b/src/rtsp.cpp index 5a12253de17..5ac6b2a8ad3 100644 --- a/src/rtsp.cpp +++ b/src/rtsp.cpp @@ -315,7 +315,7 @@ namespace rtsp_stream { if (raised_timeout > now && launch_event.peek()) { return; } - raised_timeout = now + 10s; + raised_timeout = now + config::stream.ping_timeout; --_slot_count; launch_event.raise(launch_session); From d097a06d79aff13e35ec88a8d53f8659a8d0b65c Mon Sep 17 00:00:00 2001 From: zoey jodon Date: Sun, 3 Dec 2023 16:20:37 -0500 Subject: [PATCH 2/3] Log discarded events to debug --- src/rtsp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rtsp.cpp b/src/rtsp.cpp index 5ac6b2a8ad3..f7d522bdb26 100644 --- a/src/rtsp.cpp +++ b/src/rtsp.cpp @@ -334,6 +334,7 @@ namespace rtsp_stream { if (raised_timeout < std::chrono::steady_clock::now()) { auto discarded = launch_event.pop(0s); if (discarded) { + BOOST_LOG(debug) << "Event timeout: "sv << discarded->unique_id; ++_slot_count; } } From fa52ef97f58204dc44ad64a2946061d0c2ffb2b7 Mon Sep 17 00:00:00 2001 From: zoey jodon Date: Tue, 5 Dec 2023 13:37:17 -0500 Subject: [PATCH 3/3] Comment changed functions --- src/rtsp.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/rtsp.cpp b/src/rtsp.cpp index f7d522bdb26..9aa3ea1c220 100644 --- a/src/rtsp.cpp +++ b/src/rtsp.cpp @@ -307,6 +307,19 @@ namespace rtsp_stream { _map_cmd_cb.emplace(type, std::move(cb)); } + /** + * @brief Launch a new streaming session. + * @note If the client does not begin streaming within the ping_timeout, + * the session will be discarded. + * @param launch_session Streaming session information. + * + * EXAMPLES: + * ```cpp + * launch_session_t launch_session; + * rtsp_server_t server {}; + * server.session_raise(launch_session); + * ``` + */ void session_raise(rtsp_stream::launch_session_t launch_session) { auto now = std::chrono::steady_clock::now(); @@ -328,6 +341,15 @@ namespace rtsp_stream { safe::event_t launch_event; + /** + * @brief Clear launch sessions. + * @param all If true, clear all sessions. Otherwise, only clear timed out and stopped sessions. + * + * EXAMPLES: + * ```cpp + * clear(false); + * ``` + */ void clear(bool all = true) { // if a launch event timed out --> Remove it.