summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2012-03-12 13:50:46 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2012-03-12 13:50:46 +0100
commit575cb87091dae408050f00652643d234bc4c2723 (patch)
tree53a7197bc37b79b674035aafb067da538fac8374
parentbd13c104c2cc1beae7920e0b1e3b6185834a1ef3 (diff)
ffdec: implement accept-caps
Implement a potentially faster accept-caps function
-rw-r--r--ext/ffmpeg/gstffmpegdec.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c
index f595e13..4f65e9c 100644
--- a/ext/ffmpeg/gstffmpegdec.c
+++ b/ext/ffmpeg/gstffmpegdec.c
@@ -239,6 +239,8 @@ static gboolean gst_ffmpegdec_src_event (GstPad * pad, GstObject * parent,
static gboolean gst_ffmpegdec_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event);
+static gboolean gst_ffmpegdec_sink_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
static GstFlowReturn gst_ffmpegdec_chain (GstPad * pad, GstObject * parent,
GstBuffer * buf);
@@ -430,6 +432,8 @@ gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec)
ffmpegdec->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
gst_pad_set_event_function (ffmpegdec->sinkpad,
GST_DEBUG_FUNCPTR (gst_ffmpegdec_sink_event));
+ gst_pad_set_query_function (ffmpegdec->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_ffmpegdec_sink_query));
gst_pad_set_chain_function (ffmpegdec->sinkpad,
GST_DEBUG_FUNCPTR (gst_ffmpegdec_chain));
gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->sinkpad);
@@ -2688,6 +2692,44 @@ invalid_format:
}
}
+static gboolean
+gst_ffmpegdec_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
+{
+ GstFFMpegDec *ffmpegdec;
+ gboolean ret = FALSE;
+
+ ffmpegdec = (GstFFMpegDec *) parent;
+
+ GST_DEBUG_OBJECT (ffmpegdec, "Handling %s query",
+ GST_QUERY_TYPE_NAME (query));
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_ACCEPT_CAPS:
+ {
+ GstPadTemplate *templ;
+
+ ret = FALSE;
+ if ((templ = GST_PAD_PAD_TEMPLATE (pad))) {
+ GstCaps *tcaps;
+
+ if ((tcaps = GST_PAD_TEMPLATE_CAPS (templ))) {
+ GstCaps *caps;
+
+ gst_query_parse_accept_caps (query, &caps);
+ gst_query_set_accept_caps_result (query,
+ gst_caps_is_subset (caps, tcaps));
+ ret = TRUE;
+ }
+ }
+ break;
+ }
+ default:
+ ret = gst_pad_query_default (pad, parent, query);
+ break;
+ }
+ return ret;
+}
+
static GstFlowReturn
gst_ffmpegdec_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
{