changeset 31728:25820228c2f1

Add stream_time_pos property. Patch by Paul Huwe [reicow yahoo com] with some modifications by me.
author reimar
date Sun, 25 Jul 2010 09:06:37 +0000
parents 94ba361e1766
children 302e69a83e99
files DOCS/tech/slave.txt command.c
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/tech/slave.txt	Sun Jul 25 08:40:45 2010 +0000
+++ b/DOCS/tech/slave.txt	Sun Jul 25 09:06:37 2010 +0000
@@ -503,6 +503,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)
 chapter            int       0               X   X   X    select chapter
 chapters           int                       X            number of chapters
 angle              int       0               X   X   X    select angle
--- a/command.c	Sun Jul 25 08:40:45 2010 +0000
+++ b/command.c	Sun Jul 25 09:06:37 2010 +0000
@@ -352,6 +352,17 @@
     return M_PROPERTY_NOT_IMPLEMENTED;
 }
 
+/// Current stream position in seconds (RO)
+static int mp_property_stream_time_pos(m_option_t *prop, int action,
+                                       void *arg, MPContext *mpctx)
+{
+    if (!mpctx->demuxer || mpctx->demuxer->stream_pts == MP_NOPTS_VALUE)
+        return M_PROPERTY_UNAVAILABLE;
+
+    return m_property_time_ro(prop, action, arg, mpctx->demuxer->stream_pts);
+}
+
+
 /// Media length in seconds (RO)
 static int mp_property_length(m_option_t *prop, int action, void *arg,
                               MPContext *mpctx)
@@ -2043,6 +2054,8 @@
      M_OPT_MIN, 0, 0, NULL },
     { "stream_length", mp_property_stream_length, CONF_TYPE_POSITION,
      M_OPT_MIN, 0, 0, NULL },
+    { "stream_time_pos", mp_property_stream_time_pos, CONF_TYPE_TIME,
+     M_OPT_MIN, 0, 0, NULL },
     { "length", mp_property_length, CONF_TYPE_TIME,
      M_OPT_MIN, 0, 0, NULL },
     { "percent_pos", mp_property_percent_pos, CONF_TYPE_INT,