]> git.sesse.net Git - vlc/blobdiff - src/control/video.c
Drop option_as_ from marquee interface.
[vlc] / src / control / video.c
index 30a3f46c08b23ddbb3ca126e13cc4375838e4e65..9fe1be5d07e606d467347300f37c4c3b6d8904b5 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * video.c: libvlc new API video functions
  *****************************************************************************
- * Copyright (C) 2005 the VideoLAN team
+ * Copyright (C) 2005-2010 the VideoLAN team
  *
  * $Id$
  *
@@ -112,6 +112,16 @@ void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi,
     vlc_object_release( p_vout );
 }
 
+void libvlc_video_set_key_input( libvlc_media_player_t *p_mi, unsigned on )
+{
+    p_mi->keyboard_events = !!on;
+}
+
+void libvlc_video_set_mouse_input( libvlc_media_player_t *p_mi, unsigned on )
+{
+    p_mi->mouse_events = !!on;
+}
+
 void
 libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, const char *psz_filepath,
         unsigned int i_width, unsigned int i_height, libvlc_exception_t *p_e )
@@ -634,7 +644,7 @@ void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, int b_enable,
         else
         {
             libvlc_exception_raise( p_e );
-            libvlc_printerr( "Bad or unsuported deinterlacing mode" );
+            libvlc_printerr( "Bad or unsupported deinterlacing mode" );
         }
     }
     else
@@ -696,11 +706,10 @@ static vlc_object_t *get_marquee_object( libvlc_media_player_t * p_mi )
 }
 
 /*****************************************************************************
- * libvlc_video_get_marquee_option_as_int : get a marq option value
+ * libvlc_video_get_marquee_int : get a marq option value
  *****************************************************************************/
-int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi,
-                                            libvlc_video_marquee_int_option_t option,
-                                            libvlc_exception_t *p_e )
+int libvlc_video_get_marquee_int( libvlc_media_player_t *p_mi,
+                                  unsigned option, libvlc_exception_t *p_e )
 {
     const char * identifier = get_marquee_int_option_identifier(option);
     if(!identifier)
@@ -711,8 +720,8 @@ int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi,
     }
     vlc_object_t * marquee = get_marquee_object(p_mi);
 
-    /* Handle the libvlc_marquee_Enabled separately */
-    if(option == libvlc_marquee_Enabled)
+    /* Handle the libvlc_marquee_Enable separately */
+    if(option == libvlc_marquee_Enable)
     {
         bool isEnabled = marquee != NULL;
         vlc_object_release(marquee);
@@ -733,11 +742,10 @@ int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi,
 }
 
 /*****************************************************************************
- * libvlc_video_get_marquee_option_as_string : get a marq option value
+ * libvlc_video_get_marquee_string : get a marq option value
  *****************************************************************************/
-char * libvlc_video_get_marquee_option_as_string( libvlc_media_player_t *p_mi,
-                                                  libvlc_video_marquee_string_option_t option,
-                                                  libvlc_exception_t *p_e )
+char * libvlc_video_get_marquee_string( libvlc_media_player_t *p_mi,
+                                    unsigned option, libvlc_exception_t *p_e )
 {
     const char * identifier = get_marquee_string_option_identifier(option);
     if(!identifier)
@@ -760,11 +768,10 @@ char * libvlc_video_get_marquee_option_as_string( libvlc_media_player_t *p_mi,
 }
 
 /*****************************************************************************
- * libvlc_video_set_marquee_option_as_int: enable, disable or set an int option
+ * libvlc_video_set_marquee_int: enable, disable or set an int option
  *****************************************************************************/
-void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi,
-                                          libvlc_video_marquee_int_option_t option,
-                                          int value, libvlc_exception_t *p_e )
+void libvlc_video_set_marquee_int( libvlc_media_player_t *p_mi,
+                         unsigned option, int value, libvlc_exception_t *p_e )
 {
     const char * identifier = get_marquee_int_option_identifier(option);
     if(!identifier)
@@ -774,8 +781,8 @@ void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi,
         return;
     }
 
-    /* Handle the libvlc_marquee_Enabled separately */
-    if(option == libvlc_marquee_Enabled)
+    /* Handle the libvlc_marquee_Enable separately */
+    if(option == libvlc_marquee_Enable)
     {
         libvlc_exception_t e;
         libvlc_exception_init(&e);
@@ -801,12 +808,10 @@ void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi,
 }
 
 /*****************************************************************************
- * libvlc_video_set_marquee_option_as_string: set a string option
+ * libvlc_video_set_marquee_string: set a string option
  *****************************************************************************/
-void libvlc_video_set_marquee_option_as_string( libvlc_media_player_t *p_mi,
-                                             libvlc_video_marquee_string_option_t option,
-                                             const char * value,
-                                             libvlc_exception_t *p_e )
+void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi,
+                unsigned option, const char * value, libvlc_exception_t *p_e )
 {
     const char * identifier = get_marquee_string_option_identifier(option);
     if(!identifier)
@@ -825,3 +830,152 @@ void libvlc_video_set_marquee_option_as_string( libvlc_media_player_t *p_mi,
     var_SetString(marquee, identifier, value);
     vlc_object_release(marquee);
 }
+
+
+/* logo module support */
+
+static vlc_object_t *get_logo_object( libvlc_media_player_t * p_mi,
+                                      libvlc_exception_t *p_e )
+{
+    vlc_object_t *object = NULL;
+    vout_thread_t  *vout = GetVout( p_mi, p_e );
+    libvlc_exception_clear( p_e );
+    if( vout )
+    {
+        object = vlc_object_find_name( vout, "logo", FIND_CHILD );
+        vlc_object_release(vout);
+    }
+    if( !object )
+    {
+        libvlc_exception_raise( p_e );
+        libvlc_printerr( "Logo not enabled" );
+    }
+    return object;
+}
+
+
+typedef const struct vlogo_opt {
+    const char name[16];
+    unsigned type; 
+} vlogo_opt_t;
+
+
+static vlogo_opt_t *
+logo_option_bynumber( unsigned option, libvlc_exception_t *p_e )
+{
+#   define CFG_PREFIX "logo-"
+    vlogo_opt_t vlogo_optlist[] = /* depends on libvlc_video_logo_option_t */
+    {
+        { "logo",          0 },
+        { "logo-file",     VLC_VAR_STRING },
+        { "logo-x",        VLC_VAR_INTEGER },
+        { "logo-y",        VLC_VAR_INTEGER },
+        { "logo-delay",    VLC_VAR_INTEGER },
+        { "logo-repeat",   VLC_VAR_INTEGER },
+        { "logo-opacity",  VLC_VAR_INTEGER },
+        { "logo-position", VLC_VAR_INTEGER },
+    };
+#   undef  CFG_PREFIX
+    enum { num_vlogo_opts = sizeof(vlogo_optlist) / sizeof(*vlogo_optlist) };
+
+    vlogo_opt_t *r = option < num_vlogo_opts ? vlogo_optlist+option : NULL;
+    if( !r )
+    {
+        libvlc_exception_raise( p_e );
+        libvlc_printerr( "Unknown marquee option" );
+    }
+    return r;
+}
+
+
+void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
+                                   unsigned option, const char *psz_value,
+                                   libvlc_exception_t *p_e )
+{
+    vlogo_opt_t *opt = logo_option_bynumber( option, p_e );
+    printf("logo set string  (%u)%s = %s.\n", option,
+            (opt?(opt->name):"<unkn>"),(psz_value?psz_value:"<null>"));
+    if( !opt ) return;
+    vlc_object_t *logo = get_logo_object( p_mi, p_e );
+    if( !logo ) return;
+
+    switch( opt->type )
+    {
+    case VLC_VAR_STRING:
+        var_SetString( logo, opt->name, psz_value );
+        break;
+    default:
+        libvlc_exception_raise( p_e );
+        libvlc_printerr( "Invalid argument" );
+        break;
+    }
+    vlc_object_release(logo);
+}
+
+
+void libvlc_video_set_logo_int( libvlc_media_player_t *p_mi,
+                                unsigned option, int value,
+                                libvlc_exception_t *p_e )
+{
+    vlogo_opt_t *opt = logo_option_bynumber( option, p_e );
+    printf("logo set integer (%u)%s = %i.\n",
+            option, (opt?(opt->name):"<unkn>"),value);
+    if( !opt ) return;
+
+    if( !opt->type ) /* libvlc_logo_enable */
+    {
+        vout_thread_t *vout = GetVout( p_mi, p_e );
+        libvlc_exception_clear( p_e );
+        if (vout)
+        {
+            vout_EnableFilter(vout, opt->name, value, false);
+            vlc_object_release(vout);
+        }
+        return;
+    }
+
+    vlc_object_t *logo = get_logo_object( p_mi, p_e );
+    if( !logo ) return;
+
+    switch( opt->type )
+    {
+    case VLC_VAR_INTEGER:
+        var_SetInteger(logo, opt->name, value);
+        break;
+    default:
+        libvlc_exception_raise( p_e );
+        libvlc_printerr( "Invalid argument" );
+        break;
+    }
+    vlc_object_release(logo);
+}
+
+
+int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi,
+                               unsigned option, libvlc_exception_t *p_e )
+{
+    vlogo_opt_t *opt = logo_option_bynumber( option, p_e );
+    printf("logo get integer (%u)%s.\n", option, opt?opt->name:"<unkn>");
+    if( !opt ) return 0;
+
+    vlc_object_t *logo = get_logo_object( p_mi, p_e );
+    if( !logo ) return 0;
+
+    int ret;
+    switch( opt->type )
+    {
+    case 0: /* libvlc_logo_enable */
+        ret = NULL != logo;
+        break;
+    case VLC_VAR_INTEGER:
+        ret = var_GetInteger(logo, opt->name);
+        break;
+    default:
+        libvlc_exception_raise( p_e );
+        libvlc_printerr( "Invalid argument" );
+        ret = 0;
+        break;
+    }
+    vlc_object_release(logo);
+    return ret;
+}