gst-decoder.c: Use element factory name to detect V4L2 video decoder
Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>
Carlos Rafael Giani authored 7 years ago
Rob Clark committed 7 years ago
114 | 114 | static void |
115 | 115 | element_added_cb(GstBin *bin, GstElement *element, gpointer user_data) |
116 | 116 | { |
117 | GstElementFactory *elem_factory; | |
118 | gchar const *factory_name; | |
119 | ||
117 | 120 | (void)user_data; |
118 | 121 | (void)bin; |
119 | 122 | |
120 | printf("added: %s\n", GST_OBJECT_NAME(element)); | |
121 | ||
122 | // XXX is there a better way to do this, like match class name? | |
123 | if (strstr(GST_OBJECT_NAME(element), "v4l2video0dec") == GST_OBJECT_NAME(element)) { | |
123 | elem_factory = gst_element_get_factory(element); | |
124 | factory_name = gst_plugin_feature_get_name(elem_factory); | |
125 | ||
126 | GST_DEBUG("added element %s (created with factory %s)", GST_OBJECT_NAME(element), factory_name); | |
127 | ||
128 | /* v4l2 video decoder factories are generated by the GStreamer v4l probe. | |
129 | * The format is v4l2videoNdec, where N is an integer. So, check if the | |
130 | * element's factory name fits this pattern. */ | |
131 | if (g_str_has_prefix(factory_name, "v4l2video") && g_str_has_suffix(factory_name, "dec")) { | |
124 | 132 | /* yes, "capture" rather than "output" because v4l2 is bonkers */ |
125 | 133 | gst_util_set_object_arg(G_OBJECT(element), "capture-io-mode", "dmabuf"); |
134 | printf("found GStreamer V4L2 video decoder element with name \"%s\"\n", GST_OBJECT_NAME(element)); | |
126 | 135 | } |
127 | 136 | } |
128 | 137 |