]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
Improved subtitiles/OSD quality when the rendering is done by the vout display module.
[vlc] / src / libvlc.c
index 094d2c80a8f74234b4c3458973efc53ef5a992ee..06ebd6b8a7f4cf19f7688424ad93b771f3eb4d0f 100644 (file)
@@ -81,6 +81,7 @@
 #include <vlc_cpu.h>
 #include <vlc_url.h>
 #include <vlc_atomic.h>
+#include <vlc_modules.h>
 
 #include "libvlc.h"
 
@@ -248,7 +249,7 @@ error:
  *  - configuration and commandline parsing
  */
 int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
-                         const char *ppsz_argv[] )
+                         const char *ppsz_argv[], const void **builtins_module )
 {
     libvlc_priv_t *priv = libvlc_priv (p_libvlc);
     char *       p_tmp = NULL;
@@ -311,7 +312,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     }
 
     /* Check for daemon mode */
-#ifndef WIN32
+#if !defined( WIN32 ) && !defined( __SYMBIAN32__ )
     if( var_InheritBool( p_libvlc, "daemon" ) )
     {
 #ifdef HAVE_DAEMON
@@ -386,7 +387,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
      && ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
 # if defined (WIN32) || defined (__APPLE__)
     if( !var_InheritBool( p_libvlc, "ignore-config" ) )
-        config_LoadConfigFile( p_libvlc, "main" );
+        config_LoadConfigFile( p_libvlc );
     priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" );
 
     /* Check if the user specified a custom language */
@@ -409,7 +410,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
      * list of configuration options exported by each module and loads their
      * default values.
      */
-    module_LoadPlugins( p_libvlc );
+    module_LoadPlugins( p_libvlc, builtins_module );
     if( p_libvlc->b_die )
     {
         b_exit = true;
@@ -470,10 +471,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         }
     }
 
-    if( module_count <= 1)
+    if( module_count <= 1 )
     {
-        msg_Err( p_libvlc, "No modules were found, refusing to start. Check "
-                "that you properly gave a module path with --plugin-path.");
+        msg_Err( p_libvlc, "No plugins found! Check your VLC installation.");
         b_exit = true;
         i_ret = VLC_ENOITEM;
     }
@@ -488,7 +488,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
      * Override default configuration with config file settings
      */
     if( !var_InheritBool( p_libvlc, "ignore-config" ) )
-        config_LoadConfigFile( p_libvlc, NULL );
+        config_LoadConfigFile( p_libvlc );
 
     /*
      * Override configuration with command line settings
@@ -563,8 +563,20 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 
                 for( i_input = vlc_optind; i_input < i_argc;i_input++ )
                 {
+                    /* Skip input options, we can't pass them through D-Bus */
+                    if( ppsz_argv[i_input][0] == ':' )
+                    {
+                        msg_Warn( p_libvlc, "Ignoring option %s",
+                                  ppsz_argv[i_input] );
+                        continue;
+                    }
+
+                    /* We need to resolve relative paths in this instance */
+                    char *psz_mrl = make_URI( ppsz_argv[i_input], NULL );
+                    if( psz_mrl == NULL )
+                        continue;
                     msg_Dbg( p_libvlc, "Adds %s to the running Media Player",
-                            ppsz_argv[i_input] );
+                             psz_mrl );
 
                     p_dbus_msg = dbus_message_new_method_call(
                             "org.mpris.vlc", "/TrackList",
@@ -573,6 +585,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
                     if ( NULL == p_dbus_msg )
                     {
                         msg_Err( p_libvlc, "D-Bus problem" );
+                        free( psz_mrl );
                         system_End( p_libvlc );
                         exit( 1 );
                     }
@@ -580,12 +593,14 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
                     /* append MRLs */
                     dbus_message_iter_init_append( p_dbus_msg, &dbus_args );
                     if ( !dbus_message_iter_append_basic( &dbus_args,
-                                DBUS_TYPE_STRING, &ppsz_argv[i_input] ) )
+                                DBUS_TYPE_STRING, &psz_mrl ) )
                     {
                         dbus_message_unref( p_dbus_msg );
+                        free( psz_mrl );
                         system_End( p_libvlc );
                         exit( 1 );
                     }
+                    free( psz_mrl );
                     b_play = TRUE;
                     if( var_InheritBool( p_libvlc, "playlist-enqueue" ) )
                         b_play = FALSE;
@@ -748,7 +763,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     /*
      * Initialize hotkey handling
      */
-    vlc_InitActions( p_libvlc );
+    priv->actions = vlc_InitActions( p_libvlc );
 
     /* Create a variable for showing the fullscreen interface */
     var_Create( p_libvlc, "intf-show", VLC_VAR_BOOL );
@@ -761,6 +776,11 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     var_Create( p_libvlc, "snapshot-file", VLC_VAR_STRING );
     var_Create( p_libvlc, "record-file", VLC_VAR_STRING );
 
+    /* some default internal settings */
+    var_Create( p_libvlc, "window", VLC_VAR_STRING );
+    var_Create( p_libvlc, "user-agent", VLC_VAR_STRING );
+    var_SetString( p_libvlc, "user-agent", "(LibVLC "VERSION")" );
+
     /* Initialize playlist and get commandline files */
     p_playlist = playlist_Create( VLC_OBJECT(p_libvlc) );
     if( !p_playlist )
@@ -779,7 +799,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 
 #if defined(MEDIA_LIBRARY)
     /* Get the ML */
-    if( var_GetBool( p_libvlc, "load-media-library-on-startup" ) == true )
+    if( var_GetBool( p_libvlc, "load-media-library-on-startup" ) )
     {
         priv->p_ml = ml_Create( VLC_OBJECT( p_libvlc ), NULL );
         if( !priv->p_ml )
@@ -911,7 +931,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         if( psz_codecs )
         {
             char *psz_morecodecs;
-            if( asprintf(&psz_morecodecs, "%s,dmo,quicktime", psz_codecs) != -1 )
+            if( asprintf(&psz_morecodecs, "%s,dmo", psz_codecs) != -1 )
             {
                 var_SetString( p_libvlc, "codec", psz_morecodecs);
                 free( psz_morecodecs );
@@ -919,10 +939,11 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
             free( psz_codecs );
         }
         else
-            var_SetString( p_libvlc, "codec", "dmo,quicktime");
+            var_SetString( p_libvlc, "codec", "dmo");
     }
 #endif
 
+#ifdef __APPLE__
     var_Create( p_libvlc, "drawable-view-top", VLC_VAR_INTEGER );
     var_Create( p_libvlc, "drawable-view-left", VLC_VAR_INTEGER );
     var_Create( p_libvlc, "drawable-view-bottom", VLC_VAR_INTEGER );
@@ -931,8 +952,10 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     var_Create( p_libvlc, "drawable-clip-left", VLC_VAR_INTEGER );
     var_Create( p_libvlc, "drawable-clip-bottom", VLC_VAR_INTEGER );
     var_Create( p_libvlc, "drawable-clip-right", VLC_VAR_INTEGER );
+    var_Create( p_libvlc, "drawable-nsobject", VLC_VAR_ADDRESS );
+#endif
 #ifdef WIN32
-    var_Create( p_libvlc, "drawable-hwnd", VLC_VAR_ADDRESS );
+    var_Create( p_libvlc, "drawable-hwnd", VLC_VAR_INTEGER );
 #endif
 
     /*
@@ -986,9 +1009,6 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     }
 #endif
 
-    /* Free playlist now, all threads are gone */
-    playlist_Destroy( p_playlist );
-
 #if defined(MEDIA_LIBRARY)
     media_library_t* p_ml = priv->p_ml;
     if( p_ml )
@@ -999,6 +1019,8 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     }
 #endif
 
+    /* Free playlist now, all threads are gone */
+    playlist_Destroy( p_playlist );
     stats_TimersDumpAll( p_libvlc );
     stats_TimersCleanAll( p_libvlc );
 
@@ -1032,7 +1054,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     /* Free module bank. It is refcounted, so we call this each time  */
     module_EndBank( p_libvlc, true );
 
-    vlc_DeinitActions( p_libvlc );
+    vlc_DeinitActions( p_libvlc, priv->actions );
 }
 
 /**
@@ -1130,9 +1152,8 @@ static void SetLanguage ( const char *psz_lang )
      * the language at runtime under eg. Windows. Beware that this
      * makes the environment unconsistent when libvlc is unloaded and
      * should probably be moved to a safer place like vlc.c. */
-    static char psz_lcall[20];
-    snprintf( psz_lcall, sizeof(psz_lcall), "LC_ALL=%s", psz_lang );
-    putenv( psz_lcall );
+    setenv( "LC_ALL", psz_lang, 1 );
+
 #endif
 
     setlocale( LC_ALL, psz_lang );
@@ -1163,9 +1184,7 @@ static void GetFilenames( libvlc_int_t *p_vlc, unsigned n,
             }
         }
 
-        /* TODO: write an internal function of this one, to avoid
-         *       unnecessary lookups. */
-        char *mrl = make_URI( args[n] );
+        char *mrl = make_URI( args[n], NULL );
         if( !mrl )
             continue;
 
@@ -1251,6 +1270,7 @@ static void Help( libvlc_int_t *p_this, char const *psz_help_name )
 #ifdef WIN32        /* Pause the console because it's destroyed when we exit */
     PauseConsole();
 #endif
+    fflush( stdout );
 }
 
 /*****************************************************************************
@@ -1276,7 +1296,7 @@ print_help_section( const module_t *m, const module_config_t *p_item,
     {
         utf8_fprintf( stdout, RED"   %s:\n"GRAY,
                       module_gettext( m, p_item->psz_text ) );
-        if( b_description && p_item->psz_longtext && *p_item->psz_longtext )
+        if( b_description && p_item->psz_longtext )
             utf8_fprintf( stdout, MAGENTA"   %s\n"GRAY,
                           module_gettext( m, p_item->psz_longtext ) );
     }
@@ -1284,7 +1304,7 @@ print_help_section( const module_t *m, const module_config_t *p_item,
     {
         utf8_fprintf( stdout, "   %s:\n",
                       module_gettext( m, p_item->psz_text ) );
-        if( b_description && p_item->psz_longtext && *p_item->psz_longtext )
+        if( b_description && p_item->psz_longtext )
             utf8_fprintf( stdout, "   %s\n",
                           module_gettext(m, p_item->psz_longtext ) );
     }
@@ -1478,8 +1498,7 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
                         utf8_fprintf( stdout, "\n %s\n",
                                       module_gettext( p_parser, p_item->psz_text ) );
                 }
-                if( b_description && p_item->psz_longtext
-                 && *p_item->psz_longtext )
+                if( b_description && p_item->psz_longtext )
                 {
                     if( b_color )
                         utf8_fprintf( stdout, CYAN " %s\n" GRAY,
@@ -1498,8 +1517,10 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
                 break;
 
             case CONFIG_ITEM_STRING:
-            case CONFIG_ITEM_FILE:
+            case CONFIG_ITEM_LOADFILE:
+            case CONFIG_ITEM_SAVEFILE:
             case CONFIG_ITEM_DIRECTORY:
+            case CONFIG_ITEM_KEY:
             case CONFIG_ITEM_MODULE: /* We could also have "=<" here */
             case CONFIG_ITEM_MODULE_CAT:
             case CONFIG_ITEM_MODULE_LIST:
@@ -1527,7 +1548,6 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
                 }
                 break;
             case CONFIG_ITEM_INTEGER:
-            case CONFIG_ITEM_KEY: /* FIXME: do something a bit more clever */
                 print_help_section( p_parser, p_section, b_color,
                                     b_description );
                 p_section = NULL;
@@ -1537,8 +1557,8 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
 
                 if( p_item->min.i || p_item->max.i )
                 {
-                    sprintf( psz_buffer, "%s [%i .. %i]", psz_type,
-                             p_item->min.i, p_item->max.i );
+                    sprintf( psz_buffer, "%s [%"PRId64" .. %"PRId64"]",
+                             psz_type, p_item->min.i, p_item->max.i );
                     psz_type = psz_buffer;
                 }
 
@@ -1643,6 +1663,7 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
             i_cur_width = b_description && !b_description_hack
                           ? i_width_description
                           : i_width;
+            if( !*psz_text ) strcpy(psz_text, " ");
             while( *psz_text )
             {
                 char *psz_parser, *psz_word;
@@ -1725,8 +1746,7 @@ static void Usage( libvlc_int_t *p_this, char const *psz_search )
                 }
             }
 
-            if( b_description_hack && p_item->psz_longtext
-             && *p_item->psz_longtext )
+            if( b_description_hack && p_item->psz_longtext )
             {
                 sprintf( psz_buffer, "%s%s",
                          module_gettext( p_parser, p_item->psz_longtext ),
@@ -1859,7 +1879,7 @@ static void Version( void )
     ShowConsole( true );
 #endif
 
-    utf8_fprintf( stdout, _("VLC version %s (%s)\n"), VLC_Version(),
+    utf8_fprintf( stdout, _("VLC version %s (%s)\n"), VERSION_MESSAGE,
                   psz_vlc_changeset );
     utf8_fprintf( stdout, _("Compiled by %s on %s (%s)\n"),
              VLC_CompileBy(), VLC_CompileHost(), __DATE__" "__TIME__ );