]> git.sesse.net Git - vlc/commitdiff
Modified vout_window_t to be completly independant of vout.
authorLaurent Aimar <fenrir@videolan.org>
Fri, 31 Jul 2009 19:15:33 +0000 (21:15 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 1 Aug 2009 10:07:11 +0000 (12:07 +0200)
include/vlc_vout_window.h [new file with mode: 0644]
include/vlc_window.h [deleted file]
src/Makefile.am
src/libvlccore.sym
src/video_output/vout_intf.c
src/video_output/window.c [new file with mode: 0644]

diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h
new file mode 100644 (file)
index 0000000..0500a5f
--- /dev/null
@@ -0,0 +1,150 @@
+/*****************************************************************************
+ * vlc_vout_window.h: vout_window_t definitions
+ *****************************************************************************
+ * Copyright (C) 2008 Rémi Denis-Courmont
+ * Copyright (C) 2009 Laurent Aimar
+ * $Id$
+ *
+ * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef VLC_VOUT_WINDOW_H
+#define VLC_VOUT_WINDOW_H 1
+
+/**
+ * \file
+ * This file defines vout windows structures and functions in vlc
+ */
+
+#include <vlc_common.h>
+
+/* */
+typedef struct vout_window_t vout_window_t;
+typedef struct vout_window_sys_t vout_window_sys_t;
+
+
+/**
+ * Window handle type
+ */
+enum {
+    VOUT_WINDOW_TYPE_XWINDOW,
+    VOUT_WINDOW_TYPE_HWND,
+};
+
+/**
+ * Control query for vout_window_t
+ */
+enum {
+    VOUT_WINDOW_SET_ON_TOP, /* int b_on_top */
+    VOUT_WINDOW_SET_SIZE,   /* int i_width, int i_height */
+};
+
+typedef struct {
+    /* If true, a standalone window is requested */
+    bool is_standalone;
+
+    /* Window handle type */
+    int type;
+
+    /* Window position hint */
+    int x;
+    int y;
+
+    /* Windows size int */
+    int width;
+    int height;
+
+} vout_window_cfg_t;
+
+/**
+ * FIXME do we need an event system in the window too ?
+ * or the window user will take care of it ?
+ */
+struct vout_window_t {
+    VLC_COMMON_MEMBERS
+
+    /* Module */
+    module_t *module;
+
+    /* Initial state (reserved).
+     * Once the open function is called, it will be set to NULL
+     */
+    const vout_window_cfg_t *cfg;
+
+    /* window handle (mandatory)
+     *
+     * It must be filled in the open function.
+     */
+    union {
+        void     *hwnd;   /* Win32 window handle */
+        uint32_t xid;     /* X11 windows ID */
+    } handle;
+
+    /* Control on the module (mandatory)
+     *
+     * Do not use it directly but use vout_window_Control.
+     */
+    int (*control)(vout_window_t *, int query, va_list);
+
+    /* Private place holder for the vout_window_t module (optional)
+     *
+     * A module is free to used it as it wishes.
+     */
+    vout_window_sys_t *sys;
+};
+
+/** 
+ * It creates a new window.
+ * 
+ * XXX If you are inside a "vout display", you must use
+ * vout_display_New/DeleteWindow when possible to allow window recycling.
+ */
+VLC_EXPORT( vout_window_t *, vout_window_New, (vlc_object_t *, const char *module, const vout_window_cfg_t *) );
+
+/**
+ * It deletes a window created by vout_window_New.
+ *
+ * XXX See vout_window_New about window recycling.
+ */
+VLC_EXPORT( void, vout_window_Delete, (vout_window_t *) );
+
+/**
+ * It allows configuring a window.
+ *
+ * XXX you must own the windows, and vout_window_t are not thread safe.
+ * You must not use it directly but prefer the vout_window_* wrappers.
+ */
+VLC_EXPORT( int, vout_window_Control, (vout_window_t *, int query, ...) );
+
+/**
+ * Configure the "On Top" properties of a windows.
+ */
+static inline int vout_window_SetOnTop(vout_window_t *window, bool is_on_top)
+{
+    return vout_window_Control(window, VOUT_WINDOW_SET_ON_TOP, is_on_top);
+}
+
+/**
+ * Configure the windows display size.
+ */
+static inline int vout_window_SetSize(vout_window_t *window, int width, int height)
+{
+    return vout_window_Control(window, VOUT_WINDOW_SET_SIZE, width, height);
+}
+
+#endif /* VLC_VOUT_WINDOW_H */
+
diff --git a/include/vlc_window.h b/include/vlc_window.h
deleted file mode 100644 (file)
index 144e622..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*****************************************************************************
- * vlc_window.h: Embedded video output window
- *****************************************************************************
- * Copyright (C) 2008 Rémi Denis-Courmont
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifndef LIBVLCCORE_WINDOW_H
-# define LIBVLCCORE_WINDOW_H 1
-
-/**
- * \file
- * This file defines functions and structures for output windows
- */
-
-# include <stdarg.h>
-
-typedef struct vout_window_t vout_window_t;
-typedef struct vout_window_sys_t vout_window_sys_t;
-
-struct vout_window_t
-{
-    VLC_COMMON_MEMBERS
-
-    module_t      *module;
-    vout_thread_t *vout;
-    union
-    {
-        void      *hwnd; /* Win32 window handle */
-        uint32_t   xid;  /* X11 window ID */
-    } handle;
-    vout_window_sys_t *p_sys;  /* window provider private data */
-
-    unsigned       width;  /* pixels width */
-    unsigned       height; /* pixels height */
-    int            pos_x;  /* horizontal position hint */
-    int            pos_y;  /* vertical position hint */
-
-    int (*control) (struct vout_window_t *, int, va_list);
-};
-
-VLC_EXPORT( vout_window_t *, vout_RequestWindow, ( vout_thread_t *, const char *, int *, int *, unsigned int *, unsigned int * ) );
-VLC_EXPORT( void,   vout_ReleaseWindow, ( vout_window_t * ) );
-VLC_EXPORT( int, vout_ControlWindow, ( vout_window_t *, int, va_list ) );
-
-static inline vout_window_t *
-vout_RequestXWindow (vout_thread_t *vout,
-                     int *x, int *y, unsigned *w, unsigned *h)
-{
-    return vout_RequestWindow (vout, "xwindow", x, y, w, h);
-}
-
-static inline vout_window_t *
-vout_RequestHWND (vout_thread_t *vout,
-                  int *x, int *y, unsigned *w, unsigned *h)
-{
-    return vout_RequestWindow (vout, "hwnd", x, y, w, h);
-}
-
-#endif /* !LIBVLCCORE_WINDOW_H */
index 1a7502e96f126cec785f71da46042194aea5e590..5397b559293591a53c77a8d252100c95ad74bb96 100644 (file)
@@ -95,7 +95,7 @@ pluginsinclude_HEADERS = \
        ../include/vlc_vlm.h \
        ../include/vlc_video_splitter.h \
        ../include/vlc_vout.h \
-       ../include/vlc_window.h \
+       ../include/vlc_vout_window.h \
        ../include/vlc_xml.h \
        $(NULL)
 
@@ -350,6 +350,7 @@ SOURCES_libvlc_common = \
        video_output/video_text.c \
        video_output/video_widgets.c \
        video_output/vout_subpictures.c \
+       video_output/window.c \
        video_output/vout_intf.c \
        video_output/vout_internal.h \
        video_output/vout_control.h \
index 5aa2468988d64b873b28f82a55a4d0ca2cf46dcc..904a697513ffd9c70196d567ad895477613ba01a 100644 (file)
@@ -560,7 +560,6 @@ __vlm_New
 __vout_AllocatePicture
 vout_ChromaCmp
 vout_Close
-vout_ControlWindow
 __vout_Create
 vout_CreatePicture
 vout_DestroyPicture
@@ -573,11 +572,12 @@ vout_OSDIcon
 __vout_OSDMessage
 vout_OSDSlider
 vout_PlacePicture
-vout_ReleaseWindow
 __vout_Request
-vout_RequestWindow
 vout_ShowTextAbsolute
 vout_ShowTextRelative
 vout_UnlinkPicture
+vout_window_New
+vout_window_Control
+vout_window_Delete
 __xml_Create
 xml_Delete
index cc4319e7d4bcdbec0cd2177720c39ee0e634db65..c4ea45c9e18c6cbbbf24a9a563f83da12e6f7c47 100644 (file)
@@ -43,7 +43,6 @@
 #include <vlc_playlist.h>
 
 #include <vlc_vout.h>
-#include <vlc_window.h>
 #include <vlc_image.h>
 #include <vlc_osd.h>
 #include <vlc_charset.h>
@@ -81,86 +80,6 @@ static int TitleTimeoutCallback( vlc_object_t *, char const *,
 static int TitlePositionCallback( vlc_object_t *, char const *,
                                   vlc_value_t, vlc_value_t, void * );
 
-/**
- * Creates a video output window.
- * On Unix systems, this is an X11 drawable (handle).
- * On Windows, this is a Win32 window (handle).
- * Video output plugins are supposed to called this function and display the
- * video within the resulting window, while in windowed mode.
- *
- * @param p_vout video output thread to create a window for
- * @param psz_cap VLC module capability (window system type)
- * @param pi_x_hint pointer to store the recommended horizontal position [OUT]
- * @param pi_y_hint pointer to store the recommended vertical position [OUT]
- * @param pi_width_hint pointer to store the recommended width [OUT]
- * @param pi_height_hint pointer to store the recommended height [OUT]
- *
- * @return a vout_window_t object, or NULL in case of failure.
- * The window is released with vout_ReleaseWindow().
- */
-vout_window_t *vout_RequestWindow( vout_thread_t *p_vout, const char *psz_cap,
-                          int *pi_x_hint, int *pi_y_hint,
-                          unsigned int *pi_width_hint,
-                          unsigned int *pi_height_hint )
-{
-    /* Get requested coordinates */
-    *pi_x_hint = var_GetInteger( p_vout, "video-x" );
-    *pi_y_hint = var_GetInteger( p_vout, "video-y" );
-
-    *pi_width_hint = p_vout->i_window_width;
-    *pi_height_hint = p_vout->i_window_height;
-
-    vout_window_t *wnd = vlc_custom_create (VLC_OBJECT(p_vout), sizeof (*wnd),
-                                            VLC_OBJECT_GENERIC, "window");
-    if (wnd == NULL)
-        return NULL;
-
-    wnd->vout = p_vout;
-    wnd->width = *pi_width_hint;
-    wnd->height = *pi_height_hint;
-    wnd->pos_x = *pi_x_hint;
-    wnd->pos_y = *pi_y_hint;
-    vlc_object_attach (wnd, p_vout);
-
-    wnd->module = module_need (wnd, psz_cap, NULL, false);
-    if (wnd->module == NULL)
-    {
-        msg_Dbg (wnd, "no \"%s\" window provider available", psz_cap);
-        vlc_object_release (wnd);
-        return NULL;
-    }
-    *pi_width_hint = wnd->width;
-    *pi_height_hint = wnd->height;
-    *pi_x_hint = wnd->pos_x;
-    *pi_y_hint = wnd->pos_y;
-    return wnd;
-}
-
-/**
- * Releases a window handle obtained with vout_RequestWindow().
- * @param p_vout video output thread that allocated the window
- *               (if this is NULL; this fnction is a no-op).
- */
-void vout_ReleaseWindow( vout_window_t *wnd )
-{
-    if (wnd == NULL)
-        return;
-
-    assert (wnd->module);
-    module_unneed (wnd, wnd->module);
-
-    vlc_object_release (wnd);
-}
-
-int vout_ControlWindow( vout_window_t *wnd, int i_query, va_list args )
-{
-    if (wnd == NULL)
-        return VLC_EGENERIC;
-
-    assert (wnd->control);
-    return wnd->control (wnd, i_query, args);
-}
-
 /*****************************************************************************
  * vout_IntfInit: called during the vout creation to initialise misc things.
  *****************************************************************************/
diff --git a/src/video_output/window.c b/src/video_output/window.c
new file mode 100644 (file)
index 0000000..de464d3
--- /dev/null
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * window.c: "vout window" managment
+ *****************************************************************************
+ * Copyright (C) 2009 Laurent Aimar
+ * $Id$
+ *
+ * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+#include <assert.h>
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_vout_window.h>
+
+vout_window_t *vout_window_New(vlc_object_t *obj,
+                               const char *module,
+                               const vout_window_cfg_t *cfg)
+{
+    vout_window_t *window = vlc_object_create(obj, sizeof(*window));
+
+    window->cfg = cfg;
+    memset(&window->handle, 0, sizeof(window->handle));
+    window->control = NULL;
+    window->sys = NULL;
+
+    vlc_object_attach(window, obj);
+
+    window->module = module_need(window, "vout window",
+                                 module, module && *module != '\0');
+    if (!window->module) {
+        vlc_object_detach(window);
+        vlc_object_release(window);
+        return NULL;
+    }
+    return window;
+}
+
+void vout_window_Delete(vout_window_t *window)
+{
+    if (!window)
+        return;
+
+    vlc_object_detach(window);
+
+    module_unneed(window, window->module);
+
+    vlc_object_release(window);
+}
+
+int vout_window_Control(vout_window_t *window, int query, ...)
+{
+    va_list args;
+    va_start(args, query);
+    int ret = window->control(window, query, args);
+    va_end(args);
+
+    return ret;
+}
+