[vlc-devel] [vlc-commits] commit: LibVLC Audio/video filters listing API (Jakub Wieczorek )

Pierre d'Herbemont pdherbemont at gmail.com
Tue Dec 21 22:07:11 CET 2010



El 20/12/2010, a las 09:58, git at videolan.org escribió:

> vlc | branch: master | Jakub Wieczorek <fawek at fawek.net> | Mon Dec 20 09:47:33 2010 +0100| [3f808957006315d08f2c05ae2ae64212a1a1f0fd] | committer: Jean-Baptiste Kempf 
> 
> LibVLC Audio/video filters listing API
> 
> Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> 
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3f808957006315d08f2c05ae2ae64212a1a1f0fd
> ---
> 
> include/vlc/libvlc.h |   51 ++++++++++++++++++++++++++++++++++
> src/control/core.c   |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++
> src/libvlc.sym       |    3 ++
> test/libvlc/core.c   |   31 +++++++++++++++++++++
> 4 files changed, 159 insertions(+), 0 deletions(-)
> 
> diff --git a/include/vlc/libvlc.h b/include/vlc/libvlc.h
> index 9ba4864..614c3b0 100644
> --- a/include/vlc/libvlc.h
> +++ b/include/vlc/libvlc.h
> @@ -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;

A linked list? I think we generally (tracks info) use a null terminated table. Could you also drop the Hungarian type prefix in the structure?

> +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 );
> +
> /** @} */
> /** @} */
> 
> diff --git a/src/control/core.c b/src/control/core.c
> index 15e6e72..ee80234 100644
> --- a/src/control/core.c
> +++ b/src/control/core.c
> @@ -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" );
> +}
> diff --git a/src/libvlc.sym b/src/libvlc.sym
> index 1a401d1..cdd34ff 100644
> --- a/src/libvlc.sym
> +++ b/src/libvlc.sym
> @@ -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
> diff --git a/test/libvlc/core.c b/test/libvlc/core.c
> index 3871e5e..8580631 100644
> --- a/test/libvlc/core.c
> +++ b/test/libvlc/core.c
> @@ -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;
> }
> 
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> http://mailman.videolan.org/listinfo/vlc-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20101221/8a600d59/attachment.html>


More information about the vlc-devel mailing list