]> git.sesse.net Git - vlc/commitdiff
LibVLC Audio/video filters listing API
authorJakub Wieczorek <fawek@fawek.net>
Mon, 20 Dec 2010 08:47:33 +0000 (09:47 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 20 Dec 2010 08:47:33 +0000 (09:47 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
include/vlc/libvlc.h
src/control/core.c
src/libvlc.sym
test/libvlc/core.c

index 9ba48646024b6b75b2e968646956b2370174e296..614c3b0c0c1c012b6ed4296fb1cda7a851bb097a 100644 (file)
@@ -429,6 +429,57 @@ VLC_PUBLIC_API libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterat
                                                                libvlc_log_message_t *p_buffer );
 
 /** @} */
+
+/**
+ * Description of a module.
+ */
+typedef struct libvlc_module_description_t
+{
+    char *psz_name;
+    char *psz_shortname;
+    char *psz_longname;
+    char *psz_help;
+    struct libvlc_module_description_t *p_next;
+} libvlc_module_description_t;
+
+libvlc_module_description_t *libvlc_module_description_list_get( libvlc_instance_t *p_instance, const char *capability );
+
+/**
+ * Release a list of module descriptions.
+ *
+ * \param p_list the list to be released
+ */
+VLC_PUBLIC_API
+void libvlc_module_description_list_release( libvlc_module_description_t *p_list );
+
+/**
+ * Returns a list of audio filters that are available.
+ *
+ * \param p_instance libvlc instance
+ *
+ * \return a list of module descriptions. It should be freed with libvlc_module_description_list_release().
+ *         In case of an error, NULL is returned.
+ *
+ * \see libvlc_module_description_t
+ * \see libvlc_module_description_list_release
+ */
+VLC_PUBLIC_API
+libvlc_module_description_t *libvlc_audio_filter_list_get( libvlc_instance_t *p_instance );
+
+/**
+ * Returns a list of video filters that are available.
+ *
+ * \param p_instance libvlc instance
+ *
+ * \return a list of module descriptions. It should be freed with libvlc_module_description_list_release().
+ *         In case of an error, NULL is returned.
+ *
+ * \see libvlc_module_description_t
+ * \see libvlc_module_description_list_release
+ */
+VLC_PUBLIC_API
+libvlc_module_description_t *libvlc_video_filter_list_get( libvlc_instance_t *p_instance );
+
 /** @} */
 /** @} */
 
index 15e6e72e01ad368014fa3e603ed74ca1c5de2ab5..ee80234fa62dfe6858bb23452f05e1e23e54db15 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 #include "libvlc_internal.h"
+#include <vlc_modules.h>
 #include <vlc/libvlc.h>
 
 #include <vlc_interface.h>
@@ -171,3 +172,76 @@ void libvlc_free( void *ptr )
 {
     free( ptr );
 }
+
+libvlc_module_description_t *libvlc_module_description_list_get( libvlc_instance_t *p_instance, const char *capability )
+{
+    VLC_UNUSED( p_instance );
+    libvlc_module_description_t *p_list = NULL,
+                          *p_actual = NULL,
+                          *p_previous = NULL;
+    module_t **module_list = module_list_get( NULL );
+
+    for (size_t i = 0; module_list[i]; i++)
+    {
+        module_t *p_module = module_list[i];
+
+        if ( !module_provides( p_module, capability ) )
+            continue;
+
+        p_actual = ( libvlc_module_description_t * ) malloc( sizeof( libvlc_module_description_t ) );
+        if ( p_actual == NULL )
+        {
+            libvlc_printerr( "Not enough memory" );
+            libvlc_module_description_list_release( p_list );
+            module_list_free( module_list );
+            return NULL;
+        }
+
+        if ( p_list == NULL )
+            p_list = p_actual;
+
+        const char* name = module_get_object( p_module );
+        const char* shortname = module_get_name( p_module, false );
+        const char* longname = module_get_name( p_module, true );
+        const char* help = module_get_help( p_module );
+        p_actual->psz_name = name ? strdup( name ) : NULL;
+        p_actual->psz_shortname = shortname ? strdup( shortname ) : NULL;
+        p_actual->psz_longname = longname ? strdup( longname ) : NULL;
+        p_actual->psz_help = help ? strdup( help ) : NULL;
+
+        p_actual->p_next = NULL;
+        if ( p_previous )
+            p_previous->p_next = p_actual;
+        p_previous = p_actual;
+    }
+
+    module_list_free( module_list );
+    return p_list;
+}
+
+void libvlc_module_description_list_release( libvlc_module_description_t *p_list )
+{
+    libvlc_module_description_t *p_actual, *p_before;
+    p_actual = p_list;
+
+    while ( p_actual )
+    {
+        free( p_actual->psz_name );
+        free( p_actual->psz_shortname );
+        free( p_actual->psz_longname );
+        free( p_actual->psz_help );
+        p_before = p_actual;
+        p_actual = p_before->p_next;
+        free( p_before );
+    }
+}
+
+libvlc_module_description_t *libvlc_audio_filter_list_get( libvlc_instance_t *p_instance )
+{
+    return libvlc_module_description_list_get( p_instance, "audio filter" );
+}
+
+libvlc_module_description_t *libvlc_video_filter_list_get( libvlc_instance_t *p_instance )
+{
+    return libvlc_module_description_list_get( p_instance, "video filter2" );
+}
index 1a401d159d78fd4d69dfafa1a9fe4d96634fa315..cdd34ff2ea26afc904df62c8febba1a2c37bd8c6 100644 (file)
@@ -233,3 +233,6 @@ libvlc_vlm_show_media
 libvlc_vlm_stop_media
 libvlc_set_exit_handler
 libvlc_wait
+libvlc_audio_filter_list_get
+libvlc_video_filter_list_get
+libvlc_module_description_list_release
index 3871e5e8197e01e052674a9fe025eabb1a9f00b4..85806310b97cb1f88030d62240391cd118b0c5ae 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "test.h"
 
+#include <string.h>
+
 static void test_core (const char ** argv, int argc)
 {
     libvlc_instance_t *vlc;
@@ -37,12 +39,41 @@ static void test_core (const char ** argv, int argc)
     libvlc_release (vlc);
 }
 
+static void test_moduledescriptionlist (libvlc_module_description_t *list)
+{
+    libvlc_module_description_t *module = list;
+    while ( module ) {
+        assert (strlen (module->psz_name) );
+        assert (strlen (module->psz_shortname) );
+        assert (module->psz_longname == NULL || strlen (module->psz_longname));
+        assert (module->psz_help == NULL || strlen (module->psz_help));
+        module = module->p_next;
+    }    
+
+    libvlc_module_description_list_release (list);
+}
+
+static void test_audiovideofilterlists (const char ** argv, int argc)
+{
+    libvlc_instance_t *vlc;
+
+    log ("Testing libvlc_(audio|video)_filter_list_get()\n");
+
+    vlc = libvlc_new (argc, argv);
+    assert (vlc != NULL);
+
+    test_moduledescriptionlist (libvlc_audio_filter_list_get (vlc));
+    test_moduledescriptionlist (libvlc_video_filter_list_get (vlc));
+
+    libvlc_release (vlc);
+}
 
 int main (void)
 {
     test_init();
 
     test_core (test_defaults_args, test_defaults_nargs);
+    test_audiovideofilterlists (test_defaults_args, test_defaults_nargs);
 
     return 0;
 }