GstVaapiVideoBufferPrivate))
struct _GstVaapiVideoBufferPrivate {
- GstVaapiVideoPool *image_pool;
- GstVaapiImage *image;
- GstVaapiVideoPool *surface_pool;
- GstVaapiSurface *surface;
- guint flags;
+ GstVaapiVideoPool *image_pool;
+ GstVaapiImage *image;
+ GstVaapiVideoPool *surface_pool;
+ GstVaapiSurface *surface;
+ GstVaapiSurfaceProxy *proxy;
+ guint flags;
};
static void
{
GstVaapiVideoBufferPrivate * const priv = buffer->priv;
+ if (priv->proxy) {
+ g_object_unref(priv->proxy);
+ priv->proxy = NULL;
+ }
+
if (priv->surface) {
if (priv->surface_pool)
gst_vaapi_video_pool_put_object(priv->surface_pool, priv->surface);
priv->image = NULL;
priv->surface_pool = NULL;
priv->surface = NULL;
+ priv->proxy = NULL;
}
static inline GstVaapiVideoBuffer *
}
/**
+ * gst_vaapi_video_buffer_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.
+ *
+ * Return value: the newly allocated #GstBuffer, or %NULL on error
+ */
+GstBuffer *
+gst_vaapi_video_buffer_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy)
+{
+ GstVaapiVideoBuffer *buffer;
+
+ g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
+
+ buffer = gst_vaapi_video_buffer_new();
+ if (buffer)
+ gst_vaapi_video_buffer_set_surface_proxy(buffer, proxy);
+ return GST_BUFFER(buffer);
+}
+
+/**
* gst_vaapi_video_buffer_get_image:
* @buffer: a #GstVaapiVideoBuffer
*
}
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
+)
+{
+ g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer));
+ g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
+
+ gst_vaapi_video_buffer_destroy_surface(buffer);
+
+ if (proxy) {
+ GstVaapiVideoBufferPrivate * const priv = buffer->priv;
+ priv->proxy = g_object_ref(proxy);
+ priv->surface = g_object_ref(GST_VAAPI_SURFACE_PROXY_SURFACE(proxy));
+ }
+}
#include <gst/gstbuffer.h>
#include <gst/vaapi/gstvaapiimage.h>
#include <gst/vaapi/gstvaapisurface.h>
+#include <gst/vaapi/gstvaapisurfaceproxy.h>
#include <gst/vaapi/gstvaapivideopool.h>
G_BEGIN_DECLS
GstBuffer *
gst_vaapi_video_buffer_new_with_surface(GstVaapiSurface *surface);
+GstBuffer *
+gst_vaapi_video_buffer_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy);
+
GstVaapiImage *
gst_vaapi_video_buffer_get_image(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
+);
+
G_END_DECLS
#endif /* GST_VAAPI_VIDEO_BUFFER_H */