Commit 445d63e0 authored by Olivier Aubert's avatar Olivier Aubert

mediacontrol API: update to use the new libvlc_media_player/libvlc_media API.

This implies the removal of playlist support (single-file playing only, through set_mrl/get_mrl methods). Position parameters for _pause, _resume and _stop method have also been removed.
parent 0b96b7ca
......@@ -130,6 +130,14 @@ mediacontrol_new_from_instance( libvlc_instance_t* p_instance,
VLC_PUBLIC_API libvlc_instance_t*
mediacontrol_get_libvlc_instance( mediacontrol_Instance* self );
/**
* Get the associated libvlc_media_player
* \param self: the mediacontrol instance
* \return a libvlc_media_player_t instance
*/
VLC_PUBLIC_API libvlc_media_player_t*
mediacontrol_get_media_player( mediacontrol_Instance* self );
/**
* Get the current position
* \param self the mediacontrol instance
......@@ -167,31 +175,25 @@ VLC_PUBLIC_API void mediacontrol_start( mediacontrol_Instance *self,
/**
* Pause the movie at a given position
* \param self the mediacontrol instance
* \param a_position a mediacontrol_Position (ignored for now)
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API void mediacontrol_pause( mediacontrol_Instance *self,
const mediacontrol_Position *a_position,
mediacontrol_Exception *exception );
/**
* Resume the movie at a given position
* \param self the mediacontrol instance
* \param a_position a mediacontrol_Position (ignored for now)
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API void mediacontrol_resume( mediacontrol_Instance *self,
const mediacontrol_Position *a_position,
mediacontrol_Exception *exception );
/**
* Stop the movie at a given position
* \param self the mediacontrol instance
* \param a_position a mediacontrol_Position (ignored for now)
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API void mediacontrol_stop( mediacontrol_Instance *self,
const mediacontrol_Position *a_position,
mediacontrol_Exception *exception );
/**
......@@ -201,39 +203,22 @@ VLC_PUBLIC_API void mediacontrol_stop( mediacontrol_Instance *self,
VLC_PUBLIC_API void mediacontrol_exit( mediacontrol_Instance *self );
/**
* Add a new MRL to the playlist
* Set the MRL to be played.
* \param self the mediacontrol instance
* \param psz_file the MRL
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API void mediacontrol_playlist_add_item( mediacontrol_Instance *self,
VLC_PUBLIC_API void mediacontrol_set_mrl( mediacontrol_Instance *self,
const char* psz_file,
mediacontrol_Exception *exception );
/**
* Clear the playlist
* \param self the mediacontrol instance
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API void mediacontrol_playlist_clear( mediacontrol_Instance *self,
mediacontrol_Exception *exception );
/**
* Get a flattened view of the playlist
* \param self the mediacontrol instance
* \param exception an initialized exception pointer
* \return a list of strings
*/
VLC_PUBLIC_API mediacontrol_PlaylistSeq *
mediacontrol_playlist_get_list( mediacontrol_Instance *self,
mediacontrol_Exception *exception );
/**
* Play the next item
* Get the MRL to be played.
* \param self the mediacontrol instance
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API void
mediacontrol_playlist_next_item( mediacontrol_Instance *self,
mediacontrol_Exception *exception );
VLC_PUBLIC_API char * mediacontrol_get_mrl( mediacontrol_Instance *self,
mediacontrol_Exception *exception );
/*****************************************************************************
* A/V functions
......@@ -250,17 +235,6 @@ VLC_PUBLIC_API mediacontrol_RGBPicture *
const mediacontrol_Position *a_position,
mediacontrol_Exception *exception );
/* Return a NULL terminated list */
/**
* Get a list of all cached snapshots (unimplemented)
* \param self the mediacontrol instance
* \param exception an initialized exception pointer
* \return a NULL-terminated list of RGBpicture
*/
VLC_PUBLIC_API mediacontrol_RGBPicture **
mediacontrol_all_snapshots( mediacontrol_Instance *self,
mediacontrol_Exception *exception );
/**
* Displays the message string, between "begin" and "end" positions.
* \param self the mediacontrol instance
......
......@@ -25,14 +25,11 @@
# include "config.h"
#endif
#include "mediacontrol_internal.h"
#include "libvlc_internal.h"
#include <vlc/mediacontrol.h>
#include <vlc/libvlc.h>
#include <vlc_playlist.h>
#include <vlc_aout.h>
#include <vlc_vout.h>
#include <vlc_osd.h>
......@@ -60,21 +57,30 @@ mediacontrol_snapshot( mediacontrol_Instance *self,
{
vlc_object_t* p_cache;
vout_thread_t* p_vout;
input_thread_t *p_input;
mediacontrol_RGBPicture *p_pic = NULL;
char path[256];
snapshot_t *p_snapshot;
libvlc_exception_t ex;
libvlc_exception_init( &ex );
mediacontrol_exception_init( exception );
p_vout = vlc_object_find( self->p_playlist, VLC_OBJECT_VOUT, FIND_CHILD );
p_input = libvlc_get_input_thread( self->p_media_player, &ex );
if( ! p_input )
{
RAISE_NULL( mediacontrol_InternalException, "No input" );
}
p_vout = vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
if( ! p_vout )
{
RAISE_NULL( mediacontrol_InternalException, "No video output" );
}
p_cache = vlc_object_create( self->p_playlist, VLC_OBJECT_GENERIC );
p_cache = vlc_object_create( p_input, VLC_OBJECT_GENERIC );
if( p_cache == NULL )
{
vlc_object_release( p_vout );
vlc_object_release( p_input );
RAISE_NULL( mediacontrol_InternalException, "Out of memory" );
}
snprintf( path, 255, "object:%d", p_cache->i_object_id );
......@@ -89,6 +95,7 @@ mediacontrol_snapshot( mediacontrol_Instance *self,
p_snapshot = ( snapshot_t* ) p_cache->p_private;
vlc_object_unlock( p_cache );
vlc_object_release( p_cache );
vlc_object_release( p_input );
if( p_snapshot )
{
......@@ -112,15 +119,6 @@ mediacontrol_snapshot( mediacontrol_Instance *self,
return p_pic;
}
mediacontrol_RGBPicture **
mediacontrol_all_snapshots( mediacontrol_Instance *self,
mediacontrol_Exception *exception )
{
mediacontrol_exception_init( exception );
RAISE_NULL( mediacontrol_InternalException, "unsupported method" );
}
static
int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel,
char *psz_string, text_style_t *p_style,
......@@ -174,20 +172,29 @@ mediacontrol_display_text( mediacontrol_Instance *self,
const mediacontrol_Position * end,
mediacontrol_Exception *exception )
{
input_thread_t *p_input = NULL;
vout_thread_t *p_vout = NULL;
char* psz_message;
input_thread_t *p_input;
libvlc_exception_t ex;
psz_message = strdup( message );
if( !psz_message )
libvlc_exception_init( &ex );
mediacontrol_exception_init( exception );
p_input = libvlc_get_input_thread( self->p_media_player, &ex );
if( ! p_input )
{
RAISE_VOID( mediacontrol_InternalException, "no more memory" );
RAISE_VOID( mediacontrol_InternalException, "No input" );
}
p_vout = vlc_object_find( self->p_playlist, VLC_OBJECT_VOUT, FIND_CHILD );
p_vout = vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
if( ! p_vout )
{
RAISE_VOID( mediacontrol_InternalException, "no video output" );
RAISE_VOID( mediacontrol_InternalException, "No video output" );
}
psz_message = strdup( message );
if( !psz_message )
{
RAISE_VOID( mediacontrol_InternalException, "no more memory" );
}
if( begin->origin == mediacontrol_RelativePosition &&
......@@ -198,10 +205,10 @@ mediacontrol_display_text( mediacontrol_Instance *self,
mtime_t i_now = mdate();
i_duration = 1000 * private_mediacontrol_unit_convert(
self->p_playlist->p_input,
end->key,
mediacontrol_MediaTime,
end->value );
self->p_media_player,
end->key,
mediacontrol_MediaTime,
end->value );
mediacontrol_showtext( p_vout, DEFAULT_CHAN, psz_message, NULL,
OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 0, 0,
......@@ -211,22 +218,15 @@ mediacontrol_display_text( mediacontrol_Instance *self,
{
mtime_t i_debut, i_fin, i_now;
p_input = self->p_playlist->p_input;
if( ! p_input )
{
vlc_object_release( p_vout );
RAISE_VOID( mediacontrol_InternalException, "No input" );
}
/* FIXME */
/* i_now = input_ClockGetTS( p_input, NULL, 0 ); */
i_now = mdate();
i_debut = private_mediacontrol_position2microsecond( p_input,
i_debut = private_mediacontrol_position2microsecond( self->p_media_player,
( mediacontrol_Position* ) begin );
i_debut += i_now;
i_fin = private_mediacontrol_position2microsecond( p_input,
i_fin = private_mediacontrol_position2microsecond( self->p_media_player,
( mediacontrol_Position * ) end );
i_fin += i_now;
......@@ -278,7 +278,7 @@ bool mediacontrol_set_visual( mediacontrol_Instance *self,
mediacontrol_exception_init( exception );
libvlc_exception_init( &ex );
libvlc_video_set_parent( self->p_instance, visual_id, &ex );
libvlc_media_player_set_drawable( self->p_media_player, visual_id, &ex );
HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
return true;
}
......@@ -288,17 +288,12 @@ mediacontrol_get_rate( mediacontrol_Instance *self,
mediacontrol_Exception *exception )
{
libvlc_exception_t ex;
libvlc_media_player_t* p_mi;
int i_ret;
mediacontrol_exception_init( exception );
libvlc_exception_init( &ex );
p_mi = libvlc_playlist_get_media_player( self->p_instance, &ex );
HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
i_ret = libvlc_media_player_get_rate( p_mi, &ex );
libvlc_media_player_release( p_mi );
i_ret = libvlc_media_player_get_rate( self->p_media_player, &ex );
HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
return i_ret / 10;
......@@ -310,16 +305,11 @@ mediacontrol_set_rate( mediacontrol_Instance *self,
mediacontrol_Exception *exception )
{
libvlc_exception_t ex;
libvlc_media_player_t* p_mi;
mediacontrol_exception_init( exception );
libvlc_exception_init( &ex );
p_mi = libvlc_playlist_get_media_player( self->p_instance, &ex );
HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
libvlc_media_player_set_rate( p_mi, rate * 10, &ex );
libvlc_media_player_release( p_mi );
libvlc_media_player_set_rate( self->p_media_player, rate * 10, &ex );
HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
}
......@@ -328,17 +318,12 @@ mediacontrol_get_fullscreen( mediacontrol_Instance *self,
mediacontrol_Exception *exception )
{
libvlc_exception_t ex;
libvlc_media_player_t* p_mi;
int i_ret;
mediacontrol_exception_init( exception );
libvlc_exception_init( &ex );
p_mi = libvlc_playlist_get_media_player( self->p_instance, &ex );
HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
i_ret = libvlc_get_fullscreen( p_mi, &ex );
libvlc_media_player_release( p_mi );
i_ret = libvlc_get_fullscreen( self->p_media_player, &ex );
HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
return i_ret;
......@@ -350,15 +335,10 @@ mediacontrol_set_fullscreen( mediacontrol_Instance *self,
mediacontrol_Exception *exception )
{
libvlc_exception_t ex;
libvlc_media_player_t* p_mi;
mediacontrol_exception_init( exception );
libvlc_exception_init( &ex );
p_mi = libvlc_playlist_get_media_player( self->p_instance, &ex );
HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
libvlc_set_fullscreen( p_mi, b_fullscreen, &ex );
libvlc_media_player_release( p_mi );
libvlc_set_fullscreen( self->p_media_player, b_fullscreen, &ex );
HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
}
This diff is collapsed.
......@@ -30,20 +30,20 @@ extern "C" {
#include <vlc/vlc.h>
#include <vlc/mediacontrol_structures.h>
#include "libvlc_internal.h"
#include <vlc/libvlc_structures.h>
#include <vlc/libvlc.h>
struct mediacontrol_Instance {
struct libvlc_instance_t * p_instance;
playlist_t *p_playlist;
libvlc_instance_t * p_instance;
libvlc_media_player_t * p_media_player;
};
vlc_int64_t private_mediacontrol_unit_convert( input_thread_t *p_input,
mediacontrol_PositionKey from,
mediacontrol_PositionKey to,
vlc_int64_t value );
vlc_int64_t private_mediacontrol_position2microsecond( input_thread_t *p_input,
const mediacontrol_Position *pos );
libvlc_time_t private_mediacontrol_unit_convert( libvlc_media_player_t *p_media_player,
mediacontrol_PositionKey from,
mediacontrol_PositionKey to,
vlc_int64_t value );
libvlc_time_t private_mediacontrol_position2microsecond( libvlc_media_player_t *p_media_player,
const mediacontrol_Position *pos );
/**
* Allocate a RGBPicture structure.
......@@ -53,8 +53,6 @@ mediacontrol_RGBPicture *private_mediacontrol_RGBPicture__alloc( int datasize );
mediacontrol_RGBPicture *private_mediacontrol_createRGBPicture( int, int, long, vlc_int64_t l_date, char *, int);
mediacontrol_PlaylistSeq *private_mediacontrol_PlaylistSeq__alloc( int size );
#define RAISE( c, m ) if( exception ) { exception->code = c; \
exception->message = strdup(m); }
......
......@@ -26,11 +26,7 @@
#endif
#include <vlc/mediacontrol.h>
#include <vlc_interface.h>
#include <vlc_aout.h>
#include <vlc_input.h>
#include <vlc_demux.h>
#include <vlc/libvlc.h>
#include <vlc_vout.h>
#include <vlc_osd.h>
......@@ -53,19 +49,15 @@
# include <sys/types.h>
#endif
/* FIXME: Need to stop accessing private input structures !! */
#include "input/input_internal.h"
vlc_int64_t private_mediacontrol_unit_convert( input_thread_t *p_input,
mediacontrol_PositionKey from,
mediacontrol_PositionKey to,
vlc_int64_t value )
libvlc_time_t private_mediacontrol_unit_convert( libvlc_media_player_t *p_media_player,
mediacontrol_PositionKey from,
mediacontrol_PositionKey to,
vlc_int64_t value )
{
if( to == from )
return value;
/* For all conversions, we need data from p_input */
if( !p_input )
if( !p_media_player )
return 0;
switch( from )
......@@ -73,7 +65,7 @@ vlc_int64_t private_mediacontrol_unit_convert( input_thread_t *p_input,
case mediacontrol_MediaTime:
if( to == mediacontrol_ByteCount )
{
/* FIXME */
/* FIXME Unsupported */
/* vlc < 0.8 API */
/* return value * 50 * p_input->stream.i_mux_rate / 1000; */
return 0;
......@@ -81,8 +73,11 @@ vlc_int64_t private_mediacontrol_unit_convert( input_thread_t *p_input,
if( to == mediacontrol_SampleCount )
{
double f_fps;
libvlc_exception_t ex;
libvlc_exception_init( &ex );
if( demux_Control( p_input->p->input.p_demux, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
f_fps = libvlc_media_player_get_rate( p_media_player, &ex );
if( f_fps < 0 )
return 0;
else
return( value * f_fps / 1000.0 );
......@@ -94,9 +89,11 @@ vlc_int64_t private_mediacontrol_unit_convert( input_thread_t *p_input,
case mediacontrol_SampleCount:
{
double f_fps;
if( demux_Control( p_input->p->input.p_demux, DEMUX_GET_FPS, &f_fps ) ||
f_fps < 0.1 )
libvlc_exception_t ex;
libvlc_exception_init( &ex );
f_fps = libvlc_media_player_get_rate( p_media_player, &ex );
if( f_fps < 0 )
return 0;
if( to == mediacontrol_ByteCount )
......@@ -116,28 +113,6 @@ vlc_int64_t private_mediacontrol_unit_convert( input_thread_t *p_input,
case mediacontrol_ByteCount:
/* FIXME */
return 0;
/* vlc < 0.8 API: */
// 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 ( vlc_int64_t )( 1000 * value / 50 / p_input->stream.i_mux_rate );
//
// if( to == mediacontrol_SampleCount )
// {
// double f_fps;
// if( demux_Control( p_input->input.p_demux, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
// return 0;
// else
// return ( vlc_int64_t )( value * f_fps / 50 / p_input->stream.i_mux_rate );
// }
/* Cannot happen */
break;
}
/* Cannot happen */
return 0;
......@@ -145,57 +120,56 @@ vlc_int64_t private_mediacontrol_unit_convert( input_thread_t *p_input,
/* Converts a mediacontrol_Position into a time in microseconds in
movie clock time */
vlc_int64_t
private_mediacontrol_position2microsecond( input_thread_t* p_input, const mediacontrol_Position * pos )
libvlc_time_t
private_mediacontrol_position2microsecond( libvlc_media_player_t * p_media_player,
const mediacontrol_Position * pos )
{
switch( pos->origin )
{
case mediacontrol_AbsolutePosition:
return ( 1000 * private_mediacontrol_unit_convert( p_input,
return ( 1000 * private_mediacontrol_unit_convert( p_media_player,
pos->key, /* from */
mediacontrol_MediaTime, /* to */
pos->value ) );
break;
case mediacontrol_RelativePosition:
{
vlc_int64_t l_pos;
vlc_value_t val;
val.i_time = 0;
if( p_input )
{
var_Get( p_input, "time", &val );
}
l_pos = 1000 * private_mediacontrol_unit_convert( p_input,
pos->key,
mediacontrol_MediaTime,
pos->value );
return val.i_time + l_pos;
libvlc_time_t l_time = 0;
libvlc_time_t l_pos = 0;
libvlc_exception_t ex;
libvlc_exception_init( &ex );
l_time = libvlc_media_player_get_time( p_media_player, &ex );
/* Ignore exception, we will assume a 0 time value */
l_pos = 1000 * private_mediacontrol_unit_convert( p_media_player,
pos->key,
mediacontrol_MediaTime,
pos->value );
return l_time + l_pos;
break;
}
case mediacontrol_ModuloPosition:
{
vlc_int64_t l_pos;
vlc_value_t val;
libvlc_time_t l_time = 0;
libvlc_time_t l_length = 0;
libvlc_time_t l_pos = 0;
libvlc_exception_t ex;
libvlc_exception_init( &ex );
l_length = libvlc_media_player_get_length( p_media_player, &ex );
if( l_length <= 0 )
return 0;
val.i_time = 0;
if( p_input )
{
var_Get( p_input, "length", &val );
}
l_time = libvlc_media_player_get_time( p_media_player, &ex );
/* Ignore exception, we will assume a 0 time value */
if( val.i_time > 0)
{
l_pos = ( 1000 * private_mediacontrol_unit_convert( p_input,
pos->key,
mediacontrol_MediaTime,
pos->value ) );
}
else
l_pos = 0;
l_pos = ( 1000 * private_mediacontrol_unit_convert( p_media_player,
pos->key,
mediacontrol_MediaTime,
pos->value ) );
return l_pos % val.i_time;
return ( l_time + l_pos ) % l_length;
break;
}
}
......@@ -226,33 +200,6 @@ mediacontrol_RGBPicture__free( mediacontrol_RGBPicture* pic )
}
}
mediacontrol_PlaylistSeq*
private_mediacontrol_PlaylistSeq__alloc( int size )
{
mediacontrol_PlaylistSeq* ps;
ps =( mediacontrol_PlaylistSeq* )malloc( sizeof( mediacontrol_PlaylistSeq ) );
if( ! ps )
return NULL;
ps->size = size;
ps->data = ( char** )malloc( size * sizeof( char* ) );
return ps;
}
void
mediacontrol_PlaylistSeq__free( mediacontrol_PlaylistSeq* ps )
{
if( ps )
{
int i;
for( i = 0 ; i < ps->size ; i++ )
free( ps->data[i] );
free( ps->data );
free( ps );
}
}
void
mediacontrol_StreamInformation__free( mediacontrol_StreamInformation* p_si )
{
......
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