Commit c98f92ee authored by Matt Fischer's avatar Matt Fischer Committed by Tim-Philipp Müller

gldownload: Add dmabuf exporting

This patch adds code to gldownload to export the image as a
dmabuf if requested.  The element now exposes memory:DMABuf as
a cap feature, and if it is selected, the element exports the
texture to an EGL image and then a dmabuf. It also implements a
fallback to system memory download in case the exportation failed.
parent b5dee0fe
This diff is collapsed.
......@@ -45,6 +45,8 @@ struct _GstGLDownloadElement
GstGLBaseFilter parent;
gboolean do_pbo_transfers;
GstAllocator * dmabuf_allocator;
gboolean add_videometa;
struct _GstGLDownloadElementClass
......@@ -469,4 +469,63 @@ gst_egl_image_from_dmabuf (GstGLContext * context,
return gst_egl_image_new_wrapped (context, img, format, NULL,
(GstEGLImageDestroyNotify) _destroy_egl_image);
gst_egl_image_export_dmabuf (GstEGLImage * image, int *fd, gint * stride,
gsize * offset)
EGLBoolean (*gst_eglExportDMABUFImageQueryMESA) (EGLDisplay dpy,
EGLImageKHR image, int *fourcc, int *num_planes,
EGLuint64KHR * modifiers);
EGLBoolean (*gst_eglExportDMABUFImageMESA) (EGLDisplay dpy, EGLImageKHR image,
int *fds, EGLint * strides, EGLint * offsets);
GstGLDisplayEGL *display_egl;
EGLDisplay egl_display = EGL_DEFAULT_DISPLAY;
int num_planes = 0;
int egl_fd = 0;
EGLint egl_stride = 0;
EGLint egl_offset = 0;
gst_eglExportDMABUFImageQueryMESA =
gst_gl_context_get_proc_address (image->context,
gst_eglExportDMABUFImageMESA =
gst_gl_context_get_proc_address (image->context,
if (!gst_eglExportDMABUFImageQueryMESA || !gst_eglExportDMABUFImageMESA)
return FALSE;
display_egl =
(GstGLDisplayEGL *) gst_gl_display_egl_from_gl_display (image->
if (!display_egl) {
GST_WARNING_OBJECT (image->context,
"Failed to retrieve GstGLDisplayEGL from %" GST_PTR_FORMAT,
return FALSE;
egl_display =
(EGLDisplay) gst_gl_display_get_handle (GST_GL_DISPLAY (display_egl));
gst_object_unref (display_egl);
if (!gst_eglExportDMABUFImageQueryMESA (egl_display, image->image,
NULL, &num_planes, NULL))
return FALSE;
/* Don't allow multi-plane dmabufs */
if (num_planes > 1)
return FALSE;
if (!gst_eglExportDMABUFImageMESA (egl_display, image->image, &egl_fd,
&egl_stride, &egl_offset))
return FALSE;
*fd = egl_fd;
*stride = egl_stride;
*offset = egl_offset;
return TRUE;
#endif /* GST_GL_HAVE_DMABUF */
......@@ -88,6 +88,8 @@ GstEGLImage * gst_egl_image_from_dmabuf (GstGLContext *
GstVideoInfo * in_info,
gint plane,
gsize offset);
gboolean gst_egl_image_export_dmabuf (GstEGLImage *image, int *fd, gint *stride, gsize *offset);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment