mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
applemedia: avfvideosrc: optionally get the GL context from gst_element_set_context
Allow setting the GL context with gst_element_set_context. When available, the local context obtained via the context query still has the precedence.
This commit is contained in:
parent
45b40b8467
commit
05ccc2f6ea
1 changed files with 29 additions and 3 deletions
|
@ -753,7 +753,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
|
|
||||||
GstCapsFeatures *features = gst_caps_get_features (caps, 0);
|
GstCapsFeatures *features = gst_caps_get_features (caps, 0);
|
||||||
if (gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) {
|
if (gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) {
|
||||||
GstGLContext *context = query_gl_context (GST_BASE_SRC_PAD (baseSrc));
|
GstGLContext *context = find_gl_context (element);
|
||||||
textureCache = gst_video_texture_cache_new (context);
|
textureCache = gst_video_texture_cache_new (context);
|
||||||
gst_video_texture_cache_set_format (textureCache, format, caps);
|
gst_video_texture_cache_set_format (textureCache, format, caps);
|
||||||
gst_object_unref (context);
|
gst_object_unref (context);
|
||||||
|
@ -964,7 +964,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstGLContext *
|
static GstGLContext *
|
||||||
query_gl_context (GstPad *srcpad)
|
query_gl_local_context (GstPad *srcpad)
|
||||||
{
|
{
|
||||||
GstGLContext *gl_context = NULL;
|
GstGLContext *gl_context = NULL;
|
||||||
GstContext *context = NULL;
|
GstContext *context = NULL;
|
||||||
|
@ -983,6 +983,32 @@ query_gl_context (GstPad *srcpad)
|
||||||
return gl_context;
|
return gl_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstGLContext *
|
||||||
|
find_gl_app_context (GstElement *element)
|
||||||
|
{
|
||||||
|
GstGLContext *gl_context = NULL;
|
||||||
|
GstContext *context = gst_element_get_context (element, "gst.gl.app_context");
|
||||||
|
if (context) {
|
||||||
|
const GstStructure *s = gst_context_get_structure (context);
|
||||||
|
gst_structure_get (s, "context", GST_GL_TYPE_CONTEXT, &gl_context, NULL);
|
||||||
|
gst_context_unref (context);
|
||||||
|
}
|
||||||
|
|
||||||
|
return gl_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstGLContext *
|
||||||
|
find_gl_context (GstElement *element)
|
||||||
|
{
|
||||||
|
GstGLContext *gl_context = NULL;
|
||||||
|
|
||||||
|
gl_context = query_gl_local_context (GST_BASE_SRC_PAD (element));
|
||||||
|
if (!gl_context)
|
||||||
|
gl_context = find_gl_app_context (element);
|
||||||
|
|
||||||
|
return gl_context;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
caps_filter_out_gl_memory (GstCapsFeatures * features, GstStructure * structure,
|
caps_filter_out_gl_memory (GstCapsFeatures * features, GstStructure * structure,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
|
@ -999,7 +1025,7 @@ caps_filter_out_gl_memory (GstCapsFeatures * features, GstStructure * structure,
|
||||||
|
|
||||||
new_caps = gst_caps_make_writable (new_caps);
|
new_caps = gst_caps_make_writable (new_caps);
|
||||||
|
|
||||||
context = query_gl_context (GST_BASE_SRC_PAD (baseSrc));
|
context = find_gl_context (element);
|
||||||
if (!context)
|
if (!context)
|
||||||
gst_caps_filter_and_map_in_place (new_caps, caps_filter_out_gl_memory, NULL);
|
gst_caps_filter_and_map_in_place (new_caps, caps_filter_out_gl_memory, NULL);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue