diff options
-rw-r--r-- | core/mplayer.c | 20 | ||||
-rw-r--r-- | stream/cache.c | 10 | ||||
-rw-r--r-- | stream/stream.h | 6 | ||||
-rw-r--r-- | stream/stream_dvd.c | 8 |
4 files changed, 33 insertions, 11 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index 5c4b582be7..310559958a 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -137,10 +137,6 @@ #include "demux/demux.h" #include "demux/stheader.h" -#ifdef CONFIG_DVDREAD -#include "stream/stream_dvd.h" -#endif - #include "audio/filter/af.h" #include "audio/decode/dec_audio.h" #include "video/decode/dec_video.h" @@ -1013,9 +1009,9 @@ static void add_dvd_tracks(struct MPContext *mpctx) #ifdef CONFIG_DVDREAD struct demuxer *demuxer = mpctx->demuxer; struct stream *stream = demuxer->stream; - if (stream->type == STREAMTYPE_DVD) { - int n_subs = dvd_number_of_subs(stream); - for (int n = 0; n < n_subs; n++) { + struct stream_dvd_info_req info; + if (stream_control(stream, STREAM_CTRL_GET_DVD_INFO, &info) > 0) { + for (int n = 0; n < info.num_subs; n++) { struct track *track = talloc_ptrtype(NULL, track); *track = (struct track) { .type = STREAM_SUB, @@ -1946,7 +1942,11 @@ static void set_dvdsub_fake_extradata(struct dec_sub *dec_sub, struct stream *st int width, int height) { #ifdef CONFIG_DVDREAD - if (st->type != STREAMTYPE_DVD) + if (!st) + return; + + struct stream_dvd_info_req info; + if (stream_control(st, STREAM_CTRL_GET_DVD_INFO, &info) < 0) return; struct mp_csp_params csp = MP_CSP_PARAMS_DEFAULTS; @@ -1955,8 +1955,6 @@ static void set_dvdsub_fake_extradata(struct dec_sub *dec_sub, struct stream *st float cmatrix[3][4]; mp_get_yuv2rgb_coeffs(&csp, cmatrix); - int *palette = ((dvd_priv_t *)st->priv)->cur_pgc->palette; - if (width == 0 || height == 0) { width = 720; height = 480; @@ -1966,7 +1964,7 @@ static void set_dvdsub_fake_extradata(struct dec_sub *dec_sub, struct stream *st s = talloc_asprintf_append(s, "size: %dx%d\n", width, height); s = talloc_asprintf_append(s, "palette: "); for (int i = 0; i < 16; i++) { - int color = palette[i]; + int color = info.palette[i]; int c[3] = {(color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff}; mp_map_int_color(cmatrix, 8, c); color = (c[2] << 16) | (c[1] << 8) | c[0]; diff --git a/stream/cache.c b/stream/cache.c index a0ad2559ae..9038fc6cf6 100644 --- a/stream/cache.c +++ b/stream/cache.c @@ -90,6 +90,7 @@ typedef struct { volatile uint64_t control_uint_arg; volatile double control_double_arg; volatile struct stream_lang_req control_lang_arg; + volatile struct stream_dvd_info_req control_dvd_info_arg; volatile int control_res; volatile double stream_time_length; volatile double stream_time_pos; @@ -352,6 +353,10 @@ static int cache_execute_control(cache_vars_t *s) s->control_res = s->stream->control(s->stream, s->control, (void *)&s->control_lang_arg); break; + case STREAM_CTRL_GET_DVD_INFO: + s->control_res = s->stream->control(s->stream, s->control, + (void *)&s->control_dvd_info_arg); + break; case STREAM_CTRL_MANAGES_TIMELINE: s->control_res = s->stream->control(s->stream, s->control, NULL); break; @@ -737,6 +742,8 @@ int cache_do_control(stream_t *stream, int cmd, void *arg) break; case STREAM_CTRL_GET_LANG: s->control_lang_arg = *(struct stream_lang_req *)arg; + case STREAM_CTRL_GET_DVD_INFO: + s->control_dvd_info_arg = *(struct stream_dvd_info_req *)arg; case STREAM_CTRL_GET_NUM_TITLES: case STREAM_CTRL_GET_NUM_CHAPTERS: case STREAM_CTRL_GET_CURRENT_TITLE: @@ -797,6 +804,9 @@ int cache_do_control(stream_t *stream, int cmd, void *arg) case STREAM_CTRL_GET_LANG: *(struct stream_lang_req *)arg = s->control_lang_arg; break; + case STREAM_CTRL_GET_DVD_INFO: + *(struct stream_dvd_info_req *)arg = s->control_dvd_info_arg; + break; case STREAM_CTRL_MANAGES_TIMELINE: break; } diff --git a/stream/stream.h b/stream/stream.h index e4a482f737..360f65e008 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -103,6 +103,7 @@ #define STREAM_CTRL_MANAGES_TIMELINE 19 #define STREAM_CTRL_GET_START_TIME 20 #define STREAM_CTRL_GET_CHAPTER_TIME 21 +#define STREAM_CTRL_GET_DVD_INFO 22 struct stream_lang_req { int type; // STREAM_AUDIO, STREAM_SUB @@ -110,6 +111,11 @@ struct stream_lang_req { char name[50]; }; +struct stream_dvd_info_req { + unsigned int palette[16]; + int num_subs; +}; + typedef enum { streaming_stopped_e, streaming_playing_e diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index aa113667fd..1a641de5cd 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -747,6 +747,14 @@ static int control(stream_t *stream,int cmd,void* arg) } case STREAM_CTRL_MANAGES_TIMELINE: return STREAM_OK; + case STREAM_CTRL_GET_DVD_INFO: + { + struct stream_dvd_info_req *req = arg; + memset(req, 0, sizeof(*req)); + req->num_subs = dvd_number_of_subs(stream); + memcpy(req->palette, d->cur_pgc->palette, sizeof(req->palette)); + return STREAM_OK; + } } return STREAM_UNSUPPORTED; } |