Commit 8f9c3647 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

LibVLC: use VLC variables inheritance for drawable and UI events

parent e49d07aa
......@@ -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
}
/**************************************************************************
......
......@@ -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 */
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment