mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
gl: Let base transform relay the meta api for us
During allocation query, when this element is not passthrough, it must relay the overlay compostion meta and it's parameters. Fortunatly, base transform can do this for us. https://bugzilla.gnome.org/show_bug.cgi?id=753850
This commit is contained in:
parent
c8628fc43d
commit
d1cece731e
3 changed files with 29 additions and 32 deletions
|
@ -41,6 +41,9 @@ static GstCaps *gst_gl_color_convert_element_transform_caps (GstBaseTransform *
|
|||
bt, GstPadDirection direction, GstCaps * caps, GstCaps * filter);
|
||||
static gboolean gst_gl_color_convert_element_get_unit_size (GstBaseTransform *
|
||||
trans, GstCaps * caps, gsize * size);
|
||||
static gboolean
|
||||
gst_gl_color_convert_element_filter_meta (GstBaseTransform * trans,
|
||||
GstQuery * query, GType api, const GstStructure * params);
|
||||
static gboolean gst_gl_color_convert_element_decide_allocation (GstBaseTransform
|
||||
* trans, GstQuery * query);
|
||||
static GstFlowReturn
|
||||
|
@ -92,6 +95,7 @@ gst_gl_color_convert_element_class_init (GstGLColorConvertElementClass * klass)
|
|||
bt_class->transform_caps = gst_gl_color_convert_element_transform_caps;
|
||||
bt_class->set_caps = gst_gl_color_convert_element_set_caps;
|
||||
bt_class->get_unit_size = gst_gl_color_convert_element_get_unit_size;
|
||||
bt_class->filter_meta = gst_gl_color_convert_element_filter_meta;
|
||||
bt_class->decide_allocation = gst_gl_color_convert_element_decide_allocation;
|
||||
bt_class->prepare_output_buffer =
|
||||
gst_gl_color_convert_element_prepare_output_buffer;
|
||||
|
@ -159,6 +163,14 @@ gst_gl_color_convert_element_get_unit_size (GstBaseTransform * trans,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_color_convert_element_filter_meta (GstBaseTransform * trans,
|
||||
GstQuery * query, GType api, const GstStructure * params)
|
||||
{
|
||||
/* propose all metadata upstream */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_color_convert_element_decide_allocation (GstBaseTransform * trans,
|
||||
GstQuery * query)
|
||||
|
|
|
@ -45,6 +45,8 @@ static GstCaps *_gst_gl_upload_element_transform_caps (GstBaseTransform * bt,
|
|||
GstPadDirection direction, GstCaps * caps, GstCaps * filter);
|
||||
static gboolean _gst_gl_upload_element_set_caps (GstBaseTransform * bt,
|
||||
GstCaps * in_caps, GstCaps * out_caps);
|
||||
static gboolean gst_gl_upload_element_filter_meta (GstBaseTransform * trans,
|
||||
GstQuery * query, GType api, const GstStructure * params);
|
||||
static gboolean _gst_gl_upload_element_propose_allocation (GstBaseTransform *
|
||||
bt, GstQuery * decide_query, GstQuery * query);
|
||||
static gboolean _gst_gl_upload_element_decide_allocation (GstBaseTransform *
|
||||
|
@ -72,6 +74,7 @@ gst_gl_upload_element_class_init (GstGLUploadElementClass * klass)
|
|||
bt_class->query = gst_gl_upload_element_query;
|
||||
bt_class->transform_caps = _gst_gl_upload_element_transform_caps;
|
||||
bt_class->set_caps = _gst_gl_upload_element_set_caps;
|
||||
bt_class->filter_meta = gst_gl_upload_element_filter_meta;
|
||||
bt_class->propose_allocation = _gst_gl_upload_element_propose_allocation;
|
||||
bt_class->decide_allocation = _gst_gl_upload_element_decide_allocation;
|
||||
bt_class->get_unit_size = gst_gl_upload_element_get_unit_size;
|
||||
|
@ -139,37 +142,29 @@ _gst_gl_upload_element_transform_caps (GstBaseTransform * bt,
|
|||
return gst_gl_upload_transform_caps (context, direction, caps, filter);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_upload_element_filter_meta (GstBaseTransform * trans, GstQuery * query,
|
||||
GType api, const GstStructure * params)
|
||||
{
|
||||
/* propose all metadata upstream */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_gst_gl_upload_element_propose_allocation (GstBaseTransform * bt,
|
||||
GstQuery * decide_query, GstQuery * query)
|
||||
{
|
||||
guint alloc_index;
|
||||
gboolean alloc_has_overlay_meta;
|
||||
GstGLUploadElement *upload = GST_GL_UPLOAD_ELEMENT (bt);
|
||||
gboolean ret;
|
||||
|
||||
if (!upload->upload)
|
||||
return FALSE;
|
||||
|
||||
alloc_has_overlay_meta =
|
||||
gst_query_find_allocation_meta (decide_query,
|
||||
GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, &alloc_index);
|
||||
|
||||
if (alloc_has_overlay_meta) {
|
||||
const GstStructure *params;
|
||||
GST_DEBUG ("adding allocation meta in upload for textoverlay");
|
||||
|
||||
/* read window size from decide_query */
|
||||
gst_query_parse_nth_allocation_meta (decide_query, alloc_index, ¶ms);
|
||||
|
||||
/* it does not matter if params are NULL (no known window size), forward
|
||||
* the meta in any case */
|
||||
gst_query_add_allocation_meta (query,
|
||||
GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, params);
|
||||
}
|
||||
|
||||
ret = GST_BASE_TRANSFORM_CLASS (parent_class)->propose_allocation (bt,
|
||||
decide_query, query);
|
||||
gst_gl_upload_propose_allocation (upload->upload, decide_query, query);
|
||||
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -69,8 +69,6 @@ static gboolean gst_gl_base_filter_start (GstBaseTransform * bt);
|
|||
static gboolean gst_gl_base_filter_stop (GstBaseTransform * bt);
|
||||
static gboolean gst_gl_base_filter_decide_allocation (GstBaseTransform * trans,
|
||||
GstQuery * query);
|
||||
static gboolean gst_gl_base_filter_propose_allocation (GstBaseTransform * trans,
|
||||
GstQuery * decide_query, GstQuery * query);
|
||||
|
||||
/* GstGLContextThreadFunc */
|
||||
static void gst_gl_base_filter_gl_start (GstGLContext * context, gpointer data);
|
||||
|
@ -95,8 +93,6 @@ gst_gl_base_filter_class_init (GstGLBaseFilterClass * klass)
|
|||
GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_base_filter_stop;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->decide_allocation =
|
||||
gst_gl_base_filter_decide_allocation;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->propose_allocation =
|
||||
gst_gl_base_filter_propose_allocation;
|
||||
|
||||
element_class->set_context = gst_gl_base_filter_set_context;
|
||||
element_class->change_state = gst_gl_base_filter_change_state;
|
||||
|
@ -365,7 +361,8 @@ gst_gl_base_filter_decide_allocation (GstBaseTransform * trans,
|
|||
goto error;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans,
|
||||
query);
|
||||
|
||||
context_error:
|
||||
{
|
||||
|
@ -381,13 +378,6 @@ error:
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_base_filter_propose_allocation (GstBaseTransform * trans,
|
||||
GstQuery * decide_query, GstQuery * query)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_gl_base_filter_change_state (GstElement * element,
|
||||
GstStateChange transition)
|
||||
|
|
Loading…
Reference in a new issue