diff command.c @ 23900:b5cc28c45d73

Teletext support. Part 2/5: options/slaves/configure/definitions/etc
author voroshil
date Sun, 29 Jul 2007 17:55:28 +0000
parents 8287ef1758cb
children 9e71e0345c35
line wrap: on
line diff
--- a/command.c	Sun Jul 29 17:52:11 2007 +0000
+++ b/command.c	Sun Jul 29 17:55:28 2007 +0000
@@ -1510,6 +1510,89 @@
 
 #endif
 
+#ifdef HAVE_TV_TELETEXT
+static int mp_property_teletext_common(m_option_t * prop, int action, void *arg,
+                  MPContext * mpctx)
+{
+    int val,result;
+    int base_ioctl=(int)prop->priv;
+    /* 
+      for teletext's GET,SET,STEP ioctls this is not 0
+      SET is GET+1
+      STEP is GET+2
+    */
+    tvi_handle_t *tvh = mpctx->demuxer->priv;
+    if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh)
+        return M_PROPERTY_UNAVAILABLE;
+    if(!base_ioctl)
+        return M_PROPERTY_ERROR;
+
+    switch (action) {
+    case M_PROPERTY_GET:
+        if (!arg)
+            return M_PROPERTY_ERROR;
+        result=tvh->functions->control(tvh->priv, base_ioctl, arg);
+        break;
+    case M_PROPERTY_SET:
+        if (!arg)
+            return M_PROPERTY_ERROR;
+        M_PROPERTY_CLAMP(prop, *(int *) arg);
+        result=tvh->functions->control(tvh->priv, base_ioctl+1, arg);
+        break;
+    case M_PROPERTY_STEP_UP:
+    case M_PROPERTY_STEP_DOWN:
+        result=tvh->functions->control(tvh->priv, base_ioctl, &val);
+        val += (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
+        result=tvh->functions->control(tvh->priv, base_ioctl+1, &val);
+        break;
+    default:
+        return M_PROPERTY_NOT_IMPLEMENTED;
+    }
+
+    return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
+}
+
+static int mp_property_teletext_mode(m_option_t * prop, int action, void *arg,
+                  MPContext * mpctx)
+{
+    tvi_handle_t *tvh = mpctx->demuxer->priv;
+    int result;
+    int val;
+
+    //with tvh==NULL will fail too
+    result=mp_property_teletext_common(prop,action,arg,mpctx);
+    if(result!=M_PROPERTY_OK)
+        return result;
+
+    if(tvh->functions->control(tvh->priv, prop->priv, &val)==TVI_CONTROL_TRUE && val)
+        mp_input_set_section("teletext");
+    else
+        mp_input_set_section("tv");
+    return M_PROPERTY_OK;
+}
+
+static int mp_property_teletext_page(m_option_t * prop, int action, void *arg,
+                  MPContext * mpctx)
+{
+    tvi_handle_t *tvh = mpctx->demuxer->priv;
+    int result;
+    int val;
+    switch(action){
+    case M_PROPERTY_STEP_UP:
+    case M_PROPERTY_STEP_DOWN:
+        //This should be handled separately
+        val = (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
+        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_STEP_PAGE, &val);
+        break;
+    default:
+        result=mp_property_teletext_common(prop,action,arg,mpctx);
+    }
+    return result;
+}
+
+
+#endif /* HAVE_TV_TELETEXT */
+
 ///@}
 
 /// All properties available in MPlayer.
@@ -1643,6 +1726,19 @@
      M_OPT_RANGE, -100, 100, (void *) TV_COLOR_HUE },
 #endif
 
+#ifdef HAVE_TV_TELETEXT
+    { "teletext_page", mp_property_teletext_page, CONF_TYPE_INT,
+     M_OPT_RANGE, 100, 899,  (void*)TV_VBI_CONTROL_GET_PAGE },
+    { "teletext_subpage", mp_property_teletext_common, CONF_TYPE_INT,
+     M_OPT_RANGE, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE },
+    { "teletext_mode", mp_property_teletext_mode, CONF_TYPE_FLAG,
+     M_OPT_RANGE, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE },
+    { "teletext_format", mp_property_teletext_common, CONF_TYPE_INT,
+     M_OPT_RANGE, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT },
+    { "teletext_half_page", mp_property_teletext_common, CONF_TYPE_INT,
+     M_OPT_RANGE, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE },
+#endif
+
     { NULL, NULL, NULL, 0, 0, 0, NULL }
 };
 
@@ -2342,6 +2438,15 @@
 	    if (mpctx->file_format == DEMUXER_TYPE_TV)
 		tv_step_chanlist((tvi_handle_t *) (mpctx->demuxer->priv));
 	    break;
+#ifdef HAVE_TV_TELETEXT
+	case MP_CMD_TV_TELETEXT_ADD_DEC:
+	{
+	    tvi_handle_t* tvh=(tvi_handle_t *)(mpctx->demuxer->priv);
+	    if (mpctx->file_format == DEMUXER_TYPE_TV)
+		tvh->functions->control(tvh->priv,TV_VBI_CONTROL_ADD_DEC,&(cmd->args[0].v.s));
+	    break;
+	}
+#endif /* HAVE_TV_TELETEXT */
 #endif				/* USE_TV */
 
 	case MP_CMD_SUB_LOAD: