Signed-off-by: Carlos Rafael Giani <d...@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

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to