summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 11af04d)
raw | patch | inline | side by side (parent: 11af04d)
author | Alessandro Decina <alessandro.decina@collabora.co.uk> | |
Thu, 24 May 2012 06:16:28 +0000 (06:16 +0000) | ||
committer | Alessandro Decina <alessandro.decina@collabora.co.uk> | |
Thu, 24 May 2012 06:16:28 +0000 (06:16 +0000) |
Implement the GstVideoContext interface to share the drm fd with
other elements in the pipeline
other elements in the pipeline
src/gstducatividdec.c | patch | blob | history |
diff --git a/src/gstducatividdec.c b/src/gstducatividdec.c
index 4c961b06049a70d7e88d923995c17b89b1aa379b..f6f98528766bb144bcdea4d63cf4b7240d37e231 100644 (file)
--- a/src/gstducatividdec.c
+++ b/src/gstducatividdec.c
#include "gstducatividdec.h"
#include "gstducatidrmbuffer.h"
+#include <gst/video/videocontext.h>
-GST_BOILERPLATE (GstDucatiVidDec, gst_ducati_viddec, GstElement,
- GST_TYPE_ELEMENT);
+typedef GstVideoContextInterface GstVideoContextClass;
+GST_BOILERPLATE_WITH_INTERFACE (GstDucatiVidDec, gst_ducati_viddec, GstElement,
+ GST_TYPE_ELEMENT, GstVideoContext, GST_TYPE_VIDEO_CONTEXT,
+ gst_ducati_video_context);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
{
gboolean ret;
int ec;
+ const gchar *context_types[] = { "drm-fd", NULL };
- if (G_UNLIKELY (self->engine)) {
- return TRUE;
- }
+ /* this will result in calling gst_ducati_viddec_set_video_context, and
+ * therefore dce_set_fd, if the app or downstream elements provide a drm fd
+ */
+ gst_video_context_prepare (GST_VIDEO_CONTEXT (self), context_types);
+ self->device = dce_init ();
if (self->device == NULL) {
- self->device = dce_init ();
- if (self->device == NULL) {
- GST_ERROR_OBJECT (self, "dce_init() failed");
- return FALSE;
- }
-
- self->allocator =
- GST_DUCATI_BUFFER_ALLOCATOR (gst_ducati_drm_buffer_allocator_new
- (self->device));
+ GST_ERROR_OBJECT (self, "dce_init() failed");
+ return FALSE;
}
+ self->allocator =
+ GST_DUCATI_BUFFER_ALLOCATOR (gst_ducati_drm_buffer_allocator_new
+ (self->device));
+
GST_DEBUG_OBJECT (self, "opening engine");
self->engine = Engine_open ((String) "ivahd_vidsvr", NULL, &ec);
if (G_UNLIKELY (!self->engine)) {
GST_ERROR_OBJECT (self, "could not create engine");
+ gst_mini_object_unref (GST_MINI_OBJECT (self->allocator));
+ self->allocator = NULL;
+ dce_deinit (self->device);
+ self->device = NULL;
+
return FALSE;
}
self->padded_width, self->padded_height);
*forward = FALSE;
break;
+ case GST_QUERY_CUSTOM:
+ {
+ const gchar **types;
+ gint i;
+ GstStructure *structure;
+
+ structure = gst_query_get_structure (query);
+ if (strcmp (gst_structure_get_name (structure), "prepare-video-context"))
+ break;
+
+ types = gst_video_context_query_get_supported_types (query);
+ for (i = 0; types[i]; i++) {
+ if (strcmp (types[i], "drm-fd"))
+ continue;
+
+ if (dce_get_fd () != -1) {
+ gst_structure_set (structure,
+ "video-context-type", G_TYPE_STRING, types[i],
+ "video-context", G_TYPE_INT, dce_get_fd (), NULL);
+ }
+
+ break;
+ }
+
+ break;
+ }
default:
break;
}
@@ -1324,3 +1358,27 @@ gst_ducati_viddec_init (GstDucatiVidDec * self, GstDucatiVidDecClass * klass)
self->device = NULL;
self->input_bo = NULL;
}
+
+static void
+gst_ducati_viddec_set_video_context (GstVideoContext * context,
+ const gchar * type, const GValue * value)
+{
+ int fd;
+
+ fd = g_value_get_int (value);
+ dce_set_fd (fd);
+}
+
+static void
+gst_ducati_video_context_interface_init (GstVideoContextInterface * iface)
+{
+ iface->set_context = gst_ducati_viddec_set_video_context;
+}
+
+static gboolean
+gst_ducati_video_context_supported (GstDucatiVidDec * dec, GType type)
+{
+ if (type == GST_TYPE_VIDEO_CONTEXT)
+ return TRUE;
+ return FALSE;
+}