[Mesa-dev] [PATCH v3 05/12] gst-decoder.c: Use element factory name to detect V4L2 video decoder
Carlos Rafael Giani
dv at pseudoterminal.org
Wed Apr 26 18:56:17 UTC 2017
Signed-off-by: Carlos Rafael Giani <dv at pseudoterminal.org>
---
gst-decoder.c | 15 ++++++++++++---
1 file 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));
}
}
--
2.7.4
More information about the mesa-dev
mailing list