- msg_Dbg( p_vlc, "removing announce handler" );
- vlc_object_detach( p_announce );
- vlc_object_release( p_announce );
- announce_HandlerDestroy( p_announce );
- }
-
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * 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 )
-{
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- /*
- * Free allocated memory
- */
- if( p_vlc->p_memcpy_module )
- {
- module_Unneed( p_vlc, p_vlc->p_memcpy_module );
- p_vlc->p_memcpy_module = NULL;
- }
-
- /*
- * Free module bank !
- */
- module_EndBank( p_vlc );
-
- if( p_vlc->psz_homedir )
- {
- free( p_vlc->psz_homedir );
- p_vlc->psz_homedir = NULL;
- }
-
- if( p_vlc->psz_userdir )
- {
- free( p_vlc->psz_userdir );
- p_vlc->psz_userdir = NULL;
- }
-
- if( p_vlc->psz_configfile )
- {
- free( p_vlc->psz_configfile );
- p_vlc->psz_configfile = NULL;
- }
-
- if( p_vlc->p_hotkeys )
- {
- free( p_vlc->p_hotkeys );
- p_vlc->p_hotkeys = NULL;
- }
-
- /*
- * System specific cleaning code
- */
- system_End( p_vlc );
-
- /*
- * Free message queue.
- * Nobody shall use msg_* afterward.
- */
- msg_Flush( p_vlc );
- msg_Destroy( p_libvlc );
-
- /* Destroy global iconv */
- LocaleDeinit();
-
- /* Destroy mutexes */
- vlc_mutex_destroy( &p_vlc->config_lock );
-
- vlc_object_detach( p_vlc );
-
- /* Release object before destroying it */
- if( i_object ) vlc_object_release( p_vlc );
-
- vlc_object_destroy( p_vlc );
-
- /* Stop thread system: last one out please shut the door! */
- vlc_threads_end( p_libvlc );
-
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_VariableSet: set a vlc variable
- *****************************************************************************/
-int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value )
-{
- vlc_t *p_vlc = vlc_current_object( i_object );
- int i_ret;
-
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- /* 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_vlc), psz_newvar );
-
- if( p_item )
- {
- switch( p_item->i_type )
- {
- case CONFIG_ITEM_BOOL:
- config_PutInt( p_vlc, psz_newvar, value.b_bool );
- break;
- case CONFIG_ITEM_INTEGER:
- config_PutInt( p_vlc, psz_newvar, value.i_int );
- break;
- case CONFIG_ITEM_FLOAT:
- config_PutFloat( p_vlc, psz_newvar, value.f_float );
- break;
- default:
- config_PutPsz( p_vlc, psz_newvar, value.psz_string );
- break;
- }
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_SUCCESS;
- }
- }
-
- i_ret = var_Set( p_vlc, psz_var, value );
-
- if( i_object ) vlc_object_release( p_vlc );
- return i_ret;
-}
-
-/*****************************************************************************
- * VLC_VariableGet: get a vlc variable
- *****************************************************************************/
-int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value )
-{
- vlc_t *p_vlc = vlc_current_object( i_object );
- int i_ret;
-
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- i_ret = var_Get( p_vlc , psz_var, p_value );
-
- if( i_object ) vlc_object_release( p_vlc );
- 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;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- /* 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_vlc), 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_vlc , psz_var );
-
- if( i_object ) vlc_object_release( p_vlc );
-
- if( i_type > 0 )
- {
- *pi_type = i_type;
- return VLC_SUCCESS;
- }
- return VLC_ENOVAR;
-}
-
-/*****************************************************************************
- * VLC_AddTarget: adds a target for playing.
- *****************************************************************************
- * This function adds psz_target to the current playlist. If a playlist does
- * not exist, it will create one.
- *****************************************************************************/
-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;
- playlist_t *p_playlist;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-
- if( p_playlist == NULL )
- {
- msg_Dbg( p_vlc, "no playlist present, creating one" );
- p_playlist = playlist_ThreadCreate( p_vlc );
-
- if( p_playlist == NULL )
- {
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_EGENERIC;
- }
-
- vlc_object_yield( p_playlist );
- }
-
- i_err = playlist_PlaylistAddExt( p_playlist, psz_target, psz_target,
- i_mode, i_pos, -1, ppsz_options, i_options);
-
- vlc_object_release( p_playlist );
-
- if( i_object ) vlc_object_release( p_vlc );
- return i_err;
-}
-
-/*****************************************************************************
- * VLC_Play: play the playlist
- *****************************************************************************/
-int VLC_Play( int i_object )
-{
- playlist_t * p_playlist;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
-
- if( !p_playlist )
- {
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_ENOOBJ;
- }
-
- playlist_Play( p_playlist );
- vlc_object_release( p_playlist );
-
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_Pause: toggle pause
- *****************************************************************************/
-int VLC_Pause( int i_object )
-{
- playlist_t * p_playlist;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
-
- if( !p_playlist )
- {
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_ENOOBJ;
- }
-
- playlist_Pause( p_playlist );
- vlc_object_release( p_playlist );
-
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_Stop: stop playback
- *****************************************************************************/
-int VLC_Stop( int i_object )
-{
- playlist_t * p_playlist;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
-
- if( !p_playlist )
- {
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_ENOOBJ;
- }
-
- playlist_Stop( p_playlist );
- vlc_object_release( p_playlist );
-
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_IsPlaying: Query for Playlist Status
- *****************************************************************************/
-vlc_bool_t VLC_IsPlaying( int i_object )
-{
- playlist_t * p_playlist;
- vlc_bool_t b_playing;
-
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
-
- if( !p_playlist )
- {
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_ENOOBJ;
- }
-
- if( p_playlist->p_input )
- {
- vlc_value_t val;
- var_Get( p_playlist->p_input, "state", &val );
- b_playing = ( val.i_int == PLAYING_S );
- }
- else
- {
- b_playing = playlist_IsPlaying( p_playlist );
- }
- vlc_object_release( p_playlist );
-
- if( i_object ) vlc_object_release( p_vlc );
- 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;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_ENOOBJ;
- }
-
- var_Get( p_input, "position", &val );
- vlc_object_release( p_input );
-
- if( i_object ) vlc_object_release( p_vlc );
- 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;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_vlc );
- 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_vlc );
- 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;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_ENOOBJ;
- }
-
- var_Get( p_input, "time", &val );
- vlc_object_release( p_input );
-
- if( i_object ) vlc_object_release( p_vlc );
- 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;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_vlc );
- 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_vlc );
- 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;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_vlc );
- return VLC_ENOOBJ;
- }
-
- var_Get( p_input, "length", &val );
- vlc_object_release( p_input );
-
- if( i_object ) vlc_object_release( p_vlc );
- 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;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_vlc );
- 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_vlc );
- 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;
- vlc_t *p_vlc = vlc_current_object( i_object );
-
- /* Check that the handle is valid */
- if( !p_vlc )
- {
- return VLC_ENOOBJ;
- }
-
- p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
-
- if( !p_input )
- {
- if( i_object ) vlc_object_release( p_vlc );
- 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_vlc );
- 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;
- vlc_t *p_vlc = vlc_current_object( i_object );