From 354f16a5cafbb2b543b7873cf30bedcc8935523a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Zanelli?= Date: Mon, 11 Jan 2016 15:46:16 +0100 Subject: [PATCH] rawparse: add 'decide_allocation' vfunc to let subclass parse an allocation query And so send an allocation query. This could be used to check whether downstream element supports some metas or not. https://bugzilla.gnome.org/show_bug.cgi?id=760270 --- gst/rawparse/gstrawparse.c | 16 ++++++++++++++++ gst/rawparse/gstrawparse.h | 1 + 2 files changed, 17 insertions(+) diff --git a/gst/rawparse/gstrawparse.c b/gst/rawparse/gstrawparse.c index 3d043fd497..a6468d9328 100644 --- a/gst/rawparse/gstrawparse.c +++ b/gst/rawparse/gstrawparse.c @@ -222,6 +222,22 @@ gst_raw_parse_set_src_caps (GstRawParse * rp) } rp->negotiated = gst_pad_set_caps (rp->srcpad, caps); + + /* if subclass inplement decide_allocation, send an allocation + * query, pass result to subclass and let it handle allocation if needed. */ + if (rp_class->decide_allocation) { + GstQuery *query; + + query = gst_query_new_allocation (caps, TRUE); + if (!gst_pad_peer_query (rp->srcpad, query)) { + /* not a problem, just debug a little */ + GST_DEBUG_OBJECT (rp, "peer ALLOCATION query failed"); + } + + rp_class->decide_allocation (rp, query); + gst_query_unref (query); + } + gst_caps_unref (caps); return rp->negotiated; diff --git a/gst/rawparse/gstrawparse.h b/gst/rawparse/gstrawparse.h index 944240bbc9..2327dc6fb5 100644 --- a/gst/rawparse/gstrawparse.h +++ b/gst/rawparse/gstrawparse.h @@ -78,6 +78,7 @@ struct _GstRawParseClass GstCaps * (*get_caps) (GstRawParse *rp); void (*pre_push_buffer) (GstRawParse *rp, GstBuffer *buffer); + void (*decide_allocation) (GstRawParse *rp, GstQuery *query); gboolean multiple_frames_per_buffer; };