libs: use GstVaapiObject for window objects.

This commit is contained in:
Gwenole Beauchesne 2013-04-30 17:20:14 +02:00
parent 6c46179709
commit 8402b04ac9
13 changed files with 573 additions and 807 deletions

View file

@ -117,6 +117,7 @@ libgstvaapi_source_priv_h = \
gstvaapisurfaceproxy_priv.h \
gstvaapiutils.h \
gstvaapiversion.h \
gstvaapiwindow_priv.h \
gstvaapiworkarounds.h \
sysdeps.h \
$(NULL)
@ -162,6 +163,7 @@ libgstvaapi_x11_source_priv_h = \
gstvaapidisplay_x11_priv.h \
gstvaapiutils.h \
gstvaapiutils_x11.h \
gstvaapiwindow_x11_priv.h \
$(NULL)
libgstvaapi_glx_source_c = \

View file

@ -27,209 +27,141 @@
#include "sysdeps.h"
#include "gstvaapiwindow.h"
#include "gstvaapi_priv.h"
#include "gstvaapiwindow_priv.h"
#define DEBUG 1
#include "gstvaapidebug.h"
G_DEFINE_TYPE(GstVaapiWindow, gst_vaapi_window, GST_VAAPI_TYPE_OBJECT)
#define GST_VAAPI_WINDOW_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
GST_VAAPI_TYPE_WINDOW, \
GstVaapiWindowPrivate))
struct _GstVaapiWindowPrivate {
guint width;
guint height;
guint display_width;
guint display_height;
gboolean is_constructed : 1;
guint is_fullscreen : 1;
guint check_geometry : 1;
};
enum {
PROP_0,
PROP_WIDTH,
PROP_HEIGHT,
PROP_FULLSCREEN
};
/* Ensure those symbols are actually defined in the resulting libraries */
#undef gst_vaapi_window_ref
#undef gst_vaapi_window_unref
#undef gst_vaapi_window_replace
static void
gst_vaapi_window_ensure_size(GstVaapiWindow *window)
{
GstVaapiWindowPrivate * const priv = window->priv;
GstVaapiWindowClass * const klass = GST_VAAPI_WINDOW_GET_CLASS(window);
const GstVaapiWindowClass * const klass =
GST_VAAPI_WINDOW_GET_CLASS(window);
if (!priv->check_geometry)
if (!window->check_geometry)
return;
if (klass->get_geometry)
klass->get_geometry(window, NULL, NULL, &priv->width, &priv->height);
klass->get_geometry(window, NULL, NULL,
&window->width, &window->height);
priv->check_geometry = FALSE;
priv->is_fullscreen = (priv->width == priv->display_width &&
priv->height == priv->display_height);
}
static void
gst_vaapi_window_destroy(GstVaapiWindow *window)
{
GST_VAAPI_WINDOW_GET_CLASS(window)->destroy(window);
window->check_geometry = FALSE;
window->is_fullscreen = (window->width == window->display_width &&
window->height == window->display_height);
}
static gboolean
gst_vaapi_window_create(GstVaapiWindow *window)
gst_vaapi_window_create(GstVaapiWindow *window, guint width, guint height)
{
GstVaapiWindowPrivate * const priv = window->priv;
guint width, height;
width = priv->width;
height = priv->height;
gst_vaapi_display_get_size(
GST_VAAPI_OBJECT_DISPLAY(window),
&priv->display_width,
&priv->display_height
&window->display_width,
&window->display_height
);
if (!GST_VAAPI_WINDOW_GET_CLASS(window)->create(window, &width, &height))
return FALSE;
if (width != priv->width || height != priv->height) {
if (width != window->width || height != window->height) {
GST_DEBUG("backend resized window to %ux%u", width, height);
priv->width = width;
priv->height = height;
window->width = width;
window->height = height;
}
return TRUE;
}
static void
gst_vaapi_window_finalize(GObject *object)
GstVaapiWindow *
gst_vaapi_window_new(const GstVaapiWindowClass *window_class,
GstVaapiDisplay *display, guint width, guint height)
{
gst_vaapi_window_destroy(GST_VAAPI_WINDOW(object));
GstVaapiWindow *window;
G_OBJECT_CLASS(gst_vaapi_window_parent_class)->finalize(object);
g_return_val_if_fail(width > 0, NULL);
g_return_val_if_fail(height > 0, NULL);
window = gst_vaapi_object_new(GST_VAAPI_OBJECT_CLASS(window_class),
display);
if (!window)
return NULL;
GST_VAAPI_OBJECT_ID(window) = 0;
if (!gst_vaapi_window_create(window, width, height))
goto error;
return window;
error:
gst_vaapi_window_unref_internal(window);
return NULL;
}
static void
gst_vaapi_window_set_property(
GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec
)
GstVaapiWindow *
gst_vaapi_window_new_from_native(const GstVaapiWindowClass *window_class,
GstVaapiDisplay *display, gpointer native_window)
{
GstVaapiWindow * const window = GST_VAAPI_WINDOW(object);
GstVaapiWindow *window;
switch (prop_id) {
case PROP_WIDTH:
gst_vaapi_window_set_width(window, g_value_get_uint(value));
break;
case PROP_HEIGHT:
gst_vaapi_window_set_height(window, g_value_get_uint(value));
break;
case PROP_FULLSCREEN:
gst_vaapi_window_set_fullscreen(window, g_value_get_boolean(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
window = gst_vaapi_object_new(GST_VAAPI_OBJECT_CLASS(window_class),
display);
if (!window)
return NULL;
GST_VAAPI_OBJECT_ID(window) = GPOINTER_TO_SIZE(native_window);
window->use_foreign_window = TRUE;
if (!gst_vaapi_window_create(window, 0, 0))
goto error;
return window;
error:
gst_vaapi_window_unref_internal(window);
return NULL;
}
static void
gst_vaapi_window_get_property(
GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec
)
/**
* gst_vaapi_window_ref:
* @window: a #GstVaapiWindow
*
* Atomically increases the reference count of the given @window by one.
*
* Returns: The same @window argument
*/
GstVaapiWindow *
gst_vaapi_window_ref(GstVaapiWindow *window)
{
GstVaapiWindow * const window = GST_VAAPI_WINDOW(object);
switch (prop_id) {
case PROP_WIDTH:
g_value_set_uint(value, gst_vaapi_window_get_width(window));
break;
case PROP_HEIGHT:
g_value_set_uint(value, gst_vaapi_window_get_height(window));
break;
case PROP_FULLSCREEN:
g_value_set_boolean(value, window->priv->is_fullscreen);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
return gst_vaapi_window_ref_internal(window);
}
static void
gst_vaapi_window_constructed(GObject *object)
/**
* gst_vaapi_window_unref:
* @window: a #GstVaapiWindow
*
* Atomically decreases the reference count of the @window by one. If
* the reference count reaches zero, the window will be free'd.
*/
void
gst_vaapi_window_unref(GstVaapiWindow *window)
{
GstVaapiWindow * const window = GST_VAAPI_WINDOW(object);
GObjectClass *parent_class;
window->priv->is_constructed = gst_vaapi_window_create(window);
parent_class = G_OBJECT_CLASS(gst_vaapi_window_parent_class);
if (parent_class->constructed)
parent_class->constructed(object);
gst_vaapi_window_unref_internal(window);
}
static void
gst_vaapi_window_class_init(GstVaapiWindowClass *klass)
/**
* gst_vaapi_window_replace:
* @old_window_ptr: a pointer to a #GstVaapiWindow
* @new_window: a #GstVaapiWindow
*
* Atomically replaces the window window held in @old_window_ptr with
* @new_window. This means that @old_window_ptr shall reference a
* valid window. However, @new_window can be NULL.
*/
void
gst_vaapi_window_replace(GstVaapiWindow **old_window_ptr,
GstVaapiWindow *new_window)
{
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
g_type_class_add_private(klass, sizeof(GstVaapiWindowPrivate));
object_class->finalize = gst_vaapi_window_finalize;
object_class->set_property = gst_vaapi_window_set_property;
object_class->get_property = gst_vaapi_window_get_property;
object_class->constructed = gst_vaapi_window_constructed;
g_object_class_install_property
(object_class,
PROP_WIDTH,
g_param_spec_uint("width",
"Width",
"The window width",
1, G_MAXUINT32, 1,
G_PARAM_READWRITE));
g_object_class_install_property
(object_class,
PROP_HEIGHT,
g_param_spec_uint("height",
"height",
"The window height",
1, G_MAXUINT32, 1,
G_PARAM_READWRITE));
g_object_class_install_property
(object_class,
PROP_FULLSCREEN,
g_param_spec_boolean("fullscreen",
"Fullscreen",
"The fullscreen state of the window",
FALSE,
G_PARAM_READWRITE));
}
static void
gst_vaapi_window_init(GstVaapiWindow *window)
{
GstVaapiWindowPrivate *priv = GST_VAAPI_WINDOW_GET_PRIVATE(window);
window->priv = priv;
priv->width = 1;
priv->height = 1;
priv->is_constructed = FALSE;
priv->is_fullscreen = FALSE;
priv->check_geometry = FALSE;
gst_vaapi_window_replace_internal(old_window_ptr, new_window);
}
/**
@ -259,10 +191,9 @@ void
gst_vaapi_window_show(GstVaapiWindow *window)
{
g_return_if_fail(GST_VAAPI_IS_WINDOW(window));
g_return_if_fail(window->priv->is_constructed);
GST_VAAPI_WINDOW_GET_CLASS(window)->show(window);
window->priv->check_geometry = TRUE;
window->check_geometry = TRUE;
}
/**
@ -276,7 +207,6 @@ void
gst_vaapi_window_hide(GstVaapiWindow *window)
{
g_return_if_fail(GST_VAAPI_IS_WINDOW(window));
g_return_if_fail(window->priv->is_constructed);
GST_VAAPI_WINDOW_GET_CLASS(window)->hide(window);
}
@ -296,7 +226,7 @@ gst_vaapi_window_get_fullscreen(GstVaapiWindow *window)
gst_vaapi_window_ensure_size(window);
return window->priv->is_fullscreen;
return window->is_fullscreen;
}
/**
@ -309,16 +239,16 @@ gst_vaapi_window_get_fullscreen(GstVaapiWindow *window)
void
gst_vaapi_window_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
{
GstVaapiWindowClass *klass;
const GstVaapiWindowClass *klass;
g_return_if_fail(GST_VAAPI_IS_WINDOW(window));
klass = GST_VAAPI_WINDOW_GET_CLASS(window);
if (window->priv->is_fullscreen != fullscreen &&
if (window->is_fullscreen != fullscreen &&
klass->set_fullscreen && klass->set_fullscreen(window, fullscreen)) {
window->priv->is_fullscreen = fullscreen;
window->priv->check_geometry = TRUE;
window->is_fullscreen = fullscreen;
window->check_geometry = TRUE;
}
}
@ -334,11 +264,10 @@ guint
gst_vaapi_window_get_width(GstVaapiWindow *window)
{
g_return_val_if_fail(GST_VAAPI_IS_WINDOW(window), 0);
g_return_val_if_fail(window->priv->is_constructed, 0);
gst_vaapi_window_ensure_size(window);
return window->priv->width;
return window->width;
}
/**
@ -353,11 +282,10 @@ guint
gst_vaapi_window_get_height(GstVaapiWindow *window)
{
g_return_val_if_fail(GST_VAAPI_IS_WINDOW(window), 0);
g_return_val_if_fail(window->priv->is_constructed, 0);
gst_vaapi_window_ensure_size(window);
return window->priv->height;
return window->height;
}
/**
@ -372,15 +300,14 @@ void
gst_vaapi_window_get_size(GstVaapiWindow *window, guint *pwidth, guint *pheight)
{
g_return_if_fail(GST_VAAPI_IS_WINDOW(window));
g_return_if_fail(window->priv->is_constructed);
gst_vaapi_window_ensure_size(window);
if (pwidth)
*pwidth = window->priv->width;
*pwidth = window->width;
if (pheight)
*pheight = window->priv->height;
*pheight = window->height;
}
/**
@ -395,7 +322,7 @@ gst_vaapi_window_set_width(GstVaapiWindow *window, guint width)
{
g_return_if_fail(GST_VAAPI_IS_WINDOW(window));
gst_vaapi_window_set_size(window, width, window->priv->height);
gst_vaapi_window_set_size(window, width, window->height);
}
/**
@ -410,7 +337,7 @@ gst_vaapi_window_set_height(GstVaapiWindow *window, guint height)
{
g_return_if_fail(GST_VAAPI_IS_WINDOW(window));
gst_vaapi_window_set_size(window, window->priv->width, height);
gst_vaapi_window_set_size(window, window->width, height);
}
/**
@ -426,14 +353,14 @@ gst_vaapi_window_set_size(GstVaapiWindow *window, guint width, guint height)
{
g_return_if_fail(GST_VAAPI_IS_WINDOW(window));
if (width == window->priv->width && height == window->priv->height)
if (width == window->width && height == window->height)
return;
window->priv->width = width;
window->priv->height = height;
if (!GST_VAAPI_WINDOW_GET_CLASS(window)->resize(window, width, height))
return;
if (window->priv->is_constructed)
GST_VAAPI_WINDOW_GET_CLASS(window)->resize(window, width, height);
window->width = width;
window->height = height;
}
static inline void
@ -487,11 +414,10 @@ gst_vaapi_window_put_surface(
guint flags
)
{
GstVaapiWindowClass *klass;
const GstVaapiWindowClass *klass;
GstVaapiRectangle src_rect_default, dst_rect_default;
g_return_val_if_fail(GST_VAAPI_IS_WINDOW(window), FALSE);
g_return_val_if_fail(window->priv->is_constructed, FALSE);
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), FALSE);
klass = GST_VAAPI_WINDOW_GET_CLASS(window);

View file

@ -31,81 +31,24 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_WINDOW \
(gst_vaapi_window_get_type())
#define GST_VAAPI_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_WINDOW, \
GstVaapiWindow))
#define GST_VAAPI_WINDOW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_WINDOW, \
GstVaapiWindowClass))
#define GST_VAAPI_WINDOW(obj) \
((GstVaapiWindow *)(obj))
#define GST_VAAPI_IS_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_WINDOW))
#define GST_VAAPI_IS_WINDOW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_WINDOW))
#define GST_VAAPI_WINDOW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_WINDOW, \
GstVaapiWindowClass))
((obj) != NULL)
typedef struct _GstVaapiWindow GstVaapiWindow;
typedef struct _GstVaapiWindowPrivate GstVaapiWindowPrivate;
typedef struct _GstVaapiWindowClass GstVaapiWindowClass;
/**
* GstVaapiWindow:
*
* Base class for system-dependent windows.
*/
struct _GstVaapiWindow {
/*< private >*/
GstVaapiObject parent_instance;
GstVaapiWindow *
gst_vaapi_window_ref(GstVaapiWindow *window);
GstVaapiWindowPrivate *priv;
};
void
gst_vaapi_window_unref(GstVaapiWindow *window);
/**
* GstVaapiWindowClass:
* @create: virtual function to create a window with width and height
* @destroy: virtual function to destroy a window
* @show: virtual function to show (map) a window
* @hide: virtual function to hide (unmap) a window
* @set_fullscreen: virtual function to change window fullscreen state
* @resize: virtual function to resize a window
* @render: virtual function to render a #GstVaapiSurface into a window
*
* Base class for system-dependent windows.
*/
struct _GstVaapiWindowClass {
/*< private >*/
GstVaapiObjectClass parent_class;
/*< public >*/
gboolean (*create) (GstVaapiWindow *window, guint *width, guint *height);
void (*destroy)(GstVaapiWindow *window);
gboolean (*show) (GstVaapiWindow *window);
gboolean (*hide) (GstVaapiWindow *window);
gboolean (*get_geometry) (GstVaapiWindow *window,
gint *px, gint *py,
guint *pwidth, guint *pheight);
gboolean (*set_fullscreen)(GstVaapiWindow *window, gboolean fullscreen);
gboolean (*resize) (GstVaapiWindow *window, guint width, guint height);
gboolean (*render) (GstVaapiWindow *window,
GstVaapiSurface *surface,
const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect,
guint flags);
};
GType
gst_vaapi_window_get_type(void) G_GNUC_CONST;
void
gst_vaapi_window_replace(GstVaapiWindow **old_window_ptr,
GstVaapiWindow *new_window);
GstVaapiDisplay *
gst_vaapi_window_get_display(GstVaapiWindow *window);

View file

@ -26,13 +26,32 @@
#include "sysdeps.h"
#include "gstvaapiwindow_drm.h"
#include "gstvaapiwindow_priv.h"
#define DEBUG 1
#include "gstvaapidebug.h"
G_DEFINE_TYPE(GstVaapiWindowDRM,
gst_vaapi_window_drm,
GST_VAAPI_TYPE_WINDOW)
typedef struct _GstVaapiWindowDRMClass GstVaapiWindowDRMClass;
/**
* GstVaapiWindowDRM:
*
* A dummy DRM window abstraction.
*/
struct _GstVaapiWindowDRM {
/*< private >*/
GstVaapiWindow parent_instance;
};
/**
* GstVaapiWindowDRMClass:
*
* A dummy DRM window abstraction class.
*/
struct _GstVaapiWindowDRMClass {
/*< private >*/
GstVaapiWindowClass parent_instance;
};
static gboolean
gst_vaapi_window_drm_show(GstVaapiWindow *window)
@ -56,11 +75,6 @@ gst_vaapi_window_drm_create(
return TRUE;
}
static void
gst_vaapi_window_drm_destroy(GstVaapiWindow * window)
{
}
static gboolean
gst_vaapi_window_drm_resize(
GstVaapiWindow * window,
@ -83,44 +97,29 @@ gst_vaapi_window_drm_render(
return TRUE;
}
static void
gst_vaapi_window_drm_finalize(GObject *object)
void
gst_vaapi_window_drm_class_init(GstVaapiWindowDRMClass *klass)
{
G_OBJECT_CLASS(gst_vaapi_window_drm_parent_class)->finalize(object);
GstVaapiWindowClass * const window_class =
GST_VAAPI_WINDOW_CLASS(klass);
window_class->create = gst_vaapi_window_drm_create;
window_class->show = gst_vaapi_window_drm_show;
window_class->hide = gst_vaapi_window_drm_hide;
window_class->resize = gst_vaapi_window_drm_resize;
window_class->render = gst_vaapi_window_drm_render;
}
static void
gst_vaapi_window_drm_constructed(GObject *object)
{
GObjectClass *parent_class;
parent_class = G_OBJECT_CLASS(gst_vaapi_window_drm_parent_class);
if (parent_class->constructed)
parent_class->constructed(object);
}
static void
gst_vaapi_window_drm_class_init(GstVaapiWindowDRMClass * klass)
{
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
GstVaapiWindowClass * const window_class = GST_VAAPI_WINDOW_CLASS(klass);
object_class->finalize = gst_vaapi_window_drm_finalize;
object_class->constructed = gst_vaapi_window_drm_constructed;
window_class->create = gst_vaapi_window_drm_create;
window_class->destroy = gst_vaapi_window_drm_destroy;
window_class->show = gst_vaapi_window_drm_show;
window_class->hide = gst_vaapi_window_drm_hide;
window_class->render = gst_vaapi_window_drm_render;
window_class->resize = gst_vaapi_window_drm_resize;
}
static void
gst_vaapi_window_drm_init(GstVaapiWindowDRM * window)
gst_vaapi_window_drm_finalize(GstVaapiWindowDRM *window)
{
}
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
GstVaapiWindowDRM,
gst_vaapi_window_drm,
gst_vaapi_window_drm_class_init(&g_class))
/**
* gst_vaapi_window_drm_new:
* @display: a #GstVaapiDisplay
@ -148,14 +147,6 @@ gst_vaapi_window_drm_new(
{
GST_DEBUG("new window, size %ux%u", width, height);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
g_return_val_if_fail(width > 0, NULL);
g_return_val_if_fail(height > 0, NULL);
return g_object_new(GST_VAAPI_TYPE_WINDOW_DRM,
"display", display,
"id", GST_VAAPI_ID(0),
"width", width,
"height", height,
NULL);
return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
gst_vaapi_window_drm_class()), display, width, height);
}

View file

@ -27,55 +27,13 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_WINDOW_DRM \
(gst_vaapi_window_drm_get_type())
#define GST_VAAPI_WINDOW_DRM(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_WINDOW_DRM, \
GstVaapiWindowDRM))
#define GST_VAAPI_WINDOW_DRM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_WINDOW_DRM, \
GstVaapiWindowDRMClass))
#define GST_VAAPI_WINDOW_DRM(obj) \
((GstVaapiWindowDRM *)(obj))
#define GST_VAAPI_IS_WINDOW_DRM(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_WINDOW_DRM))
#define GST_VAAPI_IS_WINDOW_DRM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_WINDOW_DRM))
#define GST_VAAPI_WINDOW_DRM_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_WINDOW_DRM, \
GstVaapiWindowDRMClass))
((obj) != NULL)
typedef struct _GstVaapiWindowDRM GstVaapiWindowDRM;
typedef struct _GstVaapiWindowDRMClass GstVaapiWindowDRMClass;
/**
* GstVaapiWindowDRM:
*
* A dummy DRM window abstraction.
*/
struct _GstVaapiWindowDRM {
/*< private >*/
GstVaapiWindow parent_instance;
};
/**
* GstVaapiWindowDRMClass:
*
* A DRM window class.
*/
struct _GstVaapiWindowDRMClass {
/*< private >*/
GstVaapiWindowClass parent_class;
};
GType
gst_vaapi_window_drm_get_type(void) G_GNUC_CONST;
GstVaapiWindow *
gst_vaapi_window_drm_new(GstVaapiDisplay *display, guint width, guint height);

View file

@ -27,35 +27,58 @@
#include "sysdeps.h"
#include "gstvaapiwindow_glx.h"
#include "gstvaapiwindow_x11_priv.h"
#include "gstvaapidisplay_x11.h"
#include "gstvaapidisplay_x11_priv.h"
#include "gstvaapiutils_x11.h"
#include "gstvaapiutils_glx.h"
#include "gstvaapi_priv.h"
#define DEBUG 1
#include "gstvaapidebug.h"
G_DEFINE_TYPE(GstVaapiWindowGLX,
gst_vaapi_window_glx,
GST_VAAPI_TYPE_WINDOW_X11)
#define GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window) \
(&GST_VAAPI_WINDOW_GLX(window)->priv)
#define GST_VAAPI_WINDOW_GLX_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
GST_VAAPI_TYPE_WINDOW_GLX, \
GstVaapiWindowGLXPrivate))
#define GST_VAAPI_IS_WINDOW_GLX(obj) \
((obj) != NULL)
#define GST_VAAPI_WINDOW_GLX_CLASS(klass) \
((GstVaapiWindowGLXClass *)(klass))
#define GST_VAAPI_WINDOW_GLX_GET_CLASS(obj) \
GST_VAAPI_WINDOW_GLX_CLASS(GST_VAAPI_OBJECT_GET_CLASS(obj))
typedef struct _GstVaapiWindowGLXPrivate GstVaapiWindowGLXPrivate;
typedef struct _GstVaapiWindowGLXClass GstVaapiWindowGLXClass;
struct _GstVaapiWindowGLXPrivate {
Colormap cmap;
GLContextState *gl_context;
guint is_constructed : 1;
guint foreign_window : 1;
};
enum {
PROP_0,
/**
* GstVaapiWindowGLX:
*
* An X11 #Window suitable for GLX rendering.
*/
struct _GstVaapiWindowGLX {
/*< private >*/
GstVaapiWindowX11 parent_instance;
PROP_GLX_CONTEXT
GstVaapiWindowGLXPrivate priv;
};
/**
* GstVaapiWindowGLXClass:
*
* An X11 #Window suitable for GLX rendering.
*/
struct _GstVaapiWindowGLXClass {
/*< private >*/
GstVaapiWindowX11Class parent_class;
GstVaapiObjectFinalizeFunc parent_finalize;
GstVaapiWindowResizeFunc parent_resize;
};
/* Fill rectangle coords with capped bounds */
@ -88,9 +111,10 @@ fill_rect(
}
static void
_gst_vaapi_window_glx_destroy_context(GstVaapiWindowGLX *window)
_gst_vaapi_window_glx_destroy_context(GstVaapiWindow *window)
{
GstVaapiWindowGLXPrivate * const priv = window->priv;
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
if (priv->gl_context) {
@ -102,11 +126,12 @@ _gst_vaapi_window_glx_destroy_context(GstVaapiWindowGLX *window)
static gboolean
_gst_vaapi_window_glx_create_context(
GstVaapiWindowGLX *window,
GLXContext foreign_context
GstVaapiWindow *window,
GLXContext foreign_context
)
{
GstVaapiWindowGLXPrivate * const priv = window->priv;
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
GLContextState parent_cs;
@ -141,11 +166,12 @@ end:
static gboolean
_gst_vaapi_window_glx_ensure_context(
GstVaapiWindowGLX *window,
GLXContext foreign_context
GstVaapiWindow *window,
GLXContext foreign_context
)
{
GstVaapiWindowGLXPrivate * const priv = window->priv;
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
if (priv->gl_context) {
if (!foreign_context || foreign_context == priv->gl_context->context)
@ -157,11 +183,12 @@ _gst_vaapi_window_glx_ensure_context(
static gboolean
gst_vaapi_window_glx_ensure_context(
GstVaapiWindowGLX *window,
GLXContext foreign_context
GstVaapiWindow *window,
GLXContext foreign_context
)
{
GstVaapiWindowGLXPrivate * const priv = window->priv;
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
GLContextState old_cs;
guint width, height;
@ -182,7 +209,7 @@ gst_vaapi_window_glx_ensure_context(
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gst_vaapi_window_get_size(GST_VAAPI_WINDOW(window), &width, &height);
gst_vaapi_window_get_size(window, &width, &height);
gl_resize(width, height);
gl_set_bgcolor(0);
@ -194,21 +221,23 @@ gst_vaapi_window_glx_ensure_context(
static Visual *
gst_vaapi_window_glx_get_visual(GstVaapiWindow *window)
{
GstVaapiWindowGLX * const glx_window = GST_VAAPI_WINDOW_GLX(window);
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
if (!_gst_vaapi_window_glx_ensure_context(glx_window, NULL))
if (!_gst_vaapi_window_glx_ensure_context(window, NULL))
return NULL;
return glx_window->priv->gl_context->visual->visual;
return priv->gl_context->visual->visual;
}
static void
gst_vaapi_window_glx_destroy_colormap(GstVaapiWindowGLX *window)
gst_vaapi_window_glx_destroy_colormap(GstVaapiWindow *window)
{
GstVaapiWindowGLXPrivate * const priv = window->priv;
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
if (priv->cmap) {
if (!priv->foreign_window) {
if (!window->use_foreign_window) {
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
XFreeColormap(dpy, priv->cmap);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
@ -218,16 +247,17 @@ gst_vaapi_window_glx_destroy_colormap(GstVaapiWindowGLX *window)
}
static Colormap
gst_vaapi_window_glx_create_colormap(GstVaapiWindowGLX *window)
gst_vaapi_window_glx_create_colormap(GstVaapiWindow *window)
{
GstVaapiWindowGLXPrivate * const priv = window->priv;
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
int screen;
XWindowAttributes wattr;
gboolean success = FALSE;
if (!priv->cmap) {
if (!priv->foreign_window) {
if (!window->use_foreign_window) {
if (!_gst_vaapi_window_glx_ensure_context(window, NULL))
return None;
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
@ -260,18 +290,21 @@ gst_vaapi_window_glx_create_colormap(GstVaapiWindowGLX *window)
static Colormap
gst_vaapi_window_glx_get_colormap(GstVaapiWindow *window)
{
return gst_vaapi_window_glx_create_colormap(GST_VAAPI_WINDOW_GLX(window));
return gst_vaapi_window_glx_create_colormap(window);
}
static gboolean
gst_vaapi_window_glx_resize(GstVaapiWindow *window, guint width, guint height)
gst_vaapi_window_glx_resize(GstVaapiWindow *window,
guint width, guint height)
{
GstVaapiWindowGLXPrivate * const priv = GST_VAAPI_WINDOW_GLX(window)->priv;
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
const GstVaapiWindowGLXClass * const klass =
GST_VAAPI_WINDOW_GLX_GET_CLASS(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
GLContextState old_cs;
if (!GST_VAAPI_WINDOW_CLASS(gst_vaapi_window_glx_parent_class)->
resize(window, width, height))
if (!klass->parent_resize(window, width, height))
return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
@ -285,117 +318,37 @@ gst_vaapi_window_glx_resize(GstVaapiWindow *window, guint width, guint height)
}
static void
gst_vaapi_window_glx_finalize(GObject *object)
gst_vaapi_window_glx_finalize(GstVaapiWindowGLX *window)
{
GstVaapiWindowGLX * const window = GST_VAAPI_WINDOW_GLX(object);
GstVaapiWindow * const base_window = GST_VAAPI_WINDOW(window);
_gst_vaapi_window_glx_destroy_context(window);
gst_vaapi_window_glx_destroy_colormap(window);
_gst_vaapi_window_glx_destroy_context(base_window);
gst_vaapi_window_glx_destroy_colormap(base_window);
G_OBJECT_CLASS(gst_vaapi_window_glx_parent_class)->finalize(object);
}
static void
gst_vaapi_window_glx_set_property(
GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec
)
{
GstVaapiWindowGLX * const window = GST_VAAPI_WINDOW_GLX(object);
switch (prop_id) {
case PROP_GLX_CONTEXT:
gst_vaapi_window_glx_set_context(window, g_value_get_pointer(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
gst_vaapi_window_glx_get_property(
GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec
)
{
GstVaapiWindowGLX * const window = GST_VAAPI_WINDOW_GLX(object);
switch (prop_id) {
case PROP_GLX_CONTEXT:
g_value_set_pointer(value, gst_vaapi_window_glx_get_context(window));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
gst_vaapi_window_glx_constructed(GObject *object)
{
GstVaapiWindowGLXPrivate * const priv = GST_VAAPI_WINDOW_GLX(object)->priv;
GObjectClass *parent_class;
parent_class = G_OBJECT_CLASS(gst_vaapi_window_glx_parent_class);
if (parent_class->constructed)
parent_class->constructed(object);
priv->foreign_window =
gst_vaapi_window_x11_is_foreign_xid(GST_VAAPI_WINDOW_X11(object));
priv->is_constructed =
gst_vaapi_window_glx_ensure_context(GST_VAAPI_WINDOW_GLX(object), NULL);
GST_VAAPI_WINDOW_GLX_GET_CLASS(window)->parent_finalize(
GST_VAAPI_OBJECT(window));
}
static void
gst_vaapi_window_glx_class_init(GstVaapiWindowGLXClass *klass)
{
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
GstVaapiWindowClass * const win_class = GST_VAAPI_WINDOW_CLASS(klass);
GstVaapiWindowX11Class * const xwin_class = GST_VAAPI_WINDOW_X11_CLASS(klass);
GstVaapiWindowClass * const window_class =
GST_VAAPI_WINDOW_CLASS(klass);
GstVaapiWindowX11Class * const xwindow_class =
GST_VAAPI_WINDOW_X11_CLASS(klass);
g_type_class_add_private(klass, sizeof(GstVaapiWindowGLXPrivate));
object_class->finalize = gst_vaapi_window_glx_finalize;
object_class->set_property = gst_vaapi_window_glx_set_property;
object_class->get_property = gst_vaapi_window_glx_get_property;
object_class->constructed = gst_vaapi_window_glx_constructed;
win_class->resize = gst_vaapi_window_glx_resize;
xwin_class->get_visual = gst_vaapi_window_glx_get_visual;
xwin_class->get_colormap = gst_vaapi_window_glx_get_colormap;
/**
* GstVaapiDisplayGLX:glx-context:
*
* The GLX context that was created by gst_vaapi_window_glx_new()
* or that was bound from gst_vaapi_window_glx_set_context().
*/
g_object_class_install_property
(object_class,
PROP_GLX_CONTEXT,
g_param_spec_pointer("glx-context",
"GLX context",
"GLX context",
G_PARAM_READWRITE));
gst_vaapi_window_x11_class_init(xwindow_class);
klass->parent_resize = window_class->resize;
klass->parent_finalize = GST_VAAPI_OBJECT_CLASS(klass)->finalize;
window_class->resize = gst_vaapi_window_glx_resize;
xwindow_class->get_visual = gst_vaapi_window_glx_get_visual;
xwindow_class->get_colormap = gst_vaapi_window_glx_get_colormap;
}
static void
gst_vaapi_window_glx_init(GstVaapiWindowGLX *window)
{
GstVaapiWindowGLXPrivate *priv = GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
window->priv = priv;
priv->cmap = None;
priv->gl_context = NULL;
priv->is_constructed = FALSE;
priv->foreign_window = FALSE;
}
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
GstVaapiWindowGLX,
gst_vaapi_window_glx,
gst_vaapi_window_glx_class_init(&g_class))
/**
* gst_vaapi_window_glx_new:
@ -412,16 +365,8 @@ gst_vaapi_window_glx_init(GstVaapiWindowGLX *window)
GstVaapiWindow *
gst_vaapi_window_glx_new(GstVaapiDisplay *display, guint width, guint height)
{
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
g_return_val_if_fail(width > 0, NULL);
g_return_val_if_fail(height > 0, NULL);
return g_object_new(GST_VAAPI_TYPE_WINDOW_GLX,
"display", display,
"id", GST_VAAPI_ID(None),
"width", width,
"height", height,
NULL);
return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
gst_vaapi_window_glx_class()), display, width, height);
}
/**
@ -441,13 +386,10 @@ gst_vaapi_window_glx_new_with_xid(GstVaapiDisplay *display, Window xid)
{
GST_DEBUG("new window from xid 0x%08x", xid);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
g_return_val_if_fail(xid != None, NULL);
return g_object_new(GST_VAAPI_TYPE_WINDOW_GLX,
"display", display,
"id", GST_VAAPI_ID(xid),
NULL);
return gst_vaapi_window_new_from_native(GST_VAAPI_WINDOW_CLASS(
gst_vaapi_window_glx_class()), display, GINT_TO_POINTER(xid));
}
/**
@ -462,9 +404,8 @@ GLXContext
gst_vaapi_window_glx_get_context(GstVaapiWindowGLX *window)
{
g_return_val_if_fail(GST_VAAPI_IS_WINDOW_GLX(window), NULL);
g_return_val_if_fail(window->priv->is_constructed, FALSE);
return window->priv->gl_context->context;
return GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window)->gl_context->context;
}
/**
@ -483,9 +424,8 @@ gboolean
gst_vaapi_window_glx_set_context(GstVaapiWindowGLX *window, GLXContext ctx)
{
g_return_val_if_fail(GST_VAAPI_IS_WINDOW_GLX(window), FALSE);
g_return_val_if_fail(window->priv->is_constructed, FALSE);
return gst_vaapi_window_glx_ensure_context(window, ctx);
return gst_vaapi_window_glx_ensure_context(GST_VAAPI_WINDOW(window), ctx);
}
/**
@ -504,10 +444,9 @@ gst_vaapi_window_glx_make_current(GstVaapiWindowGLX *window)
gboolean success;
g_return_val_if_fail(GST_VAAPI_IS_WINDOW_GLX(window), FALSE);
g_return_val_if_fail(window->priv->is_constructed, FALSE);
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
success = gl_set_current_context(window->priv->gl_context, NULL);
success = gl_set_current_context(window->priv.gl_context, NULL);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
return success;
}
@ -524,10 +463,9 @@ void
gst_vaapi_window_glx_swap_buffers(GstVaapiWindowGLX *window)
{
g_return_if_fail(GST_VAAPI_IS_WINDOW_GLX(window));
g_return_if_fail(window->priv->is_constructed);
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
gl_swap_buffers(window->priv->gl_context);
gl_swap_buffers(window->priv.gl_context);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
}
@ -564,7 +502,7 @@ gst_vaapi_window_glx_put_texture(
guint win_width, win_height;
g_return_val_if_fail(GST_VAAPI_IS_WINDOW_GLX(window), FALSE);
g_return_val_if_fail(GST_VAAPI_IS_TEXTURE(texture), FALSE);
g_return_val_if_fail(texture != NULL, FALSE);
gst_vaapi_texture_get_size(texture, &tex_width, &tex_height);
fill_rect(&tmp_src_rect, src_rect, tex_width, tex_height);

View file

@ -30,58 +30,10 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_WINDOW_GLX \
(gst_vaapi_window_glx_get_type())
#define GST_VAAPI_WINDOW_GLX(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_WINDOW_GLX, \
GstVaapiWindowGLX))
#define GST_VAAPI_WINDOW_GLX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_WINDOW_GLX, \
GstVaapiWindowGLXClass))
#define GST_VAAPI_IS_WINDOW_GLX(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_WINDOW_GLX))
#define GST_VAAPI_IS_WINDOW_GLX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_WINDOW_GLX))
#define GST_VAAPI_WINDOW_GLX_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_WINDOW_GLX, \
GstVaapiWindowGLXClass))
#define GST_VAAPI_WINDOW_GLX(obj) \
((GstVaapiWindowGLX *)(obj))
typedef struct _GstVaapiWindowGLX GstVaapiWindowGLX;
typedef struct _GstVaapiWindowGLXPrivate GstVaapiWindowGLXPrivate;
typedef struct _GstVaapiWindowGLXClass GstVaapiWindowGLXClass;
/**
* GstVaapiWindowGLX:
*
* An X11 #Window suitable for GLX rendering.
*/
struct _GstVaapiWindowGLX {
/*< private >*/
GstVaapiWindowX11 parent_instance;
GstVaapiWindowGLXPrivate *priv;
};
/**
* GstVaapiWindowGLXClass:
*
* An X11 #Window suitable for GLX rendering.
*/
struct _GstVaapiWindowGLXClass {
/*< private >*/
GstVaapiWindowX11Class parent_class;
};
GType
gst_vaapi_window_glx_get_type(void) G_GNUC_CONST;
GstVaapiWindow *
gst_vaapi_window_glx_new(GstVaapiDisplay *display, guint width, guint height);

View file

@ -0,0 +1,131 @@
/*
* gstvaapiwindow_priv.h - VA window abstraction (private definitions)
*
* Copyright (C) 2010-2011 Splitted-Desktop Systems
* Copyright (C) 2012 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef GST_VAAPI_WINDOW_PRIV_H
#define GST_VAAPI_WINDOW_PRIV_H
#include "gstvaapiobject_priv.h"
G_BEGIN_DECLS
#define GST_VAAPI_WINDOW_CLASS(klass) \
((GstVaapiWindowClass *)(klass))
#define GST_VAAPI_WINDOW_GET_CLASS(obj) \
GST_VAAPI_WINDOW_CLASS(GST_VAAPI_OBJECT_GET_CLASS(obj))
/* GstVaapiWindowClass hooks */
typedef gboolean (*GstVaapiWindowCreateFunc) (GstVaapiWindow *window,
guint *width, guint *height);
typedef gboolean (*GstVaapiWindowShowFunc) (GstVaapiWindow *window);
typedef gboolean (*GstVaapiWindowHideFunc) (GstVaapiWindow *window);
typedef gboolean (*GstVaapiWindowGetGeometryFunc)(GstVaapiWindow *window,
gint *px, gint *py, guint *pwidth, guint *pheight);
typedef gboolean (*GstVaapiWindowSetFullscreenFunc)(GstVaapiWindow *window,
gboolean fullscreen);
typedef gboolean (*GstVaapiWindowResizeFunc) (GstVaapiWindow *window,
guint width, guint height);
typedef gboolean (*GstVaapiWindowRenderFunc) (GstVaapiWindow *window,
GstVaapiSurface *surface, const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect, guint flags);
/**
* GstVaapiWindow:
*
* Base class for system-dependent windows.
*/
struct _GstVaapiWindow {
/*< private >*/
GstVaapiObject parent_instance;
/*< protected >*/
guint width;
guint height;
guint display_width;
guint display_height;
guint use_foreign_window : 1;
guint is_fullscreen : 1;
guint check_geometry : 1;
};
/**
* GstVaapiWindowClass:
* @create: virtual function to create a window with width and height
* @show: virtual function to show (map) a window
* @hide: virtual function to hide (unmap) a window
* @get_geometry: virtual function to get the current window geometry
* @set_fullscreen: virtual function to change window fullscreen state
* @resize: virtual function to resize a window
* @render: virtual function to render a #GstVaapiSurface into a window
*
* Base class for system-dependent windows.
*/
struct _GstVaapiWindowClass {
/*< private >*/
GstVaapiObjectClass parent_class;
/*< protected >*/
GstVaapiWindowCreateFunc create;
GstVaapiWindowShowFunc show;
GstVaapiWindowHideFunc hide;
GstVaapiWindowGetGeometryFunc get_geometry;
GstVaapiWindowSetFullscreenFunc set_fullscreen;
GstVaapiWindowResizeFunc resize;
GstVaapiWindowRenderFunc render;
};
GstVaapiWindow *
gst_vaapi_window_new(const GstVaapiWindowClass *window_class,
GstVaapiDisplay *display, guint width, guint height);
GstVaapiWindow *
gst_vaapi_window_new_from_native(const GstVaapiWindowClass *window_class,
GstVaapiDisplay *display, gpointer native_window);
/* Inline reference counting for core libgstvaapi library */
#ifdef GST_VAAPI_CORE
#define gst_vaapi_window_ref_internal(window) \
((gpointer)gst_vaapi_mini_object_ref(GST_VAAPI_MINI_OBJECT(window)))
#define gst_vaapi_window_unref_internal(window) \
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(window))
#define gst_vaapi_window_replace_internal(old_window_ptr, new_window) \
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)(old_window_ptr), \
GST_VAAPI_MINI_OBJECT(new_window))
#undef gst_vaapi_window_ref
#define gst_vaapi_window_ref(window) \
gst_vaapi_window_ref_internal((window))
#undef gst_vaapi_window_unref
#define gst_vaapi_window_unref(window) \
gst_vaapi_window_unref_internal((window))
#undef gst_vaapi_window_replace
#define gst_vaapi_window_replace(old_window_ptr, new_window) \
gst_vaapi_window_replace_internal((old_window_ptr), (new_window))
#endif
G_END_DECLS
#endif /* GST_VAAPI_WINDOW_PRIV_H */

View file

@ -28,22 +28,22 @@
#include <string.h>
#include "gstvaapicompat.h"
#include "gstvaapiwindow_wayland.h"
#include "gstvaapiwindow_priv.h"
#include "gstvaapidisplay_wayland.h"
#include "gstvaapidisplay_wayland_priv.h"
#include "gstvaapiutils.h"
#include "gstvaapi_priv.h"
#define DEBUG 1
#include "gstvaapidebug.h"
G_DEFINE_TYPE(GstVaapiWindowWayland,
gst_vaapi_window_wayland,
GST_VAAPI_TYPE_WINDOW)
#define GST_VAAPI_WINDOW_WAYLAND_CAST(obj) \
((GstVaapiWindowWayland *)(obj))
#define GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
GST_VAAPI_TYPE_WINDOW_WAYLAND, \
GstVaapiWindowWaylandPrivate))
#define GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(obj) \
(&GST_VAAPI_WINDOW_WAYLAND_CAST(obj)->priv)
typedef struct _GstVaapiWindowWaylandPrivate GstVaapiWindowWaylandPrivate;
typedef struct _GstVaapiWindowWaylandClass GstVaapiWindowWaylandClass;
struct _GstVaapiWindowWaylandPrivate {
struct wl_shell_surface *shell_surface;
@ -56,6 +56,28 @@ struct _GstVaapiWindowWaylandPrivate {
guint fullscreen_on_show : 1;
};
/**
* GstVaapiWindowWayland:
*
* A Wayland window abstraction.
*/
struct _GstVaapiWindowWayland {
/*< private >*/
GstVaapiWindow parent_instance;
GstVaapiWindowWaylandPrivate priv;
};
/**
* GstVaapiWindowWaylandClass:
*
* An Wayland #Window wrapper class.
*/
struct _GstVaapiWindowWaylandClass {
/*< private >*/
GstVaapiWindowClass parent_class;
};
static gboolean
gst_vaapi_window_wayland_show(GstVaapiWindow *window)
{
@ -76,7 +98,7 @@ static gboolean
gst_vaapi_window_wayland_sync(GstVaapiWindow *window)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND(window)->priv;
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
if (priv->redraw_pending) {
struct wl_display * const wl_display =
@ -118,7 +140,7 @@ static gboolean
gst_vaapi_window_wayland_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND(window)->priv;
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
if (!priv->is_shown) {
priv->fullscreen_on_show = fullscreen;
@ -147,9 +169,9 @@ gst_vaapi_window_wayland_create(
)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND(window)->priv;
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
GstVaapiDisplayWaylandPrivate * const priv_display =
GST_VAAPI_OBJECT_DISPLAY_WAYLAND(window)->priv;
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(GST_VAAPI_OBJECT_DISPLAY(window));
GST_DEBUG("create window, size %ux%u", *width, *height);
@ -195,7 +217,7 @@ static void
gst_vaapi_window_wayland_destroy(GstVaapiWindow * window)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND(window)->priv;
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
if (priv->shell_surface) {
wl_shell_surface_destroy(priv->shell_surface);
@ -226,9 +248,9 @@ gst_vaapi_window_wayland_resize(
)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND(window)->priv;
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
GstVaapiDisplayWaylandPrivate * const priv_display =
GST_VAAPI_OBJECT_DISPLAY_WAYLAND(window)->priv;
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(GST_VAAPI_OBJECT_DISPLAY(window));
GST_DEBUG("resize window, new size %ux%u", width, height);
@ -267,7 +289,7 @@ gst_vaapi_window_wayland_render(
)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND(window)->priv;
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_DISPLAY(window);
struct wl_display * const wl_display = GST_VAAPI_OBJECT_WL_DISPLAY(window);
struct wl_buffer *buffer;
@ -343,35 +365,16 @@ gst_vaapi_window_wayland_render(
return TRUE;
}
static void
gst_vaapi_window_wayland_finalize(GObject *object)
{
G_OBJECT_CLASS(gst_vaapi_window_wayland_parent_class)->finalize(object);
}
static void
gst_vaapi_window_wayland_constructed(GObject *object)
{
GObjectClass *parent_class;
parent_class = G_OBJECT_CLASS(gst_vaapi_window_wayland_parent_class);
if (parent_class->constructed)
parent_class->constructed(object);
}
static void
gst_vaapi_window_wayland_class_init(GstVaapiWindowWaylandClass * klass)
{
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
GstVaapiObjectClass * const object_class = GST_VAAPI_OBJECT_CLASS(klass);
GstVaapiWindowClass * const window_class = GST_VAAPI_WINDOW_CLASS(klass);
g_type_class_add_private(klass, sizeof(GstVaapiWindowWaylandPrivate));
object_class->finalize = gst_vaapi_window_wayland_finalize;
object_class->constructed = gst_vaapi_window_wayland_constructed;
object_class->finalize = (GstVaapiObjectFinalizeFunc)
gst_vaapi_window_wayland_destroy;
window_class->create = gst_vaapi_window_wayland_create;
window_class->destroy = gst_vaapi_window_wayland_destroy;
window_class->show = gst_vaapi_window_wayland_show;
window_class->hide = gst_vaapi_window_wayland_hide;
window_class->render = gst_vaapi_window_wayland_render;
@ -379,18 +382,13 @@ gst_vaapi_window_wayland_class_init(GstVaapiWindowWaylandClass * klass)
window_class->set_fullscreen = gst_vaapi_window_wayland_set_fullscreen;
}
static void
gst_vaapi_window_wayland_init(GstVaapiWindowWayland * window)
{
GstVaapiWindowWaylandPrivate *priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
#define gst_vaapi_window_wayland_finalize \
gst_vaapi_window_wayland_destroy
window->priv = priv;
priv->shell_surface = NULL;
priv->surface = NULL;
priv->buffer = NULL;
priv->redraw_pending = FALSE;
}
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
GstVaapiWindowWayland,
gst_vaapi_window_wayland,
gst_vaapi_window_wayland_class_init(&g_class))
/**
* gst_vaapi_window_wayland_new:
@ -413,14 +411,6 @@ gst_vaapi_window_wayland_new(
{
GST_DEBUG("new window, size %ux%u", width, height);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
g_return_val_if_fail(width > 0, NULL);
g_return_val_if_fail(height > 0, NULL);
return g_object_new(GST_VAAPI_TYPE_WINDOW_WAYLAND,
"display", display,
"id", GST_VAAPI_ID(0),
"width", width,
"height", height,
NULL);
return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
gst_vaapi_window_wayland_class()), display, width, height);
}

View file

@ -28,58 +28,7 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_WINDOW_WAYLAND \
(gst_vaapi_window_wayland_get_type())
#define GST_VAAPI_WINDOW_WAYLAND(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_WINDOW_WAYLAND, \
GstVaapiWindowWayland))
#define GST_VAAPI_WINDOW_WAYLAND_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_WINDOW_WAYLAND, \
GstVaapiWindowWaylandClass))
#define GST_VAAPI_IS_WINDOW_WAYLAND(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_WINDOW_WAYLAND))
#define GST_VAAPI_IS_WINDOW_WAYLAND_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_WINDOW_WAYLAND))
#define GST_VAAPI_WINDOW_WAYLAND_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_WINDOW_WAYLAND, \
GstVaapiWindowWaylandClass))
typedef struct _GstVaapiWindowWayland GstVaapiWindowWayland;
typedef struct _GstVaapiWindowWaylandPrivate GstVaapiWindowWaylandPrivate;
typedef struct _GstVaapiWindowWaylandClass GstVaapiWindowWaylandClass;
/**
* GstVaapiWindowWayland:
*
* A Wayland window abstraction.
*/
struct _GstVaapiWindowWayland {
/*< private >*/
GstVaapiWindow parent_instance;
GstVaapiWindowWaylandPrivate *priv;
};
/**
* GstVaapiWindowWaylandClass:
*
* An Wayland #Window wrapper class.
*/
struct _GstVaapiWindowWaylandClass {
/*< private >*/
GstVaapiWindowClass parent_class;
};
GType
gst_vaapi_window_wayland_get_type(void) G_GNUC_CONST;
GstVaapiWindow *
gst_vaapi_window_wayland_new(GstVaapiDisplay *display, guint width, guint height);

View file

@ -30,38 +30,24 @@
#include <X11/Xatom.h>
#include "gstvaapicompat.h"
#include "gstvaapiwindow_x11.h"
#include "gstvaapiwindow_x11_priv.h"
#include "gstvaapidisplay_x11.h"
#include "gstvaapidisplay_x11_priv.h"
#include "gstvaapiutils.h"
#include "gstvaapiutils_x11.h"
#include "gstvaapi_priv.h"
#define DEBUG 1
#include "gstvaapidebug.h"
G_DEFINE_TYPE(GstVaapiWindowX11, gst_vaapi_window_x11, GST_VAAPI_TYPE_WINDOW)
#define GST_VAAPI_WINDOW_X11_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
GST_VAAPI_TYPE_WINDOW_X11, \
GstVaapiWindowX11Private))
struct _GstVaapiWindowX11Private {
Atom atom_NET_WM_STATE;
Atom atom_NET_WM_STATE_FULLSCREEN;
guint create_window : 1;
guint is_mapped : 1;
guint fullscreen_on_map : 1;
};
#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
#define _NET_WM_STATE_ADD 1 /* add/set property */
#define _NET_WM_STATE_TOGGLE 2 /* toggle property */
static void
send_wmspec_change_state(GstVaapiWindowX11 *window, Atom state, gboolean add)
send_wmspec_change_state(GstVaapiWindow *window, Atom state, gboolean add)
{
GstVaapiWindowX11Private * const priv = window->priv;
GstVaapiWindowX11Private * const priv =
GST_VAAPI_WINDOW_X11_GET_PRIVATE(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
XClientMessageEvent xclient;
@ -140,7 +126,8 @@ timed_wait_event(GstVaapiWindow *window, int type, guint64 end_time, XEvent *e)
static gboolean
gst_vaapi_window_x11_show(GstVaapiWindow *window)
{
GstVaapiWindowX11Private * const priv = GST_VAAPI_WINDOW_X11(window)->priv;
GstVaapiWindowX11Private * const priv =
GST_VAAPI_WINDOW_X11_GET_PRIVATE(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
const Window xid = GST_VAAPI_OBJECT_ID(window);
XWindowAttributes wattr;
@ -151,7 +138,7 @@ gst_vaapi_window_x11_show(GstVaapiWindow *window)
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
x11_trap_errors();
if (!priv->create_window) {
if (window->use_foreign_window) {
XGetWindowAttributes(dpy, xid, &wattr);
if (!(wattr.your_event_mask & StructureNotifyMask))
XSelectInput(dpy, xid, StructureNotifyMask);
@ -162,7 +149,7 @@ gst_vaapi_window_x11_show(GstVaapiWindow *window)
if (!has_errors) {
wait_event(window, MapNotify);
if (!priv->create_window &&
if (window->use_foreign_window &&
!(wattr.your_event_mask & StructureNotifyMask)) {
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
x11_trap_errors();
@ -181,7 +168,8 @@ gst_vaapi_window_x11_show(GstVaapiWindow *window)
static gboolean
gst_vaapi_window_x11_hide(GstVaapiWindow *window)
{
GstVaapiWindowX11Private * const priv = GST_VAAPI_WINDOW_X11(window)->priv;
GstVaapiWindowX11Private * const priv =
GST_VAAPI_WINDOW_X11_GET_PRIVATE(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
const Window xid = GST_VAAPI_OBJECT_ID(window);
XWindowAttributes wattr;
@ -192,7 +180,7 @@ gst_vaapi_window_x11_hide(GstVaapiWindow *window)
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
x11_trap_errors();
if (!priv->create_window) {
if (window->use_foreign_window) {
XGetWindowAttributes(dpy, xid, &wattr);
if (!(wattr.your_event_mask & StructureNotifyMask))
XSelectInput(dpy, xid, StructureNotifyMask);
@ -203,7 +191,7 @@ gst_vaapi_window_x11_hide(GstVaapiWindow *window)
if (!has_errors) {
wait_event(window, UnmapNotify);
if (!priv->create_window &&
if (window->use_foreign_window &&
!(wattr.your_event_mask & StructureNotifyMask)) {
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
x11_trap_errors();
@ -219,12 +207,13 @@ gst_vaapi_window_x11_hide(GstVaapiWindow *window)
static gboolean
gst_vaapi_window_x11_create(GstVaapiWindow *window, guint *width, guint *height)
{
GstVaapiWindowX11Private * const priv = GST_VAAPI_WINDOW_X11(window)->priv;
GstVaapiWindowX11Private * const priv =
GST_VAAPI_WINDOW_X11_GET_PRIVATE(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
Window xid = GST_VAAPI_OBJECT_ID(window);
Visual *vis = NULL;
Colormap cmap = None;
GstVaapiWindowX11Class *klass;
const GstVaapiWindowX11Class *klass;
XWindowAttributes wattr;
Atom atoms[2];
gboolean ok;
@ -234,7 +223,7 @@ gst_vaapi_window_x11_create(GstVaapiWindow *window, guint *width, guint *height)
"_NET_WM_STATE_FULLSCREEN",
};
if (!priv->create_window && xid) {
if (window->use_foreign_window && xid) {
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
XGetWindowAttributes(dpy, xid, &wattr);
priv->is_mapped = wattr.map_state == IsViewable;
@ -274,12 +263,11 @@ gst_vaapi_window_x11_create(GstVaapiWindow *window, guint *width, guint *height)
static void
gst_vaapi_window_x11_destroy(GstVaapiWindow *window)
{
GstVaapiWindowX11Private * const priv = GST_VAAPI_WINDOW_X11(window)->priv;
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
const Window xid = GST_VAAPI_OBJECT_ID(window);
if (xid) {
if (priv->create_window) {
if (!window->use_foreign_window) {
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
XDestroyWindow(dpy, xid);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
@ -305,7 +293,8 @@ gst_vaapi_window_x11_get_geometry(
static gboolean
gst_vaapi_window_x11_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
{
GstVaapiWindowX11Private * const priv = GST_VAAPI_WINDOW_X11(window)->priv;
GstVaapiWindowX11Private * const priv =
GST_VAAPI_WINDOW_X11_GET_PRIVATE(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
const Window xid = GST_VAAPI_OBJECT_ID(window);
XEvent e;
@ -330,7 +319,7 @@ gst_vaapi_window_x11_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
}
else {
send_wmspec_change_state(
GST_VAAPI_WINDOW_X11(window),
window,
priv->atom_NET_WM_STATE_FULLSCREEN,
TRUE
);
@ -348,7 +337,7 @@ gst_vaapi_window_x11_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
}
else {
send_wmspec_change_state(
GST_VAAPI_WINDOW_X11(window),
window,
priv->atom_NET_WM_STATE_FULLSCREEN,
FALSE
);
@ -361,7 +350,7 @@ gst_vaapi_window_x11_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
return FALSE;
/* Try to wait for the completion of the fullscreen mode switch */
if (priv->create_window && priv->is_mapped) {
if (!window->use_foreign_window && priv->is_mapped) {
const guint DELAY = 100000; /* 100 ms */
g_get_current_time(&now);
end_time = DELAY + ((guint64)now.tv_sec * 1000000 + now.tv_usec);
@ -445,38 +434,18 @@ gst_vaapi_window_x11_render(
return TRUE;
}
static void
gst_vaapi_window_x11_finalize(GObject *object)
{
G_OBJECT_CLASS(gst_vaapi_window_x11_parent_class)->finalize(object);
}
static void
gst_vaapi_window_x11_constructed(GObject *object)
{
GstVaapiWindowX11 * const window = GST_VAAPI_WINDOW_X11(object);
GObjectClass *parent_class;
window->priv->create_window = GST_VAAPI_OBJECT_ID(object) == None;
parent_class = G_OBJECT_CLASS(gst_vaapi_window_x11_parent_class);
if (parent_class->constructed)
parent_class->constructed(object);
}
static void
void
gst_vaapi_window_x11_class_init(GstVaapiWindowX11Class *klass)
{
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
GstVaapiWindowClass * const window_class = GST_VAAPI_WINDOW_CLASS(klass);
GstVaapiObjectClass * const object_class =
GST_VAAPI_OBJECT_CLASS(klass);
GstVaapiWindowClass * const window_class =
GST_VAAPI_WINDOW_CLASS(klass);
g_type_class_add_private(klass, sizeof(GstVaapiWindowX11Private));
object_class->finalize = gst_vaapi_window_x11_finalize;
object_class->constructed = gst_vaapi_window_x11_constructed;
object_class->finalize = (GstVaapiObjectFinalizeFunc)
gst_vaapi_window_x11_destroy;
window_class->create = gst_vaapi_window_x11_create;
window_class->destroy = gst_vaapi_window_x11_destroy;
window_class->show = gst_vaapi_window_x11_show;
window_class->hide = gst_vaapi_window_x11_hide;
window_class->get_geometry = gst_vaapi_window_x11_get_geometry;
@ -485,16 +454,13 @@ gst_vaapi_window_x11_class_init(GstVaapiWindowX11Class *klass)
window_class->render = gst_vaapi_window_x11_render;
}
static void
gst_vaapi_window_x11_init(GstVaapiWindowX11 *window)
{
GstVaapiWindowX11Private *priv = GST_VAAPI_WINDOW_X11_GET_PRIVATE(window);
#define gst_vaapi_window_x11_finalize \
gst_vaapi_window_x11_destroy
window->priv = priv;
priv->create_window = TRUE;
priv->is_mapped = FALSE;
priv->fullscreen_on_map = FALSE;
}
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
GstVaapiWindowX11,
gst_vaapi_window_x11,
gst_vaapi_window_x11_class_init(&g_class))
/**
* gst_vaapi_window_x11_new:
@ -513,16 +479,8 @@ gst_vaapi_window_x11_new(GstVaapiDisplay *display, guint width, guint height)
{
GST_DEBUG("new window, size %ux%u", width, height);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
g_return_val_if_fail(width > 0, NULL);
g_return_val_if_fail(height > 0, NULL);
return g_object_new(GST_VAAPI_TYPE_WINDOW_X11,
"display", display,
"id", GST_VAAPI_ID(None),
"width", width,
"height", height,
NULL);
return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
gst_vaapi_window_x11_class()), display, width, height);
}
/**
@ -542,13 +500,10 @@ gst_vaapi_window_x11_new_with_xid(GstVaapiDisplay *display, Window xid)
{
GST_DEBUG("new window from xid 0x%08x", xid);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
g_return_val_if_fail(xid != None, NULL);
return g_object_new(GST_VAAPI_TYPE_WINDOW_X11,
"display", display,
"id", GST_VAAPI_ID(xid),
NULL);
return gst_vaapi_window_new_from_native(GST_VAAPI_WINDOW_CLASS(
gst_vaapi_window_x11_class()), display, GINT_TO_POINTER(xid));
}
/**
@ -583,5 +538,5 @@ gst_vaapi_window_x11_is_foreign_xid(GstVaapiWindowX11 *window)
{
g_return_val_if_fail(GST_VAAPI_IS_WINDOW_X11(window), FALSE);
return !window->priv->create_window;
return GST_VAAPI_WINDOW(window)->use_foreign_window;
}

View file

@ -29,29 +29,11 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_WINDOW_X11 \
(gst_vaapi_window_x11_get_type())
#define GST_VAAPI_WINDOW_X11(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_WINDOW_X11, \
GstVaapiWindowX11))
#define GST_VAAPI_WINDOW_X11_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_WINDOW_X11, \
GstVaapiWindowX11Class))
#define GST_VAAPI_WINDOW_X11(obj) \
((GstVaapiWindowX11 *)(obj))
#define GST_VAAPI_IS_WINDOW_X11(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_WINDOW_X11))
#define GST_VAAPI_IS_WINDOW_X11_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_WINDOW_X11))
#define GST_VAAPI_WINDOW_X11_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_WINDOW_X11, \
GstVaapiWindowX11Class))
((obj) != NULL)
/**
* GST_VAAPI_WINDOW_XWINDOW:
@ -63,40 +45,6 @@ G_BEGIN_DECLS
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(window))
typedef struct _GstVaapiWindowX11 GstVaapiWindowX11;
typedef struct _GstVaapiWindowX11Private GstVaapiWindowX11Private;
typedef struct _GstVaapiWindowX11Class GstVaapiWindowX11Class;
/**
* GstVaapiWindowX11:
*
* An X11 #Window wrapper.
*/
struct _GstVaapiWindowX11 {
/*< private >*/
GstVaapiWindow parent_instance;
GstVaapiWindowX11Private *priv;
};
/**
* GstVaapiWindowX11Class:
* @get_visual: virtual function to get the desired visual used to
* create the window
* @get_colormap: virtual function to get the desired colormap used to
* create the window
*
* An X11 #Window wrapper class.
*/
struct _GstVaapiWindowX11Class {
/*< private >*/
GstVaapiWindowClass parent_class;
Visual * (*get_visual) (GstVaapiWindow *window);
Colormap (*get_colormap) (GstVaapiWindow *window);
};
GType
gst_vaapi_window_x11_get_type(void) G_GNUC_CONST;
GstVaapiWindow *
gst_vaapi_window_x11_new(GstVaapiDisplay *display, guint width, guint height);

View file

@ -0,0 +1,83 @@
/*
* gstvaapiwindow_x11_priv.h - VA/X11 window abstraction (private definitions)
*
* Copyright (C) 2010-2011 Splitted-Desktop Systems
* Copyright (C) 2012 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef GST_VAAPI_WINDOW_X11_PRIV_H
#define GST_VAAPI_WINDOW_X11_PRIV_H
#include "gstvaapiwindow_priv.h"
G_BEGIN_DECLS
#define GST_VAAPI_WINDOW_X11_GET_PRIVATE(obj) \
(&GST_VAAPI_WINDOW_X11(obj)->priv)
#define GST_VAAPI_WINDOW_X11_CLASS(klass) \
((GstVaapiWindowX11Class *)(klass))
#define GST_VAAPI_WINDOW_X11_GET_CLASS(obj) \
GST_VAAPI_WINDOW_X11_CLASS(GST_VAAPI_WINDOW_GET_CLASS(obj))
typedef struct _GstVaapiWindowX11Private GstVaapiWindowX11Private;
typedef struct _GstVaapiWindowX11Class GstVaapiWindowX11Class;
struct _GstVaapiWindowX11Private {
Atom atom_NET_WM_STATE;
Atom atom_NET_WM_STATE_FULLSCREEN;
guint is_mapped : 1;
guint fullscreen_on_map : 1;
};
/**
* GstVaapiWindowX11:
*
* An X11 #Window wrapper.
*/
struct _GstVaapiWindowX11 {
/*< private >*/
GstVaapiWindow parent_instance;
GstVaapiWindowX11Private priv;
};
/**
* GstVaapiWindowX11Class:
* @get_visual: virtual function to get the desired visual used to
* create the window
* @get_colormap: virtual function to get the desired colormap used to
* create the window
*
* An X11 #Window wrapper class.
*/
struct _GstVaapiWindowX11Class {
/*< private >*/
GstVaapiWindowClass parent_class;
Visual * (*get_visual) (GstVaapiWindow *window);
Colormap (*get_colormap) (GstVaapiWindow *window);
};
void
gst_vaapi_window_x11_class_init(GstVaapiWindowX11Class *klass);
G_END_DECLS
#endif /* GST_VAAPI_WINDOW_X11_PRIV_H */