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