Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend session timeout #1890

Merged
merged 4 commits into from
Dec 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/rtsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -315,7 +328,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);
Expand All @@ -328,12 +341,22 @@ namespace rtsp_stream {

safe::event_t<rtsp_stream::launch_session_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.
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;
}
}
Expand Down