window: re-indent all GstVaapiWindow related source code.

This commit is contained in:
Gwenole Beauchesne 2014-07-25 16:53:41 +02:00
parent 7c2c4c7a97
commit 3490212988
12 changed files with 1351 additions and 1464 deletions

View file

@ -41,87 +41,82 @@
#undef gst_vaapi_window_replace
static void
gst_vaapi_window_ensure_size(GstVaapiWindow *window)
gst_vaapi_window_ensure_size (GstVaapiWindow * window)
{
const GstVaapiWindowClass * const klass =
GST_VAAPI_WINDOW_GET_CLASS(window);
const GstVaapiWindowClass *const klass = GST_VAAPI_WINDOW_GET_CLASS (window);
if (!window->check_geometry)
return;
if (!window->check_geometry)
return;
if (klass->get_geometry)
klass->get_geometry(window, NULL, NULL,
&window->width, &window->height);
if (klass->get_geometry)
klass->get_geometry (window, NULL, NULL, &window->width, &window->height);
window->check_geometry = FALSE;
window->is_fullscreen = (window->width == window->display_width &&
window->height == window->display_height);
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, guint width, guint height)
gst_vaapi_window_create (GstVaapiWindow * window, guint width, guint height)
{
gst_vaapi_display_get_size(
GST_VAAPI_OBJECT_DISPLAY(window),
&window->display_width,
&window->display_height
);
gst_vaapi_display_get_size (GST_VAAPI_OBJECT_DISPLAY (window),
&window->display_width, &window->display_height);
if (!GST_VAAPI_WINDOW_GET_CLASS(window)->create(window, &width, &height))
return FALSE;
if (!GST_VAAPI_WINDOW_GET_CLASS (window)->create (window, &width, &height))
return FALSE;
if (width != window->width || height != window->height) {
GST_DEBUG("backend resized window to %ux%u", width, height);
window->width = width;
window->height = height;
}
return TRUE;
if (width != window->width || height != window->height) {
GST_DEBUG ("backend resized window to %ux%u", width, height);
window->width = width;
window->height = height;
}
return TRUE;
}
GstVaapiWindow *
gst_vaapi_window_new(const GstVaapiWindowClass *window_class,
GstVaapiDisplay *display, guint width, guint height)
gst_vaapi_window_new (const GstVaapiWindowClass * window_class,
GstVaapiDisplay * display, guint width, guint height)
{
GstVaapiWindow *window;
GstVaapiWindow *window;
g_return_val_if_fail(width > 0, NULL);
g_return_val_if_fail(height > 0, NULL);
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;
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;
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;
gst_vaapi_window_unref_internal (window);
return NULL;
}
GstVaapiWindow *
gst_vaapi_window_new_from_native(const GstVaapiWindowClass *window_class,
GstVaapiDisplay *display, gpointer native_window)
gst_vaapi_window_new_from_native (const GstVaapiWindowClass * window_class,
GstVaapiDisplay * display, gpointer native_window)
{
GstVaapiWindow *window;
GstVaapiWindow *window;
window = gst_vaapi_object_new(GST_VAAPI_OBJECT_CLASS(window_class),
display);
if (!window)
return NULL;
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;
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;
gst_vaapi_window_unref_internal (window);
return NULL;
}
/**
@ -133,9 +128,9 @@ error:
* Returns: The same @window argument
*/
GstVaapiWindow *
gst_vaapi_window_ref(GstVaapiWindow *window)
gst_vaapi_window_ref (GstVaapiWindow * window)
{
return gst_vaapi_window_ref_internal(window);
return gst_vaapi_window_ref_internal (window);
}
/**
@ -146,9 +141,9 @@ gst_vaapi_window_ref(GstVaapiWindow *window)
* the reference count reaches zero, the window will be free'd.
*/
void
gst_vaapi_window_unref(GstVaapiWindow *window)
gst_vaapi_window_unref (GstVaapiWindow * window)
{
gst_vaapi_window_unref_internal(window);
gst_vaapi_window_unref_internal (window);
}
/**
@ -161,10 +156,10 @@ gst_vaapi_window_unref(GstVaapiWindow *window)
* valid window. However, @new_window can be NULL.
*/
void
gst_vaapi_window_replace(GstVaapiWindow **old_window_ptr,
GstVaapiWindow *new_window)
gst_vaapi_window_replace (GstVaapiWindow ** old_window_ptr,
GstVaapiWindow * new_window)
{
gst_vaapi_window_replace_internal(old_window_ptr, new_window);
gst_vaapi_window_replace_internal (old_window_ptr, new_window);
}
/**
@ -176,11 +171,11 @@ gst_vaapi_window_replace(GstVaapiWindow **old_window_ptr,
* Return value: the parent #GstVaapiDisplay object
*/
GstVaapiDisplay *
gst_vaapi_window_get_display(GstVaapiWindow *window)
gst_vaapi_window_get_display (GstVaapiWindow * window)
{
g_return_val_if_fail(window != NULL, NULL);
g_return_val_if_fail (window != NULL, NULL);
return GST_VAAPI_OBJECT_DISPLAY(window);
return GST_VAAPI_OBJECT_DISPLAY (window);
}
/**
@ -191,12 +186,12 @@ gst_vaapi_window_get_display(GstVaapiWindow *window)
* not appear on the screen.
*/
void
gst_vaapi_window_show(GstVaapiWindow *window)
gst_vaapi_window_show (GstVaapiWindow * window)
{
g_return_if_fail(window != NULL);
g_return_if_fail (window != NULL);
GST_VAAPI_WINDOW_GET_CLASS(window)->show(window);
window->check_geometry = TRUE;
GST_VAAPI_WINDOW_GET_CLASS (window)->show (window);
window->check_geometry = TRUE;
}
/**
@ -207,11 +202,11 @@ gst_vaapi_window_show(GstVaapiWindow *window)
* to be hidden (invisible to the user).
*/
void
gst_vaapi_window_hide(GstVaapiWindow *window)
gst_vaapi_window_hide (GstVaapiWindow * window)
{
g_return_if_fail(window != NULL);
g_return_if_fail (window != NULL);
GST_VAAPI_WINDOW_GET_CLASS(window)->hide(window);
GST_VAAPI_WINDOW_GET_CLASS (window)->hide (window);
}
/**
@ -223,13 +218,13 @@ gst_vaapi_window_hide(GstVaapiWindow *window)
* Return value: %TRUE if the window is fullscreen
*/
gboolean
gst_vaapi_window_get_fullscreen(GstVaapiWindow *window)
gst_vaapi_window_get_fullscreen (GstVaapiWindow * window)
{
g_return_val_if_fail(window != NULL, FALSE);
g_return_val_if_fail (window != NULL, FALSE);
gst_vaapi_window_ensure_size(window);
gst_vaapi_window_ensure_size (window);
return window->is_fullscreen;
return window->is_fullscreen;
}
/**
@ -240,19 +235,19 @@ gst_vaapi_window_get_fullscreen(GstVaapiWindow *window)
* Requests to place the @window in fullscreen or unfullscreen states.
*/
void
gst_vaapi_window_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
gst_vaapi_window_set_fullscreen (GstVaapiWindow * window, gboolean fullscreen)
{
const GstVaapiWindowClass *klass;
const GstVaapiWindowClass *klass;
g_return_if_fail(window != NULL);
g_return_if_fail (window != NULL);
klass = GST_VAAPI_WINDOW_GET_CLASS(window);
klass = GST_VAAPI_WINDOW_GET_CLASS (window);
if (window->is_fullscreen != fullscreen &&
klass->set_fullscreen && klass->set_fullscreen(window, fullscreen)) {
window->is_fullscreen = fullscreen;
window->check_geometry = TRUE;
}
if (window->is_fullscreen != fullscreen &&
klass->set_fullscreen && klass->set_fullscreen (window, fullscreen)) {
window->is_fullscreen = fullscreen;
window->check_geometry = TRUE;
}
}
/**
@ -264,13 +259,13 @@ gst_vaapi_window_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
* Return value: the width of the @window, in pixels
*/
guint
gst_vaapi_window_get_width(GstVaapiWindow *window)
gst_vaapi_window_get_width (GstVaapiWindow * window)
{
g_return_val_if_fail(window != NULL, 0);
g_return_val_if_fail (window != NULL, 0);
gst_vaapi_window_ensure_size(window);
gst_vaapi_window_ensure_size (window);
return window->width;
return window->width;
}
/**
@ -282,35 +277,36 @@ gst_vaapi_window_get_width(GstVaapiWindow *window)
* Return value: the height of the @window, in pixels
*/
guint
gst_vaapi_window_get_height(GstVaapiWindow *window)
gst_vaapi_window_get_height (GstVaapiWindow * window)
{
g_return_val_if_fail(window != NULL, 0);
g_return_val_if_fail (window != NULL, 0);
gst_vaapi_window_ensure_size(window);
gst_vaapi_window_ensure_size (window);
return window->height;
return window->height;
}
/**
* gst_vaapi_window_get_size:
* @window: a #GstVaapiWindow
* @pwidth: return location for the width, or %NULL
* @pheight: return location for the height, or %NULL
* @width_ptr: return location for the width, or %NULL
* @height_ptr: return location for the height, or %NULL
*
* Retrieves the dimensions of a #GstVaapiWindow.
*/
void
gst_vaapi_window_get_size(GstVaapiWindow *window, guint *pwidth, guint *pheight)
gst_vaapi_window_get_size (GstVaapiWindow * window, guint * width_ptr,
guint * height_ptr)
{
g_return_if_fail(window != NULL);
g_return_if_fail (window != NULL);
gst_vaapi_window_ensure_size(window);
gst_vaapi_window_ensure_size (window);
if (pwidth)
*pwidth = window->width;
if (width_ptr)
*width_ptr = window->width;
if (pheight)
*pheight = window->height;
if (height_ptr)
*height_ptr = window->height;
}
/**
@ -321,11 +317,11 @@ gst_vaapi_window_get_size(GstVaapiWindow *window, guint *pwidth, guint *pheight)
* Resizes the @window to match the specified @width.
*/
void
gst_vaapi_window_set_width(GstVaapiWindow *window, guint width)
gst_vaapi_window_set_width (GstVaapiWindow * window, guint width)
{
g_return_if_fail(window != NULL);
g_return_if_fail (window != NULL);
gst_vaapi_window_set_size(window, width, window->height);
gst_vaapi_window_set_size (window, width, window->height);
}
/**
@ -336,11 +332,11 @@ gst_vaapi_window_set_width(GstVaapiWindow *window, guint width)
* Resizes the @window to match the specified @height.
*/
void
gst_vaapi_window_set_height(GstVaapiWindow *window, guint height)
gst_vaapi_window_set_height (GstVaapiWindow * window, guint height)
{
g_return_if_fail(window != NULL);
g_return_if_fail (window != NULL);
gst_vaapi_window_set_size(window, window->width, height);
gst_vaapi_window_set_size (window, window->width, height);
}
/**
@ -352,39 +348,39 @@ gst_vaapi_window_set_height(GstVaapiWindow *window, guint height)
* Resizes the @window to match the specified @width and @height.
*/
void
gst_vaapi_window_set_size(GstVaapiWindow *window, guint width, guint height)
gst_vaapi_window_set_size (GstVaapiWindow * window, guint width, guint height)
{
g_return_if_fail(window != NULL);
g_return_if_fail (window != NULL);
if (width == window->width && height == window->height)
return;
if (width == window->width && height == window->height)
return;
if (!GST_VAAPI_WINDOW_GET_CLASS(window)->resize(window, width, height))
return;
if (!GST_VAAPI_WINDOW_GET_CLASS (window)->resize (window, width, height))
return;
window->width = width;
window->height = height;
window->width = width;
window->height = height;
}
static inline void
get_surface_rect(GstVaapiSurface *surface, GstVaapiRectangle *rect)
get_surface_rect (GstVaapiSurface * surface, GstVaapiRectangle * rect)
{
rect->x = 0;
rect->y = 0;
rect->width = GST_VAAPI_SURFACE_WIDTH(surface);
rect->height = GST_VAAPI_SURFACE_HEIGHT(surface);
rect->x = 0;
rect->y = 0;
rect->width = GST_VAAPI_SURFACE_WIDTH (surface);
rect->height = GST_VAAPI_SURFACE_HEIGHT (surface);
}
static inline void
get_window_rect(GstVaapiWindow *window, GstVaapiRectangle *rect)
get_window_rect (GstVaapiWindow * window, GstVaapiRectangle * rect)
{
guint width, height;
guint width, height;
gst_vaapi_window_get_size(window, &width, &height);
rect->x = 0;
rect->y = 0;
rect->width = width;
rect->height = height;
gst_vaapi_window_get_size (window, &width, &height);
rect->x = 0;
rect->y = 0;
rect->width = width;
rect->height = height;
}
/**
@ -406,47 +402,44 @@ get_window_rect(GstVaapiWindow *window, GstVaapiRectangle *rect)
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_window_put_surface(
GstVaapiWindow *window,
GstVaapiSurface *surface,
const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect,
guint flags
)
gst_vaapi_window_put_surface (GstVaapiWindow * window,
GstVaapiSurface * surface,
const GstVaapiRectangle * src_rect,
const GstVaapiRectangle * dst_rect, guint flags)
{
const GstVaapiWindowClass *klass;
GstVaapiRectangle src_rect_default, dst_rect_default;
const GstVaapiWindowClass *klass;
GstVaapiRectangle src_rect_default, dst_rect_default;
g_return_val_if_fail(window != NULL, FALSE);
g_return_val_if_fail(surface != NULL, FALSE);
g_return_val_if_fail (window != NULL, FALSE);
g_return_val_if_fail (surface != NULL, FALSE);
klass = GST_VAAPI_WINDOW_GET_CLASS(window);
if (!klass->render)
return FALSE;
klass = GST_VAAPI_WINDOW_GET_CLASS (window);
if (!klass->render)
return FALSE;
if (!src_rect) {
src_rect = &src_rect_default;
get_surface_rect(surface, &src_rect_default);
}
if (!src_rect) {
src_rect = &src_rect_default;
get_surface_rect (surface, &src_rect_default);
}
if (!dst_rect) {
dst_rect = &dst_rect_default;
get_window_rect(window, &dst_rect_default);
}
if (!dst_rect) {
dst_rect = &dst_rect_default;
get_window_rect (window, &dst_rect_default);
}
return klass->render(window, surface, src_rect, dst_rect, flags);
return klass->render (window, surface, src_rect, dst_rect, flags);
}
static inline void
get_pixmap_rect(GstVaapiPixmap *pixmap, GstVaapiRectangle *rect)
get_pixmap_rect (GstVaapiPixmap * pixmap, GstVaapiRectangle * rect)
{
guint width, height;
guint width, height;
gst_vaapi_pixmap_get_size(pixmap, &width, &height);
rect->x = 0;
rect->y = 0;
rect->width = width;
rect->height = height;
gst_vaapi_pixmap_get_size (pixmap, &width, &height);
rect->x = 0;
rect->y = 0;
rect->width = width;
rect->height = height;
}
/**
@ -465,31 +458,28 @@ get_pixmap_rect(GstVaapiPixmap *pixmap, GstVaapiRectangle *rect)
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_window_put_pixmap(
GstVaapiWindow *window,
GstVaapiPixmap *pixmap,
const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect
)
gst_vaapi_window_put_pixmap (GstVaapiWindow * window,
GstVaapiPixmap * pixmap,
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect)
{
const GstVaapiWindowClass *klass;
GstVaapiRectangle src_rect_default, dst_rect_default;
const GstVaapiWindowClass *klass;
GstVaapiRectangle src_rect_default, dst_rect_default;
g_return_val_if_fail(window != NULL, FALSE);
g_return_val_if_fail(pixmap != NULL, FALSE);
g_return_val_if_fail (window != NULL, FALSE);
g_return_val_if_fail (pixmap != NULL, FALSE);
klass = GST_VAAPI_WINDOW_GET_CLASS(window);
if (!klass->render_pixmap)
return FALSE;
klass = GST_VAAPI_WINDOW_GET_CLASS (window);
if (!klass->render_pixmap)
return FALSE;
if (!src_rect) {
src_rect = &src_rect_default;
get_pixmap_rect(pixmap, &src_rect_default);
}
if (!src_rect) {
src_rect = &src_rect_default;
get_pixmap_rect (pixmap, &src_rect_default);
}
if (!dst_rect) {
dst_rect = &dst_rect_default;
get_window_rect(window, &dst_rect_default);
}
return klass->render_pixmap(window, pixmap, src_rect, dst_rect);
if (!dst_rect) {
dst_rect = &dst_rect_default;
get_window_rect (window, &dst_rect_default);
}
return klass->render_pixmap (window, pixmap, src_rect, dst_rect);
}

View file

@ -37,68 +37,61 @@ G_BEGIN_DECLS
#define GST_VAAPI_WINDOW(obj) \
((GstVaapiWindow *)(obj))
typedef struct _GstVaapiWindow GstVaapiWindow;
typedef struct _GstVaapiWindowClass GstVaapiWindowClass;
typedef struct _GstVaapiWindow GstVaapiWindow;
typedef struct _GstVaapiWindowClass GstVaapiWindowClass;
GstVaapiWindow *
gst_vaapi_window_ref(GstVaapiWindow *window);
gst_vaapi_window_ref (GstVaapiWindow * window);
void
gst_vaapi_window_unref(GstVaapiWindow *window);
gst_vaapi_window_unref (GstVaapiWindow * window);
void
gst_vaapi_window_replace(GstVaapiWindow **old_window_ptr,
GstVaapiWindow *new_window);
gst_vaapi_window_replace (GstVaapiWindow ** old_window_ptr,
GstVaapiWindow * new_window);
GstVaapiDisplay *
gst_vaapi_window_get_display(GstVaapiWindow *window);
gst_vaapi_window_get_display (GstVaapiWindow * window);
void
gst_vaapi_window_show(GstVaapiWindow *window);
gst_vaapi_window_show (GstVaapiWindow * window);
void
gst_vaapi_window_hide(GstVaapiWindow *window);
gst_vaapi_window_hide (GstVaapiWindow * window);
gboolean
gst_vaapi_window_get_fullscreen(GstVaapiWindow *window);
gst_vaapi_window_get_fullscreen (GstVaapiWindow * window);
void
gst_vaapi_window_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen);
gst_vaapi_window_set_fullscreen (GstVaapiWindow * window, gboolean fullscreen);
guint
gst_vaapi_window_get_width(GstVaapiWindow *window);
gst_vaapi_window_get_width (GstVaapiWindow * window);
guint
gst_vaapi_window_get_height(GstVaapiWindow *window);
gst_vaapi_window_get_height (GstVaapiWindow * window);
void
gst_vaapi_window_get_size(GstVaapiWindow *window, guint *pwidth, guint *pheight);
gst_vaapi_window_get_size (GstVaapiWindow * window, guint * width_ptr,
guint * height_ptr);
void
gst_vaapi_window_set_width(GstVaapiWindow *window, guint width);
gst_vaapi_window_set_width (GstVaapiWindow * window, guint width);
void
gst_vaapi_window_set_height(GstVaapiWindow *window, guint height);
gst_vaapi_window_set_height (GstVaapiWindow * window, guint height);
void
gst_vaapi_window_set_size(GstVaapiWindow *window, guint width, guint height);
gst_vaapi_window_set_size (GstVaapiWindow * window, guint width, guint height);
gboolean
gst_vaapi_window_put_surface(
GstVaapiWindow *window,
GstVaapiSurface *surface,
const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect,
guint flags
);
gst_vaapi_window_put_surface (GstVaapiWindow * window,
GstVaapiSurface * surface, const GstVaapiRectangle * src_rect,
const GstVaapiRectangle * dst_rect, guint flags);
gboolean
gst_vaapi_window_put_pixmap(
GstVaapiWindow *window,
GstVaapiPixmap *pixmap,
const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect
);
gst_vaapi_window_put_pixmap (GstVaapiWindow * window, GstVaapiPixmap * pixmap,
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect);
G_END_DECLS

View file

@ -33,16 +33,17 @@
#define DEBUG 1
#include "gstvaapidebug.h"
typedef struct _GstVaapiWindowDRMClass GstVaapiWindowDRMClass;
typedef struct _GstVaapiWindowDRMClass GstVaapiWindowDRMClass;
/**
* GstVaapiWindowDRM:
*
* A dummy DRM window abstraction.
*/
struct _GstVaapiWindowDRM {
/*< private >*/
GstVaapiWindow parent_instance;
struct _GstVaapiWindowDRM
{
/*< private >*/
GstVaapiWindow parent_instance;
};
/**
@ -50,77 +51,65 @@ struct _GstVaapiWindowDRM {
*
* A dummy DRM window abstraction class.
*/
struct _GstVaapiWindowDRMClass {
/*< private >*/
GstVaapiWindowClass parent_instance;
struct _GstVaapiWindowDRMClass
{
/*< private >*/
GstVaapiWindowClass parent_instance;
};
static gboolean
gst_vaapi_window_drm_show(GstVaapiWindow *window)
gst_vaapi_window_drm_show (GstVaapiWindow * window)
{
return TRUE;
return TRUE;
}
static gboolean
gst_vaapi_window_drm_hide(GstVaapiWindow *window)
gst_vaapi_window_drm_hide (GstVaapiWindow * window)
{
return TRUE;
return TRUE;
}
static gboolean
gst_vaapi_window_drm_create(
GstVaapiWindow *window,
guint *width,
guint *height
)
gst_vaapi_window_drm_create (GstVaapiWindow * window,
guint * width, guint * height)
{
return TRUE;
return TRUE;
}
static gboolean
gst_vaapi_window_drm_resize(
GstVaapiWindow * window,
guint width,
guint height
)
gst_vaapi_window_drm_resize (GstVaapiWindow * window, guint width, guint height)
{
return TRUE;
return TRUE;
}
static gboolean
gst_vaapi_window_drm_render(
GstVaapiWindow *window,
GstVaapiSurface *surface,
const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect,
guint flags
)
gst_vaapi_window_drm_render (GstVaapiWindow * window,
GstVaapiSurface * surface,
const GstVaapiRectangle * src_rect,
const GstVaapiRectangle * dst_rect, guint flags)
{
return TRUE;
return TRUE;
}
void
gst_vaapi_window_drm_class_init(GstVaapiWindowDRMClass *klass)
gst_vaapi_window_drm_class_init (GstVaapiWindowDRMClass * klass)
{
GstVaapiWindowClass * const window_class =
GST_VAAPI_WINDOW_CLASS(klass);
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;
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_finalize(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_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiWindowDRM,
gst_vaapi_window_drm, gst_vaapi_window_drm_class_init (&g_class));
/**
* gst_vaapi_window_drm_new:
@ -141,16 +130,13 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
* Return value: the newly allocated #GstVaapiWindow object
*/
GstVaapiWindow *
gst_vaapi_window_drm_new(
GstVaapiDisplay *display,
guint width,
guint height
)
gst_vaapi_window_drm_new (GstVaapiDisplay * display, guint width, guint height)
{
GST_DEBUG("new window, size %ux%u", width, height);
GST_DEBUG ("new window, size %ux%u", width, height);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_DRM(display), NULL);
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_DRM (display), NULL);
return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
gst_vaapi_window_drm_class()), display, width, height);
return
gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS (gst_vaapi_window_drm_class
()), display, width, height);
}

View file

@ -31,10 +31,10 @@ G_BEGIN_DECLS
#define GST_VAAPI_WINDOW_DRM(obj) \
((GstVaapiWindowDRM *)(obj))
typedef struct _GstVaapiWindowDRM GstVaapiWindowDRM;
typedef struct _GstVaapiWindowDRM GstVaapiWindowDRM;
GstVaapiWindow *
gst_vaapi_window_drm_new(GstVaapiDisplay *display, guint width, guint height);
gst_vaapi_window_drm_new (GstVaapiDisplay * display, guint width, guint height);
G_END_DECLS

View file

@ -48,12 +48,13 @@
#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;
typedef struct _GstVaapiWindowGLXPrivate GstVaapiWindowGLXPrivate;
typedef struct _GstVaapiWindowGLXClass GstVaapiWindowGLXClass;
struct _GstVaapiWindowGLXPrivate {
Colormap cmap;
GLContextState *gl_context;
struct _GstVaapiWindowGLXPrivate
{
Colormap cmap;
GLContextState *gl_context;
};
/**
@ -61,11 +62,12 @@ struct _GstVaapiWindowGLXPrivate {
*
* An X11 #Window suitable for GLX rendering.
*/
struct _GstVaapiWindowGLX {
/*< private >*/
GstVaapiWindowX11 parent_instance;
struct _GstVaapiWindowGLX
{
/*< private >*/
GstVaapiWindowX11 parent_instance;
GstVaapiWindowGLXPrivate priv;
GstVaapiWindowGLXPrivate priv;
};
/**
@ -73,282 +75,261 @@ struct _GstVaapiWindowGLX {
*
* An X11 #Window suitable for GLX rendering.
*/
struct _GstVaapiWindowGLXClass {
/*< private >*/
GstVaapiWindowX11Class parent_class;
struct _GstVaapiWindowGLXClass
{
/*< private >*/
GstVaapiWindowX11Class parent_class;
GstVaapiObjectFinalizeFunc parent_finalize;
GstVaapiWindowResizeFunc parent_resize;
GstVaapiObjectFinalizeFunc parent_finalize;
GstVaapiWindowResizeFunc parent_resize;
};
/* Fill rectangle coords with capped bounds */
static inline void
fill_rect(
GstVaapiRectangle *dst_rect,
const GstVaapiRectangle *src_rect,
guint width,
guint height
)
fill_rect (GstVaapiRectangle * dst_rect,
const GstVaapiRectangle * src_rect, guint width, guint height)
{
if (src_rect) {
dst_rect->x = src_rect->x > 0 ? src_rect->x : 0;
dst_rect->y = src_rect->y > 0 ? src_rect->y : 0;
if (src_rect->x + src_rect->width < width)
dst_rect->width = src_rect->width;
else
dst_rect->width = width - dst_rect->x;
if (src_rect->y + src_rect->height < height)
dst_rect->height = src_rect->height;
else
dst_rect->height = height - dst_rect->y;
}
else {
dst_rect->x = 0;
dst_rect->y = 0;
dst_rect->width = width;
dst_rect->height = height;
}
if (src_rect) {
dst_rect->x = src_rect->x > 0 ? src_rect->x : 0;
dst_rect->y = src_rect->y > 0 ? src_rect->y : 0;
if (src_rect->x + src_rect->width < width)
dst_rect->width = src_rect->width;
else
dst_rect->width = width - dst_rect->x;
if (src_rect->y + src_rect->height < height)
dst_rect->height = src_rect->height;
else
dst_rect->height = height - dst_rect->y;
} else {
dst_rect->x = 0;
dst_rect->y = 0;
dst_rect->width = width;
dst_rect->height = height;
}
}
static void
_gst_vaapi_window_glx_destroy_context(GstVaapiWindow *window)
_gst_vaapi_window_glx_destroy_context (GstVaapiWindow * window)
{
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
GstVaapiWindowGLXPrivate *const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
if (priv->gl_context) {
gl_destroy_context(priv->gl_context);
priv->gl_context = NULL;
}
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
if (priv->gl_context) {
gl_destroy_context (priv->gl_context);
priv->gl_context = NULL;
}
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
}
static gboolean
_gst_vaapi_window_glx_create_context(
GstVaapiWindow *window,
GLXContext foreign_context
)
_gst_vaapi_window_glx_create_context (GstVaapiWindow * window,
GLXContext foreign_context)
{
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
GLContextState parent_cs;
GstVaapiWindowGLXPrivate *const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
GLContextState parent_cs;
parent_cs.display = dpy;
parent_cs.window = None;
parent_cs.context = foreign_context;
parent_cs.display = dpy;
parent_cs.window = None;
parent_cs.context = foreign_context;
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
priv->gl_context = gl_create_context(
dpy,
GST_VAAPI_OBJECT_XSCREEN(window),
&parent_cs
);
if (!priv->gl_context) {
GST_DEBUG("could not create GLX context");
goto end;
}
if (!glXIsDirect(dpy, priv->gl_context->context)) {
GST_DEBUG("could not create a direct-rendering GLX context");
goto out_destroy_context;
}
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
priv->gl_context = gl_create_context (dpy,
GST_VAAPI_OBJECT_XSCREEN (window), &parent_cs);
if (!priv->gl_context) {
GST_DEBUG ("could not create GLX context");
goto end;
}
if (!glXIsDirect (dpy, priv->gl_context->context)) {
GST_DEBUG ("could not create a direct-rendering GLX context");
goto out_destroy_context;
}
goto end;
out_destroy_context:
gl_destroy_context(priv->gl_context);
priv->gl_context = NULL;
gl_destroy_context (priv->gl_context);
priv->gl_context = NULL;
end:
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
return priv->gl_context != NULL;
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
return priv->gl_context != NULL;
}
static gboolean
_gst_vaapi_window_glx_ensure_context(
GstVaapiWindow *window,
GLXContext foreign_context
)
_gst_vaapi_window_glx_ensure_context (GstVaapiWindow * window,
GLXContext foreign_context)
{
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
GstVaapiWindowGLXPrivate *const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
if (priv->gl_context) {
if (!foreign_context || foreign_context == priv->gl_context->context)
return TRUE;
_gst_vaapi_window_glx_destroy_context(window);
}
return _gst_vaapi_window_glx_create_context(window, foreign_context);
if (priv->gl_context) {
if (!foreign_context || foreign_context == priv->gl_context->context)
return TRUE;
_gst_vaapi_window_glx_destroy_context (window);
}
return _gst_vaapi_window_glx_create_context (window, foreign_context);
}
static gboolean
gst_vaapi_window_glx_ensure_context(
GstVaapiWindow *window,
GLXContext foreign_context
)
gst_vaapi_window_glx_ensure_context (GstVaapiWindow * window,
GLXContext foreign_context)
{
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
GLContextState old_cs;
guint width, height;
GstVaapiWindowGLXPrivate *const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
GLContextState old_cs;
guint width, height;
if (!_gst_vaapi_window_glx_ensure_context(window, foreign_context))
return FALSE;
if (!_gst_vaapi_window_glx_ensure_context (window, foreign_context))
return FALSE;
priv->gl_context->window = GST_VAAPI_OBJECT_ID(window);
if (!gl_set_current_context(priv->gl_context, &old_cs)) {
GST_DEBUG("could not make newly created GLX context current");
return FALSE;
}
priv->gl_context->window = GST_VAAPI_OBJECT_ID (window);
if (!gl_set_current_context (priv->gl_context, &old_cs)) {
GST_DEBUG ("could not make newly created GLX context current");
return FALSE;
}
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_CULL_FACE);
glDrawBuffer(GL_BACK);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable (GL_DEPTH_TEST);
glDepthMask (GL_FALSE);
glDisable (GL_CULL_FACE);
glDrawBuffer (GL_BACK);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gst_vaapi_window_get_size(window, &width, &height);
gl_resize(width, height);
gst_vaapi_window_get_size (window, &width, &height);
gl_resize (width, height);
gl_set_bgcolor(0);
glClear(GL_COLOR_BUFFER_BIT);
gl_set_current_context(&old_cs, NULL);
return TRUE;
gl_set_bgcolor (0);
glClear (GL_COLOR_BUFFER_BIT);
gl_set_current_context (&old_cs, NULL);
return TRUE;
}
static Visual *
gst_vaapi_window_glx_get_visual(GstVaapiWindow *window)
gst_vaapi_window_glx_get_visual (GstVaapiWindow * window)
{
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
GstVaapiWindowGLXPrivate *const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
if (!_gst_vaapi_window_glx_ensure_context(window, NULL))
return NULL;
return priv->gl_context->visual->visual;
if (!_gst_vaapi_window_glx_ensure_context (window, NULL))
return NULL;
return priv->gl_context->visual->visual;
}
static void
gst_vaapi_window_glx_destroy_colormap(GstVaapiWindow *window)
gst_vaapi_window_glx_destroy_colormap (GstVaapiWindow * window)
{
GstVaapiWindowGLXPrivate * const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
GstVaapiWindowGLXPrivate *const priv =
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
if (priv->cmap) {
if (!window->use_foreign_window) {
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
XFreeColormap(dpy, priv->cmap);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
}
priv->cmap = None;
if (priv->cmap) {
if (!window->use_foreign_window) {
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
XFreeColormap (dpy, priv->cmap);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
}
priv->cmap = None;
}
}
static Colormap
gst_vaapi_window_glx_create_colormap(GstVaapiWindow *window)
gst_vaapi_window_glx_create_colormap (GstVaapiWindow * window)
{
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;
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 (!window->use_foreign_window) {
if (!_gst_vaapi_window_glx_ensure_context(window, NULL))
return None;
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
x11_trap_errors();
/* XXX: add a GstVaapiDisplayX11:x11-screen property? */
screen = GST_VAAPI_OBJECT_XSCREEN(window);
priv->cmap = XCreateColormap(
dpy,
RootWindow(dpy, screen),
priv->gl_context->visual->visual,
AllocNone
);
success = x11_untrap_errors() == 0;
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
}
else {
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
x11_trap_errors();
XGetWindowAttributes(dpy, GST_VAAPI_OBJECT_ID(window), &wattr);
priv->cmap = wattr.colormap;
success = x11_untrap_errors() == 0;
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
}
if (!success)
return None;
if (!priv->cmap) {
if (!window->use_foreign_window) {
if (!_gst_vaapi_window_glx_ensure_context (window, NULL))
return None;
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
x11_trap_errors ();
/* XXX: add a GstVaapiDisplayX11:x11-screen property? */
screen = GST_VAAPI_OBJECT_XSCREEN (window);
priv->cmap = XCreateColormap (dpy,
RootWindow (dpy, screen),
priv->gl_context->visual->visual, AllocNone);
success = x11_untrap_errors () == 0;
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
} else {
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
x11_trap_errors ();
XGetWindowAttributes (dpy, GST_VAAPI_OBJECT_ID (window), &wattr);
priv->cmap = wattr.colormap;
success = x11_untrap_errors () == 0;
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
}
return priv->cmap;
if (!success)
return None;
}
return priv->cmap;
}
static Colormap
gst_vaapi_window_glx_get_colormap(GstVaapiWindow *window)
gst_vaapi_window_glx_get_colormap (GstVaapiWindow * window)
{
return gst_vaapi_window_glx_create_colormap(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_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;
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 (!klass->parent_resize(window, width, height))
return FALSE;
if (!klass->parent_resize (window, width, height))
return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
XSync(dpy, False); /* make sure resize completed */
if (gl_set_current_context(priv->gl_context, &old_cs)) {
gl_resize(width, height);
gl_set_current_context(&old_cs, NULL);
}
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
return TRUE;
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
XSync (dpy, False); /* make sure resize completed */
if (gl_set_current_context (priv->gl_context, &old_cs)) {
gl_resize (width, height);
gl_set_current_context (&old_cs, NULL);
}
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
return TRUE;
}
static void
gst_vaapi_window_glx_finalize(GstVaapiWindowGLX *window)
gst_vaapi_window_glx_finalize (GstVaapiWindowGLX * window)
{
GstVaapiWindow * const base_window = GST_VAAPI_WINDOW(window);
GstVaapiWindow *const base_window = GST_VAAPI_WINDOW (window);
_gst_vaapi_window_glx_destroy_context(base_window);
gst_vaapi_window_glx_destroy_colormap(base_window);
_gst_vaapi_window_glx_destroy_context (base_window);
gst_vaapi_window_glx_destroy_colormap (base_window);
GST_VAAPI_WINDOW_GLX_GET_CLASS(window)->parent_finalize(
GST_VAAPI_OBJECT(window));
GST_VAAPI_WINDOW_GLX_GET_CLASS (window)->parent_finalize (GST_VAAPI_OBJECT
(window));
}
static void
gst_vaapi_window_glx_class_init(GstVaapiWindowGLXClass *klass)
gst_vaapi_window_glx_class_init (GstVaapiWindowGLXClass * klass)
{
GstVaapiWindowClass * const window_class =
GST_VAAPI_WINDOW_CLASS(klass);
GstVaapiWindowX11Class * const xwindow_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);
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;
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;
}
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
GstVaapiWindowGLX,
gst_vaapi_window_glx,
gst_vaapi_window_glx_class_init(&g_class))
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:
@ -363,24 +344,25 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
* Return value: the newly allocated #GstVaapiWindow object
*/
GstVaapiWindow *
gst_vaapi_window_glx_new(GstVaapiDisplay *display, guint width, guint height)
gst_vaapi_window_glx_new (GstVaapiDisplay * display, guint width, guint height)
{
GstVaapiWindow *window;
GstVaapiWindow *window;
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_GLX(display), NULL);
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_GLX (display), NULL);
window = gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
gst_vaapi_window_glx_class()), display, width, height);
if (!window)
return NULL;
window =
gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS (gst_vaapi_window_glx_class
()), display, width, height);
if (!window)
return NULL;
if (!gst_vaapi_window_glx_ensure_context(window, NULL))
goto error;
return window;
if (!gst_vaapi_window_glx_ensure_context (window, NULL))
goto error;
return window;
error:
gst_vaapi_window_unref(window);
return NULL;
gst_vaapi_window_unref (window);
return NULL;
}
/**
@ -396,27 +378,28 @@ error:
* Return value: the newly allocated #GstVaapiWindow object
*/
GstVaapiWindow *
gst_vaapi_window_glx_new_with_xid(GstVaapiDisplay *display, Window xid)
gst_vaapi_window_glx_new_with_xid (GstVaapiDisplay * display, Window xid)
{
GstVaapiWindow *window;
GstVaapiWindow *window;
GST_DEBUG("new window from xid 0x%08x", (guint)xid);
GST_DEBUG ("new window from xid 0x%08x", (guint) xid);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_GLX(display), NULL);
g_return_val_if_fail(xid != None, NULL);
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_GLX (display), NULL);
g_return_val_if_fail (xid != None, NULL);
window = gst_vaapi_window_new_from_native(GST_VAAPI_WINDOW_CLASS(
gst_vaapi_window_glx_class()), display, GINT_TO_POINTER(xid));
if (!window)
return NULL;
window =
gst_vaapi_window_new_from_native (GST_VAAPI_WINDOW_CLASS
(gst_vaapi_window_glx_class ()), display, GINT_TO_POINTER (xid));
if (!window)
return NULL;
if (!gst_vaapi_window_glx_ensure_context(window, NULL))
goto error;
return window;
if (!gst_vaapi_window_glx_ensure_context (window, NULL))
goto error;
return window;
error:
gst_vaapi_window_unref(window);
return NULL;
gst_vaapi_window_unref (window);
return NULL;
}
/**
@ -428,11 +411,11 @@ error:
* Return value: the #GLXContext bound to the @window
*/
GLXContext
gst_vaapi_window_glx_get_context(GstVaapiWindowGLX *window)
gst_vaapi_window_glx_get_context (GstVaapiWindowGLX * window)
{
g_return_val_if_fail(window != NULL, NULL);
g_return_val_if_fail (window != NULL, NULL);
return GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window)->gl_context->context;
return GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window)->gl_context->context;
}
/**
@ -448,11 +431,11 @@ gst_vaapi_window_glx_get_context(GstVaapiWindowGLX *window)
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_window_glx_set_context(GstVaapiWindowGLX *window, GLXContext ctx)
gst_vaapi_window_glx_set_context (GstVaapiWindowGLX * window, GLXContext ctx)
{
g_return_val_if_fail(window != NULL, FALSE);
g_return_val_if_fail (window != NULL, FALSE);
return gst_vaapi_window_glx_ensure_context(GST_VAAPI_WINDOW(window), ctx);
return gst_vaapi_window_glx_ensure_context (GST_VAAPI_WINDOW (window), ctx);
}
/**
@ -466,16 +449,16 @@ gst_vaapi_window_glx_set_context(GstVaapiWindowGLX *window, GLXContext ctx)
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_window_glx_make_current(GstVaapiWindowGLX *window)
gst_vaapi_window_glx_make_current (GstVaapiWindowGLX * window)
{
gboolean success;
gboolean success;
g_return_val_if_fail(window != NULL, FALSE);
g_return_val_if_fail (window != NULL, FALSE);
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
success = gl_set_current_context(window->priv.gl_context, NULL);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
return success;
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
success = gl_set_current_context (window->priv.gl_context, NULL);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
return success;
}
/**
@ -487,13 +470,13 @@ gst_vaapi_window_glx_make_current(GstVaapiWindowGLX *window)
* around glXSwapBuffers().
*/
void
gst_vaapi_window_glx_swap_buffers(GstVaapiWindowGLX *window)
gst_vaapi_window_glx_swap_buffers (GstVaapiWindowGLX * window)
{
g_return_if_fail(window != NULL);
g_return_if_fail (window != NULL);
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
gl_swap_buffers(window->priv.gl_context);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
gl_swap_buffers (window->priv.gl_context);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
}
/**
@ -514,57 +497,59 @@ gst_vaapi_window_glx_swap_buffers(GstVaapiWindowGLX *window)
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_window_glx_put_texture(
GstVaapiWindowGLX *window,
GstVaapiTexture *texture,
const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect
)
gst_vaapi_window_glx_put_texture (GstVaapiWindowGLX * window,
GstVaapiTexture * texture,
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect)
{
GstVaapiRectangle tmp_src_rect, tmp_dst_rect;
GLTextureState ts;
GLenum tex_target;
GLuint tex_id;
guint tex_width, tex_height;
guint win_width, win_height;
GstVaapiRectangle tmp_src_rect, tmp_dst_rect;
GLTextureState ts;
GLenum tex_target;
GLuint tex_id;
guint tex_width, tex_height;
guint win_width, win_height;
g_return_val_if_fail(window != NULL, FALSE);
g_return_val_if_fail(texture != NULL, FALSE);
g_return_val_if_fail (window != NULL, 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);
src_rect = &tmp_src_rect;
gst_vaapi_texture_get_size (texture, &tex_width, &tex_height);
fill_rect (&tmp_src_rect, src_rect, tex_width, tex_height);
src_rect = &tmp_src_rect;
gst_vaapi_window_get_size(GST_VAAPI_WINDOW(window), &win_width, &win_height);
fill_rect(&tmp_dst_rect, dst_rect, win_width, win_height);
dst_rect = &tmp_dst_rect;
gst_vaapi_window_get_size (GST_VAAPI_WINDOW (window), &win_width,
&win_height);
fill_rect (&tmp_dst_rect, dst_rect, win_width, win_height);
dst_rect = &tmp_dst_rect;
/* XXX: only GL_TEXTURE_2D textures are supported at this time */
tex_target = gst_vaapi_texture_get_target(texture);
if (tex_target != GL_TEXTURE_2D)
return FALSE;
/* XXX: only GL_TEXTURE_2D textures are supported at this time */
tex_target = gst_vaapi_texture_get_target (texture);
if (tex_target != GL_TEXTURE_2D)
return FALSE;
tex_id = gst_vaapi_texture_get_id(texture);
if (!gl_bind_texture(&ts, tex_target, tex_id))
return FALSE;
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glPushMatrix();
glTranslatef((GLfloat)dst_rect->x, (GLfloat)dst_rect->y, 0.0f);
glBegin(GL_QUADS);
{
const float tx1 = (float)src_rect->x / tex_width;
const float tx2 = (float)(src_rect->x + src_rect->width) / tex_width;
const float ty1 = (float)src_rect->y / tex_height;
const float ty2 = (float)(src_rect->y + src_rect->height) / tex_height;
const guint w = dst_rect->width;
const guint h = dst_rect->height;
glTexCoord2f(tx1, ty1); glVertex2i(0, 0);
glTexCoord2f(tx1, ty2); glVertex2i(0, h);
glTexCoord2f(tx2, ty2); glVertex2i(w, h);
glTexCoord2f(tx2, ty1); glVertex2i(w, 0);
}
glEnd();
glPopMatrix();
gl_unbind_texture(&ts);
return TRUE;
tex_id = gst_vaapi_texture_get_id (texture);
if (!gl_bind_texture (&ts, tex_target, tex_id))
return FALSE;
glColor4f (1.0f, 1.0f, 1.0f, 1.0f);
glPushMatrix ();
glTranslatef ((GLfloat) dst_rect->x, (GLfloat) dst_rect->y, 0.0f);
glBegin (GL_QUADS);
{
const float tx1 = (float) src_rect->x / tex_width;
const float tx2 = (float) (src_rect->x + src_rect->width) / tex_width;
const float ty1 = (float) src_rect->y / tex_height;
const float ty2 = (float) (src_rect->y + src_rect->height) / tex_height;
const guint w = dst_rect->width;
const guint h = dst_rect->height;
glTexCoord2f (tx1, ty1);
glVertex2i (0, 0);
glTexCoord2f (tx1, ty2);
glVertex2i (0, h);
glTexCoord2f (tx2, ty2);
glVertex2i (w, h);
glTexCoord2f (tx2, ty1);
glVertex2i (w, 0);
}
glEnd ();
glPopMatrix ();
gl_unbind_texture (&ts);
return TRUE;
}

View file

@ -35,33 +35,30 @@ G_BEGIN_DECLS
#define GST_VAAPI_WINDOW_GLX(obj) \
((GstVaapiWindowGLX *)(obj))
typedef struct _GstVaapiWindowGLX GstVaapiWindowGLX;
typedef struct _GstVaapiWindowGLX GstVaapiWindowGLX;
GstVaapiWindow *
gst_vaapi_window_glx_new(GstVaapiDisplay *display, guint width, guint height);
gst_vaapi_window_glx_new (GstVaapiDisplay * display, guint width, guint height);
GstVaapiWindow *
gst_vaapi_window_glx_new_with_xid(GstVaapiDisplay *display, Window xid);
gst_vaapi_window_glx_new_with_xid (GstVaapiDisplay * display, Window xid);
GLXContext
gst_vaapi_window_glx_get_context(GstVaapiWindowGLX *window);
gst_vaapi_window_glx_get_context (GstVaapiWindowGLX * window);
gboolean
gst_vaapi_window_glx_set_context(GstVaapiWindowGLX *window, GLXContext ctx);
gst_vaapi_window_glx_set_context (GstVaapiWindowGLX * window, GLXContext ctx);
gboolean
gst_vaapi_window_glx_make_current(GstVaapiWindowGLX *window);
gst_vaapi_window_glx_make_current (GstVaapiWindowGLX * window);
void
gst_vaapi_window_glx_swap_buffers(GstVaapiWindowGLX *window);
gst_vaapi_window_glx_swap_buffers (GstVaapiWindowGLX * window);
gboolean
gst_vaapi_window_glx_put_texture(
GstVaapiWindowGLX *window,
GstVaapiTexture *texture,
const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect
);
gst_vaapi_window_glx_put_texture (GstVaapiWindowGLX * window,
GstVaapiTexture * texture, const GstVaapiRectangle * src_rect,
const GstVaapiRectangle * dst_rect);
G_END_DECLS

View file

@ -36,40 +36,41 @@ G_BEGIN_DECLS
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,
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,
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);
typedef gboolean (*GstVaapiWindowRenderPixmapFunc)(GstVaapiWindow *window,
GstVaapiPixmap *pixmap, const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect);
typedef gboolean (*GstVaapiWindowRenderFunc) (GstVaapiWindow * window,
GstVaapiSurface * surface, const GstVaapiRectangle * src_rect,
const GstVaapiRectangle * dst_rect, guint flags);
typedef gboolean (*GstVaapiWindowRenderPixmapFunc) (GstVaapiWindow * window,
GstVaapiPixmap * pixmap, const GstVaapiRectangle * src_rect,
const GstVaapiRectangle * dst_rect);
/**
* GstVaapiWindow:
*
* Base class for system-dependent windows.
*/
struct _GstVaapiWindow {
/*< private >*/
GstVaapiObject parent_instance;
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;
/*< protected >*/
guint width;
guint height;
guint display_width;
guint display_height;
guint use_foreign_window:1;
guint is_fullscreen:1;
guint check_geometry:1;
};
/**
@ -84,28 +85,29 @@ struct _GstVaapiWindow {
*
* Base class for system-dependent windows.
*/
struct _GstVaapiWindowClass {
/*< private >*/
GstVaapiObjectClass parent_class;
struct _GstVaapiWindowClass
{
/*< private >*/
GstVaapiObjectClass parent_class;
/*< protected >*/
GstVaapiWindowCreateFunc create;
GstVaapiWindowShowFunc show;
GstVaapiWindowHideFunc hide;
GstVaapiWindowGetGeometryFunc get_geometry;
GstVaapiWindowSetFullscreenFunc set_fullscreen;
GstVaapiWindowResizeFunc resize;
GstVaapiWindowRenderFunc render;
GstVaapiWindowRenderPixmapFunc render_pixmap;
/*< protected >*/
GstVaapiWindowCreateFunc create;
GstVaapiWindowShowFunc show;
GstVaapiWindowHideFunc hide;
GstVaapiWindowGetGeometryFunc get_geometry;
GstVaapiWindowSetFullscreenFunc set_fullscreen;
GstVaapiWindowResizeFunc resize;
GstVaapiWindowRenderFunc render;
GstVaapiWindowRenderPixmapFunc render_pixmap;
};
GstVaapiWindow *
gst_vaapi_window_new(const GstVaapiWindowClass *window_class,
GstVaapiDisplay *display, guint width, guint height);
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);
gst_vaapi_window_new_from_native (const GstVaapiWindowClass *
window_class, GstVaapiDisplay * display, gpointer native_window);
/* Inline reference counting for core libgstvaapi library */
#ifdef IN_LIBGSTVAAPI_CORE

View file

@ -46,73 +46,74 @@
#define GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(obj) \
(&GST_VAAPI_WINDOW_WAYLAND_CAST(obj)->priv)
typedef struct _GstVaapiWindowWaylandPrivate GstVaapiWindowWaylandPrivate;
typedef struct _GstVaapiWindowWaylandClass GstVaapiWindowWaylandClass;
typedef struct _FrameState FrameState;
typedef struct _GstVaapiWindowWaylandPrivate GstVaapiWindowWaylandPrivate;
typedef struct _GstVaapiWindowWaylandClass GstVaapiWindowWaylandClass;
typedef struct _FrameState FrameState;
struct _FrameState {
GstVaapiWindow *window;
GstVaapiSurface *surface;
GstVaapiVideoPool *surface_pool;
struct wl_buffer *buffer;
struct wl_callback *callback;
struct _FrameState
{
GstVaapiWindow *window;
GstVaapiSurface *surface;
GstVaapiVideoPool *surface_pool;
struct wl_buffer *buffer;
struct wl_callback *callback;
};
static FrameState *
frame_state_new(GstVaapiWindow *window)
frame_state_new (GstVaapiWindow * window)
{
FrameState *frame;
FrameState *frame;
frame = g_slice_new(FrameState);
if (!frame)
return NULL;
frame = g_slice_new (FrameState);
if (!frame)
return NULL;
frame->window = window;
frame->surface = NULL;
frame->surface_pool = NULL;
frame->buffer = NULL;
frame->callback = NULL;
return frame;
frame->window = window;
frame->surface = NULL;
frame->surface_pool = NULL;
frame->buffer = NULL;
frame->callback = NULL;
return frame;
}
static void
frame_state_free(FrameState *frame)
frame_state_free (FrameState * frame)
{
if (!frame)
return;
if (!frame)
return;
if (frame->surface) {
if (frame->surface_pool)
gst_vaapi_video_pool_put_object(frame->surface_pool,
frame->surface);
frame->surface = NULL;
}
gst_vaapi_video_pool_replace(&frame->surface_pool, NULL);
if (frame->surface) {
if (frame->surface_pool)
gst_vaapi_video_pool_put_object (frame->surface_pool, frame->surface);
frame->surface = NULL;
}
gst_vaapi_video_pool_replace (&frame->surface_pool, NULL);
if (frame->buffer) {
wl_buffer_destroy(frame->buffer);
frame->buffer = NULL;
}
if (frame->buffer) {
wl_buffer_destroy (frame->buffer);
frame->buffer = NULL;
}
if (frame->callback) {
wl_callback_destroy(frame->callback);
frame->callback = NULL;
}
g_slice_free(FrameState, frame);
if (frame->callback) {
wl_callback_destroy (frame->callback);
frame->callback = NULL;
}
g_slice_free (FrameState, frame);
}
struct _GstVaapiWindowWaylandPrivate {
struct wl_shell_surface *shell_surface;
struct wl_surface *surface;
struct wl_region *opaque_region;
struct wl_event_queue *event_queue;
FrameState *frame;
GstVideoFormat surface_format;
GstVaapiVideoPool *surface_pool;
GstVaapiFilter *filter;
guint is_shown : 1;
guint fullscreen_on_show : 1;
guint use_vpp : 1;
struct _GstVaapiWindowWaylandPrivate
{
struct wl_shell_surface *shell_surface;
struct wl_surface *surface;
struct wl_region *opaque_region;
struct wl_event_queue *event_queue;
FrameState *frame;
GstVideoFormat surface_format;
GstVaapiVideoPool *surface_pool;
GstVaapiFilter *filter;
guint is_shown:1;
guint fullscreen_on_show:1;
guint use_vpp:1;
};
/**
@ -120,11 +121,12 @@ struct _GstVaapiWindowWaylandPrivate {
*
* A Wayland window abstraction.
*/
struct _GstVaapiWindowWayland {
/*< private >*/
GstVaapiWindow parent_instance;
struct _GstVaapiWindowWayland
{
/*< private >*/
GstVaapiWindow parent_instance;
GstVaapiWindowWaylandPrivate priv;
GstVaapiWindowWaylandPrivate priv;
};
/**
@ -132,419 +134,394 @@ struct _GstVaapiWindowWayland {
*
* An Wayland #Window wrapper class.
*/
struct _GstVaapiWindowWaylandClass {
/*< private >*/
GstVaapiWindowClass parent_class;
struct _GstVaapiWindowWaylandClass
{
/*< private >*/
GstVaapiWindowClass parent_class;
};
static gboolean
gst_vaapi_window_wayland_show(GstVaapiWindow *window)
gst_vaapi_window_wayland_show (GstVaapiWindow * window)
{
GST_WARNING("unimplemented GstVaapiWindowWayland::show()");
GST_WARNING ("unimplemented GstVaapiWindowWayland::show()");
return TRUE;
return TRUE;
}
static gboolean
gst_vaapi_window_wayland_hide(GstVaapiWindow *window)
gst_vaapi_window_wayland_hide (GstVaapiWindow * window)
{
GST_WARNING("unimplemented GstVaapiWindowWayland::hide()");
GST_WARNING ("unimplemented GstVaapiWindowWayland::hide()");
return TRUE;
return TRUE;
}
static gboolean
gst_vaapi_window_wayland_sync(GstVaapiWindow *window)
gst_vaapi_window_wayland_sync (GstVaapiWindow * window)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
GstVaapiWindowWaylandPrivate *const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
if (priv->frame) {
struct wl_display * const wl_display =
GST_VAAPI_OBJECT_WL_DISPLAY(window);
if (priv->frame) {
struct wl_display *const wl_display = GST_VAAPI_OBJECT_WL_DISPLAY (window);
do {
if (wl_display_dispatch_queue(wl_display, priv->event_queue) < 0)
return FALSE;
} while (priv->frame);
}
return TRUE;
do {
if (wl_display_dispatch_queue (wl_display, priv->event_queue) < 0)
return FALSE;
} while (priv->frame);
}
return TRUE;
}
static void
handle_ping(void *data, struct wl_shell_surface *shell_surface,
uint32_t serial)
handle_ping (void *data, struct wl_shell_surface *shell_surface,
uint32_t serial)
{
wl_shell_surface_pong(shell_surface, serial);
wl_shell_surface_pong (shell_surface, serial);
}
static void
handle_configure(void *data, struct wl_shell_surface *shell_surface,
uint32_t edges, int32_t width, int32_t height)
handle_configure (void *data, struct wl_shell_surface *shell_surface,
uint32_t edges, int32_t width, int32_t height)
{
}
static void
handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
handle_popup_done (void *data, struct wl_shell_surface *shell_surface)
{
}
static const struct wl_shell_surface_listener shell_surface_listener = {
handle_ping,
handle_configure,
handle_popup_done
handle_ping,
handle_configure,
handle_popup_done
};
static gboolean
gst_vaapi_window_wayland_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
gst_vaapi_window_wayland_set_fullscreen (GstVaapiWindow * window,
gboolean fullscreen)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
if (!priv->is_shown) {
priv->fullscreen_on_show = fullscreen;
return TRUE;
}
if (!fullscreen)
wl_shell_surface_set_toplevel(priv->shell_surface);
else {
wl_shell_surface_set_fullscreen(
priv->shell_surface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
0,
NULL
);
}
GstVaapiWindowWaylandPrivate *const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
if (!priv->is_shown) {
priv->fullscreen_on_show = fullscreen;
return TRUE;
}
if (!fullscreen)
wl_shell_surface_set_toplevel (priv->shell_surface);
else {
wl_shell_surface_set_fullscreen (priv->shell_surface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE, 0, NULL);
}
return TRUE;
}
static gboolean
gst_vaapi_window_wayland_create(
GstVaapiWindow *window,
guint *width,
guint *height
)
gst_vaapi_window_wayland_create (GstVaapiWindow * window,
guint * width, guint * height)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
GstVaapiDisplayWaylandPrivate * const priv_display =
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(GST_VAAPI_OBJECT_DISPLAY(window));
GstVaapiWindowWaylandPrivate *const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
GstVaapiDisplayWaylandPrivate *const priv_display =
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (GST_VAAPI_OBJECT_DISPLAY (window));
GST_DEBUG("create window, size %ux%u", *width, *height);
GST_DEBUG ("create window, size %ux%u", *width, *height);
g_return_val_if_fail(priv_display->compositor != NULL, FALSE);
g_return_val_if_fail(priv_display->shell != NULL, FALSE);
g_return_val_if_fail (priv_display->compositor != NULL, FALSE);
g_return_val_if_fail (priv_display->shell != NULL, FALSE);
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
priv->event_queue = wl_display_create_queue(priv_display->wl_display);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
if (!priv->event_queue)
return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
priv->event_queue = wl_display_create_queue (priv_display->wl_display);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
if (!priv->event_queue)
return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
priv->surface = wl_compositor_create_surface(priv_display->compositor);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
if (!priv->surface)
return FALSE;
wl_proxy_set_queue((struct wl_proxy *)priv->surface, priv->event_queue);
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
priv->surface = wl_compositor_create_surface (priv_display->compositor);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
if (!priv->surface)
return FALSE;
wl_proxy_set_queue ((struct wl_proxy *) priv->surface, priv->event_queue);
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
priv->shell_surface =
wl_shell_get_shell_surface(priv_display->shell, priv->surface);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
if (!priv->shell_surface)
return FALSE;
wl_proxy_set_queue((struct wl_proxy *)priv->shell_surface,
priv->event_queue);
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
priv->shell_surface =
wl_shell_get_shell_surface (priv_display->shell, priv->surface);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
if (!priv->shell_surface)
return FALSE;
wl_proxy_set_queue ((struct wl_proxy *) priv->shell_surface,
priv->event_queue);
wl_shell_surface_add_listener(priv->shell_surface,
&shell_surface_listener, priv);
wl_shell_surface_set_toplevel(priv->shell_surface);
wl_shell_surface_add_listener (priv->shell_surface,
&shell_surface_listener, priv);
wl_shell_surface_set_toplevel (priv->shell_surface);
if (priv->fullscreen_on_show)
gst_vaapi_window_wayland_set_fullscreen(window, TRUE);
if (priv->fullscreen_on_show)
gst_vaapi_window_wayland_set_fullscreen (window, TRUE);
priv->surface_format = GST_VIDEO_FORMAT_ENCODED;
priv->use_vpp = GST_VAAPI_DISPLAY_HAS_VPP(GST_VAAPI_OBJECT_DISPLAY(window));
priv->is_shown = TRUE;
priv->surface_format = GST_VIDEO_FORMAT_ENCODED;
priv->use_vpp = GST_VAAPI_DISPLAY_HAS_VPP (GST_VAAPI_OBJECT_DISPLAY (window));
priv->is_shown = TRUE;
return TRUE;
return TRUE;
}
static void
gst_vaapi_window_wayland_destroy(GstVaapiWindow * window)
gst_vaapi_window_wayland_destroy (GstVaapiWindow * window)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
GstVaapiWindowWaylandPrivate *const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
if (priv->frame) {
frame_state_free(priv->frame);
priv->frame = NULL;
}
if (priv->frame) {
frame_state_free (priv->frame);
priv->frame = NULL;
}
if (priv->shell_surface) {
wl_shell_surface_destroy(priv->shell_surface);
priv->shell_surface = NULL;
}
if (priv->shell_surface) {
wl_shell_surface_destroy (priv->shell_surface);
priv->shell_surface = NULL;
}
if (priv->surface) {
wl_surface_destroy(priv->surface);
priv->surface = NULL;
}
if (priv->surface) {
wl_surface_destroy (priv->surface);
priv->surface = NULL;
}
if (priv->event_queue) {
wl_event_queue_destroy(priv->event_queue);
priv->event_queue = NULL;
}
if (priv->event_queue) {
wl_event_queue_destroy (priv->event_queue);
priv->event_queue = NULL;
}
gst_vaapi_filter_replace(&priv->filter, NULL);
gst_vaapi_video_pool_replace(&priv->surface_pool, NULL);
gst_vaapi_filter_replace (&priv->filter, NULL);
gst_vaapi_video_pool_replace (&priv->surface_pool, NULL);
}
static gboolean
gst_vaapi_window_wayland_resize(
GstVaapiWindow * window,
guint width,
guint height
)
gst_vaapi_window_wayland_resize (GstVaapiWindow * window,
guint width, guint height)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
GstVaapiDisplayWaylandPrivate * const priv_display =
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(GST_VAAPI_OBJECT_DISPLAY(window));
GstVaapiWindowWaylandPrivate *const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
GstVaapiDisplayWaylandPrivate *const priv_display =
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (GST_VAAPI_OBJECT_DISPLAY (window));
GST_DEBUG("resize window, new size %ux%u", width, height);
GST_DEBUG ("resize window, new size %ux%u", width, height);
if (priv->opaque_region)
wl_region_destroy(priv->opaque_region);
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
priv->opaque_region = wl_compositor_create_region(priv_display->compositor);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
wl_region_add(priv->opaque_region, 0, 0, width, height);
if (priv->opaque_region)
wl_region_destroy (priv->opaque_region);
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
priv->opaque_region = wl_compositor_create_region (priv_display->compositor);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
wl_region_add (priv->opaque_region, 0, 0, width, height);
return TRUE;
return TRUE;
}
static void
frame_redraw_callback(void *data, struct wl_callback *callback, uint32_t time)
frame_redraw_callback (void *data, struct wl_callback *callback, uint32_t time)
{
FrameState * const frame = data;
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(frame->window);
FrameState *const frame = data;
GstVaapiWindowWaylandPrivate *const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (frame->window);
frame_state_free(frame);
if (priv->frame == frame)
priv->frame = NULL;
frame_state_free (frame);
if (priv->frame == frame)
priv->frame = NULL;
}
static const struct wl_callback_listener frame_callback_listener = {
frame_redraw_callback
frame_redraw_callback
};
static GstVaapiSurface *
vpp_convert(
GstVaapiWindow *window,
GstVaapiSurface *surface,
const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect,
guint flags
)
vpp_convert (GstVaapiWindow * window,
GstVaapiSurface * surface,
const GstVaapiRectangle * src_rect,
const GstVaapiRectangle * dst_rect, guint flags)
{
GstVaapiWindowWaylandPrivate * const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_DISPLAY(window);
GstVaapiSurface *vpp_surface = NULL;
GstVaapiFilterStatus status;
GstVideoInfo vi;
GstVaapiWindowWaylandPrivate *const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (window);
GstVaapiSurface *vpp_surface = NULL;
GstVaapiFilterStatus status;
GstVideoInfo vi;
/* Ensure VA surface pool is created */
/* XXX: optimize the surface format to use. e.g. YUY2 */
if (!priv->surface_pool) {
gst_video_info_set_format(&vi, priv->surface_format,
window->width, window->height);
priv->surface_pool = gst_vaapi_surface_pool_new(display, &vi);
if (!priv->surface_pool)
return NULL;
gst_vaapi_filter_replace(&priv->filter, NULL);
}
/* Ensure VA surface pool is created */
/* XXX: optimize the surface format to use. e.g. YUY2 */
if (!priv->surface_pool) {
gst_video_info_set_format (&vi, priv->surface_format,
window->width, window->height);
priv->surface_pool = gst_vaapi_surface_pool_new (display, &vi);
if (!priv->surface_pool)
return NULL;
gst_vaapi_filter_replace (&priv->filter, NULL);
}
/* Ensure VPP pipeline is built */
if (!priv->filter) {
priv->filter = gst_vaapi_filter_new(display);
if (!priv->filter)
goto error_create_filter;
if (!gst_vaapi_filter_set_format(priv->filter, priv->surface_format))
goto error_unsupported_format;
}
if (!gst_vaapi_filter_set_cropping_rectangle(priv->filter, src_rect))
return NULL;
if (!gst_vaapi_filter_set_target_rectangle(priv->filter, dst_rect))
return NULL;
/* Ensure VPP pipeline is built */
if (!priv->filter) {
priv->filter = gst_vaapi_filter_new (display);
if (!priv->filter)
goto error_create_filter;
if (!gst_vaapi_filter_set_format (priv->filter, priv->surface_format))
goto error_unsupported_format;
}
if (!gst_vaapi_filter_set_cropping_rectangle (priv->filter, src_rect))
return NULL;
if (!gst_vaapi_filter_set_target_rectangle (priv->filter, dst_rect))
return NULL;
/* Post-process the decoded source surface */
vpp_surface = gst_vaapi_video_pool_get_object(priv->surface_pool);
if (!vpp_surface)
return NULL;
/* Post-process the decoded source surface */
vpp_surface = gst_vaapi_video_pool_get_object (priv->surface_pool);
if (!vpp_surface)
return NULL;
status = gst_vaapi_filter_process(priv->filter, surface, vpp_surface,
flags);
if (status != GST_VAAPI_FILTER_STATUS_SUCCESS)
goto error_process_filter;
return vpp_surface;
status = gst_vaapi_filter_process (priv->filter, surface, vpp_surface, flags);
if (status != GST_VAAPI_FILTER_STATUS_SUCCESS)
goto error_process_filter;
return vpp_surface;
/* ERRORS */
/* ERRORS */
error_create_filter:
GST_WARNING("failed to create VPP filter. Disabling");
priv->use_vpp = FALSE;
return NULL;
GST_WARNING ("failed to create VPP filter. Disabling");
priv->use_vpp = FALSE;
return NULL;
error_unsupported_format:
GST_ERROR("unsupported render target format %s",
gst_vaapi_video_format_to_string(priv->surface_format));
priv->use_vpp = FALSE;
return NULL;
GST_ERROR ("unsupported render target format %s",
gst_vaapi_video_format_to_string (priv->surface_format));
priv->use_vpp = FALSE;
return NULL;
error_process_filter:
GST_ERROR("failed to process surface %" GST_VAAPI_ID_FORMAT " (error %d)",
GST_VAAPI_ID_ARGS(GST_VAAPI_OBJECT_ID(surface)), status);
gst_vaapi_video_pool_put_object(priv->surface_pool, vpp_surface);
return NULL;
GST_ERROR ("failed to process surface %" GST_VAAPI_ID_FORMAT " (error %d)",
GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (surface)), status);
gst_vaapi_video_pool_put_object (priv->surface_pool, vpp_surface);
return NULL;
}
static gboolean
gst_vaapi_window_wayland_render(
GstVaapiWindow *window,
GstVaapiSurface *surface,
const GstVaapiRectangle *src_rect,
const GstVaapiRectangle *dst_rect,
guint flags
)
gst_vaapi_window_wayland_render (GstVaapiWindow * window,
GstVaapiSurface * surface,
const GstVaapiRectangle * src_rect,
const GstVaapiRectangle * dst_rect, guint flags)
{
GstVaapiWindowWaylandPrivate * const 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;
FrameState *frame;
guint width, height, va_flags;
VAStatus status;
gboolean need_vpp = FALSE;
GstVaapiWindowWaylandPrivate *const 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;
FrameState *frame;
guint width, height, va_flags;
VAStatus status;
gboolean need_vpp = FALSE;
/* Check that we don't need to crop source VA surface */
gst_vaapi_surface_get_size(surface, &width, &height);
if (src_rect->x != 0 || src_rect->y != 0)
need_vpp = TRUE;
if (src_rect->width != width || src_rect->height != height)
need_vpp = TRUE;
/* Check that we don't need to crop source VA surface */
gst_vaapi_surface_get_size (surface, &width, &height);
if (src_rect->x != 0 || src_rect->y != 0)
need_vpp = TRUE;
if (src_rect->width != width || src_rect->height != height)
need_vpp = TRUE;
/* Check that we don't render to a subregion of this window */
if (dst_rect->x != 0 || dst_rect->y != 0)
need_vpp = TRUE;
if (dst_rect->width != window->width || dst_rect->height != window->height)
need_vpp = TRUE;
/* Check that we don't render to a subregion of this window */
if (dst_rect->x != 0 || dst_rect->y != 0)
need_vpp = TRUE;
if (dst_rect->width != window->width || dst_rect->height != window->height)
need_vpp = TRUE;
/* Try to construct a Wayland buffer from VA surface as is (without VPP) */
if (!need_vpp) {
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
va_flags = from_GstVaapiSurfaceRenderFlags(flags);
status = vaGetSurfaceBufferWl(
GST_VAAPI_DISPLAY_VADISPLAY(display),
GST_VAAPI_OBJECT_ID(surface),
va_flags & (VA_TOP_FIELD|VA_BOTTOM_FIELD),
&buffer
);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
if (status == VA_STATUS_ERROR_FLAG_NOT_SUPPORTED)
need_vpp = TRUE;
else if (!vaapi_check_status(status, "vaGetSurfaceBufferWl()"))
return FALSE;
/* Try to construct a Wayland buffer from VA surface as is (without VPP) */
if (!need_vpp) {
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
va_flags = from_GstVaapiSurfaceRenderFlags (flags);
status = vaGetSurfaceBufferWl (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface),
va_flags & (VA_TOP_FIELD | VA_BOTTOM_FIELD), &buffer);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
if (status == VA_STATUS_ERROR_FLAG_NOT_SUPPORTED)
need_vpp = TRUE;
else if (!vaapi_check_status (status, "vaGetSurfaceBufferWl()"))
return FALSE;
}
/* Try to construct a Wayland buffer with VPP */
if (need_vpp) {
if (priv->use_vpp) {
GstVaapiSurface *const vpp_surface =
vpp_convert (window, surface, src_rect, dst_rect, flags);
if (G_UNLIKELY (!vpp_surface))
need_vpp = FALSE;
else {
surface = vpp_surface;
width = window->width;
height = window->height;
}
}
/* Try to construct a Wayland buffer with VPP */
if (need_vpp) {
if (priv->use_vpp) {
GstVaapiSurface * const vpp_surface =
vpp_convert(window, surface, src_rect, dst_rect, flags);
if (G_UNLIKELY(!vpp_surface))
need_vpp = FALSE;
else {
surface = vpp_surface;
width = window->width;
height = window->height;
}
}
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
status = vaGetSurfaceBufferWl (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface), VA_FRAME_PICTURE, &buffer);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
if (!vaapi_check_status (status, "vaGetSurfaceBufferWl()"))
return FALSE;
}
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
status = vaGetSurfaceBufferWl(
GST_VAAPI_DISPLAY_VADISPLAY(display),
GST_VAAPI_OBJECT_ID(surface),
VA_FRAME_PICTURE,
&buffer
);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
if (!vaapi_check_status(status, "vaGetSurfaceBufferWl()"))
return FALSE;
}
/* Wait for the previous frame to complete redraw */
if (!gst_vaapi_window_wayland_sync (window))
return FALSE;
/* Wait for the previous frame to complete redraw */
if (!gst_vaapi_window_wayland_sync(window))
return FALSE;
frame = frame_state_new (window);
if (!frame)
return FALSE;
priv->frame = frame;
frame = frame_state_new(window);
if (!frame)
return FALSE;
priv->frame = frame;
if (need_vpp && priv->use_vpp) {
frame->surface = surface;
frame->surface_pool = gst_vaapi_video_pool_ref (priv->surface_pool);
}
if (need_vpp && priv->use_vpp) {
frame->surface = surface;
frame->surface_pool = gst_vaapi_video_pool_ref(priv->surface_pool);
}
/* XXX: attach to the specified target rectangle */
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
wl_surface_attach (priv->surface, buffer, 0, 0);
wl_surface_damage (priv->surface, 0, 0, width, height);
/* XXX: attach to the specified target rectangle */
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
wl_surface_attach(priv->surface, buffer, 0, 0);
wl_surface_damage(priv->surface, 0, 0, width, height);
if (priv->opaque_region) {
wl_surface_set_opaque_region (priv->surface, priv->opaque_region);
wl_region_destroy (priv->opaque_region);
priv->opaque_region = NULL;
}
if (priv->opaque_region) {
wl_surface_set_opaque_region(priv->surface, priv->opaque_region);
wl_region_destroy(priv->opaque_region);
priv->opaque_region = NULL;
}
frame->buffer = buffer;
frame->callback = wl_surface_frame (priv->surface);
wl_callback_add_listener (frame->callback, &frame_callback_listener, frame);
frame->buffer = buffer;
frame->callback = wl_surface_frame(priv->surface);
wl_callback_add_listener(frame->callback, &frame_callback_listener, frame);
wl_surface_commit(priv->surface);
wl_display_flush(wl_display);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
return TRUE;
wl_surface_commit (priv->surface);
wl_display_flush (wl_display);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
return TRUE;
}
static void
gst_vaapi_window_wayland_class_init(GstVaapiWindowWaylandClass * klass)
gst_vaapi_window_wayland_class_init (GstVaapiWindowWaylandClass * klass)
{
GstVaapiObjectClass * const object_class = GST_VAAPI_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);
object_class->finalize = (GstVaapiObjectFinalizeFunc)
gst_vaapi_window_wayland_destroy;
object_class->finalize = (GstVaapiObjectFinalizeFunc)
gst_vaapi_window_wayland_destroy;
window_class->create = gst_vaapi_window_wayland_create;
window_class->show = gst_vaapi_window_wayland_show;
window_class->hide = gst_vaapi_window_wayland_hide;
window_class->render = gst_vaapi_window_wayland_render;
window_class->resize = gst_vaapi_window_wayland_resize;
window_class->set_fullscreen = gst_vaapi_window_wayland_set_fullscreen;
window_class->create = gst_vaapi_window_wayland_create;
window_class->show = gst_vaapi_window_wayland_show;
window_class->hide = gst_vaapi_window_wayland_hide;
window_class->render = gst_vaapi_window_wayland_render;
window_class->resize = gst_vaapi_window_wayland_resize;
window_class->set_fullscreen = gst_vaapi_window_wayland_set_fullscreen;
}
#define gst_vaapi_window_wayland_finalize \
gst_vaapi_window_wayland_destroy
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
GstVaapiWindowWayland,
gst_vaapi_window_wayland,
gst_vaapi_window_wayland_class_init(&g_class))
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:
@ -559,16 +536,14 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
* Return value: the newly allocated #GstVaapiWindow object
*/
GstVaapiWindow *
gst_vaapi_window_wayland_new(
GstVaapiDisplay *display,
guint width,
guint height
)
gst_vaapi_window_wayland_new (GstVaapiDisplay * display,
guint width, guint height)
{
GST_DEBUG("new window, size %ux%u", width, height);
GST_DEBUG ("new window, size %ux%u", width, height);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_WAYLAND(display), NULL);
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_WAYLAND (display), NULL);
return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
gst_vaapi_window_wayland_class()), display, width, height);
return
gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS
(gst_vaapi_window_wayland_class ()), display, width, height);
}

View file

@ -30,10 +30,11 @@
G_BEGIN_DECLS
typedef struct _GstVaapiWindowWayland GstVaapiWindowWayland;
typedef struct _GstVaapiWindowWayland GstVaapiWindowWayland;
GstVaapiWindow *
gst_vaapi_window_wayland_new(GstVaapiDisplay *display, guint width, guint height);
gst_vaapi_window_wayland_new (GstVaapiDisplay * display, guint width,
guint height);
G_END_DECLS

File diff suppressed because it is too large Load diff

View file

@ -43,19 +43,19 @@ G_BEGIN_DECLS
#define GST_VAAPI_WINDOW_XWINDOW(window) \
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(window))
typedef struct _GstVaapiWindowX11 GstVaapiWindowX11;
typedef struct _GstVaapiWindowX11 GstVaapiWindowX11;
GstVaapiWindow *
gst_vaapi_window_x11_new(GstVaapiDisplay *display, guint width, guint height);
gst_vaapi_window_x11_new (GstVaapiDisplay * display, guint width, guint height);
GstVaapiWindow *
gst_vaapi_window_x11_new_with_xid(GstVaapiDisplay *display, Window xid);
gst_vaapi_window_x11_new_with_xid (GstVaapiDisplay * display, Window xid);
Window
gst_vaapi_window_x11_get_xid(GstVaapiWindowX11 *window);
gst_vaapi_window_x11_get_xid (GstVaapiWindowX11 * window);
gboolean
gst_vaapi_window_x11_is_foreign_xid(GstVaapiWindowX11 *window);
gst_vaapi_window_x11_is_foreign_xid (GstVaapiWindowX11 * window);
G_END_DECLS

View file

@ -42,18 +42,19 @@ G_BEGIN_DECLS
#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;
typedef struct _GstVaapiWindowX11Private GstVaapiWindowX11Private;
typedef struct _GstVaapiWindowX11Class GstVaapiWindowX11Class;
struct _GstVaapiWindowX11Private {
Atom atom_NET_WM_STATE;
Atom atom_NET_WM_STATE_FULLSCREEN;
struct _GstVaapiWindowX11Private
{
Atom atom_NET_WM_STATE;
Atom atom_NET_WM_STATE_FULLSCREEN;
#ifdef HAVE_XRENDER
Picture picture;
Picture picture;
#endif
guint is_mapped : 1;
guint fullscreen_on_map : 1;
guint has_xrender : 1;
guint is_mapped:1;
guint fullscreen_on_map:1;
guint has_xrender:1;
};
/**
@ -61,11 +62,12 @@ struct _GstVaapiWindowX11Private {
*
* An X11 #Window wrapper.
*/
struct _GstVaapiWindowX11 {
/*< private >*/
GstVaapiWindow parent_instance;
struct _GstVaapiWindowX11
{
/*< private >*/
GstVaapiWindow parent_instance;
GstVaapiWindowX11Private priv;
GstVaapiWindowX11Private priv;
};
/**
@ -77,16 +79,17 @@ struct _GstVaapiWindowX11 {
*
* An X11 #Window wrapper class.
*/
struct _GstVaapiWindowX11Class {
/*< private >*/
GstVaapiWindowClass parent_class;
struct _GstVaapiWindowX11Class
{
/*< private >*/
GstVaapiWindowClass parent_class;
Visual * (*get_visual) (GstVaapiWindow *window);
Colormap (*get_colormap) (GstVaapiWindow *window);
Visual *(*get_visual) (GstVaapiWindow * window);
Colormap (*get_colormap) (GstVaapiWindow * window);
};
void
gst_vaapi_window_x11_class_init(GstVaapiWindowX11Class *klass);
gst_vaapi_window_x11_class_init (GstVaapiWindowX11Class * klass);
G_END_DECLS