/*****************************************************************************
* Preamble
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <vlc/vlc.h>
#include "control/libvlc_internal.h"
+#include "libvlc.h"
#include <vlc_playlist.h>
DECLARE_VLC_VERSION( CompileDomain, COMPILE_DOMAIN );
DECLARE_VLC_VERSION( Compiler, COMPILER );
-#ifndef HAVE_SHARED_LIBVLC
extern const char psz_vlc_changeset[];
-char const * VLC_Changeset( void )
+const char* VLC_Changeset( void )
{
return psz_vlc_changeset;
}
-#endif
-
-/*****************************************************************************
- * VLC_Error: strerror() equivalent
- *****************************************************************************
- * This function returns full version string (numeric version and codename).
- *****************************************************************************/
-char const * VLC_Error( int i_err )
-{
- return vlc_error( i_err );
-}
-
-/*****************************************************************************
- * VLC_Create: allocate a libvlc instance and intialize global libvlc stuff if needed
- *****************************************************************************
- * This function allocates a libvlc instance and returns a negative value
- * in case of failure. Also, the thread system is initialized.
- *****************************************************************************/
-int VLC_Create( void )
-{
- libvlc_int_t *p_object = libvlc_InternalCreate();
- if( p_object ) return p_object->i_object_id;
- return VLC_ENOOBJ;
-}
#define LIBVLC_FUNC \
libvlc_int_t * p_libvlc = vlc_current_object( i_object ); \
/*****************************************************************************
- * VLC_Init: initialize a libvlc instance
- *****************************************************************************
- * This function initializes a previously allocated libvlc instance:
- * - CPU detection
- * - gettext initialization
- * - message queue, module bank and playlist initialization
- * - configuration and commandline parsing
- *****************************************************************************/
-int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
-{
- int i_ret;
- LIBVLC_FUNC;
- i_ret = libvlc_InternalInit( p_libvlc, i_argc, ppsz_argv );
- LIBVLC_FUNC_END;
- return i_ret;
-}
-
-/*****************************************************************************
- * 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 )
-{
- int i_ret;
- LIBVLC_FUNC;
- i_ret = libvlc_InternalAddIntf( p_libvlc, psz_module, b_block, b_play,
- 0, NULL );
- LIBVLC_FUNC_END;
- return i_ret;
-}
-
-
-/*****************************************************************************
- * 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;
- vlc_object_kill( p_libvlc );
- LIBVLC_FUNC_END;
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * VLC_CleanUp: CleanUp all the intf, playlist, vout, aout
- *****************************************************************************/
-int VLC_CleanUp( int i_object )
-{
- int i_ret;
- LIBVLC_FUNC;
- i_ret = libvlc_InternalCleanup( p_libvlc );
- LIBVLC_FUNC_END;
- return i_ret;
-}
-
-/*****************************************************************************
- * 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;
- return libvlc_InternalDestroy( p_libvlc, i_object ? VLC_TRUE : VLC_FALSE );
-}
-
-/*****************************************************************************
- * VLC_VariableSet: set a vlc variable
+ * VLC_VariableSet: set a "safe" vlc variable
*****************************************************************************/
int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value )
{
if( p_item )
{
+ /* VLC_VariableSet is only used from the browser plugins, so we
+ * can pretty much assume that the input is _not_ trusted. */
+ if( !p_item->b_safe )
+ return VLC_EGENERIC;
+
switch( p_item->i_type )
{
case CONFIG_ITEM_BOOL:
return VLC_SUCCESS;
}
}
+ /* EXPLICIT HACK (this is the legacy API anyway):
+ * VLC_VariableSet is only used from the browser plugins, so we
+ * can pretty much assume that the input is _not_ trusted. */
+ module_config_t *p_item;
+ p_item = config_FindConfig( VLC_OBJECT(p_libvlc), psz_var );
+ if( !p_item )
+ return VLC_ENOVAR;
+ if( !p_item->b_safe )
+ return VLC_EGENERIC;
i_ret = var_Set( p_libvlc, psz_var, value );
#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 );
+ if( !p_libvlc ) return VLC_ENOOBJ; \
+ playlist_t *p_playlist = pl_Yield( p_libvlc ); \
+ if( !p_playlist ) return VLC_ENOOBJ
#define LIBVLC_PLAYLIST_FUNC_END \
- vlc_object_release( p_libvlc->p_playlist ); \
+ pl_Release( p_libvlc ); \
if( i_object ) vlc_object_release( p_libvlc );
/*****************************************************************************
{
int i_err;
LIBVLC_PLAYLIST_FUNC;
- i_err = playlist_AddExt( p_libvlc->p_playlist, psz_target,
+ i_err = playlist_AddExt( p_playlist, psz_target,
NULL, i_mode, i_pos, -1,
- ppsz_options, i_options, VLC_TRUE, VLC_FALSE );
+ ppsz_options, i_options, true, false );
LIBVLC_PLAYLIST_FUNC_END;
return i_err;
}
int VLC_Play( int i_object )
{
LIBVLC_PLAYLIST_FUNC;
- playlist_Play( p_libvlc->p_playlist );
+ playlist_Play( p_playlist );
LIBVLC_PLAYLIST_FUNC_END;
return VLC_SUCCESS;
}
int VLC_Pause( int i_object )
{
LIBVLC_PLAYLIST_FUNC;
- playlist_Pause( p_libvlc->p_playlist );
+ playlist_Pause( p_playlist );
LIBVLC_PLAYLIST_FUNC_END;
return VLC_SUCCESS;
}
int VLC_Stop( int i_object )
{
LIBVLC_PLAYLIST_FUNC;
- playlist_Stop( p_libvlc->p_playlist );
+ playlist_Stop( p_playlist );
LIBVLC_PLAYLIST_FUNC_END;
return VLC_SUCCESS;
}
/*****************************************************************************
* VLC_IsPlaying: Query for Playlist Status
*****************************************************************************/
-vlc_bool_t VLC_IsPlaying( int i_object )
+bool VLC_IsPlaying( int i_object )
{
- vlc_bool_t b_playing;
+ bool b_playing;
LIBVLC_PLAYLIST_FUNC;
- if( p_libvlc->p_playlist->p_input )
+ if( p_playlist->p_input )
{
vlc_value_t val;
- var_Get( p_libvlc->p_playlist->p_input, "state", &val );
+ var_Get( p_playlist->p_input, "state", &val );
b_playing = ( val.i_int == PLAYING_S );
}
else
{
- b_playing = playlist_IsPlaying( p_libvlc->p_playlist );
+ b_playing = playlist_IsPlaying( p_playlist );
}
LIBVLC_PLAYLIST_FUNC_END;
return b_playing;
* \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 )
+int VLC_TimeSet( int i_object, int i_seconds, bool b_relative )
{
input_thread_t *p_input;
vlc_value_t val;
return VLC_ENOOBJ;
}
- val.b_bool = VLC_TRUE;
+ val.b_bool = true;
var_Set( p_input, "rate-faster", val );
var_Get( p_input, "rate", &val );
vlc_object_release( p_input );
return VLC_ENOOBJ;
}
- val.b_bool = VLC_TRUE;
+ val.b_bool = true;
var_Set( p_input, "rate-slower", val );
var_Get( p_input, "rate", &val );
vlc_object_release( p_input );
{
int i_size;
LIBVLC_PLAYLIST_FUNC;
- i_size = p_libvlc->p_playlist->items.i_size;
+ i_size = p_playlist->items.i_size;
LIBVLC_PLAYLIST_FUNC_END;
return i_size;
}
int VLC_PlaylistNext( int i_object )
{
LIBVLC_PLAYLIST_FUNC;
- playlist_Next( p_libvlc->p_playlist );
+ playlist_Next( p_playlist );
LIBVLC_PLAYLIST_FUNC_END;
return VLC_SUCCESS;
}
int VLC_PlaylistPrev( int i_object )
{
LIBVLC_PLAYLIST_FUNC;
- playlist_Prev( p_libvlc->p_playlist );
+ playlist_Prev( p_playlist );
LIBVLC_PLAYLIST_FUNC_END;
return VLC_SUCCESS;
}
int VLC_PlaylistClear( int i_object )
{
LIBVLC_PLAYLIST_FUNC;
- playlist_Clear( p_libvlc->p_playlist, VLC_TRUE );
+ playlist_Clear( p_playlist, true );
LIBVLC_PLAYLIST_FUNC_END;
return VLC_SUCCESS;
}