detect unsupported (non-youtube) HLS

This commit is contained in:
F. Duncanh
2025-02-02 17:35:05 -05:00
parent e60bf9caee
commit 14e6ba5543
7 changed files with 56 additions and 27 deletions

View File

@@ -836,12 +836,14 @@ http_handler_play(raop_conn_t *conn, http_request_t *request, http_response_t *r
char **response_data, int *response_datalen) {
char* playback_location = NULL;
char* client_proc_name = NULL;
plist_t req_root_node = NULL;
float start_position_seconds = 0.0f;
bool data_is_binary_plist = false;
bool data_is_text = false;
bool data_is_octet = false;
char supported_hls_proc_names[] = "YouTube;";
logger_log(conn->raop->logger, LOGGER_DEBUG, "http_handler_play");
const char* session_id = http_request_get_header(request, "X-Apple-Session-ID");
@@ -902,6 +904,17 @@ http_handler_play(raop_conn_t *conn, http_request_t *request, http_response_t *r
plist_get_string_val(req_content_location_node, &playback_location);
}
plist_t req_client_proc_name_node = plist_dict_get_item(req_root_node, "clientProcName");
if (!req_client_proc_name_node) {
goto play_error;
} else {
plist_get_string_val(req_client_proc_name_node, &client_proc_name);
if (!strstr(supported_hls_proc_names, client_proc_name)){
logger_log(conn->raop->logger, LOGGER_WARNING, "Unsupported HLS streaming format: clientProcName %s not found in supported list: %s",
client_proc_name, supported_hls_proc_names);
}
}
plist_t req_start_position_seconds_node = plist_dict_get_item(req_root_node, "Start-Position-Seconds");
if (!req_start_position_seconds_node) {
logger_log(conn->raop->logger, LOGGER_INFO, "No Start-Position-Seconds in Play request");
@@ -914,6 +927,10 @@ http_handler_play(raop_conn_t *conn, http_request_t *request, http_response_t *r
}
char *ptr = strstr(playback_location, "/master.m3u8");
if (!ptr) {
logger_log(conn->raop->logger, LOGGER_ERR, "Content-Location has unsupported form:\n%s\n", playback_location);
goto play_error;
}
int prefix_len = (int) (ptr - playback_location);
set_uri_prefix(conn->raop->airplay_video, playback_location, prefix_len);
set_next_media_uri_id(conn->raop->airplay_video, 0);
@@ -932,8 +949,10 @@ http_handler_play(raop_conn_t *conn, http_request_t *request, http_response_t *r
if (req_root_node) {
plist_free(req_root_node);
}
logger_log(conn->raop->logger, LOGGER_ERR, "Could not find valid Plist Data for /play, Unhandled");
logger_log(conn->raop->logger, LOGGER_ERR, "Could not find valid Plist Data for POST/play request, Unhandled");
http_response_init(response, "HTTP/1.1", 400, "Bad Request");
http_response_set_disconnect(response, 1);
conn->raop->callbacks.conn_reset(conn->raop->callbacks.cls, 2);
}
/* the HLS handler handles http requests GET /[uri] on the HLS channel from the media player to the Server, asking for

View File

@@ -68,11 +68,13 @@ struct raop_callbacks_s {
void (*video_pause)(void *cls);
void (*video_resume)(void *cls);
void (*conn_feedback) (void *cls);
/* Optional but recommended callback functions */
void (*conn_reset) (void *cls, int reason);
void (*video_reset) (void *cls);
/* Optional but recommended callback functions (probably not optional, check this)*/
void (*conn_init)(void *cls);
void (*conn_destroy)(void *cls);
void (*conn_reset) (void *cls);
void (*conn_teardown)(void *cls, bool *teardown_96, bool *teardown_110 );
void (*audio_flush)(void *cls);
void (*video_flush)(void *cls);
@@ -88,7 +90,6 @@ struct raop_callbacks_s {
void (*register_client) (void *cls, const char *device_id, const char *pk_str, const char *name);
bool (*check_register) (void *cls, const char *pk_str);
void (*export_dacp) (void *cls, const char *active_remote, const char *dacp_id);
void (*video_reset) (void *cls);
void (*video_set_codec)(void *cls, video_codec_t codec);
/* for HLS video player controls */
void (*on_video_play) (void *cls, const char *location, const float start_position);

View File

@@ -811,7 +811,7 @@ raop_rtp_mirror_thread(void *arg)
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror exiting TCP thread");
if (conn_reset&& raop_rtp_mirror->callbacks.conn_reset) {
raop_rtp_mirror->callbacks.conn_reset(raop_rtp_mirror->callbacks.cls);
raop_rtp_mirror->callbacks.conn_reset(raop_rtp_mirror->callbacks.cls, 1);
}
if (unsupported_codec) {