From dca3fffbedeef8f855ee64527a445e43d5525d06 Mon Sep 17 00:00:00 2001 From: "F. Duncanh" Date: Tue, 16 Dec 2025 13:07:43 -0500 Subject: [PATCH] minor hls rearrangements --- lib/http_handlers.h | 30 +++++++++++++++++++++++++----- lib/raop.c | 18 ------------------ lib/raop.h | 4 +--- uxplay.cpp | 5 ++++- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/lib/http_handlers.h b/lib/http_handlers.h index 48e7cec..2363876 100644 --- a/lib/http_handlers.h +++ b/lib/http_handlers.h @@ -19,6 +19,26 @@ #include "airplay_video.h" #include "fcup_request.h" +static void +*hls_get_current_video(raop_t *raop) { + if (raop->current_video < 0) { + logger_log(raop->logger, LOGGER_ERR, "hls_get_current_video: failed to identify current_playlist"); + return NULL; + } + assert(raop->airplay_video[raop->current_video]); + return (void *) raop->airplay_video[raop->current_video]; +} + +static int +get_playlist_by_uuid(raop_t *raop, const char *uuid) { + for (int i = 0 ;i < MAX_AIRPLAY_VIDEO && raop->airplay_video[i]; i++) { + if (!strcmp(uuid, get_playback_uuid(raop->airplay_video[i]))) { + return i; + } + } + return -1; +} + static void http_handler_server_info(raop_conn_t *conn, http_request_t *request, http_response_t *response, char **response_data, int *response_datalen) { @@ -158,7 +178,7 @@ http_handler_set_property(raop_conn_t *conn, selectedMediaArray contains plist with language choice: */ - airplay_video_t *airplay_video = (airplay_video_t *) raop_get_current_video(raop); + airplay_video_t *airplay_video = (airplay_video_t *) hls_get_current_video(raop); if (!strcmp(property, "selectedMediaArray")) { /* verify that this request contains a binary plist*/ char *header_str = NULL; @@ -438,7 +458,7 @@ http_handler_action(raop_conn_t *conn, http_request_t *request, http_response_t char **response_data, int *response_datalen) { raop_t *raop = conn->raop; - airplay_video_t *airplay_video = (airplay_video_t *) raop_get_current_video(raop); + airplay_video_t *airplay_video = (airplay_video_t *) hls_get_current_video(raop); bool data_is_plist = false; plist_t req_root_node = NULL; uint64_t uint_val = 0; @@ -771,7 +791,7 @@ http_handler_play(raop_conn_t *conn, http_request_t *request, http_response_t *r delete_short_playlist(raop, current_video); } raop->current_video = id; - airplay_video = raop_get_current_video(raop); + airplay_video = hls_get_current_video(raop); assert(airplay_video); set_apple_session_id(airplay_video, apple_session_id, strlen(apple_session_id)); float resume_pos = get_resume_position_seconds(airplay_video); @@ -811,7 +831,7 @@ http_handler_play(raop_conn_t *conn, http_request_t *request, http_response_t *r raop->current_video = id; raop->airplay_video[id] = airplay_video_init(raop, raop->port, raop->lang); - airplay_video = raop_get_current_video(raop); + airplay_video = hls_get_current_video(raop); if (airplay_video) { set_playback_uuid(airplay_video, playback_uuid, strlen(playback_uuid)); plist_mem_free (playback_uuid); @@ -941,7 +961,7 @@ http_handler_hls(raop_conn_t *conn, http_request_t *request, http_response_t *r free (header_str); return; } - airplay_video_t *airplay_video = (airplay_video_t *) raop_get_current_video(raop); + airplay_video_t *airplay_video = (airplay_video_t *) hls_get_current_video(raop); if (!strcmp(url, "/master.m3u8")){ char * master_playlist = get_master_playlist(airplay_video); if (master_playlist) { diff --git a/lib/raop.c b/lib/raop.c index d57dad2..f24410b 100644 --- a/lib/raop.c +++ b/lib/raop.c @@ -863,24 +863,6 @@ void raop_playlist_remove(raop_t *raop, void *opaque, float position_seconds) { } } -void *raop_get_current_video(raop_t *raop) { - if (raop->current_video < 0) { - logger_log(raop->logger, LOGGER_ERR, "raop_get_current_video: failed to identify current_playlist"); - return NULL; - } - assert(raop->airplay_video[raop->current_video]); - return (void *) raop->airplay_video[raop->current_video]; -} - -int get_playlist_by_uuid(raop_t *raop, const char *uuid) { - for (int i = 0 ;i < MAX_AIRPLAY_VIDEO && raop->airplay_video[i]; i++) { - if (!strcmp(uuid, get_playback_uuid(raop->airplay_video[i]))) { - return i; - } - } - return -1; -} - uint64_t get_local_time() { return raop_ntp_get_local_time(); } diff --git a/lib/raop.h b/lib/raop.h index 2201187..38038cd 100644 --- a/lib/raop.h +++ b/lib/raop.h @@ -108,11 +108,9 @@ raop_ntp_t *raop_ntp_init(logger_t *logger, raop_callbacks_t *callbacks, const c timing_protocol_t *time_protocol); airplay_video_t *airplay_video_init(raop_t *raop, unsigned short port, const char *lang); -int get_playlist_by_uuid(raop_t *raop, const char *uuid); char *raop_get_lang(raop_t *raop); uint64_t get_local_time(); -void *raop_get_current_video(raop_t *raop); - + RAOP_API raop_t *raop_init(raop_callbacks_t *callbacks); RAOP_API int raop_init2(raop_t *raop, int nohold, const char *device_id, const char *keyfile); RAOP_API void raop_set_log_level(raop_t *raop, int level); diff --git a/uxplay.cpp b/uxplay.cpp index 6e57199..4dc4c91 100644 --- a/uxplay.cpp +++ b/uxplay.cpp @@ -637,7 +637,10 @@ static gboolean progress_callback (gpointer loop) { static gboolean video_eos_watch_callback (gpointer loop) { if (video_renderer_eos_watch()) { /* HLS video has sent EOS */ - LOGI("hls video has sent EOS"); + LOGI("hls video has sent EOS"); + video_renderer_hls_ready(); + video_renderer_start(); + /* if raop->interrupted_video exists, we should reset video without deleting raop->airplay_video */ } return TRUE; }