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,72 +38,73 @@
#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); \
#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); }
} 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; \
}
#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; \
}
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;
switch (exception->code)
switch( exception->code )
{
case mediacontrol_InternalException:
corba_exception = (char*)VLC_InternalException__alloc ();
corba_exception = ( char* )VLC_InternalException__alloc();
i_type = ex_VLC_InternalException;
break;
case mediacontrol_PlaylistException:
corba_exception = (char*)VLC_PlaylistException__alloc ();
corba_exception = ( char* )VLC_PlaylistException__alloc();
i_type = ex_VLC_PlaylistException;
break;
case mediacontrol_InvalidPosition:
corba_exception = (char*)VLC_InvalidPosition__alloc ();
corba_exception = ( char* )VLC_InvalidPosition__alloc();
i_type = ex_VLC_InvalidPosition;
break;
case mediacontrol_PositionKeyNotSupported:
corba_exception = (char*)VLC_PositionKeyNotSupported__alloc ();
corba_exception = ( char* )VLC_PositionKeyNotSupported__alloc();
i_type = ex_VLC_PositionKeyNotSupported;
break;
case mediacontrol_PositionOriginNotSupported:
corba_exception = (char*)VLC_PositionOriginNotSupported__alloc ();
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);
( (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)
retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) );
if( ! retval )
return NULL;
retval->origin = position->origin;
retval->key = position->key;
......@@ -111,12 +112,12 @@ static mediacontrol_Position* corba_position_corba_to_c (const VLC_Position* pos
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)
retval = ( VLC_Position* )malloc( sizeof( VLC_Position ) );
if( ! retval )
return NULL;
retval->origin = position->origin;
retval->key = position->key;
......@@ -138,7 +139,7 @@ struct intf_sys_t
/*** 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
......@@ -154,128 +155,128 @@ typedef struct
/* 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,
impl_VLC_MediaControl_get_media_position( impl_POA_VLC_MediaControl * servant,
const VLC_PositionOrigin an_origin,
const VLC_PositionKey a_key,
CORBA_Environment * ev);
CORBA_Environment * ev );
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,
CORBA_Environment * ev);
CORBA_Environment * ev );
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);
CORBA_Environment * ev );
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);
CORBA_Environment * ev );
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);
CORBA_Environment * ev );
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);
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,
impl_VLC_MediaControl_playlist_add_item( impl_POA_VLC_MediaControl * servant,
const CORBA_char * a_file,
CORBA_Environment * ev);
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,
*impl_VLC_MediaControl_snapshot( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position,
CORBA_Environment * ev);
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,
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);
CORBA_Environment * ev );
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);
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,
impl_VLC_MediaControl_sound_set_volume( impl_POA_VLC_MediaControl * servant,
const CORBA_unsigned_short volume,
CORBA_Environment * ev);
CORBA_Environment * ev );
/*** epv structures ***/
static PortableServer_ServantBase__epv impl_VLC_MediaControl_base_epv = {
NULL, /* _private data */
(gpointer) & impl_VLC_MediaControl__destroy, /* finalize routine */
( gpointer ) & impl_VLC_MediaControl__destroy, /* finalize routine */
NULL, /* default_POA routine */
};
static POA_VLC_MediaControl__epv impl_VLC_MediaControl_epv = {
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,
};
......@@ -289,17 +290,17 @@ static POA_VLC_MediaControl__vepv impl_VLC_MediaControl_vepv = {
/*** 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 = 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);
( 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. */
......@@ -307,25 +308,25 @@ impl_VLC_MediaControl__create(PortableServer_POA poa, CORBA_Environment * ev)
newservant->mc = NULL;
/* ------ ---------- end ------------- ------ */
objid = PortableServer_POA_activate_object(poa, newservant, ev);
CORBA_free(objid);
retval = PortableServer_POA_servant_to_reference(poa, newservant, ev);
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 ------------- ------ */
POA_VLC_MediaControl__fini((PortableServer_Servant) servant, ev);
POA_VLC_MediaControl__fini( (PortableServer_Servant ) servant, ev );
}
/* END INSERT */
......@@ -333,153 +334,153 @@ 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,
impl_VLC_MediaControl_get_media_position( impl_POA_VLC_MediaControl * servant,
const VLC_PositionOrigin an_origin,
const VLC_PositionKey a_key,
CORBA_Environment * ev)
CORBA_Environment * ev )
{
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);
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);
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,
impl_VLC_MediaControl_set_media_position( impl_POA_VLC_MediaControl * servant,
const VLC_Position * a_position,
CORBA_Environment * ev)
CORBA_Environment * ev )
{
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);
mediacontrol_set_media_position( servant->mc, p_pos, exception );
MC_EXCEPT();
free(p_pos);
free( p_pos );
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;
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);
mediacontrol_start( servant->mc, p_pos, exception );
MC_EXCEPT();
free(p_pos);
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;
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);
mediacontrol_pause( servant->mc, p_pos, exception );
MC_EXCEPT();
free(p_pos);
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;
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);
mediacontrol_resume( servant->mc, p_pos, exception );
MC_EXCEPT();
free(p_pos);
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;
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);
mediacontrol_pause( servant->mc, p_pos, exception );
MC_EXCEPT();
free(p_pos);
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);
mediacontrol_exit( servant->mc );
return;
}
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,
CORBA_Environment * ev)
CORBA_Environment * ev )
{
mediacontrol_Exception *exception = NULL;
MC_TRY;
mediacontrol_playlist_add_item(servant->mc, psz_file, exception);
mediacontrol_playlist_add_item( servant->mc, psz_file, exception );
MC_EXCEPT();
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;
MC_TRY;
mediacontrol_playlist_clear(servant->mc, exception);
mediacontrol_playlist_clear( servant->mc, exception );
MC_EXCEPT();
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;
......@@ -487,30 +488,30 @@ impl_VLC_MediaControl_playlist_get_list(impl_POA_VLC_MediaControl * servant,
int i_index;
MC_TRY;
p_ps = mediacontrol_playlist_get_list(servant->mc, exception);
MC_EXCEPT(retval);
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 = 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);
mediacontrol_PlaylistSeq__free( p_ps );
return retval;
}
VLC_RGBPicture*
createRGBPicture (mediacontrol_RGBPicture* p_pic)
createRGBPicture( mediacontrol_RGBPicture* p_pic )
{
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;
......@@ -519,37 +520,37 @@ createRGBPicture (mediacontrol_RGBPicture* p_pic)
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._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;
}
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,
CORBA_Environment * ev)
CORBA_Environment * ev )
{
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);
p_pic = mediacontrol_snapshot( servant->mc, p_pos, exception );
MC_EXCEPT( retval );
retval = createRGBPicture(p_pic);
mediacontrol_RGBPicture__free(p_pic);
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;
......@@ -559,22 +560,22 @@ impl_VLC_MediaControl_all_snapshots(impl_POA_VLC_MediaControl * servant,
int i_index;
MC_TRY;
p_piclist = mediacontrol_all_snapshots(servant->mc, exception);
MC_EXCEPT(retval);
p_piclist = mediacontrol_all_snapshots( servant->mc, exception );
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++;
retval = VLC_RGBPictureSeq__alloc ();
retval->_buffer = VLC_RGBPictureSeq_allocbuf (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;
p_rgb = &(retval->_buffer[i_index]);
p_rgb = &( retval->_buffer[i_index] );
p_rgb->width = p_pic->width;
p_rgb->height = p_pic->height;
......@@ -583,92 +584,92 @@ impl_VLC_MediaControl_all_snapshots(impl_POA_VLC_MediaControl * servant,
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._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);
free( p_piclist );
return retval;
}
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 VLC_Position * begin,
const VLC_Position * end,
CORBA_Environment * ev)
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);
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);
mediacontrol_display_text( servant->mc, message, p_begin, p_end, exception );
MC_EXCEPT();
free(p_begin);
free(p_end);
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;
MC_TRY;
p_si = mediacontrol_get_stream_information(servant->mc, mediacontrol_MediaTime, exception);
MC_EXCEPT(retval);
p_si = mediacontrol_get_stream_information( servant->mc, mediacontrol_MediaTime, exception );
MC_EXCEPT( retval );
retval = VLC_StreamInformation__alloc();
if (! retval)
if( ! retval )
{
return NULL;
}
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->length = p_si->length;
free(p_si->url);
free(p_si);
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;
MC_TRY;
retval = mediacontrol_sound_get_volume(servant->mc, exception);
MC_EXCEPT(retval);
retval = mediacontrol_sound_get_volume( servant->mc, exception );
MC_EXCEPT( retval );
return retval;
}
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,
CORBA_Environment * ev)
CORBA_Environment * ev )
{
mediacontrol_Exception *exception = NULL;
MC_TRY;
mediacontrol_sound_set_volume(servant->mc, volume, exception);
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,7 +695,7 @@ 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 ) );
......@@ -719,46 +720,46 @@ 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;
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 );
}
/*
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;
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)
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");
msg_Err( p_intf, "Exception in CORBA events check loop" );
return FALSE;
}
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 )
{
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);
CORBA_ORB_shutdown( p_intf->p_sys->orb, TRUE, ev );
g_main_loop_quit( p_intf->p_sys->corbaloop );
/* Just in case */
return( TRUE );
}
......@@ -774,7 +775,7 @@ 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;
......@@ -789,29 +790,29 @@ static void Run ( intf_thread_t *p_intf )
char* ppsz_argv[] = { "mc" };
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
http://www.fifi.org/doc/gnome-dev-doc/html/C/orbitgtk.html) but it
/* 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); */
/* 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);
handle_exception ("Exception during RootPOA initialization");
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");
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");
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_instance = mediacontrol_new_from_object((vlc_object_t* )p_intf, exception );
MC_EXCEPT();
p_intf->p_sys->mc = mc_instance;
......@@ -819,35 +820,35 @@ static void Run ( intf_thread_t *p_intf )
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");
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);
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)
fp = fopen( VLC_IOR_FILE, "w" );
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
{
fprintf (fp, "%s", psz_objref);
fclose (fp);
msg_Warn (p_intf, "IOR written to %s", VLC_IOR_FILE);
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...
......@@ -858,32 +859,32 @@ static void Run ( intf_thread_t *p_intf )
{"vlc", "server"} };
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",
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));
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);
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);
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;
}
......@@ -28,35 +28,35 @@
#endif
#include <sys/types.h>
#define RAISE(c, m) exception->code = c; \
#define RAISE( c, m ) exception->code = c; \
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 to,
long long value)
long long value )
{
if (to == from)
if( to == from )
return value;
/* For all conversions, we need data from p_input */
if (!p_input)
if( !p_input )
return 0;
switch (from)
switch( from )
{
case mediacontrol_MediaTime:
if (to == mediacontrol_ByteCount)
if( to == mediacontrol_ByteCount )
return value * 50 * p_input->stream.i_mux_rate / 1000;
if (to == mediacontrol_SampleCount)
if( to == mediacontrol_SampleCount )
{
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;
else
return (value * f_fps / 1000.0);
return( value * f_fps / 1000.0 );
}
/* Cannot happen */
/* See http://catb.org/~esr/jargon/html/entry/can't-happen.html */
......@@ -66,36 +66,36 @@ long long mediacontrol_unit_convert (input_thread_t *p_input,
{
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;
if (to == mediacontrol_ByteCount)
return (long long)(value * 50 * p_input->stream.i_mux_rate / f_fps);
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 );
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)
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( to == mediacontrol_MediaTime )
return ( long long )( 1000 * value / 50 / p_input->stream.i_mux_rate );
if (to == mediacontrol_SampleCount)
if( to == mediacontrol_SampleCount )
{
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;
else
return (long long)(value * f_fps / 50 / p_input->stream.i_mux_rate);
return ( long long )( value * f_fps / 50 / p_input->stream.i_mux_rate );
}
/* Cannot happen */
break;
......@@ -107,51 +107,50 @@ long long mediacontrol_unit_convert (input_thread_t *p_input,
/* 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,
return ( 1000 * mediacontrol_unit_convert( p_input,
pos->key, /* from */
mediacontrol_MediaTime, /* to */
pos->value));
pos->value ) );
break;
case mediacontrol_RelativePosition:
{
off_t l_offset;
long long l_current;
long long l_pos;
vlc_value_t val;
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 );
val.i_time = 0;
var_Get( p_input, "time", &val );
l_current = 1000 * mediacontrol_unit_convert(p_input,
mediacontrol_ByteCount,
mediacontrol_MediaTime,
l_offset);
l_pos = 1000 * mediacontrol_unit_convert(p_input,
l_pos = 1000 * mediacontrol_unit_convert( p_input,
pos->key,
mediacontrol_MediaTime,
pos->value);
return l_current + l_pos;
pos->value );
return val.i_time + l_pos;
break;
}
case mediacontrol_ModuloPosition:
{
long long l_duration;
long long l_pos;
vlc_value_t val;
l_duration = 1000 * mediacontrol_unit_convert(p_input,
mediacontrol_ByteCount,
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,
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;
pos->value ) );
}
else
l_pos = 0;
return l_pos % val.i_time;
break;
}
}
......@@ -159,60 +158,60 @@ mediacontrol_position2microsecond (input_thread_t* p_input, const mediacontrol_P
}
mediacontrol_RGBPicture*
mediacontrol_RGBPicture__alloc (int datasize)
mediacontrol_RGBPicture__alloc( int datasize )
{
mediacontrol_RGBPicture* pic;
pic = (mediacontrol_RGBPicture*)malloc(sizeof(mediacontrol_RGBPicture));
if (! pic)
pic = ( mediacontrol_RGBPicture * )malloc( sizeof( mediacontrol_RGBPicture ) );
if( ! pic )
return NULL;
pic->size = datasize;
pic->data = (char*)malloc(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;
ps = (mediacontrol_PlaylistSeq*)malloc(sizeof(mediacontrol_PlaylistSeq));
if (! ps)
ps =( mediacontrol_PlaylistSeq* )malloc( sizeof( mediacontrol_PlaylistSeq ) );
if( ! ps )
return NULL;
ps->size = size;
ps->data = (char**)malloc(size * sizeof(char*));
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]);
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;
......@@ -221,73 +220,73 @@ mediacontrol_exception_init(mediacontrol_Exception *exception)
}
void
mediacontrol_exception_free(mediacontrol_Exception *exception)
mediacontrol_exception_free( mediacontrol_Exception *exception )
{
if (! exception)
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)
p_vlc = vlc_object_find( p_object, VLC_OBJECT_ROOT, FIND_PARENT );
if( ! p_vlc )
{
RAISE(mediacontrol_InternalException, "Unable to initialize VLC");
RAISE( mediacontrol_InternalException, "Unable to initialize VLC" );
return NULL;
}
retval = (mediacontrol_Instance*)malloc(sizeof(mediacontrol_Instance));
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);
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");
RAISE( mediacontrol_InternalException, "No available interface" );
return NULL;
}
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,
mediacontrol_get_media_position( mediacontrol_Instance *self,
const mediacontrol_PositionOrigin an_origin,
const mediacontrol_PositionKey a_key,
mediacontrol_Exception *exception)
mediacontrol_Exception *exception )
{
mediacontrol_Position* retval;
off_t l_offset;
input_thread_t * p_input = self->p_playlist->p_input;;
vlc_value_t val;
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->key = a_key;
if (! p_input)
if( ! p_input )
{
/*
RAISE(mediacontrol_InternalException, "No input thread.");
return(NULL);
RAISE( mediacontrol_InternalException, "No input thread." );
return( NULL );
*/
retval->value = 0;
return retval;
}
if ( an_origin == mediacontrol_RelativePosition
if( an_origin == mediacontrol_RelativePosition
|| an_origin == mediacontrol_ModuloPosition )
{
/* Relative or ModuloPosition make no sense */
......@@ -296,107 +295,75 @@ mediacontrol_get_media_position(mediacontrol_Instance *self,
}
/* 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 );
val.i_time = 0;
var_Get( p_input, "time", &val );
/* FIXME: check val.i_time > 0 */
retval->value = mediacontrol_unit_convert(p_input,
mediacontrol_ByteCount,
retval->value = mediacontrol_unit_convert( p_input,
mediacontrol_MediaTime,
a_key,
l_offset);
val.i_time / 1000 );
return retval;
}
/* Sets the media position */
void
mediacontrol_set_media_position(mediacontrol_Instance *self,
mediacontrol_set_media_position( mediacontrol_Instance *self,
const mediacontrol_Position * a_position,
mediacontrol_Exception *exception)
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);
val.i_time = mediacontrol_position2microsecond( p_input, a_position );
var_Set( p_input, "time", val );
return;
#endif
}
/* Starts playing a stream */
void
mediacontrol_start(mediacontrol_Instance *self,
mediacontrol_start( mediacontrol_Instance *self,
const mediacontrol_Position * a_position,
mediacontrol_Exception *exception)
mediacontrol_Exception *exception )
{
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");
RAISE( mediacontrol_PlaylistException, "No available playlist" );
return;
}
vlc_mutex_lock( &p_playlist->object_lock );
if (p_playlist->i_size)
if( p_playlist->i_size )
{
vlc_value_t val;
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);
val.i_int = mediacontrol_position2microsecond( p_playlist->p_input, a_position ) / 1000000;
var_Set( p_playlist, "start-time", val );
playlist_Play( p_playlist );
}
else
{
RAISE(mediacontrol_PlaylistException, "Empty playlist.");
RAISE( mediacontrol_PlaylistException, "Empty playlist." );
vlc_mutex_unlock( &p_playlist->object_lock );
return;
}
......@@ -405,123 +372,116 @@ mediacontrol_start(mediacontrol_Instance *self,
}
void
mediacontrol_pause(mediacontrol_Instance *self,
mediacontrol_pause( mediacontrol_Instance *self,
const mediacontrol_Position * a_position,
mediacontrol_Exception *exception)
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,
mediacontrol_resume( mediacontrol_Instance *self,
const mediacontrol_Position * a_position,
mediacontrol_Exception *exception)
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,
mediacontrol_stop( mediacontrol_Instance *self,
const mediacontrol_Position * a_position,
mediacontrol_Exception *exception)
mediacontrol_Exception *exception )
{
/* FIXME: use the a_position parameter */
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;
}
playlist_Stop( self->p_playlist );
return;
}
void
mediacontrol_playlist_add_item(mediacontrol_Instance *self,
mediacontrol_playlist_add_item( mediacontrol_Instance *self,
const char * psz_file,
mediacontrol_Exception *exception)
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");
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");
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;
}
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;
exception=mediacontrol_exception_init(exception);
if (!p_playlist)
exception=mediacontrol_exception_init( exception );
if( !p_playlist )
{
RAISE(mediacontrol_PlaylistException, "No playlist");
RAISE( mediacontrol_PlaylistException, "No playlist" );
return NULL;
}
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 );
......@@ -529,28 +489,28 @@ mediacontrol_playlist_get_list(mediacontrol_Instance *self,
}
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 = 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);
memcpy( retval->data, p_data, i_datasize );
}
return retval;
}
mediacontrol_RGBPicture *
mediacontrol_snapshot(mediacontrol_Instance *self,
mediacontrol_snapshot( mediacontrol_Instance *self,
const mediacontrol_Position * a_position,
mediacontrol_Exception *exception)
mediacontrol_Exception *exception )
{
mediacontrol_RGBPicture *retval = NULL;
input_thread_t* p_input = self->p_playlist->p_input;
......@@ -565,71 +525,73 @@ mediacontrol_snapshot(mediacontrol_Instance *self,
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)
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;
}
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;
}
#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
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)
if( var_Get( p_vout, "snapshot-datasize", &val ) != VLC_SUCCESS )
{
RAISE(mediacontrol_InternalException, "No snapshot module");
vlc_object_release(p_vout);
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))
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)
mediacontrol_set_media_position( self,
( mediacontrol_Position* ) a_position,
exception );
if( exception->code )
{
vlc_object_release(p_vout);
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). */
( which means that we had the possibility to capture the right
picture ). */
vlc_mutex_lock( &p_vout->picture_lock );
searched_date = mediacontrol_position2microsecond (p_input,
(mediacontrol_Position *)a_position);
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;
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_object_release( p_vout );
......@@ -639,10 +601,10 @@ mediacontrol_snapshot(mediacontrol_Instance *self,
/* Find the more appropriate picture, based on date */
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;
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 */
p_best_snapshot = pointer[i_index];
......@@ -650,13 +612,13 @@ mediacontrol_snapshot(mediacontrol_Instance *self,
}
/* 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,
( 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);
i_datasize );
vlc_mutex_unlock( &p_vout->picture_lock );
vlc_object_release( p_vout );
......@@ -667,8 +629,8 @@ mediacontrol_snapshot(mediacontrol_Instance *self,
}
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;
......@@ -680,24 +642,24 @@ mediacontrol_all_snapshots(mediacontrol_Instance *self,
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)
if( ! p_vout )
{
RAISE(mediacontrol_InternalException, "No snapshot module");
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
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)
if( var_Get( p_vout, "snapshot-datasize", &val ) != VLC_SUCCESS )
{
RAISE(mediacontrol_InternalException, "No snapshot module");
vlc_object_release(p_vout);
RAISE( mediacontrol_InternalException, "No snapshot module" );
vlc_object_release( p_vout );
return NULL;
}
i_datasize = val.i_int;
......@@ -708,30 +670,30 @@ mediacontrol_all_snapshots(mediacontrol_Instance *self,
i_cachesize = val.i_int ;
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_object_release( p_vout );
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];
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_vout->output.i_chroma,
p_s->date,
p_s->p_data,
i_datasize);
i_datasize );
retval[i_index] = p_rgb;
}
......@@ -747,35 +709,35 @@ mediacontrol_all_snapshots(mediacontrol_Instance *self,
}
void
mediacontrol_display_text(mediacontrol_Instance *self,
mediacontrol_display_text( mediacontrol_Instance *self,
const char * message,
const mediacontrol_Position * begin,
const mediacontrol_Position * end,
mediacontrol_Exception *exception)
mediacontrol_Exception *exception )
{
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");
RAISE( mediacontrol_InternalException, "No video output" );
return;
}
if (begin->origin == mediacontrol_RelativePosition &&
if( begin->origin == mediacontrol_RelativePosition &&
begin->value == 0 &&
end->origin == mediacontrol_RelativePosition)
end->origin == mediacontrol_RelativePosition )
{
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,
mediacontrol_MediaTime,
end->value);
end->value );
vout_ShowTextRelative( p_vout, (char*)message, NULL,
OSD_ALIGN_BOTTOM|OSD_ALIGN_LEFT, 20, 20,
vout_ShowTextRelative( p_vout, ( char* ) message, NULL,
OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 20, 20,
i_duration );
}
else
......@@ -783,23 +745,25 @@ mediacontrol_display_text(mediacontrol_Instance *self,
mtime_t i_debut, i_fin, i_now;
p_input = self->p_playlist->p_input;
if (! p_input)
if( ! p_input )
{
RAISE(mediacontrol_InternalException, "No input");
vlc_object_release(p_vout);
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 = mediacontrol_position2microsecond( p_input,
( mediacontrol_Position* ) begin );
i_debut += i_now;
i_fin = mediacontrol_position2microsecond (p_input, (mediacontrol_Position *) end);
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,
vout_ShowTextAbsolute( p_vout,( char* )message, NULL,
OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 20, 20,
i_debut, i_fin );
}
......@@ -807,31 +771,32 @@ mediacontrol_display_text(mediacontrol_Instance *self,
}
mediacontrol_StreamInformation *
mediacontrol_get_stream_information(mediacontrol_Instance *self,
mediacontrol_get_stream_information( mediacontrol_Instance *self,
mediacontrol_PositionKey a_key,
mediacontrol_Exception *exception)
mediacontrol_Exception *exception )
{
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");
RAISE( mediacontrol_InternalException, "Out of memory" );
return NULL;
}
if (! p_input)
if( ! p_input )
{
/* No p_input defined */
retval->streamstatus = mediacontrol_UndefinedStatus;
retval->url = strdup ("None");
retval->url = strdup( "None" );
retval->position = 0;
retval->length = 0;
}
else
{
switch (p_input->stream.control.i_status)
switch( p_input->stream.control.i_status )
{
case UNDEF_S :
retval->streamstatus = mediacontrol_UndefinedStatus;
......@@ -859,34 +824,35 @@ mediacontrol_get_stream_information(mediacontrol_Instance *self,
break;
}
retval->url = strdup (p_input->psz_source);
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;
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,
retval->position = mediacontrol_unit_convert( p_input,
mediacontrol_MediaTime, a_key,
retval->position);
retval->length = mediacontrol_unit_convert(p_input,
retval->position );
retval->length = mediacontrol_unit_convert( p_input,
mediacontrol_MediaTime, a_key,
retval->length);
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)
if( !self->p_intf )
{
RAISE(mediacontrol_InternalException, "No interface module");
RAISE( mediacontrol_InternalException, "No interface module" );
return 0;
}
aout_VolumeGet( self->p_intf, &i_volume );
......@@ -895,14 +861,14 @@ mediacontrol_sound_get_volume(mediacontrol_Instance *self,
}
void
mediacontrol_sound_set_volume(mediacontrol_Instance *self,
mediacontrol_sound_set_volume( mediacontrol_Instance *self,
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;
}
aout_VolumeSet( self->p_intf, (audio_volume_t)volume );
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;
......@@ -10,53 +10,53 @@ mediacontrol_Instance* mediacontrol_new(char** args, mediacontrol_Exception *exc
int i_index;
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++;
}
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 = 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 = (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");
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;
/* 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);
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");
exception->code = mediacontrol_InternalException;
exception->message = strdup( "No available interface" );
return NULL;
}
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.");
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_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_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