changeset 21007:ae51c2fe7310

switch_program property to switch to/set a new program
author nicodvb
date Sat, 18 Nov 2006 14:33:04 +0000
parents deafbd2533df
children b50f601f88e8
files mplayer.c
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mplayer.c	Sat Nov 18 14:32:14 2006 +0000
+++ b/mplayer.c	Sat Nov 18 14:33:04 2006 +0000
@@ -1904,6 +1904,28 @@
     }
 }
 
+static int mp_property_program(m_option_t* prop,int action,void* arg) {
+    demux_program_t prog;
+
+    switch(action) {
+    case M_PROPERTY_STEP_UP:
+    case M_PROPERTY_SET:
+        if(action==M_PROPERTY_SET && arg)
+            prog.progid = *((int*)arg);
+        else
+            prog.progid = -1;
+        if(demux_control(demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM, &prog) == DEMUXER_CTRL_NOTIMPL)
+            return M_PROPERTY_ERROR;
+
+        mp_property_do("switch_audio", M_PROPERTY_SET, &prog.aid);
+        mp_property_do("switch_video", M_PROPERTY_SET, &prog.vid);
+        return M_PROPERTY_OK;
+
+    default:
+        return M_PROPERTY_NOT_IMPLEMENTED;
+    }
+}
+
 ///@}
 
 /// \defgroup VideoProperties Video properties
@@ -2540,6 +2562,8 @@
       0, 0, 0, NULL },
     { "switch_video", mp_property_video, CONF_TYPE_INT,
       -1, -1, 0, NULL },
+    { "switch_program", mp_property_program, CONF_TYPE_INT,
+      CONF_RANGE, -1, 65535, NULL },
 
     // Subs
     { "sub", mp_property_sub, CONF_TYPE_INT,