- var_Create( p_libvlc, "volume-change", VLC_VAR_BOOL );
-
- /*
- * Get input filenames given as commandline arguments
- */
- GetFilenames( p_libvlc, i_argc, ppsz_argv );
-
- /*
- * Get --open argument
- */
- var_Create( p_libvlc, "open", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
- var_Get( p_libvlc, "open", &val );
- if ( val.psz_string != NULL && *val.psz_string )
- {
- VLC_AddTarget( p_libvlc->i_object_id, val.psz_string, NULL, 0,
- PLAYLIST_INSERT, 0 );
- }
- if ( val.psz_string != NULL ) free( val.psz_string );
-
- LIBVLC_FUNC_END;
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_AddIntf: add an interface
- *****************************************************************************
- * This function opens an interface plugin and runs it. If b_block is set
- * to 0, VLC_AddIntf will return immediately and let the interface run in a
- * separate thread. If b_block is set to 1, VLC_AddIntf will continue until
- * user requests to quit. If b_play is set to 1, VLC_AddIntf will start playing
- * the playlist when it is completely initialised.
- *****************************************************************************/
-int VLC_AddIntf( int i_object, char const *psz_module,
- vlc_bool_t b_block, vlc_bool_t b_play )
-{
- return AddIntfInternal( i_object, psz_module, b_block, b_play, 0, NULL );
-}
-
-
-/*****************************************************************************
- * VLC_Die: ask vlc to die.
- *****************************************************************************
- * This function sets p_vlc->b_die to VLC_TRUE, but does not do any other
- * task. It is your duty to call VLC_CleanUp and VLC_Destroy afterwards.
- *****************************************************************************/
-int VLC_Die( int i_object )
-{
- LIBVLC_FUNC;
- p_libvlc->b_die = VLC_TRUE;
- LIBVLC_FUNC_END;
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_CleanUp: CleanUp all the intf, playlist, vout, aout
- *****************************************************************************/
-int VLC_CleanUp( int i_object )
-{
- intf_thread_t * p_intf;
- playlist_t * p_playlist;
- vout_thread_t * p_vout;
- aout_instance_t * p_aout;
- announce_handler_t * p_announce;
-
- LIBVLC_FUNC;
-
- /* Ask the interfaces to stop and destroy them */
- msg_Dbg( p_libvlc, "removing all interfaces" );
- while( (p_intf = vlc_object_find( p_libvlc, VLC_OBJECT_INTF, FIND_CHILD )) )
- {
- intf_StopThread( p_intf );
- vlc_object_detach( p_intf );
- vlc_object_release( p_intf );
- intf_Destroy( p_intf );
- }
-
- /* Free playlist */
- msg_Dbg( p_libvlc, "removing playlist" );
- playlist_ThreadDestroy( p_libvlc->p_playlist );
-
- /* Free video outputs */
- msg_Dbg( p_libvlc, "removing all video outputs" );
- while( (p_vout = vlc_object_find( p_libvlc, VLC_OBJECT_VOUT, FIND_CHILD )) )
- {
- vlc_object_detach( p_vout );
- vlc_object_release( p_vout );
- vout_Destroy( p_vout );
- }
-
- /* Free audio outputs */
- msg_Dbg( p_libvlc, "removing all audio outputs" );
- while( (p_aout = vlc_object_find( p_libvlc, VLC_OBJECT_AOUT, FIND_CHILD )) )
- {
- vlc_object_detach( (vlc_object_t *)p_aout );
- vlc_object_release( (vlc_object_t *)p_aout );
- aout_Delete( p_aout );
- }
-
- stats_TimersDumpAll( p_libvlc );
- stats_TimersClean( p_libvlc );
-
- /* Free announce handler(s?) */
- while( (p_announce = vlc_object_find( p_libvlc, VLC_OBJECT_ANNOUNCE,
- FIND_CHILD ) ) )
- {
- msg_Dbg( p_libvlc, "removing announce handler" );
- vlc_object_detach( p_announce );
- vlc_object_release( p_announce );
- announce_HandlerDestroy( p_announce );
- }
-
- LIBVLC_FUNC_END;
-}
-
-/*****************************************************************************
- * VLC_Destroy: Destroy everything.
- *****************************************************************************
- * This function requests the running threads to finish, waits for their
- * termination, and destroys their structure.
- *****************************************************************************/
-int VLC_Destroy( int i_object )
-{
- LIBVLC_FUNC;
-
- /* Free allocated memory */
- if( p_libvlc->p_memcpy_module )
- {
- module_Unneed( p_libvlc, p_libvlc->p_memcpy_module );
- p_libvlc->p_memcpy_module = NULL;
- }
-
- /* Free module bank ! */
- module_EndBank( p_libvlc );
-
- FREENULL( p_libvlc->psz_homedir );
- FREENULL( p_libvlc->psz_userdir );
- FREENULL( p_libvlc->psz_configfile );
- FREENULL( p_libvlc->p_hotkeys );
-
- /* System specific cleaning code */
- system_End( p_libvlc );
-
- /*
- * Free message queue.
- * Nobody shall use msg_* afterward.
- */
- msg_Flush( p_libvlc );
- msg_Destroy( p_libvlc_global );
-
- /* Destroy global iconv */
- LocaleDeinit();
-
- /* Destroy mutexes */
- vlc_mutex_destroy( &p_libvlc->config_lock );
-
- vlc_object_detach( p_libvlc );
-
- /* Release object before destroying it */
- if( i_object ) vlc_object_release( p_libvlc );
-
- vlc_object_destroy( p_libvlc );
-
- /* Stop thread system: last one out please shut the door! */
- vlc_threads_end( p_libvlc_global );
-
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_VariableSet: set a vlc variable
- *****************************************************************************/
-int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value )
-{
- int i_ret;
- LIBVLC_FUNC;
-
- /* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
- * we handle it as a configuration variable. Don't tell Gildas :) -- sam */
- if( !strncmp( psz_var, "conf::", 6 ) )
- {
- module_config_t *p_item;
- char const *psz_newvar = psz_var + 6;
-
- p_item = config_FindConfig( VLC_OBJECT(p_libvlc), psz_newvar );
-
- if( p_item )
- {
- switch( p_item->i_type )
- {
- case CONFIG_ITEM_BOOL:
- config_PutInt( p_libvlc, psz_newvar, value.b_bool );
- break;
- case CONFIG_ITEM_INTEGER:
- config_PutInt( p_libvlc, psz_newvar, value.i_int );
- break;
- case CONFIG_ITEM_FLOAT:
- config_PutFloat( p_libvlc, psz_newvar, value.f_float );
- break;
- default:
- config_PutPsz( p_libvlc, psz_newvar, value.psz_string );
- break;
- }
- if( i_object ) vlc_object_release( p_libvlc );
- return VLC_SUCCESS;
- }
- }
-
- i_ret = var_Set( p_libvlc, psz_var, value );
-
- LIBVLC_FUNC_END;
- return i_ret;
-}
-
-/*****************************************************************************
- * VLC_VariableGet: get a vlc variable
- *****************************************************************************/
-int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value )
-{
- int i_ret;
- LIBVLC_FUNC;
- i_ret = var_Get( p_libvlc , psz_var, p_value );
- LIBVLC_FUNC_END;
- return i_ret;
-}
-
-/*****************************************************************************
- * VLC_VariableType: get a vlc variable type
- *****************************************************************************/
-int VLC_VariableType( int i_object, char const *psz_var, int *pi_type )
-{
- int i_type;
- LIBVLC_FUNC;
- /* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
- * we handle it as a configuration variable. Don't tell Gildas :) -- sam */
- if( !strncmp( psz_var, "conf::", 6 ) )
- {
- module_config_t *p_item;
- char const *psz_newvar = psz_var + 6;
-
- p_item = config_FindConfig( VLC_OBJECT(p_libvlc), psz_newvar );
-
- if( p_item )
- {
- switch( p_item->i_type )
- {
- case CONFIG_ITEM_BOOL:
- i_type = VLC_VAR_BOOL;
- break;
- case CONFIG_ITEM_INTEGER:
- i_type = VLC_VAR_INTEGER;
- break;
- case CONFIG_ITEM_FLOAT:
- i_type = VLC_VAR_FLOAT;
- break;
- default:
- i_type = VLC_VAR_STRING;
- break;
- }
- }
- else
- i_type = 0;
- }
- else
- i_type = VLC_VAR_TYPE & var_Type( p_libvlc , psz_var );
-
- LIBVLC_FUNC_END;
-
- if( i_type > 0 )
- {
- *pi_type = i_type;
- return VLC_SUCCESS;
- }
- return VLC_ENOVAR;
-}
-
-#define LIBVLC_PLAYLIST_FUNC \
- libvlc_int_t *p_libvlc = vlc_current_object( i_object );\
- if( !p_libvlc || !p_libvlc->p_playlist ) return VLC_ENOOBJ; \
- vlc_object_yield( p_libvlc->p_playlist );
-
-#define LIBVLC_PLAYLIST_FUNC_END \
- vlc_object_release( p_libvlc->p_playlist ); \
- if( i_object ) vlc_object_release( p_libvlc );
-
-/*****************************************************************************
- * VLC_AddTarget: adds a target for playing.
- *****************************************************************************
- * This function adds psz_target to the playlist
- *****************************************************************************/
-
-int VLC_AddTarget( int i_object, char const *psz_target,
- char const **ppsz_options, int i_options,
- int i_mode, int i_pos )
-{
- int i_err;
- LIBVLC_PLAYLIST_FUNC;
- i_err = playlist_PlaylistAddExt( p_libvlc->p_playlist, psz_target,
- psz_target, i_mode, i_pos, -1,
- ppsz_options, i_options );
- LIBVLC_PLAYLIST_FUNC_END;
- return i_err;
-}
-
-/*****************************************************************************
- * VLC_Play: play the playlist
- *****************************************************************************/
-int VLC_Play( int i_object )
-{
- LIBVLC_PLAYLIST_FUNC;
- playlist_Play( p_libvlc->p_playlist );
- LIBVLC_PLAYLIST_FUNC_END;
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_Pause: toggle pause
- *****************************************************************************/
-int VLC_Pause( int i_object )
-{
- LIBVLC_PLAYLIST_FUNC;
- playlist_Pause( p_libvlc->p_playlist );
- LIBVLC_PLAYLIST_FUNC_END;
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_Stop: stop playback
- *****************************************************************************/
-int VLC_Stop( int i_object )
-{
- LIBVLC_PLAYLIST_FUNC;
- playlist_Stop( p_libvlc->p_playlist );
- LIBVLC_PLAYLIST_FUNC_END;
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_IsPlaying: Query for Playlist Status
- *****************************************************************************/
-vlc_bool_t VLC_IsPlaying( int i_object )
-{
- vlc_bool_t b_playing;
-
- LIBVLC_PLAYLIST_FUNC;
- if( p_libvlc->p_playlist->p_input )
- {
- vlc_value_t val;
- var_Get( p_libvlc->p_playlist->p_input, "state", &val );
- b_playing = ( val.i_int == PLAYING_S );
- }
- else
- {
- b_playing = playlist_IsPlaying( p_libvlc->p_playlist );
- }
- LIBVLC_PLAYLIST_FUNC_END;
- return b_playing;
-}
-
-/**
- * Get the current position in a input
- *
- * Return the current position as a float
- * \note For some inputs, this will be unknown.
- *
- * \param i_object a vlc object id
- * \return a float in the range of 0.0 - 1.0
- */
-float VLC_PositionGet( int i_object )
-{
- input_thread_t *p_input;
- vlc_value_t val;
- libvlc_int_t *p_libvlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_libvlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_libvlc );
- return VLC_ENOOBJ;
- }
-
- var_Get( p_input, "position", &val );
- vlc_object_release( p_input );
-
- if( i_object ) vlc_object_release( p_libvlc );
- return val.f_float;
-}
-
-/**
- * Set the current position in a input
- *
- * Set the current position in a input and then return
- * the current position as a float.
- * \note For some inputs, this will be unknown.
- *
- * \param i_object a vlc object id
- * \param i_position a float in the range of 0.0 - 1.0
- * \return a float in the range of 0.0 - 1.0
- */
-float VLC_PositionSet( int i_object, float i_position )
-{
- input_thread_t *p_input;
- vlc_value_t val;
- libvlc_int_t *p_libvlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_libvlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_libvlc );
- return VLC_ENOOBJ;
- }
-
- val.f_float = i_position;
- var_Set( p_input, "position", val );
- var_Get( p_input, "position", &val );
- vlc_object_release( p_input );
-
- if( i_object ) vlc_object_release( p_libvlc );
- return val.f_float;
-}
-
-/**
- * Get the current position in a input
- *
- * Return the current position in seconds from the start.
- * \note For some inputs, this will be unknown.
- *
- * \param i_object a vlc object id
- * \return the offset from 0:00 in seconds
- */
-int VLC_TimeGet( int i_object )
-{
- input_thread_t *p_input;
- vlc_value_t val;
- libvlc_int_t *p_libvlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_libvlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_libvlc );
- return VLC_ENOOBJ;
- }
-
- var_Get( p_input, "time", &val );
- vlc_object_release( p_input );
-
- if( i_object ) vlc_object_release( p_libvlc );
- return val.i_time / 1000000;
-}
-
-/**
- * Seek to a position in the current input
- *
- * Seek i_seconds in the current input. If b_relative is set,
- * then the seek will be relative to the current position, otherwise
- * it will seek to i_seconds from the beginning of the input.
- * \note For some inputs, this will be unknown.
- *
- * \param i_object a vlc object id
- * \param i_seconds seconds from current position or from beginning of input
- * \param b_relative seek relative from current position
- * \return VLC_SUCCESS on success
- */
-int VLC_TimeSet( int i_object, int i_seconds, vlc_bool_t b_relative )
-{
- input_thread_t *p_input;
- vlc_value_t val;
- libvlc_int_t *p_libvlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_libvlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_libvlc );
- return VLC_ENOOBJ;
- }
-
- if( b_relative )
- {
- val.i_time = i_seconds;
- val.i_time = val.i_time * 1000000L;
- var_Set( p_input, "time-offset", val );
- }
- else
- {
- val.i_time = i_seconds;
- val.i_time = val.i_time * 1000000L;
- var_Set( p_input, "time", val );
- }
- vlc_object_release( p_input );
-
- if( i_object ) vlc_object_release( p_libvlc );
- return VLC_SUCCESS;
-}
-
-/**
- * Get the total length of a input
- *
- * Return the total length in seconds from the current input.
- * \note For some inputs, this will be unknown.
- *
- * \param i_object a vlc object id
- * \return the length in seconds
- */
-int VLC_LengthGet( int i_object )
-{
- input_thread_t *p_input;
- vlc_value_t val;
- libvlc_int_t *p_libvlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_libvlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_libvlc );
- return VLC_ENOOBJ;
- }
-
- var_Get( p_input, "length", &val );
- vlc_object_release( p_input );
-
- if( i_object ) vlc_object_release( p_libvlc );
- return val.i_time / 1000000L;
-}
-
-/**
- * Play the input faster than realtime
- *
- * 2x, 4x, 8x faster than realtime
- * \note For some inputs, this will be impossible.
- *
- * \param i_object a vlc object id
- * \return the current speedrate
- */
-float VLC_SpeedFaster( int i_object )
-{
- input_thread_t *p_input;
- vlc_value_t val;
- libvlc_int_t *p_libvlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_libvlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_libvlc );
- return VLC_ENOOBJ;
- }
-
- val.b_bool = VLC_TRUE;
- var_Set( p_input, "rate-faster", val );
- var_Get( p_input, "rate", &val );
- vlc_object_release( p_input );
-
- if( i_object ) vlc_object_release( p_libvlc );
- return val.f_float / INPUT_RATE_DEFAULT;
-}
-
-/**
- * Play the input slower than realtime
- *
- * 1/2x, 1/4x, 1/8x slower than realtime
- * \note For some inputs, this will be impossible.
- *
- * \param i_object a vlc object id
- * \return the current speedrate
- */
-float VLC_SpeedSlower( int i_object )
-{
- input_thread_t *p_input;
- vlc_value_t val;
- libvlc_int_t *p_libvlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_libvlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_libvlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_libvlc );
- return VLC_ENOOBJ;
- }
-
- val.b_bool = VLC_TRUE;
- var_Set( p_input, "rate-slower", val );
- var_Get( p_input, "rate", &val );
- vlc_object_release( p_input );
-
- if( i_object ) vlc_object_release( p_libvlc );
- return val.f_float / INPUT_RATE_DEFAULT;
-}
-
-/**
- * Return the current playlist item
- *
- * Returns the index of the playlistitem that is currently selected for play.
- * This is valid even if nothing is currently playing.
- *
- * \param i_object a vlc object id
- * \return the current index
- */
-int VLC_PlaylistIndex( int i_object )
-{
- printf( "This function is deprecated and should not be used anymore" );
- return -1;
-}
-
-/**
- * Total amount of items in the playlist
- *
- * \param i_object a vlc object id
- * \return amount of playlist items
- */
-int VLC_PlaylistNumberOfItems( int i_object )
-{
- int i_size;
- playlist_t * p_playlist;
- libvlc_int_t *p_libvlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_libvlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
-
- if( !p_playlist )
- {
- if( i_object ) vlc_object_release( p_libvlc );
- return VLC_ENOOBJ;
- }
-
- i_size = p_playlist->i_size;
- vlc_object_release( p_playlist );
-
- if( i_object ) vlc_object_release( p_libvlc );
- return i_size;
-}
-
-/**
- * Next playlist item
- *
- * Skip to the next playlistitem and play it.
- *
- * \param i_object a vlc object id
- * \return VLC_SUCCESS on success
- */
-int VLC_PlaylistNext( int i_object )
-{
- playlist_t * p_playlist;
- libvlc_int_t *p_libvlc = vlc_current_object( i_object );