[MPlayer-dev-eng] Re: [PACTH] get_byte_pos slave command

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Apr 19 16:53:17 CEST 2006


Hi,
On Wed, Apr 19, 2006 at 12:53:59PM +0200, Alban Bedel wrote:
> On Tue, 18 Apr 2006 23:16:44 +0200
> Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:
> > I think this might be useful, esp. in combination with -sb.
> > Comments?
> 
> Making it a property would make more sense imho.

Like the attached patch?
But a few questions came up:
What are M_PROPERTY_ERROR and M_PROPERTY_OK for? They are not used
anywhere currently...
Does all this property stuff really have to be in mplayer.c??
Am I missing something or is there really no (I really mean nada, zilch)
documentation for this stuff? Not even a simple list of supported
properties?
Shouldn't those property commands also be active in idle mode?

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.930
diff -u -r1.930 mplayer.c
--- mplayer.c	17 Apr 2006 16:31:42 -0000	1.930
+++ mplayer.c	19 Apr 2006 14:47:28 -0000
@@ -1361,6 +1391,30 @@
     return m_property_string_ro(prop,action,arg,(char*)demuxer->desc->name);
 }
 
+static int mp_property_bytepos(m_option_t* prop,int action,void* arg) {
+  if (!demuxer || !demuxer->stream) return M_PROPERTY_UNAVAILABLE;
+  if (!arg) return M_PROPERTY_ERROR;
+  switch (action) {
+    case M_PROPERTY_PRINT: {
+      char **str = (char **)arg;
+      *str = malloc(21);
+      sprintf(*str, "%"PRIu64, stream_tell(demuxer->stream));
+      return M_PROPERTY_OK;
+    }
+    case M_PROPERTY_GET: {
+      off_t *val = (off_t *)arg;
+      *val = stream_tell(demuxer->stream);
+      return M_PROPERTY_OK;
+    }
+    case M_PROPERTY_SET: {
+      off_t *val = (off_t *)arg;
+      stream_seek(demuxer->stream, *val);
+      return M_PROPERTY_OK;
+    }
+  }
+  return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
 static int mp_property_length(m_option_t* prop,int action,void* arg) {
     double len;
     
@@ -1962,6 +2016,7 @@
       0, 0, 0, NULL },
     { "length", mp_property_length, CONF_TYPE_DOUBLE,
       0, 0, 0, NULL },
+    { "bytepos", mp_property_bytepos, CONF_TYPE_POSITION, 0, 0, 0, NULL },
 
     // Audio
     { "volume", mp_property_volume, CONF_TYPE_FLOAT,


More information about the MPlayer-dev-eng mailing list