Commit 34f81612 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

libvlc: Rename input to media_instance. And add the possibility to create a...

libvlc: Rename input to media_instance. And add the possibility to create a medi_instance from a media_descriptor.
parent 0dabfb1d
......@@ -286,42 +286,58 @@ VLC_PUBLIC_API int libvlc_playlist_add_extended( libvlc_instance_t *, const char
VLC_PUBLIC_API int libvlc_playlist_delete_item( libvlc_instance_t *, int,
libvlc_exception_t * );
typedef struct libvlc_input_t libvlc_input_t;
/* Get the input that is currently being played by the playlist
* \param p_instance the instance to use
* \param p_exception an initialized excecption
* \return an input object
*/
VLC_PUBLIC_API libvlc_input_t *libvlc_playlist_get_input( libvlc_instance_t *,
libvlc_exception_t * );
VLC_PUBLIC_API libvlc_media_instance_t * libvlc_playlist_get_media_instance(
libvlc_instance_t *, libvlc_exception_t * );
/** @}*/
/*****************************************************************************
* Input
* Media Instance
*****************************************************************************/
/** defgroup libvlc_input Input
/** defgroup libvlc_media_instance Media Instance
* \ingroup libvlc
* LibVLC Input handling
* LibVLC Media Instance
* @{
*/
/** Free an input object
* \param p_input the input to free
/** Create a Media Instance object from a Media Descriptor
* \param p_md the Media Descriptor from which the Media Instance should be
* created. The p_md can then be destroyed if needed.
*/
VLC_PUBLIC_API libvlc_media_instance_t * libvlc_media_instance_new( libvlc_media_descriptor_t * );
/** Destroy a Media Instance object
* \param p_mi the Media Instance to free
*/
VLC_PUBLIC_API void libvlc_input_free( libvlc_input_t * );
VLC_PUBLIC_API void libvlc_media_instance_destroy( libvlc_media_instance_t * );
VLC_PUBLIC_API void libvlc_media_instance_play ( libvlc_media_instance_t *, libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_media_instance_pause ( libvlc_media_instance_t *, libvlc_exception_t * );
/// \bug This might go away ... to be replaced by a broader system
VLC_PUBLIC_API vlc_int64_t libvlc_input_get_length ( libvlc_input_t *, libvlc_exception_t *);
VLC_PUBLIC_API vlc_int64_t libvlc_input_get_time ( libvlc_input_t *, libvlc_exception_t *);
VLC_PUBLIC_API void libvlc_input_set_time ( libvlc_input_t *, vlc_int64_t, libvlc_exception_t *);
VLC_PUBLIC_API float libvlc_input_get_position ( libvlc_input_t *, libvlc_exception_t *);
VLC_PUBLIC_API void libvlc_input_set_position ( libvlc_input_t *, float, libvlc_exception_t *);
VLC_PUBLIC_API vlc_bool_t libvlc_input_will_play ( libvlc_input_t *, libvlc_exception_t *);
VLC_PUBLIC_API float libvlc_input_get_rate ( libvlc_input_t *, libvlc_exception_t *);
VLC_PUBLIC_API void libvlc_input_set_rate ( libvlc_input_t *, float, libvlc_exception_t *);
VLC_PUBLIC_API int libvlc_input_get_state ( libvlc_input_t *, libvlc_exception_t *);
VLC_PUBLIC_API vlc_int64_t libvlc_media_instance_get_length ( libvlc_media_instance_t *, libvlc_exception_t *);
VLC_PUBLIC_API vlc_int64_t libvlc_media_instance_get_time ( libvlc_media_instance_t *, libvlc_exception_t *);
VLC_PUBLIC_API void libvlc_media_instance_set_time ( libvlc_media_instance_t *, vlc_int64_t, libvlc_exception_t *);
VLC_PUBLIC_API float libvlc_media_instance_get_position ( libvlc_media_instance_t *, libvlc_exception_t *);
VLC_PUBLIC_API void libvlc_media_instance_set_position ( libvlc_media_instance_t *, float, libvlc_exception_t *);
VLC_PUBLIC_API vlc_bool_t libvlc_media_instance_will_play ( libvlc_media_instance_t *, libvlc_exception_t *);
VLC_PUBLIC_API float libvlc_media_instance_get_rate ( libvlc_media_instance_t *, libvlc_exception_t *);
VLC_PUBLIC_API void libvlc_media_instance_set_rate ( libvlc_media_instance_t *, float, libvlc_exception_t *);
VLC_PUBLIC_API int libvlc_media_instance_get_state ( libvlc_media_instance_t *, libvlc_exception_t *);
/**
* Does this input have a video output ?
* \param p_input the input
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API vlc_bool_t libvlc_media_instance_has_vout( libvlc_media_instance_t *, libvlc_exception_t *);
VLC_PUBLIC_API float libvlc_media_instance_get_fps( libvlc_media_instance_t *, libvlc_exception_t *);
/** @} */
......@@ -336,15 +352,15 @@ VLC_PUBLIC_API int libvlc_input_get_state ( libvlc_input_t *, libvl
* \param p_input the input
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API vlc_bool_t libvlc_input_has_vout( libvlc_input_t *, libvlc_exception_t *);
VLC_PUBLIC_API float libvlc_input_get_fps( libvlc_input_t *, libvlc_exception_t *);
VLC_PUBLIC_API vlc_bool_t libvlc_input_has_vout( libvlc_media_instance_t *, libvlc_exception_t *);
VLC_PUBLIC_API float libvlc_input_get_fps( libvlc_media_instance_t *, libvlc_exception_t *);
/**
* Toggle fullscreen status on video output
* \param p_input the input
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_toggle_fullscreen( libvlc_input_t *, libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_toggle_fullscreen( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Enable or disable fullscreen on a video output
......@@ -352,7 +368,7 @@ VLC_PUBLIC_API void libvlc_toggle_fullscreen( libvlc_input_t *, libvlc_exception
* \param b_fullscreen boolean for fullscreen status
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_set_fullscreen( libvlc_media_instance_t *, int, libvlc_exception_t * );
/**
* Get current fullscreen status
......@@ -360,7 +376,7 @@ VLC_PUBLIC_API void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_excepti
* \param p_exception an initialized exception
* \return the fullscreen status (boolean)
*/
VLC_PUBLIC_API int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * );
VLC_PUBLIC_API int libvlc_get_fullscreen( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Get current video height
......@@ -368,7 +384,7 @@ VLC_PUBLIC_API int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t *
* \param p_exception an initialized exception
* \return the video height
*/
VLC_PUBLIC_API int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t * );
VLC_PUBLIC_API int libvlc_video_get_height( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Get current video width
......@@ -376,7 +392,7 @@ VLC_PUBLIC_API int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t
* \param p_exception an initialized exception
* \return the video width
*/
VLC_PUBLIC_API int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
VLC_PUBLIC_API int libvlc_video_get_width( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Get current video aspect ratio
......@@ -384,7 +400,7 @@ VLC_PUBLIC_API int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t
* \param p_exception an initialized exception
* \return the video aspect ratio
*/
VLC_PUBLIC_API char *libvlc_video_get_aspect_ratio( libvlc_input_t *, libvlc_exception_t * );
VLC_PUBLIC_API char *libvlc_video_get_aspect_ratio( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Set new video aspect ratio
......@@ -392,7 +408,7 @@ VLC_PUBLIC_API char *libvlc_video_get_aspect_ratio( libvlc_input_t *, libvlc_exc
* \param psz_aspect new video aspect-ratio
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_video_set_aspect_ratio( libvlc_input_t *, char *, libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_video_set_aspect_ratio( libvlc_media_instance_t *, char *, libvlc_exception_t * );
/**
* Get current video subtitle
......@@ -400,7 +416,7 @@ VLC_PUBLIC_API void libvlc_video_set_aspect_ratio( libvlc_input_t *, char *, lib
* \param p_exception an initialized exception
* \return the video subtitle selected
*/
VLC_PUBLIC_API int libvlc_video_get_spu( libvlc_input_t *, libvlc_exception_t * );
VLC_PUBLIC_API int libvlc_video_get_spu( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Set new video subtitle
......@@ -408,7 +424,7 @@ VLC_PUBLIC_API int libvlc_video_get_spu( libvlc_input_t *, libvlc_exception_t *
* \param i_spu new video subtitle to select
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_video_set_spu( libvlc_input_t *, int , libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_video_set_spu( libvlc_media_instance_t *, int , libvlc_exception_t * );
/**
* Get current crop filter geometry
......@@ -416,7 +432,7 @@ VLC_PUBLIC_API void libvlc_video_set_spu( libvlc_input_t *, int , libvlc_excepti
* \param p_exception an initialized exception
* \return the crop filter geometry
*/
VLC_PUBLIC_API char *libvlc_video_get_crop_geometry( libvlc_input_t *, libvlc_exception_t * );
VLC_PUBLIC_API char *libvlc_video_get_crop_geometry( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Set new crop filter geometry
......@@ -424,7 +440,7 @@ VLC_PUBLIC_API char *libvlc_video_get_crop_geometry( libvlc_input_t *, libvlc_ex
* \param psz_geometry new crop filter geometry
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_video_set_crop_geometry( libvlc_input_t *, char *, libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_video_set_crop_geometry( libvlc_media_instance_t *, char *, libvlc_exception_t * );
/**
* Take a snapshot of the current video window
......@@ -432,9 +448,9 @@ VLC_PUBLIC_API void libvlc_video_set_crop_geometry( libvlc_input_t *, char *, li
* \param psz_filepath the path where to save the screenshot to
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_video_take_snapshot( libvlc_media_instance_t *, char *, libvlc_exception_t * );
VLC_PUBLIC_API int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
VLC_PUBLIC_API int libvlc_video_destroy( libvlc_media_instance_t *, libvlc_exception_t *);
/**
* Resize the current video output window
......@@ -444,7 +460,7 @@ VLC_PUBLIC_API int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *)
* \param p_exception an initialized exception
* \return the success status (boolean)
*/
VLC_PUBLIC_API void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
VLC_PUBLIC_API void libvlc_video_resize( libvlc_media_instance_t *, int, int, libvlc_exception_t *);
/**
* change the parent for the current the video output
......@@ -453,7 +469,7 @@ VLC_PUBLIC_API void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exce
* \param p_exception an initialized exception
* \return the success status (boolean)
*/
VLC_PUBLIC_API int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, libvlc_exception_t * );
VLC_PUBLIC_API int libvlc_video_reparent( libvlc_media_instance_t *, libvlc_drawable_t, libvlc_exception_t * );
/**
* Tell windowless video output to redraw rectangular area (MacOS X only)
......@@ -461,7 +477,7 @@ VLC_PUBLIC_API int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, l
* \param area coordinates within video drawable
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_video_redraw_rectangle( libvlc_input_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_video_redraw_rectangle( libvlc_media_instance_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
/**
* Set the default video output parent
......@@ -563,7 +579,7 @@ VLC_PUBLIC_API void libvlc_audio_set_volume( libvlc_instance_t *, int, libvlc_ex
+ * \param p_exception an initialized exception
+ * \return the audio track (int)
+ */
VLC_PUBLIC_API int libvlc_audio_get_track( libvlc_input_t *, libvlc_exception_t * );
VLC_PUBLIC_API int libvlc_audio_get_track( libvlc_media_instance_t *, libvlc_exception_t * );
/**
* Set current audio track
......@@ -571,7 +587,7 @@ VLC_PUBLIC_API int libvlc_audio_get_track( libvlc_input_t *, libvlc_exception_t
* \param i_track the track (int)
* \param p_exception an initialized exception
*/
VLC_PUBLIC_API void libvlc_audio_set_track( libvlc_input_t *, int, libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_audio_set_track( libvlc_media_instance_t *, int, libvlc_exception_t * );
/**
* Get current audio channel
......
......@@ -79,6 +79,19 @@ typedef struct libvlc_media_descriptor_t libvlc_media_descriptor_t;
/**@} */
/*****************************************************************************
* Media Instance
*****************************************************************************/
/** defgroup libvlc_media_instance MediaInstance
* \ingroup libvlc
* LibVLC Media Instance handling
* @{
*/
typedef struct libvlc_media_instance_t libvlc_media_instance_t;
/**@} */
/*****************************************************************************
* Playlist
......
......@@ -28,33 +28,6 @@
#include <vlc_input.h>
#include <vlc_aout.h>
/*
* Remember to release the returned input_thread_t since it is locked at
* the end of this function.
*/
static input_thread_t *GetInput( libvlc_input_t *p_input,
libvlc_exception_t *p_exception )
{
input_thread_t *p_input_thread = NULL;
if( !p_input )
{
libvlc_exception_raise( p_exception, "Input is NULL" );
return NULL;
}
p_input_thread = (input_thread_t*)vlc_object_get(
p_input->p_instance->p_libvlc_int,
p_input->i_input_id );
if( !p_input_thread )
{
libvlc_exception_raise( p_exception, "Input does not exist" );
return NULL;
}
return p_input_thread;
}
/*
* Remember to release the returned aout_instance_t since it is locked at
* the end of this function.
......@@ -142,10 +115,10 @@ void libvlc_audio_set_volume( libvlc_instance_t *p_instance, int i_volume,
/*****************************************************************************
* libvlc_audio_get_track : Get the current audio track
*****************************************************************************/
int libvlc_audio_get_track( libvlc_input_t *p_input,
int libvlc_audio_get_track( libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = GetInput( p_input, p_e );
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
vlc_value_t val_list;
vlc_value_t val;
int i_track = -1;
......@@ -180,10 +153,10 @@ int libvlc_audio_get_track( libvlc_input_t *p_input,
/*****************************************************************************
* libvlc_audio_set_track : Set the current audio track
*****************************************************************************/
void libvlc_audio_set_track( libvlc_input_t *p_input, int i_track,
void libvlc_audio_set_track( libvlc_media_instance_t *p_mi, int i_track,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread = GetInput( p_input, p_e );
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
vlc_value_t val_list;
int i_ret = -1;
int i;
......
......@@ -90,15 +90,17 @@ static int handle_event( vlc_object_t *p_this, char const *psz_cmd,
static input_thread_t * get_input(libvlc_instance_t * p_instance)
{
libvlc_exception_t p_e_unused; /* FIXME: error checking here */
libvlc_input_t * p_libvlc_input = libvlc_playlist_get_input( p_instance, &p_e_unused );
libvlc_media_instance_t * p_mi;
input_thread_t * p_input;
if( !p_libvlc_input )
p_mi = libvlc_playlist_get_media_instance( p_instance, &p_e_unused );
if( !p_mi )
return NULL;
p_input = libvlc_get_input_thread( p_libvlc_input, &p_e_unused );
libvlc_input_free(p_libvlc_input);
p_input = libvlc_get_input_thread( p_mi, &p_e_unused );
libvlc_media_instance_destroy( p_mi );
return p_input;
}
......
/*****************************************************************************
* input.c: Libvlc new API input management functions
* media_instance.c: Libvlc API Media Instance management functions
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
* $Id$
......@@ -27,43 +27,161 @@
#include <vlc_input.h>
#include "input/input_internal.h"
void libvlc_input_free( libvlc_input_t *p_input )
{
if( p_input ) free( p_input );
}
/*
* Retrieve the input thread. Be sure to release the object
* once you are done with it. (libvlc Internal)
*/
input_thread_t *libvlc_get_input_thread( libvlc_input_t *p_input,
input_thread_t *libvlc_get_input_thread( libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread;
if( !p_input )
if( !p_mi || p_mi->i_input_id == -1 )
RAISENULL( "Input is NULL" );
p_input_thread = (input_thread_t*)vlc_object_get(
p_input->p_instance->p_libvlc_int,
p_input->i_input_id );
p_mi->p_libvlc_instance->p_libvlc_int,
p_mi->i_input_id );
if( !p_input_thread )
RAISENULL( "Input does not exist" );
return p_input_thread;
}
/**************************************************************************
* Create a Media Instance object
**************************************************************************/
libvlc_media_instance_t *
libvlc_media_instance_new( libvlc_media_descriptor_t *p_md )
{
libvlc_media_instance_t * p_mi;
if( !p_md )
return NULL;
p_mi = malloc( sizeof(libvlc_media_instance_t) );
p_mi->p_md = libvlc_media_descriptor_duplicate( p_md );
p_mi->p_libvlc_instance = p_mi->p_md->p_libvlc_instance;
p_mi->i_input_id = -1;
return p_mi;
}
/**************************************************************************
* Create a new media instance object from an input_thread (Libvlc Internal)
**************************************************************************/
libvlc_media_instance_t * libvlc_media_instance_new_from_input_thread(
struct libvlc_instance_t *p_libvlc_instance,
input_thread_t *p_input )
{
libvlc_media_instance_t * p_mi;
p_mi = malloc( sizeof(libvlc_media_instance_t) );
p_mi->p_md = libvlc_media_descriptor_new_from_input_item(
p_libvlc_instance,
p_input->p->input.p_item );
p_mi->p_libvlc_instance = p_libvlc_instance;
p_mi->i_input_id = p_input->i_object_id;
return p_mi;
}
/**************************************************************************
* Destroy a Media Instance object
**************************************************************************/
void libvlc_media_instance_destroy( libvlc_media_instance_t *p_mi )
{
input_thread_t *p_input_thread;
libvlc_exception_t p_e;
/* XXX: locking */
libvlc_exception_init( &p_e );
if( !p_mi )
return;
p_input_thread = libvlc_get_input_thread( p_mi, &p_e );
if( libvlc_exception_raised( &p_e ) )
return; /* no need to worry about no input thread */
input_DestroyThread( p_input_thread );
libvlc_media_descriptor_destroy( p_mi->p_md );
free( p_mi );
}
/**************************************************************************
* Free a Media Instance object (libvlc internal)
**************************************************************************/
void libvlc_media_instance_destroy_and_detach( libvlc_media_instance_t *p_mi )
{
if( !p_mi )
return;
libvlc_media_descriptor_destroy( p_mi->p_md );
free( p_mi );
}
/**************************************************************************
* Play
**************************************************************************/
void libvlc_media_instance_play( libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t * p_input_thread;
if( p_mi->i_input_id != -1)
{
vlc_value_t val;
val.i_int = PLAYING_S;
/* A thread alread exists, send it a play message */
p_input_thread = libvlc_get_input_thread( p_mi, p_e );
if( libvlc_exception_raised( p_e ) )
return;
input_Control( p_input_thread, INPUT_CONTROL_SET_STATE, PLAYING_S );
return;
}
p_input_thread = input_CreateThread( p_mi->p_libvlc_instance->p_libvlc_int,
p_mi->p_md->p_input_item );
p_mi->i_input_id = p_input_thread->i_object_id;
}
/**************************************************************************
* Pause
**************************************************************************/
void libvlc_media_instance_pause( libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t * p_input_thread;
vlc_value_t val;
val.i_int = PAUSE_S;
p_input_thread = libvlc_get_input_thread( p_mi, p_e );
if( libvlc_exception_raised( p_e ) )
return;
input_Control( p_input_thread, INPUT_CONTROL_SET_STATE, val );
}
/**************************************************************************
* Getters for stream information
**************************************************************************/
vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
vlc_int64_t libvlc_media_instance_get_length(
libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread;
vlc_value_t val;
p_input_thread = libvlc_get_input_thread ( p_input, p_e);
p_input_thread = libvlc_get_input_thread ( p_mi, p_e);
if( !p_input_thread )
return -1;
......@@ -73,13 +191,14 @@ vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
return (val.i_time+500LL)/1000LL;
}
vlc_int64_t libvlc_input_get_time( libvlc_input_t *p_input,
vlc_int64_t libvlc_media_instance_get_time(
libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread;
vlc_value_t val;
p_input_thread = libvlc_get_input_thread ( p_input, p_e );
p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
if( !p_input_thread )
return -1;
......@@ -88,13 +207,15 @@ vlc_int64_t libvlc_input_get_time( libvlc_input_t *p_input,
return (val.i_time+500LL)/1000LL;
}
void libvlc_input_set_time( libvlc_input_t *p_input, vlc_int64_t time,
libvlc_exception_t *p_e )
void libvlc_media_instance_set_time(
libvlc_media_instance_t *p_mi,
vlc_int64_t time,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread;
vlc_value_t value;
p_input_thread = libvlc_get_input_thread ( p_input, p_e );
p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
if( !p_input_thread )
return;
......@@ -103,14 +224,16 @@ void libvlc_input_set_time( libvlc_input_t *p_input, vlc_int64_t time,
vlc_object_release( p_input_thread );
}
void libvlc_input_set_position( libvlc_input_t *p_input, float position,
void libvlc_media_instance_set_position(
libvlc_media_instance_t *p_mi,
float position,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread;
vlc_value_t val;
val.f_float = position;
p_input_thread = libvlc_get_input_thread ( p_input, p_e);
p_input_thread = libvlc_get_input_thread ( p_mi, p_e);
if( !p_input_thread )
return;
......@@ -118,13 +241,14 @@ void libvlc_input_set_position( libvlc_input_t *p_input, float position,
vlc_object_release( p_input_thread );
}
float libvlc_input_get_position( libvlc_input_t *p_input,
float libvlc_media_instance_get_position(
libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread;
vlc_value_t val;
p_input_thread = libvlc_get_input_thread ( p_input, p_e);
p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
if( !p_input_thread )
return -1.0;
......@@ -134,13 +258,14 @@ float libvlc_input_get_position( libvlc_input_t *p_input,
return val.f_float;
}
float libvlc_input_get_fps( libvlc_input_t *p_input,
libvlc_exception_t *p_e)
float libvlc_media_instance_get_fps(
libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e)
{
double f_fps = 0.0;
input_thread_t *p_input_thread;
p_input_thread = libvlc_get_input_thread ( p_input, p_e );
p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
if( !p_input_thread )
return 0.0;
......@@ -158,11 +283,12 @@ float libvlc_input_get_fps( libvlc_input_t *p_input,
}
}
vlc_bool_t libvlc_input_will_play( libvlc_input_t *p_input,
libvlc_exception_t *p_e)
vlc_bool_t libvlc_media_instance_will_play(
libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e)
{
input_thread_t *p_input_thread =
libvlc_get_input_thread ( p_input, p_e);
libvlc_get_input_thread ( p_mi, p_e);
if ( !p_input_thread )
return VLC_FALSE;
......@@ -175,8 +301,10 @@ vlc_bool_t libvlc_input_will_play( libvlc_input_t *p_input,
return VLC_FALSE;
}
void libvlc_input_set_rate( libvlc_input_t *p_input, float rate,
libvlc_exception_t *p_e )
void libvlc_media_instance_set_rate(
libvlc_media_instance_t *p_mi,
float rate,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread;
vlc_value_t val;
......@@ -186,7 +314,7 @@ void libvlc_input_set_rate( libvlc_input_t *p_input, float rate,
val.i_int = 1000.0f/rate;
p_input_thread = libvlc_get_input_thread ( p_input, p_e);
p_input_thread = libvlc_get_input_thread ( p_mi, p_e);
if ( !p_input_thread )
return;
......@@ -194,13 +322,14 @@ void libvlc_input_set_rate( libvlc_input_t *p_input, float rate,
vlc_object_release( p_input_thread );
}
float libvlc_input_get_rate( libvlc_input_t *p_input,
float libvlc_media_instance_get_rate(
libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread;
vlc_value_t val;
p_input_thread = libvlc_get_input_thread ( p_input, p_e);
p_input_thread = libvlc_get_input_thread ( p_mi, p_e);
if ( !p_input_thread )
return -1.0;
......@@ -210,13 +339,14 @@ float libvlc_input_get_rate( libvlc_input_t *p_input,
return (float)1000.0f/val.i_int;
}
int libvlc_input_get_state( libvlc_input_t *p_input,
int libvlc_media_instance_get_state(
libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e )
{
input_thread_t *p_input_thread;
vlc_value_t val;
p_input_thread = libvlc_get_input_thread ( p_input, p_e );
p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
if ( !p_input_thread )
return 0;
......
......@@ -31,6 +31,8 @@ extern "C" {
#include <vlc/vlc.h>
#include <vlc/libvlc_structures.h>
#include <vlc_input.h>
/***************************************************************************
* Internal creation and destruction functions
......@@ -82,18 +84,31 @@ struct libvlc_media_descriptor_t
libvlc_instance_t *p_libvlc_instance;
};
struct libvlc_input_t
struct libvlc_media_instance_t
{
int i_input_id; ///< Input object id. We don't use a pointer to
/// avoid any crash
struct libvlc_instance_t *p_instance; ///< Parent instance
int i_input_id; /* Input object id. We don't use a pointer to
avoid any crash */
struct libvlc_instance_t *p_libvlc_instance; /* Parent instance */
libvlc_media_descriptor_t *p_md; /* current media descriptor */
};
/***************************************************************************
* Other internal functions
***************************************************************************/
VLC_EXPORT (input_thread_t *, libvlc_get_input_thread,
( struct libvlc_input_t *, libvlc_exception_t * ) );
( struct libvlc_media_instance_t *, libvlc_exception_t * ) );
VLC_EXPORT (libvlc_media_instance_t *, libvlc_media_instance_new_from_input_thread,
( struct libvlc_instance_t *, input_thread_t * ) );
VLC_EXPORT (void, libvlc_media_instance_destroy_and_detach,
( libvlc_media_instance_t * ) );
VLC_EXPORT (libvlc_media_descriptor_t *, libvlc_media_descriptor_new_from_input_item,
( struct libvlc_instance_t *, input_item_t * ) );
VLC_EXPORT (libvlc_media_descriptor_t *, libvlc_media_descriptor_duplicate,
( libvlc_media_descriptor_t * ) );
#define RAISENULL( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
return NULL; }
......
......@@ -58,7 +58,7 @@ libvlc_media_descriptor_t * libvlc_media_descriptor_new(
if (!p_input_item)
return NULL; /* XXX: throw an exception */
p_media_desc = malloc( sizeof(libvlc_input_t) );
p_media_desc = malloc( sizeof(libvlc_media_descriptor_t) );
p_media_desc->p_libvlc_instance = p_instance;
p_media_desc->p_input_item = p_input_item;
p_media_desc->b_preparsed = VLC_FALSE;
......@@ -66,22 +66,57 @@ libvlc_media_descriptor_t * libvlc_media_descriptor_new(
return p_media_desc;
}
/**************************************************************************
* Create a new media descriptor object from an input_item
* (libvlc internal)
**************************************************************************/
libvlc_media_descriptor_t * libvlc_media_descriptor_new_from_input_item(
libvlc_instance_t *p_instance,
input_item_t *p_input_item )
{
libvlc_media_descriptor_t * p_media_desc;
if (!p_input_item)
return NULL; /* XXX: throw an exception */
p_media_desc = malloc( sizeof(libvlc_media_descriptor_t) );
p_media_desc->p_libvlc_instance = p_instance;
p_media_desc->p_input_item = p_input_item;
p_media_desc->b_preparsed = VLC_TRUE;