mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
plugins: record downstream GstGLContext.
Record GL context supplied by downstream elements. This can be useful, and further needed, to enforce run-time check that the GL context is compatible for use by libgstvaapi. e.g. check that we don't create a VA/GLX display for EGL/X11 contexts. https://bugzilla.gnome.org/show_bug.cgi?id=725643 Original-path-by: Matthew Waters <ystreet00@gmail.com>
This commit is contained in:
parent
8d4498f9fd
commit
d9c082168b
4 changed files with 90 additions and 1 deletions
32
configure.ac
32
configure.ac
|
@ -503,6 +503,38 @@ dnl ... video parsers
|
|||
AM_CONDITIONAL([USE_LOCAL_VIDEO_PARSERS],
|
||||
[test "$enable_builtin_videoparsers" = "yes"])
|
||||
|
||||
dnl ... opengl helper libraries
|
||||
HAVE_GSTGL=0
|
||||
if test "$enable_glx" = "yes" -o "$enable_egl" = "yes"; then
|
||||
PKG_CHECK_MODULES([GST_GL],
|
||||
[gstreamer-gl-$GST_PKG_VERSION >= $GST_PLUGINS_BAD_VERSION_REQUIRED],
|
||||
[HAVE_GSTGL=1], [HAVE_GSTGL=0])
|
||||
fi
|
||||
|
||||
if test $HAVE_GSTGL -eq 1; then
|
||||
AC_CACHE_CHECK([for GStreamer OpenGL helper libraries],
|
||||
[ac_cv_have_gst_gl_helpers], [
|
||||
saved_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $GST_GL_CFLAGS"
|
||||
saved_LIBS="$LIBS"
|
||||
LIBS="$saved_LIBS"
|
||||
AC_CHECK_HEADERS([gst/gl/gl.h], [:], [HAVE_GSTGL=0])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <gst/gl/gl.h>]],
|
||||
[[GstGLContext gl_context;]])],
|
||||
[ac_cv_have_gst_gl_helpers="yes"],
|
||||
[ac_cv_have_gst_gl_helpers="no" HAVE_GSTGL=0]
|
||||
)
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
LIBS="$saved_LIBS"
|
||||
])
|
||||
fi
|
||||
AM_CONDITIONAL([USE_GST_GL_HELPERS], [test $HAVE_GSTGL -eq 1])
|
||||
|
||||
AC_DEFINE_UNQUOTED([USE_GST_GL_HELPERS], [$HAVE_GSTGL],
|
||||
[Defined to 1 if GStreamer OpenGL helper libraries are available])
|
||||
|
||||
case $GST_API_VERSION in
|
||||
0.10) lt_bias=gst0_vaapi_lt_current_bias;;
|
||||
1.0) lt_bias=gst1_vaapi_lt_current_bias;;
|
||||
|
|
|
@ -35,6 +35,11 @@ libgstvaapi_LIBS += \
|
|||
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-wayland-$(GST_API_VERSION).la
|
||||
endif
|
||||
|
||||
if USE_GST_GL_HELPERS
|
||||
libgstvaapi_CFLAGS += $(GST_GL_CFLAGS)
|
||||
libgstvaapi_LIBS += $(GST_GL_LIBS)
|
||||
endif
|
||||
|
||||
libgstvaapi_source_c = \
|
||||
gstvaapi.c \
|
||||
gstvaapidecode.c \
|
||||
|
|
|
@ -295,6 +295,7 @@ gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin)
|
|||
{
|
||||
g_clear_object (&plugin->uploader);
|
||||
gst_vaapi_display_replace (&plugin->display, NULL);
|
||||
gst_object_replace (&plugin->gl_context, NULL);
|
||||
|
||||
gst_caps_replace (&plugin->sinkpad_caps, NULL);
|
||||
plugin->sinkpad_caps_changed = FALSE;
|
||||
|
@ -629,12 +630,17 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
|
|||
gboolean has_video_alignment = FALSE;
|
||||
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
|
||||
gboolean has_texture_upload_meta = FALSE;
|
||||
guint idx;
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (plugin->display != NULL, FALSE);
|
||||
|
||||
gst_query_parse_allocation (query, &caps, &need_pool);
|
||||
|
||||
/* We don't need any GL context beyond this point if not requested
|
||||
so explicitly through GstVideoGLTextureUploadMeta */
|
||||
gst_object_replace (&plugin->gl_context, NULL);
|
||||
|
||||
if (!caps)
|
||||
goto error_no_caps;
|
||||
|
||||
|
@ -648,7 +654,23 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
|
|||
|
||||
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
|
||||
has_texture_upload_meta = gst_query_find_allocation_meta (query,
|
||||
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, NULL);
|
||||
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, &idx);
|
||||
|
||||
#if USE_GST_GL_HELPERS
|
||||
if (has_texture_upload_meta) {
|
||||
const GstStructure *params;
|
||||
GstObject *gl_context;
|
||||
|
||||
gst_query_parse_nth_allocation_meta (query, idx, ¶ms);
|
||||
if (params) {
|
||||
if (gst_structure_get (params, "gst.gl.GstGLContext", GST_GL_TYPE_CONTEXT,
|
||||
&gl_context, NULL) && gl_context) {
|
||||
gst_vaapi_plugin_base_set_gl_context (plugin, gl_context);
|
||||
gst_object_unref (gl_context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
gst_video_info_init (&vi);
|
||||
|
@ -936,3 +958,22 @@ error_copy_buffer:
|
|||
return GST_FLOW_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_plugin_base_set_gl_context:
|
||||
* @plugin: a #GstVaapiPluginBase
|
||||
* @object: the new GL context from downstream
|
||||
*
|
||||
* Registers the new GL context. The change is effective at the next
|
||||
* call to gst_vaapi_plugin_base_ensure_display(), where the
|
||||
* underlying display object could be re-allocated to fit the GL
|
||||
* context needs
|
||||
*/
|
||||
void
|
||||
gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
|
||||
GstObject * object)
|
||||
{
|
||||
#if USE_GST_GL_HELPERS
|
||||
gst_object_replace (&plugin->gl_context, object);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
#include "gstvaapiuploader.h"
|
||||
|
||||
#ifdef HAVE_GST_GL_GL_H
|
||||
# include <gst/gl/gstglcontext.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstVaapiPluginBase GstVaapiPluginBase;
|
||||
|
@ -145,6 +149,8 @@ struct _GstVaapiPluginBase
|
|||
GstVaapiDisplayType display_type_req;
|
||||
gchar *display_name;
|
||||
|
||||
GstObject *gl_context;
|
||||
|
||||
GstVaapiUploader *uploader;
|
||||
gboolean uploader_used;
|
||||
};
|
||||
|
@ -233,6 +239,11 @@ GstFlowReturn
|
|||
gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
|
||||
GstBuffer * inbuf, GstBuffer ** outbuf_ptr);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
|
||||
GstObject * object);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_PLUGIN_BASE_H */
|
||||
|
|
Loading…
Reference in a new issue