mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-14 00:04:13 +09:00
shut down HLS when client stops streaming
This commit is contained in:
13
lib/httpd.c
13
lib/httpd.c
@@ -205,6 +205,8 @@ httpd_remove_connection(httpd_t *httpd, http_connection_t *connection)
|
||||
http_request_destroy(connection->request);
|
||||
connection->request = NULL;
|
||||
}
|
||||
logger_log(httpd->logger, LOGGER_DEBUG, "removing connection type %s socket %d conn %p", typename[connection->type],
|
||||
connection->socket_fd, connection->user_data);
|
||||
httpd->callbacks.conn_destroy(connection->user_data);
|
||||
shutdown(connection->socket_fd, SHUT_WR);
|
||||
closesocket(connection->socket_fd);
|
||||
@@ -303,6 +305,17 @@ httpd_remove_known_connections(httpd_t *httpd) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
httpd_remove_connections_by_type(httpd_t *httpd, connection_type_t type) {
|
||||
for (int i = 0; i < httpd->max_connections; i++) {
|
||||
http_connection_t *connection = &httpd->connections[i];
|
||||
if (!connection->connected || connection->type != type) {
|
||||
continue;
|
||||
}
|
||||
httpd_remove_connection(httpd, connection);
|
||||
}
|
||||
}
|
||||
|
||||
static THREAD_RETVAL
|
||||
httpd_thread(void *arg)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ struct httpd_callbacks_s {
|
||||
typedef struct httpd_callbacks_s httpd_callbacks_t;
|
||||
bool httpd_nohold(httpd_t *httpd);
|
||||
void httpd_remove_known_connections(httpd_t *httpd);
|
||||
void httpd_remove_connections_by_type(httpd_t *httpd, connection_type_t type);
|
||||
|
||||
int httpd_set_connection_type (httpd_t *http, void *user_data, connection_type_t type);
|
||||
int httpd_count_connection_type (httpd_t *http, connection_type_t type);
|
||||
|
||||
@@ -1083,5 +1083,8 @@ raop_handler_teardown(raop_conn_t *conn,
|
||||
raop_rtp_mirror_destroy(conn->raop_rtp_mirror);
|
||||
conn->raop_rtp_mirror = NULL;
|
||||
}
|
||||
/* shut down any HLS connections */
|
||||
httpd_remove_connections_by_type(conn->raop->httpd, CONNECTION_TYPE_HLS);
|
||||
conn->raop->callbacks.video_reset(conn->raop->callbacks.cls);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user