avfvideosrc: fix GL texture negotiation

GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE should no longer be used.
Instead, just get the GL context.

https://bugzilla.gnome.org/show_bug.cgi?id=747352
This commit is contained in:
Ilya Konstantinov 2015-04-11 07:38:57 +03:00 committed by Alessandro Decina
parent 49aba362a8
commit 1b27538648

View file

@ -769,26 +769,32 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
useVideoMeta = gst_query_find_allocation_meta (query, useVideoMeta = gst_query_find_allocation_meta (query,
GST_VIDEO_META_API_TYPE, NULL); GST_VIDEO_META_API_TYPE, NULL);
guint idx; /* determine whether we can pass GL textures to downstream element */
if (gst_query_find_allocation_meta (query, GstCapsFeatures *features = gst_caps_get_features (caps, 0);
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, &idx)) { if (gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) {
GstGLContext *context; GstGLContext *glContext = NULL;
const GstStructure *upload_meta_params;
gst_query_parse_nth_allocation_meta (query, idx, &upload_meta_params); /* get GL context from downstream element */
if (gst_structure_get (upload_meta_params, "gst.gl.GstGLContext", GstQuery *query = gst_query_new_context ("gst.gl.local_context");
GST_GL_TYPE_CONTEXT, &context, NULL) && context) { if (gst_pad_peer_query (GST_BASE_SRC_PAD (element), query)) {
GstCaps *query_caps; GstContext *context;
GstCapsFeatures *features; gst_query_parse_context (query, &context);
if (context) {
gst_query_parse_allocation (query, &query_caps, NULL); const GstStructure *s = gst_context_get_structure (context);
features = gst_caps_get_features (query_caps, 0); gst_structure_get (s, "context", GST_GL_TYPE_CONTEXT, &glContext,
if (gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) { NULL);
textureCache = gst_core_video_texture_cache_new (context);
gst_core_video_texture_cache_set_format (textureCache,
"NV12", query_caps);
} }
gst_object_unref (context); }
gst_query_unref (query);
if (glContext) {
GST_INFO_OBJECT (element, "pushing textures. GL context %p", glContext);
textureCache = gst_core_video_texture_cache_new (glContext);
gst_core_video_texture_cache_set_format (textureCache,
"NV12", caps);
gst_object_unref (glContext);
} else {
GST_WARNING_OBJECT (element, "got memory:GLMemory caps but not GL context from downstream element");
} }
} }