diff --git a/gst-libs/gst/vaapi/Makefile.am b/gst-libs/gst/vaapi/Makefile.am index acf393b06f..205f902583 100644 --- a/gst-libs/gst/vaapi/Makefile.am +++ b/gst-libs/gst/vaapi/Makefile.am @@ -117,7 +117,6 @@ libgstvaapi_source_priv_h = \ gstvaapiobject_priv.h \ gstvaapisurface_priv.h \ gstvaapiutils.h \ - gstvaapivideobuffer_priv.h \ gstvaapiworkarounds.h \ sysdeps.h \ $(NULL) @@ -169,7 +168,6 @@ libgstvaapi_glx_source_c = \ gstvaapiutils.c \ gstvaapiutils_glx.c \ gstvaapiutils_x11.c \ - gstvaapivideobuffer_glx.c \ gstvaapivideoconverter_glx.c \ gstvaapiwindow_glx.c \ $(NULL) @@ -177,7 +175,6 @@ libgstvaapi_glx_source_c = \ libgstvaapi_glx_source_h = \ gstvaapidisplay_glx.h \ gstvaapitexture.h \ - gstvaapivideobuffer_glx.h \ gstvaapivideoconverter_glx.h \ gstvaapiwindow_glx.h \ $(NULL) diff --git a/gst-libs/gst/vaapi/gstvaapivideobuffer.c b/gst-libs/gst/vaapi/gstvaapivideobuffer.c index 987b467d57..994f057370 100644 --- a/gst-libs/gst/vaapi/gstvaapivideobuffer.c +++ b/gst-libs/gst/vaapi/gstvaapivideobuffer.c @@ -27,591 +27,80 @@ #include "sysdeps.h" #include "gstvaapivideobuffer.h" -#include "gstvaapivideobuffer_priv.h" -#include "gstvaapiimagepool.h" -#include "gstvaapisurfacepool.h" -#include "gstvaapiobject_priv.h" #define DEBUG 1 #include "gstvaapidebug.h" -G_DEFINE_TYPE(GstVaapiVideoBuffer, gst_vaapi_video_buffer, GST_TYPE_SURFACE_BUFFER) +G_DEFINE_TYPE(GstVaapiVideoBuffer, + gst_vaapi_video_buffer, + GST_TYPE_SURFACE_BUFFER) -#define GST_VAAPI_VIDEO_BUFFER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ - GST_VAAPI_TYPE_VIDEO_BUFFER, \ - GstVaapiVideoBufferPrivate)) +typedef GstSurfaceConverter *(*GstSurfaceConverterCreateFunc)( + GstSurfaceBuffer *surface, const gchar *type, GValue *dest); -struct _GstVaapiVideoBufferPrivate { - GstVaapiDisplay *display; - GstVaapiVideoPool *image_pool; - GstVaapiImage *image; - GstVaapiVideoPool *surface_pool; - GstVaapiSurface *surface; - GstVaapiSurfaceProxy *proxy; - GstBuffer *buffer; - guint render_flags; -}; - -static void -set_display(GstVaapiVideoBuffer *buffer, GstVaapiDisplay *display) +static GstSurfaceConverter * +gst_vaapi_video_buffer_create_converter(GstSurfaceBuffer *surface, + const gchar *type, GValue *dest) { - GstVaapiVideoBufferPrivate * const priv = buffer->priv; + GstVaapiVideoBuffer * const vbuffer = GST_VAAPI_VIDEO_BUFFER(surface); + GstSurfaceConverterCreateFunc func; - g_clear_object(&priv->display); + func = (GstSurfaceConverterCreateFunc) + gst_vaapi_video_meta_get_surface_converter(vbuffer->meta); - if (display) - priv->display = g_object_ref(display); -} - -static inline void -set_image(GstVaapiVideoBuffer *buffer, GstVaapiImage *image) -{ - buffer->priv->image = g_object_ref(image); - set_display(buffer, GST_VAAPI_OBJECT_DISPLAY(image)); -} - -static inline void -set_surface(GstVaapiVideoBuffer *buffer, GstVaapiSurface *surface) -{ - buffer->priv->surface = g_object_ref(surface); - set_display(buffer, GST_VAAPI_OBJECT_DISPLAY(surface)); -} - -static void -gst_vaapi_video_buffer_destroy_image(GstVaapiVideoBuffer *buffer) -{ - GstVaapiVideoBufferPrivate * const priv = buffer->priv; - - if (priv->image) { - if (priv->image_pool) - gst_vaapi_video_pool_put_object(priv->image_pool, priv->image); - g_object_unref(priv->image); - priv->image = NULL; - } - - g_clear_object(&priv->image_pool); -} - -static void -gst_vaapi_video_buffer_destroy_surface(GstVaapiVideoBuffer *buffer) -{ - GstVaapiVideoBufferPrivate * const priv = buffer->priv; - - gst_vaapi_surface_proxy_replace(&priv->proxy, NULL); - - if (priv->surface) { - if (priv->surface_pool) - gst_vaapi_video_pool_put_object(priv->surface_pool, priv->surface); - g_object_unref(priv->surface); - priv->surface = NULL; - } - - g_clear_object(&priv->surface_pool); - - if (priv->buffer) { - gst_buffer_unref(priv->buffer); - priv->buffer = NULL; - } -} - -static void -gst_vaapi_video_buffer_finalize(GstMiniObject *object) -{ - GstVaapiVideoBuffer * const buffer = GST_VAAPI_VIDEO_BUFFER(object); - GstMiniObjectClass *parent_class; - - gst_vaapi_video_buffer_destroy_image(buffer); - gst_vaapi_video_buffer_destroy_surface(buffer); - - set_display(buffer, NULL); - - parent_class = GST_MINI_OBJECT_CLASS(gst_vaapi_video_buffer_parent_class); - if (parent_class->finalize) - parent_class->finalize(object); + return func ? func(surface, type, dest) : NULL; } static void gst_vaapi_video_buffer_class_init(GstVaapiVideoBufferClass *klass) { - GstMiniObjectClass * const object_class = GST_MINI_OBJECT_CLASS(klass); + GstSurfaceBufferClass * const surface_class = + GST_SURFACE_BUFFER_CLASS(klass); - g_type_class_add_private(klass, sizeof(GstVaapiVideoBufferPrivate)); - - object_class->finalize = gst_vaapi_video_buffer_finalize; + surface_class->create_converter = gst_vaapi_video_buffer_create_converter; } static void gst_vaapi_video_buffer_init(GstVaapiVideoBuffer *buffer) { - GstVaapiVideoBufferPrivate *priv; - - priv = GST_VAAPI_VIDEO_BUFFER_GET_PRIVATE(buffer); - buffer->priv = priv; - priv->display = NULL; - priv->image_pool = NULL; - priv->image = NULL; - priv->surface_pool = NULL; - priv->surface = NULL; - priv->proxy = NULL; - priv->buffer = NULL; - priv->render_flags = 0; -} - -static inline gboolean -gst_vaapi_video_buffer_is_a(GstBuffer *buffer, GType type) -{ - return G_TYPE_CHECK_INSTANCE_TYPE(buffer, type); -} - -static inline gpointer -_gst_vaapi_video_buffer_typed_new(GType type) -{ - g_return_val_if_fail(g_type_is_a(type, GST_VAAPI_TYPE_VIDEO_BUFFER), NULL); - - return gst_mini_object_new(type); } /** - * gst_vaapi_video_buffer_typed_new: - * @display: a #GstVaapiDisplay + * gst_vaapi_video_buffer_new: + * @meta: a #GstVaapiVideoMeta * - * Creates an empty #GstBuffer. The caller is responsible for completing - * the initialization of the buffer with the gst_vaapi_video_buffer_set_*() - * functions. - * - * This function shall only be called from within gstreamer-vaapi - * plugin elements. + * Creates a #GstBuffer that holds video @meta information. * * Return value: the newly allocated #GstBuffer, or %NULL or error */ GstBuffer * -gst_vaapi_video_buffer_typed_new(GType type, GstVaapiDisplay *display) +gst_vaapi_video_buffer_new(GstVaapiVideoMeta *meta) { GstBuffer *buffer; - g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL); + g_return_val_if_fail(meta != NULL, NULL); - buffer = _gst_vaapi_video_buffer_typed_new(type); + buffer = GST_BUFFER_CAST(gst_mini_object_new(GST_TYPE_SURFACE_BUFFER)); if (!buffer) return NULL; - set_display(GST_VAAPI_VIDEO_BUFFER(buffer), display); + gst_buffer_set_vaapi_video_meta(buffer, meta); return buffer; } /** - * gst_vaapi_video_buffer_typed_new_from_pool: - * @pool: a #GstVaapiVideoPool - * - * Creates a #GstBuffer with a video object allocated from a @pool. - * Only #GstVaapiSurfacePool and #GstVaapiImagePool pools are supported. - * - * The buffer is destroyed through the last call to gst_buffer_unref() - * and the video objects are pushed back to their respective pools. - * - * Return value: the newly allocated #GstBuffer, or %NULL on error - */ -GstBuffer * -gst_vaapi_video_buffer_typed_new_from_pool(GType type, GstVaapiVideoPool *pool) -{ - GstVaapiVideoBuffer *buffer; - gboolean is_image_pool, is_surface_pool; - - g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), NULL); - - is_image_pool = GST_VAAPI_IS_IMAGE_POOL(pool); - is_surface_pool = GST_VAAPI_IS_SURFACE_POOL(pool); - - if (!is_image_pool && !is_surface_pool) - return NULL; - - buffer = _gst_vaapi_video_buffer_typed_new(type); - if (buffer && - ((is_image_pool && - gst_vaapi_video_buffer_set_image_from_pool(buffer, pool)) || - (is_surface_pool && - gst_vaapi_video_buffer_set_surface_from_pool(buffer, pool)))) { - set_display(buffer, gst_vaapi_video_pool_get_display(pool)); - return GST_BUFFER(buffer); - } - - gst_mini_object_unref(GST_MINI_OBJECT(buffer)); - return NULL; -} - -/** - * gst_vaapi_video_buffer_typed_new_from_buffer: - * @buffer: a #GstBuffer - * - * Creates a #GstBuffer with video objects bound to @buffer video - * objects, if any. - * - * This function shall only be called from within gstreamer-vaapi - * plugin elements. - * - * Return value: the newly allocated #GstBuffer, or %NULL on error - */ -GstBuffer * -gst_vaapi_video_buffer_typed_new_from_buffer(GType type, GstBuffer *buffer) -{ - GstVaapiVideoBuffer *inbuf, *outbuf; - - if (!gst_vaapi_video_buffer_is_a(buffer, type)) { - if (!buffer->parent || - !gst_vaapi_video_buffer_is_a(buffer->parent, type)) - return NULL; - buffer = buffer->parent; - } - inbuf = GST_VAAPI_VIDEO_BUFFER(buffer); - - outbuf = _gst_vaapi_video_buffer_typed_new(type); - if (!outbuf) - return NULL; - - if (inbuf->priv->image) - gst_vaapi_video_buffer_set_image(outbuf, inbuf->priv->image); - if (inbuf->priv->surface) - gst_vaapi_video_buffer_set_surface(outbuf, inbuf->priv->surface); - if (inbuf->priv->proxy) - gst_vaapi_video_buffer_set_surface_proxy(outbuf, inbuf->priv->proxy); - - outbuf->priv->buffer = gst_buffer_ref(buffer); - return GST_BUFFER(outbuf); -} - -/** - * gst_vaapi_video_buffer_typed_new_with_image: - * @image: a #GstVaapiImage - * - * Creates a #GstBuffer with the specified @image. The resulting - * buffer holds an additional reference to the @image. - * - * This function shall only be called from within gstreamer-vaapi - * plugin elements. - * - * Return value: the newly allocated #GstBuffer, or %NULL on error - */ -GstBuffer * -gst_vaapi_video_buffer_typed_new_with_image(GType type, GstVaapiImage *image) -{ - GstVaapiVideoBuffer *buffer; - - g_return_val_if_fail(GST_VAAPI_IS_IMAGE(image), NULL); - - buffer = _gst_vaapi_video_buffer_typed_new(type); - if (buffer) - gst_vaapi_video_buffer_set_image(buffer, image); - return GST_BUFFER(buffer); -} - -/** - * gst_vaapi_video_buffer_typed_new_with_surface: - * @surface: a #GstVaapiSurface - * - * Creates a #GstBuffer with the specified @surface. The resulting - * buffer holds an additional reference to the @surface. - * - * This function shall only be called from within gstreamer-vaapi - * plugin elements. - * - * Return value: the newly allocated #GstBuffer, or %NULL on error - */ -GstBuffer * -gst_vaapi_video_buffer_typed_new_with_surface( - GType type, - GstVaapiSurface *surface -) -{ - GstVaapiVideoBuffer *buffer; - - g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), NULL); - - buffer = _gst_vaapi_video_buffer_typed_new(type); - if (buffer) - gst_vaapi_video_buffer_set_surface(buffer, surface); - return GST_BUFFER(buffer); -} - -/** - * gst_vaapi_video_buffer_typed_new_with_surface_proxy: - * @proxy: a #GstVaapiSurfaceProxy - * - * Creates a #GstBuffer with the specified surface @proxy. The - * resulting buffer holds an additional reference to the @proxy. - * - * This function shall only be called from within gstreamer-vaapi - * plugin elements. - * - * Return value: the newly allocated #GstBuffer, or %NULL on error - */ -GstBuffer * -gst_vaapi_video_buffer_typed_new_with_surface_proxy( - GType type, - GstVaapiSurfaceProxy *proxy -) -{ - GstVaapiVideoBuffer *buffer; - - g_return_val_if_fail(proxy != NULL, NULL); - - buffer = _gst_vaapi_video_buffer_typed_new(type); - if (buffer) - gst_vaapi_video_buffer_set_surface_proxy(buffer, proxy); - return GST_BUFFER(buffer); -} - -/** - * gst_vaapi_video_buffer_get_display: + * gst_vaapi_video_buffer_get_meta: * @buffer: a #GstVaapiVideoBuffer * - * Retrieves the #GstVaapiDisplay the @buffer is bound to. The @buffer - * owns the returned #GstVaapiDisplay object so the caller is - * responsible for calling g_object_ref() when needed. + * Returns the #GstVaapiVideoMeta associated to this @buffer. * - * Return value: the #GstVaapiDisplay the @buffer is bound to + * Return value: the #GstVaapiVideoMeta bound to the @buffer, or %NULL + * if none was found */ -GstVaapiDisplay * -gst_vaapi_video_buffer_get_display(GstVaapiVideoBuffer *buffer) +GstVaapiVideoMeta * +gst_vaapi_video_buffer_get_meta(GstVaapiVideoBuffer *buffer) { g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL); - return buffer->priv->display; -} - -/** - * gst_vaapi_video_buffer_get_image: - * @buffer: a #GstVaapiVideoBuffer - * - * Retrieves the #GstVaapiImage bound to the @buffer. The @buffer owns - * the #GstVaapiImage so the caller is responsible for calling - * g_object_ref() when needed. - * - * Return value: the #GstVaapiImage bound to the @buffer, or %NULL if - * there is none - */ -GstVaapiImage * -gst_vaapi_video_buffer_get_image(GstVaapiVideoBuffer *buffer) -{ - g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL); - - return buffer->priv->image; -} - -/** - * gst_vaapi_video_buffer_set_image: - * @buffer: a #GstVaapiVideoBuffer - * @image: a #GstVaapiImage - * - * Binds @image to the @buffer. If the @buffer contains another image - * previously allocated from a pool, it's pushed back to its parent - * pool and the pool is also released. - */ -void -gst_vaapi_video_buffer_set_image( - GstVaapiVideoBuffer *buffer, - GstVaapiImage *image -) -{ - g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer)); - g_return_if_fail(GST_VAAPI_IS_IMAGE(image)); - - gst_vaapi_video_buffer_destroy_image(buffer); - - if (image) - set_image(buffer, image); -} - -/** - * gst_vaapi_video_buffer_set_image_from_pool - * @buffer: a #GstVaapiVideoBuffer - * @pool: a #GstVaapiVideoPool - * - * Binds a newly allocated video object from the @pool. The @pool - * shall be of type #GstVaapiImagePool. Previously allocated objects - * are released and returned to their parent pools, if any. - * - * Return value: %TRUE on success - */ -gboolean -gst_vaapi_video_buffer_set_image_from_pool( - GstVaapiVideoBuffer *buffer, - GstVaapiVideoPool *pool -) -{ - GstVaapiImage *image; - - g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), FALSE); - g_return_val_if_fail(GST_VAAPI_IS_IMAGE_POOL(pool), FALSE); - - gst_vaapi_video_buffer_destroy_image(buffer); - - if (pool) { - image = gst_vaapi_video_pool_get_object(pool); - if (!image) - return FALSE; - set_image(buffer, image); - buffer->priv->image_pool = g_object_ref(pool); - } - return TRUE; -} - -/** - * gst_vaapi_video_buffer_get_surface: - * @buffer: a #GstVaapiVideoBuffer - * - * Retrieves the #GstVaapiSurface bound to the @buffer. The @buffer - * owns the #GstVaapiSurface so the caller is responsible for calling - * g_object_ref() when needed. - * - * Return value: the #GstVaapiSurface bound to the @buffer, or %NULL if - * there is none - */ -GstVaapiSurface * -gst_vaapi_video_buffer_get_surface(GstVaapiVideoBuffer *buffer) -{ - g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL); - - return buffer->priv->surface; -} - -/** - * gst_vaapi_video_buffer_set_surface: - * @buffer: a #GstVaapiVideoBuffer - * @surface: a #GstVaapiSurface - * - * Binds @surface to the @buffer. If the @buffer contains another - * surface previously allocated from a pool, it's pushed back to its - * parent pool and the pool is also released. - */ -void -gst_vaapi_video_buffer_set_surface( - GstVaapiVideoBuffer *buffer, - GstVaapiSurface *surface -) -{ - g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer)); - g_return_if_fail(GST_VAAPI_IS_SURFACE(surface)); - - gst_vaapi_video_buffer_destroy_surface(buffer); - - if (surface) - set_surface(buffer, surface); -} - -/** - * gst_vaapi_video_buffer_set_surface_from_pool - * @buffer: a #GstVaapiVideoBuffer - * @pool: a #GstVaapiVideoPool - * - * Binds a newly allocated video object from the @pool. The @pool - * shall be of type #GstVaapiSurfacePool. Previously allocated objects - * are released and returned to their parent pools, if any. - * - * Return value: %TRUE on success - */ -gboolean -gst_vaapi_video_buffer_set_surface_from_pool( - GstVaapiVideoBuffer *buffer, - GstVaapiVideoPool *pool -) -{ - GstVaapiSurface *surface; - - g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), FALSE); - g_return_val_if_fail(GST_VAAPI_IS_SURFACE_POOL(pool), FALSE); - - gst_vaapi_video_buffer_destroy_surface(buffer); - - if (pool) { - surface = gst_vaapi_video_pool_get_object(pool); - if (!surface) - return FALSE; - set_surface(buffer, surface); - buffer->priv->surface_pool = g_object_ref(pool); - } - return TRUE; -} - -/** - * gst_vaapi_video_buffer_get_surface_proxy: - * @buffer: a #GstVaapiVideoBuffer - * - * Retrieves the #GstVaapiSurfaceProxy bound to the @buffer. The @buffer - * owns the #GstVaapiSurfaceProxy so the caller is responsible for calling - * g_object_ref() when needed. - * - * Return value: the #GstVaapiSurfaceProxy bound to the @buffer, or - * %NULL if there is none - */ -GstVaapiSurfaceProxy * -gst_vaapi_video_buffer_get_surface_proxy(GstVaapiVideoBuffer *buffer) -{ - g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL); - - return buffer->priv->proxy; -} - -/** - * gst_vaapi_video_buffer_set_surface_proxy: - * @buffer: a #GstVaapiVideoBuffer - * @proxy: a #GstVaapiSurfaceProxy - * - * Binds surface @proxy to the @buffer. If the @buffer contains another - * surface previously allocated from a pool, it's pushed back to its - * parent pool and the pool is also released. - */ -void -gst_vaapi_video_buffer_set_surface_proxy( - GstVaapiVideoBuffer *buffer, - GstVaapiSurfaceProxy *proxy -) -{ - GstVaapiSurface *surface; - - g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer)); - g_return_if_fail(proxy != NULL); - - gst_vaapi_video_buffer_destroy_surface(buffer); - - if (proxy) { - surface = GST_VAAPI_SURFACE_PROXY_SURFACE(proxy); - if (!surface) - return; - set_surface(buffer, surface); - buffer->priv->proxy = gst_vaapi_surface_proxy_ref(proxy); - } -} - -/** - * gst_vaapi_video_buffer_get_render_flags: - * @buffer: a #GstVaapiVideoBuffer - * - * Retrieves the surface render flags bound to the @buffer. - * - * Return value: a combination for #GstVaapiSurfaceRenderFlags - */ -guint -gst_vaapi_video_buffer_get_render_flags(GstVaapiVideoBuffer *buffer) -{ - g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), 0); - g_return_val_if_fail(GST_VAAPI_IS_SURFACE(buffer->priv->surface), 0); - - return buffer->priv->render_flags; -} - -/** - * gst_vaapi_video_buffer_set_render_flags: - * @buffer: a #GstVaapiVideoBuffer - * @flags: a set of surface render flags - * - * Sets #GstVaapiSurfaceRenderFlags to the @buffer. - */ -void -gst_vaapi_video_buffer_set_render_flags(GstVaapiVideoBuffer *buffer, guint flags) -{ - g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer)); - g_return_if_fail(GST_VAAPI_IS_SURFACE(buffer->priv->surface)); - - buffer->priv->render_flags = flags; + return buffer->meta; } diff --git a/gst-libs/gst/vaapi/gstvaapivideobuffer.h b/gst-libs/gst/vaapi/gstvaapivideobuffer.h index 5d479b241f..e7f09ed3be 100644 --- a/gst-libs/gst/vaapi/gstvaapivideobuffer.h +++ b/gst-libs/gst/vaapi/gstvaapivideobuffer.h @@ -24,11 +24,7 @@ #define GST_VAAPI_VIDEO_BUFFER_H #include -#include -#include -#include -#include -#include +#include G_BEGIN_DECLS @@ -57,7 +53,6 @@ G_BEGIN_DECLS GstVaapiVideoBufferClass)) typedef struct _GstVaapiVideoBuffer GstVaapiVideoBuffer; -typedef struct _GstVaapiVideoBufferPrivate GstVaapiVideoBufferPrivate; typedef struct _GstVaapiVideoBufferClass GstVaapiVideoBufferClass; /** @@ -69,7 +64,7 @@ struct _GstVaapiVideoBuffer { /*< private >*/ GstSurfaceBuffer parent_instance; - GstVaapiVideoBufferPrivate *priv; + GstVaapiVideoMeta *meta; }; /** @@ -85,53 +80,11 @@ struct _GstVaapiVideoBufferClass { GType gst_vaapi_video_buffer_get_type(void) G_GNUC_CONST; -GstVaapiDisplay * -gst_vaapi_video_buffer_get_display(GstVaapiVideoBuffer *buffer); +GstBuffer * +gst_vaapi_video_buffer_new(GstVaapiVideoMeta *meta); -GstVaapiImage * -gst_vaapi_video_buffer_get_image(GstVaapiVideoBuffer *buffer); - -void -gst_vaapi_video_buffer_set_image( - GstVaapiVideoBuffer *buffer, - GstVaapiImage *image -); - -gboolean -gst_vaapi_video_buffer_set_image_from_pool( - GstVaapiVideoBuffer *buffer, - GstVaapiVideoPool *pool -); - -GstVaapiSurface * -gst_vaapi_video_buffer_get_surface(GstVaapiVideoBuffer *buffer); - -void -gst_vaapi_video_buffer_set_surface( - GstVaapiVideoBuffer *buffer, - GstVaapiSurface *surface -); - -gboolean -gst_vaapi_video_buffer_set_surface_from_pool( - GstVaapiVideoBuffer *buffer, - GstVaapiVideoPool *pool -); - -GstVaapiSurfaceProxy * -gst_vaapi_video_buffer_get_surface_proxy(GstVaapiVideoBuffer *buffer); - -void -gst_vaapi_video_buffer_set_surface_proxy( - GstVaapiVideoBuffer *buffer, - GstVaapiSurfaceProxy *proxy -); - -guint -gst_vaapi_video_buffer_get_render_flags(GstVaapiVideoBuffer *buffer); - -void -gst_vaapi_video_buffer_set_render_flags(GstVaapiVideoBuffer *buffer, guint flags); +GstVaapiVideoMeta * +gst_vaapi_video_buffer_get_meta(GstVaapiVideoBuffer *buffer); G_END_DECLS diff --git a/gst-libs/gst/vaapi/gstvaapivideobuffer_glx.c b/gst-libs/gst/vaapi/gstvaapivideobuffer_glx.c deleted file mode 100644 index 7ab4b51e1c..0000000000 --- a/gst-libs/gst/vaapi/gstvaapivideobuffer_glx.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * gstvaapivideobuffer_glx.c - Gst VA video buffer - * - * Copyright (C) 2011 Intel Corporation - * Copyright (C) 2011 Collabora Ltd. - * Author: Nicolas Dufresne - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -/** - * SECTION:gstvaapivideobufferglx - * @short_description: VA video buffer for GStreamer with GLX support - */ - -#include "sysdeps.h" -#include "gstvaapivideobuffer_glx.h" -#include "gstvaapivideoconverter_glx.h" -#include "gstvaapivideopool.h" -#include "gstvaapivideobuffer_priv.h" -#include "gstvaapidisplay_priv.h" - -#define DEBUG 1 -#include "gstvaapidebug.h" - -G_DEFINE_TYPE(GstVaapiVideoBufferGLX, - gst_vaapi_video_buffer_glx, - GST_VAAPI_TYPE_VIDEO_BUFFER) - -static void -gst_vaapi_video_buffer_glx_class_init(GstVaapiVideoBufferGLXClass *klass) -{ - GstSurfaceBufferClass * const surface_class = - GST_SURFACE_BUFFER_CLASS(klass); - - surface_class->create_converter = gst_vaapi_video_converter_glx_new; -} - -static void -gst_vaapi_video_buffer_glx_init(GstVaapiVideoBufferGLX *buffer) -{ -} diff --git a/gst-libs/gst/vaapi/gstvaapivideobuffer_glx.h b/gst-libs/gst/vaapi/gstvaapivideobuffer_glx.h deleted file mode 100644 index 0dbe065c09..0000000000 --- a/gst-libs/gst/vaapi/gstvaapivideobuffer_glx.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * gstvaapivideobuffer_glx.h - Gstreamer/VA video buffer - * - * Copyright (C) 2011 Intel Corporation - * Copyright (C) 2011 Collabora Ltd. - * Author: Nicolas Dufresne - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -#ifndef GST_VAAPI_VIDEO_BUFFER_GLX_H -#define GST_VAAPI_VIDEO_BUFFER_GLX_H - -#include -#include -#include -#include - -G_BEGIN_DECLS - -#define GST_VAAPI_TYPE_VIDEO_BUFFER_GLX \ - (gst_vaapi_video_buffer_glx_get_type()) - -#define GST_VAAPI_VIDEO_BUFFER_GLX(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), \ - GST_VAAPI_TYPE_VIDEO_BUFFER_GLX, \ - GstVaapiVideoBufferGLX)) - -#define GST_VAAPI_VIDEO_BUFFER_GLX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), \ - GST_VAAPI_TYPE_VIDEO_BUFFER_GLX, \ - GstVaapiVideoBufferGLXClass)) - -#define GST_VAAPI_IS_VIDEO_BUFFER_GLX(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_VIDEO_BUFFER_GLX)) - -#define GST_VAAPI_IS_VIDEO_BUFFER_GLX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_VIDEO_BUFFER_GLX)) - -#define GST_VAAPI_VIDEO_BUFFER_GLX_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), \ - GST_VAAPI_TYPE_VIDEO_BUFFER_GLX, \ - GstVaapiVideoBufferGLXClass)) - -typedef struct _GstVaapiVideoBufferGLX GstVaapiVideoBufferGLX; -typedef struct _GstVaapiVideoBufferGLXClass GstVaapiVideoBufferGLXClass; - -/** - * GstVaapiVideoBufferGLX: - * - * A #GstBuffer holding video objects (#GstVaapiSurface and #GstVaapiImage). - */ -struct _GstVaapiVideoBufferGLX { - /*< private >*/ - GstVaapiVideoBuffer parent_instance; -}; - -/** - * GstVaapiVideoBufferGLXClass: - * - * A #GstBuffer holding video objects - */ -struct _GstVaapiVideoBufferGLXClass { - /*< private >*/ - GstVaapiVideoBufferClass parent_class; -}; - -GType gst_vaapi_video_buffer_glx_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* GST_VAAPI_VIDEO_BUFFER_GLX_H */ diff --git a/gst-libs/gst/vaapi/gstvaapivideobuffer_priv.h b/gst-libs/gst/vaapi/gstvaapivideobuffer_priv.h deleted file mode 100644 index a08edbd8bf..0000000000 --- a/gst-libs/gst/vaapi/gstvaapivideobuffer_priv.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * gstvaapivideobuffer_priv.h - Gstreamer/VA video buffer (private interface) - * - * Copyright (C) 2011 Intel Corporation - * Copyright (C) 2011 Collabora Ltd. - * Author: Nicolas Dufresne - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -#ifndef GST_VAAPI_VIDEO_BUFFER_PRIV_H -#define GST_VAAPI_VIDEO_BUFFER_PRIV_H - -#include - -G_BEGIN_DECLS - -/* Private API for gstreamer-vaapi plugin elements only */ - -GstBuffer * -gst_vaapi_video_buffer_typed_new(GType type, GstVaapiDisplay *display); - -GstBuffer * -gst_vaapi_video_buffer_typed_new_from_pool(GType type, GstVaapiVideoPool *pool); - -GstBuffer * -gst_vaapi_video_buffer_typed_new_from_buffer(GType type, GstBuffer *buffer); - -GstBuffer * -gst_vaapi_video_buffer_typed_new_with_image(GType type, GstVaapiImage *image); - -GstBuffer * -gst_vaapi_video_buffer_typed_new_with_surface( - GType type, - GstVaapiSurface *surface -); - -GstBuffer * -gst_vaapi_video_buffer_typed_new_with_surface_proxy( - GType type, - GstVaapiSurfaceProxy *proxy -); - -G_END_DECLS - -#endif /* GST_VAAPI_VIDEO_BUFFER_PRIV_H */ diff --git a/gst-libs/gst/vaapi/gstvaapivideoconverter_glx.c b/gst-libs/gst/vaapi/gstvaapivideoconverter_glx.c index 26de76803f..dc5c62e21e 100644 --- a/gst-libs/gst/vaapi/gstvaapivideoconverter_glx.c +++ b/gst-libs/gst/vaapi/gstvaapivideoconverter_glx.c @@ -87,27 +87,25 @@ GstSurfaceConverter * gst_vaapi_video_converter_glx_new(GstSurfaceBuffer *surface, const gchar *type, GValue *dest) { - GstVaapiVideoBuffer *buffer = GST_VAAPI_VIDEO_BUFFER (surface); - GstVaapiDisplay *display = gst_vaapi_video_buffer_get_display (buffer); + GstVaapiVideoMeta * const meta = + gst_vaapi_video_buffer_get_meta(GST_VAAPI_VIDEO_BUFFER(surface)); GstVaapiTexture *texture; - GstVaapiVideoConverterGLX *converter = NULL; + GstVaapiVideoConverterGLX *converter; /* We only support Open GL texture conversion */ - if (strcmp(type, "opengl") || !G_VALUE_HOLDS_UINT (dest)) + if (strcmp(type, "opengl") || !G_VALUE_HOLDS_UINT(dest)) return NULL; /* FIXME Should we assume target and format ? */ - texture = gst_vaapi_texture_new_with_texture (display, - g_value_get_uint (dest), - GL_TEXTURE_2D, - GL_BGRA); + texture = gst_vaapi_texture_new_with_texture( + gst_vaapi_video_meta_get_display(meta), + g_value_get_uint(dest), GL_TEXTURE_2D, GL_BGRA); + if (!texture) + return NULL; - if (texture) { - converter = g_object_new (GST_VAAPI_TYPE_VIDEO_CONVERTER, NULL); - converter->priv->texture = texture; - } - - return GST_SURFACE_CONVERTER (converter); + converter = g_object_new(GST_VAAPI_TYPE_VIDEO_CONVERTER, NULL); + converter->priv->texture = texture; + return GST_SURFACE_CONVERTER(converter); } gboolean @@ -116,8 +114,9 @@ gst_vaapi_video_converter_glx_upload (GstSurfaceConverter *converter, { GstVaapiVideoConverterGLXPrivate *priv = GST_VAAPI_VIDEO_CONVERTER_GLX (converter)->priv; - GstVaapiVideoBuffer * const vbuffer = GST_VAAPI_VIDEO_BUFFER (buffer); - GstVaapiSurface *surface = gst_vaapi_video_buffer_get_surface (vbuffer); + GstVaapiVideoMeta * const meta = + gst_vaapi_video_buffer_get_meta (GST_VAAPI_VIDEO_BUFFER (buffer)); + GstVaapiSurface *surface = gst_vaapi_video_meta_get_surface (meta); GstVaapiDisplay *new_dpy, *old_dpy; GstVideoOverlayComposition * const composition = gst_video_buffer_get_overlay_composition (GST_BUFFER (buffer)); @@ -139,5 +138,5 @@ gst_vaapi_video_converter_glx_upload (GstSurfaceConverter *converter, GST_WARNING ("could not update subtitles"); return gst_vaapi_texture_put_surface (priv->texture, surface, - gst_vaapi_video_buffer_get_render_flags (vbuffer)); + gst_vaapi_video_meta_get_render_flags (meta)); }