libvlc: Rename input to media_instance. And add the possibility to create a medi_inst...
authorPierre d'Herbemont <pdherbemont@videolan.org>
Sun, 17 Jun 2007 20:54:32 +0000 (20:54 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Sun, 17 Jun 2007 20:54:32 +0000 (20:54 +0000)
include/vlc/libvlc.h
include/vlc/libvlc_structures.h
src/control/audio.c
src/control/event.c
src/control/input.c
src/control/libvlc_internal.h
src/control/media_descriptor.c
src/control/mediacontrol_audio_video.c
src/control/mediacontrol_core.c
src/control/playlist.c
src/control/video.c

index 71d95fe..518f39c 100644 (file)
@@ -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
index 72b1f92..d04533f 100644 (file)
@@ -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
index c90d785..24abbdf 100644 (file)
 #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;
index 5f3c670..d67c148 100644 (file)
@@ -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;
 }
index 793484c..c10bbb2 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * input.c: Libvlc new API input management functions
+ * media_instance.c: Libvlc API Media Instance management functions
  *****************************************************************************
  * Copyright (C) 2005 the VideoLAN team
  * $Id$
 #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;
 
index 2e7b5c0..cf16b60 100644 (file)
@@ -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; }
index 48511c9..d55ead0 100644 (file)
@@ -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;
+
+    return p_media_desc;
+}
+
 /**************************************************************************
  * Delete a media descriptor object
  **************************************************************************/
-void libvlc_media_descriptor_destroy( libvlc_media_descriptor_t *p_meta_desc )
+void libvlc_media_descriptor_destroy( libvlc_media_descriptor_t *p_md )
 {
-    if (!p_meta_desc)
+    if (!p_md)
         return;
 
     /* XXX: locking */
-    input_ItemClean( p_meta_desc->p_input_item );
+    input_ItemClean( p_md->p_input_item );
+
+    free( p_md );
+}
+
+/**************************************************************************
+ * Delete a media descriptor object
+ **************************************************************************/
+libvlc_media_descriptor_t *
+libvlc_media_descriptor_duplicate( libvlc_media_descriptor_t *p_md_orig )
+{
+    libvlc_media_descriptor_t * p_md;
+
+    p_md = malloc( sizeof(libvlc_media_descriptor_t) );
+    bcopy( p_md_orig, p_md, sizeof(libvlc_media_descriptor_t) );
 
-    free( p_meta_desc );
+    return p_md;
 }
 
 /**************************************************************************
- * Getters for meta information
+ * Getter for meta information
  **************************************************************************/
 static const int meta_conversion[] =
 {
index f3a0be5..584f504 100644 (file)
@@ -283,17 +283,17 @@ mediacontrol_get_rate( mediacontrol_Instance *self,
                       mediacontrol_Exception *exception )
 {
     libvlc_exception_t ex;
-    libvlc_input_t* p_input;
+    libvlc_media_instance_t* p_mi;
     int i_ret;
 
     mediacontrol_exception_init( exception );
     libvlc_exception_init( &ex );
 
-    p_input = libvlc_playlist_get_input( self->p_instance, &ex );
+    p_mi = libvlc_playlist_get_media_instance( self->p_instance, &ex );
     HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
 
-    i_ret = libvlc_input_get_rate( p_input, &ex );
-    libvlc_input_free( p_input );
+    i_ret = libvlc_media_instance_get_rate( p_mi, &ex );
+    libvlc_media_instance_destroy_and_detach( p_mi );
     HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
 
     return i_ret / 10;
@@ -305,16 +305,16 @@ mediacontrol_set_rate( mediacontrol_Instance *self,
                       mediacontrol_Exception *exception )
 {
     libvlc_exception_t ex;
-    libvlc_input_t* p_input;
+    libvlc_media_instance_t* p_mi;
 
     mediacontrol_exception_init( exception );
     libvlc_exception_init( &ex );
 
-    p_input = libvlc_playlist_get_input( self->p_instance, &ex );
+    p_mi = libvlc_playlist_get_media_instance( self->p_instance, &ex );
     HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
 
-    libvlc_input_set_rate( p_input, rate * 10, &ex );
-    libvlc_input_free( p_input );
+    libvlc_media_instance_set_rate( p_mi, rate * 10, &ex );
+    libvlc_media_instance_destroy_and_detach( p_mi );
     HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
 }
 
@@ -323,17 +323,17 @@ mediacontrol_get_fullscreen( mediacontrol_Instance *self,
                             mediacontrol_Exception *exception )
 {
     libvlc_exception_t ex;
-    libvlc_input_t* p_input;
+    libvlc_media_instance_t* p_mi;
     int i_ret;
 
     mediacontrol_exception_init( exception );
     libvlc_exception_init( &ex );
 
-    p_input = libvlc_playlist_get_input( self->p_instance, &ex );
+    p_mi = libvlc_playlist_get_media_instance( self->p_instance, &ex );
     HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
 
-    i_ret = libvlc_get_fullscreen( p_input, &ex );
-    libvlc_input_free( p_input );
+    i_ret = libvlc_get_fullscreen( p_mi, &ex );
+    libvlc_media_instance_destroy_and_detach( p_mi );
     HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );
 
     return i_ret;
@@ -345,15 +345,15 @@ mediacontrol_set_fullscreen( mediacontrol_Instance *self,
                             mediacontrol_Exception *exception )
 {
     libvlc_exception_t ex;
-    libvlc_input_t* p_input;
+    libvlc_media_instance_t* p_mi;
 
     mediacontrol_exception_init( exception );
     libvlc_exception_init( &ex );
 
-    p_input = libvlc_playlist_get_input( self->p_instance, &ex );
+    p_mi = libvlc_playlist_get_media_instance( self->p_instance, &ex );
     HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
 
-    libvlc_set_fullscreen( p_input, b_fullscreen, &ex );
-    libvlc_input_free( p_input );
+    libvlc_set_fullscreen( p_mi, b_fullscreen, &ex );
+    libvlc_media_instance_destroy_and_detach( p_mi );
     HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
 }
index e561b60..db2907c 100644 (file)
@@ -124,7 +124,7 @@ mediacontrol_get_media_position( mediacontrol_Instance *self,
     mediacontrol_Position* retval = NULL;
     libvlc_exception_t ex;
     vlc_int64_t pos;
-    libvlc_input_t * p_input;
+    libvlc_media_instance_t * p_mi;
 
     mediacontrol_exception_init( exception );
     libvlc_exception_init( &ex );
@@ -133,19 +133,19 @@ mediacontrol_get_media_position( mediacontrol_Instance *self,
     retval->origin = an_origin;
     retval->key = a_key;
 
-    p_input = libvlc_playlist_get_input( self->p_instance, &ex);
+    p_mi = libvlc_playlist_get_media_instance( self->p_instance, &ex);
     HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
 
     if(  an_origin != mediacontrol_AbsolutePosition )
     {
-        libvlc_input_free( p_input );
+        libvlc_media_instance_destroy_and_detach( p_mi );
         /* Relative or ModuloPosition make no sense */
         RAISE_NULL( mediacontrol_PositionOriginNotSupported,
                     "Only absolute position is valid." );
     }
 
     /* We are asked for an AbsolutePosition. */
-    pos = libvlc_input_get_time( p_input, &ex );
+    pos = libvlc_media_instance_get_time( p_mi, &ex );
 
     if( a_key == mediacontrol_MediaTime )
     {
@@ -155,7 +155,7 @@ mediacontrol_get_media_position( mediacontrol_Instance *self,
     {
         if( ! self->p_playlist->p_input )
         {
-            libvlc_input_free( p_input );
+            libvlc_media_instance_destroy_and_detach( p_mi );
             RAISE_NULL( mediacontrol_InternalException,
                         "No input" );
         }
@@ -164,7 +164,7 @@ mediacontrol_get_media_position( mediacontrol_Instance *self,
                                                    a_key,
                                                    pos );
     }
-    libvlc_input_free( p_input );
+    libvlc_media_instance_destroy_and_detach( p_mi );
     return retval;
 }
 
@@ -174,19 +174,19 @@ mediacontrol_set_media_position( mediacontrol_Instance *self,
                                  const mediacontrol_Position * a_position,
                                  mediacontrol_Exception *exception )
 {
-    libvlc_input_t * p_input;
+    libvlc_media_instance_t * p_mi;
     libvlc_exception_t ex;
     vlc_int64_t i_pos;
 
     libvlc_exception_init( &ex );
     mediacontrol_exception_init( exception );
 
-    p_input = libvlc_playlist_get_input( self->p_instance, &ex);
+    p_mi = libvlc_playlist_get_media_instance( self->p_instance, &ex);
     HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
 
     i_pos = mediacontrol_position2microsecond( self->p_playlist->p_input, a_position );
-    libvlc_input_set_time( p_input, i_pos / 1000, &ex );
-    libvlc_input_free( p_input );
+    libvlc_media_instance_set_time( p_mi, i_pos / 1000, &ex );
+    libvlc_media_instance_destroy_and_detach( p_mi );
     HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
 }
 
index 9b626b1..c5a085a 100644 (file)
@@ -211,29 +211,17 @@ void libvlc_playlist_unlock( libvlc_instance_t *p_instance )
     vlc_mutex_unlock( &PL->object_lock );
 }
 
-libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
-                                            libvlc_exception_t *p_e )
+libvlc_media_instance_t * libvlc_playlist_get_media_instance(
+                                libvlc_instance_t *p_instance,
+                                libvlc_exception_t *p_e )
 {
-    libvlc_input_t *p_input;
+    libvlc_media_instance_t *p_mi;
     assert( PL );
 
     vlc_mutex_lock( &PL->object_lock );
-    if( PL->p_input == NULL )
-    {
-        libvlc_exception_raise( p_e, "No active input" );
-        vlc_mutex_unlock( &PL->object_lock );
-        return NULL;
-    }
-    p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
-    if( !p_input )
-    {
-        libvlc_exception_raise( p_e, "out of memory" );
-        vlc_mutex_unlock( &PL->object_lock );
-        return NULL;
-    }
-    p_input->i_input_id = PL->p_input->i_object_id;
-    p_input->p_instance = p_instance;
+    p_mi = libvlc_media_instance_new_from_input_thread(
+                        p_instance, PL->p_input );
     vlc_mutex_unlock( &PL->object_lock );
 
-    return p_input;
+    return p_mi;
 }
index 962244b..881be2d 100644 (file)
 #include <vlc_input.h>
 #include <vlc_vout.h>
 
-/*
- * Remember to release the returned input_thread_t since it is locked at
- * the end of this function.
- */
-static input_thread_t *GetInputThread( libvlc_input_t *p_input,
-                               libvlc_exception_t *p_exception )
-{
-    input_thread_t *p_input_thread;
-
-    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 vout_thread_t since it is locked at
  * the end of this function.
  */
-static vout_thread_t *GetVout( libvlc_input_t *p_input,
+static vout_thread_t *GetVout( libvlc_media_instance_t *p_mi,
                                libvlc_exception_t *p_exception )
 {
-    input_thread_t *p_input_thread = GetInputThread(p_input, p_exception);
+    input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_exception );
     vout_thread_t *p_vout = NULL;
 
     if( p_input_thread )
@@ -83,11 +56,11 @@ static vout_thread_t *GetVout( libvlc_input_t *p_input,
  * Exported functions
  **********************************************************************/
 
-void libvlc_set_fullscreen( libvlc_input_t *p_input, int b_fullscreen,
+void libvlc_set_fullscreen( libvlc_media_instance_t *p_mi, int b_fullscreen,
                             libvlc_exception_t *p_e )
 {
     /* We only work on the first vout */
-    vout_thread_t *p_vout1 = GetVout( p_input, p_e );
+    vout_thread_t *p_vout1 = GetVout( p_mi, p_e );
     vlc_value_t val; int i_ret;
 
     /* GetVout will raise the exception for us */
@@ -107,11 +80,11 @@ void libvlc_set_fullscreen( libvlc_input_t *p_input, int b_fullscreen,
     vlc_object_release( p_vout1 );
 }
 
-int libvlc_get_fullscreen( libvlc_input_t *p_input,
+int libvlc_get_fullscreen( libvlc_media_instance_t *p_mi,
                             libvlc_exception_t *p_e )
 {
     /* We only work on the first vout */
-    vout_thread_t *p_vout1 = GetVout( p_input, p_e );
+    vout_thread_t *p_vout1 = GetVout( p_mi, p_e );
     vlc_value_t val; int i_ret;
 
     /* GetVout will raise the exception for us */
@@ -126,11 +99,11 @@ int libvlc_get_fullscreen( libvlc_input_t *p_input,
     return val.b_bool == VLC_TRUE ? 1 : 0;
 }
 
-void libvlc_toggle_fullscreen( libvlc_input_t *p_input,
+void libvlc_toggle_fullscreen( libvlc_media_instance_t *p_mi,
                                libvlc_exception_t *p_e )
 {
     /* We only work on the first vout */
-    vout_thread_t *p_vout1 = GetVout( p_input, p_e );
+    vout_thread_t *p_vout1 = GetVout( p_mi, p_e );
     vlc_value_t val; int i_ret;
 
     /* GetVout will raise the exception for us */
@@ -152,10 +125,10 @@ void libvlc_toggle_fullscreen( libvlc_input_t *p_input,
 }
 
 void
-libvlc_video_take_snapshot( libvlc_input_t *p_input, char *psz_filepath,
+libvlc_video_take_snapshot( libvlc_media_instance_t *p_mi, char *psz_filepath,
                        libvlc_exception_t *p_e )
 {
-    vout_thread_t *p_vout = GetVout( p_input, p_e );
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
     input_thread_t *p_input_thread;
 
     /* GetVout will raise the exception for us */
@@ -172,8 +145,8 @@ libvlc_video_take_snapshot( libvlc_input_t *p_input, char *psz_filepath,
 
 
     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 )
     {
         libvlc_exception_raise( p_e, "Input does not exist" );
@@ -188,10 +161,10 @@ libvlc_video_take_snapshot( libvlc_input_t *p_input, char *psz_filepath,
     vlc_object_release( p_input_thread );
 }
 
-int libvlc_video_get_height( libvlc_input_t *p_input,
+int libvlc_video_get_height( libvlc_media_instance_t *p_mi,
                              libvlc_exception_t *p_e ) 
 {
-    vout_thread_t *p_vout1 = GetVout( p_input, p_e );
+    vout_thread_t *p_vout1 = GetVout( p_mi, p_e );
     if( !p_vout1 )
         return 0;
 
@@ -200,10 +173,10 @@ int libvlc_video_get_height( libvlc_input_t *p_input,
     return p_vout1->i_window_height;
 }
 
-int libvlc_video_get_width( libvlc_input_t *p_input,
+int libvlc_video_get_width( libvlc_media_instance_t *p_mi,
                             libvlc_exception_t *p_e ) 
 {
-    vout_thread_t *p_vout1 = GetVout( p_input, p_e );
+    vout_thread_t *p_vout1 = GetVout( p_mi, p_e );
     if( !p_vout1 )
         return 0;
 
@@ -212,10 +185,10 @@ int libvlc_video_get_width( libvlc_input_t *p_input,
     return p_vout1->i_window_width;
 }
 
-vlc_bool_t libvlc_input_has_vout( libvlc_input_t *p_input,
+vlc_bool_t libvlc_input_has_vout( libvlc_media_instance_t *p_mi,
                                   libvlc_exception_t *p_e )
 {
-    input_thread_t *p_input_thread = GetInputThread(p_input, p_e);
+    input_thread_t *p_input_thread = libvlc_get_input_thread(p_mi, p_e);
     vlc_bool_t has_vout = VLC_FALSE;
 
     if( p_input_thread )
@@ -233,10 +206,10 @@ vlc_bool_t libvlc_input_has_vout( libvlc_input_t *p_input,
     return has_vout;
 }
 
-int libvlc_video_reparent( libvlc_input_t *p_input, libvlc_drawable_t d,
+int libvlc_video_reparent( libvlc_media_instance_t *p_mi, libvlc_drawable_t d,
                            libvlc_exception_t *p_e )
 {
-    vout_thread_t *p_vout = GetVout( p_input, p_e );
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
 
     if( p_vout )
     {
@@ -246,9 +219,9 @@ int libvlc_video_reparent( libvlc_input_t *p_input, libvlc_drawable_t d,
     return 0;
 }
 
-void libvlc_video_resize( libvlc_input_t *p_input, int width, int height, libvlc_exception_t *p_e )
+void libvlc_video_resize( libvlc_media_instance_t *p_mi, int width, int height, libvlc_exception_t *p_e )
 {
-    vout_thread_t *p_vout = GetVout( p_input, p_e );
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
     if( p_vout )
     {
         vout_Control( p_vout, VOUT_SET_SIZE, width, height );
@@ -256,7 +229,7 @@ void libvlc_video_resize( libvlc_input_t *p_input, int width, int height, libvlc
     }
 }
 
-void libvlc_video_redraw_rectangle( libvlc_input_t *p_input,
+void libvlc_video_redraw_rectangle( libvlc_media_instance_t *p_mi,
                            const libvlc_rectangle_t *area,
                            libvlc_exception_t *p_e )
 {
@@ -264,7 +237,7 @@ void libvlc_video_redraw_rectangle( libvlc_input_t *p_input,
      && ((area->bottom - area->top) > 0)
      && ((area->right - area->left) > 0) )
     {
-        vout_thread_t *p_vout = GetVout( p_input, p_e );
+        vout_thread_t *p_vout = GetVout( p_mi, p_e );
         if( p_vout )
         {
             /* tell running vout to redraw area */
@@ -285,17 +258,17 @@ void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d
 
     if( libvlc_playlist_isplaying(p_instance, p_e) )
     {
-        libvlc_input_t *p_input = libvlc_playlist_get_input(p_instance, p_e);
-        if( p_input )
+        libvlc_media_instance_t *p_mi = libvlc_playlist_get_media_instance(p_instance, p_e);
+        if( p_mi )
         {
-            vout_thread_t *p_vout = GetVout( p_input, p_e );
+            vout_thread_t *p_vout = GetVout( p_mi, p_e );
             if( p_vout )
             {
                 /* tell running vout to re-parent */
                 vout_Control( p_vout , VOUT_REPARENT, d);
                 vlc_object_release( p_vout );
             }
-            libvlc_input_free(p_input);
+            libvlc_media_instance_destroy_and_detach(p_mi);
         }
     }
 }
@@ -319,17 +292,17 @@ void libvlc_video_set_size( libvlc_instance_t *p_instance, int width, int height
 
     if( libvlc_playlist_isplaying(p_instance, p_e) )
     {
-        libvlc_input_t *p_input = libvlc_playlist_get_input(p_instance, p_e);
-        if( p_input )
+        libvlc_media_instance_t *p_mi = libvlc_playlist_get_media_instance(p_instance, p_e);
+        if( p_mi )
         {
-            vout_thread_t *p_vout = GetVout( p_input, p_e );
+            vout_thread_t *p_vout = GetVout( p_mi, p_e );
             if( p_vout )
             {
                 /* tell running vout to re-size */
                 vout_Control( p_vout , VOUT_SET_SIZE, width, height);
                 vlc_object_release( p_vout );
             }
-            libvlc_input_free(p_input);
+            libvlc_media_instance_destroy_and_detach(p_mi);
         }
     }
 }
@@ -359,10 +332,10 @@ void libvlc_video_set_viewport( libvlc_instance_t *p_instance,
 
     if( libvlc_playlist_isplaying(p_instance, p_e) )
     {
-        libvlc_input_t *p_input = libvlc_playlist_get_input(p_instance, p_e);
-        if( p_input )
+        libvlc_media_instance_t *p_mi = libvlc_playlist_get_media_instance(p_instance, p_e);
+        if( p_mi )
         {
-            vout_thread_t *p_vout = GetVout( p_input, p_e );
+            vout_thread_t *p_vout = GetVout( p_mi, p_e );
             if( p_vout )
             {
                 /* change viewport for running vout */
@@ -371,16 +344,16 @@ void libvlc_video_set_viewport( libvlc_instance_t *p_instance,
                                    clip->top, clip->left, clip->bottom, clip->right );
                 vlc_object_release( p_vout );
             }
-            libvlc_input_free(p_input);
+            libvlc_media_instance_destroy_and_detach(p_mi);
         }
     }
 }
 
-char *libvlc_video_get_aspect_ratio( libvlc_input_t *p_input,
+char *libvlc_video_get_aspect_ratio( libvlc_media_instance_t *p_mi,
                                      libvlc_exception_t *p_e )
 {
     char *psz_aspect = 0;
-    vout_thread_t *p_vout = GetVout( p_input, p_e );
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
 
     if( !p_vout )
         return 0;
@@ -390,10 +363,10 @@ char *libvlc_video_get_aspect_ratio( libvlc_input_t *p_input,
     return psz_aspect;
 }
 
-void libvlc_video_set_aspect_ratio( libvlc_input_t *p_input,
+void libvlc_video_set_aspect_ratio( libvlc_media_instance_t *p_mi,
                                     char *psz_aspect, libvlc_exception_t *p_e )
 {
-    vout_thread_t *p_vout = GetVout( p_input, p_e );
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
     int i_ret = -1;
 
     if( !p_vout )
@@ -407,10 +380,10 @@ void libvlc_video_set_aspect_ratio( libvlc_input_t *p_input,
     vlc_object_release( p_vout );
 }
 
-int libvlc_video_get_spu( libvlc_input_t *p_input,
+int libvlc_video_get_spu( libvlc_media_instance_t *p_mi,
                           libvlc_exception_t *p_e )
 {
-    input_thread_t *p_input_thread = GetInputThread( 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_spu = -1;
@@ -442,10 +415,10 @@ int libvlc_video_get_spu( libvlc_input_t *p_input,
     return i_spu;
 }
 
-void libvlc_video_set_spu( libvlc_input_t *p_input, int i_spu,
+void libvlc_video_set_spu( libvlc_media_instance_t *p_mi, int i_spu,
                            libvlc_exception_t *p_e )
 {
-    input_thread_t *p_input_thread = GetInputThread( 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;
@@ -475,11 +448,11 @@ void libvlc_video_set_spu( libvlc_input_t *p_input, int i_spu,
     vlc_object_release( p_input_thread );
 }
 
-char *libvlc_video_get_crop_geometry( libvlc_input_t *p_input,
+char *libvlc_video_get_crop_geometry( libvlc_media_instance_t *p_mi,
                                    libvlc_exception_t *p_e )
 {
     char *psz_geometry = 0;
-    vout_thread_t *p_vout = GetVout( p_input, p_e );
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
 
     if( !p_vout )
         return 0;
@@ -489,10 +462,10 @@ char *libvlc_video_get_crop_geometry( libvlc_input_t *p_input,
     return psz_geometry;
 }
 
-void libvlc_video_set_crop_geometry( libvlc_input_t *p_input,
+void libvlc_video_set_crop_geometry( libvlc_media_instance_t *p_mi,
                                     char *psz_geometry, libvlc_exception_t *p_e )
 {
-    vout_thread_t *p_vout = GetVout( p_input, p_e );
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
     int i_ret = -1;
 
     if( !p_vout )
@@ -506,10 +479,10 @@ void libvlc_video_set_crop_geometry( libvlc_input_t *p_input,
     vlc_object_release( p_vout );
 }
 
-int libvlc_video_destroy( libvlc_input_t *p_input,
+int libvlc_video_destroy( libvlc_media_instance_t *p_mi,
                           libvlc_exception_t *p_e )
 {
-    vout_thread_t *p_vout = GetVout( p_input, p_e );
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
     vlc_object_detach( p_vout ); 
     vlc_object_release( p_vout );
     vout_Destroy( p_vout );