mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-14 00:04:13 +09:00
ensure space for stored playlists by not storing short adverts
This commit is contained in:
@@ -127,6 +127,10 @@ const char *get_apple_session_id(airplay_video_t *airplay_video) {
|
||||
return airplay_video->apple_session_id;
|
||||
}
|
||||
|
||||
float get_duration(airplay_video_t *airplay_video) {
|
||||
return airplay_video->media_data_store->duration;
|
||||
}
|
||||
|
||||
float get_start_position_seconds(airplay_video_t *airplay_video) {
|
||||
return airplay_video->start_position_seconds;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ typedef struct media_item_s media_item_t;
|
||||
const char *get_apple_session_id(airplay_video_t *airplay_video);
|
||||
void set_start_position_seconds(airplay_video_t *airplay_video, float start_position_seconds);
|
||||
void set_resume_position_seconds(airplay_video_t *airplay_video, float resume_position_seconds);
|
||||
float get_duration(airplay_video_t *airplay_video);
|
||||
float get_start_position_seconds(airplay_video_t *airplay_video);
|
||||
float get_resume_position_seconds(airplay_video_t *airplay_video);
|
||||
void set_playback_uuid(airplay_video_t *airplay_video, const char *playback_uuid);
|
||||
|
||||
@@ -715,7 +715,15 @@ http_handler_play(raop_conn_t *conn, http_request_t *request, http_response_t *r
|
||||
|
||||
plist_from_bin(request_data, request_datalen, &req_root_node);
|
||||
|
||||
/* initialize the airplay video service */
|
||||
plist_t req_uuid_node = plist_dict_get_item(req_root_node, "uuid");
|
||||
if (!req_uuid_node) {
|
||||
goto play_error;
|
||||
}
|
||||
char* playback_uuid = NULL;
|
||||
plist_get_string_val(req_uuid_node, &playback_uuid);
|
||||
|
||||
/* initialize new airplay_video structure to hold playlist */
|
||||
|
||||
int id = -1;
|
||||
for (int i = 0; i < MAX_AIRPLAY_VIDEO; i++) {
|
||||
if (conn->raop->airplay_video[i]) {
|
||||
@@ -730,7 +738,23 @@ http_handler_play(raop_conn_t *conn, http_request_t *request, http_response_t *r
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* initialize new airplay_video structure to hold playlist */
|
||||
/* ensure that space will always be available */
|
||||
int count = 1;
|
||||
for (int i = 0; i < MAX_AIRPLAY_VIDEO; i++) {
|
||||
if (conn->raop->airplay_video[i]) {
|
||||
if (get_duration(conn->raop->airplay_video[i]) < (float) MIN_STORED_AIRPLAY_VIDEO_DURATION_SECONDS ) {
|
||||
airplay_video_destroy(conn->raop->airplay_video[i]);
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert (count <= MAX_AIRPLAY_VIDEO);
|
||||
if (count == MAX_AIRPLAY_VIDEO) {
|
||||
int next = (id + 1) % (int) MAX_AIRPLAY_VIDEO;
|
||||
airplay_video_destroy(conn->raop->airplay_video[next]);
|
||||
}
|
||||
|
||||
airplay_video_t *airplay_video = airplay_video_init(conn->raop, conn->raop->port, conn->raop->lang, apple_session_id);
|
||||
if (airplay_video) {
|
||||
conn->raop->current_video = id;
|
||||
@@ -740,15 +764,9 @@ http_handler_play(raop_conn_t *conn, http_request_t *request, http_response_t *r
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
plist_t req_uuid_node = plist_dict_get_item(req_root_node, "uuid");
|
||||
if (!req_uuid_node) {
|
||||
goto play_error;
|
||||
} else {
|
||||
char* playback_uuid = NULL;
|
||||
plist_get_string_val(req_uuid_node, &playback_uuid);
|
||||
set_playback_uuid(airplay_video, playback_uuid);
|
||||
plist_mem_free (playback_uuid);
|
||||
}
|
||||
|
||||
|
||||
plist_t req_content_location_node = plist_dict_get_item(req_root_node, "Content-Location");
|
||||
if (!req_content_location_node) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#define RAOP_API
|
||||
#define MAX_AIRPLAY_VIDEO 10
|
||||
#define MIN_STORED_AIRPLAY_VIDEO_DURATION_SECONDS 90 //dont store advertisement playlists
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
Reference in New Issue
Block a user