summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-13 20:25:31 +0100
committerwm4 <wm4@nowhere>2014-12-13 20:25:56 +0100
commit5b618ef62976370ca184839d0bd8efd615e9f20e (patch)
tree8be94ca30d18ff40e86fe1b6f4f216cc81078e10 /player/command.c
parentc3275f7e531dc95f68e7a293d1e75684d75725f2 (diff)
downloadmpv-5b618ef62976370ca184839d0bd8efd615e9f20e.tar.bz2
mpv-5b618ef62976370ca184839d0bd8efd615e9f20e.tar.xz
command, dvd: add property which returns list of DVD titles
This was requested. It seems libdvdread can't get the duration for titlesets other than the currently opened title. The data structures contain dangling pointers for these, and MPlayer works this around by opening every title separately for the purpose of dumping the title list.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index 1b7156bb6c..febbb785b0 100644
--- a/player/command.c
+++ b/player/command.c
@@ -910,6 +910,38 @@ static int mp_property_disc_titles(void *ctx, struct m_property *prop,
return m_property_int_ro(action, arg, num_titles);
}
+static int get_disc_title_entry(int item, int action, void *arg, void *ctx)
+{
+ struct MPContext *mpctx = ctx;
+ struct demuxer *demuxer = mpctx->master_demuxer;
+
+ double len = item;
+ if (demux_stream_control(demuxer, STREAM_CTRL_GET_TITLE_LENGTH, &len) < 1)
+ len = -1;
+
+ struct m_sub_property props[] = {
+ {"id", SUB_PROP_INT(item)},
+ {"length", {.type = CONF_TYPE_TIME}, {.time = len},
+ .unavailable = len < 0},
+ {0}
+ };
+
+ return m_property_read_sub(props, action, arg);
+}
+
+static int mp_property_list_disc_titles(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ struct demuxer *demuxer = mpctx->master_demuxer;
+ unsigned int num_titles;
+ if (!demuxer || demux_stream_control(demuxer, STREAM_CTRL_GET_NUM_TITLES,
+ &num_titles) < 1)
+ return M_PROPERTY_UNAVAILABLE;
+ return m_property_read_list(action, arg, num_titles,
+ get_disc_title_entry, mpctx);
+}
+
/// Number of chapters in file
static int mp_property_chapters(void *ctx, struct m_property *prop,
int action, void *arg)
@@ -3227,6 +3259,7 @@ static const struct m_property mp_properties[] = {
{"chapter-list", mp_property_list_chapters},
{"track-list", property_list_tracks},
{"edition-list", property_list_editions},
+ {"disc-title-list", mp_property_list_disc_titles},
{"playlist", mp_property_playlist},
{"playlist-pos", mp_property_playlist_pos},