plugins: implement GLTextureUploadMeta user data copy.

Makes the copies of a buffer reference their own GLTextureUploadMeta
user data and prevent the original buffer accessing already freed
memory if its copies has been released and freed.

https://bugzilla.gnome.org/show_bug.cgi?id=720336

[Propagate the original meta texture to the copy too]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
Matthieu Bouron 2013-12-12 17:01:29 +00:00 committed by Gwenole Beauchesne
parent e3dcd33114
commit bf8f244de3

View file

@ -57,6 +57,19 @@ meta_texture_new(void)
return meta;
}
static GstVaapiVideoMetaTexture *
meta_texture_copy(GstVaapiVideoMetaTexture *meta)
{
GstVaapiVideoMetaTexture *copy;
copy = meta_texture_new();
if (!copy)
return NULL;
gst_vaapi_texture_replace(&copy->texture, meta->texture);
return copy;
}
static gboolean
gst_vaapi_texture_upload(GstVideoGLTextureUploadMeta *meta, guint texture_id[4])
{
@ -108,7 +121,8 @@ gst_buffer_add_texture_upload_meta(GstBuffer *buffer)
meta = gst_buffer_add_video_gl_texture_upload_meta(buffer,
GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL,
1, tex_type, gst_vaapi_texture_upload,
meta_texture, NULL, (GBoxedFreeFunc)meta_texture_free);
meta_texture, (GBoxedCopyFunc)meta_texture_copy,
(GBoxedFreeFunc)meta_texture_free);
if (!meta)
goto error;
return TRUE;