summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2016-06-08 19:11:15 +0200
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-06-23 18:44:42 +0200
commit5312923d1c0ad7d63b12bb2f5e60a57ae43dde1b (patch)
tree9c1c4aea4551ba31704043d850da37330ca83ae6 /gst
parent7d7f722a18912e7e8fc8a15be1f49b41ccc73669 (diff)
vaapivideomemory: add gst_vaapi_dmabuf_can_map()
This new method checks the specified allocator can create GstMemory that can be mapped. https://bugzilla.gnome.org/show_bug.cgi?id=755072
Diffstat (limited to 'gst')
-rw-r--r--gst/vaapi/gstvaapivideomemory.c47
-rw-r--r--gst/vaapi/gstvaapivideomemory.h4
2 files changed, 51 insertions, 0 deletions
diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c
index 6b26d02a..3d00e8dd 100644
--- a/gst/vaapi/gstvaapivideomemory.c
+++ b/gst/vaapi/gstvaapivideomemory.c
@@ -1327,3 +1327,50 @@ gst_vaapi_is_dmabuf_allocator (GstAllocator * allocator)
st = g_object_get_qdata (G_OBJECT (allocator), GST_VAAPI_VIDEO_INFO_QUARK);
return (st != NULL);
}
+
+/**
+ * gst_vaapi_dmabuf_can_map:
+ * @display: a #GstVaapiDisplay
+ * @allocator: a #GstAllocator
+ *
+ * It will create a dmabuf-based buffer using @allocator, and it will
+ * try to map it using gst_memory_map().
+ *
+ * Returns: %TRUE if the internal dummy buffer can be
+ * mapped. Otherwise %FALSE.
+ **/
+gboolean
+gst_vaapi_dmabuf_can_map (GstVaapiDisplay * display, GstAllocator * allocator)
+{
+ GstVaapiVideoMeta *meta;
+ GstMemory *mem;
+ GstMapInfo info;
+ gboolean ret;
+
+ g_return_val_if_fail (display != NULL, FALSE);
+
+ ret = FALSE;
+ mem = NULL;
+ meta = NULL;
+ if (!gst_vaapi_is_dmabuf_allocator (allocator))
+ return FALSE;
+ meta = gst_vaapi_video_meta_new (display);
+ if (!meta)
+ return FALSE;
+ mem = gst_vaapi_dmabuf_memory_new (allocator, meta);
+ if (!mem)
+ goto bail;
+
+ if (!gst_memory_map (mem, &info, GST_MAP_READWRITE) || info.size == 0)
+ goto bail;
+
+ gst_memory_unmap (mem, &info);
+ ret = TRUE;
+
+bail:
+ if (mem)
+ gst_memory_unref (mem);
+ if (meta)
+ gst_vaapi_video_meta_unref (meta);
+ return ret;
+}
diff --git a/gst/vaapi/gstvaapivideomemory.h b/gst/vaapi/gstvaapivideomemory.h
index dcc998d4..db31b696 100644
--- a/gst/vaapi/gstvaapivideomemory.h
+++ b/gst/vaapi/gstvaapivideomemory.h
@@ -291,6 +291,10 @@ G_GNUC_INTERNAL
gboolean
gst_vaapi_is_dmabuf_allocator (GstAllocator * allocator);
+G_GNUC_INTERNAL
+gboolean
+gst_vaapi_dmabuf_can_map (GstVaapiDisplay * display, GstAllocator * allocator);
+
G_END_DECLS
#endif /* GST_VAAPI_VIDEO_MEMORY_H */