minor hls rearrangements

This commit is contained in:
F. Duncanh
2025-12-16 13:07:43 -05:00
parent ed6326e915
commit dca3fffbed
4 changed files with 30 additions and 27 deletions

View File

@@ -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) {

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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;
}