From b1a98433f8d3d989dc1136f15b4b46c1a27fb99d Mon Sep 17 00:00:00 2001 From: He Junyan Date: Fri, 4 Nov 2022 17:06:37 +0800 Subject: [PATCH] libs: va: Add API to peek the allocator's display. Part-of: --- .../gst-libs/gst/va/gstvaallocator.c | 24 +++++++++++++++++++ .../gst-libs/gst/va/gstvaallocator.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c index a9e8d91676..a50d420863 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c @@ -1902,6 +1902,30 @@ gst_va_allocator_set_hacks (GstAllocator * allocator, guint32 hacks) self->hacks = hacks; } +/** + * gst_va_allocator_peek_display: + * @allocator: a #GstAllocator + * + * Returns: (type #GstVaDisplay) (transfer none): the display which this + * @allocator belongs to. The reference of the display is unchanged. + * + * Since: 1.22 + */ +GstVaDisplay * +gst_va_allocator_peek_display (GstAllocator * allocator) +{ + if (!allocator) + return NULL; + + if (GST_IS_VA_DMABUF_ALLOCATOR (allocator)) { + return GST_VA_DMABUF_ALLOCATOR (allocator)->display; + } else if (GST_IS_VA_ALLOCATOR (allocator)) { + return GST_VA_ALLOCATOR (allocator)->display; + } + + return NULL; +} + /*============ Utilities =====================================================*/ /** diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h index 23d54d29e5..780c21da57 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h @@ -118,6 +118,8 @@ gboolean gst_va_allocator_get_format (GstAllocator * alloca GST_VA_API void gst_va_allocator_set_hacks (GstAllocator * allocator, guint32 hacks); +GST_VA_API +GstVaDisplay * gst_va_allocator_peek_display (GstAllocator * allocator); GST_VA_API VASurfaceID gst_va_memory_get_surface (GstMemory * mem);