summaryrefslogtreecommitdiff
path: root/gst-decoder.c
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2017-04-26 20:56:22 +0200
committerRob Clark <robdclark@gmail.com>2017-04-29 10:23:41 -0400
commit89a9a69386f849ec79081564a734ce3159e247c3 (patch)
tree7f24992e4f283bcc8d4d89ec42dac2cfb612d009 /gst-decoder.c
parentf7dd2bc30da5ab0448ef716bc238d67a9d1a7304 (diff)
downloadkmscube-89a9a69386f849ec79081564a734ce3159e247c3.tar.gz
gst-decoder.c: advertise support for GstVideoMeta
This way, upstream decoder the produce frame with special strides and offsets won't have to copy the frames. This also ensure DMABuf can be delivered to kmscube. Signed-off-by: Nicolas Dufresne <nicolas@ndufresne.ca>
Diffstat (limited to 'gst-decoder.c')
-rw-r--r--gst-decoder.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gst-decoder.c b/gst-decoder.c
index 17d5407..044c07d 100644
--- a/gst-decoder.c
+++ b/gst-decoder.c
@@ -234,11 +234,26 @@ bus_watch_cb(GstBus *bus, GstMessage *msg, gpointer user_data)
return TRUE;
}
+static GstPadProbeReturn
+appsink_query_cb(GstPad *pad G_GNUC_UNUSED, GstPadProbeInfo *info,
+ gpointer user_data G_GNUC_UNUSED)
+{
+ GstQuery *query = info->data;
+
+ if (GST_QUERY_TYPE (query) != GST_QUERY_ALLOCATION)
+ return GST_PAD_PROBE_OK;
+
+ gst_query_add_allocation_meta(query, GST_VIDEO_META_API_TYPE, NULL);
+
+ return GST_PAD_PROBE_HANDLED;
+}
+
struct decoder *
video_init(const struct egl *egl, const struct gbm *gbm, const char *filename)
{
struct decoder *dec;
GstElement *src, *decodebin;
+ GstPad *pad;
GstBus *bus;
dec = calloc(1, sizeof(*dec));
@@ -253,6 +268,16 @@ video_init(const struct egl *egl, const struct gbm *gbm, const char *filename)
dec->sink = gst_bin_get_by_name(GST_BIN(dec->pipeline), "sink");
+ /* Implement the allocation query using a pad probe. This probe will
+ * adverstize support for GstVideoMeta, which avoid hardware accelerated
+ * decoder that produce special strides and offsets from having to
+ * copy the buffers.
+ */
+ pad = gst_element_get_static_pad(dec->sink, "sink");
+ gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM,
+ appsink_query_cb, NULL, NULL);
+ gst_object_unref(pad);
+
src = gst_bin_get_by_name(GST_BIN(dec->pipeline), "src");
g_object_set(G_OBJECT(src), "location", filename, NULL);
gst_object_unref(src);