# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include "mediacontrol_internal.h"
#include <vlc/mediacontrol.h>
#include <vlc/libvlc.h>
+#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_playlist.h>
#include <vlc_aout.h>
#include <vlc_input.h>
#include <vlc_osd.h>
-#include "mediacontrol_internal.h"
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
{
mediacontrol_Instance* retval;
libvlc_exception_t ex;
-
+
libvlc_exception_init( &ex );
-
+
retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
if( ! retval )
{
{
mediacontrol_Position* retval = NULL;
libvlc_exception_t ex;
- vlc_int64_t pos;
+ int64_t pos;
mediacontrol_exception_init( exception );
libvlc_exception_init( &ex );
if( an_origin != mediacontrol_AbsolutePosition )
{
+ free( retval );
/* Relative or ModuloPosition make no sense */
RAISE_NULL( mediacontrol_PositionOriginNotSupported,
"Only absolute position is valid." );
mediacontrol_Exception *exception )
{
libvlc_exception_t ex;
- vlc_int64_t i_pos;
+ int64_t i_pos;
libvlc_exception_init( &ex );
mediacontrol_exception_init( exception );
mediacontrol_exception_init( exception );
libvlc_exception_init( &ex );
-
+
p_media = libvlc_media_player_get_media( self->p_media_player, &ex );
HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
/* Create a new media */
p_media = libvlc_media_new( self->p_instance, psz_name, &ex );
HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
-
+
if( a_position->value )
{
char * psz_from;
/* A start position was specified. Add it to media options */
psz_from = ( char * )malloc( 20 * sizeof( char ) );
i_from = private_mediacontrol_position2microsecond( self->p_media_player, a_position ) / 1000000;
- snprintf( psz_from, 20, "start-time=%ld", i_from );
+ snprintf( psz_from, 20, "start-time=%"PRId64, i_from );
libvlc_media_add_option( p_media, psz_from, &ex );
HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
}
-
+
libvlc_media_player_set_media( self->p_media_player, p_media, &ex );
HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
mediacontrol_exception_init( exception );
libvlc_exception_init( &ex );
-
+
p_media = libvlc_media_new( self->p_instance, psz_file, &ex );
HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
mediacontrol_exception_init( exception );
libvlc_exception_init( &ex );
-
+
p_media = libvlc_media_player_get_media( self->p_media_player, &ex );
HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
mediacontrol_PositionKey a_key,
mediacontrol_Exception *exception )
{
+ (void)a_key;
mediacontrol_StreamInformation *retval = NULL;
libvlc_media_t * p_media;
libvlc_exception_t ex;
}
p_media = libvlc_media_player_get_media( self->p_media_player, &ex );
- HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
+ if( libvlc_exception_raised( &ex ) )
+ {
+ free( retval );
+ RAISE( mediacontrol_InternalException, libvlc_errmsg( ) );
+ libvlc_exception_clear( &ex );
+ return NULL;
+ }
+
if( ! p_media )
{
/* No p_media defined */
retval->streamstatus = mediacontrol_UndefinedStatus;
- retval->url = strdup( "None" );
+ retval->url = strdup( "" );
retval->position = 0;
retval->length = 0;
}
libvlc_state_t state;
state = libvlc_media_player_get_state( self->p_media_player, &ex );
- HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
+ if( libvlc_exception_raised( &ex ) )
+ {
+ free( retval );
+ RAISE( mediacontrol_InternalException, libvlc_errmsg() );
+ libvlc_exception_clear( &ex );
+ return NULL;
+ }
+
switch( state )
{
- case libvlc_Playing :
- retval->streamstatus = mediacontrol_PlayingStatus;
- break;
- case libvlc_Paused :
- retval->streamstatus = mediacontrol_PauseStatus;
+ case libvlc_NothingSpecial:
+ retval->streamstatus = mediacontrol_UndefinedStatus;
break;
case libvlc_Opening :
- case libvlc_Buffering:
retval->streamstatus = mediacontrol_InitStatus;
break;
+ case libvlc_Buffering:
+ retval->streamstatus = mediacontrol_BufferingStatus;
+ break;
+ case libvlc_Playing:
+ retval->streamstatus = mediacontrol_PlayingStatus;
+ break;
+ case libvlc_Paused:
+ retval->streamstatus = mediacontrol_PauseStatus;
+ break;
case libvlc_Stopped:
+ retval->streamstatus = mediacontrol_StopStatus;
+ break;
case libvlc_Ended:
retval->streamstatus = mediacontrol_EndStatus;
break;
+ case libvlc_Error:
+ retval->streamstatus = mediacontrol_ErrorStatus;
+ break;
default :
retval->streamstatus = mediacontrol_UndefinedStatus;
break;
}
retval->url = libvlc_media_get_mrl( p_media, &ex );
-
- /* TIME and LENGTH are in microseconds. We want them in ms */
+
retval->position = libvlc_media_player_get_time( self->p_media_player, &ex );
+ if( libvlc_exception_raised( &ex ) )
+ {
+ libvlc_exception_clear( &ex );
+ retval->position = 0;
+ }
retval->length = libvlc_media_player_get_length( self->p_media_player, &ex );
+ if( libvlc_exception_raised( &ex ) )
+ {
+ libvlc_exception_clear( &ex );
+ retval->length = 0;
+ }
- retval->position = private_mediacontrol_unit_convert( self->p_media_player,
- mediacontrol_MediaTime, a_key,
- retval->position );
- retval->length = private_mediacontrol_unit_convert( self->p_media_player,
- mediacontrol_MediaTime, a_key,
- retval->length );
}
return retval;
}