#include <mediacontrol_internal.h>
#include <vlc/mediacontrol.h>
+#include <vlc/libvlc.h>
#include <vlc/intf.h>
#include <vlc/vout.h>
# include <sys/types.h>
#endif
-#define RAISE( c, m ) exception->code = c; \
- exception->message = strdup(m);
-
mediacontrol_RGBPicture *
mediacontrol_snapshot( mediacontrol_Instance *self,
const mediacontrol_Position * a_position,
p_vout = vlc_object_find( self->p_playlist, VLC_OBJECT_VOUT, FIND_CHILD );
if( ! p_vout )
{
- RAISE( mediacontrol_InternalException, "No video output" );
- return NULL;
+ RAISE_NULL( mediacontrol_InternalException, "No video output" );
}
p_cache = vlc_object_create( self->p_playlist, VLC_OBJECT_GENERIC );
if( p_cache == NULL )
{
vlc_object_release( p_vout );
- msg_Err( self->p_playlist, "out of memory" );
- RAISE( mediacontrol_InternalException, "Out of memory" );
- return NULL;
+ RAISE_NULL( mediacontrol_InternalException, "Out of memory" );
}
snprintf( path, 255, "object:%d", p_cache->i_object_id );
var_SetString( p_vout, "snapshot-path", path );
p_snapshot->p_data,
p_snapshot->i_datasize );
if( !p_pic )
- RAISE( mediacontrol_InternalException, "Out of memory" );
- free( p_snapshot->p_data );
- free( p_snapshot );
+ {
+ free( p_snapshot->p_data );
+ free( p_snapshot );
+ RAISE_NULL( mediacontrol_InternalException, "Out of memory" );
+ }
}
else
{
- RAISE( mediacontrol_InternalException, "Snapshot exception" );
+ RAISE_NULL( mediacontrol_InternalException, "Snapshot exception" );
}
return p_pic;
}
{
exception=mediacontrol_exception_init( exception );
- RAISE( mediacontrol_InternalException, "Unsupported method" );
- return NULL;
+ RAISE_NULL( mediacontrol_InternalException, "unsupported method" );
}
int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel,
psz_message = strdup( message );
if( !psz_message )
{
- RAISE( mediacontrol_InternalException, "No more memory" );
- return;
+ RAISE_VOID( mediacontrol_InternalException, "no more memory" );
}
p_vout = vlc_object_find( self->p_playlist, VLC_OBJECT_VOUT, FIND_CHILD );
if( ! p_vout )
{
- RAISE( mediacontrol_InternalException, "No video output" );
- return;
+ RAISE_VOID( mediacontrol_InternalException, "no video output" );
}
if( begin->origin == mediacontrol_RelativePosition &&
p_input = self->p_playlist->p_input;
if( ! p_input )
{
- RAISE( mediacontrol_InternalException, "No input" );
vlc_object_release( p_vout );
- return;
+ RAISE_VOID( mediacontrol_InternalException, "No input" );
}
/* FIXME */
mediacontrol_sound_get_volume( mediacontrol_Instance *self,
mediacontrol_Exception *exception )
{
- short retval;
- audio_volume_t i_volume;
+ libvlc_exception_t ex;
+ int i_ret = 0;
- if( !self->p_intf )
- {
- RAISE( mediacontrol_InternalException, "No interface module" );
- return 0;
- }
- aout_VolumeGet( self->p_intf, &i_volume );
- retval = i_volume;
- return retval;
+ mediacontrol_exception_init( exception );
+ libvlc_exception_init( &ex );
+
+ i_ret = libvlc_audio_get_volume( self->p_instance, &ex );
+ HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
+ /* FIXME: Normalize in [0..100] */
+ return (unsigned short)i_ret;
}
void
const unsigned short volume,
mediacontrol_Exception *exception )
{
- if( !self->p_intf )
- {
- RAISE( mediacontrol_InternalException, "No interface module" );
- }
- else aout_VolumeSet( self->p_intf,( audio_volume_t )volume );
+ /* FIXME: Normalize in [0..100] */
+ libvlc_exception_t ex;
+
+ mediacontrol_exception_init( exception );
+ libvlc_exception_init( &ex );
+
+ libvlc_audio_set_volume( self->p_instance, volume, &ex );
+ HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
}
vlc_bool_t mediacontrol_set_visual( mediacontrol_Instance *self,
WINDOWHANDLE visual_id,
mediacontrol_Exception *exception )
{
- vlc_value_t value;
- int ret;
+ libvlc_exception_t ex;
- if( !self->p_vlc )
- {
- RAISE( mediacontrol_InternalException, "No vlc reference" );
- return VLC_FALSE;
- }
- value.i_int=visual_id;
- ret = var_Set(self->p_vlc, "drawable", value);
+ mediacontrol_exception_init( exception );
+ libvlc_exception_init( &ex );
+
+ libvlc_video_set_parent( self->p_instance, visual_id, &ex );
+ HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
+ return VLC_TRUE;
+}
+
+int
+mediacontrol_get_rate( mediacontrol_Instance *self,
+ mediacontrol_Exception *exception )
+{
+ libvlc_exception_t ex;
+ libvlc_input_t* p_input;
+ int i_ret;
+
+ mediacontrol_exception_init( exception );
+ libvlc_exception_init( &ex );
+
+ p_input = libvlc_playlist_get_input( self->p_instance, &ex );
+ HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
+
+ i_ret = libvlc_input_get_rate( p_input, &ex );
+ libvlc_input_free( p_input );
+ HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
+
+ return i_ret / 10;
+}
+
+void
+mediacontrol_set_rate( mediacontrol_Instance *self,
+ const int rate,
+ mediacontrol_Exception *exception )
+{
+ libvlc_exception_t ex;
+ libvlc_input_t* p_input;
+
+ mediacontrol_exception_init( exception );
+ libvlc_exception_init( &ex );
+
+ p_input = libvlc_playlist_get_input( self->p_instance, &ex );
+ HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
+
+ libvlc_input_set_rate( p_input, rate * 10, &ex );
+ libvlc_input_free( p_input );
+ HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
+}
+
+int
+mediacontrol_get_fullscreen( mediacontrol_Instance *self,
+ mediacontrol_Exception *exception )
+{
+ libvlc_exception_t ex;
+ libvlc_input_t* p_input;
+ int i_ret;
+
+ mediacontrol_exception_init( exception );
+ libvlc_exception_init( &ex );
+
+ p_input = libvlc_playlist_get_input( self->p_instance, &ex );
+ HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
+
+ i_ret = libvlc_get_fullscreen( p_input, &ex );
+ libvlc_input_free( p_input );
+ HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
+
+ return i_ret;
+}
+
+void
+mediacontrol_set_fullscreen( mediacontrol_Instance *self,
+ const int b_fullscreen,
+ mediacontrol_Exception *exception )
+{
+ libvlc_exception_t ex;
+ libvlc_input_t* p_input;
+
+ mediacontrol_exception_init( exception );
+ libvlc_exception_init( &ex );
+
+ p_input = libvlc_playlist_get_input( self->p_instance, &ex );
+ HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
- return (ret == VLC_SUCCESS);
+ libvlc_set_fullscreen( p_input, b_fullscreen, &ex );
+ libvlc_input_free( p_input );
+ HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
}