summaryrefslogtreecommitdiff
path: root/gst-decoder.c
diff options
context:
space:
mode:
authorCarlos Rafael Giani <dv@pseudoterminal.org>2017-04-26 20:56:17 +0200
committerRob Clark <robdclark@gmail.com>2017-04-29 10:23:41 -0400
commit76d2b93f40f670ac4bcd22cc1f5a6e437f3131db (patch)
tree45a71aacd2299a9b9d73368c9b49f2bc4260b0aa /gst-decoder.c
parenta07e4dabed604bbc7ff9fa6eea58eb009af24197 (diff)
downloadkmscube-76d2b93f40f670ac4bcd22cc1f5a6e437f3131db.tar.gz
gst-decoder.c: Use element factory name to detect V4L2 video decoder
Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>
Diffstat (limited to 'gst-decoder.c')
-rw-r--r--gst-decoder.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/gst-decoder.c b/gst-decoder.c
index 51304a2..05d73b7 100644
--- a/gst-decoder.c
+++ b/gst-decoder.c
@@ -115,15 +115,24 @@ gst_thread_func(void *args)
static void
element_added_cb(GstBin *bin, GstElement *element, gpointer user_data)
{
+ GstElementFactory *elem_factory;
+ gchar const *factory_name;
+
(void)user_data;
(void)bin;
- printf("added: %s\n", GST_OBJECT_NAME(element));
+ elem_factory = gst_element_get_factory(element);
+ factory_name = gst_plugin_feature_get_name(elem_factory);
+
+ GST_DEBUG("added element %s (created with factory %s)", GST_OBJECT_NAME(element), factory_name);
- // XXX is there a better way to do this, like match class name?
- if (strstr(GST_OBJECT_NAME(element), "v4l2video0dec") == GST_OBJECT_NAME(element)) {
+ /* v4l2 video decoder factories are generated by the GStreamer v4l probe.
+ * The format is v4l2videoNdec, where N is an integer. So, check if the
+ * element's factory name fits this pattern. */
+ if (g_str_has_prefix(factory_name, "v4l2video") && g_str_has_suffix(factory_name, "dec")) {
/* yes, "capture" rather than "output" because v4l2 is bonkers */
gst_util_set_object_arg(G_OBJECT(element), "capture-io-mode", "dmabuf");
+ printf("found GStreamer V4L2 video decoder element with name \"%s\"\n", GST_OBJECT_NAME(element));
}
}