[vlc-devel] commit: LibVLC: use VLC variables inheritance for drawable and UI events ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sun Jan 31 17:57:34 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jan 31 18:56:56 2010 +0200| [8f9c3647ccfcd55cd6835ed90e98766a7f2eb677] | committer: Rémi Denis-Courmont
LibVLC: use VLC variables inheritance for drawable and UI events
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8f9c3647ccfcd55cd6835ed90e98766a7f2eb677
---
src/control/media_player.c | 92 ++++++++++++++++++++--------------
src/control/media_player_internal.h | 9 ---
src/control/video.c | 4 +-
3 files changed, 56 insertions(+), 49 deletions(-)
diff --git a/src/control/media_player.c b/src/control/media_player.c
index 7911ce8..e8f9379 100644
--- a/src/control/media_player.c
+++ b/src/control/media_player.c
@@ -111,10 +111,6 @@ static void release_input_thread( libvlc_media_player_t *p_mi, bool b_input_abor
/* Store the input resource for future use. */
p_mi->p_input_resource = input_DetachResource( p_input_thread );
- var_Destroy( p_input_thread, "drawable-hwnd" );
- var_Destroy( p_input_thread, "drawable-xid" );
- var_Destroy( p_input_thread, "drawable-agl" );
-
vlc_object_release( p_input_thread );
p_mi->p_input_thread = NULL;
@@ -350,12 +346,23 @@ libvlc_media_player_new( libvlc_instance_t *instance, libvlc_exception_t *e )
return NULL;
}
vlc_object_attach (mp, mp->p_libvlc);
+
+ /* Drawable */
+ var_Create (mp, "drawable-xid", VLC_VAR_INTEGER);
+#ifdef WIN32
+ var_Create (mp, "drawable-hwnd", VLC_VAR_ADDRESS);
+#endif
+#ifdef __APPLE__
+ var_Create (mp, "drawable-agl", VLC_VAR_INTEGER);
+ var_Create (mp, "drawable-nsobject", VLC_VAR_ADDRESS);
+#endif
+
+ /* Drawable input methods */
+ var_Create (mp, "keyboard-events", VLC_VAR_BOOL);
+ var_SetBool (mp, "keyboard-events", true);
+ var_Create (mp, "mouse-events", VLC_VAR_BOOL);
+
mp->p_md = NULL;
- mp->drawable.agl = 0;
- mp->drawable.xid = 0;
- mp->drawable.hwnd = NULL;
- mp->drawable.nsobject = NULL;
- mp->keyboard_events = mp->mouse_events = 1;
mp->state = libvlc_NothingSpecial;
mp->p_libvlc_instance = instance;
mp->p_input_thread = NULL;
@@ -601,27 +608,6 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi,
p_mi->p_input_resource = NULL;
p_input_thread = p_mi->p_input_thread;
- var_Create( p_input_thread, "drawable-agl", VLC_VAR_INTEGER );
- if( p_mi->drawable.agl )
- var_SetInteger( p_input_thread, "drawable-agl", p_mi->drawable.agl );
-
- var_Create( p_input_thread, "drawable-xid", VLC_VAR_INTEGER );
- if( p_mi->drawable.xid )
- var_SetInteger( p_input_thread, "drawable-xid", p_mi->drawable.xid );
-
- var_Create( p_input_thread, "drawable-hwnd", VLC_VAR_ADDRESS );
- if( p_mi->drawable.hwnd != NULL )
- var_SetAddress( p_input_thread, "drawable-hwnd", p_mi->drawable.hwnd );
-
- var_Create( p_input_thread, "drawable-nsobject", VLC_VAR_ADDRESS );
- if( p_mi->drawable.nsobject != NULL )
- var_SetAddress( p_input_thread, "drawable-nsobject", p_mi->drawable.nsobject );
-
- var_Create( p_input_thread, "keyboard-events", VLC_VAR_BOOL );
- var_SetBool( p_input_thread, "keyboard-events", p_mi->keyboard_events );
- var_Create( p_input_thread, "mouse-events", VLC_VAR_BOOL );
- var_SetBool( p_input_thread, "mouse-events", p_mi->mouse_events );
-
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, "intf-event", input_event_changed, p_mi );
@@ -700,7 +686,12 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi )
void libvlc_media_player_set_nsobject( libvlc_media_player_t *p_mi,
void * drawable )
{
- p_mi->drawable.nsobject = drawable;
+ assert (p_mi != NULL);
+#ifdef __APPLE__
+ var_SetAddress (p_mi, "drawable-nsobject", drawable);
+#else
+ (void) p_mi; (void)drawable;
+#endif
}
/**************************************************************************
@@ -708,7 +699,12 @@ void libvlc_media_player_set_nsobject( libvlc_media_player_t *p_mi,
**************************************************************************/
void * libvlc_media_player_get_nsobject( libvlc_media_player_t *p_mi )
{
- return p_mi->drawable.nsobject;
+ assert (p_mi != NULL);
+#ifdef __APPLE__
+ return var_GetAddress (p_mi, "drawable-nsobject");
+#else
+ return NULL;
+#endif
}
/**************************************************************************
@@ -717,7 +713,11 @@ void * libvlc_media_player_get_nsobject( libvlc_media_player_t *p_mi )
void libvlc_media_player_set_agl( libvlc_media_player_t *p_mi,
uint32_t drawable )
{
- p_mi->drawable.agl = drawable;
+#ifdef __APPLE__
+ var_SetInteger (p_mi, "drawable-agl", drawable);
+#else
+ (void) p_mi; (void)drawable;
+#endif
}
/**************************************************************************
@@ -725,7 +725,12 @@ void libvlc_media_player_set_agl( libvlc_media_player_t *p_mi,
**************************************************************************/
uint32_t libvlc_media_player_get_agl( libvlc_media_player_t *p_mi )
{
- return p_mi->drawable.agl;
+ assert (p_mi != NULL);
+#ifdef __APPLE__
+ return var_GetInteger (p_mi, "drawable-agl");
+#else
+ return 0;
+#endif
}
/**************************************************************************
@@ -734,7 +739,8 @@ uint32_t libvlc_media_player_get_agl( libvlc_media_player_t *p_mi )
void libvlc_media_player_set_xwindow( libvlc_media_player_t *p_mi,
uint32_t drawable )
{
- p_mi->drawable.xid = drawable;
+ assert (p_mi != NULL);
+ var_SetInteger (p_mi, "drawable-xid", drawable);
}
/**************************************************************************
@@ -742,7 +748,7 @@ void libvlc_media_player_set_xwindow( libvlc_media_player_t *p_mi,
**************************************************************************/
uint32_t libvlc_media_player_get_xwindow( libvlc_media_player_t *p_mi )
{
- return p_mi->drawable.xid;
+ return var_GetInteger (p_mi, "drawable-xid");
}
/**************************************************************************
@@ -751,7 +757,12 @@ uint32_t libvlc_media_player_get_xwindow( libvlc_media_player_t *p_mi )
void libvlc_media_player_set_hwnd( libvlc_media_player_t *p_mi,
void *drawable )
{
- p_mi->drawable.hwnd = drawable;
+ assert (p_mi != NULL);
+#ifdef WIN32
+ var_SetAddress (p_mi, "drawable-hwnd", drawable);
+#else
+ (void) p_mi; (void) drawable;
+#endif
}
/**************************************************************************
@@ -759,7 +770,12 @@ void libvlc_media_player_set_hwnd( libvlc_media_player_t *p_mi,
**************************************************************************/
void *libvlc_media_player_get_hwnd( libvlc_media_player_t *p_mi )
{
- return p_mi->drawable.hwnd;
+ assert (p_mi != NULL);
+#ifdef WIN32
+ return var_GetAddress (p_mi, "drawable-hwnd");
+#else
+ return NULL;
+#endif
}
/**************************************************************************
diff --git a/src/control/media_player_internal.h b/src/control/media_player_internal.h
index cf22cc0..96bb610 100644
--- a/src/control/media_player_internal.h
+++ b/src/control/media_player_internal.h
@@ -46,15 +46,6 @@ struct libvlc_media_player_t
libvlc_media_t * p_md; /* current media descriptor */
libvlc_event_manager_t * p_event_manager;
libvlc_state_t state;
- struct
- {
- void *hwnd;
- void *nsobject;
- uint32_t xid;
- uint32_t agl;
- } drawable;
- unsigned keyboard_events:1;
- unsigned mouse_events:1;
};
/* Media player - audio, video */
diff --git a/src/control/video.c b/src/control/video.c
index 3cec002..415605c 100644
--- a/src/control/video.c
+++ b/src/control/video.c
@@ -114,12 +114,12 @@ void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi,
void libvlc_video_set_key_input( libvlc_media_player_t *p_mi, unsigned on )
{
- p_mi->keyboard_events = !!on;
+ var_SetBool (p_mi, "keyboard-events", !!on);
}
void libvlc_video_set_mouse_input( libvlc_media_player_t *p_mi, unsigned on )
{
- p_mi->mouse_events = !!on;
+ var_SetBool (p_mi, "mouse-events", !!on);
}
void
More information about the vlc-devel
mailing list