include/os_specific.h \
include/stream_control.h \
include/stream_output.h \
+ include/variables.h \
include/video.h \
include/video_output.h \
include/vlc_common.h \
src/misc/iso-639.def \
src/misc/messages.c \
src/misc/objects.c \
+ src/misc/variables.c \
src/misc/extras.c \
$(SOURCES_libvlc_win32) \
$(SOURCES_libvlc_beos) \
dnl this one is needed until automake knows what to do
LDFLAGS_test3="${LDFLAGS_test3} -lobjc"
PLUGINS="${PLUGINS} ${TESTS}"
- BUILTINS="${BUILTINS} ${TESTS}"
+ #BUILTINS="${BUILTINS} ${TESTS}"
fi
dnl
dnl
dnl Stuff used by the program
dnl
-AC_DEFINE_UNQUOTED(VERSION_MESSAGE, "vlc ${VERSION} ${CODENAME} Copyright 1996-2002 VideoLAN", [Simple version string])
+AC_DEFINE_UNQUOTED(VERSION_MESSAGE, "${VERSION} ${CODENAME}", [Simple version string])
AC_DEFINE_UNQUOTED(COPYRIGHT_MESSAGE, "VideoLAN Client - version ${VERSION} ${CODENAME} - (c) 1996-2002 VideoLAN", [Copyright string])
AC_DEFINE_UNQUOTED(CONFIGURE_LINE, "${CONFIGURE_LINE}", [The ./configure command line])
* interface, such as message output.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: interface.h,v 1.35 2002/10/04 12:01:40 gbazin Exp $
+ * $Id: interface.h,v 1.36 2002/10/11 22:32:55 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
*****************************************************************************/
#define intf_Create(a) __intf_Create(VLC_OBJECT(a))
VLC_EXPORT( intf_thread_t *, __intf_Create, ( vlc_object_t * ) );
-VLC_EXPORT( vlc_error_t, intf_RunThread, ( intf_thread_t * ) );
+VLC_EXPORT( int, intf_RunThread, ( intf_thread_t * ) );
VLC_EXPORT( void, intf_StopThread, ( intf_thread_t * ) );
VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) );
freopen( "CONOUT$", "w", stdout ); \
freopen( "CONOUT$", "w", stderr ); \
freopen( "CONIN$", "r", stdin ); \
- msg_Info( p_intf, VERSION_MESSAGE ); \
+ msg_Info( p_intf, COPYRIGHT_MESSAGE ); \
msg_Info( p_intf, _("\nWarning: if you can't access the GUI " \
"anymore, open a dos command box, go to the " \
"directory where you installed VLC and run " \
* vlc.h: global header for vlc
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: vlc.h,v 1.14 2002/09/29 18:19:53 sam Exp $
+ * $Id: vlc.h,v 1.15 2002/10/11 22:32:56 sam Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*****************************************************************************
* Our custom types
*****************************************************************************/
-typedef struct vlc_t vlc_t;
-typedef struct vlc_list_t vlc_list_t;
-typedef struct vlc_object_t vlc_object_t;
+typedef int vlc_bool_t;
-typedef signed int vlc_error_t;
-typedef int vlc_bool_t;
-typedef int vlc_status_t;
+typedef union
+{
+ int i_int;
+ vlc_bool_t b_bool;
+ float f_float;
+ char * psz_string;
+ void * p_address;
+
+ /* Use this to make sure the structure is at least 64bits */
+ struct { char a, b, c, d, e, f, g, h; } padding;
+
+} vlc_value_t;
/*****************************************************************************
* Error values
#define VLC_ESTATUS -3 /* Invalid status */
#define VLC_ETHREAD -4 /* Could not spawn thread */
#define VLC_EOBJECT -5 /* Object not found */
+#define VLC_EVAR -6 /* Variable not found */
#define VLC_EEXIT -255 /* Program exited */
#define VLC_EGENERIC -666 /* Generic error */
/*****************************************************************************
* Exported libvlc API
*****************************************************************************/
-vlc_status_t vlc_status ( void );
-
-vlc_error_t vlc_create ( void );
-vlc_error_t vlc_init ( int, char *[] );
-vlc_error_t vlc_die ( void );
-vlc_error_t vlc_destroy ( void );
-
-vlc_error_t vlc_set ( const char *, const char * );
-vlc_error_t vlc_add_intf ( const char *, vlc_bool_t );
-vlc_error_t vlc_add_target ( const char *, int, int );
-
-vlc_error_t vlc_play ( );
-vlc_error_t vlc_pause ( );
-vlc_error_t vlc_stop ( void );
-vlc_error_t vlc_fullscreen ( );
-
-/*****************************************************************************
- * Exported libvlc reentrant API
- *****************************************************************************/
-vlc_status_t vlc_status_r ( vlc_t * );
-
-vlc_t * vlc_create_r ( void );
-vlc_error_t vlc_init_r ( vlc_t *, int, char *[] );
-vlc_error_t vlc_die_r ( vlc_t * );
-vlc_error_t vlc_destroy_r ( vlc_t * );
-
-vlc_error_t vlc_set_r ( vlc_t *, const char *, const char * );
-vlc_error_t vlc_add_intf_r ( vlc_t *, const char *, vlc_bool_t );
-vlc_error_t vlc_add_target_r ( vlc_t *, const char *, int, int );
-
-vlc_error_t vlc_play_r ( vlc_t * );
-vlc_error_t vlc_pause_r ( vlc_t * );
-vlc_error_t vlc_stop_r ( vlc_t * );
-vlc_error_t vlc_fullscreen_r ( vlc_t * );
+char * VLC_Version ( void );
+
+int VLC_Create ( void );
+int VLC_Init ( int, int, char *[] );
+int VLC_Die ( int );
+int VLC_Destroy ( int );
+
+int VLC_Set ( int, const char *, vlc_value_t );
+int VLC_Get ( int, const char *, vlc_value_t * );
+int VLC_AddIntf ( int, const char *, vlc_bool_t );
+int VLC_AddTarget ( int, const char *, int, int );
+
+int VLC_Play ( int );
+int VLC_Pause ( int );
+int VLC_Stop ( int );
+int VLC_FullScreen ( int );
# ifdef __cplusplus
}
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: vlc_common.h,v 1.28 2002/10/03 13:21:54 sam Exp $
+ * $Id: vlc_common.h,v 1.29 2002/10/11 22:32:55 sam Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
/* Internal types */
typedef struct libvlc_t libvlc_t;
+typedef struct vlc_t vlc_t;
+typedef struct vlc_list_t vlc_list_t;
+typedef struct vlc_object_t vlc_object_t;
+typedef struct variable_t variable_t;
/* Messages */
typedef struct msg_bank_t msg_bank_t;
vlc_mutex_t object_lock; \
vlc_cond_t object_wait; \
\
+ /* Object properties */ \
volatile vlc_bool_t b_error; /* set by the object */ \
volatile vlc_bool_t b_die; /* set by the outside */ \
volatile vlc_bool_t b_dead; /* set by the object */ \
volatile vlc_bool_t b_attached; /* set by the object */ \
\
+ /* Object variables */ \
+ vlc_mutex_t var_lock; \
+ int i_vars; \
+ variable_t * p_vars; \
+ \
+ /* Stuff related to the libvlc structure */ \
libvlc_t * p_libvlc; /* root of all evil */ \
vlc_t * p_vlc; /* (root of all evil) - 1 */ \
\
/* Just a reminder so that people don't cast garbage */ \
int be_sure_to_add_VLC_COMMON_MEMBERS_to_struct; \
-/* The real vlc_object_t type. Yes, it's that simple :-) */
-struct vlc_object_t
-{
- VLC_COMMON_MEMBERS
-};
-
-/* The object list */
-struct vlc_list_t
-{
- int i_count;
- vlc_object_t ** pp_objects;
-
- /* Private */
- int _i_extra;
- vlc_object_t * _p_first;
-};
-
/* VLC_OBJECT: attempt at doing a clever cast */
#define VLC_OBJECT( x ) \
((vlc_object_t *)(x))+0*(x)->be_sure_to_add_VLC_COMMON_MEMBERS_to_struct
#include "vlc_symbols.h"
#include "os_specific.h"
#include "vlc_messages.h"
+#include "variables.h"
+#include "vlc_objects.h"
#include "vlc_threads_funcs.h"
#include "mtime.h"
#include "modules.h"
#include "main.h"
#include "configuration.h"
-#include "vlc_objects.h"
#if defined( __BORLANDC__ )
# undef PACKAGE
* vlc_objects.h: vlc_object_t definition.
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: vlc_objects.h,v 1.11 2002/10/03 13:21:54 sam Exp $
+ * $Id: vlc_objects.h,v 1.12 2002/10/11 22:32:55 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
#define FIND_STRICT 0x0010
+/*****************************************************************************
+ * The vlc_object_t type. Yes, it's that simple :-)
+ *****************************************************************************/
+struct vlc_object_t
+{
+ VLC_COMMON_MEMBERS
+};
+
+/*****************************************************************************
+ * The vlc_list_t object list type
+ *****************************************************************************/
+struct vlc_list_t
+{
+ int i_count;
+ vlc_object_t ** pp_objects;
+
+ /* Private */
+ int _i_extra;
+ vlc_object_t * _p_first;
+};
+
/*****************************************************************************
* Prototypes
*****************************************************************************/
VLC_EXPORT( void, __vlc_object_destroy, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_object_attach, ( vlc_object_t *, vlc_object_t * ) );
VLC_EXPORT( void, __vlc_object_detach, ( vlc_object_t * ) );
+VLC_EXPORT( void *, __vlc_object_get, ( vlc_object_t *, int ) );
VLC_EXPORT( void *, __vlc_object_find, ( vlc_object_t *, int, int ) );
VLC_EXPORT( void, __vlc_object_yield, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) );
#define vlc_object_attach(a,b) \
__vlc_object_attach( VLC_OBJECT(a), VLC_OBJECT(b) )
+#define vlc_object_get(a,b) \
+ __vlc_object_get( VLC_OBJECT(a),b)
+
#define vlc_object_find(a,b,c) \
__vlc_object_find( VLC_OBJECT(a),b,c)
* rc.c : remote control stdin/stdout plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: rc.c,v 1.7 2002/10/03 17:01:59 gbazin Exp $
+ * $Id: rc.c,v 1.8 2002/10/11 22:32:56 sam Exp $
*
* Authors: Peter Surda <shurdeek@panorama.sth.ac.at>
*
vlc_module_begin();
add_category_hint( N_("Remote control"), NULL );
add_bool( "rc-show-pos", 0, NULL, POS_TEXT, POS_LONGTEXT );
+#ifdef HAVE_ISATTY
add_bool( "fake-tty", 0, NULL, TTY_TEXT, TTY_LONGTEXT );
+#endif
set_description( _("remote control interface module") );
set_capability( "interface", 20 );
set_callbacks( Activate, NULL );
p_input = NULL;
p_playlist = NULL;
+ var_Create( p_intf, "foo", VLC_VAR_STRING );
+ var_Set( p_intf, "foo", (vlc_value_t)"test" );
+
while( !p_intf->b_die )
{
b_complete = 0;
if( b_complete == 1 )
{
char *p_cmd = p_buffer;
- char *p_tmp;
if( !strcmp( p_cmd, "quit" ) )
{
{
vlc_liststructure( p_intf->p_vlc );
}
- else if( !strncmp( p_cmd, "set ", 4 ) )
+ else if( !strncmp( p_cmd, "setfoo ", 7 ) )
{
-// vlc_set_r( p_intf->p_vlc, p_cmd + 4, strstr( p_cmd + 4, " " ) );
- p_tmp = strstr( p_cmd + 4, " " );
- p_tmp[0] = '\0';
- config_PutPsz( p_intf->p_vlc, p_cmd + 4, p_tmp + 1 );
- config_PutInt( p_intf->p_vlc, p_cmd + 4, atoi(p_tmp + 1) );
+ vlc_value_t value;
+ value.psz_string = p_cmd + 7;
+ var_Set( p_intf, "foo", value );
+ }
+ else if( !strncmp( p_cmd, "getfoo", 6 ) )
+ {
+ vlc_value_t value;
+ var_Get( p_intf, "foo", &value );
+ printf( "current value is '%s'\n", value.psz_string );
}
else if( !strncmp( p_cmd, "intf ", 5 ) )
{
break;
}
}
-
- msleep( INTF_IDLE_SLEEP );
}
if( p_input )
vlc_object_release( p_playlist );
p_playlist = NULL;
}
+
+ var_Destroy( p_intf, "foo" );
}
* vlcpeer.cpp: scriptable peer descriptor
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: vlcpeer.cpp,v 1.2 2002/09/30 11:05:41 sam Exp $
+ * $Id: vlcpeer.cpp,v 1.3 2002/10/11 22:32:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
{
if( !p_plugin->b_stream && p_plugin->psz_target )
{
- vlc_add_target_r( p_plugin->p_vlc, p_plugin->psz_target,
- PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+ VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target,
+ PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
p_plugin->b_stream = 1;
}
- vlc_play_r( p_plugin->p_vlc );
+ VLC_Play( p_plugin->i_vlc );
}
return NS_OK;
}
{
if( p_plugin )
{
- vlc_pause_r( p_plugin->p_vlc );
+ VLC_Pause( p_plugin->i_vlc );
}
return NS_OK;
}
{
if( p_plugin )
{
- vlc_stop_r( p_plugin->p_vlc );
+ VLC_Stop( p_plugin->i_vlc );
p_plugin->b_stream = 0;
}
return NS_OK;
{
if( p_plugin )
{
- vlc_fullscreen_r( p_plugin->p_vlc );
+ VLC_FullScreen( p_plugin->i_vlc );
}
return NS_OK;
}
* vlcplugin.h: a VideoLAN plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: vlcplugin.h,v 1.4 2002/09/30 11:05:41 sam Exp $
+ * $Id: vlcplugin.h,v 1.5 2002/10/11 22:32:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
uint32 width, height;
/* vlc data members */
- vlc_t * p_vlc;
+ int i_vlc;
int b_stream;
int b_autoplay;
char * psz_target;
#define PLUGIN_DESCRIPTION \
"VideoLAN Client Multimedia Player Plugin <br>" \
" <br>" \
- /*COPYRIGHT_MESSAGE*/ " <br>" \
+ "version %s <br>" \
"VideoLAN WWW: <a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
#define PLUGIN_MIMETYPES \
* vlcshell.c: a VideoLAN Client plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: vlcshell.cpp,v 1.3 2002/10/03 18:56:09 sam Exp $
+ * $Id: vlcshell.cpp,v 1.4 2002/10/11 22:32:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
/* vlc stuff */
#include <vlc/vlc.h>
-#include "config.h"
/* Mozilla stuff */
#include <npapi.h>
NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
{
static nsIID nsid = VLCINTF_IID;
+ static char psz_desc[1000];
switch( variable )
{
return NPERR_NO_ERROR;
case NPPVpluginDescriptionString:
- *((char **)value) = PLUGIN_DESCRIPTION;
+ snprintf( psz_desc, 1000-1, PLUGIN_DESCRIPTION, VLC_Version() );
+ psz_desc[1000-1] = 0;
+ *((char **)value) = psz_desc;
return NPERR_NO_ERROR;
+
+ default:
+ /* go on... */
+ break;
}
if( instance == NULL )
NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
char* argn[], char* argv[], NPSavedData* saved )
{
+ vlc_value_t value;
int i_ret;
int i;
p_plugin->fWindow = NULL;
p_plugin->window = 0;
- p_plugin->p_vlc = vlc_create_r();
- if( p_plugin->p_vlc == NULL )
+ p_plugin->i_vlc = VLC_Create();
+ if( p_plugin->i_vlc < 0 )
{
+ p_plugin->i_vlc = 0;
delete p_plugin;
p_plugin = NULL;
return NPERR_GENERIC_ERROR;
}
- i_ret = vlc_init_r( p_plugin->p_vlc, sizeof(ppsz_foo)/sizeof(char*), ppsz_foo );
+ i_ret = VLC_Init( p_plugin->i_vlc, sizeof(ppsz_foo)/sizeof(char*), ppsz_foo );
if( i_ret )
{
- vlc_destroy_r( p_plugin->p_vlc );
- p_plugin->p_vlc = NULL;
+ VLC_Destroy( p_plugin->i_vlc );
+ p_plugin->i_vlc = 0;
delete p_plugin;
p_plugin = NULL;
return NPERR_GENERIC_ERROR;
}
- vlc_set_r( p_plugin->p_vlc, "vout", "xvideo,x11,dummy" );
- vlc_set_r( p_plugin->p_vlc, "intf", "dummy" );
+ value.psz_string = "xvideo,x11,dummy";
+ VLC_Set( p_plugin->i_vlc, "conf::vout", value );
+ value.psz_string = "dummy";
+ VLC_Set( p_plugin->i_vlc, "conf::intf", value );
p_plugin->b_stream = 0;
p_plugin->b_autoplay = 0;
{
if( !strcmp( argv[i], "yes" ) )
{
- vlc_set_r( p_plugin->p_vlc, "loop", "1" );
+ value.b_bool = VLC_TRUE;
+ VLC_Set( p_plugin->i_vlc, "conf::loop", value );
}
}
}
if( p_plugin != NULL )
{
- if( p_plugin->p_vlc != NULL )
+ if( p_plugin->i_vlc )
{
- vlc_stop_r( p_plugin->p_vlc );
- vlc_destroy_r( p_plugin->p_vlc );
- p_plugin->p_vlc = NULL;
+ VLC_Stop( p_plugin->i_vlc );
+ VLC_Destroy( p_plugin->i_vlc );
+ p_plugin->i_vlc = 0;
}
if( p_plugin->psz_target )
NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
- char psz_window[32];
+ vlc_value_t value;
if( instance == NULL )
{
VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
/* Write the window ID for vlc */
- sprintf( psz_window, "%li", (long int)window->window );
- vlc_set_r( p_plugin->p_vlc, "x11-drawable", psz_window );
- vlc_set_r( p_plugin->p_vlc, "xvideo-drawable", psz_window );
+ value.p_address = (void*)window->window;
+ VLC_Set( p_plugin->i_vlc, "drawable", value );
/*
* PLUGIN DEVELOPERS:
if( p_plugin->psz_target )
{
- vlc_add_target_r( p_plugin->p_vlc, p_plugin->psz_target,
- i_mode, PLAYLIST_END );
+ VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target,
+ i_mode, PLAYLIST_END );
p_plugin->b_stream = 1;
}
}
VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
fprintf(stderr, "NPP_StreamAsFile\n");
- vlc_add_target_r( p_plugin->p_vlc, fname,
- PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+ VLC_AddTarget( p_plugin->i_vlc, fname,
+ PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
#if 0
* interface, such as command line.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: interface.c,v 1.99 2002/08/29 23:53:22 massiot Exp $
+ * $Id: interface.c,v 1.100 2002/10/11 22:32:56 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
}
/* Initialize structure */
- p_intf->b_menu = 0;
- p_intf->b_menu_change = 0;
+ p_intf->b_menu = VLC_FALSE;
+ p_intf->b_menu_change = VLC_FALSE;
/* Initialize mutexes */
vlc_mutex_init( p_intf, &p_intf->change_lock );
* This function either creates a new thread and runs the interface in it,
* or runs the interface in the current thread, depending on b_block.
*****************************************************************************/
-vlc_error_t intf_RunThread( intf_thread_t *p_intf )
+int intf_RunThread( intf_thread_t *p_intf )
{
if( p_intf->b_block )
{
p_intf->pf_run( p_intf );
- p_intf->b_die = 1;
+ p_intf->b_die = VLC_TRUE;
/* Do not join the thread... intf_StopThread will do it for us */
}
/* Tell the interface to die */
if( !p_intf->b_block )
{
- p_intf->b_die = 1;
+ p_intf->b_die = VLC_TRUE;
}
/* Wait for the thread to exit */
if( p_intf->p_vlc->b_die )
{
- p_intf->b_die = 1;
+ p_intf->b_die = VLC_TRUE;
return;
}
}
* libvlc.c: main libvlc source
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: libvlc.c,v 1.37 2002/10/08 18:10:09 sam Exp $
+ * $Id: libvlc.c,v 1.38 2002/10/11 22:32:56 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
* The evil global variable. We handle it with care, don't worry.
*****************************************************************************/
static libvlc_t libvlc;
-
-//#define GLOBAL_VLC NULL
-#define GLOBAL_VLC ((vlc_t*)libvlc.pp_children[1])
+static vlc_t * p_static_vlc;
/*****************************************************************************
* Local prototypes
#endif
/*****************************************************************************
- * vlc_create: allocate a vlc_t structure, and initialize libvlc if needed.
+ * VLC_Version: return the libvlc version.
*****************************************************************************
- * This function allocates a vlc_t structure and returns NULL in case of
- * failure. Also, the thread system is initialized.
+ * This function returns full version string (numeric version and codename).
*****************************************************************************/
-vlc_error_t vlc_create( void )
+char * VLC_Version( void )
{
- vlc_t * p_vlc;
- vlc_bool_t b_failed = VLC_FALSE;
-
- /* This call should be thread-safe, but an additional check will be
- * necessary afterwards to check that only one p_vlc is created. */
- p_vlc = vlc_create_r();
-
- if( p_vlc == NULL )
- {
- return VLC_EGENERIC;
- }
-
- /* We have created an object, which ensures us that p_global_lock has
- * been properly initialized. We can now atomically check that we are
- * the only p_vlc object. */
-#if 0
- vlc_mutex_lock( libvlc.p_global_lock );
- if( libvlc.i_children != 1 ) /* FIXME !!! FIXME */
- {
- b_failed = VLC_TRUE;
- }
- vlc_mutex_unlock( libvlc.p_global_lock );
-#endif
-
- /* There can be only one */
- if( b_failed )
- {
- vlc_destroy_r( p_vlc );
- return VLC_EGENERIC;
- }
-
- return VLC_SUCCESS;
+ return VERSION_MESSAGE;
}
-vlc_t * vlc_create_r( void )
+/*****************************************************************************
+ * VLC_Create: allocate a vlc_t structure, and initialize libvlc if needed.
+ *****************************************************************************
+ * This function allocates a vlc_t structure and returns a negative value
+ * in case of failure. Also, the thread system is initialized.
+ *****************************************************************************/
+int VLC_Create( void )
{
int i_ret;
vlc_t * p_vlc = NULL;
/* vlc_threads_init *must* be the first internal call! No other call is
* allowed before the thread system has been initialized. */
i_ret = vlc_threads_init( &libvlc );
- if( i_ret )
+ if( i_ret < 0 )
{
- return NULL;
+ return i_ret;
}
/* Now that the thread system is initialized, we don't have much, but
p_vlc = vlc_object_create( &libvlc, VLC_OBJECT_VLC );
if( p_vlc == NULL )
{
- return NULL;
+ return VLC_EGENERIC;
}
p_vlc->psz_object_name = "root";
/* Store our newly allocated structure in the global list */
vlc_object_attach( p_vlc, &libvlc );
+ /* Store data for the non-reentrant API */
+ p_static_vlc = p_vlc;
+
/* Update the handle status */
p_vlc->i_status = VLC_STATUS_CREATED;
- return p_vlc;
+ return p_vlc->i_object_id;
}
/*****************************************************************************
- * vlc_init: initialize a vlc_t structure.
+ * VLC_Init: initialize a vlc_t structure.
*****************************************************************************
* This function initializes a previously allocated vlc_t structure:
* - CPU detection
* - message queue, module bank and playlist initialization
* - configuration and commandline parsing
*****************************************************************************/
-vlc_error_t vlc_init( int i_argc, char *ppsz_argv[] )
-{
- return vlc_init_r( GLOBAL_VLC, i_argc, ppsz_argv );
-}
-
-vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
+int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
{
char p_capabilities[200];
char * p_tmp;
vlc_bool_t b_exit;
+ vlc_t * p_vlc;
module_t *p_help_module;
playlist_t *p_playlist;
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
+
/* Check that the handle is valid */
if( !p_vlc || p_vlc->i_status != VLC_STATUS_CREATED )
{
}
/*****************************************************************************
- * vlc_add_intf: add an interface
+ * VLC_AddIntf: add an interface
*****************************************************************************
* This function opens an interface plugin and runs it. If b_block is set
- * to 0, vlc_add_intf will return immediately and let the interface run in a
- * separate thread. If b_block is set to 1, vlc_add_intf will continue until
+ * 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.
*****************************************************************************/
-vlc_error_t vlc_add_intf( const char *psz_module, vlc_bool_t b_block )
-{
- return vlc_add_intf_r( GLOBAL_VLC,
- psz_module, b_block );
-}
-
-vlc_error_t vlc_add_intf_r( vlc_t *p_vlc, const char *psz_module,
- vlc_bool_t b_block )
+int VLC_AddIntf( int i_object, const char *psz_module, vlc_bool_t b_block )
{
- vlc_error_t err;
+ int i_err;
intf_thread_t *p_intf;
+ vlc_t *p_vlc;
char *psz_oldmodule = NULL;
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
+
/* Check that the handle is valid */
if( !p_vlc || p_vlc->i_status != VLC_STATUS_RUNNING )
{
/* Try to run the interface */
p_intf->b_block = b_block;
- err = intf_RunThread( p_intf );
- if( err )
+ i_err = intf_RunThread( p_intf );
+ if( i_err )
{
vlc_object_detach( p_intf );
intf_Destroy( p_intf );
- return err;
+ return i_err;
}
return VLC_SUCCESS;
}
/*****************************************************************************
- * vlc_destroy: stop playing and destroy everything.
+ * VLC_Destroy: stop playing and destroy everything.
*****************************************************************************
* This function requests the running threads to finish, waits for their
* termination, and destroys their structure.
*****************************************************************************/
-vlc_error_t vlc_destroy( void )
+int VLC_Destroy( int i_object )
{
- return vlc_destroy_r( GLOBAL_VLC );
-}
+ vlc_t *p_vlc;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
-vlc_error_t vlc_destroy_r( vlc_t *p_vlc )
-{
/* Check that the handle is valid */
if( !p_vlc || (p_vlc->i_status != VLC_STATUS_STOPPED
&& p_vlc->i_status != VLC_STATUS_CREATED) )
}
/*****************************************************************************
- * vlc_die: ask vlc to die.
+ * 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_end and vlc_destroy afterwards.
+ * task. It is your duty to call vlc_end and VLC_Destroy afterwards.
*****************************************************************************/
-vlc_error_t vlc_die( void )
+int VLC_Die( int i_object )
{
- return vlc_die_r( GLOBAL_VLC );
-}
+ vlc_t *p_vlc;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
-vlc_error_t vlc_die_r( vlc_t *p_vlc )
-{
if( !p_vlc )
{
fprintf( stderr, "error: invalid status (!EXIST)\n" );
}
/*****************************************************************************
- * vlc_status: return the current vlc status.
- *****************************************************************************
- * This function returns the current value of p_vlc->i_status.
- *****************************************************************************/
-vlc_status_t vlc_status( void )
-{
- return vlc_status_r( GLOBAL_VLC );
-}
-
-vlc_status_t vlc_status_r( vlc_t *p_vlc )
-{
- if( !p_vlc )
- {
- return VLC_STATUS_NONE;
- }
-
- return p_vlc->i_status;
-}
-
-/*****************************************************************************
- * vlc_add_target: adds a target for playing.
+ * 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.
*****************************************************************************/
-vlc_error_t vlc_add_target( const char *psz_target, int i_mode, int i_pos )
-{
- return vlc_add_target_r( GLOBAL_VLC,
- psz_target, i_mode, i_pos );
-}
-
-vlc_error_t vlc_add_target_r( vlc_t *p_vlc, const char *psz_target,
- int i_mode, int i_pos )
+int VLC_AddTarget( int i_object, const char *psz_target, int i_mode, int i_pos )
{
- vlc_error_t err;
+ int i_err;
playlist_t *p_playlist;
+ vlc_t *p_vlc;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
if( !p_vlc || ( p_vlc->i_status != VLC_STATUS_STOPPED
&& p_vlc->i_status != VLC_STATUS_RUNNING ) )
vlc_object_yield( p_playlist );
}
- err = playlist_Add( p_playlist, psz_target, i_mode, i_pos );
+ i_err = playlist_Add( p_playlist, psz_target, i_mode, i_pos );
vlc_object_release( p_playlist );
- return err;
+ return i_err;
}
/*****************************************************************************
- * vlc_set: set a vlc variable
+ * VLC_Set: set a vlc variable
*****************************************************************************
*
*****************************************************************************/
-vlc_error_t vlc_set( const char *psz_var, const char *psz_val )
+int VLC_Set( int i_object, const char *psz_var, vlc_value_t value )
{
- return vlc_set_r( GLOBAL_VLC, psz_var, psz_val );
-}
+ vlc_t *p_vlc;
-vlc_error_t vlc_set_r( vlc_t *p_vlc, const char *psz_var, const char *psz_val )
-{
- module_config_t *p_config;
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
if( !p_vlc )
{
return VLC_ESTATUS;
}
- p_config = config_FindConfig( VLC_OBJECT(p_vlc), psz_var );
-
- if( !p_config )
+ /* 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 ) )
{
- msg_Err( p_vlc, "option %s does not exist", psz_var );
- return VLC_EGENERIC;
- }
+ module_config_t *p_item;
+ const char *psz_newvar = psz_var + 6;
- vlc_mutex_lock( p_config->p_lock );
+ p_item = config_FindConfig( VLC_OBJECT(p_vlc), psz_newvar );
- switch( p_config->i_type )
- {
- case CONFIG_ITEM_BOOL:
- if( psz_val && *psz_val )
+ if( p_item )
{
- if( !strcmp( psz_val, "off" ) || !strcmp( psz_val, "no" ) )
- {
- p_config->i_value = VLC_FALSE;
- }
- else
+ switch( p_item->i_type )
{
- p_config->i_value = atoi( psz_val );
+ 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;
}
+ return VLC_SUCCESS;
}
- else
- {
- p_config->i_value = VLC_TRUE;
- }
- break;
- case CONFIG_ITEM_INTEGER:
- if( psz_val && *psz_val )
- {
- p_config->i_value = atoi( psz_val );
- }
- else
- {
- p_config->i_value = 0;
- }
- break;
- case CONFIG_ITEM_FLOAT:
- if( psz_val && *psz_val )
- {
- p_config->f_value = (float)atof( psz_val );
- }
- else
- {
- p_config->f_value = 0.0;
- }
- break;
- case CONFIG_ITEM_STRING:
- case CONFIG_ITEM_FILE:
- case CONFIG_ITEM_MODULE:
- default:
- if( p_config->psz_value )
- {
- free( p_config->psz_value );
- }
-
- if( psz_val )
- {
- p_config->psz_value = strdup( psz_val );
- }
- else
- {
- p_config->psz_value = NULL;
- }
- break;
}
- if( p_config->pf_callback )
- {
- vlc_mutex_unlock( p_config->p_lock );
- p_config->pf_callback( VLC_OBJECT(p_vlc) );
- }
- else
+ return var_Set( p_vlc, psz_var, value );
+}
+
+/*****************************************************************************
+ * VLC_Get: get a vlc variable
+ *****************************************************************************
+ *
+ *****************************************************************************/
+int VLC_Get( int i_object, const char *psz_var, vlc_value_t *p_value )
+{
+ vlc_t *p_vlc;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
+
+ if( !p_vlc )
{
- vlc_mutex_unlock( p_config->p_lock );
+ fprintf( stderr, "error: invalid status\n" );
+ return VLC_ESTATUS;
}
- return VLC_SUCCESS;
+ return var_Get( p_vlc, psz_var, p_value );
}
-/* XXX: temporary hacks */
+/* FIXME: temporary hacks */
/*****************************************************************************
- * vlc_play: play
+ * VLC_Play: play
*****************************************************************************/
-vlc_error_t vlc_play( )
-{
- return vlc_play_r( GLOBAL_VLC );
-}
-
-vlc_error_t vlc_play_r( vlc_t *p_vlc )
+int VLC_Play( int i_object )
{
playlist_t * p_playlist;
+ vlc_t *p_vlc;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
/* Check that the handle is valid */
if( !p_vlc || p_vlc->i_status != VLC_STATUS_STOPPED )
}
/*****************************************************************************
- * vlc_stop: stop
+ * VLC_Stop: stop
*****************************************************************************/
-vlc_error_t vlc_stop( )
-{
- return vlc_stop_r( GLOBAL_VLC );
-}
-
-vlc_error_t vlc_stop_r( vlc_t *p_vlc )
+int VLC_Stop( int i_object )
{
intf_thread_t * p_intf;
playlist_t * p_playlist;
vout_thread_t * p_vout;
aout_instance_t * p_aout;
+ vlc_t *p_vlc;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
/* Check that the handle is valid */
if( !p_vlc || ( p_vlc->i_status != VLC_STATUS_STOPPED
}
/*****************************************************************************
- * vlc_pause: toggle pause
+ * VLC_Pause: toggle pause
*****************************************************************************/
-vlc_error_t vlc_pause( )
-{
- return vlc_pause_r( GLOBAL_VLC );
-}
-
-vlc_error_t vlc_pause_r( vlc_t *p_vlc )
+int VLC_Pause( int i_object )
{
input_thread_t *p_input;
+ vlc_t *p_vlc;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
+
+ if( !p_vlc )
+ {
+ return VLC_ESTATUS;
+ }
p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
}
/*****************************************************************************
- * vlc_fullscreen: toggle fullscreen mode
+ * VLC_FullScreen: toggle fullscreen mode
*****************************************************************************/
-vlc_error_t vlc_fullscreen( )
-{
- return vlc_fullscreen_r( GLOBAL_VLC );
-}
-
-vlc_error_t vlc_fullscreen_r( vlc_t *p_vlc )
+int VLC_FullScreen( int i_object )
{
vout_thread_t *p_vout;
+ vlc_t *p_vlc;
+
+ p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
+
+ if( !p_vlc )
+ {
+ return VLC_ESTATUS;
+ }
p_vout = vlc_object_find( p_vlc, VLC_OBJECT_VOUT, FIND_CHILD );
/* We assume that the remaining parameters are filenames */
for( i_opt = optind; i_opt < i_argc; i_opt++ )
{
- vlc_add_target_r( p_vlc, ppsz_argv[ i_opt ],
+ /* TODO: write an internal function of this one, to avoid
+ * unnecessary lookups. */
+ VLC_AddTarget( p_vlc->i_object_id, ppsz_argv[ i_opt ],
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
* objects.c: vlc_object_t handling
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: objects.c,v 1.23 2002/10/04 18:07:22 sam Exp $
+ * $Id: objects.c,v 1.24 2002/10/11 22:32:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
p_new->psz_object_name = NULL;
- p_new->i_refcount = 0;
p_new->b_die = VLC_FALSE;
p_new->b_error = VLC_FALSE;
p_new->b_dead = VLC_FALSE;
p_new->b_attached = VLC_FALSE;
+ p_new->i_vars = 0;
+ p_new->p_vars = (variable_t *)malloc( 16 * sizeof( variable_t ) );
+
+ if( !p_new->p_vars )
+ {
+ free( p_new );
+ return NULL;
+ }
+
if( i_type == VLC_OBJECT_ROOT )
{
/* If i_type is root, then p_new is actually p_libvlc */
vlc_mutex_unlock( &structure_lock );
}
+ p_new->i_refcount = 0;
p_new->p_parent = NULL;
p_new->pp_children = NULL;
p_new->i_children = 0;
/* Initialize mutexes and condvars */
vlc_mutex_init( p_new, &p_new->object_lock );
vlc_cond_init( p_new, &p_new->object_wait );
+ vlc_mutex_init( p_new, &p_new->var_lock );
if( i_type == VLC_OBJECT_ROOT )
{
msleep( 100000 );
}
+ /* Destroy the associated variables, starting from the end so that
+ * no memmove calls have to be done. */
+ while( p_this->i_vars )
+ {
+ var_Destroy( p_this, p_this->p_vars[p_this->i_vars - 1].psz_name );
+ }
+
+ free( p_this->p_vars );
+ vlc_mutex_destroy( &p_this->var_lock );
+
if( p_this->i_object_type == VLC_OBJECT_ROOT )
{
/* We are the root object ... no need to lock. */
free( p_this );
}
+/*****************************************************************************
+ * vlc_object_get: find an object given its ID
+ *****************************************************************************
+ * This function looks for the object whose i_object_id field is i_id. We
+ * use a dichotomy so that lookups are in log2(n).
+ *****************************************************************************/
+void * __vlc_object_get( vlc_object_t *p_this, int i_id )
+{
+ int i_max, i_middle;
+ vlc_object_t **pp_objects;
+
+ vlc_mutex_lock( &structure_lock );
+
+ pp_objects = p_this->p_libvlc->pp_objects;
+
+ /* Perform our dichotomy */
+ for( i_max = p_this->p_libvlc->i_objects - 1 ; ; )
+ {
+ i_middle = i_max / 2;
+
+ if( pp_objects[i_middle]->i_object_id > i_id )
+ {
+ i_max = i_middle;
+ }
+ else if( pp_objects[i_middle]->i_object_id < i_id )
+ {
+ if( i_middle )
+ {
+ pp_objects += i_middle;
+ i_max -= i_middle;
+ }
+ else
+ {
+ /* This happens when there are only two remaining objects */
+ if( pp_objects[i_middle+1]->i_object_id == i_id )
+ {
+ vlc_mutex_unlock( &structure_lock );
+ return pp_objects[i_middle+1];
+ }
+ break;
+ }
+ }
+ else
+ {
+ vlc_mutex_unlock( &structure_lock );
+ return pp_objects[i_middle];
+ }
+
+ if( i_max == 0 )
+ {
+ /* this means that i_max == i_middle, and since we have already
+ * tested pp_objects[i_middle]), p_found is properly set. */
+ break;
+ }
+ }
+
+ vlc_mutex_unlock( &structure_lock );
+ return NULL;
+}
+
/*****************************************************************************
* vlc_object_find: find a typed object and increment its refcount
*****************************************************************************
* vlc.c: the vlc player
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: vlc.c,v 1.13 2002/10/08 18:10:09 sam Exp $
+ * $Id: vlc.c,v 1.14 2002/10/11 22:32:56 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
#include <vlc/vlc.h>
-#include "config.h"
-
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
*****************************************************************************/
int main( int i_argc, char *ppsz_argv[] )
{
- vlc_error_t err;
+ int i_ret;
- fprintf( stderr, COPYRIGHT_MESSAGE "\n" );
+ fprintf( stderr, "VideoLAN Client %s\n", VLC_Version() );
#ifdef HAVE_PUTENV
# ifdef DEBUG
#endif
/* Create a libvlc structure */
- err = vlc_create();
- if( err != VLC_SUCCESS )
+ i_ret = VLC_Create();
+ if( i_ret < 0 )
{
- return err;
+ return i_ret;
}
#ifndef WIN32
#endif
/* Initialize libvlc */
- err = vlc_init( i_argc, ppsz_argv );
- if( err != VLC_SUCCESS )
+ i_ret = VLC_Init( 0, i_argc, ppsz_argv );
+ if( i_ret < 0 )
{
- vlc_destroy();
- return err;
+ VLC_Destroy( 0 );
+ return i_ret;
}
/* Run libvlc, in non-blocking mode */
- err = vlc_play();
+ i_ret = VLC_Play( 0 );
/* Add background interfaces */
#if 0
- { int i; for( i=10; i--; ) vlc_add_intf( NULL, "dummy", 0 ); }
- vlc_add_intf( NULL, "dummy", VLC_FALSE );
- vlc_add_intf( NULL, "logger", VLC_FALSE );
- vlc_add_intf( NULL, "xosd", VLC_FALSE );
- vlc_add_intf( NULL, "gtk", VLC_FALSE );
- vlc_add_intf( NULL, "kde", VLC_FALSE );
- vlc_add_intf( "rc", VLC_FALSE );
+ { int i; for( i=10; i--; ) VLC_AddIntf( 0, "dummy", 0 ); }
+ VLC_AddIntf( 0, "dummy", VLC_FALSE );
+ VLC_AddIntf( 0, "logger", VLC_FALSE );
+ VLC_AddIntf( 0, "xosd", VLC_FALSE );
+ VLC_AddIntf( 0, "gtk", VLC_FALSE );
+ VLC_AddIntf( 0, "kde", VLC_FALSE );
+ VLC_AddIntf( 0, "rc", VLC_FALSE );
#endif
/* Add a blocking interface and keep the return value */
- err = vlc_add_intf( NULL, VLC_TRUE );
+ i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE );
/* Finish the threads */
- vlc_stop();
+ VLC_Stop( 0 );
/* Destroy the libvlc structure */
- vlc_destroy();
+ VLC_Destroy( 0 );
- return err;
+ return i_ret;
}
#ifndef WIN32
"again in case it gets stuck\n", i_signal );
/* Acknowledge the signal received */
- vlc_die();
+ VLC_Die( 0 );
}
else if( time( NULL ) > abort_time + 2 )
{