harness: Add API for proposing meta APIs from the allocation query

https://bugzilla.gnome.org/show_bug.cgi?id=797350
This commit is contained in:
Sebastian Dröge 2018-10-28 15:19:38 +00:00
parent 80015d69a7
commit c3214e8deb
4 changed files with 68 additions and 1 deletions

View file

@ -1347,6 +1347,8 @@ gst_harness_set_upstream_latency
gst_harness_set_propose_allocator gst_harness_set_propose_allocator
gst_harness_get_allocator gst_harness_get_allocator
gst_harness_add_propose_allocation_meta
gst_harness_add_src gst_harness_add_src
gst_harness_add_src_harness gst_harness_add_src_harness
gst_harness_add_src_parse gst_harness_add_src_parse

View file

@ -107,6 +107,7 @@ LIBGSTCHECK_EXPORTED_FUNCS = \
gst_harness_add_element_sink_pad \ gst_harness_add_element_sink_pad \
gst_harness_add_parse \ gst_harness_add_parse \
gst_harness_add_probe \ gst_harness_add_probe \
gst_harness_add_propose_allocation_meta \
gst_harness_add_sink \ gst_harness_add_sink \
gst_harness_add_sink_harness \ gst_harness_add_sink_harness \
gst_harness_add_sink_parse \ gst_harness_add_sink_parse \

View file

@ -147,6 +147,19 @@ static GstStaticPadTemplate hsinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY); GST_STATIC_CAPS_ANY);
typedef struct
{
GType api;
GstStructure *params;
} ProposeMeta;
static void
propose_meta_clear (ProposeMeta * meta)
{
if (meta->params)
gst_structure_free (meta->params);
}
struct _GstHarnessPrivate struct _GstHarnessPrivate
{ {
gchar *element_sinkpad_name; gchar *element_sinkpad_name;
@ -179,6 +192,8 @@ struct _GstHarnessPrivate
GstAllocator *propose_allocator; GstAllocator *propose_allocator;
GstAllocationParams propose_allocation_params; GstAllocationParams propose_allocation_params;
GArray *propose_allocation_metas;
gboolean blocking_push_mode; gboolean blocking_push_mode;
GCond blocking_push_cond; GCond blocking_push_cond;
GMutex blocking_push_mutex; GMutex blocking_push_mutex;
@ -390,6 +405,15 @@ gst_harness_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
gst_query_add_allocation_param (query, gst_query_add_allocation_param (query,
priv->propose_allocator, &priv->propose_allocation_params); priv->propose_allocator, &priv->propose_allocation_params);
if (priv->propose_allocation_metas) {
guint i;
for (i = 0; i < priv->propose_allocation_metas->len; i++) {
ProposeMeta *meta =
&g_array_index (priv->propose_allocation_metas, ProposeMeta, i);
gst_query_add_allocation_meta (query, meta->api, meta->params);
}
}
GST_DEBUG_OBJECT (pad, "proposing allocation %" GST_PTR_FORMAT, GST_DEBUG_OBJECT (pad, "proposing allocation %" GST_PTR_FORMAT,
priv->propose_allocator); priv->propose_allocator);
} }
@ -1052,6 +1076,9 @@ gst_harness_teardown (GstHarness * h)
gst_object_replace ((GstObject **) & priv->allocator, NULL); gst_object_replace ((GstObject **) & priv->allocator, NULL);
gst_object_replace ((GstObject **) & priv->pool, NULL); gst_object_replace ((GstObject **) & priv->pool, NULL);
if (priv->propose_allocation_metas)
g_array_unref (priv->propose_allocation_metas);
/* if we hold the last ref, set to NULL */ /* if we hold the last ref, set to NULL */
if (gst_harness_element_unref (h) == 0) { if (gst_harness_element_unref (h) == 0) {
gboolean state_change; gboolean state_change;
@ -2161,6 +2188,38 @@ gst_harness_set_propose_allocator (GstHarness * h, GstAllocator * allocator,
priv->propose_allocation_params = *params; priv->propose_allocation_params = *params;
} }
/**
* gst_harness_add_propose_allocation_meta:
* @h: a #GstHarness
* @api: a metadata API
* @params: (allow-none) (transfer none): API specific parameters
*
* Add api with params as one of the supported metadata API to propose when
* receiving an allocation query.
*
* MT safe.
*
* Since: 1.16
*/
void
gst_harness_add_propose_allocation_meta (GstHarness * h, GType api,
const GstStructure * params)
{
GstHarnessPrivate *priv = h->priv;
ProposeMeta meta;
meta.api = api;
meta.params = params ? gst_structure_copy (params) : NULL;
if (!priv->propose_allocation_metas) {
priv->propose_allocation_metas =
g_array_new (FALSE, FALSE, sizeof (ProposeMeta));
g_array_set_clear_func (priv->propose_allocation_metas,
(GDestroyNotify) propose_meta_clear);
}
g_array_append_val (priv->propose_allocation_metas, meta);
}
/** /**
* gst_harness_add_src_harness: * gst_harness_add_src_harness:
* @h: a #GstHarness * @h: a #GstHarness

View file

@ -257,7 +257,7 @@ GstClockTime gst_harness_query_latency (GstHarness * h);
GST_CHECK_API GST_CHECK_API
void gst_harness_set_upstream_latency (GstHarness * h, GstClockTime latency); void gst_harness_set_upstream_latency (GstHarness * h, GstClockTime latency);
/* allocator and allocation params */ /* allocation query parameters */
GST_CHECK_API GST_CHECK_API
void gst_harness_set_propose_allocator (GstHarness * h, void gst_harness_set_propose_allocator (GstHarness * h,
@ -269,6 +269,11 @@ void gst_harness_get_allocator (GstHarness * h,
GstAllocator ** allocator, GstAllocator ** allocator,
GstAllocationParams * params); GstAllocationParams * params);
GST_CHECK_API
void gst_harness_add_propose_allocation_meta (GstHarness * h,
GType api,
const GstStructure * params);
/* src-harness */ /* src-harness */
GST_CHECK_API GST_CHECK_API