Commit 3f808957 authored by Jakub Wieczorek's avatar Jakub Wieczorek Committed by Jean-Baptiste Kempf

LibVLC Audio/video filters listing API

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 81758ac0
......@@ -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 );
/** @} */
/** @} */
......
......@@ -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" );
}
......@@ -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
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment