Add libvlc_media_player_set_hwnd and libvlc_media_player_set_xid
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 7 Feb 2009 17:21:01 +0000 (19:21 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 7 Feb 2009 17:32:10 +0000 (19:32 +0200)
include/vlc/libvlc.h
include/vlc/libvlc_structures.h
src/control/libvlc_internal.h
src/control/media_player.c
src/libvlc.sym

index baab65f..a720c76 100644 (file)
@@ -445,7 +445,7 @@ VLC_PUBLIC_API void *
 /** \defgroup libvlc_media_player libvlc_media_player
  * \ingroup libvlc
  * LibVLC Media Player, object that let you play a media
 /** \defgroup libvlc_media_player libvlc_media_player
  * \ingroup libvlc
  * LibVLC Media Player, object that let you play a media
- * in a libvlc_drawable_t
+ * in a custom drawable
  * @{
  */
 
  * @{
  */
 
@@ -549,6 +549,37 @@ VLC_PUBLIC_API void libvlc_media_player_pause ( libvlc_media_player_t *, libvlc_
  */
 VLC_PUBLIC_API void libvlc_media_player_stop ( libvlc_media_player_t *, libvlc_exception_t * );
 
  */
 VLC_PUBLIC_API void libvlc_media_player_stop ( libvlc_media_player_t *, libvlc_exception_t * );
 
+/**
+ * Set an X Window System drawable where the media player should render its
+ * video output. If LibVLC was built without X11 output support, then this has
+ * no effects.
+ *
+ * The specified identifier must correspond to an existing Input/Output class
+ * X11 drawable. The caller shall ensure that the X11 server is the same as the
+ * one the VLC instance has been configured with.
+ * If XVideo is <b>not</b> supported or usable, it is assumed that the drawable
+ * has the following properties in common with the default X11 screen:
+ * depth, scan line pad, black pixel. This is a bug.
+ * Using a pixmap rather than a window might not work as VLC might try to
+ * get window properties and subscribe to window events.
+ *
+ * \param p_mi the Media Player
+ * \param drawable the ID of the X drawable
+ * \param p_e an initialized exception pointer
+ */
+VLC_PUBLIC_API void libvlc_media_player_set_xid ( libvlc_media_player_t *p_mi, uint32_t drawable, libvlc_exception_t *p_e );
+
+/**
+ * Set a Win32/Win64 API window handle (HWND) where the media player should
+ * render its video output. If LibVLC was built without Win32/Win64 API output
+ * support, then this has no effects.
+ *
+ * \param p_mi the Media Player
+ * \param drawable windows handle of the drawable
+ * \param p_e an initialized exception pointer
+ */
+VLC_PUBLIC_API void libvlc_media_player_set_hwnd ( libvlc_media_player_t *p_mi, void *drawable, libvlc_exception_t *p_e );
+
 /**
  * Set the drawable where the media player should render its video output.
  *
 /**
  * Set the drawable where the media player should render its video output.
  *
index 49ddbbb..e5e1be3 100644 (file)
@@ -214,7 +214,7 @@ typedef struct libvlc_playlist_item_t
 /** \defgroup libvlc_media_player libvlc_media_player
  * \ingroup libvlc
  * LibVLC Media Player, object that let you play a media
 /** \defgroup libvlc_media_player libvlc_media_player
  * \ingroup libvlc
  * LibVLC Media Player, object that let you play a media
- * in a libvlc_drawable_t
+ * in a drawable
  * @{
  */
 
  * @{
  */
 
index fb26449..9509735 100644 (file)
@@ -153,7 +153,7 @@ struct libvlc_media_player_t
     struct libvlc_instance_t *  p_libvlc_instance; /* Parent instance */
     libvlc_media_t * p_md; /* current media descriptor */
     libvlc_event_manager_t *    p_event_manager;
     struct libvlc_instance_t *  p_libvlc_instance; /* Parent instance */
     libvlc_media_t * p_md; /* current media descriptor */
     libvlc_event_manager_t *    p_event_manager;
-    union
+    struct
     {
         void *hwnd;
         uint32_t xid;
     {
         void *hwnd;
         uint32_t xid;
index 7be73ed..31589b3 100644 (file)
@@ -258,11 +258,8 @@ libvlc_media_player_new( libvlc_instance_t * p_libvlc_instance,
         return NULL;
     }
     p_mi->p_md = NULL;
         return NULL;
     }
     p_mi->p_md = NULL;
-#ifndef WIN32
     p_mi->drawable.xid = 0;
     p_mi->drawable.xid = 0;
-#else
     p_mi->drawable.hwnd = NULL;
     p_mi->drawable.hwnd = NULL;
-#endif
     p_mi->p_libvlc_instance = p_libvlc_instance;
     p_mi->p_input_thread = NULL;
     /* refcount strategy:
     p_mi->p_libvlc_instance = p_libvlc_instance;
     p_mi->p_input_thread = NULL;
     /* refcount strategy:
@@ -598,13 +595,15 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi,
     p_input_thread = p_mi->p_input_thread;
 
     var_Create( p_input_thread, "drawable-xid", VLC_VAR_INTEGER );
     p_input_thread = p_mi->p_input_thread;
 
     var_Create( p_input_thread, "drawable-xid", VLC_VAR_INTEGER );
-    var_Create( p_input_thread, "drawable-hwnd", VLC_VAR_ADDRESS );
+    if( p_mi->drawable.xid )
+        var_SetInteger( p_input_thread, "drawable-xid", p_mi->drawable.xid );
 
 
-#ifndef WIN32
-    var_SetInteger( p_input_thread, "drawable-xid", p_mi->drawable.xid );
-#else
-    var_SetInteger( p_input_thread, "drawable-hwnd", p_mi->drawable.hwnd );
-#endif
+    var_Create( p_input_thread, "drawable-hwnd", VLC_VAR_ADDRESS );
+    if( p_mi->drawable.hwnd != NULL )
+    {
+        vlc_value_t val = { .p_address = p_mi->drawable.hwnd };
+        var_Set( p_input_thread, "drawable-hwnd", val );
+    }
 
     var_AddCallback( p_input_thread, "can-seek", input_seekable_changed, p_mi );
     var_AddCallback( p_input_thread, "can-pause", input_pausable_changed, p_mi );
 
     var_AddCallback( p_input_thread, "can-seek", input_seekable_changed, p_mi );
     var_AddCallback( p_input_thread, "can-pause", input_pausable_changed, p_mi );
@@ -699,6 +698,22 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi,
     }
 }
 
     }
 }
 
+void libvlc_media_player_set_xid( libvlc_media_player_t *p_mi,
+                                  uint32_t drawable,
+                                  libvlc_exception_t *p_e )
+{
+    (void) p_e;
+    p_mi->drawable.xid = drawable;
+}
+
+void libvlc_media_player_set_hwnd( libvlc_media_player_t *p_mi,
+                                   void *drawable,
+                                   libvlc_exception_t *p_e )
+{
+    (void) p_e;
+    p_mi->drawable.hwnd = drawable;
+}
+
 /**************************************************************************
  * Set Drawable
  **************************************************************************/
 /**************************************************************************
  * Set Drawable
  **************************************************************************/
index 498da0c..3c46ec1 100644 (file)
@@ -147,11 +147,13 @@ libvlc_media_player_release
 libvlc_media_player_retain
 libvlc_media_player_set_chapter
 libvlc_media_player_set_drawable
 libvlc_media_player_retain
 libvlc_media_player_set_chapter
 libvlc_media_player_set_drawable
+libvlc_media_player_set_hwnd
 libvlc_media_player_set_media
 libvlc_media_player_set_position
 libvlc_media_player_set_rate
 libvlc_media_player_set_time
 libvlc_media_player_set_title
 libvlc_media_player_set_media
 libvlc_media_player_set_position
 libvlc_media_player_set_rate
 libvlc_media_player_set_time
 libvlc_media_player_set_title
+libvlc_media_player_set_xid
 libvlc_media_player_stop
 libvlc_media_player_will_play
 libvlc_media_release
 libvlc_media_player_stop
 libvlc_media_player_will_play
 libvlc_media_release