]> git.sesse.net Git - vlc/blobdiff - src/control/core.c
Correct variable name in libvlc_audio_output_device_set()
[vlc] / src / control / core.c
index 54e2fd03807d322a675318c2d1f3d0e5bc77bcd0..2834af187c5694b0d2d15ffb89481e777b705813 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 #include "libvlc_internal.h"
+#include <vlc_modules.h>
 #include <vlc/libvlc.h>
 
 #include <vlc_interface.h>
@@ -69,6 +70,8 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
     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:
@@ -111,7 +114,20 @@ void libvlc_release( libvlc_instance_t *p_instance )
 
 int libvlc_add_intf( libvlc_instance_t *p_i, const char *name )
 {
-    return libvlc_InternalAddIntf( p_i->p_libvlc_int, name ) ? -1 : 0;
+    if( libvlc_InternalAddIntf( p_i->p_libvlc_int, name ))
+    {
+        if( name )
+        {
+            libvlc_printerr("interface \"%s\" initialization failed",
+                name );
+        }
+        else
+        {
+            libvlc_printerr("default interface initialization failed");
+        }
+        return -1;
+    }
+    return 0;
 }
 
 void libvlc_set_exit_handler( libvlc_instance_t *p_i, void (*cb) (void *),
@@ -127,9 +143,24 @@ void libvlc_wait( libvlc_instance_t *p_i )
     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)
@@ -142,3 +173,87 @@ const char * libvlc_get_changeset(void)
     extern const char psz_vlc_changeset[];
     return psz_vlc_changeset;
 }
+
+void libvlc_free( void *ptr )
+{
+    free( ptr );
+}
+
+static libvlc_module_description_t *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 module_description_list_get( p_instance, "audio filter" );
+}
+
+libvlc_module_description_t *libvlc_video_filter_list_get( libvlc_instance_t *p_instance )
+{
+    return module_description_list_get( p_instance, "video filter2" );
+}
+
+int64_t libvlc_clock(void)
+{
+    return mdate();
+}