[MPlayer-dev-eng] [PATCH] Teletext support try3 (4/5, configure, slaves, etc)

Alban Bedel albeu at free.fr
Sun Jul 15 14:19:13 CEST 2007


On Sun, 15 Jul 2007 17:59:19 +0700
"Vladimir Voroshilov" <voroshil at gmail.com> wrote:

Index: cfg-common.h
===================================================================
--- cfg-common.h	(revision 23784)
+++ cfg-common.h	(working copy)
@@ -460,6 +460,11 @@
 #endif
 	{"adevice", &tv_param_adevice, CONF_TYPE_STRING, 0, 0, 0, NULL},
 #endif
+#ifdef HAVE_TV_TELETEXT
+    {"tdevice", &tv_param_tdevice, CONF_TYPE_STRING, 0, 0, 0, NULL},
+    {"tformat", &tv_param_tformat, CONF_TYPE_STRING, 0, 0, 0, NULL},
+    {"tpage", &tv_param_tpage, CONF_TYPE_INT, CONF_RANGE, 100, 999, NULL},
+#endif
 	{"audioid", &tv_param_audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL},
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };

Wrong indentation.

> +#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)
> +        return M_PROPERTY_UNAVAILABLE;
> +
> +    switch (action) {
> +    case M_PROPERTY_SET:
> +        if (!arg)
> +            return M_PROPERTY_ERROR;
> +        M_PROPERTY_CLAMP(prop, *(int *) arg);
> +        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_SET_PAGE, arg);
> +	break;
> +    case M_PROPERTY_GET:
> +        if (!arg)
> +            return M_PROPERTY_ERROR;
> +        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_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=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_STEP_PAGE, &val);
> +	break;
> +    default:
> +        return M_PROPERTY_NOT_IMPLEMENTED;
> +    }
> +    return (result==TVI_CONTROL_TRUE?M_PROPERTY_OK:M_PROPERTY_ERROR);
> +}
> +/// teletext subpage (RW)
> +static int mp_property_teletext_subpage(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)
> +        return M_PROPERTY_UNAVAILABLE;
> +
> +    switch (action) {
> +    case M_PROPERTY_SET:
> +        if (!arg)
> +            return M_PROPERTY_ERROR;
> +        M_PROPERTY_CLAMP(prop, *(int *) arg);
> +        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_SET_SUBPAGE, arg);
> +	break;
> +    case M_PROPERTY_GET:
> +        if (!arg)
> +            return M_PROPERTY_ERROR;
> +        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_GET_SUBPAGE, 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=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_STEP_SUBPAGE, &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)
> +        return M_PROPERTY_UNAVAILABLE;
> +
> +    switch (action) {
> +    case M_PROPERTY_SET:
> +        if (!arg)
> +            return M_PROPERTY_ERROR;
> +        M_PROPERTY_CLAMP(prop, *(int *) arg);
> +        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_SET_MODE, arg);
> +	break;
> +    case M_PROPERTY_GET:
> +        if (!arg)
> +            return M_PROPERTY_ERROR;
> +        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_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=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_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)
> +        return M_PROPERTY_UNAVAILABLE;
> +
> +    switch (action) {
> +    case M_PROPERTY_GET:
> +        if (!arg)
> +            return M_PROPERTY_ERROR;
> +        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_GET_FORMAT, arg);
> +	break;
> +    case M_PROPERTY_SET:
> +        if (!arg)
> +            return M_PROPERTY_ERROR;
> +        M_PROPERTY_CLAMP(prop, *(int *) arg);
> +        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_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=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_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)
> +        return M_PROPERTY_UNAVAILABLE;
> +
> +    switch (action) {
> +    case M_PROPERTY_GET:
> +        if (!arg)
> +            return M_PROPERTY_ERROR;
> +        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_GET_HALF_PAGE, arg);
> +	break;
> +    case M_PROPERTY_SET:
> +        if (!arg)
> +            return M_PROPERTY_ERROR;
> +        M_PROPERTY_CLAMP(prop, *(int *) arg);
> +        result=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_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=tvh->functions->control(tvh->priv, TV_VBI_CONTROL_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.

That's quiet a bit of code duplication, use a common function instead.
Also having PRINT for the mode, format and half_page properties would
be a nice addition.

> +/**
> +    \ Empty input section function because don't link libinput.a
> +*/
> +void mp_input_set_section(char *name) {
> +    return;
> +}
> +
> +char* mp_input_get_section(void) {
> +    return "default";
> +}
> +

This is awful and won't be needed once these functions are called from
the right place.

	Albeu




More information about the MPlayer-dev-eng mailing list