summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>2021-01-25 22:38:45 +0100
committerJan Alexander Steffens (heftig) <jan.steffens@gmail.com>2021-01-26 20:30:47 +0100
commit00fd60aaa8ceb11b193c2b340c565f342799e387 (patch)
tree56174b5bdb586cac6dc8fb76771f783e3cd5e75c
parentc7a7d0582a52f0109f3f534ae7ae7a1f4ff24274 (diff)
downloadgtk+-00fd60aaa8ceb11b193c2b340c565f342799e387.tar.gz
gtkgstsink: Use video_frame_free also for the GL path
The video frame needs to stay mapped while the texture is in use. Avoid using g_memdup because the structure is not supposed to be moved.
-rw-r--r--modules/media/gtkgstsink.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/modules/media/gtkgstsink.c b/modules/media/gtkgstsink.c
index 7375525c60..c546ec7ff6 100644
--- a/modules/media/gtkgstsink.c
+++ b/modules/media/gtkgstsink.c
@@ -259,44 +259,43 @@ gtk_gst_sink_texture_from_buffer (GtkGstSink *self,
GstBuffer *buffer,
double *pixel_aspect_ratio)
{
- GstVideoFrame frame;
+ GstVideoFrame *frame = g_new (GstVideoFrame, 1);
GdkTexture *texture;
if (self->gdk_context &&
- gst_video_frame_map (&frame, &self->v_info, buffer, GST_MAP_READ | GST_MAP_GL))
+ gst_video_frame_map (frame, &self->v_info, buffer, GST_MAP_READ | GST_MAP_GL))
{
texture = gdk_gl_texture_new (self->gdk_context,
- *(guint *) frame.data[0],
- frame.info.width,
- frame.info.height,
- (GDestroyNotify) gst_buffer_unref,
- gst_buffer_ref (buffer));
+ *(guint *) frame->data[0],
+ frame->info.width,
+ frame->info.height,
+ (GDestroyNotify) video_frame_free,
+ frame);
- *pixel_aspect_ratio = ((double) frame.info.par_n) / ((double) frame.info.par_d);
-
- gst_video_frame_unmap (&frame);
+ *pixel_aspect_ratio = ((double) frame->info.par_n) / ((double) frame->info.par_d);
}
- else if (gst_video_frame_map (&frame, &self->v_info, buffer, GST_MAP_READ))
+ else if (gst_video_frame_map (frame, &self->v_info, buffer, GST_MAP_READ))
{
GBytes *bytes;
- bytes = g_bytes_new_with_free_func (frame.data[0],
- frame.info.height * frame.info.stride[0],
+ bytes = g_bytes_new_with_free_func (frame->data[0],
+ frame->info.height * frame->info.stride[0],
(GDestroyNotify) video_frame_free,
- g_memdup (&frame, sizeof (frame)));
- texture = gdk_memory_texture_new (frame.info.width,
- frame.info.height,
- gtk_gst_memory_format_from_video (GST_VIDEO_FRAME_FORMAT (&frame)),
+ frame);
+ texture = gdk_memory_texture_new (frame->info.width,
+ frame->info.height,
+ gtk_gst_memory_format_from_video (GST_VIDEO_FRAME_FORMAT (frame)),
bytes,
- frame.info.stride[0]);
+ frame->info.stride[0]);
g_bytes_unref (bytes);
- *pixel_aspect_ratio = ((double) frame.info.par_n) / ((double) frame.info.par_d);
+ *pixel_aspect_ratio = ((double) frame->info.par_n) / ((double) frame->info.par_d);
}
else
{
GST_ERROR_OBJECT (self, "Could not convert buffer to texture.");
texture = NULL;
+ g_free (frame);
}
return texture;