| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
> |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
#ifdef HAVE_CONFIG_H |
| 36 |
# include "config.h" |
| 37 |
#endif |
| 38 |
|
| 39 |
#include <vlc_common.h> |
| 40 |
#include "../lib/libvlc_internal.h" |
| 41 |
#include <vlc_input.h> |
| 42 |
|
| 43 |
#include "modules/modules.h" |
| 44 |
#include "config/configuration.h" |
| 45 |
#include "playlist/preparser.h" |
| 46 |
|
| 47 |
#include <stdio.h> |
| 48 |
#include <string.h> |
| 49 |
#include <stdlib.h> |
| 50 |
#include <errno.h> |
| 51 |
|
| 52 |
#include "config/vlc_getopt.h" |
| 53 |
|
| 54 |
#ifdef HAVE_DBUS |
| 55 |
|
| 56 |
# include <dbus/dbus.h> |
| 57 |
#endif |
| 58 |
|
| 59 |
|
| 60 |
#include <vlc_playlist.h> |
| 61 |
#include <vlc_interface.h> |
| 62 |
|
| 63 |
#include <vlc_charset.h> |
| 64 |
#include <vlc_dialog.h> |
| 65 |
#include <vlc_keystore.h> |
| 66 |
#include <vlc_fs.h> |
| 67 |
#include <vlc_cpu.h> |
| 68 |
#include <vlc_url.h> |
| 69 |
#include <vlc_modules.h> |
| 70 |
|
| 71 |
#include "libvlc.h" |
| 72 |
#include "playlist/playlist_internal.h" |
| 73 |
#include "misc/variables.h" |
| 74 |
|
| 75 |
#include <vlc_vlm.h> |
| 76 |
|
| 77 |
#ifdef __APPLE__ |
| 78 |
# include <libkern/OSAtomic.h> |
| 79 |
#endif |
| 80 |
|
| 81 |
#include <assert.h> |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
static void GetFilenames ( libvlc_int_t *, unsigned, const char *const [] ); |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
libvlc_int_t * libvlc_InternalCreate( void ) |
| 93 |
{ |
| 94 |
libvlc_int_t *p_libvlc; |
| 95 |
libvlc_priv_t *priv; |
| 96 |
|
| 97 |
|
| 98 |
p_libvlc = vlc_custom_create( (vlc_object_t *)NULL, sizeof (*priv), |
| 99 |
"libvlc" ); |
| 100 |
if( p_libvlc == NULL ) |
| 101 |
return NULL; |
| 102 |
|
| 103 |
priv = libvlc_priv (p_libvlc); |
| 104 |
priv->playlist = NULL; |
| 105 |
priv->p_vlm = NULL; |
| 106 |
|
| 107 |
vlc_ExitInit( &priv->exit ); |
| 108 |
|
| 109 |
return p_libvlc; |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, |
| 121 |
const char *ppsz_argv[] ) |
| 122 |
{ |
| 123 |
libvlc_priv_t *priv = libvlc_priv (p_libvlc); |
| 124 |
char * psz_modules = NULL; |
| 125 |
char * psz_parser = NULL; |
| 126 |
char * psz_control = NULL; |
| 127 |
char *psz_val; |
| 128 |
|
| 129 |
|
| 130 |
system_Init(); |
| 131 |
|
| 132 |
vlc_LogPreinit(p_libvlc); |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
module_InitBank (); |
| 139 |
|
| 140 |
|
| 141 |
if( config_LoadCmdLine( p_libvlc, i_argc, ppsz_argv, NULL ) ) |
| 142 |
{ |
| 143 |
module_EndBank (false); |
| 144 |
return VLC_EGENERIC; |
| 145 |
} |
| 146 |
|
| 147 |
vlc_threads_setup (p_libvlc); |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
size_t module_count = module_LoadPlugins (p_libvlc); |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
if( !var_InheritBool( p_libvlc, "ignore-config" ) ) |
| 159 |
{ |
| 160 |
if( var_InheritBool( p_libvlc, "reset-config" ) ) |
| 161 |
config_SaveConfigFile( p_libvlc ); |
| 162 |
else |
| 163 |
config_LoadConfigFile( p_libvlc ); |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
int vlc_optind; |
| 170 |
if( config_LoadCmdLine( p_libvlc, i_argc, ppsz_argv, &vlc_optind ) ) |
| 171 |
{ |
| 172 |
vlc_LogDeinit (p_libvlc); |
| 173 |
module_EndBank (true); |
| 174 |
return VLC_EGENERIC; |
| 175 |
} |
| 176 |
|
| 177 |
vlc_LogInit(p_libvlc); |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
#if defined( ENABLE_NLS ) \ |
| 183 |
&& ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) ) |
| 184 |
vlc_bindtextdomain (PACKAGE_NAME); |
| 185 |
#endif |
| 186 |
|
| 187 |
msg_Dbg( p_libvlc, "translation test: code is \"%s\"", _("C") ); |
| 188 |
|
| 189 |
if (config_PrintHelp (VLC_OBJECT(p_libvlc))) |
| 190 |
{ |
| 191 |
module_EndBank (true); |
| 192 |
exit(0); |
| 193 |
} |
| 194 |
|
| 195 |
if( module_count <= 1 ) |
| 196 |
{ |
| 197 |
msg_Err( p_libvlc, "No plugins found! Check your VLC installation."); |
| 198 |
vlc_LogDeinit (p_libvlc); |
| 199 |
module_EndBank (true); |
| 200 |
return VLC_ENOMOD; |
| 201 |
} |
| 202 |
|
| 203 |
#ifdef HAVE_DAEMON |
| 204 |
|
| 205 |
if( var_InheritBool( p_libvlc, "daemon" ) ) |
| 206 |
{ |
| 207 |
if( daemon( 1, 0) != 0 ) |
| 208 |
{ |
| 209 |
msg_Err( p_libvlc, "Unable to fork vlc to daemon mode" ); |
| 210 |
vlc_LogDeinit (p_libvlc); |
| 211 |
module_EndBank (true); |
| 212 |
return VLC_ENOMEM; |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
char *pidfile = var_InheritString( p_libvlc, "pidfile" ); |
| 217 |
if( pidfile != NULL ) |
| 218 |
{ |
| 219 |
FILE *stream = vlc_fopen( pidfile, "w" ); |
| 220 |
if( stream != NULL ) |
| 221 |
{ |
| 222 |
fprintf( stream, "%d", (int)getpid() ); |
| 223 |
fclose( stream ); |
| 224 |
msg_Dbg( p_libvlc, "written PID file %s", pidfile ); |
| 225 |
} |
| 226 |
else |
| 227 |
msg_Err( p_libvlc, "cannot write PID file %s: %s", |
| 228 |
pidfile, vlc_strerror_c(errno) ); |
| 229 |
free( pidfile ); |
| 230 |
} |
| 231 |
} |
| 232 |
else |
| 233 |
{ |
| 234 |
var_Create( p_libvlc, "pidfile", VLC_VAR_STRING ); |
| 235 |
var_SetString( p_libvlc, "pidfile", "" ); |
| 236 |
} |
| 237 |
#endif |
| 238 |
|
| 239 |
if( libvlc_InternalDialogInit( p_libvlc ) != VLC_SUCCESS ) |
| 240 |
{ |
| 241 |
vlc_LogDeinit (p_libvlc); |
| 242 |
module_EndBank (true); |
| 243 |
return VLC_ENOMEM; |
| 244 |
} |
| 245 |
if( libvlc_InternalKeystoreInit( p_libvlc ) != VLC_SUCCESS ) |
| 246 |
msg_Warn( p_libvlc, "memory keystore init failed" ); |
| 247 |
|
| 248 |
|
| 249 |
#ifdef HAVE_DBUS |
| 250 |
|
| 251 |
#define MPRIS_APPEND "/org/mpris/MediaPlayer2/TrackList/Append" |
| 252 |
#define MPRIS_BUS_NAME "org.mpris.MediaPlayer2.vlc" |
| 253 |
#define MPRIS_OBJECT_PATH "/org/mpris/MediaPlayer2" |
| 254 |
#define MPRIS_TRACKLIST_INTERFACE "org.mpris.MediaPlayer2.TrackList" |
| 255 |
|
| 256 |
if( var_InheritBool( p_libvlc, "one-instance" ) |
| 257 |
|| ( var_InheritBool( p_libvlc, "one-instance-when-started-from-file" ) |
| 258 |
&& var_InheritBool( p_libvlc, "started-from-file" ) ) ) |
| 259 |
{ |
| 260 |
for( int i = vlc_optind; i < i_argc; i++ ) |
| 261 |
if( ppsz_argv[i][0] == ':' ) |
| 262 |
{ |
| 263 |
msg_Err( p_libvlc, "item option %s incompatible with single instance", |
| 264 |
ppsz_argv[i] ); |
| 265 |
goto dbus_out; |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
dbus_threads_init_default(); |
| 270 |
|
| 271 |
DBusError err; |
| 272 |
dbus_error_init( &err ); |
| 273 |
|
| 274 |
|
| 275 |
DBusConnection *conn = dbus_bus_get( DBUS_BUS_SESSION, &err ); |
| 276 |
if( conn == NULL ) |
| 277 |
{ |
| 278 |
msg_Err( p_libvlc, "Failed to connect to D-Bus session daemon: %s", |
| 279 |
err.message ); |
| 280 |
dbus_error_free( &err ); |
| 281 |
goto dbus_out; |
| 282 |
} |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
if( !dbus_bus_name_has_owner( conn, MPRIS_BUS_NAME, &err ) ) |
| 289 |
{ |
| 290 |
dbus_connection_unref( conn ); |
| 291 |
if( dbus_error_is_set( &err ) ) |
| 292 |
{ |
| 293 |
msg_Err( p_libvlc, "D-Bus error: %s", err.message ); |
| 294 |
} |
| 295 |
else |
| 296 |
msg_Dbg( p_libvlc, "No media player running. Continuing normally." ); |
| 297 |
dbus_error_free( &err ); |
| 298 |
goto dbus_out; |
| 299 |
} |
| 300 |
|
| 301 |
const dbus_bool_t play = !var_InheritBool( p_libvlc, "playlist-enqueue" ); |
| 302 |
|
| 303 |
msg_Warn( p_libvlc, "media player running. Exiting..."); |
| 304 |
for( int i = vlc_optind; i < i_argc; i++ ) |
| 305 |
{ |
| 306 |
DBusMessage *msg = dbus_message_new_method_call( |
| 307 |
MPRIS_BUS_NAME, MPRIS_OBJECT_PATH, MPRIS_TRACKLIST_INTERFACE, "AddTrack" ); |
| 308 |
if( unlikely(msg == NULL) ) |
| 309 |
continue; |
| 310 |
|
| 311 |
|
| 312 |
char *mrl; |
| 313 |
if( strstr( ppsz_argv[i], "://" ) ) |
| 314 |
mrl = strdup( ppsz_argv[i] ); |
| 315 |
else |
| 316 |
mrl = vlc_path2uri( ppsz_argv[i], NULL ); |
| 317 |
if( mrl == NULL ) |
| 318 |
{ |
| 319 |
dbus_message_unref( msg ); |
| 320 |
continue; |
| 321 |
} |
| 322 |
|
| 323 |
const char *after_track = MPRIS_APPEND; |
| 324 |
|
| 325 |
|
| 326 |
if( !dbus_message_append_args( msg, DBUS_TYPE_STRING, &mrl, |
| 327 |
DBUS_TYPE_OBJECT_PATH, &after_track, |
| 328 |
DBUS_TYPE_BOOLEAN, &play, |
| 329 |
DBUS_TYPE_INVALID ) ) |
| 330 |
{ |
| 331 |
dbus_message_unref( msg ); |
| 332 |
msg = NULL; |
| 333 |
free( mrl ); |
| 334 |
continue; |
| 335 |
} |
| 336 |
|
| 337 |
msg_Dbg( p_libvlc, "Adds %s to the running media player", mrl ); |
| 338 |
free( mrl ); |
| 339 |
|
| 340 |
|
| 341 |
DBusMessage *reply = dbus_connection_send_with_reply_and_block( conn, msg, -1, |
| 342 |
&err ); |
| 343 |
dbus_message_unref( msg ); |
| 344 |
if( reply == NULL ) |
| 345 |
{ |
| 346 |
msg_Err( p_libvlc, "D-Bus error: %s", err.message ); |
| 347 |
continue; |
| 348 |
} |
| 349 |
dbus_message_unref( reply ); |
| 350 |
} |
| 351 |
|
| 352 |
dbus_connection_unref( conn ); |
| 353 |
exit( 0 ); |
| 354 |
} |
| 355 |
#undef MPRIS_APPEND |
| 356 |
#undef MPRIS_BUS_NAME |
| 357 |
#undef MPRIS_OBJECT_PATH |
| 358 |
#undef MPRIS_TRACKLIST_INTERFACE |
| 359 |
dbus_out: |
| 360 |
#endif |
| 361 |
|
| 362 |
vlc_CPU_dump( VLC_OBJECT(p_libvlc) ); |
| 363 |
|
| 364 |
priv->b_stats = var_InheritBool( p_libvlc, "stats" ); |
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
priv->actions = vlc_InitActions( p_libvlc ); |
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
priv->parser = playlist_preparser_New(VLC_OBJECT(p_libvlc)); |
| 375 |
|
| 376 |
|
| 377 |
var_Create( p_libvlc, "intf-toggle-fscontrol", VLC_VAR_BOOL ); |
| 378 |
var_SetBool( p_libvlc, "intf-toggle-fscontrol", true ); |
| 379 |
|
| 380 |
|
| 381 |
var_Create( p_libvlc, "intf-boss", VLC_VAR_VOID ); |
| 382 |
|
| 383 |
|
| 384 |
var_Create( p_libvlc, "intf-show", VLC_VAR_BOOL ); |
| 385 |
|
| 386 |
|
| 387 |
var_Create( p_libvlc, "intf-popupmenu", VLC_VAR_BOOL ); |
| 388 |
|
| 389 |
|
| 390 |
var_Create( p_libvlc, "snapshot-file", VLC_VAR_STRING ); |
| 391 |
var_Create( p_libvlc, "record-file", VLC_VAR_STRING ); |
| 392 |
|
| 393 |
|
| 394 |
var_Create( p_libvlc, "window", VLC_VAR_STRING ); |
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
var_Create( p_libvlc, "user-agent", VLC_VAR_STRING ); |
| 400 |
var_SetString( p_libvlc, "user-agent", |
| 401 |
"VLC media player (LibVLC "VERSION")" ); |
| 402 |
var_Create( p_libvlc, "http-user-agent", VLC_VAR_STRING ); |
| 403 |
var_SetString( p_libvlc, "http-user-agent", |
| 404 |
"VLC/"PACKAGE_VERSION" LibVLC/"PACKAGE_VERSION ); |
| 405 |
var_Create( p_libvlc, "app-icon-name", VLC_VAR_STRING ); |
| 406 |
var_SetString( p_libvlc, "app-icon-name", PACKAGE_NAME ); |
| 407 |
var_Create( p_libvlc, "app-id", VLC_VAR_STRING ); |
| 408 |
var_SetString( p_libvlc, "app-id", "org.VideoLAN.VLC" ); |
| 409 |
var_Create( p_libvlc, "app-version", VLC_VAR_STRING ); |
| 410 |
var_SetString( p_libvlc, "app-version", PACKAGE_VERSION ); |
| 411 |
|
| 412 |
|
| 413 |
system_Configure( p_libvlc, i_argc - vlc_optind, ppsz_argv + vlc_optind ); |
| 414 |
|
| 415 |
#ifdef ENABLE_VLM |
| 416 |
|
| 417 |
psz_parser = var_CreateGetNonEmptyString( p_libvlc, "vlm-conf" ); |
| 418 |
if( psz_parser ) |
| 419 |
{ |
| 420 |
priv->p_vlm = vlm_New( p_libvlc ); |
| 421 |
if( !priv->p_vlm ) |
| 422 |
msg_Err( p_libvlc, "VLM initialization failed" ); |
| 423 |
} |
| 424 |
free( psz_parser ); |
| 425 |
#endif |
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
psz_modules = var_CreateGetNonEmptyString( p_libvlc, "extraintf" ); |
| 431 |
psz_control = var_CreateGetNonEmptyString( p_libvlc, "control" ); |
| 432 |
|
| 433 |
if( psz_modules && psz_control ) |
| 434 |
{ |
| 435 |
char* psz_tmp; |
| 436 |
if( asprintf( &psz_tmp, "%s:%s", psz_modules, psz_control ) != -1 ) |
| 437 |
{ |
| 438 |
free( psz_modules ); |
| 439 |
psz_modules = psz_tmp; |
| 440 |
} |
| 441 |
} |
| 442 |
else if( psz_control ) |
| 443 |
{ |
| 444 |
free( psz_modules ); |
| 445 |
psz_modules = strdup( psz_control ); |
| 446 |
} |
| 447 |
|
| 448 |
psz_parser = psz_modules; |
| 449 |
while ( psz_parser && *psz_parser ) |
| 450 |
{ |
| 451 |
char *psz_module, *psz_temp; |
| 452 |
psz_module = psz_parser; |
| 453 |
psz_parser = strchr( psz_module, ':' ); |
| 454 |
if ( psz_parser ) |
| 455 |
{ |
| 456 |
*psz_parser = '\0'; |
| 457 |
psz_parser++; |
| 458 |
} |
| 459 |
if( asprintf( &psz_temp, "%s,none", psz_module ) != -1) |
| 460 |
{ |
| 461 |
libvlc_InternalAddIntf( p_libvlc, psz_temp ); |
| 462 |
free( psz_temp ); |
| 463 |
} |
| 464 |
} |
| 465 |
free( psz_modules ); |
| 466 |
free( psz_control ); |
| 467 |
|
| 468 |
if( var_InheritBool( p_libvlc, "network-synchronisation") ) |
| 469 |
libvlc_InternalAddIntf( p_libvlc, "netsync,none" ); |
| 470 |
|
| 471 |
#ifdef __APPLE__ |
| 472 |
var_Create( p_libvlc, "drawable-view-top", VLC_VAR_INTEGER ); |
| 473 |
var_Create( p_libvlc, "drawable-view-left", VLC_VAR_INTEGER ); |
| 474 |
var_Create( p_libvlc, "drawable-view-bottom", VLC_VAR_INTEGER ); |
| 475 |
var_Create( p_libvlc, "drawable-view-right", VLC_VAR_INTEGER ); |
| 476 |
var_Create( p_libvlc, "drawable-clip-top", VLC_VAR_INTEGER ); |
| 477 |
var_Create( p_libvlc, "drawable-clip-left", VLC_VAR_INTEGER ); |
| 478 |
var_Create( p_libvlc, "drawable-clip-bottom", VLC_VAR_INTEGER ); |
| 479 |
var_Create( p_libvlc, "drawable-clip-right", VLC_VAR_INTEGER ); |
| 480 |
var_Create( p_libvlc, "drawable-nsobject", VLC_VAR_ADDRESS ); |
| 481 |
#endif |
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
GetFilenames( p_libvlc, i_argc - vlc_optind, ppsz_argv + vlc_optind ); |
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
psz_val = var_InheritString( p_libvlc, "open" ); |
| 494 |
if ( psz_val != NULL ) |
| 495 |
{ |
| 496 |
intf_InsertItem( p_libvlc, psz_val, 0, NULL, 0 ); |
| 497 |
free( psz_val ); |
| 498 |
} |
| 499 |
|
| 500 |
return VLC_SUCCESS; |
| 501 |
} |
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
void libvlc_InternalCleanup( libvlc_int_t *p_libvlc ) |
| 508 |
{ |
| 509 |
libvlc_priv_t *priv = libvlc_priv (p_libvlc); |
| 510 |
|
| 511 |
|
| 512 |
msg_Dbg( p_libvlc, "removing all interfaces" ); |
| 513 |
libvlc_Quit( p_libvlc ); |
| 514 |
intf_DestroyAll( p_libvlc ); |
| 515 |
|
| 516 |
libvlc_InternalDialogClean( p_libvlc ); |
| 517 |
libvlc_InternalKeystoreClean( p_libvlc ); |
| 518 |
|
| 519 |
#ifdef ENABLE_VLM |
| 520 |
|
| 521 |
if( priv->p_vlm ) |
| 522 |
{ |
| 523 |
vlm_Delete( priv->p_vlm ); |
| 524 |
} |
| 525 |
#endif |
| 526 |
|
| 527 |
#if !defined( _WIN32 ) && !defined( __OS2__ ) |
| 528 |
char *pidfile = var_InheritString( p_libvlc, "pidfile" ); |
| 529 |
if( pidfile != NULL ) |
| 530 |
{ |
| 531 |
msg_Dbg( p_libvlc, "removing PID file %s", pidfile ); |
| 532 |
if( unlink( pidfile ) ) |
| 533 |
msg_Warn( p_libvlc, "cannot remove PID file %s: %s", |
| 534 |
pidfile, vlc_strerror_c(errno) ); |
| 535 |
free( pidfile ); |
| 536 |
} |
| 537 |
#endif |
| 538 |
|
| 539 |
if (priv->parser != NULL) |
| 540 |
playlist_preparser_Delete(priv->parser); |
| 541 |
|
| 542 |
vlc_DeinitActions( p_libvlc, priv->actions ); |
| 543 |
|
| 544 |
|
| 545 |
if( !var_InheritBool( p_libvlc, "ignore-config" ) ) |
| 546 |
config_AutoSaveConfigFile( VLC_OBJECT(p_libvlc) ); |
| 547 |
|
| 548 |
|
| 549 |
vlc_LogDeinit (p_libvlc); |
| 550 |
module_EndBank (true); |
| 551 |
#if defined(_WIN32) || defined(__OS2__) |
| 552 |
system_End( ); |
| 553 |
#endif |
| 554 |
} |
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
void libvlc_InternalDestroy( libvlc_int_t *p_libvlc ) |
| 564 |
{ |
| 565 |
libvlc_priv_t *priv = libvlc_priv( p_libvlc ); |
| 566 |
|
| 567 |
vlc_ExitDestroy( &priv->exit ); |
| 568 |
|
| 569 |
assert( atomic_load(&(vlc_internals(p_libvlc)->refs)) == 1 ); |
| 570 |
vlc_object_release( p_libvlc ); |
| 571 |
} |
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
static void GetFilenames( libvlc_int_t *p_vlc, unsigned n, |
| 580 |
const char *const args[] ) |
| 581 |
{ |
| 582 |
while( n > 0 ) |
| 583 |
{ |
| 584 |
|
| 585 |
unsigned i_options = 0; |
| 586 |
|
| 587 |
while( args[--n][0] == ':' ) |
| 588 |
{ |
| 589 |
i_options++; |
| 590 |
if( n == 0 ) |
| 591 |
{ |
| 592 |
msg_Warn( p_vlc, "options %s without item", args[n] ); |
| 593 |
return; |
| 594 |
} |
| 595 |
} |
| 596 |
|
| 597 |
char *mrl = NULL; |
| 598 |
if( strstr( args[n], "://" ) == NULL ) |
| 599 |
{ |
| 600 |
mrl = vlc_path2uri( args[n], NULL ); |
| 601 |
if( !mrl ) |
| 602 |
continue; |
| 603 |
} |
| 604 |
|
| 605 |
intf_InsertItem( p_vlc, (mrl != NULL) ? mrl : args[n], i_options, |
| 606 |
( i_options ? &args[n + 1] : NULL ), |
| 607 |
VLC_INPUT_OPTION_TRUSTED ); |
| 608 |
free( mrl ); |
| 609 |
} |
| 610 |
} |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
int libvlc_MetaRequest(libvlc_int_t *libvlc, input_item_t *item, |
| 617 |
input_item_meta_request_option_t i_options) |
| 618 |
{ |
| 619 |
libvlc_priv_t *priv = libvlc_priv(libvlc); |
| 620 |
|
| 621 |
if (unlikely(priv->parser == NULL)) |
| 622 |
return VLC_ENOMEM; |
| 623 |
|
| 624 |
vlc_mutex_lock( &item->lock ); |
| 625 |
if( item->i_preparse_depth == 0 ) |
| 626 |
item->i_preparse_depth = 1; |
| 627 |
if( i_options & META_REQUEST_OPTION_DO_INTERACT ) |
| 628 |
item->b_preparse_interact = true; |
| 629 |
vlc_mutex_unlock( &item->lock ); |
| 630 |
playlist_preparser_Push(priv->parser, item, i_options); |
| 631 |
return VLC_SUCCESS; |
| 632 |
} |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
int libvlc_ArtRequest(libvlc_int_t *libvlc, input_item_t *item, |
| 639 |
input_item_meta_request_option_t i_options) |
| 640 |
{ |
| 641 |
libvlc_priv_t *priv = libvlc_priv(libvlc); |
| 642 |
|
| 643 |
if (unlikely(priv->parser == NULL)) |
| 644 |
return VLC_ENOMEM; |
| 645 |
|
| 646 |
playlist_preparser_fetcher_Push(priv->parser, item, i_options); |
| 647 |
return VLC_SUCCESS; |
| 648 |
} |