/*****************************************************************************
- * core.c: Core libvlc new API functions : initialization, exceptions handling
+ * core.c: Core libvlc new API functions : initialization
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
* $Id$
#endif
#include "libvlc_internal.h"
+#include <vlc_modules.h>
#include <vlc/libvlc.h>
#include <vlc_interface.h>
static const char nomemstr[] = "Insufficient memory";
-/*************************************************************************
- * Exceptions handling
- *************************************************************************/
-void libvlc_exception_init( libvlc_exception_t *p_exception )
-{
- p_exception->b_raised = 0;
-}
-
-void libvlc_exception_clear( libvlc_exception_t *p_exception )
-{
- if( NULL == p_exception )
- return;
- p_exception->b_raised = 0;
- libvlc_clearerr ();
-}
-
-int libvlc_exception_raised( const libvlc_exception_t *p_exception )
-{
- return (NULL != p_exception) && p_exception->b_raised;
-}
-
-static void libvlc_exception_not_handled( const char *psz )
-{
- fprintf( stderr, "*** LibVLC Exception not handled: %s\nSet a breakpoint in '%s' to debug.\n",
- psz, __func__ );
- abort();
-}
-
-void libvlc_exception_raise( libvlc_exception_t *p_exception )
-{
- /* Does caller care about exceptions ? */
- if( p_exception == NULL ) {
- /* Print something, so that lazy third-parties can easily
- * notice that something may have gone unnoticedly wrong */
- libvlc_exception_not_handled( libvlc_errmsg() );
- return;
- }
-
- p_exception->b_raised = 1;
-}
-
libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
{
libvlc_instance_t *p_new = malloc (sizeof (*p_new));
p_new->verbosity = 1;
p_new->p_callback_list = NULL;
vlc_mutex_init(&p_new->instance_lock);
+ var_Create( p_libvlc_int, "http-user-agent",
+ VLC_VAR_STRING|VLC_VAR_DOINHERIT );
return p_new;
error:
return libvlc_InternalAddIntf( p_i->p_libvlc_int, name ) ? -1 : 0;
}
+void libvlc_set_exit_handler( libvlc_instance_t *p_i, void (*cb) (void *),
+ void *data )
+{
+ libvlc_int_t *p_libvlc = p_i->p_libvlc_int;
+ libvlc_SetExitHandler( p_libvlc, cb, data );
+}
+
void libvlc_wait( libvlc_instance_t *p_i )
{
libvlc_int_t *p_libvlc = p_i->p_libvlc_int;
libvlc_InternalWait( p_libvlc );
}
+void libvlc_set_user_agent (libvlc_instance_t *p_i,
+ const char *name, const char *http)
+{
+ libvlc_int_t *p_libvlc = p_i->p_libvlc_int;
+ char *str;
+
+ var_SetString (p_libvlc, "user-agent", name);
+ if ((http != NULL)
+ && (asprintf (&str, "%s LibVLC/"PACKAGE_VERSION, http) != -1))
+ {
+ var_SetString (p_libvlc, "http-user-agent", str);
+ free (str);
+ }
+}
+
const char * libvlc_get_version(void)
{
- return VLC_Version();
+ return VERSION_MESSAGE;
}
const char * libvlc_get_compiler(void)
{
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" );
+}