mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-03 16:09:39 +00:00
window: re-indent all GstVaapiWindow related source code.
This commit is contained in:
parent
7c2c4c7a97
commit
3490212988
12 changed files with 1351 additions and 1464 deletions
|
@ -41,87 +41,82 @@
|
||||||
#undef gst_vaapi_window_replace
|
#undef gst_vaapi_window_replace
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_window_ensure_size(GstVaapiWindow *window)
|
gst_vaapi_window_ensure_size (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
const GstVaapiWindowClass * const klass =
|
const GstVaapiWindowClass *const klass = GST_VAAPI_WINDOW_GET_CLASS (window);
|
||||||
GST_VAAPI_WINDOW_GET_CLASS(window);
|
|
||||||
|
|
||||||
if (!window->check_geometry)
|
if (!window->check_geometry)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (klass->get_geometry)
|
if (klass->get_geometry)
|
||||||
klass->get_geometry(window, NULL, NULL,
|
klass->get_geometry (window, NULL, NULL, &window->width, &window->height);
|
||||||
&window->width, &window->height);
|
|
||||||
|
|
||||||
window->check_geometry = FALSE;
|
window->check_geometry = FALSE;
|
||||||
window->is_fullscreen = (window->width == window->display_width &&
|
window->is_fullscreen = (window->width == window->display_width &&
|
||||||
window->height == window->display_height);
|
window->height == window->display_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
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_display_get_size (GST_VAAPI_OBJECT_DISPLAY (window),
|
||||||
GST_VAAPI_OBJECT_DISPLAY(window),
|
&window->display_width, &window->display_height);
|
||||||
&window->display_width,
|
|
||||||
&window->display_height
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!GST_VAAPI_WINDOW_GET_CLASS(window)->create(window, &width, &height))
|
if (!GST_VAAPI_WINDOW_GET_CLASS (window)->create (window, &width, &height))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (width != window->width || height != window->height) {
|
if (width != window->width || height != window->height) {
|
||||||
GST_DEBUG("backend resized window to %ux%u", width, height);
|
GST_DEBUG ("backend resized window to %ux%u", width, height);
|
||||||
window->width = width;
|
window->width = width;
|
||||||
window->height = height;
|
window->height = height;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_new(const GstVaapiWindowClass *window_class,
|
gst_vaapi_window_new (const GstVaapiWindowClass * window_class,
|
||||||
GstVaapiDisplay *display, guint width, guint height)
|
GstVaapiDisplay * display, guint width, guint height)
|
||||||
{
|
{
|
||||||
GstVaapiWindow *window;
|
GstVaapiWindow *window;
|
||||||
|
|
||||||
g_return_val_if_fail(width > 0, NULL);
|
g_return_val_if_fail (width > 0, NULL);
|
||||||
g_return_val_if_fail(height > 0, NULL);
|
g_return_val_if_fail (height > 0, NULL);
|
||||||
|
|
||||||
window = gst_vaapi_object_new(GST_VAAPI_OBJECT_CLASS(window_class),
|
window = gst_vaapi_object_new (GST_VAAPI_OBJECT_CLASS (window_class),
|
||||||
display);
|
display);
|
||||||
if (!window)
|
if (!window)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_ID(window) = 0;
|
GST_VAAPI_OBJECT_ID (window) = 0;
|
||||||
if (!gst_vaapi_window_create(window, width, height))
|
if (!gst_vaapi_window_create (window, width, height))
|
||||||
goto error;
|
goto error;
|
||||||
return window;
|
return window;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
gst_vaapi_window_unref_internal(window);
|
gst_vaapi_window_unref_internal (window);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_new_from_native(const GstVaapiWindowClass *window_class,
|
gst_vaapi_window_new_from_native (const GstVaapiWindowClass * window_class,
|
||||||
GstVaapiDisplay *display, gpointer native_window)
|
GstVaapiDisplay * display, gpointer native_window)
|
||||||
{
|
{
|
||||||
GstVaapiWindow *window;
|
GstVaapiWindow *window;
|
||||||
|
|
||||||
window = gst_vaapi_object_new(GST_VAAPI_OBJECT_CLASS(window_class),
|
window = gst_vaapi_object_new (GST_VAAPI_OBJECT_CLASS (window_class),
|
||||||
display);
|
display);
|
||||||
if (!window)
|
if (!window)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_ID(window) = GPOINTER_TO_SIZE(native_window);
|
GST_VAAPI_OBJECT_ID (window) = GPOINTER_TO_SIZE (native_window);
|
||||||
window->use_foreign_window = TRUE;
|
window->use_foreign_window = TRUE;
|
||||||
if (!gst_vaapi_window_create(window, 0, 0))
|
if (!gst_vaapi_window_create (window, 0, 0))
|
||||||
goto error;
|
goto error;
|
||||||
return window;
|
return window;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
gst_vaapi_window_unref_internal(window);
|
gst_vaapi_window_unref_internal (window);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,9 +128,9 @@ error:
|
||||||
* Returns: The same @window argument
|
* Returns: The same @window argument
|
||||||
*/
|
*/
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_ref(GstVaapiWindow *window)
|
gst_vaapi_window_ref (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
return gst_vaapi_window_ref_internal(window);
|
return gst_vaapi_window_ref_internal (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,9 +141,9 @@ gst_vaapi_window_ref(GstVaapiWindow *window)
|
||||||
* the reference count reaches zero, the window will be free'd.
|
* the reference count reaches zero, the window will be free'd.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_vaapi_window_unref(GstVaapiWindow *window)
|
gst_vaapi_window_unref (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
gst_vaapi_window_unref_internal(window);
|
gst_vaapi_window_unref_internal (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,10 +156,10 @@ gst_vaapi_window_unref(GstVaapiWindow *window)
|
||||||
* valid window. However, @new_window can be NULL.
|
* valid window. However, @new_window can be NULL.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_vaapi_window_replace(GstVaapiWindow **old_window_ptr,
|
gst_vaapi_window_replace (GstVaapiWindow ** old_window_ptr,
|
||||||
GstVaapiWindow *new_window)
|
GstVaapiWindow * new_window)
|
||||||
{
|
{
|
||||||
gst_vaapi_window_replace_internal(old_window_ptr, new_window);
|
gst_vaapi_window_replace_internal (old_window_ptr, new_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,11 +171,11 @@ gst_vaapi_window_replace(GstVaapiWindow **old_window_ptr,
|
||||||
* Return value: the parent #GstVaapiDisplay object
|
* Return value: the parent #GstVaapiDisplay object
|
||||||
*/
|
*/
|
||||||
GstVaapiDisplay *
|
GstVaapiDisplay *
|
||||||
gst_vaapi_window_get_display(GstVaapiWindow *window)
|
gst_vaapi_window_get_display (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(window != NULL, NULL);
|
g_return_val_if_fail (window != NULL, NULL);
|
||||||
|
|
||||||
return GST_VAAPI_OBJECT_DISPLAY(window);
|
return GST_VAAPI_OBJECT_DISPLAY (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,12 +186,12 @@ gst_vaapi_window_get_display(GstVaapiWindow *window)
|
||||||
* not appear on the screen.
|
* not appear on the screen.
|
||||||
*/
|
*/
|
||||||
void
|
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);
|
GST_VAAPI_WINDOW_GET_CLASS (window)->show (window);
|
||||||
window->check_geometry = TRUE;
|
window->check_geometry = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,11 +202,11 @@ gst_vaapi_window_show(GstVaapiWindow *window)
|
||||||
* to be hidden (invisible to the user).
|
* to be hidden (invisible to the user).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_vaapi_window_hide(GstVaapiWindow *window)
|
gst_vaapi_window_hide (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
g_return_if_fail(window != NULL);
|
g_return_if_fail (window != NULL);
|
||||||
|
|
||||||
GST_VAAPI_WINDOW_GET_CLASS(window)->hide(window);
|
GST_VAAPI_WINDOW_GET_CLASS (window)->hide (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -223,13 +218,13 @@ gst_vaapi_window_hide(GstVaapiWindow *window)
|
||||||
* Return value: %TRUE if the window is fullscreen
|
* Return value: %TRUE if the window is fullscreen
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_get_fullscreen(GstVaapiWindow *window)
|
gst_vaapi_window_get_fullscreen (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(window != NULL, FALSE);
|
g_return_val_if_fail (window != NULL, FALSE);
|
||||||
|
|
||||||
gst_vaapi_window_ensure_size(window);
|
gst_vaapi_window_ensure_size (window);
|
||||||
|
|
||||||
return window->is_fullscreen;
|
return window->is_fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -240,19 +235,19 @@ gst_vaapi_window_get_fullscreen(GstVaapiWindow *window)
|
||||||
* Requests to place the @window in fullscreen or unfullscreen states.
|
* Requests to place the @window in fullscreen or unfullscreen states.
|
||||||
*/
|
*/
|
||||||
void
|
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 &&
|
if (window->is_fullscreen != fullscreen &&
|
||||||
klass->set_fullscreen && klass->set_fullscreen(window, fullscreen)) {
|
klass->set_fullscreen && klass->set_fullscreen (window, fullscreen)) {
|
||||||
window->is_fullscreen = fullscreen;
|
window->is_fullscreen = fullscreen;
|
||||||
window->check_geometry = TRUE;
|
window->check_geometry = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,13 +259,13 @@ gst_vaapi_window_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen)
|
||||||
* Return value: the width of the @window, in pixels
|
* Return value: the width of the @window, in pixels
|
||||||
*/
|
*/
|
||||||
guint
|
guint
|
||||||
gst_vaapi_window_get_width(GstVaapiWindow *window)
|
gst_vaapi_window_get_width (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(window != NULL, 0);
|
g_return_val_if_fail (window != NULL, 0);
|
||||||
|
|
||||||
gst_vaapi_window_ensure_size(window);
|
gst_vaapi_window_ensure_size (window);
|
||||||
|
|
||||||
return window->width;
|
return window->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -282,35 +277,36 @@ gst_vaapi_window_get_width(GstVaapiWindow *window)
|
||||||
* Return value: the height of the @window, in pixels
|
* Return value: the height of the @window, in pixels
|
||||||
*/
|
*/
|
||||||
guint
|
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:
|
* gst_vaapi_window_get_size:
|
||||||
* @window: a #GstVaapiWindow
|
* @window: a #GstVaapiWindow
|
||||||
* @pwidth: return location for the width, or %NULL
|
* @width_ptr: return location for the width, or %NULL
|
||||||
* @pheight: return location for the height, or %NULL
|
* @height_ptr: return location for the height, or %NULL
|
||||||
*
|
*
|
||||||
* Retrieves the dimensions of a #GstVaapiWindow.
|
* Retrieves the dimensions of a #GstVaapiWindow.
|
||||||
*/
|
*/
|
||||||
void
|
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)
|
if (width_ptr)
|
||||||
*pwidth = window->width;
|
*width_ptr = window->width;
|
||||||
|
|
||||||
if (pheight)
|
if (height_ptr)
|
||||||
*pheight = window->height;
|
*height_ptr = window->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -321,11 +317,11 @@ gst_vaapi_window_get_size(GstVaapiWindow *window, guint *pwidth, guint *pheight)
|
||||||
* Resizes the @window to match the specified @width.
|
* Resizes the @window to match the specified @width.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_vaapi_window_set_width(GstVaapiWindow *window, guint width)
|
gst_vaapi_window_set_width (GstVaapiWindow * window, guint width)
|
||||||
{
|
{
|
||||||
g_return_if_fail(window != NULL);
|
g_return_if_fail (window != NULL);
|
||||||
|
|
||||||
gst_vaapi_window_set_size(window, width, window->height);
|
gst_vaapi_window_set_size (window, width, window->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -336,11 +332,11 @@ gst_vaapi_window_set_width(GstVaapiWindow *window, guint width)
|
||||||
* Resizes the @window to match the specified @height.
|
* Resizes the @window to match the specified @height.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_vaapi_window_set_height(GstVaapiWindow *window, guint height)
|
gst_vaapi_window_set_height (GstVaapiWindow * window, guint height)
|
||||||
{
|
{
|
||||||
g_return_if_fail(window != NULL);
|
g_return_if_fail (window != NULL);
|
||||||
|
|
||||||
gst_vaapi_window_set_size(window, window->width, height);
|
gst_vaapi_window_set_size (window, window->width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -352,39 +348,39 @@ gst_vaapi_window_set_height(GstVaapiWindow *window, guint height)
|
||||||
* Resizes the @window to match the specified @width and @height.
|
* Resizes the @window to match the specified @width and @height.
|
||||||
*/
|
*/
|
||||||
void
|
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)
|
if (width == window->width && height == window->height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!GST_VAAPI_WINDOW_GET_CLASS(window)->resize(window, width, height))
|
if (!GST_VAAPI_WINDOW_GET_CLASS (window)->resize (window, width, height))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
window->width = width;
|
window->width = width;
|
||||||
window->height = height;
|
window->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
get_surface_rect(GstVaapiSurface *surface, GstVaapiRectangle *rect)
|
get_surface_rect (GstVaapiSurface * surface, GstVaapiRectangle * rect)
|
||||||
{
|
{
|
||||||
rect->x = 0;
|
rect->x = 0;
|
||||||
rect->y = 0;
|
rect->y = 0;
|
||||||
rect->width = GST_VAAPI_SURFACE_WIDTH(surface);
|
rect->width = GST_VAAPI_SURFACE_WIDTH (surface);
|
||||||
rect->height = GST_VAAPI_SURFACE_HEIGHT(surface);
|
rect->height = GST_VAAPI_SURFACE_HEIGHT (surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
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);
|
gst_vaapi_window_get_size (window, &width, &height);
|
||||||
rect->x = 0;
|
rect->x = 0;
|
||||||
rect->y = 0;
|
rect->y = 0;
|
||||||
rect->width = width;
|
rect->width = width;
|
||||||
rect->height = height;
|
rect->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -406,47 +402,44 @@ get_window_rect(GstVaapiWindow *window, GstVaapiRectangle *rect)
|
||||||
* Return value: %TRUE on success
|
* Return value: %TRUE on success
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_put_surface(
|
gst_vaapi_window_put_surface (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
GstVaapiSurface * surface,
|
||||||
GstVaapiSurface *surface,
|
const GstVaapiRectangle * src_rect,
|
||||||
const GstVaapiRectangle *src_rect,
|
const GstVaapiRectangle * dst_rect, guint flags)
|
||||||
const GstVaapiRectangle *dst_rect,
|
|
||||||
guint flags
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const GstVaapiWindowClass *klass;
|
const GstVaapiWindowClass *klass;
|
||||||
GstVaapiRectangle src_rect_default, dst_rect_default;
|
GstVaapiRectangle src_rect_default, dst_rect_default;
|
||||||
|
|
||||||
g_return_val_if_fail(window != NULL, FALSE);
|
g_return_val_if_fail (window != NULL, FALSE);
|
||||||
g_return_val_if_fail(surface != NULL, FALSE);
|
g_return_val_if_fail (surface != NULL, FALSE);
|
||||||
|
|
||||||
klass = GST_VAAPI_WINDOW_GET_CLASS(window);
|
klass = GST_VAAPI_WINDOW_GET_CLASS (window);
|
||||||
if (!klass->render)
|
if (!klass->render)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!src_rect) {
|
if (!src_rect) {
|
||||||
src_rect = &src_rect_default;
|
src_rect = &src_rect_default;
|
||||||
get_surface_rect(surface, &src_rect_default);
|
get_surface_rect (surface, &src_rect_default);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dst_rect) {
|
if (!dst_rect) {
|
||||||
dst_rect = &dst_rect_default;
|
dst_rect = &dst_rect_default;
|
||||||
get_window_rect(window, &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
|
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);
|
gst_vaapi_pixmap_get_size (pixmap, &width, &height);
|
||||||
rect->x = 0;
|
rect->x = 0;
|
||||||
rect->y = 0;
|
rect->y = 0;
|
||||||
rect->width = width;
|
rect->width = width;
|
||||||
rect->height = height;
|
rect->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -465,31 +458,28 @@ get_pixmap_rect(GstVaapiPixmap *pixmap, GstVaapiRectangle *rect)
|
||||||
* Return value: %TRUE on success
|
* Return value: %TRUE on success
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_put_pixmap(
|
gst_vaapi_window_put_pixmap (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
GstVaapiPixmap * pixmap,
|
||||||
GstVaapiPixmap *pixmap,
|
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect)
|
||||||
const GstVaapiRectangle *src_rect,
|
|
||||||
const GstVaapiRectangle *dst_rect
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const GstVaapiWindowClass *klass;
|
const GstVaapiWindowClass *klass;
|
||||||
GstVaapiRectangle src_rect_default, dst_rect_default;
|
GstVaapiRectangle src_rect_default, dst_rect_default;
|
||||||
|
|
||||||
g_return_val_if_fail(window != NULL, FALSE);
|
g_return_val_if_fail (window != NULL, FALSE);
|
||||||
g_return_val_if_fail(pixmap != NULL, FALSE);
|
g_return_val_if_fail (pixmap != NULL, FALSE);
|
||||||
|
|
||||||
klass = GST_VAAPI_WINDOW_GET_CLASS(window);
|
klass = GST_VAAPI_WINDOW_GET_CLASS (window);
|
||||||
if (!klass->render_pixmap)
|
if (!klass->render_pixmap)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!src_rect) {
|
if (!src_rect) {
|
||||||
src_rect = &src_rect_default;
|
src_rect = &src_rect_default;
|
||||||
get_pixmap_rect(pixmap, &src_rect_default);
|
get_pixmap_rect (pixmap, &src_rect_default);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dst_rect) {
|
if (!dst_rect) {
|
||||||
dst_rect = &dst_rect_default;
|
dst_rect = &dst_rect_default;
|
||||||
get_window_rect(window, &dst_rect_default);
|
get_window_rect (window, &dst_rect_default);
|
||||||
}
|
}
|
||||||
return klass->render_pixmap(window, pixmap, src_rect, dst_rect);
|
return klass->render_pixmap (window, pixmap, src_rect, dst_rect);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,68 +37,61 @@ G_BEGIN_DECLS
|
||||||
#define GST_VAAPI_WINDOW(obj) \
|
#define GST_VAAPI_WINDOW(obj) \
|
||||||
((GstVaapiWindow *)(obj))
|
((GstVaapiWindow *)(obj))
|
||||||
|
|
||||||
typedef struct _GstVaapiWindow GstVaapiWindow;
|
typedef struct _GstVaapiWindow GstVaapiWindow;
|
||||||
typedef struct _GstVaapiWindowClass GstVaapiWindowClass;
|
typedef struct _GstVaapiWindowClass GstVaapiWindowClass;
|
||||||
|
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_ref(GstVaapiWindow *window);
|
gst_vaapi_window_ref (GstVaapiWindow * window);
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_window_unref(GstVaapiWindow *window);
|
gst_vaapi_window_unref (GstVaapiWindow * window);
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_window_replace(GstVaapiWindow **old_window_ptr,
|
gst_vaapi_window_replace (GstVaapiWindow ** old_window_ptr,
|
||||||
GstVaapiWindow *new_window);
|
GstVaapiWindow * new_window);
|
||||||
|
|
||||||
GstVaapiDisplay *
|
GstVaapiDisplay *
|
||||||
gst_vaapi_window_get_display(GstVaapiWindow *window);
|
gst_vaapi_window_get_display (GstVaapiWindow * window);
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_window_show(GstVaapiWindow *window);
|
gst_vaapi_window_show (GstVaapiWindow * window);
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_window_hide(GstVaapiWindow *window);
|
gst_vaapi_window_hide (GstVaapiWindow * window);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_get_fullscreen(GstVaapiWindow *window);
|
gst_vaapi_window_get_fullscreen (GstVaapiWindow * window);
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_window_set_fullscreen(GstVaapiWindow *window, gboolean fullscreen);
|
gst_vaapi_window_set_fullscreen (GstVaapiWindow * window, gboolean fullscreen);
|
||||||
|
|
||||||
guint
|
guint
|
||||||
gst_vaapi_window_get_width(GstVaapiWindow *window);
|
gst_vaapi_window_get_width (GstVaapiWindow * window);
|
||||||
|
|
||||||
guint
|
guint
|
||||||
gst_vaapi_window_get_height(GstVaapiWindow *window);
|
gst_vaapi_window_get_height (GstVaapiWindow * window);
|
||||||
|
|
||||||
void
|
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
|
void
|
||||||
gst_vaapi_window_set_width(GstVaapiWindow *window, guint width);
|
gst_vaapi_window_set_width (GstVaapiWindow * window, guint width);
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_window_set_height(GstVaapiWindow *window, guint height);
|
gst_vaapi_window_set_height (GstVaapiWindow * window, guint height);
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_window_set_size(GstVaapiWindow *window, guint width, guint height);
|
gst_vaapi_window_set_size (GstVaapiWindow * window, guint width, guint height);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_put_surface(
|
gst_vaapi_window_put_surface (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
GstVaapiSurface * surface, const GstVaapiRectangle * src_rect,
|
||||||
GstVaapiSurface *surface,
|
const GstVaapiRectangle * dst_rect, guint flags);
|
||||||
const GstVaapiRectangle *src_rect,
|
|
||||||
const GstVaapiRectangle *dst_rect,
|
|
||||||
guint flags
|
|
||||||
);
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_put_pixmap(
|
gst_vaapi_window_put_pixmap (GstVaapiWindow * window, GstVaapiPixmap * pixmap,
|
||||||
GstVaapiWindow *window,
|
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect);
|
||||||
GstVaapiPixmap *pixmap,
|
|
||||||
const GstVaapiRectangle *src_rect,
|
|
||||||
const GstVaapiRectangle *dst_rect
|
|
||||||
);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -33,16 +33,17 @@
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#include "gstvaapidebug.h"
|
#include "gstvaapidebug.h"
|
||||||
|
|
||||||
typedef struct _GstVaapiWindowDRMClass GstVaapiWindowDRMClass;
|
typedef struct _GstVaapiWindowDRMClass GstVaapiWindowDRMClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstVaapiWindowDRM:
|
* GstVaapiWindowDRM:
|
||||||
*
|
*
|
||||||
* A dummy DRM window abstraction.
|
* A dummy DRM window abstraction.
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiWindowDRM {
|
struct _GstVaapiWindowDRM
|
||||||
/*< private >*/
|
{
|
||||||
GstVaapiWindow parent_instance;
|
/*< private >*/
|
||||||
|
GstVaapiWindow parent_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,77 +51,65 @@ struct _GstVaapiWindowDRM {
|
||||||
*
|
*
|
||||||
* A dummy DRM window abstraction class.
|
* A dummy DRM window abstraction class.
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiWindowDRMClass {
|
struct _GstVaapiWindowDRMClass
|
||||||
/*< private >*/
|
{
|
||||||
GstVaapiWindowClass parent_instance;
|
/*< private >*/
|
||||||
|
GstVaapiWindowClass parent_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapi_window_drm_show(GstVaapiWindow *window)
|
gst_vaapi_window_drm_show (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapi_window_drm_hide(GstVaapiWindow *window)
|
gst_vaapi_window_drm_hide (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapi_window_drm_create(
|
gst_vaapi_window_drm_create (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
guint * width, guint * height)
|
||||||
guint *width,
|
|
||||||
guint *height
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapi_window_drm_resize(
|
gst_vaapi_window_drm_resize (GstVaapiWindow * window, guint width, guint height)
|
||||||
GstVaapiWindow * window,
|
|
||||||
guint width,
|
|
||||||
guint height
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapi_window_drm_render(
|
gst_vaapi_window_drm_render (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
GstVaapiSurface * surface,
|
||||||
GstVaapiSurface *surface,
|
const GstVaapiRectangle * src_rect,
|
||||||
const GstVaapiRectangle *src_rect,
|
const GstVaapiRectangle * dst_rect, guint flags)
|
||||||
const GstVaapiRectangle *dst_rect,
|
|
||||||
guint flags
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_window_drm_class_init(GstVaapiWindowDRMClass *klass)
|
gst_vaapi_window_drm_class_init (GstVaapiWindowDRMClass * klass)
|
||||||
{
|
{
|
||||||
GstVaapiWindowClass * const window_class =
|
GstVaapiWindowClass *const window_class = GST_VAAPI_WINDOW_CLASS (klass);
|
||||||
GST_VAAPI_WINDOW_CLASS(klass);
|
|
||||||
|
|
||||||
window_class->create = gst_vaapi_window_drm_create;
|
window_class->create = gst_vaapi_window_drm_create;
|
||||||
window_class->show = gst_vaapi_window_drm_show;
|
window_class->show = gst_vaapi_window_drm_show;
|
||||||
window_class->hide = gst_vaapi_window_drm_hide;
|
window_class->hide = gst_vaapi_window_drm_hide;
|
||||||
window_class->resize = gst_vaapi_window_drm_resize;
|
window_class->resize = gst_vaapi_window_drm_resize;
|
||||||
window_class->render = gst_vaapi_window_drm_render;
|
window_class->render = gst_vaapi_window_drm_render;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_window_drm_finalize(GstVaapiWindowDRM *window)
|
gst_vaapi_window_drm_finalize (GstVaapiWindowDRM * window)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
|
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiWindowDRM,
|
||||||
GstVaapiWindowDRM,
|
gst_vaapi_window_drm, gst_vaapi_window_drm_class_init (&g_class));
|
||||||
gst_vaapi_window_drm,
|
|
||||||
gst_vaapi_window_drm_class_init(&g_class))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_vaapi_window_drm_new:
|
* gst_vaapi_window_drm_new:
|
||||||
|
@ -141,16 +130,13 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
|
||||||
* Return value: the newly allocated #GstVaapiWindow object
|
* Return value: the newly allocated #GstVaapiWindow object
|
||||||
*/
|
*/
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_drm_new(
|
gst_vaapi_window_drm_new (GstVaapiDisplay * display, guint width, guint height)
|
||||||
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(
|
return
|
||||||
gst_vaapi_window_drm_class()), display, width, height);
|
gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS (gst_vaapi_window_drm_class
|
||||||
|
()), display, width, height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,10 @@ G_BEGIN_DECLS
|
||||||
#define GST_VAAPI_WINDOW_DRM(obj) \
|
#define GST_VAAPI_WINDOW_DRM(obj) \
|
||||||
((GstVaapiWindowDRM *)(obj))
|
((GstVaapiWindowDRM *)(obj))
|
||||||
|
|
||||||
typedef struct _GstVaapiWindowDRM GstVaapiWindowDRM;
|
typedef struct _GstVaapiWindowDRM GstVaapiWindowDRM;
|
||||||
|
|
||||||
GstVaapiWindow *
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,13 @@
|
||||||
#define GST_VAAPI_WINDOW_GLX_GET_CLASS(obj) \
|
#define GST_VAAPI_WINDOW_GLX_GET_CLASS(obj) \
|
||||||
GST_VAAPI_WINDOW_GLX_CLASS(GST_VAAPI_OBJECT_GET_CLASS(obj))
|
GST_VAAPI_WINDOW_GLX_CLASS(GST_VAAPI_OBJECT_GET_CLASS(obj))
|
||||||
|
|
||||||
typedef struct _GstVaapiWindowGLXPrivate GstVaapiWindowGLXPrivate;
|
typedef struct _GstVaapiWindowGLXPrivate GstVaapiWindowGLXPrivate;
|
||||||
typedef struct _GstVaapiWindowGLXClass GstVaapiWindowGLXClass;
|
typedef struct _GstVaapiWindowGLXClass GstVaapiWindowGLXClass;
|
||||||
|
|
||||||
struct _GstVaapiWindowGLXPrivate {
|
struct _GstVaapiWindowGLXPrivate
|
||||||
Colormap cmap;
|
{
|
||||||
GLContextState *gl_context;
|
Colormap cmap;
|
||||||
|
GLContextState *gl_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,11 +62,12 @@ struct _GstVaapiWindowGLXPrivate {
|
||||||
*
|
*
|
||||||
* An X11 #Window suitable for GLX rendering.
|
* An X11 #Window suitable for GLX rendering.
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiWindowGLX {
|
struct _GstVaapiWindowGLX
|
||||||
/*< private >*/
|
{
|
||||||
GstVaapiWindowX11 parent_instance;
|
/*< private >*/
|
||||||
|
GstVaapiWindowX11 parent_instance;
|
||||||
|
|
||||||
GstVaapiWindowGLXPrivate priv;
|
GstVaapiWindowGLXPrivate priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,282 +75,261 @@ struct _GstVaapiWindowGLX {
|
||||||
*
|
*
|
||||||
* An X11 #Window suitable for GLX rendering.
|
* An X11 #Window suitable for GLX rendering.
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiWindowGLXClass {
|
struct _GstVaapiWindowGLXClass
|
||||||
/*< private >*/
|
{
|
||||||
GstVaapiWindowX11Class parent_class;
|
/*< private >*/
|
||||||
|
GstVaapiWindowX11Class parent_class;
|
||||||
|
|
||||||
GstVaapiObjectFinalizeFunc parent_finalize;
|
GstVaapiObjectFinalizeFunc parent_finalize;
|
||||||
GstVaapiWindowResizeFunc parent_resize;
|
GstVaapiWindowResizeFunc parent_resize;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Fill rectangle coords with capped bounds */
|
/* Fill rectangle coords with capped bounds */
|
||||||
static inline void
|
static inline void
|
||||||
fill_rect(
|
fill_rect (GstVaapiRectangle * dst_rect,
|
||||||
GstVaapiRectangle *dst_rect,
|
const GstVaapiRectangle * src_rect, guint width, guint height)
|
||||||
const GstVaapiRectangle *src_rect,
|
|
||||||
guint width,
|
|
||||||
guint height
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (src_rect) {
|
if (src_rect) {
|
||||||
dst_rect->x = src_rect->x > 0 ? src_rect->x : 0;
|
dst_rect->x = src_rect->x > 0 ? src_rect->x : 0;
|
||||||
dst_rect->y = src_rect->y > 0 ? src_rect->y : 0;
|
dst_rect->y = src_rect->y > 0 ? src_rect->y : 0;
|
||||||
if (src_rect->x + src_rect->width < width)
|
if (src_rect->x + src_rect->width < width)
|
||||||
dst_rect->width = src_rect->width;
|
dst_rect->width = src_rect->width;
|
||||||
else
|
else
|
||||||
dst_rect->width = width - dst_rect->x;
|
dst_rect->width = width - dst_rect->x;
|
||||||
if (src_rect->y + src_rect->height < height)
|
if (src_rect->y + src_rect->height < height)
|
||||||
dst_rect->height = src_rect->height;
|
dst_rect->height = src_rect->height;
|
||||||
else
|
else
|
||||||
dst_rect->height = height - dst_rect->y;
|
dst_rect->height = height - dst_rect->y;
|
||||||
}
|
} else {
|
||||||
else {
|
dst_rect->x = 0;
|
||||||
dst_rect->x = 0;
|
dst_rect->y = 0;
|
||||||
dst_rect->y = 0;
|
dst_rect->width = width;
|
||||||
dst_rect->width = width;
|
dst_rect->height = height;
|
||||||
dst_rect->height = height;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gst_vaapi_window_glx_destroy_context(GstVaapiWindow *window)
|
_gst_vaapi_window_glx_destroy_context (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
GstVaapiWindowGLXPrivate * const priv =
|
GstVaapiWindowGLXPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
if (priv->gl_context) {
|
if (priv->gl_context) {
|
||||||
gl_destroy_context(priv->gl_context);
|
gl_destroy_context (priv->gl_context);
|
||||||
priv->gl_context = NULL;
|
priv->gl_context = NULL;
|
||||||
}
|
}
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_gst_vaapi_window_glx_create_context(
|
_gst_vaapi_window_glx_create_context (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
GLXContext foreign_context)
|
||||||
GLXContext foreign_context
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstVaapiWindowGLXPrivate * const priv =
|
GstVaapiWindowGLXPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
|
||||||
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
|
Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
|
||||||
GLContextState parent_cs;
|
GLContextState parent_cs;
|
||||||
|
|
||||||
parent_cs.display = dpy;
|
parent_cs.display = dpy;
|
||||||
parent_cs.window = None;
|
parent_cs.window = None;
|
||||||
parent_cs.context = foreign_context;
|
parent_cs.context = foreign_context;
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
priv->gl_context = gl_create_context(
|
priv->gl_context = gl_create_context (dpy,
|
||||||
dpy,
|
GST_VAAPI_OBJECT_XSCREEN (window), &parent_cs);
|
||||||
GST_VAAPI_OBJECT_XSCREEN(window),
|
if (!priv->gl_context) {
|
||||||
&parent_cs
|
GST_DEBUG ("could not create GLX context");
|
||||||
);
|
|
||||||
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;
|
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:
|
out_destroy_context:
|
||||||
gl_destroy_context(priv->gl_context);
|
gl_destroy_context (priv->gl_context);
|
||||||
priv->gl_context = NULL;
|
priv->gl_context = NULL;
|
||||||
end:
|
end:
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
return priv->gl_context != NULL;
|
return priv->gl_context != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_gst_vaapi_window_glx_ensure_context(
|
_gst_vaapi_window_glx_ensure_context (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
GLXContext foreign_context)
|
||||||
GLXContext foreign_context
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstVaapiWindowGLXPrivate * const priv =
|
GstVaapiWindowGLXPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
|
||||||
|
|
||||||
if (priv->gl_context) {
|
if (priv->gl_context) {
|
||||||
if (!foreign_context || foreign_context == priv->gl_context->context)
|
if (!foreign_context || foreign_context == priv->gl_context->context)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
_gst_vaapi_window_glx_destroy_context(window);
|
_gst_vaapi_window_glx_destroy_context (window);
|
||||||
}
|
}
|
||||||
return _gst_vaapi_window_glx_create_context(window, foreign_context);
|
return _gst_vaapi_window_glx_create_context (window, foreign_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapi_window_glx_ensure_context(
|
gst_vaapi_window_glx_ensure_context (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
GLXContext foreign_context)
|
||||||
GLXContext foreign_context
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstVaapiWindowGLXPrivate * const priv =
|
GstVaapiWindowGLXPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
|
||||||
GLContextState old_cs;
|
GLContextState old_cs;
|
||||||
guint width, height;
|
guint width, height;
|
||||||
|
|
||||||
if (!_gst_vaapi_window_glx_ensure_context(window, foreign_context))
|
if (!_gst_vaapi_window_glx_ensure_context (window, foreign_context))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
priv->gl_context->window = GST_VAAPI_OBJECT_ID(window);
|
priv->gl_context->window = GST_VAAPI_OBJECT_ID (window);
|
||||||
if (!gl_set_current_context(priv->gl_context, &old_cs)) {
|
if (!gl_set_current_context (priv->gl_context, &old_cs)) {
|
||||||
GST_DEBUG("could not make newly created GLX context current");
|
GST_DEBUG ("could not make newly created GLX context current");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable (GL_DEPTH_TEST);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask (GL_FALSE);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable (GL_CULL_FACE);
|
||||||
glDrawBuffer(GL_BACK);
|
glDrawBuffer (GL_BACK);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
glEnable(GL_BLEND);
|
glEnable (GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
gst_vaapi_window_get_size(window, &width, &height);
|
gst_vaapi_window_get_size (window, &width, &height);
|
||||||
gl_resize(width, height);
|
gl_resize (width, height);
|
||||||
|
|
||||||
gl_set_bgcolor(0);
|
gl_set_bgcolor (0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear (GL_COLOR_BUFFER_BIT);
|
||||||
gl_set_current_context(&old_cs, NULL);
|
gl_set_current_context (&old_cs, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Visual *
|
static Visual *
|
||||||
gst_vaapi_window_glx_get_visual(GstVaapiWindow *window)
|
gst_vaapi_window_glx_get_visual (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
GstVaapiWindowGLXPrivate * const priv =
|
GstVaapiWindowGLXPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
|
||||||
|
|
||||||
if (!_gst_vaapi_window_glx_ensure_context(window, NULL))
|
if (!_gst_vaapi_window_glx_ensure_context (window, NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
return priv->gl_context->visual->visual;
|
return priv->gl_context->visual->visual;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_window_glx_destroy_colormap(GstVaapiWindow *window)
|
gst_vaapi_window_glx_destroy_colormap (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
GstVaapiWindowGLXPrivate * const priv =
|
GstVaapiWindowGLXPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
|
||||||
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
|
Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
|
||||||
|
|
||||||
if (priv->cmap) {
|
if (priv->cmap) {
|
||||||
if (!window->use_foreign_window) {
|
if (!window->use_foreign_window) {
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
XFreeColormap(dpy, priv->cmap);
|
XFreeColormap (dpy, priv->cmap);
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
}
|
|
||||||
priv->cmap = None;
|
|
||||||
}
|
}
|
||||||
|
priv->cmap = None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Colormap
|
static Colormap
|
||||||
gst_vaapi_window_glx_create_colormap(GstVaapiWindow *window)
|
gst_vaapi_window_glx_create_colormap (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
GstVaapiWindowGLXPrivate * const priv =
|
GstVaapiWindowGLXPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
|
||||||
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
|
Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
|
||||||
int screen;
|
int screen;
|
||||||
XWindowAttributes wattr;
|
XWindowAttributes wattr;
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
|
|
||||||
if (!priv->cmap) {
|
if (!priv->cmap) {
|
||||||
if (!window->use_foreign_window) {
|
if (!window->use_foreign_window) {
|
||||||
if (!_gst_vaapi_window_glx_ensure_context(window, NULL))
|
if (!_gst_vaapi_window_glx_ensure_context (window, NULL))
|
||||||
return None;
|
return None;
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
x11_trap_errors();
|
x11_trap_errors ();
|
||||||
/* XXX: add a GstVaapiDisplayX11:x11-screen property? */
|
/* XXX: add a GstVaapiDisplayX11:x11-screen property? */
|
||||||
screen = GST_VAAPI_OBJECT_XSCREEN(window);
|
screen = GST_VAAPI_OBJECT_XSCREEN (window);
|
||||||
priv->cmap = XCreateColormap(
|
priv->cmap = XCreateColormap (dpy,
|
||||||
dpy,
|
RootWindow (dpy, screen),
|
||||||
RootWindow(dpy, screen),
|
priv->gl_context->visual->visual, AllocNone);
|
||||||
priv->gl_context->visual->visual,
|
success = x11_untrap_errors () == 0;
|
||||||
AllocNone
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
);
|
} else {
|
||||||
success = x11_untrap_errors() == 0;
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
x11_trap_errors ();
|
||||||
}
|
XGetWindowAttributes (dpy, GST_VAAPI_OBJECT_ID (window), &wattr);
|
||||||
else {
|
priv->cmap = wattr.colormap;
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
success = x11_untrap_errors () == 0;
|
||||||
x11_trap_errors();
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
return priv->cmap;
|
if (!success)
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
return priv->cmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Colormap
|
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
|
static gboolean
|
||||||
gst_vaapi_window_glx_resize(GstVaapiWindow *window,
|
gst_vaapi_window_glx_resize (GstVaapiWindow * window, guint width, guint height)
|
||||||
guint width, guint height)
|
|
||||||
{
|
{
|
||||||
GstVaapiWindowGLXPrivate * const priv =
|
GstVaapiWindowGLXPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
|
||||||
const GstVaapiWindowGLXClass * const klass =
|
const GstVaapiWindowGLXClass *const klass =
|
||||||
GST_VAAPI_WINDOW_GLX_GET_CLASS(window);
|
GST_VAAPI_WINDOW_GLX_GET_CLASS (window);
|
||||||
Display * const dpy = GST_VAAPI_OBJECT_XDISPLAY(window);
|
Display *const dpy = GST_VAAPI_OBJECT_XDISPLAY (window);
|
||||||
GLContextState old_cs;
|
GLContextState old_cs;
|
||||||
|
|
||||||
if (!klass->parent_resize(window, width, height))
|
if (!klass->parent_resize (window, width, height))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
XSync(dpy, False); /* make sure resize completed */
|
XSync (dpy, False); /* make sure resize completed */
|
||||||
if (gl_set_current_context(priv->gl_context, &old_cs)) {
|
if (gl_set_current_context (priv->gl_context, &old_cs)) {
|
||||||
gl_resize(width, height);
|
gl_resize (width, height);
|
||||||
gl_set_current_context(&old_cs, NULL);
|
gl_set_current_context (&old_cs, NULL);
|
||||||
}
|
}
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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_context (base_window);
|
||||||
gst_vaapi_window_glx_destroy_colormap(base_window);
|
gst_vaapi_window_glx_destroy_colormap (base_window);
|
||||||
|
|
||||||
GST_VAAPI_WINDOW_GLX_GET_CLASS(window)->parent_finalize(
|
GST_VAAPI_WINDOW_GLX_GET_CLASS (window)->parent_finalize (GST_VAAPI_OBJECT
|
||||||
GST_VAAPI_OBJECT(window));
|
(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_window_glx_class_init(GstVaapiWindowGLXClass *klass)
|
gst_vaapi_window_glx_class_init (GstVaapiWindowGLXClass * klass)
|
||||||
{
|
{
|
||||||
GstVaapiWindowClass * const window_class =
|
GstVaapiWindowClass *const window_class = GST_VAAPI_WINDOW_CLASS (klass);
|
||||||
GST_VAAPI_WINDOW_CLASS(klass);
|
GstVaapiWindowX11Class *const xwindow_class =
|
||||||
GstVaapiWindowX11Class * const xwindow_class =
|
GST_VAAPI_WINDOW_X11_CLASS (klass);
|
||||||
GST_VAAPI_WINDOW_X11_CLASS(klass);
|
|
||||||
|
|
||||||
gst_vaapi_window_x11_class_init(xwindow_class);
|
gst_vaapi_window_x11_class_init (xwindow_class);
|
||||||
klass->parent_resize = window_class->resize;
|
klass->parent_resize = window_class->resize;
|
||||||
klass->parent_finalize = GST_VAAPI_OBJECT_CLASS(klass)->finalize;
|
klass->parent_finalize = GST_VAAPI_OBJECT_CLASS (klass)->finalize;
|
||||||
window_class->resize = gst_vaapi_window_glx_resize;
|
window_class->resize = gst_vaapi_window_glx_resize;
|
||||||
xwindow_class->get_visual = gst_vaapi_window_glx_get_visual;
|
xwindow_class->get_visual = gst_vaapi_window_glx_get_visual;
|
||||||
xwindow_class->get_colormap = gst_vaapi_window_glx_get_colormap;
|
xwindow_class->get_colormap = gst_vaapi_window_glx_get_colormap;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
|
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiWindowGLX,
|
||||||
GstVaapiWindowGLX,
|
gst_vaapi_window_glx, gst_vaapi_window_glx_class_init (&g_class));
|
||||||
gst_vaapi_window_glx,
|
|
||||||
gst_vaapi_window_glx_class_init(&g_class))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_vaapi_window_glx_new:
|
* gst_vaapi_window_glx_new:
|
||||||
|
@ -363,24 +344,25 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
|
||||||
* Return value: the newly allocated #GstVaapiWindow object
|
* Return value: the newly allocated #GstVaapiWindow object
|
||||||
*/
|
*/
|
||||||
GstVaapiWindow *
|
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(
|
window =
|
||||||
gst_vaapi_window_glx_class()), display, width, height);
|
gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS (gst_vaapi_window_glx_class
|
||||||
if (!window)
|
()), display, width, height);
|
||||||
return NULL;
|
if (!window)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (!gst_vaapi_window_glx_ensure_context(window, NULL))
|
if (!gst_vaapi_window_glx_ensure_context (window, NULL))
|
||||||
goto error;
|
goto error;
|
||||||
return window;
|
return window;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
gst_vaapi_window_unref(window);
|
gst_vaapi_window_unref (window);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -396,27 +378,28 @@ error:
|
||||||
* Return value: the newly allocated #GstVaapiWindow object
|
* Return value: the newly allocated #GstVaapiWindow object
|
||||||
*/
|
*/
|
||||||
GstVaapiWindow *
|
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 (GST_VAAPI_IS_DISPLAY_GLX (display), NULL);
|
||||||
g_return_val_if_fail(xid != None, NULL);
|
g_return_val_if_fail (xid != None, NULL);
|
||||||
|
|
||||||
window = gst_vaapi_window_new_from_native(GST_VAAPI_WINDOW_CLASS(
|
window =
|
||||||
gst_vaapi_window_glx_class()), display, GINT_TO_POINTER(xid));
|
gst_vaapi_window_new_from_native (GST_VAAPI_WINDOW_CLASS
|
||||||
if (!window)
|
(gst_vaapi_window_glx_class ()), display, GINT_TO_POINTER (xid));
|
||||||
return NULL;
|
if (!window)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (!gst_vaapi_window_glx_ensure_context(window, NULL))
|
if (!gst_vaapi_window_glx_ensure_context (window, NULL))
|
||||||
goto error;
|
goto error;
|
||||||
return window;
|
return window;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
gst_vaapi_window_unref(window);
|
gst_vaapi_window_unref (window);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -428,11 +411,11 @@ error:
|
||||||
* Return value: the #GLXContext bound to the @window
|
* Return value: the #GLXContext bound to the @window
|
||||||
*/
|
*/
|
||||||
GLXContext
|
GLXContext
|
||||||
gst_vaapi_window_glx_get_context(GstVaapiWindowGLX *window)
|
gst_vaapi_window_glx_get_context (GstVaapiWindowGLX * window)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(window != NULL, NULL);
|
g_return_val_if_fail (window != NULL, NULL);
|
||||||
|
|
||||||
return GST_VAAPI_WINDOW_GLX_GET_PRIVATE(window)->gl_context->context;
|
return GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window)->gl_context->context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -448,11 +431,11 @@ gst_vaapi_window_glx_get_context(GstVaapiWindowGLX *window)
|
||||||
* Return value: %TRUE on success
|
* Return value: %TRUE on success
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_glx_set_context(GstVaapiWindowGLX *window, GLXContext ctx)
|
gst_vaapi_window_glx_set_context (GstVaapiWindowGLX * window, GLXContext ctx)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(window != NULL, FALSE);
|
g_return_val_if_fail (window != NULL, FALSE);
|
||||||
|
|
||||||
return gst_vaapi_window_glx_ensure_context(GST_VAAPI_WINDOW(window), ctx);
|
return gst_vaapi_window_glx_ensure_context (GST_VAAPI_WINDOW (window), ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -466,16 +449,16 @@ gst_vaapi_window_glx_set_context(GstVaapiWindowGLX *window, GLXContext ctx)
|
||||||
* Return value: %TRUE on success
|
* Return value: %TRUE on success
|
||||||
*/
|
*/
|
||||||
gboolean
|
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);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
success = gl_set_current_context(window->priv.gl_context, NULL);
|
success = gl_set_current_context (window->priv.gl_context, NULL);
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -487,13 +470,13 @@ gst_vaapi_window_glx_make_current(GstVaapiWindowGLX *window)
|
||||||
* around glXSwapBuffers().
|
* around glXSwapBuffers().
|
||||||
*/
|
*/
|
||||||
void
|
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);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
gl_swap_buffers(window->priv.gl_context);
|
gl_swap_buffers (window->priv.gl_context);
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -514,57 +497,59 @@ gst_vaapi_window_glx_swap_buffers(GstVaapiWindowGLX *window)
|
||||||
* Return value: %TRUE on success
|
* Return value: %TRUE on success
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_glx_put_texture(
|
gst_vaapi_window_glx_put_texture (GstVaapiWindowGLX * window,
|
||||||
GstVaapiWindowGLX *window,
|
GstVaapiTexture * texture,
|
||||||
GstVaapiTexture *texture,
|
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect)
|
||||||
const GstVaapiRectangle *src_rect,
|
|
||||||
const GstVaapiRectangle *dst_rect
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstVaapiRectangle tmp_src_rect, tmp_dst_rect;
|
GstVaapiRectangle tmp_src_rect, tmp_dst_rect;
|
||||||
GLTextureState ts;
|
GLTextureState ts;
|
||||||
GLenum tex_target;
|
GLenum tex_target;
|
||||||
GLuint tex_id;
|
GLuint tex_id;
|
||||||
guint tex_width, tex_height;
|
guint tex_width, tex_height;
|
||||||
guint win_width, win_height;
|
guint win_width, win_height;
|
||||||
|
|
||||||
g_return_val_if_fail(window != NULL, FALSE);
|
g_return_val_if_fail (window != NULL, FALSE);
|
||||||
g_return_val_if_fail(texture != NULL, FALSE);
|
g_return_val_if_fail (texture != NULL, FALSE);
|
||||||
|
|
||||||
gst_vaapi_texture_get_size(texture, &tex_width, &tex_height);
|
gst_vaapi_texture_get_size (texture, &tex_width, &tex_height);
|
||||||
fill_rect(&tmp_src_rect, src_rect, tex_width, tex_height);
|
fill_rect (&tmp_src_rect, src_rect, tex_width, tex_height);
|
||||||
src_rect = &tmp_src_rect;
|
src_rect = &tmp_src_rect;
|
||||||
|
|
||||||
gst_vaapi_window_get_size(GST_VAAPI_WINDOW(window), &win_width, &win_height);
|
gst_vaapi_window_get_size (GST_VAAPI_WINDOW (window), &win_width,
|
||||||
fill_rect(&tmp_dst_rect, dst_rect, win_width, win_height);
|
&win_height);
|
||||||
dst_rect = &tmp_dst_rect;
|
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 */
|
/* XXX: only GL_TEXTURE_2D textures are supported at this time */
|
||||||
tex_target = gst_vaapi_texture_get_target(texture);
|
tex_target = gst_vaapi_texture_get_target (texture);
|
||||||
if (tex_target != GL_TEXTURE_2D)
|
if (tex_target != GL_TEXTURE_2D)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
tex_id = gst_vaapi_texture_get_id(texture);
|
tex_id = gst_vaapi_texture_get_id (texture);
|
||||||
if (!gl_bind_texture(&ts, tex_target, tex_id))
|
if (!gl_bind_texture (&ts, tex_target, tex_id))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
glColor4f (1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
glPushMatrix();
|
glPushMatrix ();
|
||||||
glTranslatef((GLfloat)dst_rect->x, (GLfloat)dst_rect->y, 0.0f);
|
glTranslatef ((GLfloat) dst_rect->x, (GLfloat) dst_rect->y, 0.0f);
|
||||||
glBegin(GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
{
|
{
|
||||||
const float tx1 = (float)src_rect->x / tex_width;
|
const float tx1 = (float) src_rect->x / tex_width;
|
||||||
const float tx2 = (float)(src_rect->x + src_rect->width) / 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 ty1 = (float) src_rect->y / tex_height;
|
||||||
const float ty2 = (float)(src_rect->y + src_rect->height) / tex_height;
|
const float ty2 = (float) (src_rect->y + src_rect->height) / tex_height;
|
||||||
const guint w = dst_rect->width;
|
const guint w = dst_rect->width;
|
||||||
const guint h = dst_rect->height;
|
const guint h = dst_rect->height;
|
||||||
glTexCoord2f(tx1, ty1); glVertex2i(0, 0);
|
glTexCoord2f (tx1, ty1);
|
||||||
glTexCoord2f(tx1, ty2); glVertex2i(0, h);
|
glVertex2i (0, 0);
|
||||||
glTexCoord2f(tx2, ty2); glVertex2i(w, h);
|
glTexCoord2f (tx1, ty2);
|
||||||
glTexCoord2f(tx2, ty1); glVertex2i(w, 0);
|
glVertex2i (0, h);
|
||||||
}
|
glTexCoord2f (tx2, ty2);
|
||||||
glEnd();
|
glVertex2i (w, h);
|
||||||
glPopMatrix();
|
glTexCoord2f (tx2, ty1);
|
||||||
gl_unbind_texture(&ts);
|
glVertex2i (w, 0);
|
||||||
return TRUE;
|
}
|
||||||
|
glEnd ();
|
||||||
|
glPopMatrix ();
|
||||||
|
gl_unbind_texture (&ts);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,33 +35,30 @@ G_BEGIN_DECLS
|
||||||
#define GST_VAAPI_WINDOW_GLX(obj) \
|
#define GST_VAAPI_WINDOW_GLX(obj) \
|
||||||
((GstVaapiWindowGLX *)(obj))
|
((GstVaapiWindowGLX *)(obj))
|
||||||
|
|
||||||
typedef struct _GstVaapiWindowGLX GstVaapiWindowGLX;
|
typedef struct _GstVaapiWindowGLX GstVaapiWindowGLX;
|
||||||
|
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_glx_new(GstVaapiDisplay *display, guint width, guint height);
|
gst_vaapi_window_glx_new (GstVaapiDisplay * display, guint width, guint height);
|
||||||
|
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_glx_new_with_xid(GstVaapiDisplay *display, Window xid);
|
gst_vaapi_window_glx_new_with_xid (GstVaapiDisplay * display, Window xid);
|
||||||
|
|
||||||
GLXContext
|
GLXContext
|
||||||
gst_vaapi_window_glx_get_context(GstVaapiWindowGLX *window);
|
gst_vaapi_window_glx_get_context (GstVaapiWindowGLX * window);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_glx_set_context(GstVaapiWindowGLX *window, GLXContext ctx);
|
gst_vaapi_window_glx_set_context (GstVaapiWindowGLX * window, GLXContext ctx);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_glx_make_current(GstVaapiWindowGLX *window);
|
gst_vaapi_window_glx_make_current (GstVaapiWindowGLX * window);
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_window_glx_swap_buffers(GstVaapiWindowGLX *window);
|
gst_vaapi_window_glx_swap_buffers (GstVaapiWindowGLX * window);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_glx_put_texture(
|
gst_vaapi_window_glx_put_texture (GstVaapiWindowGLX * window,
|
||||||
GstVaapiWindowGLX *window,
|
GstVaapiTexture * texture, const GstVaapiRectangle * src_rect,
|
||||||
GstVaapiTexture *texture,
|
const GstVaapiRectangle * dst_rect);
|
||||||
const GstVaapiRectangle *src_rect,
|
|
||||||
const GstVaapiRectangle *dst_rect
|
|
||||||
);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -36,40 +36,41 @@ G_BEGIN_DECLS
|
||||||
GST_VAAPI_WINDOW_CLASS(GST_VAAPI_OBJECT_GET_CLASS(obj))
|
GST_VAAPI_WINDOW_CLASS(GST_VAAPI_OBJECT_GET_CLASS(obj))
|
||||||
|
|
||||||
/* GstVaapiWindowClass hooks */
|
/* GstVaapiWindowClass hooks */
|
||||||
typedef gboolean (*GstVaapiWindowCreateFunc) (GstVaapiWindow *window,
|
typedef gboolean (*GstVaapiWindowCreateFunc) (GstVaapiWindow * window,
|
||||||
guint *width, guint *height);
|
guint * width, guint * height);
|
||||||
typedef gboolean (*GstVaapiWindowShowFunc) (GstVaapiWindow *window);
|
typedef gboolean (*GstVaapiWindowShowFunc) (GstVaapiWindow * window);
|
||||||
typedef gboolean (*GstVaapiWindowHideFunc) (GstVaapiWindow *window);
|
typedef gboolean (*GstVaapiWindowHideFunc) (GstVaapiWindow * window);
|
||||||
typedef gboolean (*GstVaapiWindowGetGeometryFunc)(GstVaapiWindow *window,
|
typedef gboolean (*GstVaapiWindowGetGeometryFunc) (GstVaapiWindow * window,
|
||||||
gint *px, gint *py, guint *pwidth, guint *pheight);
|
gint * px, gint * py, guint * pwidth, guint * pheight);
|
||||||
typedef gboolean (*GstVaapiWindowSetFullscreenFunc)(GstVaapiWindow *window,
|
typedef gboolean (*GstVaapiWindowSetFullscreenFunc) (GstVaapiWindow * window,
|
||||||
gboolean fullscreen);
|
gboolean fullscreen);
|
||||||
typedef gboolean (*GstVaapiWindowResizeFunc) (GstVaapiWindow *window,
|
typedef gboolean (*GstVaapiWindowResizeFunc) (GstVaapiWindow * window,
|
||||||
guint width, guint height);
|
guint width, guint height);
|
||||||
typedef gboolean (*GstVaapiWindowRenderFunc) (GstVaapiWindow *window,
|
typedef gboolean (*GstVaapiWindowRenderFunc) (GstVaapiWindow * window,
|
||||||
GstVaapiSurface *surface, const GstVaapiRectangle *src_rect,
|
GstVaapiSurface * surface, const GstVaapiRectangle * src_rect,
|
||||||
const GstVaapiRectangle *dst_rect, guint flags);
|
const GstVaapiRectangle * dst_rect, guint flags);
|
||||||
typedef gboolean (*GstVaapiWindowRenderPixmapFunc)(GstVaapiWindow *window,
|
typedef gboolean (*GstVaapiWindowRenderPixmapFunc) (GstVaapiWindow * window,
|
||||||
GstVaapiPixmap *pixmap, const GstVaapiRectangle *src_rect,
|
GstVaapiPixmap * pixmap, const GstVaapiRectangle * src_rect,
|
||||||
const GstVaapiRectangle *dst_rect);
|
const GstVaapiRectangle * dst_rect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstVaapiWindow:
|
* GstVaapiWindow:
|
||||||
*
|
*
|
||||||
* Base class for system-dependent windows.
|
* Base class for system-dependent windows.
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiWindow {
|
struct _GstVaapiWindow
|
||||||
/*< private >*/
|
{
|
||||||
GstVaapiObject parent_instance;
|
/*< private >*/
|
||||||
|
GstVaapiObject parent_instance;
|
||||||
|
|
||||||
/*< protected >*/
|
/*< protected >*/
|
||||||
guint width;
|
guint width;
|
||||||
guint height;
|
guint height;
|
||||||
guint display_width;
|
guint display_width;
|
||||||
guint display_height;
|
guint display_height;
|
||||||
guint use_foreign_window : 1;
|
guint use_foreign_window:1;
|
||||||
guint is_fullscreen : 1;
|
guint is_fullscreen:1;
|
||||||
guint check_geometry : 1;
|
guint check_geometry:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,28 +85,29 @@ struct _GstVaapiWindow {
|
||||||
*
|
*
|
||||||
* Base class for system-dependent windows.
|
* Base class for system-dependent windows.
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiWindowClass {
|
struct _GstVaapiWindowClass
|
||||||
/*< private >*/
|
{
|
||||||
GstVaapiObjectClass parent_class;
|
/*< private >*/
|
||||||
|
GstVaapiObjectClass parent_class;
|
||||||
|
|
||||||
/*< protected >*/
|
/*< protected >*/
|
||||||
GstVaapiWindowCreateFunc create;
|
GstVaapiWindowCreateFunc create;
|
||||||
GstVaapiWindowShowFunc show;
|
GstVaapiWindowShowFunc show;
|
||||||
GstVaapiWindowHideFunc hide;
|
GstVaapiWindowHideFunc hide;
|
||||||
GstVaapiWindowGetGeometryFunc get_geometry;
|
GstVaapiWindowGetGeometryFunc get_geometry;
|
||||||
GstVaapiWindowSetFullscreenFunc set_fullscreen;
|
GstVaapiWindowSetFullscreenFunc set_fullscreen;
|
||||||
GstVaapiWindowResizeFunc resize;
|
GstVaapiWindowResizeFunc resize;
|
||||||
GstVaapiWindowRenderFunc render;
|
GstVaapiWindowRenderFunc render;
|
||||||
GstVaapiWindowRenderPixmapFunc render_pixmap;
|
GstVaapiWindowRenderPixmapFunc render_pixmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_new(const GstVaapiWindowClass *window_class,
|
gst_vaapi_window_new (const GstVaapiWindowClass * window_class,
|
||||||
GstVaapiDisplay *display, guint width, guint height);
|
GstVaapiDisplay * display, guint width, guint height);
|
||||||
|
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_new_from_native(const GstVaapiWindowClass *window_class,
|
gst_vaapi_window_new_from_native (const GstVaapiWindowClass *
|
||||||
GstVaapiDisplay *display, gpointer native_window);
|
window_class, GstVaapiDisplay * display, gpointer native_window);
|
||||||
|
|
||||||
/* Inline reference counting for core libgstvaapi library */
|
/* Inline reference counting for core libgstvaapi library */
|
||||||
#ifdef IN_LIBGSTVAAPI_CORE
|
#ifdef IN_LIBGSTVAAPI_CORE
|
||||||
|
|
|
@ -46,73 +46,74 @@
|
||||||
#define GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(obj) \
|
#define GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(obj) \
|
||||||
(&GST_VAAPI_WINDOW_WAYLAND_CAST(obj)->priv)
|
(&GST_VAAPI_WINDOW_WAYLAND_CAST(obj)->priv)
|
||||||
|
|
||||||
typedef struct _GstVaapiWindowWaylandPrivate GstVaapiWindowWaylandPrivate;
|
typedef struct _GstVaapiWindowWaylandPrivate GstVaapiWindowWaylandPrivate;
|
||||||
typedef struct _GstVaapiWindowWaylandClass GstVaapiWindowWaylandClass;
|
typedef struct _GstVaapiWindowWaylandClass GstVaapiWindowWaylandClass;
|
||||||
typedef struct _FrameState FrameState;
|
typedef struct _FrameState FrameState;
|
||||||
|
|
||||||
struct _FrameState {
|
struct _FrameState
|
||||||
GstVaapiWindow *window;
|
{
|
||||||
GstVaapiSurface *surface;
|
GstVaapiWindow *window;
|
||||||
GstVaapiVideoPool *surface_pool;
|
GstVaapiSurface *surface;
|
||||||
struct wl_buffer *buffer;
|
GstVaapiVideoPool *surface_pool;
|
||||||
struct wl_callback *callback;
|
struct wl_buffer *buffer;
|
||||||
|
struct wl_callback *callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
static FrameState *
|
static FrameState *
|
||||||
frame_state_new(GstVaapiWindow *window)
|
frame_state_new (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
FrameState *frame;
|
FrameState *frame;
|
||||||
|
|
||||||
frame = g_slice_new(FrameState);
|
frame = g_slice_new (FrameState);
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
frame->window = window;
|
frame->window = window;
|
||||||
frame->surface = NULL;
|
frame->surface = NULL;
|
||||||
frame->surface_pool = NULL;
|
frame->surface_pool = NULL;
|
||||||
frame->buffer = NULL;
|
frame->buffer = NULL;
|
||||||
frame->callback = NULL;
|
frame->callback = NULL;
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
frame_state_free(FrameState *frame)
|
frame_state_free (FrameState * frame)
|
||||||
{
|
{
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (frame->surface) {
|
if (frame->surface) {
|
||||||
if (frame->surface_pool)
|
if (frame->surface_pool)
|
||||||
gst_vaapi_video_pool_put_object(frame->surface_pool,
|
gst_vaapi_video_pool_put_object (frame->surface_pool, frame->surface);
|
||||||
frame->surface);
|
frame->surface = NULL;
|
||||||
frame->surface = NULL;
|
}
|
||||||
}
|
gst_vaapi_video_pool_replace (&frame->surface_pool, NULL);
|
||||||
gst_vaapi_video_pool_replace(&frame->surface_pool, NULL);
|
|
||||||
|
|
||||||
if (frame->buffer) {
|
if (frame->buffer) {
|
||||||
wl_buffer_destroy(frame->buffer);
|
wl_buffer_destroy (frame->buffer);
|
||||||
frame->buffer = NULL;
|
frame->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame->callback) {
|
if (frame->callback) {
|
||||||
wl_callback_destroy(frame->callback);
|
wl_callback_destroy (frame->callback);
|
||||||
frame->callback = NULL;
|
frame->callback = NULL;
|
||||||
}
|
}
|
||||||
g_slice_free(FrameState, frame);
|
g_slice_free (FrameState, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct _GstVaapiWindowWaylandPrivate {
|
struct _GstVaapiWindowWaylandPrivate
|
||||||
struct wl_shell_surface *shell_surface;
|
{
|
||||||
struct wl_surface *surface;
|
struct wl_shell_surface *shell_surface;
|
||||||
struct wl_region *opaque_region;
|
struct wl_surface *surface;
|
||||||
struct wl_event_queue *event_queue;
|
struct wl_region *opaque_region;
|
||||||
FrameState *frame;
|
struct wl_event_queue *event_queue;
|
||||||
GstVideoFormat surface_format;
|
FrameState *frame;
|
||||||
GstVaapiVideoPool *surface_pool;
|
GstVideoFormat surface_format;
|
||||||
GstVaapiFilter *filter;
|
GstVaapiVideoPool *surface_pool;
|
||||||
guint is_shown : 1;
|
GstVaapiFilter *filter;
|
||||||
guint fullscreen_on_show : 1;
|
guint is_shown:1;
|
||||||
guint use_vpp : 1;
|
guint fullscreen_on_show:1;
|
||||||
|
guint use_vpp:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,11 +121,12 @@ struct _GstVaapiWindowWaylandPrivate {
|
||||||
*
|
*
|
||||||
* A Wayland window abstraction.
|
* A Wayland window abstraction.
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiWindowWayland {
|
struct _GstVaapiWindowWayland
|
||||||
/*< private >*/
|
{
|
||||||
GstVaapiWindow parent_instance;
|
/*< private >*/
|
||||||
|
GstVaapiWindow parent_instance;
|
||||||
|
|
||||||
GstVaapiWindowWaylandPrivate priv;
|
GstVaapiWindowWaylandPrivate priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,419 +134,394 @@ struct _GstVaapiWindowWayland {
|
||||||
*
|
*
|
||||||
* An Wayland #Window wrapper class.
|
* An Wayland #Window wrapper class.
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiWindowWaylandClass {
|
struct _GstVaapiWindowWaylandClass
|
||||||
/*< private >*/
|
{
|
||||||
GstVaapiWindowClass parent_class;
|
/*< private >*/
|
||||||
|
GstVaapiWindowClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
static gboolean
|
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
|
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
|
static gboolean
|
||||||
gst_vaapi_window_wayland_sync(GstVaapiWindow *window)
|
gst_vaapi_window_wayland_sync (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
GstVaapiWindowWaylandPrivate * const priv =
|
GstVaapiWindowWaylandPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
|
||||||
|
|
||||||
if (priv->frame) {
|
if (priv->frame) {
|
||||||
struct wl_display * const wl_display =
|
struct wl_display *const wl_display = GST_VAAPI_OBJECT_WL_DISPLAY (window);
|
||||||
GST_VAAPI_OBJECT_WL_DISPLAY(window);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (wl_display_dispatch_queue(wl_display, priv->event_queue) < 0)
|
if (wl_display_dispatch_queue (wl_display, priv->event_queue) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} while (priv->frame);
|
} while (priv->frame);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_ping(void *data, struct wl_shell_surface *shell_surface,
|
handle_ping (void *data, struct wl_shell_surface *shell_surface,
|
||||||
uint32_t serial)
|
uint32_t serial)
|
||||||
{
|
{
|
||||||
wl_shell_surface_pong(shell_surface, serial);
|
wl_shell_surface_pong (shell_surface, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_configure(void *data, struct wl_shell_surface *shell_surface,
|
handle_configure (void *data, struct wl_shell_surface *shell_surface,
|
||||||
uint32_t edges, int32_t width, int32_t height)
|
uint32_t edges, int32_t width, int32_t height)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 = {
|
static const struct wl_shell_surface_listener shell_surface_listener = {
|
||||||
handle_ping,
|
handle_ping,
|
||||||
handle_configure,
|
handle_configure,
|
||||||
handle_popup_done
|
handle_popup_done
|
||||||
};
|
};
|
||||||
|
|
||||||
static gboolean
|
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 =
|
GstVaapiWindowWaylandPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
|
||||||
|
|
||||||
if (!priv->is_shown) {
|
|
||||||
priv->fullscreen_on_show = fullscreen;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fullscreen)
|
|
||||||
wl_shell_surface_set_toplevel(priv->shell_surface);
|
|
||||||
else {
|
|
||||||
wl_shell_surface_set_fullscreen(
|
|
||||||
priv->shell_surface,
|
|
||||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
|
|
||||||
0,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!priv->is_shown) {
|
||||||
|
priv->fullscreen_on_show = fullscreen;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fullscreen)
|
||||||
|
wl_shell_surface_set_toplevel (priv->shell_surface);
|
||||||
|
else {
|
||||||
|
wl_shell_surface_set_fullscreen (priv->shell_surface,
|
||||||
|
WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapi_window_wayland_create(
|
gst_vaapi_window_wayland_create (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
guint * width, guint * height)
|
||||||
guint *width,
|
|
||||||
guint *height
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstVaapiWindowWaylandPrivate * const priv =
|
GstVaapiWindowWaylandPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
|
||||||
GstVaapiDisplayWaylandPrivate * const priv_display =
|
GstVaapiDisplayWaylandPrivate *const priv_display =
|
||||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(GST_VAAPI_OBJECT_DISPLAY(window));
|
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (GST_VAAPI_OBJECT_DISPLAY (window));
|
||||||
|
|
||||||
GST_DEBUG("create window, size %ux%u", *width, *height);
|
GST_DEBUG ("create window, size %ux%u", *width, *height);
|
||||||
|
|
||||||
g_return_val_if_fail(priv_display->compositor != NULL, FALSE);
|
g_return_val_if_fail (priv_display->compositor != NULL, FALSE);
|
||||||
g_return_val_if_fail(priv_display->shell != NULL, FALSE);
|
g_return_val_if_fail (priv_display->shell != NULL, FALSE);
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
priv->event_queue = wl_display_create_queue(priv_display->wl_display);
|
priv->event_queue = wl_display_create_queue (priv_display->wl_display);
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
if (!priv->event_queue)
|
if (!priv->event_queue)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
priv->surface = wl_compositor_create_surface(priv_display->compositor);
|
priv->surface = wl_compositor_create_surface (priv_display->compositor);
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
if (!priv->surface)
|
if (!priv->surface)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
wl_proxy_set_queue((struct wl_proxy *)priv->surface, priv->event_queue);
|
wl_proxy_set_queue ((struct wl_proxy *) priv->surface, priv->event_queue);
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
priv->shell_surface =
|
priv->shell_surface =
|
||||||
wl_shell_get_shell_surface(priv_display->shell, priv->surface);
|
wl_shell_get_shell_surface (priv_display->shell, priv->surface);
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
if (!priv->shell_surface)
|
if (!priv->shell_surface)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
wl_proxy_set_queue((struct wl_proxy *)priv->shell_surface,
|
wl_proxy_set_queue ((struct wl_proxy *) priv->shell_surface,
|
||||||
priv->event_queue);
|
priv->event_queue);
|
||||||
|
|
||||||
wl_shell_surface_add_listener(priv->shell_surface,
|
wl_shell_surface_add_listener (priv->shell_surface,
|
||||||
&shell_surface_listener, priv);
|
&shell_surface_listener, priv);
|
||||||
wl_shell_surface_set_toplevel(priv->shell_surface);
|
wl_shell_surface_set_toplevel (priv->shell_surface);
|
||||||
|
|
||||||
if (priv->fullscreen_on_show)
|
if (priv->fullscreen_on_show)
|
||||||
gst_vaapi_window_wayland_set_fullscreen(window, TRUE);
|
gst_vaapi_window_wayland_set_fullscreen (window, TRUE);
|
||||||
|
|
||||||
priv->surface_format = GST_VIDEO_FORMAT_ENCODED;
|
priv->surface_format = GST_VIDEO_FORMAT_ENCODED;
|
||||||
priv->use_vpp = GST_VAAPI_DISPLAY_HAS_VPP(GST_VAAPI_OBJECT_DISPLAY(window));
|
priv->use_vpp = GST_VAAPI_DISPLAY_HAS_VPP (GST_VAAPI_OBJECT_DISPLAY (window));
|
||||||
priv->is_shown = TRUE;
|
priv->is_shown = TRUE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_window_wayland_destroy(GstVaapiWindow * window)
|
gst_vaapi_window_wayland_destroy (GstVaapiWindow * window)
|
||||||
{
|
{
|
||||||
GstVaapiWindowWaylandPrivate * const priv =
|
GstVaapiWindowWaylandPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
|
||||||
|
|
||||||
if (priv->frame) {
|
if (priv->frame) {
|
||||||
frame_state_free(priv->frame);
|
frame_state_free (priv->frame);
|
||||||
priv->frame = NULL;
|
priv->frame = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->shell_surface) {
|
if (priv->shell_surface) {
|
||||||
wl_shell_surface_destroy(priv->shell_surface);
|
wl_shell_surface_destroy (priv->shell_surface);
|
||||||
priv->shell_surface = NULL;
|
priv->shell_surface = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->surface) {
|
if (priv->surface) {
|
||||||
wl_surface_destroy(priv->surface);
|
wl_surface_destroy (priv->surface);
|
||||||
priv->surface = NULL;
|
priv->surface = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->event_queue) {
|
if (priv->event_queue) {
|
||||||
wl_event_queue_destroy(priv->event_queue);
|
wl_event_queue_destroy (priv->event_queue);
|
||||||
priv->event_queue = NULL;
|
priv->event_queue = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_vaapi_filter_replace(&priv->filter, NULL);
|
gst_vaapi_filter_replace (&priv->filter, NULL);
|
||||||
gst_vaapi_video_pool_replace(&priv->surface_pool, NULL);
|
gst_vaapi_video_pool_replace (&priv->surface_pool, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapi_window_wayland_resize(
|
gst_vaapi_window_wayland_resize (GstVaapiWindow * window,
|
||||||
GstVaapiWindow * window,
|
guint width, guint height)
|
||||||
guint width,
|
|
||||||
guint height
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstVaapiWindowWaylandPrivate * const priv =
|
GstVaapiWindowWaylandPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
|
||||||
GstVaapiDisplayWaylandPrivate * const priv_display =
|
GstVaapiDisplayWaylandPrivate *const priv_display =
|
||||||
GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE(GST_VAAPI_OBJECT_DISPLAY(window));
|
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)
|
if (priv->opaque_region)
|
||||||
wl_region_destroy(priv->opaque_region);
|
wl_region_destroy (priv->opaque_region);
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
priv->opaque_region = wl_compositor_create_region(priv_display->compositor);
|
priv->opaque_region = wl_compositor_create_region (priv_display->compositor);
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
wl_region_add(priv->opaque_region, 0, 0, width, height);
|
wl_region_add (priv->opaque_region, 0, 0, width, height);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
FrameState *const frame = data;
|
||||||
GstVaapiWindowWaylandPrivate * const priv =
|
GstVaapiWindowWaylandPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(frame->window);
|
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (frame->window);
|
||||||
|
|
||||||
frame_state_free(frame);
|
frame_state_free (frame);
|
||||||
if (priv->frame == frame)
|
if (priv->frame == frame)
|
||||||
priv->frame = NULL;
|
priv->frame = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_callback_listener frame_callback_listener = {
|
static const struct wl_callback_listener frame_callback_listener = {
|
||||||
frame_redraw_callback
|
frame_redraw_callback
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstVaapiSurface *
|
static GstVaapiSurface *
|
||||||
vpp_convert(
|
vpp_convert (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
GstVaapiSurface * surface,
|
||||||
GstVaapiSurface *surface,
|
const GstVaapiRectangle * src_rect,
|
||||||
const GstVaapiRectangle *src_rect,
|
const GstVaapiRectangle * dst_rect, guint flags)
|
||||||
const GstVaapiRectangle *dst_rect,
|
|
||||||
guint flags
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstVaapiWindowWaylandPrivate * const priv =
|
GstVaapiWindowWaylandPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
|
||||||
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_DISPLAY(window);
|
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (window);
|
||||||
GstVaapiSurface *vpp_surface = NULL;
|
GstVaapiSurface *vpp_surface = NULL;
|
||||||
GstVaapiFilterStatus status;
|
GstVaapiFilterStatus status;
|
||||||
GstVideoInfo vi;
|
GstVideoInfo vi;
|
||||||
|
|
||||||
/* Ensure VA surface pool is created */
|
/* Ensure VA surface pool is created */
|
||||||
/* XXX: optimize the surface format to use. e.g. YUY2 */
|
/* XXX: optimize the surface format to use. e.g. YUY2 */
|
||||||
if (!priv->surface_pool) {
|
if (!priv->surface_pool) {
|
||||||
gst_video_info_set_format(&vi, priv->surface_format,
|
gst_video_info_set_format (&vi, priv->surface_format,
|
||||||
window->width, window->height);
|
window->width, window->height);
|
||||||
priv->surface_pool = gst_vaapi_surface_pool_new(display, &vi);
|
priv->surface_pool = gst_vaapi_surface_pool_new (display, &vi);
|
||||||
if (!priv->surface_pool)
|
if (!priv->surface_pool)
|
||||||
return NULL;
|
return NULL;
|
||||||
gst_vaapi_filter_replace(&priv->filter, NULL);
|
gst_vaapi_filter_replace (&priv->filter, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure VPP pipeline is built */
|
/* Ensure VPP pipeline is built */
|
||||||
if (!priv->filter) {
|
if (!priv->filter) {
|
||||||
priv->filter = gst_vaapi_filter_new(display);
|
priv->filter = gst_vaapi_filter_new (display);
|
||||||
if (!priv->filter)
|
if (!priv->filter)
|
||||||
goto error_create_filter;
|
goto error_create_filter;
|
||||||
if (!gst_vaapi_filter_set_format(priv->filter, priv->surface_format))
|
if (!gst_vaapi_filter_set_format (priv->filter, priv->surface_format))
|
||||||
goto error_unsupported_format;
|
goto error_unsupported_format;
|
||||||
}
|
}
|
||||||
if (!gst_vaapi_filter_set_cropping_rectangle(priv->filter, src_rect))
|
if (!gst_vaapi_filter_set_cropping_rectangle (priv->filter, src_rect))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!gst_vaapi_filter_set_target_rectangle(priv->filter, dst_rect))
|
if (!gst_vaapi_filter_set_target_rectangle (priv->filter, dst_rect))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Post-process the decoded source surface */
|
/* Post-process the decoded source surface */
|
||||||
vpp_surface = gst_vaapi_video_pool_get_object(priv->surface_pool);
|
vpp_surface = gst_vaapi_video_pool_get_object (priv->surface_pool);
|
||||||
if (!vpp_surface)
|
if (!vpp_surface)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
status = gst_vaapi_filter_process(priv->filter, surface, vpp_surface,
|
status = gst_vaapi_filter_process (priv->filter, surface, vpp_surface, flags);
|
||||||
flags);
|
if (status != GST_VAAPI_FILTER_STATUS_SUCCESS)
|
||||||
if (status != GST_VAAPI_FILTER_STATUS_SUCCESS)
|
goto error_process_filter;
|
||||||
goto error_process_filter;
|
return vpp_surface;
|
||||||
return vpp_surface;
|
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
error_create_filter:
|
error_create_filter:
|
||||||
GST_WARNING("failed to create VPP filter. Disabling");
|
GST_WARNING ("failed to create VPP filter. Disabling");
|
||||||
priv->use_vpp = FALSE;
|
priv->use_vpp = FALSE;
|
||||||
return NULL;
|
return NULL;
|
||||||
error_unsupported_format:
|
error_unsupported_format:
|
||||||
GST_ERROR("unsupported render target format %s",
|
GST_ERROR ("unsupported render target format %s",
|
||||||
gst_vaapi_video_format_to_string(priv->surface_format));
|
gst_vaapi_video_format_to_string (priv->surface_format));
|
||||||
priv->use_vpp = FALSE;
|
priv->use_vpp = FALSE;
|
||||||
return NULL;
|
return NULL;
|
||||||
error_process_filter:
|
error_process_filter:
|
||||||
GST_ERROR("failed to process surface %" GST_VAAPI_ID_FORMAT " (error %d)",
|
GST_ERROR ("failed to process surface %" GST_VAAPI_ID_FORMAT " (error %d)",
|
||||||
GST_VAAPI_ID_ARGS(GST_VAAPI_OBJECT_ID(surface)), status);
|
GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (surface)), status);
|
||||||
gst_vaapi_video_pool_put_object(priv->surface_pool, vpp_surface);
|
gst_vaapi_video_pool_put_object (priv->surface_pool, vpp_surface);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapi_window_wayland_render(
|
gst_vaapi_window_wayland_render (GstVaapiWindow * window,
|
||||||
GstVaapiWindow *window,
|
GstVaapiSurface * surface,
|
||||||
GstVaapiSurface *surface,
|
const GstVaapiRectangle * src_rect,
|
||||||
const GstVaapiRectangle *src_rect,
|
const GstVaapiRectangle * dst_rect, guint flags)
|
||||||
const GstVaapiRectangle *dst_rect,
|
|
||||||
guint flags
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstVaapiWindowWaylandPrivate * const priv =
|
GstVaapiWindowWaylandPrivate *const priv =
|
||||||
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE(window);
|
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
|
||||||
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_DISPLAY(window);
|
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (window);
|
||||||
struct wl_display * const wl_display = GST_VAAPI_OBJECT_WL_DISPLAY(window);
|
struct wl_display *const wl_display = GST_VAAPI_OBJECT_WL_DISPLAY (window);
|
||||||
struct wl_buffer *buffer;
|
struct wl_buffer *buffer;
|
||||||
FrameState *frame;
|
FrameState *frame;
|
||||||
guint width, height, va_flags;
|
guint width, height, va_flags;
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
gboolean need_vpp = FALSE;
|
gboolean need_vpp = FALSE;
|
||||||
|
|
||||||
/* Check that we don't need to crop source VA surface */
|
/* Check that we don't need to crop source VA surface */
|
||||||
gst_vaapi_surface_get_size(surface, &width, &height);
|
gst_vaapi_surface_get_size (surface, &width, &height);
|
||||||
if (src_rect->x != 0 || src_rect->y != 0)
|
if (src_rect->x != 0 || src_rect->y != 0)
|
||||||
need_vpp = TRUE;
|
need_vpp = TRUE;
|
||||||
if (src_rect->width != width || src_rect->height != height)
|
if (src_rect->width != width || src_rect->height != height)
|
||||||
need_vpp = TRUE;
|
need_vpp = TRUE;
|
||||||
|
|
||||||
/* Check that we don't render to a subregion of this window */
|
/* Check that we don't render to a subregion of this window */
|
||||||
if (dst_rect->x != 0 || dst_rect->y != 0)
|
if (dst_rect->x != 0 || dst_rect->y != 0)
|
||||||
need_vpp = TRUE;
|
need_vpp = TRUE;
|
||||||
if (dst_rect->width != window->width || dst_rect->height != window->height)
|
if (dst_rect->width != window->width || dst_rect->height != window->height)
|
||||||
need_vpp = TRUE;
|
need_vpp = TRUE;
|
||||||
|
|
||||||
/* Try to construct a Wayland buffer from VA surface as is (without VPP) */
|
/* Try to construct a Wayland buffer from VA surface as is (without VPP) */
|
||||||
if (!need_vpp) {
|
if (!need_vpp) {
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
va_flags = from_GstVaapiSurfaceRenderFlags(flags);
|
va_flags = from_GstVaapiSurfaceRenderFlags (flags);
|
||||||
status = vaGetSurfaceBufferWl(
|
status = vaGetSurfaceBufferWl (GST_VAAPI_DISPLAY_VADISPLAY (display),
|
||||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
GST_VAAPI_OBJECT_ID (surface),
|
||||||
GST_VAAPI_OBJECT_ID(surface),
|
va_flags & (VA_TOP_FIELD | VA_BOTTOM_FIELD), &buffer);
|
||||||
va_flags & (VA_TOP_FIELD|VA_BOTTOM_FIELD),
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
&buffer
|
if (status == VA_STATUS_ERROR_FLAG_NOT_SUPPORTED)
|
||||||
);
|
need_vpp = TRUE;
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
else if (!vaapi_check_status (status, "vaGetSurfaceBufferWl()"))
|
||||||
if (status == VA_STATUS_ERROR_FLAG_NOT_SUPPORTED)
|
return FALSE;
|
||||||
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 */
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
if (need_vpp) {
|
status = vaGetSurfaceBufferWl (GST_VAAPI_DISPLAY_VADISPLAY (display),
|
||||||
if (priv->use_vpp) {
|
GST_VAAPI_OBJECT_ID (surface), VA_FRAME_PICTURE, &buffer);
|
||||||
GstVaapiSurface * const vpp_surface =
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
vpp_convert(window, surface, src_rect, dst_rect, flags);
|
if (!vaapi_check_status (status, "vaGetSurfaceBufferWl()"))
|
||||||
if (G_UNLIKELY(!vpp_surface))
|
return FALSE;
|
||||||
need_vpp = FALSE;
|
}
|
||||||
else {
|
|
||||||
surface = vpp_surface;
|
|
||||||
width = window->width;
|
|
||||||
height = window->height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
/* Wait for the previous frame to complete redraw */
|
||||||
status = vaGetSurfaceBufferWl(
|
if (!gst_vaapi_window_wayland_sync (window))
|
||||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
return FALSE;
|
||||||
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 */
|
frame = frame_state_new (window);
|
||||||
if (!gst_vaapi_window_wayland_sync(window))
|
if (!frame)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
priv->frame = frame;
|
||||||
|
|
||||||
frame = frame_state_new(window);
|
if (need_vpp && priv->use_vpp) {
|
||||||
if (!frame)
|
frame->surface = surface;
|
||||||
return FALSE;
|
frame->surface_pool = gst_vaapi_video_pool_ref (priv->surface_pool);
|
||||||
priv->frame = frame;
|
}
|
||||||
|
|
||||||
if (need_vpp && priv->use_vpp) {
|
/* XXX: attach to the specified target rectangle */
|
||||||
frame->surface = surface;
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
|
||||||
frame->surface_pool = gst_vaapi_video_pool_ref(priv->surface_pool);
|
wl_surface_attach (priv->surface, buffer, 0, 0);
|
||||||
}
|
wl_surface_damage (priv->surface, 0, 0, width, height);
|
||||||
|
|
||||||
/* XXX: attach to the specified target rectangle */
|
if (priv->opaque_region) {
|
||||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(window);
|
wl_surface_set_opaque_region (priv->surface, priv->opaque_region);
|
||||||
wl_surface_attach(priv->surface, buffer, 0, 0);
|
wl_region_destroy (priv->opaque_region);
|
||||||
wl_surface_damage(priv->surface, 0, 0, width, height);
|
priv->opaque_region = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->opaque_region) {
|
frame->buffer = buffer;
|
||||||
wl_surface_set_opaque_region(priv->surface, priv->opaque_region);
|
frame->callback = wl_surface_frame (priv->surface);
|
||||||
wl_region_destroy(priv->opaque_region);
|
wl_callback_add_listener (frame->callback, &frame_callback_listener, frame);
|
||||||
priv->opaque_region = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->buffer = buffer;
|
wl_surface_commit (priv->surface);
|
||||||
frame->callback = wl_surface_frame(priv->surface);
|
wl_display_flush (wl_display);
|
||||||
wl_callback_add_listener(frame->callback, &frame_callback_listener, frame);
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
|
||||||
|
return TRUE;
|
||||||
wl_surface_commit(priv->surface);
|
|
||||||
wl_display_flush(wl_display);
|
|
||||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
GstVaapiObjectClass *const object_class = GST_VAAPI_OBJECT_CLASS (klass);
|
||||||
GstVaapiWindowClass * const window_class = GST_VAAPI_WINDOW_CLASS(klass);
|
GstVaapiWindowClass *const window_class = GST_VAAPI_WINDOW_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = (GstVaapiObjectFinalizeFunc)
|
object_class->finalize = (GstVaapiObjectFinalizeFunc)
|
||||||
gst_vaapi_window_wayland_destroy;
|
gst_vaapi_window_wayland_destroy;
|
||||||
|
|
||||||
window_class->create = gst_vaapi_window_wayland_create;
|
window_class->create = gst_vaapi_window_wayland_create;
|
||||||
window_class->show = gst_vaapi_window_wayland_show;
|
window_class->show = gst_vaapi_window_wayland_show;
|
||||||
window_class->hide = gst_vaapi_window_wayland_hide;
|
window_class->hide = gst_vaapi_window_wayland_hide;
|
||||||
window_class->render = gst_vaapi_window_wayland_render;
|
window_class->render = gst_vaapi_window_wayland_render;
|
||||||
window_class->resize = gst_vaapi_window_wayland_resize;
|
window_class->resize = gst_vaapi_window_wayland_resize;
|
||||||
window_class->set_fullscreen = gst_vaapi_window_wayland_set_fullscreen;
|
window_class->set_fullscreen = gst_vaapi_window_wayland_set_fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define gst_vaapi_window_wayland_finalize \
|
#define gst_vaapi_window_wayland_finalize \
|
||||||
gst_vaapi_window_wayland_destroy
|
gst_vaapi_window_wayland_destroy
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
|
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiWindowWayland,
|
||||||
GstVaapiWindowWayland,
|
gst_vaapi_window_wayland, gst_vaapi_window_wayland_class_init (&g_class));
|
||||||
gst_vaapi_window_wayland,
|
|
||||||
gst_vaapi_window_wayland_class_init(&g_class))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_vaapi_window_wayland_new:
|
* gst_vaapi_window_wayland_new:
|
||||||
|
@ -559,16 +536,14 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
|
||||||
* Return value: the newly allocated #GstVaapiWindow object
|
* Return value: the newly allocated #GstVaapiWindow object
|
||||||
*/
|
*/
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_wayland_new(
|
gst_vaapi_window_wayland_new (GstVaapiDisplay * display,
|
||||||
GstVaapiDisplay *display,
|
guint width, guint height)
|
||||||
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(
|
return
|
||||||
gst_vaapi_window_wayland_class()), display, width, height);
|
gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS
|
||||||
|
(gst_vaapi_window_wayland_class ()), display, width, height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,11 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstVaapiWindowWayland GstVaapiWindowWayland;
|
typedef struct _GstVaapiWindowWayland GstVaapiWindowWayland;
|
||||||
|
|
||||||
GstVaapiWindow *
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -43,19 +43,19 @@ G_BEGIN_DECLS
|
||||||
#define GST_VAAPI_WINDOW_XWINDOW(window) \
|
#define GST_VAAPI_WINDOW_XWINDOW(window) \
|
||||||
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(window))
|
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(window))
|
||||||
|
|
||||||
typedef struct _GstVaapiWindowX11 GstVaapiWindowX11;
|
typedef struct _GstVaapiWindowX11 GstVaapiWindowX11;
|
||||||
|
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_x11_new(GstVaapiDisplay *display, guint width, guint height);
|
gst_vaapi_window_x11_new (GstVaapiDisplay * display, guint width, guint height);
|
||||||
|
|
||||||
GstVaapiWindow *
|
GstVaapiWindow *
|
||||||
gst_vaapi_window_x11_new_with_xid(GstVaapiDisplay *display, Window xid);
|
gst_vaapi_window_x11_new_with_xid (GstVaapiDisplay * display, Window xid);
|
||||||
|
|
||||||
Window
|
Window
|
||||||
gst_vaapi_window_x11_get_xid(GstVaapiWindowX11 *window);
|
gst_vaapi_window_x11_get_xid (GstVaapiWindowX11 * window);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_window_x11_is_foreign_xid(GstVaapiWindowX11 *window);
|
gst_vaapi_window_x11_is_foreign_xid (GstVaapiWindowX11 * window);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -42,18 +42,19 @@ G_BEGIN_DECLS
|
||||||
#define GST_VAAPI_WINDOW_X11_GET_CLASS(obj) \
|
#define GST_VAAPI_WINDOW_X11_GET_CLASS(obj) \
|
||||||
GST_VAAPI_WINDOW_X11_CLASS(GST_VAAPI_WINDOW_GET_CLASS(obj))
|
GST_VAAPI_WINDOW_X11_CLASS(GST_VAAPI_WINDOW_GET_CLASS(obj))
|
||||||
|
|
||||||
typedef struct _GstVaapiWindowX11Private GstVaapiWindowX11Private;
|
typedef struct _GstVaapiWindowX11Private GstVaapiWindowX11Private;
|
||||||
typedef struct _GstVaapiWindowX11Class GstVaapiWindowX11Class;
|
typedef struct _GstVaapiWindowX11Class GstVaapiWindowX11Class;
|
||||||
|
|
||||||
struct _GstVaapiWindowX11Private {
|
struct _GstVaapiWindowX11Private
|
||||||
Atom atom_NET_WM_STATE;
|
{
|
||||||
Atom atom_NET_WM_STATE_FULLSCREEN;
|
Atom atom_NET_WM_STATE;
|
||||||
|
Atom atom_NET_WM_STATE_FULLSCREEN;
|
||||||
#ifdef HAVE_XRENDER
|
#ifdef HAVE_XRENDER
|
||||||
Picture picture;
|
Picture picture;
|
||||||
#endif
|
#endif
|
||||||
guint is_mapped : 1;
|
guint is_mapped:1;
|
||||||
guint fullscreen_on_map : 1;
|
guint fullscreen_on_map:1;
|
||||||
guint has_xrender : 1;
|
guint has_xrender:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,11 +62,12 @@ struct _GstVaapiWindowX11Private {
|
||||||
*
|
*
|
||||||
* An X11 #Window wrapper.
|
* An X11 #Window wrapper.
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiWindowX11 {
|
struct _GstVaapiWindowX11
|
||||||
/*< private >*/
|
{
|
||||||
GstVaapiWindow parent_instance;
|
/*< private >*/
|
||||||
|
GstVaapiWindow parent_instance;
|
||||||
|
|
||||||
GstVaapiWindowX11Private priv;
|
GstVaapiWindowX11Private priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,16 +79,17 @@ struct _GstVaapiWindowX11 {
|
||||||
*
|
*
|
||||||
* An X11 #Window wrapper class.
|
* An X11 #Window wrapper class.
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiWindowX11Class {
|
struct _GstVaapiWindowX11Class
|
||||||
/*< private >*/
|
{
|
||||||
GstVaapiWindowClass parent_class;
|
/*< private >*/
|
||||||
|
GstVaapiWindowClass parent_class;
|
||||||
|
|
||||||
Visual * (*get_visual) (GstVaapiWindow *window);
|
Visual *(*get_visual) (GstVaapiWindow * window);
|
||||||
Colormap (*get_colormap) (GstVaapiWindow *window);
|
Colormap (*get_colormap) (GstVaapiWindow * window);
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_window_x11_class_init(GstVaapiWindowX11Class *klass);
|
gst_vaapi_window_x11_class_init (GstVaapiWindowX11Class * klass);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue