diff command.c @ 23510:a6c619ee9d30

Teletext support for tv:// (v4l and v4l2 only) modified patch from Otvos Attila oattila at chello dot hu Module uses zvbi library for all low-level VBI operations (like I/O with vbi device, converting vbi pages into usefull vbi_page stuctures, rendering them into RGB32 images). All teletext related stuff (except properties, slave commands and rendering osd in text mode or RGB32 rendered teletext pages in spu mode) is implemented in tvi_vbi.c New properties: teletext_page - switching between pages teletext_mode - switch between on/off/opaque/transparent modes teletext_format - (currently read-only) allows to get format info (black/white,gray,text) teletext_half_page - trivial zooming (displaying top/bottom half of teletext page) New slave commands: teletext_add_dec - user interface for jumping to any page by editing page number interactively teletext_go_link - goes though links, specified on current page
author voroshil
date Sun, 10 Jun 2007 00:06:12 +0000
parents f6055798121d
children ac72a4e46c45
line wrap: on
line diff
--- a/command.c	Sat Jun 09 18:20:21 2007 +0000
+++ b/command.c	Sun Jun 10 00:06:12 2007 +0000
@@ -1415,6 +1415,134 @@
 
 #endif
 
+#ifdef HAVE_TV_TELETEXT
+/// teletext page (RW)
+static int mp_property_teletext_page(m_option_t * prop, int action, void *arg,
+                  MPContext * mpctx)
+{
+    int val,result;
+    tvi_handle_t *tvh = mpctx->demuxer->priv;
+    if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh || !tvh->priv_vbi)
+        return M_PROPERTY_UNAVAILABLE;
+
+    switch (action) {
+    case M_PROPERTY_SET:
+        if (!arg)
+            return M_PROPERTY_ERROR;
+        M_PROPERTY_CLAMP(prop, *(int *) arg);
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_SET_PAGE, arg);
+	break;
+    case M_PROPERTY_GET:
+        if (!arg)
+            return M_PROPERTY_ERROR;
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_GET_PAGE, arg);
+	break;
+    case M_PROPERTY_STEP_UP:
+    case M_PROPERTY_STEP_DOWN:
+        val = (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_STEP_PAGE, &val);
+	break;
+    default:
+        return M_PROPERTY_NOT_IMPLEMENTED;
+    }
+    return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
+}
+/// VBI teletext mode (RW)
+static int mp_property_teletext_mode(m_option_t * prop, int action, void *arg,
+                  MPContext * mpctx)
+{
+    int val,result;
+    tvi_handle_t *tvh = mpctx->demuxer->priv;
+    if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh || !tvh->priv_vbi)
+        return M_PROPERTY_UNAVAILABLE;
+
+    switch (action) {
+    case M_PROPERTY_SET:
+        if (!arg)
+            return M_PROPERTY_ERROR;
+        M_PROPERTY_CLAMP(prop, *(int *) arg);
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_SET_MODE, arg);
+	break;
+    case M_PROPERTY_GET:
+        if (!arg)
+            return M_PROPERTY_ERROR;
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_GET_MODE, arg);
+	break;
+    case M_PROPERTY_STEP_UP:
+    case M_PROPERTY_STEP_DOWN:    
+        val = (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_STEP_MODE, &val);
+	break;
+    default:
+        return M_PROPERTY_NOT_IMPLEMENTED;
+    }
+    return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
+}
+/// VBI teletext format (R)
+static int mp_property_teletext_format(m_option_t * prop, int action, void *arg,
+                  MPContext * mpctx)
+{
+    int val,result;
+    tvi_handle_t *tvh = mpctx->demuxer->priv;
+    if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh || !tvh->priv_vbi)
+        return M_PROPERTY_UNAVAILABLE;
+
+    switch (action) {
+    case M_PROPERTY_GET:
+        if (!arg)
+            return M_PROPERTY_ERROR;
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_GET_FORMAT, arg);
+	break;
+    case M_PROPERTY_SET:
+        if (!arg)
+            return M_PROPERTY_ERROR;
+        M_PROPERTY_CLAMP(prop, *(int *) arg);
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_SET_FORMAT, arg);
+	break;
+    case M_PROPERTY_STEP_UP:
+    case M_PROPERTY_STEP_DOWN:
+        val = (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_STEP_FORMAT, &val);
+	break;
+    default:
+        return M_PROPERTY_NOT_IMPLEMENTED;
+    }
+    return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
+}
+
+/// VBI teletext half-page mode (RW)
+static int mp_property_teletext_half_page(m_option_t * prop, int action, void *arg,
+                  MPContext * mpctx)
+{
+    int val,result;
+    tvi_handle_t *tvh = mpctx->demuxer->priv;
+    if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh || !tvh->priv_vbi)
+        return M_PROPERTY_UNAVAILABLE;
+
+    switch (action) {
+    case M_PROPERTY_GET:
+        if (!arg)
+            return M_PROPERTY_ERROR;
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_GET_HALF_PAGE, arg);
+	break;
+    case M_PROPERTY_SET:
+        if (!arg)
+            return M_PROPERTY_ERROR;
+        M_PROPERTY_CLAMP(prop, *(int *) arg);
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_SET_HALF_PAGE, arg);
+	break;
+    case M_PROPERTY_STEP_UP:
+    case M_PROPERTY_STEP_DOWN:
+        val = (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
+        result=tv_teletext_control(tvh, TVI_CONTROL_VBI_STEP_HALF_PAGE, &val);
+	break;
+    default:
+        return M_PROPERTY_NOT_IMPLEMENTED;
+    }
+    return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
+}
+#endif /* HAVE_TV_TELETEXT */
+
 ///@}
 
 /// All properties available in MPlayer.
@@ -1540,6 +1668,17 @@
      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, -999, 999, NULL },
+    { "teletext_mode", mp_property_teletext_mode, CONF_TYPE_INT,
+     M_OPT_RANGE, 0, 3, NULL },
+    { "teletext_format", mp_property_teletext_format, CONF_TYPE_INT,
+     M_OPT_RANGE, 0, 3, NULL },
+    { "teletext_half_page", mp_property_teletext_half_page, CONF_TYPE_INT,
+     M_OPT_RANGE, 0, 2, NULL },
+#endif
+
     { NULL, NULL, NULL, 0, 0, 0, NULL }
 };
 
@@ -2233,6 +2372,16 @@
 	    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:
+            if (mpctx->file_format == DEMUXER_TYPE_TV)
+                tv_teletext_add_dec((tvi_handle_t *) (mpctx->demuxer->priv),cmd->args[0].v.s);
+            break;
+        case MP_CMD_TV_TELETEXT_GO_LINK:
+            if (mpctx->file_format == DEMUXER_TYPE_TV)
+                tv_teletext_go_link((tvi_handle_t *) (mpctx->demuxer->priv),cmd->args[0].v.i);
+            break;
+#endif /* HAVE_TV_TELETEXT */
 #endif				/* USE_TV */
 
 	case MP_CMD_SUB_LOAD: