mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
videometa: API: Add GstVideoGLTextureUploadMeta
This allows elements to specify a function to upload a buffer content to a specific OpenGL texture ID. It could be used by the vaapi elements to provide a way for eglglessink or WebKit to upload a VA surface to an GL texture without the respective sinks knowing anything about VA.
This commit is contained in:
parent
8fe9f5a6ea
commit
5f79a8cb93
2 changed files with 126 additions and 0 deletions
|
@ -378,3 +378,92 @@ gst_video_meta_transform_scale_get_quark (void)
|
|||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
GType
|
||||
gst_video_gl_texture_upload_meta_api_get_type (void)
|
||||
{
|
||||
static volatile GType type = 0;
|
||||
static const gchar *tags[] = { "memory", NULL };
|
||||
|
||||
if (g_once_init_enter (&type)) {
|
||||
GType _type =
|
||||
gst_meta_api_type_register ("GstVideoGLTextureUploadMetaAPI", tags);
|
||||
g_once_init_leave (&type, _type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_video_gl_texture_upload_meta_free (GstMeta * meta, GstBuffer * buffer)
|
||||
{
|
||||
GstVideoGLTextureUploadMeta *vmeta = (GstVideoGLTextureUploadMeta *) meta;
|
||||
|
||||
if (vmeta->destroy_notify)
|
||||
vmeta->destroy_notify (vmeta->user_data);
|
||||
}
|
||||
|
||||
const GstMetaInfo *
|
||||
gst_video_gl_texture_upload_meta_get_info (void)
|
||||
{
|
||||
static const GstMetaInfo *info = NULL;
|
||||
|
||||
if (g_once_init_enter (&info)) {
|
||||
const GstMetaInfo *meta =
|
||||
gst_meta_register (GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE,
|
||||
"GstVideoGLTextureUploadMeta",
|
||||
sizeof (GstVideoGLTextureUploadMeta),
|
||||
NULL,
|
||||
gst_video_gl_texture_upload_meta_free,
|
||||
NULL);
|
||||
g_once_init_leave (&info, meta);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_buffer_add_video_meta:
|
||||
* @buffer: a #GstBuffer
|
||||
* @flags: #GstVideoFrameFlags
|
||||
* @format: a #GstVideoFormat
|
||||
* @width: the width
|
||||
* @height: the height
|
||||
*
|
||||
* Attaches GstVideoMeta metadata to @buffer with the given parameters and the
|
||||
* default offsets and strides for @format and @width x @height.
|
||||
*
|
||||
* This function calculates the default offsets and strides and then calls
|
||||
* gst_buffer_add_video_meta_full() with them.
|
||||
*
|
||||
* Returns: the #GstVideoMeta on @buffer.
|
||||
*/
|
||||
GstVideoGLTextureUploadMeta *
|
||||
gst_buffer_add_video_gl_texture_upload_meta (GstBuffer * buffer,
|
||||
GstVideoGLTextureUpload upload, gpointer user_data,
|
||||
GDestroyNotify destroy_notify)
|
||||
{
|
||||
GstVideoGLTextureUploadMeta *meta;
|
||||
|
||||
g_return_val_if_fail (buffer != NULL, NULL);
|
||||
g_return_val_if_fail (upload != NULL, NULL);
|
||||
|
||||
meta =
|
||||
(GstVideoGLTextureUploadMeta *) gst_buffer_add_meta (buffer,
|
||||
GST_VIDEO_GL_TEXTURE_UPLOAD_META_INFO, NULL);
|
||||
|
||||
meta->buffer = buffer;
|
||||
meta->upload = upload;
|
||||
meta->user_data = user_data;
|
||||
meta->destroy_notify = destroy_notify;
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_video_gl_texture_upload_meta_upload (GstVideoGLTextureUploadMeta * meta,
|
||||
guint format, guint texture_id)
|
||||
{
|
||||
g_return_val_if_fail (meta != NULL, FALSE);
|
||||
|
||||
return meta->upload (meta, format, texture_id);
|
||||
}
|
||||
|
|
|
@ -138,6 +138,43 @@ typedef struct {
|
|||
GstVideoInfo *out_info;
|
||||
} GstVideoMetaTransform;
|
||||
|
||||
#define GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE (gst_video_gl_texture_upload_meta_api_get_type())
|
||||
#define GST_VIDEO_GL_TEXTURE_UPLOAD_META_INFO (gst_video_gl_texture_upload_meta_get_info())
|
||||
|
||||
typedef struct _GstVideoGLTextureUploadMeta GstVideoGLTextureUploadMeta;
|
||||
typedef gboolean (*GstVideoGLTextureUpload) (GstVideoGLTextureUploadMeta *meta, guint format, guint texture_id);
|
||||
|
||||
/**
|
||||
* GstVideoGLTextureUploadMeta:
|
||||
* @meta: parent #GstMeta
|
||||
* @buffer: the buffer of this meta
|
||||
* @upload: the function to upload the buffer to a specific texture ID
|
||||
* @user_data: user data for the implementor of @upload
|
||||
* @destroy_notify: #GDestroyNotify for destroying @user_data
|
||||
*
|
||||
* Extra buffer metadata for uploading a buffer to an OpenGL texture
|
||||
* ID. The caller of gst_video_gl_texture_upload_meta_upload() must
|
||||
* have OpenGL set up and call this from a thread where it is valid
|
||||
* to upload something to an OpenGL texture.
|
||||
*/
|
||||
|
||||
struct _GstVideoGLTextureUploadMeta {
|
||||
GstMeta meta;
|
||||
|
||||
GstBuffer *buffer;
|
||||
GstVideoGLTextureUpload upload;
|
||||
|
||||
gpointer user_data;
|
||||
GDestroyNotify destroy_notify;
|
||||
};
|
||||
|
||||
#define gst_buffer_get_video_gl_texture_upload_meta(b) ((GstVideoGLTextureUploadMeta*)gst_buffer_get_meta((b),GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE))
|
||||
GstVideoGLTextureUploadMeta * gst_buffer_add_video_gl_texture_upload_meta (GstBuffer *buffer, GstVideoGLTextureUpload upload, gpointer user_data, GDestroyNotify destroy_notify);
|
||||
gboolean gst_video_gl_texture_upload_meta_upload (GstVideoGLTextureUploadMeta *meta, guint format, guint texture_id);
|
||||
|
||||
GType gst_video_gl_texture_upload_meta_api_get_type (void);
|
||||
const GstMetaInfo * gst_video_gl_texture_upload_meta_get_info (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_VIDEO_META_H__ */
|
||||
|
|
Loading…
Reference in a new issue