#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
- );
-
- 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;
+ 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 (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;
}
/**
* 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);
}
/**
* 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);
}
/**
* 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);
}
/**
* 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);
}
/**
* 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;
}
/**
* 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);
}
/**
* 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;
}
/**
* 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;
+ }
}
/**
* 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;
}
/**
* 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;
}
/**
* 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);
}
/**
* 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);
}
/**
* 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;
}
/**
* 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;
}
/**
* 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;
-
- 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;
-
- 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);
+ 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);
+
+ 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 (!dst_rect) {
+ dst_rect = &dst_rect_default;
+ get_window_rect (window, &dst_rect_default);
+ }
+ return klass->render_pixmap (window, pixmap, src_rect, dst_rect);
}
#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
#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;
};
/**
*
* 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);
-
- 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;
+ 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_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:
* 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);
}
#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
#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;
};
/**
*
* An X11 #Window suitable for GLX rendering.
*/
-struct _GstVaapiWindowGLX {
- /*< private >*/
- GstVaapiWindowX11 parent_instance;
+struct _GstVaapiWindowGLX
+{
+ /*< private >*/
+ GstVaapiWindowX11 parent_instance;
- GstVaapiWindowGLXPrivate priv;
+ GstVaapiWindowGLXPrivate priv;
};
/**
*
* 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;
-
- 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;
- }
+ 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;
+
+ 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);
-
- 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);
+ 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);
}
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;
-
- 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;
- }
-
- 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);
-
- gl_set_bgcolor(0);
- glClear(GL_COLOR_BUFFER_BIT);
- gl_set_current_context(&old_cs, NULL);
- return TRUE;
+ 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;
+
+ 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);
+
+ 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;
}
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);
-
- 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;
+ 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;
+ }
}
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;
-
- 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;
+ 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);
}
- 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;
-
- 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;
+ 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;
+
+ 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);
-
- 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;
+ 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_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:
* 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;
}
/**
* 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;
}
/**
* 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;
}
/**
* 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);
}
/**
* 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;
}
/**
* 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);
}
/**
* 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;
-
- 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_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;
-
- 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;
+ 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);
+
+ 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;
+
+ /* 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;
}
#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
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;
-
- /*< protected >*/
- guint width;
- guint height;
- guint display_width;
- guint display_height;
- guint use_foreign_window : 1;
- guint is_fullscreen : 1;
- guint check_geometry : 1;
+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;
};
/**
*
* 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;
- GstVaapiWindowRenderPixmapFunc render_pixmap;
+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;
};
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
#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;
-
-struct _FrameState {
- GstVaapiWindow *window;
- GstVaapiSurface *surface;
- GstVaapiVideoPool *surface_pool;
- struct wl_buffer *buffer;
- struct wl_callback *callback;
+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;
};
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->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)
+ return;
- if (frame->buffer) {
- wl_buffer_destroy(frame->buffer);
- frame->buffer = 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->callback) {
- wl_callback_destroy(frame->callback);
- frame->callback = NULL;
- }
- g_slice_free(FrameState, frame);
+ 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);
}
-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;
};
/**
*
* A Wayland window abstraction.
*/
-struct _GstVaapiWindowWayland {
- /*< private >*/
- GstVaapiWindow parent_instance;
+struct _GstVaapiWindowWayland
+{
+ /*< private >*/
+ GstVaapiWindow parent_instance;
- GstVaapiWindowWaylandPrivate priv;
+ GstVaapiWindowWaylandPrivate priv;
};
/**
*
* 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);
+ GstVaapiWindowWaylandPrivate *const priv =
+ GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
- if (!priv->is_shown) {
- priv->fullscreen_on_show = fullscreen;
- return TRUE;
- }
+ 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
- );
- }
+ 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;
+ 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));
-
- 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);
-
- 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->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);
-
- 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;
-
- return TRUE;
+ 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);
+
+ 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->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);
+
+ 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);
+
+ 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;
}
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);
-
- 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->surface) {
- wl_surface_destroy(priv->surface);
- priv->surface = 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);
+ GstVaapiWindowWaylandPrivate *const priv =
+ GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
+
+ 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->surface) {
+ wl_surface_destroy (priv->surface);
+ priv->surface = 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);
}
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;
-
- /* 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);
- }
+ 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 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;
-
- 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 */
-error_create_filter:
- GST_WARNING("failed to create VPP filter. Disabling");
- priv->use_vpp = FALSE;
+ /* 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;
+
+ /* ERRORS */
+error_create_filter:
+ 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;
-
- /* 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;
-
- /* 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;
+ 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 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 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;
- }
-
- /* 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;
-
- 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);
-
- 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);
-
- wl_surface_commit(priv->surface);
- wl_display_flush(wl_display);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- return TRUE;
+ 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;
+
+ 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);
+ }
+
+ /* 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;
+ }
+
+ 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;
}
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);
-
- 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;
+ 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;
+
+ 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:
* 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);
}
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
#define DEBUG 1
#include "gstvaapidebug.h"
-#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 */
+#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(GstVaapiWindow *window, Atom state, gboolean add)
+send_wmspec_change_state (GstVaapiWindow * window, Atom state, gboolean add)
{
- GstVaapiWindowX11Private * const priv =
- GST_VAAPI_WINDOW_X11_GET_PRIVATE(window);
- Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
- XClientMessageEvent xclient;
-
- memset(&xclient, 0, sizeof(xclient));
-
- xclient.type = ClientMessage;
- xclient.window = GST_VAAPI_OBJECT_ID(window);
- xclient.message_type = priv->atom_NET_WM_STATE;
- xclient.format = 32;
-
- xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
- xclient.data.l[1] = state;
- xclient.data.l[2] = 0;
- xclient.data.l[3] = 0;
- xclient.data.l[4] = 0;
-
- XSendEvent(
- dpy,
- DefaultRootWindow(dpy),
- False,
- SubstructureRedirectMask|SubstructureNotifyMask,
- (XEvent *)&xclient
- );
+ GstVaapiWindowX11Private *const priv =
+ GST_VAAPI_WINDOW_X11_GET_PRIVATE (window);
+ Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
+ XClientMessageEvent xclient;
+
+ memset (&xclient, 0, sizeof (xclient));
+
+ xclient.type = ClientMessage;
+ xclient.window = GST_VAAPI_OBJECT_ID (window);
+ xclient.message_type = priv->atom_NET_WM_STATE;
+ xclient.format = 32;
+
+ xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
+ xclient.data.l[1] = state;
+ xclient.data.l[2] = 0;
+ xclient.data.l[3] = 0;
+ xclient.data.l[4] = 0;
+
+ XSendEvent (dpy,
+ DefaultRootWindow (dpy),
+ False,
+ SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *) & xclient);
}
static void
-wait_event(GstVaapiWindow *window, int type)
+wait_event (GstVaapiWindow * window, int type)
{
- Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
- const Window xid = GST_VAAPI_OBJECT_ID(window);
- XEvent e;
- Bool got_event;
-
- for (;;) {
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- got_event = XCheckTypedWindowEvent(dpy, xid, type, &e);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- if (got_event)
- break;
- g_usleep(10);
- }
+ Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
+ const Window xid = GST_VAAPI_OBJECT_ID (window);
+ XEvent e;
+ Bool got_event;
+
+ for (;;) {
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ got_event = XCheckTypedWindowEvent (dpy, xid, type, &e);
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+ if (got_event)
+ break;
+ g_usleep (10);
+ }
}
static gboolean
-timed_wait_event(GstVaapiWindow *window, int type, guint64 end_time, XEvent *e)
+timed_wait_event (GstVaapiWindow * window, int type, guint64 end_time,
+ XEvent * e)
{
- Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
- const Window xid = GST_VAAPI_OBJECT_ID(window);
- XEvent tmp_event;
- GTimeVal now;
- guint64 now_time;
- Bool got_event;
-
- if (!e)
- e = &tmp_event;
-
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- got_event = XCheckTypedWindowEvent(dpy, xid, type, e);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
+ Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
+ const Window xid = GST_VAAPI_OBJECT_ID (window);
+ XEvent tmp_event;
+ GTimeVal now;
+ guint64 now_time;
+ Bool got_event;
+
+ if (!e)
+ e = &tmp_event;
+
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ got_event = XCheckTypedWindowEvent (dpy, xid, type, e);
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+ if (got_event)
+ return TRUE;
+
+ do {
+ g_usleep (10);
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ got_event = XCheckTypedWindowEvent (dpy, xid, type, e);
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
if (got_event)
- return TRUE;
-
- do {
- g_usleep(10);
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- got_event = XCheckTypedWindowEvent(dpy, xid, type, e);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- if (got_event)
- return TRUE;
- g_get_current_time(&now);
- now_time = (guint64)now.tv_sec * 1000000 + now.tv_usec;
- } while (now_time < end_time);
- return FALSE;
+ return TRUE;
+ g_get_current_time (&now);
+ now_time = (guint64) now.tv_sec * 1000000 + now.tv_usec;
+ } while (now_time < end_time);
+ return FALSE;
}
static gboolean
-gst_vaapi_window_x11_show(GstVaapiWindow *window)
+gst_vaapi_window_x11_show (GstVaapiWindow * window)
{
- 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;
- gboolean has_errors;
-
- if (priv->is_mapped)
- return TRUE;
-
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- x11_trap_errors();
- if (window->use_foreign_window) {
- XGetWindowAttributes(dpy, xid, &wattr);
- if (!(wattr.your_event_mask & StructureNotifyMask))
- XSelectInput(dpy, xid, StructureNotifyMask);
- }
- XMapWindow(dpy, xid);
- has_errors = x11_untrap_errors() != 0;
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
-
- if (!has_errors) {
- wait_event(window, MapNotify);
- if (window->use_foreign_window &&
- !(wattr.your_event_mask & StructureNotifyMask)) {
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- x11_trap_errors();
- XSelectInput(dpy, xid, wattr.your_event_mask);
- has_errors = x11_untrap_errors() != 0;
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- }
- priv->is_mapped = TRUE;
-
- if (priv->fullscreen_on_map)
- gst_vaapi_window_set_fullscreen(window, TRUE);
+ 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;
+ gboolean has_errors;
+
+ if (priv->is_mapped)
+ return TRUE;
+
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ x11_trap_errors ();
+ if (window->use_foreign_window) {
+ XGetWindowAttributes (dpy, xid, &wattr);
+ if (!(wattr.your_event_mask & StructureNotifyMask))
+ XSelectInput (dpy, xid, StructureNotifyMask);
+ }
+ XMapWindow (dpy, xid);
+ has_errors = x11_untrap_errors () != 0;
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+
+ if (!has_errors) {
+ wait_event (window, MapNotify);
+ if (window->use_foreign_window &&
+ !(wattr.your_event_mask & StructureNotifyMask)) {
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ x11_trap_errors ();
+ XSelectInput (dpy, xid, wattr.your_event_mask);
+ has_errors = x11_untrap_errors () != 0;
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
}
- return !has_errors;
+ priv->is_mapped = TRUE;
+
+ if (priv->fullscreen_on_map)
+ gst_vaapi_window_set_fullscreen (window, TRUE);
+ }
+ return !has_errors;
}
static gboolean
-gst_vaapi_window_x11_hide(GstVaapiWindow *window)
+gst_vaapi_window_x11_hide (GstVaapiWindow * window)
{
- 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;
- gboolean has_errors;
-
- if (!priv->is_mapped)
- return TRUE;
-
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- x11_trap_errors();
- if (window->use_foreign_window) {
- XGetWindowAttributes(dpy, xid, &wattr);
- if (!(wattr.your_event_mask & StructureNotifyMask))
- XSelectInput(dpy, xid, StructureNotifyMask);
- }
- XUnmapWindow(dpy, xid);
- has_errors = x11_untrap_errors() != 0;
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
-
- if (!has_errors) {
- wait_event(window, UnmapNotify);
- if (window->use_foreign_window &&
- !(wattr.your_event_mask & StructureNotifyMask)) {
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- x11_trap_errors();
- XSelectInput(dpy, xid, wattr.your_event_mask);
- has_errors = x11_untrap_errors() != 0;
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- }
- priv->is_mapped = FALSE;
+ 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;
+ gboolean has_errors;
+
+ if (!priv->is_mapped)
+ return TRUE;
+
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ x11_trap_errors ();
+ if (window->use_foreign_window) {
+ XGetWindowAttributes (dpy, xid, &wattr);
+ if (!(wattr.your_event_mask & StructureNotifyMask))
+ XSelectInput (dpy, xid, StructureNotifyMask);
+ }
+ XUnmapWindow (dpy, xid);
+ has_errors = x11_untrap_errors () != 0;
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+
+ if (!has_errors) {
+ wait_event (window, UnmapNotify);
+ if (window->use_foreign_window &&
+ !(wattr.your_event_mask & StructureNotifyMask)) {
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ x11_trap_errors ();
+ XSelectInput (dpy, xid, wattr.your_event_mask);
+ has_errors = x11_untrap_errors () != 0;
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
}
- return !has_errors;
+ priv->is_mapped = FALSE;
+ }
+ return !has_errors;
}
static gboolean
-gst_vaapi_window_x11_create(GstVaapiWindow *window, guint *width, guint *height)
+gst_vaapi_window_x11_create (GstVaapiWindow * window, guint * width,
+ guint * height)
{
- 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;
- const GstVaapiWindowX11Class *klass;
- XWindowAttributes wattr;
- Atom atoms[2];
- gboolean ok;
-
- static const char *atom_names[2] = {
- "_NET_WM_STATE",
- "_NET_WM_STATE_FULLSCREEN",
- };
-
- priv->has_xrender = GST_VAAPI_DISPLAY_HAS_XRENDER(
- GST_VAAPI_OBJECT_DISPLAY(window));
-
- if (window->use_foreign_window && xid) {
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- XGetWindowAttributes(dpy, xid, &wattr);
- priv->is_mapped = wattr.map_state == IsViewable;
- ok = x11_get_geometry(dpy, xid, NULL, NULL, width, height, NULL);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- return ok;
- }
-
- klass = GST_VAAPI_WINDOW_X11_GET_CLASS(window);
- if (klass) {
- if (klass->get_visual)
- vis = klass->get_visual(window);
- if (klass->get_colormap)
- cmap = klass->get_colormap(window);
- }
-
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- XInternAtoms(
- dpy,
- (char **)atom_names, G_N_ELEMENTS(atom_names),
- False,
- atoms
- );
- priv->atom_NET_WM_STATE = atoms[0];
- priv->atom_NET_WM_STATE_FULLSCREEN = atoms[1];
-
- xid = x11_create_window(dpy, *width, *height, vis, cmap);
- if (xid)
- XRaiseWindow(dpy, xid);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
-
- GST_DEBUG("xid %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(xid));
- GST_VAAPI_OBJECT_ID(window) = xid;
- return xid != None;
+ 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;
+ const GstVaapiWindowX11Class *klass;
+ XWindowAttributes wattr;
+ Atom atoms[2];
+ gboolean ok;
+
+ static const char *atom_names[2] = {
+ "_NET_WM_STATE",
+ "_NET_WM_STATE_FULLSCREEN",
+ };
+
+ priv->has_xrender =
+ GST_VAAPI_DISPLAY_HAS_XRENDER (GST_VAAPI_OBJECT_DISPLAY (window));
+
+ if (window->use_foreign_window && xid) {
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ XGetWindowAttributes (dpy, xid, &wattr);
+ priv->is_mapped = wattr.map_state == IsViewable;
+ ok = x11_get_geometry (dpy, xid, NULL, NULL, width, height, NULL);
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+ return ok;
+ }
+
+ klass = GST_VAAPI_WINDOW_X11_GET_CLASS (window);
+ if (klass) {
+ if (klass->get_visual)
+ vis = klass->get_visual (window);
+ if (klass->get_colormap)
+ cmap = klass->get_colormap (window);
+ }
+
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ XInternAtoms (dpy,
+ (char **) atom_names, G_N_ELEMENTS (atom_names), False, atoms);
+ priv->atom_NET_WM_STATE = atoms[0];
+ priv->atom_NET_WM_STATE_FULLSCREEN = atoms[1];
+
+ xid = x11_create_window (dpy, *width, *height, vis, cmap);
+ if (xid)
+ XRaiseWindow (dpy, xid);
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+
+ GST_DEBUG ("xid %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (xid));
+ GST_VAAPI_OBJECT_ID (window) = xid;
+ return xid != None;
}
static void
-gst_vaapi_window_x11_destroy(GstVaapiWindow *window)
+gst_vaapi_window_x11_destroy (GstVaapiWindow * window)
{
- Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
- const Window xid = GST_VAAPI_OBJECT_ID(window);
+ Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
+ const Window xid = GST_VAAPI_OBJECT_ID (window);
#ifdef HAVE_XRENDER
- GstVaapiWindowX11Private * const priv =
- GST_VAAPI_WINDOW_X11_GET_PRIVATE(window);
- if (priv->picture) {
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- XRenderFreePicture(dpy, priv->picture);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- priv->picture = None;
- }
+ GstVaapiWindowX11Private *const priv =
+ GST_VAAPI_WINDOW_X11_GET_PRIVATE (window);
+ if (priv->picture) {
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ XRenderFreePicture (dpy, priv->picture);
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+ priv->picture = None;
+ }
#endif
- if (xid) {
- if (!window->use_foreign_window) {
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- XDestroyWindow(dpy, xid);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- }
- GST_VAAPI_OBJECT_ID(window) = None;
+ if (xid) {
+ if (!window->use_foreign_window) {
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ XDestroyWindow (dpy, xid);
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
}
+ GST_VAAPI_OBJECT_ID (window) = None;
+ }
}
static gboolean
-gst_vaapi_window_x11_get_geometry(
- GstVaapiWindow *window,
- gint *px,
- gint *py,
- guint *pwidth,
- guint *pheight)
+gst_vaapi_window_x11_get_geometry (GstVaapiWindow * window,
+ gint * px, gint * py, guint * pwidth, guint * pheight)
{
- Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
- const Window xid = GST_VAAPI_OBJECT_ID(window);
+ Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
+ const Window xid = GST_VAAPI_OBJECT_ID (window);
- return x11_get_geometry(dpy, xid, px, py, pwidth, pheight, NULL);
+ return x11_get_geometry (dpy, xid, px, py, pwidth, pheight, NULL);
}
static gboolean
-gst_vaapi_window_x11_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
+gst_vaapi_window_x11_set_fullscreen (GstVaapiWindow * window,
+ gboolean fullscreen)
{
- 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;
- guint width, height;
- gboolean has_errors;
- GTimeVal now;
- guint64 end_time;
-
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- x11_trap_errors();
- if (fullscreen) {
- if (!priv->is_mapped) {
- priv->fullscreen_on_map = TRUE;
-
- XChangeProperty(
- dpy,
- xid,
- priv->atom_NET_WM_STATE, XA_ATOM, 32,
- PropModeReplace,
- (unsigned char *)&priv->atom_NET_WM_STATE_FULLSCREEN, 1
- );
- }
- else {
- send_wmspec_change_state(
- window,
- priv->atom_NET_WM_STATE_FULLSCREEN,
- TRUE
- );
- }
- }
- else {
- if (!priv->is_mapped) {
- priv->fullscreen_on_map = FALSE;
-
- XDeleteProperty(
- dpy,
- xid,
- priv->atom_NET_WM_STATE
- );
- }
- else {
- send_wmspec_change_state(
- window,
- priv->atom_NET_WM_STATE_FULLSCREEN,
- FALSE
- );
- }
+ 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;
+ guint width, height;
+ gboolean has_errors;
+ GTimeVal now;
+ guint64 end_time;
+
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ x11_trap_errors ();
+ if (fullscreen) {
+ if (!priv->is_mapped) {
+ priv->fullscreen_on_map = TRUE;
+
+ XChangeProperty (dpy,
+ xid,
+ priv->atom_NET_WM_STATE, XA_ATOM, 32,
+ PropModeReplace,
+ (unsigned char *) &priv->atom_NET_WM_STATE_FULLSCREEN, 1);
+ } else {
+ send_wmspec_change_state (window,
+ priv->atom_NET_WM_STATE_FULLSCREEN, TRUE);
}
- XSync(dpy, False);
- has_errors = x11_untrap_errors() != 0;
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- if (has_errors)
- return FALSE;
-
- /* Try to wait for the completion of the fullscreen mode switch */
- 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);
- while (timed_wait_event(window, ConfigureNotify, end_time, &e)) {
- if (fullscreen) {
- gst_vaapi_display_get_size(
- GST_VAAPI_OBJECT_DISPLAY(window),
- &width,
- &height
- );
- if (e.xconfigure.width == width && e.xconfigure.height == height)
- return TRUE;
- }
- else {
- gst_vaapi_window_get_size(window, &width, &height);
- if (e.xconfigure.width != width || e.xconfigure.height != height)
- return TRUE;
- }
- }
+ } else {
+ if (!priv->is_mapped) {
+ priv->fullscreen_on_map = FALSE;
+
+ XDeleteProperty (dpy, xid, priv->atom_NET_WM_STATE);
+ } else {
+ send_wmspec_change_state (window,
+ priv->atom_NET_WM_STATE_FULLSCREEN, FALSE);
}
+ }
+ XSync (dpy, False);
+ has_errors = x11_untrap_errors () != 0;
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+ if (has_errors)
return FALSE;
+
+ /* Try to wait for the completion of the fullscreen mode switch */
+ 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);
+ while (timed_wait_event (window, ConfigureNotify, end_time, &e)) {
+ if (fullscreen) {
+ gst_vaapi_display_get_size (GST_VAAPI_OBJECT_DISPLAY (window),
+ &width, &height);
+ if (e.xconfigure.width == width && e.xconfigure.height == height)
+ return TRUE;
+ } else {
+ gst_vaapi_window_get_size (window, &width, &height);
+ if (e.xconfigure.width != width || e.xconfigure.height != height)
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
}
static gboolean
-gst_vaapi_window_x11_resize(GstVaapiWindow *window, guint width, guint height)
+gst_vaapi_window_x11_resize (GstVaapiWindow * window, guint width, guint height)
{
- gboolean has_errors;
-
- if (!GST_VAAPI_OBJECT_ID(window))
- return FALSE;
-
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- x11_trap_errors();
- XResizeWindow(
- GST_VAAPI_OBJECT_XDISPLAY(window),
- GST_VAAPI_OBJECT_ID(window),
- width,
- height
- );
- has_errors = x11_untrap_errors() != 0;
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- return !has_errors;
+ gboolean has_errors;
+
+ if (!GST_VAAPI_OBJECT_ID (window))
+ return FALSE;
+
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ x11_trap_errors ();
+ XResizeWindow (GST_VAAPI_OBJECT_XDISPLAY (window),
+ GST_VAAPI_OBJECT_ID (window), width, height);
+ has_errors = x11_untrap_errors () != 0;
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+ return !has_errors;
}
static gboolean
-gst_vaapi_window_x11_render(
- GstVaapiWindow *window,
- GstVaapiSurface *surface,
- const GstVaapiRectangle *src_rect,
- const GstVaapiRectangle *dst_rect,
- guint flags
-)
+gst_vaapi_window_x11_render (GstVaapiWindow * window,
+ GstVaapiSurface * surface,
+ const GstVaapiRectangle * src_rect,
+ const GstVaapiRectangle * dst_rect, guint flags)
{
- VASurfaceID surface_id;
- VAStatus status;
-
- surface_id = GST_VAAPI_OBJECT_ID(surface);
- if (surface_id == VA_INVALID_ID)
- return FALSE;
-
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- status = vaPutSurface(
- GST_VAAPI_OBJECT_VADISPLAY(window),
- surface_id,
- GST_VAAPI_OBJECT_ID(window),
- src_rect->x,
- src_rect->y,
- src_rect->width,
- src_rect->height,
- dst_rect->x,
- dst_rect->y,
- dst_rect->width,
- dst_rect->height,
- NULL, 0,
- from_GstVaapiSurfaceRenderFlags(flags)
- );
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- if (!vaapi_check_status(status, "vaPutSurface()"))
- return FALSE;
+ VASurfaceID surface_id;
+ VAStatus status;
- return TRUE;
+ surface_id = GST_VAAPI_OBJECT_ID (surface);
+ if (surface_id == VA_INVALID_ID)
+ return FALSE;
+
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ status = vaPutSurface (GST_VAAPI_OBJECT_VADISPLAY (window),
+ surface_id,
+ GST_VAAPI_OBJECT_ID (window),
+ src_rect->x,
+ src_rect->y,
+ src_rect->width,
+ src_rect->height,
+ dst_rect->x,
+ dst_rect->y,
+ dst_rect->width,
+ dst_rect->height, NULL, 0, from_GstVaapiSurfaceRenderFlags (flags)
+ );
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+ if (!vaapi_check_status (status, "vaPutSurface()"))
+ return FALSE;
+
+ return TRUE;
}
static gboolean
-gst_vaapi_window_x11_render_pixmap_xrender(
- GstVaapiWindow *window,
- GstVaapiPixmap *pixmap,
- const GstVaapiRectangle *src_rect,
- const GstVaapiRectangle *dst_rect
-)
+gst_vaapi_window_x11_render_pixmap_xrender (GstVaapiWindow * window,
+ GstVaapiPixmap * pixmap,
+ const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect)
{
#ifdef HAVE_XRENDER
- GstVaapiWindowX11Private * const priv =
- GST_VAAPI_WINDOW_X11_GET_PRIVATE(window);
- Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
- const Window win = GST_VAAPI_OBJECT_ID(window);
- const Pixmap pix = GST_VAAPI_OBJECT_ID(pixmap);
- Picture picture;
- XRenderPictFormat *pic_fmt;
- XWindowAttributes wattr;
- int fmt, op;
- gboolean success = FALSE;
-
- /* Ensure Picture for window is created */
- if (!priv->picture) {
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- XGetWindowAttributes(dpy, win, &wattr);
- pic_fmt = XRenderFindVisualFormat(dpy, wattr.visual);
- if (pic_fmt)
- priv->picture = XRenderCreatePicture(dpy, win, pic_fmt, 0, NULL);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- if (!priv->picture)
- return FALSE;
- }
-
- /* Check pixmap format */
- switch (GST_VAAPI_PIXMAP_FORMAT(pixmap)) {
+ GstVaapiWindowX11Private *const priv =
+ GST_VAAPI_WINDOW_X11_GET_PRIVATE (window);
+ Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
+ const Window win = GST_VAAPI_OBJECT_ID (window);
+ const Pixmap pix = GST_VAAPI_OBJECT_ID (pixmap);
+ Picture picture;
+ XRenderPictFormat *pic_fmt;
+ XWindowAttributes wattr;
+ int fmt, op;
+ gboolean success = FALSE;
+
+ /* Ensure Picture for window is created */
+ if (!priv->picture) {
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ XGetWindowAttributes (dpy, win, &wattr);
+ pic_fmt = XRenderFindVisualFormat (dpy, wattr.visual);
+ if (pic_fmt)
+ priv->picture = XRenderCreatePicture (dpy, win, pic_fmt, 0, NULL);
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+ if (!priv->picture)
+ return FALSE;
+ }
+
+ /* Check pixmap format */
+ switch (GST_VAAPI_PIXMAP_FORMAT (pixmap)) {
case GST_VIDEO_FORMAT_xRGB:
- fmt = PictStandardRGB24;
- op = PictOpSrc;
- goto get_pic_fmt;
+ fmt = PictStandardRGB24;
+ op = PictOpSrc;
+ goto get_pic_fmt;
case GST_VIDEO_FORMAT_ARGB:
- fmt = PictStandardARGB32;
- op = PictOpOver;
+ fmt = PictStandardARGB32;
+ op = PictOpOver;
get_pic_fmt:
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- pic_fmt = XRenderFindStandardFormat(dpy, fmt);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- break;
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ pic_fmt = XRenderFindStandardFormat (dpy, fmt);
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+ break;
default:
- pic_fmt = NULL;
- break;
- }
- if (!pic_fmt)
- return FALSE;
-
- GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
- do {
- const double sx = (double)src_rect->width / dst_rect->width;
- const double sy = (double)src_rect->height / dst_rect->height;
- XTransform xform;
-
- picture = XRenderCreatePicture(dpy, pix, pic_fmt, 0, NULL);
- if (!picture)
- break;
-
- xform.matrix[0][0] = XDoubleToFixed(sx);
- xform.matrix[0][1] = XDoubleToFixed(0.0);
- xform.matrix[0][2] = XDoubleToFixed(src_rect->x);
- xform.matrix[1][0] = XDoubleToFixed(0.0);
- xform.matrix[1][1] = XDoubleToFixed(sy);
- xform.matrix[1][2] = XDoubleToFixed(src_rect->y);
- xform.matrix[2][0] = XDoubleToFixed(0.0);
- xform.matrix[2][1] = XDoubleToFixed(0.0);
- xform.matrix[2][2] = XDoubleToFixed(1.0);
- XRenderSetPictureTransform(dpy, picture, &xform);
-
- XRenderComposite(dpy, op, picture, None, priv->picture,
- 0, 0, 0, 0, dst_rect->x, dst_rect->y,
- dst_rect->width, dst_rect->height);
- XSync(dpy, False);
- success = TRUE;
- } while (0);
- if (picture)
- XRenderFreePicture(dpy, picture);
- GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
- return success;
-#endif
+ pic_fmt = NULL;
+ break;
+ }
+ if (!pic_fmt)
return FALSE;
+
+ GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
+ do {
+ const double sx = (double) src_rect->width / dst_rect->width;
+ const double sy = (double) src_rect->height / dst_rect->height;
+ XTransform xform;
+
+ picture = XRenderCreatePicture (dpy, pix, pic_fmt, 0, NULL);
+ if (!picture)
+ break;
+
+ xform.matrix[0][0] = XDoubleToFixed (sx);
+ xform.matrix[0][1] = XDoubleToFixed (0.0);
+ xform.matrix[0][2] = XDoubleToFixed (src_rect->x);
+ xform.matrix[1][0] = XDoubleToFixed (0.0);
+ xform.matrix[1][1] = XDoubleToFixed (sy);
+ xform.matrix[1][2] = XDoubleToFixed (src_rect->y);
+ xform.matrix[2][0] = XDoubleToFixed (0.0);
+ xform.matrix[2][1] = XDoubleToFixed (0.0);
+ xform.matrix[2][2] = XDoubleToFixed (1.0);
+ XRenderSetPictureTransform (dpy, picture, &xform);
+
+ XRenderComposite (dpy, op, picture, None, priv->picture,
+ 0, 0, 0, 0, dst_rect->x, dst_rect->y,
+ dst_rect->width, dst_rect->height);
+ XSync (dpy, False);
+ success = TRUE;
+ } while (0);
+ if (picture)
+ XRenderFreePicture (dpy, picture);
+ GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
+ return success;
+#endif
+ return FALSE;
}
static gboolean
-gst_vaapi_window_x11_render_pixmap(
- GstVaapiWindow *window,
- GstVaapiPixmap *pixmap,
- const GstVaapiRectangle *src_rect,
- const GstVaapiRectangle *dst_rect
-)
+gst_vaapi_window_x11_render_pixmap (GstVaapiWindow * window,
+ GstVaapiPixmap * pixmap,
+ const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect)
{
- GstVaapiWindowX11Private * const priv =
- GST_VAAPI_WINDOW_X11_GET_PRIVATE(window);
+ GstVaapiWindowX11Private *const priv =
+ GST_VAAPI_WINDOW_X11_GET_PRIVATE (window);
- if (priv->has_xrender)
- return gst_vaapi_window_x11_render_pixmap_xrender(window, pixmap,
- src_rect, dst_rect);
+ if (priv->has_xrender)
+ return gst_vaapi_window_x11_render_pixmap_xrender (window, pixmap,
+ src_rect, dst_rect);
- /* XXX: only X RENDER extension is supported for now */
- return FALSE;
+ /* XXX: only X RENDER extension is supported for now */
+ return FALSE;
}
void
-gst_vaapi_window_x11_class_init(GstVaapiWindowX11Class *klass)
+gst_vaapi_window_x11_class_init (GstVaapiWindowX11Class * 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_x11_destroy;
-
- window_class->create = gst_vaapi_window_x11_create;
- 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;
- window_class->set_fullscreen = gst_vaapi_window_x11_set_fullscreen;
- window_class->resize = gst_vaapi_window_x11_resize;
- window_class->render = gst_vaapi_window_x11_render;
- window_class->render_pixmap = gst_vaapi_window_x11_render_pixmap;
+ 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_x11_destroy;
+
+ window_class->create = gst_vaapi_window_x11_create;
+ 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;
+ window_class->set_fullscreen = gst_vaapi_window_x11_set_fullscreen;
+ window_class->resize = gst_vaapi_window_x11_resize;
+ window_class->render = gst_vaapi_window_x11_render;
+ window_class->render_pixmap = gst_vaapi_window_x11_render_pixmap;
}
#define gst_vaapi_window_x11_finalize \
gst_vaapi_window_x11_destroy
-GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
- GstVaapiWindowX11,
- gst_vaapi_window_x11,
- gst_vaapi_window_x11_class_init(&g_class))
+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:
* Return value: the newly allocated #GstVaapiWindow object
*/
GstVaapiWindow *
-gst_vaapi_window_x11_new(GstVaapiDisplay *display, guint width, guint height)
+gst_vaapi_window_x11_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_X11(display), NULL);
+ g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
- return gst_vaapi_window_new(GST_VAAPI_WINDOW_CLASS(
- gst_vaapi_window_x11_class()), display, width, height);
+ return
+ gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS (gst_vaapi_window_x11_class
+ ()), display, width, height);
}
/**
* Return value: the newly allocated #GstVaapiWindow object
*/
GstVaapiWindow *
-gst_vaapi_window_x11_new_with_xid(GstVaapiDisplay *display, Window xid)
+gst_vaapi_window_x11_new_with_xid (GstVaapiDisplay * display, Window xid)
{
- 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_X11(display), NULL);
- g_return_val_if_fail(xid != None, NULL);
+ g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
+ g_return_val_if_fail (xid != None, NULL);
- return gst_vaapi_window_new_from_native(GST_VAAPI_WINDOW_CLASS(
- gst_vaapi_window_x11_class()), display, GINT_TO_POINTER(xid));
+ return
+ gst_vaapi_window_new_from_native (GST_VAAPI_WINDOW_CLASS
+ (gst_vaapi_window_x11_class ()), display, GINT_TO_POINTER (xid));
}
/**
* Return value: the underlying X11 #Window bound to @window.
*/
Window
-gst_vaapi_window_x11_get_xid(GstVaapiWindowX11 *window)
+gst_vaapi_window_x11_get_xid (GstVaapiWindowX11 * window)
{
- g_return_val_if_fail(window != NULL, None);
+ g_return_val_if_fail (window != NULL, None);
- return GST_VAAPI_OBJECT_ID(window);
+ return GST_VAAPI_OBJECT_ID (window);
}
/**
* caller (foreign window)
*/
gboolean
-gst_vaapi_window_x11_is_foreign_xid(GstVaapiWindowX11 *window)
+gst_vaapi_window_x11_is_foreign_xid (GstVaapiWindowX11 * window)
{
- g_return_val_if_fail(window != NULL, FALSE);
+ g_return_val_if_fail (window != NULL, FALSE);
- return GST_VAAPI_WINDOW(window)->use_foreign_window;
+ return GST_VAAPI_WINDOW (window)->use_foreign_window;
}
#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
#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;
};
/**
*
* An X11 #Window wrapper.
*/
-struct _GstVaapiWindowX11 {
- /*< private >*/
- GstVaapiWindow parent_instance;
+struct _GstVaapiWindowX11
+{
+ /*< private >*/
+ GstVaapiWindow parent_instance;
- GstVaapiWindowX11Private priv;
+ GstVaapiWindowX11Private priv;
};
/**
*
* 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