Commit da73802e authored by Olivier Aubert's avatar Olivier Aubert

* All C files: coding style update

* mediacontrol-core.c: update to the new control API
* configure.ac, Modules.am: (unfinished) build changes
parent f0bb8873
...@@ -3547,36 +3547,23 @@ then ...@@ -3547,36 +3547,23 @@ then
) )
fi fi
dnl dnl
dnl corba (ORBit) plugin dnl corba (ORBit) plugin
dnl dnl
AC_ARG_ENABLE(corba, AC_ARG_ENABLE(corba,
[ --enable-corba corba interface support (default disabled)]) [ --enable-corba corba interface support (default disabled)])
if test "${enable_corba}" = "yes"; then if test "${enable_corba}" = "yes"; then
ORBIT_PATH="${PATH}" GLIB_VERSION=2.3.2
AC_ARG_WITH(orbit-config-path, PKG_CHECK_MODULES(LIBMEDIACONTROL,
[ --with-orbit-config-path=PATH orbit-config path (default search in \$PATH)]) ORBit-2.0 >= 2.8.0 \
if test "${with_orbit_config_path}" != "no"; then glib-2.0 >= $GLIB_VERSION \
ORBIT_PATH="${with_orbit_config_path}:${PATH}" gobject-2.0 >= $GLIB_VERSION \
fi gthread-2.0 >= $GLIB_VERSION,
# look for orbit2-config [
AC_PATH_PROG(ORBIT_CONFIG, orbit2-config, no, ${ORBIT_PATH}) AX_ADD_LDFLAGS([corba],[$LIBMEDIACONTROL_LIBS])
if test "${ORBIT_CONFIG}" != "no"; then AX_ADD_CFLAGS([corba],[$LIBMEDIACONTROL_CFLAGS])
AX_ADD_CFLAGS(corba,[`${ORBIT_CONFIG} --cflags server`]) AX_ADD_PLUGINS([corba snapshot]) ],
AX_ADD_LDFLAGS(corba,[`${ORBIT_CONFIG} --libs server | sed 's,-rdynamic,,'`]) [AC_MSG_WARN(corba library not found)])
# now look for the orbit.h header
CPPFLAGS="${CPPFLAGS_save} ${CFLAGS_corba}"
ac_cv_corba_headers=yes
AC_CHECK_HEADERS(orbit/orbit.h, , [
ac_cv_corba_headers=no
AC_MSG_ERROR([Could not find corba development headers])
])
if test "${ac_cv_corba_headers}" = "yes"; then
AX_ADD_PLUGINS([corba snapshot])
fi
CPPFLAGS="${CPPFLAGS_save}"
fi
fi fi
AC_ARG_WITH(,[Misc options:]) AC_ARG_WITH(,[Misc options:])
......
...@@ -2,30 +2,45 @@ ...@@ -2,30 +2,45 @@
SOURCES_corba = corba.c mediacontrol-core.c mediacontrol-plugin.c SOURCES_corba = corba.c mediacontrol-core.c mediacontrol-plugin.c
EXTRA_DIST += MediaControl.so
nodist_SOURCES_corba = \ nodist_SOURCES_corba = \
MediaControl-common.c \ MediaControl-common.c \
MediaControl-skels.c \ MediaControl-skels.c \
MediaControl-skelimpl.c \
MediaControl-stubs.c \
MediaControl-imodule.c \
MediaControl.h \ MediaControl.h \
$(NULL) $(NULL)
ORBITIDL = orbit-idl-2 corbaidldir = $(datadir)/idl
corbaidl_DATA = MediaControl.idl
GENERATEDFILES=MediaControl-common.c MediaControl-skels.c MediaControl.h MediaControl-imodule.c ## orbittypelibdir = $(libdir)/orbit-2.0
orbittypelibdir = $(libdir)/advene
orbittypelib_DATA = MediaControl.so
corba.c: MediaControl.h MediaControl-common.c EXTRA_DIST += $(corbaidl_DATA)
$(GENERATEDFILES): MediaControl.idl ORBIT_IDL=$(shell pkg-config --variable=orbit_idl ORBit-2.0)
$(ORBITIDL) --skeleton-impl MediaControl.idl
GENERATEDFILES = MediaControl-common.c MediaControl-skels.c MediaControl.h
BUILT_SOURCES += $(GENERATEDFILES) MediaControl-imodule.c
corba.c: MediaControl.h
MediaControl-imodule.c: ## Needed for both MediaControl.so and libcorba_plugin compilation
$(ORBITIDL) --imodule MediaControl.idl INCLUDES = $(LIBMEDIACONTROL_CFLAGS)
## MediaControl.so rules
MediaControl.so: MediaControl-imodule.c MediaControl.so: MediaControl-imodule.c
$(CC) -fPIC -o MediaControl-imodule.o -c MediaControl-imodule.c `pkg-config --cflags ORBit-2.0` $(CC) -fPIC -o MediaControl-imodule.o -c $< $(LIBMEDIACONTROL_CFLAGS)
$(CC) -shared -o $@ MediaControl-imodule.o `pkg-config --libs ORBit-2.0` $(CC) -shared -o $@ MediaControl-imodule.o $(LIBMEDIACONTROL_LIBS)
$(GENERATEDFILES): MediaControl.idl
$(ORBIT_IDL) --skeleton-impl $(corbaidl_DATA)
MediaControl-imodule.c: $(corbaidl_DATA)
$(ORBIT_IDL) --imodule $<
clean: clean:
$(RM) -f $(GENERATEDFILES) $(RM) -f $(GENERATEDFILES)
$(RM) -f MediaControl-imodule.c
...@@ -38,90 +38,91 @@ ...@@ -38,90 +38,91 @@
#include <unistd.h> #include <unistd.h>
/* FIXME: replace this to ~/.vlc/vlc-ior.ref thanks to /* FIXME: replace this to ~/.vlc/vlc-ior.ref thanks to
config_GetHomeDir() */ config_GetHomeDir( ) */
#ifndef __WIN32__ #ifndef __WIN32__
#define VLC_IOR_FILE "/tmp/vlc-ior.ref" #define VLC_IOR_FILE "/tmp/vlc-ior.ref"
#else #else
#define VLC_IOR_FILE "vlc-ior-ref" #define VLC_IOR_FILE "vlc-ior-ref"
#endif #endif
#define MC_TRY exception=mediacontrol_exception_init(exception) #define MC_TRY exception = mediacontrol_exception_init( exception )
#define MC_EXCEPT(return_value) \ #define MC_EXCEPT( return_value ) \
if (exception->code) { \ if ( exception->code )\
corba_raise(ev, exception); \ { \
mediacontrol_exception_free(exception); \ corba_raise( ev, exception ); \
return return_value; \ mediacontrol_exception_free( exception ); \
} else { mediacontrol_exception_free(exception); } return return_value; \
} else { mediacontrol_exception_free( exception ); }
#define handle_exception(m) if(ev->_major != CORBA_NO_EXCEPTION) \ #define handle_exception( m ) if( ev->_major != CORBA_NO_EXCEPTION ) \
{ \ { \
msg_Err (servant->p_intf, m); \ msg_Err( servant->p_intf, m ); \
return; \ return; \
} }
#define handle_exception_no_servant(p,m) if(ev->_major != CORBA_NO_EXCEPTION) \ #define handle_exception_no_servant( p,m ) if( ev->_major != CORBA_NO_EXCEPTION ) \
{ \ { \
msg_Err (p, m); \ msg_Err( p, m ); \
return; \ return; \
} }
static void corba_raise(CORBA_Environment *ev, mediacontrol_Exception *exception) static void corba_raise( CORBA_Environment *ev, mediacontrol_Exception *exception )
{ {
char *corba_exception=NULL; char *corba_exception=NULL;
char* i_type = NULL; char* i_type = NULL;
switch (exception->code) switch( exception->code )
{ {
case mediacontrol_InternalException: case mediacontrol_InternalException:
corba_exception = (char*)VLC_InternalException__alloc (); corba_exception = ( char* )VLC_InternalException__alloc();
i_type = ex_VLC_InternalException; i_type = ex_VLC_InternalException;
break; break;
case mediacontrol_PlaylistException: case mediacontrol_PlaylistException:
corba_exception = (char*)VLC_PlaylistException__alloc (); corba_exception = ( char* )VLC_PlaylistException__alloc();
i_type = ex_VLC_PlaylistException; i_type = ex_VLC_PlaylistException;
break; break;
case mediacontrol_InvalidPosition: case mediacontrol_InvalidPosition:
corba_exception = (char*)VLC_InvalidPosition__alloc (); corba_exception = ( char* )VLC_InvalidPosition__alloc();
i_type = ex_VLC_InvalidPosition; i_type = ex_VLC_InvalidPosition;
break; break;
case mediacontrol_PositionKeyNotSupported: case mediacontrol_PositionKeyNotSupported:
corba_exception = (char*)VLC_PositionKeyNotSupported__alloc (); corba_exception = ( char* )VLC_PositionKeyNotSupported__alloc();
i_type = ex_VLC_PositionKeyNotSupported; i_type = ex_VLC_PositionKeyNotSupported;
break; break;
case mediacontrol_PositionOriginNotSupported: case mediacontrol_PositionOriginNotSupported:
corba_exception = (char*)VLC_PositionOriginNotSupported__alloc (); corba_exception = ( char* )VLC_PositionOriginNotSupported__alloc();
i_type = ex_VLC_PositionOriginNotSupported; i_type = ex_VLC_PositionOriginNotSupported;
break; break;
} }
((VLC_InternalException*)corba_exception)->message = CORBA_string_dup(exception->message); ( (VLC_InternalException* )corba_exception )->message = CORBA_string_dup( exception->message );
CORBA_exception_set (ev, CORBA_USER_EXCEPTION, i_type, corba_exception); CORBA_exception_set( ev, CORBA_USER_EXCEPTION, i_type, corba_exception );
return; return;
} }
static mediacontrol_Position* corba_position_corba_to_c (const VLC_Position* position) static mediacontrol_Position* corba_position_corba_to_c( const VLC_Position* position )
{ {
mediacontrol_Position* retval; mediacontrol_Position* retval;
retval = (mediacontrol_Position*)malloc(sizeof(mediacontrol_Position)); retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) );
if (! retval) if( ! retval )
return NULL; return NULL;
retval->origin = position->origin; retval->origin = position->origin;
retval->key = position->key; retval->key = position->key;
retval->value = position->value; retval->value = position->value;
return retval; return retval;
} }
static VLC_Position* corba_position_c_to_corba(const mediacontrol_Position* position) static VLC_Position* corba_position_c_to_corba( const mediacontrol_Position* position )
{ {
VLC_Position* retval; VLC_Position* retval;
retval = (VLC_Position*)malloc(sizeof(VLC_Position)); retval = ( VLC_Position* )malloc( sizeof( VLC_Position ) );
if (! retval) if( ! retval )
return NULL; return NULL;
retval->origin = position->origin; retval->origin = position->origin;
retval->key = position->key; retval->key = position->key;
retval->value = position->value; retval->value = position->value;
return retval; return retval;
} }
/***************************************************************************** /*****************************************************************************
...@@ -129,203 +130,203 @@ static VLC_Position* corba_position_c_to_corba(const mediacontrol_Position* posi ...@@ -129,203 +130,203 @@ static VLC_Position* corba_position_c_to_corba(const mediacontrol_Position* posi
*****************************************************************************/ *****************************************************************************/
struct intf_sys_t struct intf_sys_t
{ {
CORBA_ORB orb; CORBA_ORB orb;
GMainLoop* corbaloop; GMainLoop* corbaloop;
mediacontrol_Instance *mc; mediacontrol_Instance *mc;
msg_subscription_t* p_sub; /* message bank subscription */ msg_subscription_t* p_sub; /* message bank subscription */
}; };
/*** App-specific servant structures ***/ /*** App-specific servant structures ***/
/* We can add attributes to this structure, which is both a pointer on a /* We can add attributes to this structure, which is both a pointer on a
specific structure, and on a POA_VLC_MediaControl (servant). Cf specific structure, and on a POA_VLC_MediaControl ( servant ). Cf
http://developer.gnome.org/doc/guides/corba/html/corba-poa-example.html */ http://developer.gnome.org/doc/guides/corba/html/corba-poa-example.html */
typedef struct typedef struct
{ {
POA_VLC_MediaControl servant; POA_VLC_MediaControl servant;
PortableServer_POA poa; PortableServer_POA poa;
/* Ajouter ici les attributs utiles */ /* Ajouter ici les attributs utiles */
mediacontrol_Instance *mc; mediacontrol_Instance *mc;
intf_thread_t *p_intf; intf_thread_t *p_intf;
} impl_POA_VLC_MediaControl; } impl_POA_VLC_MediaControl;
/* Beginning of the CORBA code generated in Mediacontrol-skelimpl.c */ /* Beginning of the CORBA code generated in Mediacontrol-skelimpl.c */
/* BEGIN INSERT */ /* BEGIN INSERT */
/*** Implementation stub prototypes ***/ /*** Implementation stub prototypes ***/
static void impl_VLC_MediaControl__destroy(impl_POA_VLC_MediaControl * static void impl_VLC_MediaControl__destroy( impl_POA_VLC_MediaControl *
servant, CORBA_Environment * ev); servant, CORBA_Environment * ev );
static VLC_Position static VLC_Position
impl_VLC_MediaControl_get_media_position(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_get_media_position( impl_POA_VLC_MediaControl * servant,
const VLC_PositionOrigin an_origin, const VLC_PositionOrigin an_origin,
const VLC_PositionKey a_key, const VLC_PositionKey a_key,
CORBA_Environment * ev); CORBA_Environment * ev );
static void static void
impl_VLC_MediaControl_set_media_position(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_set_media_position( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, const VLC_Position * a_position,
CORBA_Environment * ev); CORBA_Environment * ev );
static void static void
impl_VLC_MediaControl_start(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_start( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, const VLC_Position * a_position,
CORBA_Environment * ev); CORBA_Environment * ev );
static void static void
impl_VLC_MediaControl_pause(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_pause( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, const VLC_Position * a_position,
CORBA_Environment * ev); CORBA_Environment * ev );
static void static void
impl_VLC_MediaControl_resume(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_resume( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, const VLC_Position * a_position,
CORBA_Environment * ev); CORBA_Environment * ev );
static void static void
impl_VLC_MediaControl_stop(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_stop( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, const VLC_Position * a_position,
CORBA_Environment * ev); CORBA_Environment * ev );
static void static void
impl_VLC_MediaControl_exit(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_exit( impl_POA_VLC_MediaControl * servant,
CORBA_Environment * ev); CORBA_Environment * ev );
static void static void
impl_VLC_MediaControl_playlist_add_item(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_playlist_add_item( impl_POA_VLC_MediaControl * servant,
const CORBA_char * a_file, const CORBA_char * a_file,
CORBA_Environment * ev); CORBA_Environment * ev );
static void static void
impl_VLC_MediaControl_playlist_clear(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_playlist_clear( impl_POA_VLC_MediaControl * servant,
CORBA_Environment * ev); CORBA_Environment * ev );
static VLC_PlaylistSeq static VLC_PlaylistSeq
*impl_VLC_MediaControl_playlist_get_list(impl_POA_VLC_MediaControl * *impl_VLC_MediaControl_playlist_get_list( impl_POA_VLC_MediaControl *
servant, CORBA_Environment * ev); servant, CORBA_Environment * ev );
static VLC_RGBPicture static VLC_RGBPicture
*impl_VLC_MediaControl_snapshot(impl_POA_VLC_MediaControl * servant, *impl_VLC_MediaControl_snapshot( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, const VLC_Position * a_position,
CORBA_Environment * ev); CORBA_Environment * ev );
static VLC_RGBPictureSeq static VLC_RGBPictureSeq
*impl_VLC_MediaControl_all_snapshots(impl_POA_VLC_MediaControl * servant, *impl_VLC_MediaControl_all_snapshots( impl_POA_VLC_MediaControl * servant,
CORBA_Environment * ev); CORBA_Environment * ev );
static void static void
impl_VLC_MediaControl_display_text(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_display_text( impl_POA_VLC_MediaControl * servant,
const CORBA_char * message, const CORBA_char * message,
const VLC_Position * begin, const VLC_Position * begin,
const VLC_Position * end, const VLC_Position * end,
CORBA_Environment * ev); CORBA_Environment * ev );
static VLC_StreamInformation static VLC_StreamInformation
*impl_VLC_MediaControl_get_stream_information(impl_POA_VLC_MediaControl * *impl_VLC_MediaControl_get_stream_information( impl_POA_VLC_MediaControl *
servant, servant,
CORBA_Environment * ev); CORBA_Environment * ev );
static CORBA_unsigned_short static CORBA_unsigned_short
impl_VLC_MediaControl_sound_get_volume(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_sound_get_volume( impl_POA_VLC_MediaControl * servant,
CORBA_Environment * ev); CORBA_Environment * ev );
static void static void
impl_VLC_MediaControl_sound_set_volume(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_sound_set_volume( impl_POA_VLC_MediaControl * servant,
const CORBA_unsigned_short volume, const CORBA_unsigned_short volume,
CORBA_Environment * ev); CORBA_Environment * ev );
/*** epv structures ***/ /*** epv structures ***/
static PortableServer_ServantBase__epv impl_VLC_MediaControl_base_epv = { static PortableServer_ServantBase__epv impl_VLC_MediaControl_base_epv = {
NULL, /* _private data */ NULL, /* _private data */
(gpointer) & impl_VLC_MediaControl__destroy, /* finalize routine */ ( gpointer ) & impl_VLC_MediaControl__destroy, /* finalize routine */
NULL, /* default_POA routine */ NULL, /* default_POA routine */
}; };
static POA_VLC_MediaControl__epv impl_VLC_MediaControl_epv = { static POA_VLC_MediaControl__epv impl_VLC_MediaControl_epv = {
NULL, /* _private */ NULL, /* _private */
(gpointer) & impl_VLC_MediaControl_get_media_position, ( gpointer ) & impl_VLC_MediaControl_get_media_position,
(gpointer) & impl_VLC_MediaControl_set_media_position, ( gpointer ) & impl_VLC_MediaControl_set_media_position,
(gpointer) & impl_VLC_MediaControl_start, ( gpointer ) & impl_VLC_MediaControl_start,
(gpointer) & impl_VLC_MediaControl_pause, ( gpointer ) & impl_VLC_MediaControl_pause,
(gpointer) & impl_VLC_MediaControl_resume, ( gpointer ) & impl_VLC_MediaControl_resume,
(gpointer) & impl_VLC_MediaControl_stop, ( gpointer ) & impl_VLC_MediaControl_stop,
(gpointer) & impl_VLC_MediaControl_exit, ( gpointer ) & impl_VLC_MediaControl_exit,
(gpointer) & impl_VLC_MediaControl_playlist_add_item, ( gpointer ) & impl_VLC_MediaControl_playlist_add_item,
(gpointer) & impl_VLC_MediaControl_playlist_clear, ( gpointer ) & impl_VLC_MediaControl_playlist_clear,
(gpointer) & impl_VLC_MediaControl_playlist_get_list, ( gpointer ) & impl_VLC_MediaControl_playlist_get_list,
(gpointer) & impl_VLC_MediaControl_snapshot, ( gpointer ) & impl_VLC_MediaControl_snapshot,
(gpointer) & impl_VLC_MediaControl_all_snapshots, ( gpointer ) & impl_VLC_MediaControl_all_snapshots,
(gpointer) & impl_VLC_MediaControl_display_text, ( gpointer ) & impl_VLC_MediaControl_display_text,
(gpointer) & impl_VLC_MediaControl_get_stream_information, ( gpointer ) & impl_VLC_MediaControl_get_stream_information,
(gpointer) & impl_VLC_MediaControl_sound_get_volume, ( gpointer ) & impl_VLC_MediaControl_sound_get_volume,
(gpointer) & impl_VLC_MediaControl_sound_set_volume, ( gpointer ) & impl_VLC_MediaControl_sound_set_volume,
}; };
/*** vepv structures ***/ /*** vepv structures ***/
static POA_VLC_MediaControl__vepv impl_VLC_MediaControl_vepv = { static POA_VLC_MediaControl__vepv impl_VLC_MediaControl_vepv = {
&impl_VLC_MediaControl_base_epv, &impl_VLC_MediaControl_base_epv,
&impl_VLC_MediaControl_epv, &impl_VLC_MediaControl_epv,
}; };
/*** Stub implementations ***/ /*** Stub implementations ***/
static VLC_MediaControl static VLC_MediaControl
impl_VLC_MediaControl__create(PortableServer_POA poa, CORBA_Environment * ev) impl_VLC_MediaControl__create( PortableServer_POA poa, CORBA_Environment * ev )
{ {
VLC_MediaControl retval; VLC_MediaControl retval;
impl_POA_VLC_MediaControl *newservant; impl_POA_VLC_MediaControl *newservant;
PortableServer_ObjectId *objid; PortableServer_ObjectId *objid;
newservant = g_new0(impl_POA_VLC_MediaControl, 1); newservant = g_new0( impl_POA_VLC_MediaControl, 1 );
newservant->servant.vepv = &impl_VLC_MediaControl_vepv; newservant->servant.vepv = &impl_VLC_MediaControl_vepv;
newservant->poa = newservant->poa =
(PortableServer_POA) CORBA_Object_duplicate((CORBA_Object) poa, ev); ( PortableServer_POA ) CORBA_Object_duplicate( (CORBA_Object ) poa, ev );
POA_VLC_MediaControl__init((PortableServer_Servant) newservant, ev); POA_VLC_MediaControl__init( (PortableServer_Servant ) newservant, ev );
/* Before servant is going to be activated all /* Before servant is going to be activated all
* private attributes must be initialized. */ * private attributes must be initialized. */
/* ------ init private attributes here ------ */ /* ------ init private attributes here ------ */
newservant->mc = NULL; newservant->mc = NULL;
/* ------ ---------- end ------------- ------ */ /* ------ ---------- end ------------- ------ */
objid = PortableServer_POA_activate_object(poa, newservant, ev); objid = PortableServer_POA_activate_object( poa, newservant, ev );
CORBA_free(objid); CORBA_free( objid );
retval = PortableServer_POA_servant_to_reference(poa, newservant, ev); retval = PortableServer_POA_servant_to_reference( poa, newservant, ev );
return retval; return retval;
} }
static void static void
impl_VLC_MediaControl__destroy(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl__destroy( impl_POA_VLC_MediaControl * servant,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
CORBA_Object_release((CORBA_Object) servant->poa, ev); CORBA_Object_release( (CORBA_Object ) servant->poa, ev );
/* No further remote method calls are delegated to /* No further remote method calls are delegated to
* servant and you may free your private attributes. */ * servant and you may free your private attributes. */
/* ------ free private attributes here ------ */ /* ------ free private attributes here ------ */
/* ------ ---------- end ------------- ------ */ /* ------ ---------- end ------------- ------ */
POA_VLC_MediaControl__fini((PortableServer_Servant) servant, ev); POA_VLC_MediaControl__fini( (PortableServer_Servant ) servant, ev );
} }
/* END INSERT */ /* END INSERT */
...@@ -333,342 +334,342 @@ impl_VLC_MediaControl__destroy(impl_POA_VLC_MediaControl * servant, ...@@ -333,342 +334,342 @@ impl_VLC_MediaControl__destroy(impl_POA_VLC_MediaControl * servant,
/* Beginning of the CORBA functions that we define */ /* Beginning of the CORBA functions that we define */
/* Returns the current position in the stream. The returned value can /* Returns the current position in the stream. The returned value can
be relative or absolute (according to PositionOrigin) and the unit be relative or absolute ( according to PositionOrigin ) and the unit
is set by PositionKey */ is set by PositionKey */
static VLC_Position static VLC_Position
impl_VLC_MediaControl_get_media_position(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_get_media_position( impl_POA_VLC_MediaControl * servant,
const VLC_PositionOrigin an_origin, const VLC_PositionOrigin an_origin,
const VLC_PositionKey a_key, const VLC_PositionKey a_key,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
VLC_Position* retval = NULL; VLC_Position* retval = NULL;
mediacontrol_Position *p_pos; mediacontrol_Position *p_pos;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
MC_TRY; MC_TRY;
p_pos = mediacontrol_get_media_position(servant->mc, an_origin, a_key, exception); p_pos = mediacontrol_get_media_position( servant->mc, an_origin, a_key, exception );
MC_EXCEPT(*retval); MC_EXCEPT( *retval );
retval = corba_position_c_to_corba(p_pos); retval = corba_position_c_to_corba( p_pos );
free(p_pos); free( p_pos );
return *retval; return *retval;
} }
/* Sets the media position */ /* Sets the media position */
static void static void
impl_VLC_MediaControl_set_media_position(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_set_media_position( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, const VLC_Position * a_position,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
mediacontrol_Position *p_pos; mediacontrol_Position *p_pos;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
p_pos = corba_position_corba_to_c(a_position); p_pos = corba_position_corba_to_c( a_position );
MC_TRY; MC_TRY;
mediacontrol_set_media_position(servant->mc, p_pos, exception); mediacontrol_set_media_position( servant->mc, p_pos, exception );
MC_EXCEPT(); MC_EXCEPT();
free(p_pos); free( p_pos );
return; return;
} }
/* Starts playing a stream */ /* Starts playing a stream */
static void static void
impl_VLC_MediaControl_start(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_start( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, CORBA_Environment * ev) const VLC_Position * a_position, CORBA_Environment * ev )
{ {
mediacontrol_Position *p_pos; mediacontrol_Position *p_pos;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
p_pos = corba_position_corba_to_c(a_position); p_pos = corba_position_corba_to_c( a_position );
MC_TRY; MC_TRY;
mediacontrol_start(servant->mc, p_pos, exception); mediacontrol_start( servant->mc, p_pos, exception );
MC_EXCEPT(); MC_EXCEPT();
free(p_pos); free( p_pos );
return; return;
} }
static void static void
impl_VLC_MediaControl_pause(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_pause( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, CORBA_Environment * ev) const VLC_Position * a_position, CORBA_Environment * ev )
{ {
mediacontrol_Position *p_pos; mediacontrol_Position *p_pos;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
p_pos = corba_position_corba_to_c(a_position); p_pos = corba_position_corba_to_c( a_position );
MC_TRY; MC_TRY;
mediacontrol_pause(servant->mc, p_pos, exception); mediacontrol_pause( servant->mc, p_pos, exception );
MC_EXCEPT(); MC_EXCEPT();
free(p_pos); free( p_pos );
return; return;
} }
static void static void
impl_VLC_MediaControl_resume(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_resume( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, CORBA_Environment * ev) const VLC_Position * a_position, CORBA_Environment * ev )
{ {
mediacontrol_Position *p_pos; mediacontrol_Position *p_pos;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
p_pos = corba_position_corba_to_c(a_position); p_pos = corba_position_corba_to_c( a_position );
MC_TRY; MC_TRY;
mediacontrol_resume(servant->mc, p_pos, exception); mediacontrol_resume( servant->mc, p_pos, exception );
MC_EXCEPT(); MC_EXCEPT();
free(p_pos); free( p_pos );
return; return;
} }
static void static void
impl_VLC_MediaControl_stop(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_stop( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, CORBA_Environment * ev) const VLC_Position * a_position, CORBA_Environment * ev )
{ {
mediacontrol_Position *p_pos; mediacontrol_Position *p_pos;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
p_pos = corba_position_corba_to_c(a_position); p_pos = corba_position_corba_to_c( a_position );
MC_TRY; MC_TRY;
mediacontrol_pause(servant->mc, p_pos, exception); mediacontrol_pause( servant->mc, p_pos, exception );
MC_EXCEPT(); MC_EXCEPT();
free(p_pos); free( p_pos );
return; return;
} }
static void static void
impl_VLC_MediaControl_exit(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_exit( impl_POA_VLC_MediaControl * servant,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
mediacontrol_exit(servant->mc); mediacontrol_exit( servant->mc );
return; return;
} }
static void static void
impl_VLC_MediaControl_playlist_add_item(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_playlist_add_item( impl_POA_VLC_MediaControl * servant,
const CORBA_char * psz_file, const CORBA_char * psz_file,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
MC_TRY; MC_TRY;
mediacontrol_playlist_add_item(servant->mc, psz_file, exception); mediacontrol_playlist_add_item( servant->mc, psz_file, exception );
MC_EXCEPT(); MC_EXCEPT();
return; return;
} }
static void static void
impl_VLC_MediaControl_playlist_clear(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_playlist_clear( impl_POA_VLC_MediaControl * servant,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
MC_TRY; MC_TRY;
mediacontrol_playlist_clear(servant->mc, exception); mediacontrol_playlist_clear( servant->mc, exception );
MC_EXCEPT(); MC_EXCEPT();
return; return;
} }
static VLC_PlaylistSeq * static VLC_PlaylistSeq *
impl_VLC_MediaControl_playlist_get_list(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_playlist_get_list( impl_POA_VLC_MediaControl * servant,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
VLC_PlaylistSeq *retval = NULL; VLC_PlaylistSeq *retval = NULL;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
mediacontrol_PlaylistSeq* p_ps; mediacontrol_PlaylistSeq* p_ps;
int i_index; int i_index;
MC_TRY; MC_TRY;
p_ps = mediacontrol_playlist_get_list(servant->mc, exception); p_ps = mediacontrol_playlist_get_list( servant->mc, exception );
MC_EXCEPT(retval); MC_EXCEPT( retval );
retval = VLC_PlaylistSeq__alloc (); retval = VLC_PlaylistSeq__alloc();
retval->_buffer = VLC_PlaylistSeq_allocbuf (p_ps->size); retval->_buffer = VLC_PlaylistSeq_allocbuf( p_ps->size );
retval->_length = p_ps->size; retval->_length = p_ps->size;
for (i_index = 0 ; i_index < p_ps->size ; i_index++) for( i_index = 0 ; i_index < p_ps->size ; i_index++ )
{ {
retval->_buffer[i_index] = CORBA_string_dup (p_ps->data[i_index]); retval->_buffer[i_index] = CORBA_string_dup( p_ps->data[i_index] );
} }
CORBA_sequence_set_release (retval, TRUE); CORBA_sequence_set_release( retval, TRUE );
mediacontrol_PlaylistSeq__free(p_ps); mediacontrol_PlaylistSeq__free( p_ps );
return retval; return retval;
} }
VLC_RGBPicture* VLC_RGBPicture*
createRGBPicture (mediacontrol_RGBPicture* p_pic) createRGBPicture( mediacontrol_RGBPicture* p_pic )
{ {
VLC_RGBPicture *retval; VLC_RGBPicture *retval;
retval = VLC_RGBPicture__alloc (); retval = VLC_RGBPicture__alloc();
if (retval) if( retval )
{ {
retval->width = p_pic->width; retval->width = p_pic->width;
retval->height = p_pic->height; retval->height = p_pic->height;
retval->type = p_pic->type; retval->type = p_pic->type;
retval->date = p_pic->date; retval->date = p_pic->date;
retval->data._maximum = p_pic->size; retval->data._maximum = p_pic->size;
retval->data._length = p_pic->size; retval->data._length = p_pic->size;
retval->data._buffer = VLC_ByteSeq_allocbuf (p_pic->size); retval->data._buffer = VLC_ByteSeq_allocbuf( p_pic->size );
memcpy (retval->data._buffer, p_pic->data, p_pic->size); memcpy( retval->data._buffer, p_pic->data, p_pic->size );
/* CORBA_sequence_set_release (&(retval->data), FALSE); */ /* CORBA_sequence_set_release( &( retval->data ), FALSE ); */
} }
return retval; return retval;
} }
static VLC_RGBPicture * static VLC_RGBPicture *
impl_VLC_MediaControl_snapshot(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_snapshot( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position, const VLC_Position * a_position,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
VLC_RGBPicture *retval = NULL; VLC_RGBPicture *retval = NULL;
mediacontrol_RGBPicture* p_pic = NULL; mediacontrol_RGBPicture* p_pic = NULL;
mediacontrol_Position *p_pos; mediacontrol_Position *p_pos;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
p_pos = corba_position_corba_to_c(a_position); p_pos = corba_position_corba_to_c( a_position );
MC_TRY; MC_TRY;
p_pic = mediacontrol_snapshot(servant->mc, p_pos, exception); p_pic = mediacontrol_snapshot( servant->mc, p_pos, exception );
MC_EXCEPT(retval); MC_EXCEPT( retval );
retval = createRGBPicture(p_pic); retval = createRGBPicture( p_pic );
mediacontrol_RGBPicture__free(p_pic); mediacontrol_RGBPicture__free( p_pic );
return retval; return retval;
} }
static VLC_RGBPictureSeq * static VLC_RGBPictureSeq *
impl_VLC_MediaControl_all_snapshots(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_all_snapshots( impl_POA_VLC_MediaControl * servant,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
VLC_RGBPictureSeq *retval = NULL; VLC_RGBPictureSeq *retval = NULL;
mediacontrol_RGBPicture** p_piclist = NULL; mediacontrol_RGBPicture** p_piclist = NULL;
mediacontrol_RGBPicture** p_tmp = NULL; mediacontrol_RGBPicture** p_tmp = NULL;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
int i_size = 0; int i_size = 0;
int i_index; int i_index;
MC_TRY; MC_TRY;
p_piclist = mediacontrol_all_snapshots(servant->mc, exception); p_piclist = mediacontrol_all_snapshots( servant->mc, exception );
MC_EXCEPT(retval); MC_EXCEPT( retval );
for (p_tmp = p_piclist ; *p_tmp != NULL ; p_tmp++) for( p_tmp = p_piclist ; *p_tmp != NULL ; p_tmp++ )
i_size++; i_size++;
retval = VLC_RGBPictureSeq__alloc (); retval = VLC_RGBPictureSeq__alloc();
retval->_buffer = VLC_RGBPictureSeq_allocbuf (i_size); retval->_buffer = VLC_RGBPictureSeq_allocbuf( i_size );
retval->_length = i_size; retval->_length = i_size;
for (i_index = 0 ; i_index < i_size ; i_index++) for( i_index = 0 ; i_index < i_size ; i_index++ )
{ {
mediacontrol_RGBPicture *p_pic = p_piclist[i_index]; mediacontrol_RGBPicture *p_pic = p_piclist[i_index];
VLC_RGBPicture *p_rgb; VLC_RGBPicture *p_rgb;
p_rgb = &(retval->_buffer[i_index]); p_rgb = &( retval->_buffer[i_index] );
p_rgb->width = p_pic->width; p_rgb->width = p_pic->width;
p_rgb->height = p_pic->height; p_rgb->height = p_pic->height;
p_rgb->type = p_pic->type; p_rgb->type = p_pic->type;
p_rgb->date = p_pic->date; p_rgb->date = p_pic->date;
p_rgb->data._maximum = p_pic->size; p_rgb->data._maximum = p_pic->size;
p_rgb->data._length = p_pic->size; p_rgb->data._length = p_pic->size;
p_rgb->data._buffer = VLC_ByteSeq_allocbuf (p_pic->size); p_rgb->data._buffer = VLC_ByteSeq_allocbuf( p_pic->size );
memcpy (p_rgb->data._buffer, p_pic->data, p_pic->size); memcpy( p_rgb->data._buffer, p_pic->data, p_pic->size );
mediacontrol_RGBPicture__free(p_pic); mediacontrol_RGBPicture__free( p_pic );
} }
free(p_piclist); free( p_piclist );
return retval; return retval;
} }
static void static void
impl_VLC_MediaControl_display_text(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_display_text( impl_POA_VLC_MediaControl * servant,
const CORBA_char * message, const CORBA_char * message,
const VLC_Position * begin, const VLC_Position * begin,
const VLC_Position * end, const VLC_Position * end,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
mediacontrol_Position *p_begin = NULL; mediacontrol_Position *p_begin = NULL;
mediacontrol_Position *p_end = NULL; mediacontrol_Position *p_end = NULL;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
p_begin = corba_position_corba_to_c(begin); p_begin = corba_position_corba_to_c( begin );
p_end = corba_position_corba_to_c(end); p_end = corba_position_corba_to_c( end );
MC_TRY; MC_TRY;
mediacontrol_display_text(servant->mc, message, p_begin, p_end, exception); mediacontrol_display_text( servant->mc, message, p_begin, p_end, exception );
MC_EXCEPT(); MC_EXCEPT();
free(p_begin); free( p_begin );
free(p_end); free( p_end );
return; return;
} }
static VLC_StreamInformation * static VLC_StreamInformation *
impl_VLC_MediaControl_get_stream_information(impl_POA_VLC_MediaControl * impl_VLC_MediaControl_get_stream_information( impl_POA_VLC_MediaControl *
servant, CORBA_Environment * ev) servant, CORBA_Environment * ev )
{ {
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
mediacontrol_StreamInformation *p_si = NULL; mediacontrol_StreamInformation *p_si = NULL;
VLC_StreamInformation *retval = NULL; VLC_StreamInformation *retval = NULL;
MC_TRY; MC_TRY;
p_si = mediacontrol_get_stream_information(servant->mc, mediacontrol_MediaTime, exception); p_si = mediacontrol_get_stream_information( servant->mc, mediacontrol_MediaTime, exception );
MC_EXCEPT(retval); MC_EXCEPT( retval );
retval = VLC_StreamInformation__alloc(); retval = VLC_StreamInformation__alloc();
if (! retval) if( ! retval )
{ {
return NULL; return NULL;
} }
retval->streamstatus = p_si->streamstatus; retval->streamstatus = p_si->streamstatus;
retval->url = CORBA_string_dup (p_si->url); retval->url = CORBA_string_dup( p_si->url );
retval->position = p_si->position; retval->position = p_si->position;
retval->length = p_si->length; retval->length = p_si->length;
free(p_si->url); free( p_si->url );
free(p_si); free( p_si );
return retval; return retval;
} }
static CORBA_unsigned_short static CORBA_unsigned_short
impl_VLC_MediaControl_sound_get_volume(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_sound_get_volume( impl_POA_VLC_MediaControl * servant,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
CORBA_short retval = 0; CORBA_short retval = 0;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
MC_TRY; MC_TRY;
retval = mediacontrol_sound_get_volume(servant->mc, exception); retval = mediacontrol_sound_get_volume( servant->mc, exception );
MC_EXCEPT(retval); MC_EXCEPT( retval );
return retval; return retval;
} }
static void static void
impl_VLC_MediaControl_sound_set_volume(impl_POA_VLC_MediaControl * servant, impl_VLC_MediaControl_sound_set_volume( impl_POA_VLC_MediaControl * servant,
const CORBA_unsigned_short volume, const CORBA_unsigned_short volume,
CORBA_Environment * ev) CORBA_Environment * ev )
{ {
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
MC_TRY; MC_TRY;
mediacontrol_sound_set_volume(servant->mc, volume, exception); mediacontrol_sound_set_volume( servant->mc, volume, exception );
MC_EXCEPT(); MC_EXCEPT();
} }
/* (Real) end of the CORBA code generated in Mediacontrol-skelimpl.c */ /* ( Real ) end of the CORBA code generated in Mediacontrol-skelimpl.c */
/***************************************************************************** /*****************************************************************************
* Local prototypes. * Local prototypes.
...@@ -681,12 +682,12 @@ static void Run ( intf_thread_t * ); ...@@ -681,12 +682,12 @@ static void Run ( intf_thread_t * );
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
vlc_module_begin(); vlc_module_begin();
add_category_hint( N_("Corba control"), NULL, VLC_FALSE ); add_category_hint( N_( "Corba control" ), NULL, VLC_FALSE );
set_description( _("corba control module") ); set_description( _( "corba control module" ) );
set_capability( "interface", 10 ); set_capability( "interface", 10 );
add_integer( "corba-reactivity", 5000, NULL, "Internal reactivity factor", "Internal reactivity factor (gtk timeout is INTF_IDLE_SLEEP / factor)", VLC_TRUE ); add_integer( "corba-reactivity", 5000, NULL, "Internal reactivity factor", "Internal reactivity factor ( gtk timeout is INTF_IDLE_SLEEP / factor )", VLC_TRUE );
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
/***************************************************************************** /*****************************************************************************
...@@ -694,24 +695,24 @@ vlc_module_end(); ...@@ -694,24 +695,24 @@ vlc_module_end();
*****************************************************************************/ *****************************************************************************/
static int Open( vlc_object_t *p_this ) static int Open( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_thread_t *p_intf = ( intf_thread_t * )p_this;
/* Allocate instance and initialize some members */ /* Allocate instance and initialize some members */
p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL ) if( p_intf->p_sys == NULL )
{ {
msg_Err( p_intf, "Out of memory" ); msg_Err( p_intf, "Out of memory" );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
/* Initialize the fields of the p_intf struct */ /* Initialize the fields of the p_intf struct */
p_intf->pf_run = Run; p_intf->pf_run = Run;
p_intf->p_sys->mc = NULL; p_intf->p_sys->mc = NULL;
p_intf->p_sys->orb = NULL; p_intf->p_sys->orb = NULL;
p_intf->p_sys->corbaloop = NULL; p_intf->p_sys->corbaloop = NULL;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -719,53 +720,53 @@ static int Open( vlc_object_t *p_this ) ...@@ -719,53 +720,53 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static void Close( vlc_object_t *p_this ) static void Close( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_thread_t *p_intf = ( intf_thread_t * )p_this;
CORBA_Environment* ev = NULL; CORBA_Environment* ev = NULL;
ev = CORBA_exception__alloc (); ev = CORBA_exception__alloc();
CORBA_ORB_shutdown (p_intf->p_sys->orb, FALSE, ev); CORBA_ORB_shutdown( p_intf->p_sys->orb, FALSE, ev );
handle_exception_no_servant (p_intf, "Error in Close"); handle_exception_no_servant( p_intf, "Error in Close" );
/* Destroy structure */ /* Destroy structure */
free( p_intf->p_sys ); free( p_intf->p_sys );
} }
/* /*
Function called regularly to handle various tasks (mainly CORBA calls) Function called regularly to handle various tasks( mainly CORBA calls )
*/ */
static gboolean Manage (gpointer p_interface) static gboolean Manage( gpointer p_interface )
{ {
intf_thread_t *p_intf = (intf_thread_t*)p_interface; intf_thread_t *p_intf = ( intf_thread_t* )p_interface;
CORBA_boolean b_work_pending; CORBA_boolean b_work_pending;
CORBA_Environment* ev; CORBA_Environment* ev;
ev = CORBA_exception__alloc (); ev = CORBA_exception__alloc();
/* CORBA */ /* CORBA */
b_work_pending = CORBA_ORB_work_pending (p_intf->p_sys->orb, ev); b_work_pending = CORBA_ORB_work_pending( p_intf->p_sys->orb, ev );
if(ev->_major != CORBA_NO_EXCEPTION) if( ev->_major != CORBA_NO_EXCEPTION )
{ {
msg_Err (p_intf, "Exception in CORBA events check loop"); msg_Err( p_intf, "Exception in CORBA events check loop" );
return FALSE; return FALSE;
} }
vlc_mutex_lock( &p_intf->change_lock ); vlc_mutex_lock( &p_intf->change_lock );
if (b_work_pending) if( b_work_pending )
CORBA_ORB_perform_work (p_intf->p_sys->orb, ev); CORBA_ORB_perform_work( p_intf->p_sys->orb, ev );
if( p_intf->b_die ) if( p_intf->b_die )
{ {
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
CORBA_ORB_shutdown (p_intf->p_sys->orb, TRUE, ev); CORBA_ORB_shutdown( p_intf->p_sys->orb, TRUE, ev );
g_main_loop_quit (p_intf->p_sys->corbaloop); g_main_loop_quit( p_intf->p_sys->corbaloop );
/* Just in case */ /* Just in case */
return( TRUE ); return( TRUE );
} }
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
return TRUE; return TRUE;
} }
/***************************************************************************** /*****************************************************************************
...@@ -774,116 +775,116 @@ static gboolean Manage (gpointer p_interface) ...@@ -774,116 +775,116 @@ static gboolean Manage (gpointer p_interface)
* this part of the interface is in a separate thread so that we can call * this part of the interface is in a separate thread so that we can call
* g_main_loop_run() from within it without annoying the rest of the program. * g_main_loop_run() from within it without annoying the rest of the program.
*****************************************************************************/ *****************************************************************************/
static void Run ( intf_thread_t *p_intf ) static void Run( intf_thread_t *p_intf )
{ {
CORBA_Environment* ev = NULL; CORBA_Environment* ev = NULL;
PortableServer_POA root_poa; PortableServer_POA root_poa;
PortableServer_POAManager root_poa_manager; PortableServer_POAManager root_poa_manager;
guint i_event_source; guint i_event_source;
CORBA_char* psz_objref; CORBA_char* psz_objref;
impl_POA_VLC_MediaControl *servant = NULL; impl_POA_VLC_MediaControl *servant = NULL;
VLC_MediaControl corba_instance; VLC_MediaControl corba_instance;
mediacontrol_Instance *mc_instance; mediacontrol_Instance *mc_instance;
mediacontrol_Exception *exception = NULL; mediacontrol_Exception *exception = NULL;
int i_argc = 1; int i_argc = 1;
char* ppsz_argv[] = { "mc" }; char* ppsz_argv[] = { "mc" };
int i_reactivity; int i_reactivity;
ev = CORBA_exception__alloc (); ev = CORBA_exception__alloc();
p_intf->p_sys->orb = CORBA_ORB_init(&i_argc, ppsz_argv, "orbit-local-orb", ev); p_intf->p_sys->orb = CORBA_ORB_init( &i_argc, ppsz_argv, "orbit-local-orb", ev );
/* Should be cleaner this way (cf /* Should be cleaner this way ( cf
http://www.fifi.org/doc/gnome-dev-doc/html/C/orbitgtk.html) but it http://www.fifi.org/doc/gnome-dev-doc/html/C/orbitgtk.html ) but it
functions well enough in the ugly way so that I do not bother functions well enough in the ugly way so that I do not bother
cleaning it */ cleaning it */
/* p_intf->p_sys->orb = gnome_CORBA_init ("VLC", NULL, &argc, &argv, 0, NULL, ev); */ /* p_intf->p_sys->orb = gnome_CORBA_init ( "VLC", NULL, &argc, &argv, 0, NULL, ev ); */
handle_exception_no_servant (p_intf, "Exception during CORBA_ORB_init"); handle_exception_no_servant( p_intf, "Exception during CORBA_ORB_init" );
root_poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references(p_intf->p_sys->orb, "RootPOA", ev); root_poa = ( PortableServer_POA )CORBA_ORB_resolve_initial_references( p_intf->p_sys->orb, "RootPOA", ev );
handle_exception ("Exception during RootPOA initialization"); handle_exception( "Exception during RootPOA initialization" );
corba_instance = impl_VLC_MediaControl__create(root_poa, ev); corba_instance = impl_VLC_MediaControl__create( root_poa, ev );
handle_exception ("Exception during MediaControl initialization"); handle_exception( "Exception during MediaControl initialization" );
servant = (impl_POA_VLC_MediaControl*)PortableServer_POA_reference_to_servant(root_poa, corba_instance, ev); servant = ( impl_POA_VLC_MediaControl* )PortableServer_POA_reference_to_servant( root_poa, corba_instance, ev );
handle_exception ("Exception during MediaControl access"); handle_exception( "Exception during MediaControl access" );
MC_TRY; MC_TRY;
mc_instance = mediacontrol_new_from_object((vlc_object_t*)p_intf, exception); mc_instance = mediacontrol_new_from_object((vlc_object_t* )p_intf, exception );
MC_EXCEPT(); MC_EXCEPT();
p_intf->p_sys->mc = mc_instance; p_intf->p_sys->mc = mc_instance;
servant->p_intf = p_intf; servant->p_intf = p_intf;
servant->mc = p_intf->p_sys->mc; servant->mc = p_intf->p_sys->mc;
psz_objref = CORBA_ORB_object_to_string(p_intf->p_sys->orb, corba_instance, ev); psz_objref = CORBA_ORB_object_to_string( p_intf->p_sys->orb, corba_instance, ev );
handle_exception ("Exception during IOR generation"); handle_exception( "Exception during IOR generation" );
msg_Warn (p_intf, "MediaControl IOR :"); msg_Warn( p_intf, "MediaControl IOR :" );
msg_Warn (p_intf, psz_objref); msg_Warn( p_intf, psz_objref );
/* We write the IOR in a file. */ /* We write the IOR in a file. */
{ {
FILE* fp; FILE* fp;
fp = fopen (VLC_IOR_FILE, "w"); fp = fopen( VLC_IOR_FILE, "w" );
if (fp == NULL) if( fp == NULL )
{ {
msg_Err (p_intf, "Cannot write the IOR to %s (%d).", VLC_IOR_FILE, errno); msg_Err( p_intf, "Cannot write the IOR to %s ( %d ).", VLC_IOR_FILE, errno );
} }
else else
{ {
fprintf (fp, "%s", psz_objref); fprintf( fp, "%s", psz_objref );
fclose (fp); fclose( fp );
msg_Warn (p_intf, "IOR written to %s", VLC_IOR_FILE); msg_Warn( p_intf, "IOR written to %s", VLC_IOR_FILE );
} }
} }
root_poa_manager = PortableServer_POA__get_the_POAManager(root_poa, ev); root_poa_manager = PortableServer_POA__get_the_POAManager( root_poa, ev );
handle_exception ("Exception during POAManager resolution"); handle_exception( "Exception during POAManager resolution" );
PortableServer_POAManager_activate(root_poa_manager, ev); PortableServer_POAManager_activate( root_poa_manager, ev );
handle_exception ("Exception during POAManager activation"); handle_exception( "Exception during POAManager activation" );
msg_Info(p_intf, "corba remote control interface initialized" ); msg_Info( p_intf, "corba remote control interface initialized" );
/* /*
// Tentative de gestion du nommage... // Tentative de gestion du nommage...
{ {
CosNaming_NamingContext name_service; CosNaming_NamingContext name_service;
CosNaming_NameComponent name_component[3] = {{"GNOME", "subcontext"}, CosNaming_NameComponent name_component[3] = {{"GNOME", "subcontext"},
{"Servers", "subcontext"}, {"Servers", "subcontext"},
{"vlc", "server"} }; {"vlc", "server"} };
CosNaming_Name name = {3, 3, name_component, CORBA_FALSE}; CosNaming_Name name = {3, 3, name_component, CORBA_FALSE};
name_service = CORBA_ORB_resolve_initial_references (p_intf->p_sys->orb, name_service = CORBA_ORB_resolve_initial_references( p_intf->p_sys->orb,
"NameService", "NameService",
ev); ev );
handle_exception ("Error: could not get name service: %s\n", handle_exception( "Error: could not get name service: %s\n",
CORBA_exception_id(ev)); CORBA_exception_id( ev ) );
msg_Warn (p_intf, "Name service OK"); msg_Warn( p_intf, "Name service OK" );
CosNaming_NamingContext_bind (name_service, &name, p_intf->p_sys->mc, ev); CosNaming_NamingContext_bind( name_service, &name, p_intf->p_sys->mc, ev );
handle_exception ("Error: could not register object: %s\n", handle_exception( "Error: could not register object: %s\n",
CORBA_exception_id(ev)); CORBA_exception_id( ev ) );
} }
*/ */
/* The time factor should be 1/1000 but it is a little too /* The time factor should be 1/1000 but it is a little too
slow. Make it 1/10000 */ slow. Make it 1/10000 */
i_reactivity = config_GetInt( p_intf, "corba-reactivity" ); i_reactivity = config_GetInt( p_intf, "corba-reactivity" );
i_event_source = g_timeout_add (INTF_IDLE_SLEEP / i_reactivity, Manage, p_intf); i_event_source = g_timeout_add( INTF_IDLE_SLEEP / i_reactivity, Manage, p_intf );
p_intf->p_sys->corbaloop = g_main_loop_new (NULL, FALSE); p_intf->p_sys->corbaloop = g_main_loop_new( NULL, FALSE );
g_main_loop_run (p_intf->p_sys->corbaloop); g_main_loop_run( p_intf->p_sys->corbaloop );
/* Cleaning */ /* Cleaning */
g_source_remove( i_event_source ); g_source_remove( i_event_source );
unlink (VLC_IOR_FILE); unlink( VLC_IOR_FILE );
/* Make sure we exit (In case other interfaces have been spawned) */ /* Make sure we exit ( In case other interfaces have been spawned ) */
mediacontrol_exit(p_intf->p_sys->mc); mediacontrol_exit( p_intf->p_sys->mc );
return; return;
} }
...@@ -28,881 +28,847 @@ ...@@ -28,881 +28,847 @@
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#define RAISE(c, m) exception->code = c; \ #define RAISE( c, m ) exception->code = c; \
exception->message = strdup(m); exception->message = strdup(m);
long long mediacontrol_unit_convert (input_thread_t *p_input, long long mediacontrol_unit_convert( input_thread_t *p_input,
mediacontrol_PositionKey from, mediacontrol_PositionKey from,
mediacontrol_PositionKey to, mediacontrol_PositionKey to,
long long value) long long value )
{ {
if (to == from) if( to == from )
return value; return value;
/* For all conversions, we need data from p_input */ /* For all conversions, we need data from p_input */
if (!p_input) if( !p_input )
return 0; return 0;
switch (from) switch( from )
{ {
case mediacontrol_MediaTime: case mediacontrol_MediaTime:
if (to == mediacontrol_ByteCount) if( to == mediacontrol_ByteCount )
return value * 50 * p_input->stream.i_mux_rate / 1000; return value * 50 * p_input->stream.i_mux_rate / 1000;
if (to == mediacontrol_SampleCount) if( to == mediacontrol_SampleCount )
{ {
double f_fps; double f_fps;
if (demux_Control( p_input, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1) if( demux_Control( p_input, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
return 0; return 0;
else else
return (value * f_fps / 1000.0); return( value * f_fps / 1000.0 );
} }
/* Cannot happen */ /* Cannot happen */
/* See http://catb.org/~esr/jargon/html/entry/can't-happen.html */ /* See http://catb.org/~esr/jargon/html/entry/can't-happen.html */
break; break;
case mediacontrol_SampleCount: case mediacontrol_SampleCount:
{ {
double f_fps; double f_fps;
if (demux_Control( p_input, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1) if( demux_Control( p_input, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
return 0; return 0;
if (to == mediacontrol_ByteCount) if( to == mediacontrol_ByteCount )
return (long long)(value * 50 * p_input->stream.i_mux_rate / f_fps); return ( long long )( value * 50 * p_input->stream.i_mux_rate / f_fps );
if (to == mediacontrol_MediaTime) if( to == mediacontrol_MediaTime )
return (long long)(value * 1000.0 / (double)f_fps ); return( long long )( value * 1000.0 / ( double )f_fps );
/* Cannot happen */ /* Cannot happen */
break; break;
} }
case mediacontrol_ByteCount: case mediacontrol_ByteCount:
if (p_input->stream.i_mux_rate == 0) if( p_input->stream.i_mux_rate == 0 )
return 0; return 0;
/* Convert an offset into milliseconds. Taken from input_ext-intf.c.
The 50 hardcoded constant comes from the definition of i_mux_rate :
i_mux_rate : the rate we read the stream (in units of 50 bytes/s) ;
0 if undef */
if (to == mediacontrol_MediaTime)
return (long long) (1000 * value / 50 / p_input->stream.i_mux_rate);
if (to == mediacontrol_SampleCount) /* Convert an offset into milliseconds. Taken from input_ext-intf.c.
{ The 50 hardcoded constant comes from the definition of i_mux_rate :
double f_fps; i_mux_rate : the rate we read the stream (in units of 50 bytes/s) ;
if (demux_Control( p_input, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1) 0 if undef */
return 0; if( to == mediacontrol_MediaTime )
else return ( long long )( 1000 * value / 50 / p_input->stream.i_mux_rate );
return (long long)(value * f_fps / 50 / p_input->stream.i_mux_rate);
} if( to == mediacontrol_SampleCount )
/* Cannot happen */ {
break; double f_fps;
} if( demux_Control( p_input, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
/* Cannot happen */ return 0;
return 0; else
return ( long long )( value * f_fps / 50 / p_input->stream.i_mux_rate );
}
/* Cannot happen */
break;
}
/* Cannot happen */
return 0;
} }
/* Converts a mediacontrol_Position into a time in microseconds in /* Converts a mediacontrol_Position into a time in microseconds in
movie clock time */ movie clock time */
long long long long
mediacontrol_position2microsecond (input_thread_t* p_input, const mediacontrol_Position * pos) mediacontrol_position2microsecond( input_thread_t* p_input, const mediacontrol_Position * pos )
{ {
switch (pos->origin) switch( pos->origin )
{ {
case mediacontrol_AbsolutePosition: case mediacontrol_AbsolutePosition:
return (1000 * mediacontrol_unit_convert(p_input, return ( 1000 * mediacontrol_unit_convert( p_input,
pos->key, /* from */ pos->key, /* from */
mediacontrol_MediaTime, /* to */ mediacontrol_MediaTime, /* to */
pos->value)); pos->value ) );
break; break;
case mediacontrol_RelativePosition: case mediacontrol_RelativePosition:
{ {
off_t l_offset; long long l_pos;
long long l_current; vlc_value_t val;
long long l_pos;
val.i_time = 0;
vlc_mutex_lock( &p_input->stream.stream_lock ); var_Get( p_input, "time", &val );
l_offset = p_input->stream.p_selected_area->i_tell;
vlc_mutex_unlock( &p_input->stream.stream_lock ); l_pos = 1000 * mediacontrol_unit_convert( p_input,
pos->key,
l_current = 1000 * mediacontrol_unit_convert(p_input, mediacontrol_MediaTime,
mediacontrol_ByteCount, pos->value );
mediacontrol_MediaTime, return val.i_time + l_pos;
l_offset); break;
l_pos = 1000 * mediacontrol_unit_convert(p_input, }
pos->key,
mediacontrol_MediaTime,
pos->value);
return l_current + l_pos;
break;
}
case mediacontrol_ModuloPosition: case mediacontrol_ModuloPosition:
{ {
long long l_duration; long long l_pos;
long long l_pos; vlc_value_t val;
l_duration = 1000 * mediacontrol_unit_convert(p_input, val.i_time = 0;
mediacontrol_ByteCount, var_Get( p_input, "length", &val );
mediacontrol_MediaTime,
p_input->stream.p_selected_area->i_size); if( val.i_time > 0)
l_pos = (1000 * mediacontrol_unit_convert(p_input, {
pos->key, /* from */ l_pos = ( 1000 * mediacontrol_unit_convert( p_input,
mediacontrol_MediaTime, /* to */ pos->key,
pos->value)); mediacontrol_MediaTime,
return l_pos % l_duration; pos->value ) );
break; }
} else
} l_pos = 0;
return 0;
return l_pos % val.i_time;
break;
}
}
return 0;
} }
mediacontrol_RGBPicture* mediacontrol_RGBPicture*
mediacontrol_RGBPicture__alloc (int datasize) mediacontrol_RGBPicture__alloc( int datasize )
{ {
mediacontrol_RGBPicture* pic; mediacontrol_RGBPicture* pic;
pic = (mediacontrol_RGBPicture*)malloc(sizeof(mediacontrol_RGBPicture)); pic = ( mediacontrol_RGBPicture * )malloc( sizeof( mediacontrol_RGBPicture ) );
if (! pic) if( ! pic )
return NULL; return NULL;
pic->size = datasize; pic->size = datasize;
pic->data = (char*)malloc(datasize); pic->data = ( char* )malloc( datasize );
return pic; return pic;
} }
void void
mediacontrol_RGBPicture__free (mediacontrol_RGBPicture* pic) mediacontrol_RGBPicture__free( mediacontrol_RGBPicture* pic )
{ {
if (pic) if( pic )
free(pic->data); free( pic->data );
free(pic); free( pic );
} }
mediacontrol_PlaylistSeq* mediacontrol_PlaylistSeq*
mediacontrol_PlaylistSeq__alloc (int size) mediacontrol_PlaylistSeq__alloc( int size )
{ {
mediacontrol_PlaylistSeq* ps; mediacontrol_PlaylistSeq* ps;
ps = (mediacontrol_PlaylistSeq*)malloc(sizeof(mediacontrol_PlaylistSeq)); ps =( mediacontrol_PlaylistSeq* )malloc( sizeof( mediacontrol_PlaylistSeq ) );
if (! ps) if( ! ps )
return NULL; return NULL;
ps->size = size; ps->size = size;
ps->data = (char**)malloc(size * sizeof(char*)); ps->data = ( char** )malloc( size * sizeof( char* ) );
return ps; return ps;
} }
void void
mediacontrol_PlaylistSeq__free (mediacontrol_PlaylistSeq* ps) mediacontrol_PlaylistSeq__free( mediacontrol_PlaylistSeq* ps )
{ {
if (ps) if( ps )
{ {
int i; int i;
for (i = 0; i < ps->size; i++) for( i = 0 ; i < ps->size ; i++ )
free(ps->data[i]); free( ps->data[i] );
} }
free(ps->data); free( ps->data );
free(ps); free( ps );
} }
mediacontrol_Exception* mediacontrol_Exception*
mediacontrol_exception_init(mediacontrol_Exception *exception) mediacontrol_exception_init( mediacontrol_Exception *exception )
{ {
if (exception == NULL) if( exception == NULL )
{ {
exception = (mediacontrol_Exception*)malloc(sizeof(mediacontrol_Exception)); exception = ( mediacontrol_Exception* )malloc( sizeof( mediacontrol_Exception ) );
} }
exception->code = 0; exception->code = 0;
exception->message = NULL; exception->message = NULL;
return exception; return exception;
} }
void void
mediacontrol_exception_free(mediacontrol_Exception *exception) mediacontrol_exception_free( mediacontrol_Exception *exception )
{ {
if (! exception) if( ! exception )
return; return;
free(exception->message); free( exception->message );
free(exception); free( exception );
} }
mediacontrol_Instance* mediacontrol_new_from_object(vlc_object_t* p_object, mediacontrol_Instance* mediacontrol_new_from_object( vlc_object_t* p_object,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
mediacontrol_Instance* retval; mediacontrol_Instance* retval;
vlc_object_t *p_vlc; vlc_object_t *p_vlc;
p_vlc = vlc_object_find(p_object, VLC_OBJECT_ROOT, FIND_PARENT); p_vlc = vlc_object_find( p_object, VLC_OBJECT_ROOT, FIND_PARENT );
if (! p_vlc) if( ! p_vlc )
{ {
RAISE(mediacontrol_InternalException, "Unable to initialize VLC"); RAISE( mediacontrol_InternalException, "Unable to initialize VLC" );
return NULL; return NULL;
} }
retval = (mediacontrol_Instance*)malloc(sizeof(mediacontrol_Instance)); retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
retval->p_vlc = p_vlc; retval->p_vlc = p_vlc;
retval->vlc_object_id = p_vlc->i_object_id; retval->vlc_object_id = p_vlc->i_object_id;
/* We can keep references on these, which should not change. Is it true ? */ /* We can keep references on these, which should not change. Is it true ? */
retval->p_playlist = vlc_object_find(p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE); retval->p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
retval->p_intf = vlc_object_find(p_vlc, VLC_OBJECT_INTF, FIND_ANYWHERE); retval->p_intf = vlc_object_find( p_vlc, VLC_OBJECT_INTF, FIND_ANYWHERE );
if (! retval->p_playlist || ! retval->p_intf) if( ! retval->p_playlist || ! retval->p_intf )
{ {
RAISE(mediacontrol_InternalException, "No available interface"); RAISE( mediacontrol_InternalException, "No available interface" );
return NULL; return NULL;
} }
return retval; return retval;
}; };
/* Returns the current position in the stream. The returned value can /* Returns the current position in the stream. The returned value can
be relative or absolute (according to PositionOrigin) and the unit be relative or absolute( according to PositionOrigin ) and the unit
is set by PositionKey */ is set by PositionKey */
mediacontrol_Position* mediacontrol_Position*
mediacontrol_get_media_position(mediacontrol_Instance *self, mediacontrol_get_media_position( mediacontrol_Instance *self,
const mediacontrol_PositionOrigin an_origin, const mediacontrol_PositionOrigin an_origin,
const mediacontrol_PositionKey a_key, const mediacontrol_PositionKey a_key,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
mediacontrol_Position* retval; mediacontrol_Position* retval;
off_t l_offset; vlc_value_t val;
input_thread_t * p_input = self->p_playlist->p_input;; input_thread_t * p_input = self->p_playlist->p_input;
exception=mediacontrol_exception_init(exception); exception = mediacontrol_exception_init( exception );
retval = (mediacontrol_Position*)malloc(sizeof(mediacontrol_Position)); retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) );
retval->origin = an_origin; retval->origin = an_origin;
retval->key = a_key; retval->key = a_key;
if (! p_input) if( ! p_input )
{ {
/* /*
RAISE(mediacontrol_InternalException, "No input thread."); RAISE( mediacontrol_InternalException, "No input thread." );
return(NULL); return( NULL );
*/ */
retval->value = 0; retval->value = 0;
return retval; return retval;
} }
if ( an_origin == mediacontrol_RelativePosition if( an_origin == mediacontrol_RelativePosition
|| an_origin == mediacontrol_ModuloPosition ) || an_origin == mediacontrol_ModuloPosition )
{ {
/* Relative or ModuloPosition make no sense */ /* Relative or ModuloPosition make no sense */
retval->value = 0; retval->value = 0;
return retval; return retval;
} }
/* We are asked for an AbsolutePosition. */ /* We are asked for an AbsolutePosition. */
vlc_mutex_lock( &p_input->stream.stream_lock ); val.i_time = 0;
l_offset = p_input->stream.p_selected_area->i_tell; var_Get( p_input, "time", &val );
vlc_mutex_unlock( &p_input->stream.stream_lock ); /* FIXME: check val.i_time > 0 */
retval->value = mediacontrol_unit_convert(p_input, retval->value = mediacontrol_unit_convert( p_input,
mediacontrol_ByteCount, mediacontrol_MediaTime,
a_key, a_key,
l_offset); val.i_time / 1000 );
return retval; return retval;
} }
/* Sets the media position */ /* Sets the media position */
void void
mediacontrol_set_media_position(mediacontrol_Instance *self, mediacontrol_set_media_position( mediacontrol_Instance *self,
const mediacontrol_Position * a_position, const mediacontrol_Position * a_position,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
off_t l_offset_destination = 0; vlc_value_t val;
int i_whence = 0;
input_thread_t * p_input = self->p_playlist->p_input; input_thread_t * p_input = self->p_playlist->p_input;
exception=mediacontrol_exception_init(exception); exception=mediacontrol_exception_init( exception );
if (! p_input) if( ! p_input )
{ {
RAISE(mediacontrol_InternalException, "No input thread."); RAISE( mediacontrol_InternalException, "No input thread." );
return; return;
} }
if ( !p_input->stream.b_seekable ) if( !p_input->stream.b_seekable )
{ {
RAISE(mediacontrol_InvalidPosition, "Stream not seekable"); RAISE( mediacontrol_InvalidPosition, "Stream not seekable" );
return; return;
} }
/* FIXME FIXME FIXME input_Seek is deprecated, and I don't know how to fix that --fenrir */ val.i_time = mediacontrol_position2microsecond( p_input, a_position );
/* You need to do a var_SetFloat( p_input, pos ); where pos is a float between 0.0 and 1.0 */ var_Set( p_input, "time", val );
RAISE(mediacontrol_InvalidPosition, "mediacontrol_set_media_position is not usable for now"); return;
return
#if 0
l_offset_destination = a_position->value;
i_whence |= INPUT_SEEK_BYTES;
l_offset_destination = mediacontrol_unit_convert(p_input,
a_position->key,
mediacontrol_ByteCount,
l_offset_destination);
switch ( a_position->origin)
{
case mediacontrol_RelativePosition:
i_whence |= INPUT_SEEK_CUR;
break;
case mediacontrol_ModuloPosition:
i_whence |= INPUT_SEEK_END;
break;
case mediacontrol_AbsolutePosition:
i_whence |= INPUT_SEEK_SET;
break;
default:
i_whence |= INPUT_SEEK_SET;
break;
}
/* Now we can set the position. The lock is taken in the input_Seek
function (cf input_ext-intf.c) */
input_Seek (p_input, l_offset_destination, i_whence);
return;
#endif
} }
/* Starts playing a stream */ /* Starts playing a stream */
void void
mediacontrol_start(mediacontrol_Instance *self, mediacontrol_start( mediacontrol_Instance *self,
const mediacontrol_Position * a_position, const mediacontrol_Position * a_position,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
playlist_t * p_playlist = self->p_playlist; playlist_t * p_playlist = self->p_playlist;
exception=mediacontrol_exception_init(exception); exception = mediacontrol_exception_init( exception );
if (! p_playlist) if( ! p_playlist )
{ {
RAISE(mediacontrol_PlaylistException, "No available playlist"); RAISE( mediacontrol_PlaylistException, "No available playlist" );
return; return;
} }
vlc_mutex_lock( &p_playlist->object_lock ); vlc_mutex_lock( &p_playlist->object_lock );
if (p_playlist->i_size) if( p_playlist->i_size )
{ {
vlc_value_t val; vlc_value_t val;
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
/* Set start time */ /* Set start time */
val.i_int = mediacontrol_position2microsecond(p_playlist->p_input, a_position) / 1000000; val.i_int = mediacontrol_position2microsecond( p_playlist->p_input, a_position ) / 1000000;
var_Set (p_playlist, "start-time", val); var_Set( p_playlist, "start-time", val );
playlist_Play( p_playlist ); playlist_Play( p_playlist );
} }
else else
{ {
RAISE(mediacontrol_PlaylistException, "Empty playlist."); RAISE( mediacontrol_PlaylistException, "Empty playlist." );
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
return; return;
} }
return; return;
} }
void void
mediacontrol_pause(mediacontrol_Instance *self, mediacontrol_pause( mediacontrol_Instance *self,
const mediacontrol_Position * a_position, const mediacontrol_Position * a_position,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
input_thread_t *p_input = self->p_playlist->p_input;; input_thread_t *p_input = self->p_playlist->p_input;;
/* FIXME: use the a_position parameter */ /* FIXME: use the a_position parameter */
exception=mediacontrol_exception_init(exception); exception=mediacontrol_exception_init( exception );
if (p_input != NULL) if( p_input != NULL )
{ {
var_SetInteger( p_input, "state", PAUSE_S ); var_SetInteger( p_input, "state", PAUSE_S );
} }
else else
{ {
RAISE(mediacontrol_InternalException, "No input"); RAISE( mediacontrol_InternalException, "No input" );
} }
return;
} }
void void
mediacontrol_resume(mediacontrol_Instance *self, mediacontrol_resume( mediacontrol_Instance *self,
const mediacontrol_Position * a_position, const mediacontrol_Position * a_position,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
input_thread_t *p_input = self->p_playlist->p_input; input_thread_t *p_input = self->p_playlist->p_input;
/* FIXME: use the a_position parameter */ /* FIXME: use the a_position parameter */
exception=mediacontrol_exception_init(exception); exception=mediacontrol_exception_init( exception );
if (p_input != NULL) if( p_input != NULL )
{ {
var_SetInteger( p_input, "state", PAUSE_S ); var_SetInteger( p_input, "state", PAUSE_S );
} }
else else
{ {
RAISE(mediacontrol_InternalException, "No input"); RAISE( mediacontrol_InternalException, "No input" );
} }
} }
void void
mediacontrol_stop(mediacontrol_Instance *self, mediacontrol_stop( mediacontrol_Instance *self,
const mediacontrol_Position * a_position, const mediacontrol_Position * a_position,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
/* FIXME: use the a_position parameter */ /* FIXME: use the a_position parameter */
exception=mediacontrol_exception_init(exception); exception=mediacontrol_exception_init( exception );
if (!self->p_playlist) if( !self->p_playlist )
{ {
RAISE(mediacontrol_PlaylistException, "No playlist"); RAISE( mediacontrol_PlaylistException, "No playlist" );
return; return;
} }
playlist_Stop( self->p_playlist ); playlist_Stop( self->p_playlist );
return;
} }
void void
mediacontrol_playlist_add_item(mediacontrol_Instance *self, mediacontrol_playlist_add_item( mediacontrol_Instance *self,
const char * psz_file, const char * psz_file,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
exception=mediacontrol_exception_init(exception); exception=mediacontrol_exception_init( exception );
if (!self->p_playlist) if( !self->p_playlist )
{ {
RAISE(mediacontrol_InternalException, "No playlist"); RAISE( mediacontrol_InternalException, "No playlist" );
return; return;
} }
playlist_Add (self->p_playlist, psz_file, psz_file , PLAYLIST_REPLACE, 0); playlist_Add( self->p_playlist, psz_file, psz_file , PLAYLIST_REPLACE, 0 );
return;
} }
void void
mediacontrol_playlist_clear(mediacontrol_Instance *self, mediacontrol_playlist_clear( mediacontrol_Instance *self,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
int i_index; exception=mediacontrol_exception_init( exception );
if( !self->p_playlist )
exception=mediacontrol_exception_init(exception);
if (!self->p_playlist)
{ {
RAISE(mediacontrol_PlaylistException, "No playlist"); RAISE( mediacontrol_PlaylistException, "No playlist" );
return; return;
} }
for (i_index = 0 ; i_index < self->p_playlist->i_size ; i_index++) playlist_Clear( self->p_playlist );
{
playlist_Delete (self->p_playlist, i_index);
}
return; return;
} }
mediacontrol_PlaylistSeq * mediacontrol_PlaylistSeq *
mediacontrol_playlist_get_list(mediacontrol_Instance *self, mediacontrol_playlist_get_list( mediacontrol_Instance *self,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
mediacontrol_PlaylistSeq *retval; mediacontrol_PlaylistSeq *retval;
int i_index; int i_index;
playlist_t * p_playlist = self->p_playlist;; playlist_t * p_playlist = self->p_playlist;;
int i_playlist_size; int i_playlist_size;
exception=mediacontrol_exception_init(exception); exception=mediacontrol_exception_init( exception );
if (!p_playlist) if( !p_playlist )
{ {
RAISE(mediacontrol_PlaylistException, "No playlist"); RAISE( mediacontrol_PlaylistException, "No playlist" );
return NULL; return NULL;
} }
vlc_mutex_lock( &p_playlist->object_lock ); vlc_mutex_lock( &p_playlist->object_lock );
i_playlist_size = p_playlist->i_size; i_playlist_size = p_playlist->i_size;
retval = mediacontrol_PlaylistSeq__alloc(i_playlist_size); retval = mediacontrol_PlaylistSeq__alloc( i_playlist_size );
for (i_index = 0 ; i_index < i_playlist_size ; i_index++) for( i_index = 0 ; i_index < i_playlist_size ; i_index++ )
{ {
retval->data[i_index] = strdup (p_playlist->pp_items[i_index]->input.psz_uri); retval->data[i_index] = strdup( p_playlist->pp_items[i_index]->input.psz_uri );
} }
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
return retval; return retval;
} }
mediacontrol_RGBPicture* mediacontrol_RGBPicture*
_mediacontrol_createRGBPicture (int i_width, int i_height, long i_chroma, long long l_date, _mediacontrol_createRGBPicture( int i_width, int i_height, long i_chroma, long long l_date,
char* p_data, int i_datasize) char* p_data, int i_datasize )
{ {
mediacontrol_RGBPicture *retval; mediacontrol_RGBPicture *retval;
retval = mediacontrol_RGBPicture__alloc (i_datasize); retval = mediacontrol_RGBPicture__alloc( i_datasize );
if (retval) if( retval )
{ {
retval->width = i_width; retval->width = i_width;
retval->height = i_height; retval->height = i_height;
retval->type = i_chroma; retval->type = i_chroma;
retval->date = l_date; retval->date = l_date;
retval->size = i_datasize; retval->size = i_datasize;
memcpy (retval->data, p_data, i_datasize); memcpy( retval->data, p_data, i_datasize );
} }
return retval; return retval;
} }
mediacontrol_RGBPicture * mediacontrol_RGBPicture *
mediacontrol_snapshot(mediacontrol_Instance *self, mediacontrol_snapshot( mediacontrol_Instance *self,
const mediacontrol_Position * a_position, const mediacontrol_Position * a_position,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
mediacontrol_RGBPicture *retval = NULL; mediacontrol_RGBPicture *retval = NULL;
input_thread_t* p_input = self->p_playlist->p_input; input_thread_t* p_input = self->p_playlist->p_input;
vout_thread_t *p_vout = NULL; vout_thread_t *p_vout = NULL;
int i_datasize; int i_datasize;
snapshot_t **pointer; snapshot_t **pointer;
vlc_value_t val; vlc_value_t val;
int i_index; int i_index;
snapshot_t *p_best_snapshot; snapshot_t *p_best_snapshot;
long searched_date; long searched_date;
#ifdef HAS_SNAPSHOT #ifdef HAS_SNAPSHOT
int i_cachesize; int i_cachesize;
#endif #endif
exception=mediacontrol_exception_init(exception); exception=mediacontrol_exception_init( exception );
/* /*
if (var_Get (self->p_vlc, "snapshot-id", &val) == VLC_SUCCESS) if( var_Get( self->p_vlc, "snapshot-id", &val ) == VLC_SUCCESS )
p_vout = vlc_object_get (self->p_vlc, val.i_int); p_vout = vlc_object_get( self->p_vlc, val.i_int );
*/ */
/* FIXME: if in p_libvlc, we cannot have multiple video outputs */ /* FIXME: if in p_libvlc, we cannot have multiple video outputs */
/* Once corrected, search for snapshot-id to modify all instances */ /* Once corrected, search for snapshot-id to modify all instances */
if (var_Get (p_input, "snapshot-id", &val) != VLC_SUCCESS) if( var_Get( p_input, "snapshot-id", &val ) != VLC_SUCCESS )
{ {
RAISE(mediacontrol_InternalException, "No snapshot-id in p_input"); RAISE( mediacontrol_InternalException, "No snapshot-id in p_input" );
return NULL; return NULL;
} }
p_vout = vlc_object_get (self->p_vlc, val.i_int); p_vout = vlc_object_get( self->p_vlc, val.i_int );
if (! p_vout) if( ! p_vout )
{ {
RAISE(mediacontrol_InternalException, "No snapshot module"); RAISE( mediacontrol_InternalException, "No snapshot module" );
return NULL; return NULL;
} }
#ifdef HAS_SNAPSHOT #ifdef HAS_SNAPSHOT
/* We test if the vout is a snapshot module. We cannot test /* We test if the vout is a snapshot module. We cannot test
pvout_psz_object_name (which is NULL). But we can check if pvout_psz_object_name( which is NULL ). But we can check if
there are snapshot-specific variables */ there are snapshot-specific variables */
if (var_Get( p_vout, "snapshot-datasize", &val ) != VLC_SUCCESS) if( var_Get( p_vout, "snapshot-datasize", &val ) != VLC_SUCCESS )
{ {
RAISE(mediacontrol_InternalException, "No snapshot module"); RAISE( mediacontrol_InternalException, "No snapshot module" );
vlc_object_release(p_vout); vlc_object_release( p_vout );
return NULL; return NULL;
} }
i_datasize = val.i_int; i_datasize = val.i_int;
/* Handle the a_position parameter */
if (! (a_position->origin == mediacontrol_RelativePosition
&& a_position->value == 0))
{
/* The position is not the current one. Go to it. */
mediacontrol_set_media_position (self, (mediacontrol_Position*)a_position, exception);
if (exception->code)
{
vlc_object_release(p_vout);
return NULL;
}
}
/* FIXME: We should not go further until we got past the position
(which means that we had the possibility to capture the right
picture). */
vlc_mutex_lock( &p_vout->picture_lock ); /* Handle the a_position parameter */
if( ! ( a_position->origin == mediacontrol_RelativePosition
&& a_position->value == 0 ) )
{
/* The position is not the current one. Go to it. */
mediacontrol_set_media_position( self,
( mediacontrol_Position* ) a_position,
exception );
if( exception->code )
{
vlc_object_release( p_vout );
return NULL;
}
}
/* FIXME: We should not go further until we got past the position
( which means that we had the possibility to capture the right
picture ). */
searched_date = mediacontrol_position2microsecond (p_input, vlc_mutex_lock( &p_vout->picture_lock );
(mediacontrol_Position *)a_position);
var_Get( p_vout, "snapshot-cache-size", &val ); searched_date = mediacontrol_position2microsecond( p_input,
i_cachesize = val.i_int ; ( mediacontrol_Position * ) a_position );
var_Get( p_vout, "snapshot-cache-size", &val );
i_cachesize = val.i_int ;
var_Get( p_vout, "snapshot-list-pointer", &val ); var_Get( p_vout, "snapshot-list-pointer", &val );
pointer = (snapshot_t **)val.p_address; pointer = ( snapshot_t ** )val.p_address;
if (! pointer) if( ! pointer )
{ {
RAISE(mediacontrol_InternalException, "No available snapshot"); RAISE( mediacontrol_InternalException, "No available snapshot" );
vlc_mutex_unlock( &p_vout->picture_lock ); vlc_mutex_unlock( &p_vout->picture_lock );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
return NULL; return NULL;
} }
/* Find the more appropriate picture, based on date */ /* Find the more appropriate picture, based on date */
p_best_snapshot = pointer[0]; p_best_snapshot = pointer[0];
for (i_index = 1 ; i_index < i_cachesize ; i_index++) for( i_index = 1 ; i_index < i_cachesize ; i_index++ )
{ {
long l_diff = pointer[i_index]->date - searched_date; long l_diff = pointer[i_index]->date - searched_date;
if (l_diff > 0 && l_diff < abs(p_best_snapshot->date - searched_date)) if( l_diff > 0 && l_diff < abs( p_best_snapshot->date - searched_date ))
{ {
/* This one is closer, and _after_ the requested position */ /* This one is closer, and _after_ the requested position */
p_best_snapshot = pointer[i_index]; p_best_snapshot = pointer[i_index];
} }
} }
/* FIXME: add a test for the case that no picture matched the test /* FIXME: add a test for the case that no picture matched the test
(we have p_best_snapshot == pointer[0] */ ( we have p_best_snapshot == pointer[0] */
retval = _mediacontrol_createRGBPicture (p_best_snapshot->i_width, retval = _mediacontrol_createRGBPicture( p_best_snapshot->i_width,
p_best_snapshot->i_height, p_best_snapshot->i_height,
p_vout->output.i_chroma, p_vout->output.i_chroma,
p_best_snapshot->date, p_best_snapshot->date,
p_best_snapshot->p_data, p_best_snapshot->p_data,
i_datasize); i_datasize );
vlc_mutex_unlock( &p_vout->picture_lock ); vlc_mutex_unlock( &p_vout->picture_lock );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
#endif #endif
return retval; return retval;
} }
mediacontrol_RGBPicture ** mediacontrol_RGBPicture **
mediacontrol_all_snapshots(mediacontrol_Instance *self, mediacontrol_all_snapshots( mediacontrol_Instance *self,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
mediacontrol_RGBPicture **retval = NULL; mediacontrol_RGBPicture **retval = NULL;
vout_thread_t *p_vout = NULL; vout_thread_t *p_vout = NULL;
int i_datasize; int i_datasize;
int i_cachesize; int i_cachesize;
vlc_value_t val; vlc_value_t val;
int i_index; int i_index;
#ifdef HAS_SNAPSHOT #ifdef HAS_SNAPSHOT
snapshot_t **pointer; snapshot_t **pointer;
#endif #endif
exception=mediacontrol_exception_init(exception); exception=mediacontrol_exception_init( exception );
if (var_Get (self->p_playlist->p_input, "snapshot-id", &val) == VLC_SUCCESS) if( var_Get( self->p_playlist->p_input, "snapshot-id", &val ) == VLC_SUCCESS )
p_vout = vlc_object_get (self->p_vlc, val.i_int); p_vout = vlc_object_get( self->p_vlc, val.i_int );
if (! p_vout) if( ! p_vout )
{ {
RAISE(mediacontrol_InternalException, "No snapshot module"); RAISE( mediacontrol_InternalException, "No snapshot module" );
return NULL; return NULL;
} }
#ifdef HAS_SNAPSHOT #ifdef HAS_SNAPSHOT
/* We test if the vout is a snapshot module. We cannot test /* We test if the vout is a snapshot module. We cannot test
pvout_psz_object_name (which is NULL). But we can check if pvout_psz_object_name( which is NULL ). But we can check if
there are snapshot-specific variables */ there are snapshot-specific variables */
if (var_Get( p_vout, "snapshot-datasize", &val ) != VLC_SUCCESS) if( var_Get( p_vout, "snapshot-datasize", &val ) != VLC_SUCCESS )
{ {
RAISE(mediacontrol_InternalException, "No snapshot module"); RAISE( mediacontrol_InternalException, "No snapshot module" );
vlc_object_release(p_vout); vlc_object_release( p_vout );
return NULL; return NULL;
} }
i_datasize = val.i_int; i_datasize = val.i_int;
vlc_mutex_lock( &p_vout->picture_lock ); vlc_mutex_lock( &p_vout->picture_lock );
var_Get( p_vout, "snapshot-cache-size", &val ); var_Get( p_vout, "snapshot-cache-size", &val );
i_cachesize = val.i_int ; i_cachesize = val.i_int ;
var_Get( p_vout, "snapshot-list-pointer", &val ); var_Get( p_vout, "snapshot-list-pointer", &val );
pointer = (snapshot_t **)val.p_address; pointer = ( snapshot_t ** )val.p_address;
if (! pointer) if( ! pointer )
{ {
RAISE(mediacontrol_InternalException, "No available picture"); RAISE( mediacontrol_InternalException, "No available picture" );
vlc_mutex_unlock( &p_vout->picture_lock ); vlc_mutex_unlock( &p_vout->picture_lock );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
return NULL; return NULL;
} }
retval = (mediacontrol_RGBPicture**)malloc((i_cachesize + 1) * sizeof(char*)); retval = ( mediacontrol_RGBPicture** )malloc( (i_cachesize + 1 ) * sizeof( char* ));
for (i_index = 0 ; i_index < i_cachesize ; i_index++) for( i_index = 0 ; i_index < i_cachesize ; i_index++ )
{ {
snapshot_t *p_s = pointer[i_index]; snapshot_t *p_s = pointer[i_index];
mediacontrol_RGBPicture *p_rgb; mediacontrol_RGBPicture *p_rgb;
p_rgb = _mediacontrol_createRGBPicture (p_s->i_width, p_rgb = _mediacontrol_createRGBPicture( p_s->i_width,
p_s->i_height, p_s->i_height,
p_vout->output.i_chroma, p_vout->output.i_chroma,
p_s->date, p_s->date,
p_s->p_data, p_s->p_data,
i_datasize); i_datasize );
retval[i_index] = p_rgb; retval[i_index] = p_rgb;
} }
retval[i_cachesize] = NULL; retval[i_cachesize] = NULL;
vlc_mutex_unlock( &p_vout->picture_lock ); vlc_mutex_unlock( &p_vout->picture_lock );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
#endif #endif
return retval; return retval;
} }
void void
mediacontrol_display_text(mediacontrol_Instance *self, mediacontrol_display_text( mediacontrol_Instance *self,
const char * message, const char * message,
const mediacontrol_Position * begin, const mediacontrol_Position * begin,
const mediacontrol_Position * end, const mediacontrol_Position * end,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
input_thread_t *p_input = NULL; input_thread_t *p_input = NULL;
vout_thread_t *p_vout = NULL; vout_thread_t *p_vout = NULL;
p_vout = vlc_object_find( self->p_vlc, VLC_OBJECT_VOUT, FIND_ANYWHERE ); p_vout = vlc_object_find( self->p_playlist, VLC_OBJECT_VOUT, FIND_CHILD );
if (! p_vout) if( ! p_vout )
{ {
RAISE(mediacontrol_InternalException, "No video output"); RAISE( mediacontrol_InternalException, "No video output" );
return; return;
} }
if (begin->origin == mediacontrol_RelativePosition && if( begin->origin == mediacontrol_RelativePosition &&
begin->value == 0 && begin->value == 0 &&
end->origin == mediacontrol_RelativePosition) end->origin == mediacontrol_RelativePosition )
{ {
mtime_t i_duration = 0; mtime_t i_duration = 0;
i_duration = 1000 * mediacontrol_unit_convert(self->p_playlist->p_input, i_duration = 1000 * mediacontrol_unit_convert( self->p_playlist->p_input,
end->key, end->key,
mediacontrol_MediaTime, mediacontrol_MediaTime,
end->value); end->value );
vout_ShowTextRelative( p_vout, (char*)message, NULL, vout_ShowTextRelative( p_vout, ( char* ) message, NULL,
OSD_ALIGN_BOTTOM|OSD_ALIGN_LEFT, 20, 20, OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 20, 20,
i_duration ); i_duration );
} }
else else
{ {
mtime_t i_debut, i_fin, i_now; mtime_t i_debut, i_fin, i_now;
p_input = self->p_playlist->p_input; p_input = self->p_playlist->p_input;
if (! p_input) if( ! p_input )
{ {
RAISE(mediacontrol_InternalException, "No input"); RAISE( mediacontrol_InternalException, "No input" );
vlc_object_release(p_vout); vlc_object_release( p_vout );
return; return;
} }
i_now = input_ClockGetTS (p_input, NULL, 0); i_now = input_ClockGetTS( p_input, NULL, 0 );
i_debut = mediacontrol_position2microsecond (p_input, (mediacontrol_Position *) begin); i_debut = mediacontrol_position2microsecond( p_input,
i_debut += i_now; ( mediacontrol_Position* ) begin );
i_debut += i_now;
i_fin = mediacontrol_position2microsecond (p_input, (mediacontrol_Position *) end); i_fin = mediacontrol_position2microsecond( p_input,
i_fin += i_now; ( mediacontrol_Position * ) end );
i_fin += i_now;
vout_ShowTextAbsolute( p_vout, (char*)message, NULL, vout_ShowTextAbsolute( p_vout,( char* )message, NULL,
OSD_ALIGN_BOTTOM|OSD_ALIGN_LEFT, 20, 20, OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 20, 20,
i_debut, i_fin ); i_debut, i_fin );
} }
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
mediacontrol_StreamInformation * mediacontrol_StreamInformation *
mediacontrol_get_stream_information(mediacontrol_Instance *self, mediacontrol_get_stream_information( mediacontrol_Instance *self,
mediacontrol_PositionKey a_key, mediacontrol_PositionKey a_key,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
mediacontrol_StreamInformation *retval; mediacontrol_StreamInformation *retval;
input_thread_t *p_input = self->p_playlist->p_input; input_thread_t *p_input = self->p_playlist->p_input;
vlc_value_t val;
retval = (mediacontrol_StreamInformation*)malloc(sizeof(mediacontrol_StreamInformation)); retval = ( mediacontrol_StreamInformation* )malloc( sizeof( mediacontrol_StreamInformation ) );
if (! retval) if( ! retval )
{ {
RAISE(mediacontrol_InternalException, "Out of memory"); RAISE( mediacontrol_InternalException, "Out of memory" );
return NULL; return NULL;
} }
if (! p_input) if( ! p_input )
{ {
/* No p_input defined */ /* No p_input defined */
retval->streamstatus = mediacontrol_UndefinedStatus; retval->streamstatus = mediacontrol_UndefinedStatus;
retval->url = strdup ("None"); retval->url = strdup( "None" );
retval->position = 0; retval->position = 0;
retval->length = 0; retval->length = 0;
} }
else else
{ {
switch (p_input->stream.control.i_status) switch( p_input->stream.control.i_status )
{ {
case UNDEF_S : case UNDEF_S :
retval->streamstatus = mediacontrol_UndefinedStatus; retval->streamstatus = mediacontrol_UndefinedStatus;
break; break;
case PLAYING_S : case PLAYING_S :
retval->streamstatus = mediacontrol_PlayingStatus; retval->streamstatus = mediacontrol_PlayingStatus;
break; break;
case PAUSE_S : case PAUSE_S :
retval->streamstatus = mediacontrol_PauseStatus; retval->streamstatus = mediacontrol_PauseStatus;
break; break;
case FORWARD_S : case FORWARD_S :
retval->streamstatus = mediacontrol_ForwardStatus; retval->streamstatus = mediacontrol_ForwardStatus;
break; break;
case BACKWARD_S : case BACKWARD_S :
retval->streamstatus = mediacontrol_BackwardStatus; retval->streamstatus = mediacontrol_BackwardStatus;
break; break;
case INIT_S : case INIT_S :
retval->streamstatus = mediacontrol_InitStatus; retval->streamstatus = mediacontrol_InitStatus;
break; break;
case END_S : case END_S :
retval->streamstatus = mediacontrol_EndStatus; retval->streamstatus = mediacontrol_EndStatus;
break; break;
default : default :
retval->streamstatus = mediacontrol_UndefinedStatus; retval->streamstatus = mediacontrol_UndefinedStatus;
break; break;
} }
retval->url = strdup (p_input->psz_source); retval->url = strdup( p_input->psz_source );
demux_Control(p_input, DEMUX_GET_TIME, &(retval->position)); /* TIME and LENGTH are in microseconds. We want them in ms */
demux_Control(p_input, DEMUX_GET_LENGTH, &(retval->length)); var_Get( p_input, "time", &val);
/* TIME and LENGTH are in microseconds. We want them in ms */ retval->position = val.i_time / 1000;
retval->position /= 1000;
retval->length /= 1000; var_Get( p_input, "length", &val);
retval->length = val.i_time / 1000;
retval->position = mediacontrol_unit_convert(p_input,
mediacontrol_MediaTime, a_key, retval->position = mediacontrol_unit_convert( p_input,
retval->position); mediacontrol_MediaTime, a_key,
retval->length = mediacontrol_unit_convert(p_input, retval->position );
mediacontrol_MediaTime, a_key, retval->length = mediacontrol_unit_convert( p_input,
retval->length); mediacontrol_MediaTime, a_key,
} retval->length );
return retval; }
return retval;
} }
unsigned short unsigned short
mediacontrol_sound_get_volume(mediacontrol_Instance *self, mediacontrol_sound_get_volume( mediacontrol_Instance *self,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
short retval; short retval;
audio_volume_t i_volume; audio_volume_t i_volume;
if (!self->p_intf) if( !self->p_intf )
{ {
RAISE(mediacontrol_InternalException, "No interface module"); RAISE( mediacontrol_InternalException, "No interface module" );
return 0; return 0;
} }
aout_VolumeGet( self->p_intf, &i_volume ); aout_VolumeGet( self->p_intf, &i_volume );
retval = i_volume; retval = i_volume;
return retval; return retval;
} }
void void
mediacontrol_sound_set_volume(mediacontrol_Instance *self, mediacontrol_sound_set_volume( mediacontrol_Instance *self,
const unsigned short volume, const unsigned short volume,
mediacontrol_Exception *exception) mediacontrol_Exception *exception )
{ {
if (!self->p_intf) if( !self->p_intf )
{ {
RAISE(mediacontrol_InternalException, "No interface module"); RAISE( mediacontrol_InternalException, "No interface module" );
return; return;
} }
aout_VolumeSet( self->p_intf, (audio_volume_t)volume ); aout_VolumeSet( self->p_intf,( audio_volume_t )volume );
} }
#include "mediacontrol-core.h" #include "mediacontrol-core.h"
mediacontrol_Instance* mediacontrol_new(char** args, mediacontrol_Exception *exception) mediacontrol_Instance* mediacontrol_new( char** args, mediacontrol_Exception *exception )
{ {
mediacontrol_Instance* retval; mediacontrol_Instance* retval;
vlc_object_t *p_vlc; vlc_object_t *p_vlc;
int p_vlc_id; int p_vlc_id;
char **ppsz_argv; char **ppsz_argv;
int i_count = 0; int i_count = 0;
int i_index; int i_index;
char **p_tmp; char **p_tmp;
if (args) if( args )
{ {
for (p_tmp = args ; *p_tmp != NULL; p_tmp++) for ( p_tmp = args ; *p_tmp != NULL ; p_tmp++ )
i_count++; i_count++;
} }
ppsz_argv = malloc(i_count + 2); ppsz_argv = malloc( i_count + 2 );
ppsz_argv[0] = strdup("vlc"); ppsz_argv[0] = strdup( "vlc" );
for (i_index = 0; i_index < i_count; i_index++) for ( i_index = 0; i_index < i_count; i_index++ )
ppsz_argv[i_index+1] = strdup(args[i_index]); ppsz_argv[i_index + 1] = strdup( args[i_index] );
ppsz_argv[i_count + 1] = NULL; ppsz_argv[i_count + 1] = NULL;
p_vlc_id = VLC_Create(); p_vlc_id = VLC_Create();
p_vlc = (vlc_object_t*)vlc_current_object (p_vlc_id); p_vlc = ( vlc_object_t* )vlc_current_object( p_vlc_id );
if (! p_vlc) if( ! p_vlc )
{ {
exception->code = mediacontrol_InternalException; exception->code = mediacontrol_InternalException;
exception->message = strdup("Unable to initialize VLC"); exception->message = strdup( "Unable to initialize VLC" );
return NULL; return NULL;
} }
retval = (mediacontrol_Instance*)malloc(sizeof(mediacontrol_Instance)); retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
VLC_Init(p_vlc_id, i_count + 1, ppsz_argv); VLC_Init( p_vlc_id, i_count + 1, ppsz_argv );
retval->p_vlc = p_vlc; retval->p_vlc = p_vlc;
retval->vlc_object_id = p_vlc_id; retval->vlc_object_id = p_vlc_id;
/* We can keep references on these, which should not change. Is it true ? */ /* We can keep references on these, which should not change. Is it true ? */
retval->p_playlist = vlc_object_find(p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE); retval->p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
retval->p_intf = vlc_object_find(p_vlc, VLC_OBJECT_INTF, FIND_ANYWHERE); retval->p_intf = vlc_object_find( p_vlc, VLC_OBJECT_INTF, FIND_ANYWHERE );
if (! retval->p_playlist || ! retval->p_intf) if( ! retval->p_playlist || ! retval->p_intf )
{ {
exception->code=mediacontrol_InternalException; exception->code = mediacontrol_InternalException;
exception->message=strdup("No available interface"); exception->message = strdup( "No available interface" );
return NULL; return NULL;
} }
return retval; return retval;
}; };
void void
mediacontrol_exit(mediacontrol_Instance *self) mediacontrol_exit( mediacontrol_Instance *self )
{ {
vlc_object_release((vlc_object_t*)self->p_playlist); vlc_object_release( (vlc_object_t* )self->p_playlist );
vlc_object_release((vlc_object_t*)self->p_intf); vlc_object_release( (vlc_object_t* )self->p_intf );
VLC_CleanUp(self->vlc_object_id); VLC_CleanUp( self->vlc_object_id );
VLC_Destroy(self->vlc_object_id); VLC_Destroy( self->vlc_object_id );
} }
#include "mediacontrol-core.h" #include "mediacontrol-core.h"
#include <vlc/intf.h> #include <vlc/intf.h>
mediacontrol_Instance* mediacontrol_new(char** args, mediacontrol_Exception *exception) mediacontrol_Instance* mediacontrol_new( char** args, mediacontrol_Exception *exception )
{ {
exception->code = mediacontrol_InternalException; exception->code = mediacontrol_InternalException;
exception->message = strdup("The mediacontrol extension was compiled for plugin use only."); exception->message = strdup( "The mediacontrol extension was compiled for plugin use only." );
return NULL; return NULL;
}; };
void void
mediacontrol_exit(mediacontrol_Instance *self) mediacontrol_exit( mediacontrol_Instance *self )
{ {
vlc_object_release(self->p_playlist); vlc_object_release( self->p_playlist );
vlc_mutex_lock( &self->p_intf->change_lock ); vlc_mutex_lock( &self->p_intf->change_lock );
self->p_intf->b_die = 1; self->p_intf->b_die = 1;
vlc_mutex_unlock( &self->p_intf->change_lock ); vlc_mutex_unlock( &self->p_intf->change_lock );
vlc_object_release(self->p_intf); vlc_object_release( self->p_intf );
vlc_object_release(self->p_vlc); vlc_object_release( self->p_vlc );
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment