applemedia: vtdec: fix GL negotiation
This commit is contained in:
parent
3e0391a1f1
commit
a10232f7da
@ -198,37 +198,48 @@ static gboolean
|
|||||||
gst_vtdec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
|
gst_vtdec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
|
||||||
{
|
{
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
GstCaps *caps;
|
||||||
|
GstCapsFeatures *features;
|
||||||
GstVtdec *vtdec = GST_VTDEC (decoder);
|
GstVtdec *vtdec = GST_VTDEC (decoder);
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
GST_VIDEO_DECODER_CLASS (gst_vtdec_parent_class)->decide_allocation
|
GST_VIDEO_DECODER_CLASS (gst_vtdec_parent_class)->decide_allocation
|
||||||
(decoder, query);
|
(decoder, query);
|
||||||
if (ret) {
|
if (!ret)
|
||||||
GstCaps *caps;
|
goto out;
|
||||||
GstCapsFeatures *features;
|
|
||||||
guint idx;
|
|
||||||
|
|
||||||
gst_query_parse_allocation (query, &caps, NULL);
|
gst_query_parse_allocation (query, &caps, NULL);
|
||||||
if (caps) {
|
if (caps) {
|
||||||
|
GstGLContext *gl_context = NULL;
|
||||||
features = gst_caps_get_features (caps, 0);
|
features = gst_caps_get_features (caps, 0);
|
||||||
|
|
||||||
if (gst_caps_features_contains (features,
|
if (gst_caps_features_contains (features,
|
||||||
GST_CAPS_FEATURE_MEMORY_GL_MEMORY)
|
GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) {
|
||||||
&& gst_query_find_allocation_meta (query,
|
GstContext *context = NULL;
|
||||||
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, &idx)) {
|
GstQuery *query = gst_query_new_context ("gst.gl.local_context");
|
||||||
GstGLContext *context;
|
if (gst_pad_peer_query (GST_VIDEO_DECODER_SRC_PAD (decoder), query)) {
|
||||||
const GstStructure *upload_meta_params;
|
|
||||||
|
|
||||||
gst_query_parse_nth_allocation_meta (query, idx, &upload_meta_params);
|
gst_query_parse_context (query, &context);
|
||||||
if (gst_structure_get (upload_meta_params, "gst.gl.GstGLContext",
|
if (context) {
|
||||||
GST_GL_TYPE_CONTEXT, &context, NULL) && context) {
|
const GstStructure *s = gst_context_get_structure (context);
|
||||||
vtdec->texture_cache = gst_core_video_texture_cache_new (context);
|
gst_structure_get (s, "context", GST_GL_TYPE_CONTEXT, &gl_context,
|
||||||
gst_object_unref (context);
|
NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
gst_query_unref (query);
|
||||||
|
|
||||||
|
if (context) {
|
||||||
|
GST_INFO_OBJECT (decoder, "pushing textures. GL context %p", context);
|
||||||
|
vtdec->texture_cache = gst_core_video_texture_cache_new (gl_context);
|
||||||
|
gst_object_unref (gl_context);
|
||||||
|
} else {
|
||||||
|
GST_WARNING_OBJECT (decoder,
|
||||||
|
"got memory:GLMemory caps but not GL context from downstream element");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user