From 98f15b645ff1d10a914c004d0b076916a5f1f094 Mon Sep 17 00:00:00 2001 From: mplayer-svn Date: Sat, 31 Dec 2011 12:20:08 +0000 Subject: stream: add new stream control command STREAM_CTRL_GET_NUM_TITLES This provides the total number of titles (aka tracks) of CDs / VCDs / DVDs. Additionally, add a titles property to the get_property slave command. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34474 b3059339-0415-0410-9bf9-f77b7e298cf2 Author: ib --- DOCS/OUTDATED-tech/slave.txt | 1 + command.c | 13 +++++++++++++ libmpdemux/demuxer.h | 2 ++ stream/stream.h | 1 + stream/stream_cdda.c | 5 +++++ stream/stream_dvd.c | 5 +++++ stream/stream_vcd.c | 1 + 7 files changed, 28 insertions(+) diff --git a/DOCS/OUTDATED-tech/slave.txt b/DOCS/OUTDATED-tech/slave.txt index d57a8aca46..db7fabc5ce 100644 --- a/DOCS/OUTDATED-tech/slave.txt +++ b/DOCS/OUTDATED-tech/slave.txt @@ -518,6 +518,7 @@ stream_start pos 0 X start pos in stream stream_end pos 0 X end pos in stream stream_length pos 0 X (end - start) stream_time_pos time 0 X present position in stream (in seconds) +titles int X number of titles chapter int 0 X X X select chapter chapters int X number of chapters angle int 0 X X X select angle diff --git a/command.c b/command.c index 842a9359e0..dd7a1ee34c 100644 --- a/command.c +++ b/command.c @@ -547,6 +547,17 @@ static int mp_property_chapter(m_option_t *prop, int action, void *arg, return M_PROPERTY_OK; } +/// Number of titles in file +static int mp_property_titles(m_option_t *prop, int action, void *arg, + MPContext *mpctx) +{ + if (!mpctx->demuxer) + return M_PROPERTY_UNAVAILABLE; + if (mpctx->demuxer->num_titles == 0) + stream_control(mpctx->demuxer->stream, STREAM_CTRL_GET_NUM_TITLES, &mpctx->demuxer->num_titles); + return m_property_int_ro(prop, action, arg, mpctx->demuxer->num_titles); +} + /// Number of chapters in file static int mp_property_chapters(m_option_t *prop, int action, void *arg, MPContext *mpctx) @@ -2144,6 +2155,8 @@ static const m_option_t mp_properties[] = { M_OPT_MIN, 0, 0, NULL }, { "chapter", mp_property_chapter, CONF_TYPE_INT, M_OPT_MIN, 0, 0, NULL }, + { "titles", mp_property_titles, CONF_TYPE_INT, + 0, 0, 0, NULL }, { "chapters", mp_property_chapters, CONF_TYPE_INT, 0, 0, 0, NULL }, { "angle", mp_property_angle, CONF_TYPE_INT, diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h index 10ccc0b8e4..bdc401dd14 100644 --- a/libmpdemux/demuxer.h +++ b/libmpdemux/demuxer.h @@ -248,6 +248,8 @@ typedef struct demuxer { struct sh_video *v_streams[MAX_V_STREAMS]; struct sh_sub *s_streams[MAX_S_STREAMS]; + int num_titles; + struct demux_chapter *chapters; int num_chapters; diff --git a/stream/stream.h b/stream/stream.h index 81bfcf0386..3ad65bb656 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -98,6 +98,7 @@ #define STREAM_CTRL_GET_NUM_ANGLES 9 #define STREAM_CTRL_GET_ANGLE 10 #define STREAM_CTRL_SET_ANGLE 11 +#define STREAM_CTRL_GET_NUM_TITLES 12 typedef enum { diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index 8bd179b1df..a014ad14c4 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -254,6 +254,11 @@ static int control(stream_t *stream, int cmd, void *arg) { cdda_priv *p = stream->priv; switch (cmd) { + case STREAM_CTRL_GET_NUM_TITLES: + { + *(unsigned int *)arg = p->cd->tracks; + return STREAM_OK; + } case STREAM_CTRL_GET_NUM_CHAPTERS: { int start_track = get_track_by_sector(p, p->start_sector); diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 2121e78ccc..b9ffafed8f 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -621,6 +621,11 @@ static int control(stream_t *stream,int cmd,void* arg) *((double *)arg) = (double) mp_get_titleset_length(d->vts_file, d->tt_srpt, d->cur_title-1)/1000.0; return 1; } + case STREAM_CTRL_GET_NUM_TITLES: + { + *((unsigned int *)arg) = d->vmg_file->tt_srpt->nr_of_srpts; + return 1; + } case STREAM_CTRL_GET_NUM_CHAPTERS: { int r; diff --git a/stream/stream_vcd.c b/stream/stream_vcd.c index e06e381f59..0dae3731fb 100644 --- a/stream/stream_vcd.c +++ b/stream/stream_vcd.c @@ -91,6 +91,7 @@ static int seek(stream_t *s,off_t newpos) { static int control(stream_t *stream, int cmd, void *arg) { struct stream_priv_s *p = stream->priv; switch(cmd) { + case STREAM_CTRL_GET_NUM_TITLES: case STREAM_CTRL_GET_NUM_CHAPTERS: { mp_vcd_priv_t *vcd = vcd_read_toc(stream->fd); -- cgit v1.2.3