]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/distort.c
* Stringreview !!!
[vlc] / modules / video_filter / distort.c
index 02c9fdd76ea76882821992a7bb4564347e00068f..ab27a8280e322d9a17927d621a0981bb9c3e8548 100644 (file)
@@ -2,7 +2,7 @@
  * distort.c : Misc video effects plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
- * $Id: distort.c,v 1.8 2003/03/18 23:30:28 gbazin Exp $
+ * $Id: distort.c,v 1.14 2004/01/25 20:05:28 hartman Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -56,17 +56,20 @@ static int  SendEvents   ( vlc_object_t *, char const *,
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-#define MODE_TEXT N_("distort mode")
+#define MODE_TEXT N_("Distort mode")
 #define MODE_LONGTEXT N_("Distort mode, one of \"wave\" and \"ripple\"")
 
-static char *mode_list[] = { "wave", "ripple", NULL };
+static char *mode_list[] = { "wave", "ripple" };
+static char *mode_list_text[] = { N_("Wave"), N_("Ripple") };
 
 vlc_module_begin();
-    add_category_hint( N_("Distort"), NULL, VLC_FALSE );
-    add_string_from_list( "distort-mode", "wave", mode_list, NULL,
-                          MODE_TEXT, MODE_LONGTEXT, VLC_FALSE );
-    set_description( _("miscellaneous video effects module") );
+    set_description( _("Distort video filter") );
     set_capability( "video filter", 0 );
+
+    add_string( "distort-mode", "wave", NULL, MODE_TEXT, MODE_LONGTEXT,
+                VLC_FALSE );
+        change_string_list( mode_list, mode_list_text, 0 );
+
     add_shortcut( "distort" );
     set_callbacks( Create, Destroy );
 vlc_module_end();
@@ -112,53 +115,30 @@ static int Create( vlc_object_t *p_this )
     p_vout->pf_display = NULL;
 
     p_vout->p_sys->i_mode = 0;
-    /* Look what method was requested from command line*/
-    if( !(psz_method = psz_method_tmp = config_GetPsz( p_vout, "filter" )) )
-    {
-        msg_Err( p_vout, "configuration variable %s empty", "filter" );
-        return VLC_EGENERIC;
-    }
-    while( *psz_method && *psz_method != ':' )
-    {
-        psz_method++;
-    }
 
-    if( !strcmp( psz_method, ":wave" ) )
+    if( !(psz_method = psz_method_tmp
+          = config_GetPsz( p_vout, "distort-mode" )) )
     {
+        msg_Err( p_vout, "configuration variable %s empty, using 'wave'",
+                         "distort-mode" );
         p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
     }
-    else if( !strcmp( psz_method, ":ripple" ) )
-    {
-        p_vout->p_sys->i_mode = DISTORT_MODE_RIPPLE;
-    }
-    free( psz_method_tmp );
-    if( !p_vout->p_sys->i_mode )
+    else
     {
-        /* No method given in commandline. Look what method was
-         requested in configuration system */
-        if( !(psz_method = psz_method_tmp
-              = config_GetPsz( p_vout, "distort-mode" )) )
+
+        if( !strcmp( psz_method, "wave" ) )
         {
-            msg_Err( p_vout, "configuration variable %s empty, using 'wave'",
-                             "distort-mode" );
             p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
         }
-        else {
-
-            if( !strcmp( psz_method, "wave" ) )
-            {
-                p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
-            }
-            else if( !strcmp( psz_method, "ripple" ) )
-            {
-                p_vout->p_sys->i_mode = DISTORT_MODE_RIPPLE;
-            }
-            else
-            {
-                msg_Err( p_vout, "no valid distort mode provided, "
-                                 "using wave" );
-                p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
-            }
+        else if( !strcmp( psz_method, "ripple" ) )
+        {
+            p_vout->p_sys->i_mode = DISTORT_MODE_RIPPLE;
+        }
+        else
+        {
+            msg_Err( p_vout, "no valid distort mode provided, "
+                             "using wave" );
+            p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
         }
     }
     free( psz_method_tmp );
@@ -201,6 +181,8 @@ static int Init( vout_thread_t *p_vout )
 
     ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
 
+    ADD_PARENT_CALLBACKS( SendEventsToChild );
+
     p_vout->p_sys->f_angle = 0.0;
     p_vout->p_sys->last_date = 0;
 
@@ -235,6 +217,8 @@ static void Destroy( vlc_object_t *p_this )
     vlc_object_detach( p_vout->p_sys->p_vout );
     vout_Destroy( p_vout->p_sys->p_vout );
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
     free( p_vout->p_sys );
 }
 
@@ -437,3 +421,13 @@ static int SendEvents( vlc_object_t *p_this, char const *psz_var,
     return VLC_SUCCESS;
 }
 
+/*****************************************************************************
+ * SendEventsToChild: forward events to the child/children vout
+ *****************************************************************************/
+static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
+                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+    vout_thread_t *p_vout = (vout_thread_t *)p_this;
+    var_Set( p_vout->p_sys->p_vout, psz_var, newval );
+    return VLC_SUCCESS;
+}