mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-14 00:04:13 +09:00
add functions for future use (will not change current behavior)
This commit is contained in:
@@ -44,6 +44,7 @@ struct airplay_video_s {
|
||||
int next_uri;
|
||||
int FCUP_RequestID;
|
||||
float start_position_seconds;
|
||||
float resume_position_seconds;
|
||||
playback_info_t *playback_info;
|
||||
// The local port of the airplay server on the AirPlay server
|
||||
unsigned short airplay_port;
|
||||
@@ -125,10 +126,18 @@ float get_start_position_seconds(airplay_video_t *airplay_video) {
|
||||
return airplay_video->start_position_seconds;
|
||||
}
|
||||
|
||||
float get_resume_position_seconds(airplay_video_t *airplay_video) {
|
||||
return airplay_video->resume_position_seconds;
|
||||
}
|
||||
|
||||
void set_start_position_seconds(airplay_video_t *airplay_video, float start_position_seconds) {
|
||||
airplay_video->start_position_seconds = start_position_seconds;
|
||||
}
|
||||
|
||||
|
||||
void set_resume_position_seconds(airplay_video_t *airplay_video, float resume_position_seconds) {
|
||||
airplay_video->resume_position_seconds = resume_position_seconds;
|
||||
}
|
||||
|
||||
void set_playback_uuid(airplay_video_t *airplay_video, const char *playback_uuid) {
|
||||
size_t len = strlen(playback_uuid);
|
||||
assert(len == 36);
|
||||
|
||||
@@ -28,7 +28,9 @@ 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_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);
|
||||
const char *get_playback_uuid(airplay_video_t *airplay_video);
|
||||
void set_uri_prefix(airplay_video_t *airplay_video, char *uri_prefix, int uri_prefix_len);
|
||||
|
||||
32
lib/raop.c
32
lib/raop.c
@@ -852,6 +852,38 @@ void raop_destroy_airplay_video(raop_t *raop, int id) {
|
||||
}
|
||||
}
|
||||
}
|
||||
void raop_playlist_remove(raop_t *raop, void *opaque, float position_seconds) {
|
||||
airplay_video_t *airplay_video = (airplay_video_t *) opaque;
|
||||
|
||||
int id = -1;
|
||||
for (int i = 0; i < MAX_AIRPLAY_VIDEO; i++) {
|
||||
if (airplay_video == raop->airplay_video[i]) {
|
||||
id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (id >= 0) {
|
||||
set_resume_position_seconds(airplay_video, position_seconds);
|
||||
raop->current_video = -1;
|
||||
float pos = get_resume_position_seconds(airplay_video);
|
||||
assert(pos == position_seconds);
|
||||
} else {
|
||||
logger_log(raop->logger, LOGGER_ERR, "raop_playlist_remove: failed to identify removed_video");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
int raop_current_playlist_delete(raop_t *raop) {
|
||||
int current_video = raop->current_video;
|
||||
assert (current_video < MAX_AIRPLAY_VIDEO);
|
||||
if (current_video >= 0) {
|
||||
raop_destroy_airplay_video(raop, current_video);
|
||||
raop->current_video = -1;
|
||||
} else {
|
||||
logger_log(raop->logger, LOGGER_ERR, "raop_current_playlist_delete: failed to identify current_playlist");
|
||||
}
|
||||
return current_video;
|
||||
}
|
||||
|
||||
uint64_t get_local_time() {
|
||||
return raop_ntp_get_local_time();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "airplay_video.h"
|
||||
|
||||
#define RAOP_API
|
||||
#define MAX_AIRPLAY_VIDEO 2
|
||||
#define MAX_AIRPLAY_VIDEO 10
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -98,6 +98,7 @@ struct raop_callbacks_s {
|
||||
void (*on_video_rate) (void *cls, const float rate);
|
||||
void (*on_video_stop) (void *cls);
|
||||
void (*on_video_acquire_playback_info) (void *cls, playback_info_t *playback_video);
|
||||
void (*on_video_playlist_remove) (void *cls, void *airplay_video);
|
||||
};
|
||||
|
||||
typedef struct raop_callbacks_s raop_callbacks_t;
|
||||
@@ -128,7 +129,9 @@ RAOP_API void raop_destroy(raop_t *raop);
|
||||
RAOP_API void raop_remove_known_connections(raop_t * raop);
|
||||
RAOP_API void raop_remove_hls_connections(raop_t * raop);
|
||||
RAOP_API void raop_destroy_airplay_video(raop_t *raop, int id);
|
||||
|
||||
RAOP_API int raop_current_playlist_delete(raop_t *raop);
|
||||
RAOP_API void raop_playlist_remove(raop_t *raop, void *airplay_video, float position);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -635,6 +635,19 @@ uint64_t video_renderer_render_buffer(unsigned char* data, int *data_len, int *n
|
||||
void video_renderer_flush() {
|
||||
}
|
||||
|
||||
void video_renderer_hls_ready() {
|
||||
GstState state;
|
||||
GstStateChangeReturn ret;
|
||||
if (renderer && hls_video) {
|
||||
logger_log(logger, LOGGER_DEBUG,"video_renderer_hls_ready");
|
||||
ret = gst_element_set_state (renderer->pipeline, GST_STATE_READY);
|
||||
logger_log(logger, LOGGER_DEBUG,"pipeline_state_change_return: %s",
|
||||
gst_element_state_change_return_get_name(ret));
|
||||
gst_element_get_state(renderer->pipeline, &state, NULL, 1000 * GST_MSECOND);
|
||||
logger_log(logger, LOGGER_DEBUG,"pipeline state is %s", gst_element_state_get_name(state));
|
||||
}
|
||||
}
|
||||
|
||||
void video_renderer_stop() {
|
||||
if (renderer) {
|
||||
logger_log(logger, LOGGER_DEBUG,"video_renderer_stop");
|
||||
|
||||
@@ -54,6 +54,7 @@ typedef struct video_renderer_s video_renderer_t;
|
||||
void video_renderer_start (void *raop, const char *uri);
|
||||
void video_renderer_stop ();
|
||||
void video_renderer_pause ();
|
||||
void video_renderer_hls_ready ();
|
||||
void video_renderer_seek(float position);
|
||||
void video_renderer_set_start(float position);
|
||||
void video_renderer_resume ();
|
||||
|
||||
18
uxplay.cpp
18
uxplay.cpp
@@ -2485,10 +2485,23 @@ extern "C" void on_video_rate(void *cls, const float rate) {
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void on_video_stop(void *cls) {
|
||||
LOGI("on_video_stop\n");
|
||||
|
||||
|
||||
extern "C" void on_video_playlist_remove (void *cls, void *airplay_video) {
|
||||
double duration, position;
|
||||
float rate;
|
||||
bool buffer_empty, buffer_full;
|
||||
LOGI("************************* on_video_playlist_remove\n");
|
||||
video_renderer_pause();
|
||||
video_get_playback_info(&duration, &position, &rate, &buffer_empty, &buffer_full);
|
||||
raop_playlist_remove(raop, airplay_video, (float) position);
|
||||
}
|
||||
|
||||
extern "C" void on_video_stop(void *cls) {
|
||||
LOGI("**************************on_video_stop\n");
|
||||
video_renderer_hls_ready();
|
||||
}
|
||||
|
||||
extern "C" void on_video_acquire_playback_info (void *cls, playback_info_t *playback_info) {
|
||||
int buffering_level;
|
||||
bool still_playing = video_get_playback_info(&playback_info->duration, &playback_info->position,
|
||||
@@ -2562,6 +2575,7 @@ static int start_raop_server (unsigned short display[5], unsigned short tcp[3],
|
||||
raop_cbs.on_video_scrub = on_video_scrub;
|
||||
raop_cbs.on_video_rate = on_video_rate;
|
||||
raop_cbs.on_video_stop = on_video_stop;
|
||||
raop_cbs.on_video_playlist_remove = on_video_playlist_remove;
|
||||
raop_cbs.on_video_acquire_playback_info = on_video_acquire_playback_info;
|
||||
|
||||
raop = raop_init(&raop_cbs);
|
||||
|
||||
Reference in New Issue
Block a user