[MPlayer-cvslog] r34474 - in trunk: DOCS/tech/slave.txt command.c libmpdemux/demuxer.h stream/stream.h stream/stream_cdda.c stream/stream_dvd.c stream/stream_vcd.c

ib subversion at mplayerhq.hu
Sat Dec 31 13:20:09 CET 2011


Author: ib
Date: Sat Dec 31 13:20:08 2011
New Revision: 34474

Log:
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.

Modified:
   trunk/DOCS/tech/slave.txt
   trunk/command.c
   trunk/libmpdemux/demuxer.h
   trunk/stream/stream.h
   trunk/stream/stream_cdda.c
   trunk/stream/stream_dvd.c
   trunk/stream/stream_vcd.c

Modified: trunk/DOCS/tech/slave.txt
==============================================================================
--- trunk/DOCS/tech/slave.txt	Thu Dec 29 20:42:58 2011	(r34473)
+++ trunk/DOCS/tech/slave.txt	Sat Dec 31 13:20:08 2011	(r34474)
@@ -530,6 +530,7 @@ stream_start       pos       0          
 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

Modified: trunk/command.c
==============================================================================
--- trunk/command.c	Thu Dec 29 20:42:58 2011	(r34473)
+++ trunk/command.c	Sat Dec 31 13:20:08 2011	(r34474)
@@ -515,6 +515,17 @@ static int mp_property_chapter(m_option_
     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)
@@ -2142,6 +2153,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,

Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h	Thu Dec 29 20:42:58 2011	(r34473)
+++ trunk/libmpdemux/demuxer.h	Sat Dec 31 13:20:08 2011	(r34474)
@@ -263,6 +263,8 @@ typedef struct demuxer {
   // pointer to teletext decoder private data, if demuxer stream contains teletext
   void *teletext;
 
+  int num_titles;
+
   demux_chapter_t* chapters;
   int num_chapters;
 

Modified: trunk/stream/stream.h
==============================================================================
--- trunk/stream/stream.h	Thu Dec 29 20:42:58 2011	(r34473)
+++ trunk/stream/stream.h	Sat Dec 31 13:20:08 2011	(r34474)
@@ -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 {

Modified: trunk/stream/stream_cdda.c
==============================================================================
--- trunk/stream/stream_cdda.c	Thu Dec 29 20:42:58 2011	(r34473)
+++ trunk/stream/stream_cdda.c	Sat Dec 31 13:20:08 2011	(r34474)
@@ -243,6 +243,11 @@ static int get_track_by_sector(cdda_priv
 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);

Modified: trunk/stream/stream_dvd.c
==============================================================================
--- trunk/stream/stream_dvd.c	Thu Dec 29 20:42:58 2011	(r34473)
+++ trunk/stream/stream_dvd.c	Sat Dec 31 13:20:08 2011	(r34474)
@@ -665,6 +665,11 @@ static int control(stream_t *stream,int 
             *((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;

Modified: trunk/stream/stream_vcd.c
==============================================================================
--- trunk/stream/stream_vcd.c	Thu Dec 29 20:42:58 2011	(r34473)
+++ trunk/stream/stream_vcd.c	Sat Dec 31 13:20:08 2011	(r34474)
@@ -92,6 +92,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);


More information about the MPlayer-cvslog mailing list