+ return i_ret;
+}
+
+/******************************************************************************
+ * libvlc_video_set_deinterlace : enable deinterlace
+ *****************************************************************************/
+void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi,
+ const char *psz_mode )
+{
+ if (psz_mode == NULL)
+ psz_mode = "";
+ if (*psz_mode
+ && strcmp (psz_mode, "blend") && strcmp (psz_mode, "bob")
+ && strcmp (psz_mode, "discard") && strcmp (psz_mode, "linear")
+ && strcmp (psz_mode, "mean") && strcmp (psz_mode, "x")
+ && strcmp (psz_mode, "yadif") && strcmp (psz_mode, "yadif2x"))
+ return;
+
+ if (*psz_mode)
+ {
+ var_SetString (p_mi, "deinterlace-mode", psz_mode);
+ var_SetInteger (p_mi, "deinterlace", 1);
+ }
+ else
+ var_SetInteger (p_mi, "deinterlace", 0);
+
+ size_t n;
+ vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
+ for (size_t i = 0; i < n; i++)
+ {
+ vout_thread_t *p_vout = pp_vouts[i];
+
+ if (*psz_mode)
+ {
+ var_SetString (p_vout, "deinterlace-mode", psz_mode);
+ var_SetInteger (p_vout, "deinterlace", 1);
+ }
+ else
+ var_SetInteger (p_vout, "deinterlace", 0);
+ vlc_object_release (p_vout);
+ }
+ free (pp_vouts);
+}
+
+/* ************** */
+/* module helpers */
+/* ************** */
+
+
+static vlc_object_t *get_object( libvlc_media_player_t * p_mi,
+ const char *name, libvlc_exception_t *p_e )
+{
+ vlc_object_t *object = NULL;
+ vout_thread_t *vout = GetVout( p_mi, 0 );
+ libvlc_exception_clear( p_e );
+ if( vout )
+ {
+ object = vlc_object_find_name( vout, name, FIND_CHILD );
+ vlc_object_release(vout);
+ }
+ if( !object )
+ {
+ libvlc_exception_raise( p_e );
+ libvlc_printerr( "%s not enabled", name );
+ }
+ return object;
+}
+
+
+typedef const struct {
+ const char name[20]; /* probably will become a const char * sometime */
+ unsigned type;
+} opt_t;
+
+
+static void
+set_int( libvlc_media_player_t *p_mi, const char *name,
+ const opt_t *opt, int value, libvlc_exception_t *p_e )
+{
+ if( !opt ) return;
+
+ if( !opt->type ) /* the enabler */
+ {
+ vout_thread_t *vout = GetVout( p_mi, 0 );
+ if (vout)
+ {
+ vout_EnableFilter( vout, opt->name, value, false );
+ vlc_object_release( vout );
+ }
+ return;
+ }
+
+ vlc_object_t *object = get_object( p_mi, name, p_e );
+ if( !object ) return;
+
+ switch( opt->type )
+ {
+ case VLC_VAR_INTEGER:
+ var_SetInteger(object, opt->name, value);
+ break;
+ default:
+ libvlc_exception_raise( p_e );
+ libvlc_printerr( "Invalid argument for %s in %s", name, "set int" );
+ break;
+ }
+ vlc_object_release( object );
+}
+
+
+static int
+get_int( libvlc_media_player_t *p_mi, const char *name,
+ const opt_t *opt, libvlc_exception_t *p_e )
+{
+ if( !opt ) return 0;
+
+ vlc_object_t *object = get_object( p_mi, name, p_e );
+ if( !object ) return 0;
+
+ int ret;
+ switch( opt->type )
+ {
+ case 0: /* the enabler */
+ ret = NULL != object;
+ break;
+ case VLC_VAR_INTEGER:
+ ret = var_GetInteger(object, opt->name);
+ break;
+ default:
+ libvlc_exception_raise( p_e );
+ libvlc_printerr( "Invalid argument for %s in %s", name, "get int" );
+ ret = 0;
+ break;
+ }
+ vlc_object_release( object );
+ return ret;
+}
+
+
+static void
+set_string( libvlc_media_player_t *p_mi, const char *name, const opt_t *opt,
+ const char *psz_value, libvlc_exception_t *p_e )
+{
+ if( !opt ) return;
+ vlc_object_t *object = get_object( p_mi, name, p_e );
+ if( !object ) return;
+
+ switch( opt->type )
+ {
+ case VLC_VAR_STRING:
+ var_SetString( object, opt->name, psz_value );
+ break;
+ default:
+ libvlc_exception_raise( p_e );
+ libvlc_printerr( "Invalid argument for %s in %s", name, "set string" );
+ break;
+ }
+ vlc_object_release( object );
+}
+
+
+static char *
+get_string( libvlc_media_player_t *p_mi, const char *name,
+ const opt_t *opt, libvlc_exception_t *p_e )
+{
+ if( !opt ) return NULL;
+ vlc_object_t *object = get_object( p_mi, name, p_e );
+ if( !object ) return NULL;
+
+ char *ret;
+ switch( opt->type )
+ {
+ case VLC_VAR_STRING:
+ ret = var_GetString( object, opt->name );
+ break;
+ default:
+ libvlc_exception_raise( p_e );
+ libvlc_printerr( "Invalid argument for %s in %s", name, "get string" );
+ ret = NULL;
+ break;
+ }
+ vlc_object_release( object );
+ return ret;
+}
+
+
+/*****************************************************************************
+ * Marquee: FIXME: That implementation has no persistent state and requires
+ * a vout
+ *****************************************************************************/
+
+static const opt_t *
+marq_option_bynumber(unsigned option, libvlc_exception_t *p_e)
+{
+ opt_t optlist[] =
+ {
+ { "marq", 0 },
+ { "marq-marquee", VLC_VAR_STRING },
+ { "marq-color", VLC_VAR_INTEGER },
+ { "marq-opacity", VLC_VAR_INTEGER },
+ { "marq-position", VLC_VAR_INTEGER },
+ { "marq-refresh", VLC_VAR_INTEGER },
+ { "marq-size", VLC_VAR_INTEGER },
+ { "marq-timeout", VLC_VAR_INTEGER },
+ { "marq-x", VLC_VAR_INTEGER },
+ { "marq-y", VLC_VAR_INTEGER },
+ };
+ enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
+
+ opt_t *r = option < num_opts ? optlist+option : NULL;
+ if( !r )
+ {
+ libvlc_exception_raise( p_e );
+ libvlc_printerr( "Unknown marquee option" );
+ }
+ return r;
+}
+
+static vlc_object_t *get_object( libvlc_media_player_t *,
+ const char *, libvlc_exception_t *);
+
+/*****************************************************************************
+ * libvlc_video_get_marquee_int : get a marq option value
+ *****************************************************************************/
+int libvlc_video_get_marquee_int( libvlc_media_player_t *p_mi,
+ unsigned option, libvlc_exception_t *p_e )
+{
+ return get_int( p_mi, "marq", marq_option_bynumber(option,p_e), p_e );
+}
+
+/*****************************************************************************
+ * libvlc_video_get_marquee_string : get a marq option value
+ *****************************************************************************/
+char * libvlc_video_get_marquee_string( libvlc_media_player_t *p_mi,
+ unsigned option, libvlc_exception_t *p_e )
+{
+ return get_string( p_mi, "marq", marq_option_bynumber(option,p_e), p_e );
+}
+
+/*****************************************************************************
+ * libvlc_video_set_marquee_int: enable, disable or set an int option
+ *****************************************************************************/
+void libvlc_video_set_marquee_int( libvlc_media_player_t *p_mi,
+ unsigned option, int value, libvlc_exception_t *p_e )
+{
+ set_int( p_mi, "marq", marq_option_bynumber(option,p_e), value, p_e );