Commit fcab73f6 authored by Laurent Aimar's avatar Laurent Aimar

Updated maemo vout_window provider to the new API.

parent 411471d7
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_interface.h> #include <vlc_interface.h>
#include <vlc_window.h> #include <vlc_vout_window.h>
#include <hildon/hildon-program.h> #include <hildon/hildon-program.h>
#include <hildon/hildon-banner.h> #include <hildon/hildon-banner.h>
...@@ -53,7 +53,7 @@ static gboolean should_die ( gpointer ); ...@@ -53,7 +53,7 @@ static gboolean should_die ( gpointer );
static int OpenWindow ( vlc_object_t * ); static int OpenWindow ( vlc_object_t * );
static void CloseWindow ( vlc_object_t * ); static void CloseWindow ( vlc_object_t * );
static int ControlWindow ( vout_window_t *, int, va_list ); static int ControlWindow ( vout_window_t *, int, va_list );
static void* request_video ( intf_thread_t *, vout_thread_t * ); static uint32_t request_video ( intf_thread_t *, vout_thread_t * );
static void release_video ( intf_thread_t * ); static void release_video ( intf_thread_t * );
static gboolean video_widget_ready ( gpointer data ); static gboolean video_widget_ready ( gpointer data );
...@@ -70,7 +70,7 @@ vlc_module_begin(); ...@@ -70,7 +70,7 @@ vlc_module_begin();
add_shortcut( "maemo" ); add_shortcut( "maemo" );
add_submodule(); add_submodule();
set_capability( "xwindow", 50 ); set_capability( "vout window", 50 );
set_callbacks( OpenWindow, CloseWindow ); set_callbacks( OpenWindow, CloseWindow );
vlc_module_end(); vlc_module_end();
...@@ -265,60 +265,74 @@ static int OpenWindow (vlc_object_t *obj) ...@@ -265,60 +265,74 @@ static int OpenWindow (vlc_object_t *obj)
{ {
vout_window_t *wnd = (vout_window_t *)obj; vout_window_t *wnd = (vout_window_t *)obj;
/* TODO: should probably be in the libvlc core instead: */ if (wnd->cfg->type != VOUT_WINDOW_TYPE_XWINDOW ||
if (!config_GetInt (obj, "embedded-video")) wnd->cfg->is_standalone)
return VLC_EGENERIC; return VLC_EGENERIC;
intf_thread_t *intf = (intf_thread_t *) intf_thread_t *intf = (intf_thread_t*)vlc_object_find_name (obj, "maemo", FIND_ANYWHERE);
vlc_object_find_name (obj, "maemo", FIND_ANYWHERE);
if (intf == NULL) if (intf == NULL)
{ {
msg_Err( obj, "Maemo interface not found" ); msg_Err( obj, "Maemo interface not found" );
return VLC_EGENERIC; /* Maemo not in use */ return VLC_EGENERIC; /* Maemo not in use */
} }
wnd->handle.xid = request_video( intf, wnd->vout ); /* FIXME it should NOT be needed */
msg_Dbg( intf, "Using handle %"PRIu32, wnd->handle.xid ); vout_thread_t *vout = vlc_object_find (obj, VLC_OBJECT_VOUT, FIND_PARENT);
wnd->control = ControlWindow; wnd->handle.xid = request_video( intf, vout );
wnd->p_private = intf; if (!wnd->handle.xid)
{
vlc_object_release( vout );
return VLC_EGENERIC;
}
vlc_object_release( vout );
// Signaling that the window is not at the requested sizeof msg_Dbg( intf, "Using handle %"PRIu32, wnd->handle.xid );
int i_width, i_height, i_x_top, i_y_top, i_x, i_y;
gdk_drawable_get_size( GDK_DRAWABLE( intf->p_sys->p_video_window->window ),
&i_width, &i_height );
gdk_window_get_position( GTK_WIDGET(intf->p_sys->p_main_window)->window,
&i_x_top, &i_y_top );
gdk_window_get_position( intf->p_sys->p_video_window->window, &i_x, &i_y );
wnd->width = i_width; wnd->control = ControlWindow;
wnd->height = i_height; wnd->sys = (vout_window_sys_t*)intf;
wnd->pos_x = i_x_top + i_x;
wnd->pos_y = i_y_top + i_y;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int ControlWindow (vout_window_t *wnd, int query, va_list args) static int ControlWindow (vout_window_t *wnd, int query, va_list args)
{ {
(void)wnd; (void)query; (void)args; intf_thread_t *intf = (intf_thread_t *)wnd->sys;
switch( query )
{
case VOUT_WINDOW_SET_SIZE:
{
int i_width = (int)va_arg( args, int );
int i_height = (int)va_arg( args, int );
int i_current_w, i_current_h;
gdk_drawable_get_size( GDK_DRAWABLE( intf->p_sys->p_video_window->window ),
&i_current_w, &i_current_h );
if( i_width != i_current_w || i_height != i_current_h )
return VLC_EGENERIC; return VLC_EGENERIC;
return VLC_SUCCESS;
}
default:
return VLC_EGENERIC;
}
} }
static void CloseWindow (vlc_object_t *obj) static void CloseWindow (vlc_object_t *obj)
{ {
intf_thread_t *intf = (intf_thread_t *)obj->p_private; vout_window_t *wnd = (vout_window_t *)obj;
intf_thread_t *intf = (intf_thread_t *)wnd->sys;
release_video( intf ); release_video( intf );
vlc_object_release (intf); vlc_object_release (intf);
} }
static void *request_video( intf_thread_t *p_intf, vout_thread_t *p_nvout ) static uint32_t request_video( intf_thread_t *p_intf, vout_thread_t *p_nvout )
{ {
if( p_intf->p_sys->p_vout ) if( p_intf->p_sys->p_vout )
{ {
msg_Dbg( p_intf, "Embedded video already in use" ); msg_Dbg( p_intf, "Embedded video already in use" );
return NULL; return 0;
} }
vlc_mutex_lock( &p_intf->p_sys->p_video_mutex ); vlc_mutex_lock( &p_intf->p_sys->p_video_mutex );
...@@ -331,13 +345,15 @@ static void *request_video( intf_thread_t *p_intf, vout_thread_t *p_nvout ) ...@@ -331,13 +345,15 @@ static void *request_video( intf_thread_t *p_intf, vout_thread_t *p_nvout )
vlc_cleanup_run(); vlc_cleanup_run();
p_intf->p_sys->p_vout = p_nvout; p_intf->p_sys->p_vout = vlc_object_hold( p_nvout );
return ( void * )GDK_WINDOW_XID( p_intf->p_sys->p_video_window->window ); return GDK_WINDOW_XID( p_intf->p_sys->p_video_window->window );
} }
static void release_video( intf_thread_t *p_intf ) static void release_video( intf_thread_t *p_intf )
{ {
msg_Dbg( p_intf, "Releasing embedded video" ); msg_Dbg( p_intf, "Releasing embedded video" );
vlc_object_release( p_intf->p_sys->p_vout );
p_intf->p_sys->p_vout = NULL; p_intf->p_sys->p_vout = NULL;
} }
......
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