]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_intf.c
Filter handling helpers moved to core
[vlc] / src / video_output / vout_intf.c
index d1041be97307560bbfd40a1d1d4998128aea1372..57e15e83490f98fe3b411331b0011b2aae69d753 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+
+#include <vlc/vlc.h>
+
+#include <stdio.h>
 #include <stdlib.h>                                                /* free() */
 #include <sys/types.h>                                          /* opendir() */
 #include <dirent.h>                                             /* opendir() */
 
-#include <vlc/vlc.h>
 #include <vlc/intf.h>
 #include <vlc_block.h>
 
@@ -727,6 +730,59 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
     return VLC_SUCCESS;
 }
 
+/*****************************************************************************
+ * Handle filters
+ *****************************************************************************/
+
+void vout_EnableFilter( vout_thread_t *p_vout, char *psz_name,
+                        vlc_bool_t b_add, vlc_bool_t b_setconfig )
+{
+    char *psz_parser;
+    char *psz_string = config_GetPsz( p_vout, "vout-filter" );
+
+    /* Todo : Use some generic chain manipulation functions */
+    if( !psz_string ) psz_string = strdup("");
+
+    psz_parser = strstr( psz_string, psz_name );
+    if( b_add )
+    {
+        if( !psz_parser )
+        {
+            psz_parser = psz_string;
+            asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
+                            psz_string, psz_name );
+            free( psz_parser );
+        }
+        else
+            return;
+    }
+    else
+    {
+        if( psz_parser )
+        {
+            memmove( psz_parser, psz_parser + strlen(psz_name) +
+                            (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
+                            strlen(psz_parser + strlen(psz_name)) + 1 );
+
+            /* Remove trailing : : */
+            if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
+            {
+                *(psz_string+strlen(psz_string ) -1 ) = '\0';
+            }
+         }
+         else
+         {
+             free( psz_string );
+             return;
+         }
+    }
+    if( b_setconfig )
+        config_PutPsz( p_vout, "vout-filter", psz_string );
+
+    var_SetString( p_vout, "vout-filter", psz_string );
+    free( psz_string );
+}
+
 /*****************************************************************************
  * vout_ControlDefault: default methods for video output control.
  *****************************************************************************/