Commit 054e7db9 authored by Jean-Paul Saman's avatar Jean-Paul Saman

macosx: vout drawable rework.

The macosx drawable variable that used to hold the drawable window reference is splitted up in two variables "drawable-agl" (used by macosx safari/mozilla plugin) and "drawable-gl" (used by macosx interface).
parent 42bf6ff2
/***************************************************************************** /*****************************************************************************
* vout.m: MacOS X video output module * vout.m: MacOS X video output module
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2008 the VideoLAN team * Copyright (C) 2001-2009 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Colin Delacroix <colin@zoy.org> * Authors: Colin Delacroix <colin@zoy.org>
...@@ -338,7 +338,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -338,7 +338,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
- (void)setOnTop:(BOOL)b_on_top - (void)setOnTop:(BOOL)b_on_top
{ {
if( b_on_top ) if( b_on_top )
...@@ -711,11 +710,11 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -711,11 +710,11 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
+ (id)voutView: (vout_thread_t *)p_vout subView: (NSView *)view + (id)voutView: (vout_thread_t *)p_vout subView: (NSView *)view
frame: (NSRect *)s_frame frame: (NSRect *)s_frame
{ {
vlc_value_t value_drawable; int i_drawable_gl;
int i_timeout; int i_timeout;
id o_return = nil; id o_return = nil;
var_Get( p_vout->p_libvlc, "drawable", &value_drawable ); i_drawable_gl = var_GetInteger( p_vout->p_libvlc, "drawable-gl" );
var_Create( p_vout, "macosx-vdev", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "macosx-vdev", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "macosx-stretch", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_vout, "macosx-stretch", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
...@@ -726,9 +725,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -726,9 +725,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
/* We only wait for NSApp to initialise if we're not embedded (as in the /* We only wait for NSApp to initialise if we're not embedded (as in the
* case of the Mozilla plugin). We can tell whether we're embedded or not * case of the Mozilla plugin). We can tell whether we're embedded or not
* by examining the "drawable" value: if it's zero, we're running in the * by examining the "drawable-gl" value: if it's zero, we're running in the
* main Mac intf; if it's non-zero, we're embedded. */ * main Mac intf; if it's non-zero, we're embedded. */
if( value_drawable.i_int == 0 ) if( i_drawable_gl == 0 )
{ {
/* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */ /* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */
for( i_timeout = 20 ; i_timeout-- ; ) for( i_timeout = 20 ; i_timeout-- ; )
......
...@@ -114,7 +114,7 @@ int OpenVideoGL ( vlc_object_t * p_this ) ...@@ -114,7 +114,7 @@ int OpenVideoGL ( vlc_object_t * p_this )
memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) ); memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
var_Get( p_vout->p_libvlc, "drawable", &value_drawable ); var_Get( p_vout->p_libvlc, "drawable-agl", &value_drawable );
if( value_drawable.i_int != 0 ) if( value_drawable.i_int != 0 )
{ {
static const GLint ATTRIBUTES[] = { static const GLint ATTRIBUTES[] = {
...@@ -148,7 +148,8 @@ int OpenVideoGL ( vlc_object_t * p_this ) ...@@ -148,7 +148,8 @@ int OpenVideoGL ( vlc_object_t * p_this )
msg_Err( p_vout, "cannot create AGL context." ); msg_Err( p_vout, "cannot create AGL context." );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
else { else
{
// tell opengl not to sync buffer swap with vertical retrace (too inefficient) // tell opengl not to sync buffer swap with vertical retrace (too inefficient)
GLint param = 0; GLint param = 0;
aglSetInteger(p_vout->p_sys->agl_ctx, AGL_SWAP_INTERVAL, &param); aglSetInteger(p_vout->p_sys->agl_ctx, AGL_SWAP_INTERVAL, &param);
...@@ -496,7 +497,7 @@ static int aglInit( vout_thread_t * p_vout ) ...@@ -496,7 +497,7 @@ static int aglInit( vout_thread_t * p_vout )
Rect viewBounds; Rect viewBounds;
Rect clipBounds; Rect clipBounds;
var_Get( p_vout->p_libvlc, "drawable", &val ); var_Get( p_vout->p_libvlc, "drawable-agl", &val );
p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int; p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int;
aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable); aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable);
...@@ -616,7 +617,7 @@ static int aglManage( vout_thread_t * p_vout ) ...@@ -616,7 +617,7 @@ static int aglManage( vout_thread_t * p_vout )
Rect viewBounds; Rect viewBounds;
Rect clipBounds; Rect clipBounds;
var_Get( p_vout->p_libvlc, "drawable", &val ); var_Get( p_vout->p_libvlc, "drawable-agl", &val );
p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int; p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int;
aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable); aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* a layer. The layer will register itself to the drawable object stored in * a layer. The layer will register itself to the drawable object stored in
* the "drawable" variable. * the "drawable" variable.
***************************************************************************** *****************************************************************************
* Copyright (C) 2004 the VideoLAN team * Copyright (C) 2004-2009 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
...@@ -185,8 +185,8 @@ static int Init( vout_thread_t *p_vout ) ...@@ -185,8 +185,8 @@ static int Init( vout_thread_t *p_vout )
/* We do need a drawable to work properly */ /* We do need a drawable to work properly */
vlc_value_t value_drawable; vlc_value_t value_drawable;
var_Create( p_vout, "drawable", VLC_VAR_DOINHERIT ); var_Create( p_vout, "drawable-gl", VLC_VAR_DOINHERIT );
var_Get( p_vout, "drawable", &value_drawable ); var_Get( p_vout, "drawable-gl", &value_drawable );
p_vout->p_sys->o_cocoa_container = (id) value_drawable.i_int; p_vout->p_sys->o_cocoa_container = (id) value_drawable.i_int;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc_internal.h : Definition of opaque structures for libvlc exported API * libvlc_internal.h : Definition of opaque structures for libvlc exported API
* Also contains some internal utility functions * Also contains some internal utility functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2005 the VideoLAN team * Copyright (C) 2005-2009 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
...@@ -158,6 +158,7 @@ struct libvlc_media_player_t ...@@ -158,6 +158,7 @@ struct libvlc_media_player_t
{ {
void *hwnd; void *hwnd;
uint32_t xid; uint32_t xid;
uint32_t agl;
} drawable; } drawable;
bool b_own_its_input_thread; bool b_own_its_input_thread;
......
...@@ -94,6 +94,7 @@ static void release_input_thread( libvlc_media_player_t *p_mi, bool b_input_abor ...@@ -94,6 +94,7 @@ static void release_input_thread( libvlc_media_player_t *p_mi, bool b_input_abor
var_Destroy( p_input_thread, "drawable-hwnd" ); var_Destroy( p_input_thread, "drawable-hwnd" );
var_Destroy( p_input_thread, "drawable-xid" ); var_Destroy( p_input_thread, "drawable-xid" );
var_Destroy( p_input_thread, "drawable-agl" );
} }
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
...@@ -274,6 +275,7 @@ libvlc_media_player_new( libvlc_instance_t * p_libvlc_instance, ...@@ -274,6 +275,7 @@ libvlc_media_player_new( libvlc_instance_t * p_libvlc_instance,
return NULL; return NULL;
} }
p_mi->p_md = NULL; p_mi->p_md = NULL;
p_mi->drawable.agl = 0;
p_mi->drawable.xid = 0; p_mi->drawable.xid = 0;
p_mi->drawable.hwnd = NULL; p_mi->drawable.hwnd = NULL;
p_mi->p_libvlc_instance = p_libvlc_instance; p_mi->p_libvlc_instance = p_libvlc_instance;
...@@ -615,6 +617,10 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi, ...@@ -615,6 +617,10 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi,
p_input_thread = p_mi->p_input_thread; 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 ); var_Create( p_input_thread, "drawable-xid", VLC_VAR_INTEGER );
if( p_mi->drawable.xid ) if( p_mi->drawable.xid )
var_SetInteger( p_input_thread, "drawable-xid", p_mi->drawable.xid ); var_SetInteger( p_input_thread, "drawable-xid", p_mi->drawable.xid );
...@@ -728,6 +734,25 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi, ...@@ -728,6 +734,25 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi,
} }
} }
/**************************************************************************
* set_agl
**************************************************************************/
void libvlc_media_player_set_agl( libvlc_media_player_t *p_mi,
uint32_t drawable,
libvlc_exception_t *p_e )
{
(void) p_e;
p_mi->drawable.agl = drawable;
}
/**************************************************************************
* get_agl
**************************************************************************/
uint32_t libvlc_media_player_get_agl( libvlc_media_player_t *p_mi )
{
return p_mi->drawable.agl;
}
/************************************************************************** /**************************************************************************
* set_xwindow * set_xwindow
**************************************************************************/ **************************************************************************/
...@@ -778,6 +803,8 @@ void libvlc_media_player_set_drawable( libvlc_media_player_t *p_mi, ...@@ -778,6 +803,8 @@ void libvlc_media_player_set_drawable( libvlc_media_player_t *p_mi,
p_mi->drawable.hwnd = (HWND)drawable; p_mi->drawable.hwnd = (HWND)drawable;
else else
libvlc_exception_raise(p_e, "Operation not supported"); libvlc_exception_raise(p_e, "Operation not supported");
#elif defined(__APPLE__)
p_mi->drawable.agl = drawable;
#else #else
p_mi->drawable.xid = drawable; p_mi->drawable.xid = drawable;
#endif #endif
...@@ -797,6 +824,8 @@ libvlc_media_player_get_drawable ( libvlc_media_player_t *p_mi, ...@@ -797,6 +824,8 @@ libvlc_media_player_get_drawable ( libvlc_media_player_t *p_mi,
return (libvlc_drawable_t)p_mi->drawable.hwnd; return (libvlc_drawable_t)p_mi->drawable.hwnd;
else else
return 0; return 0;
#elif defined(__APPLE__)
return p_mi->drawable.agl;
#else #else
return p_mi->drawable.xid; return p_mi->drawable.xid;
#endif #endif
......
...@@ -242,6 +242,8 @@ void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d ...@@ -242,6 +242,8 @@ void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d
return; /* BOOM! we told you not to use this function! */ return; /* BOOM! we told you not to use this function! */
val.p_address = (void *)(uintptr_t)d; val.p_address = (void *)(uintptr_t)d;
var_Set( p_instance->p_libvlc_int, "drawable-hwnd", val ); var_Set( p_instance->p_libvlc_int, "drawable-hwnd", val );
#elif defined(__APPLE__)
var_SetInteger( p_instance->p_libvlc_int, "drawable-agl", d );
#else #else
var_SetInteger( p_instance->p_libvlc_int, "drawable-xid", d ); var_SetInteger( p_instance->p_libvlc_int, "drawable-xid", d );
#endif #endif
...@@ -266,12 +268,13 @@ libvlc_drawable_t libvlc_video_get_parent( libvlc_instance_t *p_instance, libvlc ...@@ -266,12 +268,13 @@ libvlc_drawable_t libvlc_video_get_parent( libvlc_instance_t *p_instance, libvlc
return 0; return 0;
var_Get( p_instance->p_libvlc_int, "drawable-hwnd", &val ); var_Get( p_instance->p_libvlc_int, "drawable-hwnd", &val );
return (uintptr_t)val.p_address; return (uintptr_t)val.p_address;
#elif defined(__APPLE__)
return var_GetInteger( p_instance->p_libvlc_int, "drawable-agl" );
#else #else
return var_GetInteger( p_instance->p_libvlc_int, "drawable-xid" ); return var_GetInteger( p_instance->p_libvlc_int, "drawable-xid" );
#endif #endif
} }
void libvlc_video_set_size( libvlc_instance_t *p_instance, int width, int height, void libvlc_video_set_size( libvlc_instance_t *p_instance, int width, int height,
libvlc_exception_t *p_e ) libvlc_exception_t *p_e )
{ {
......
...@@ -970,9 +970,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -970,9 +970,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
*/ */
var_Create( p_libvlc, "drawable-xid", VLC_VAR_INTEGER ); var_Create( p_libvlc, "drawable-xid", VLC_VAR_INTEGER );
var_Create( p_libvlc, "drawable-hwnd", VLC_VAR_ADDRESS ); var_Create( p_libvlc, "drawable-hwnd", VLC_VAR_ADDRESS );
#ifdef __APPLE__ var_Create( p_libvlc, "drawable-agl", VLC_VAR_INTEGER );
var_Create( p_libvlc, "drawable", VLC_VAR_INTEGER ); var_Create( p_libvlc, "drawable-gl", VLC_VAR_INTEGER );
#endif
var_Create( p_libvlc, "drawable-view-top", VLC_VAR_INTEGER ); var_Create( p_libvlc, "drawable-view-top", VLC_VAR_INTEGER );
var_Create( p_libvlc, "drawable-view-left", VLC_VAR_INTEGER ); var_Create( p_libvlc, "drawable-view-left", VLC_VAR_INTEGER );
var_Create( p_libvlc, "drawable-view-bottom", VLC_VAR_INTEGER ); var_Create( p_libvlc, "drawable-view-bottom", VLC_VAR_INTEGER );
......
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