plugins: fix detection of upstream v4l2src element.

Improve check for upstream element that requires DMABUF buffer pool,
e.g. v4l2src element. In particular, make sure to traverse through
any additional capsfilter for instance.

Note: the traversal to the top-most upstream element could be made
more generic, but we are insofar only interested in supporting pipes
similar to v4l2src or v4l2src ! capsfilter, e.g. with an explicit
specification for a desired video camera format, or resolution.
This commit is contained in:
Gwenole Beauchesne 2015-03-02 13:28:41 +01:00
parent 8b91ddac0b
commit 336eddffa5

View file

@ -433,27 +433,46 @@ has_dmabuf_capable_peer (GstVaapiPluginBase * plugin, GstPad * pad)
gboolean is_dmabuf_capable = FALSE;
gint v;
do {
gst_object_ref (pad);
for (;;) {
other_pad = gst_pad_get_peer (pad);
gst_object_unref (pad);
if (!other_pad)
break;
element = gst_pad_get_parent_element (other_pad);
if (!element || !GST_IS_PUSH_SRC (element))
gst_object_unref (other_pad);
if (!element)
break;
element_name = gst_element_get_name (element);
if (!element_name || sscanf (element_name, "v4l2src%d", &v) != 1)
if (GST_IS_PUSH_SRC (element)) {
element_name = gst_element_get_name (element);
if (!element_name || sscanf (element_name, "v4l2src%d", &v) != 1)
break;
v = 0;
g_object_get (element, "io-mode", &v, NULL);
is_dmabuf_capable = v == 5; /* "dmabuf-import" enum value */
break;
} else if (GST_IS_BASE_TRANSFORM (element)) {
element_name = gst_element_get_name (element);
if (!element_name || sscanf (element_name, "capsfilter%d", &v) != 1)
break;
pad = gst_element_get_static_pad (element, "sink");
if (!pad)
break;
} else
break;
v = 0;
g_object_get (element, "io-mode", &v, NULL);
is_dmabuf_capable = v == 5; /* "dmabuf-import" enum value */
} while (0);
g_free (element_name);
element_name = NULL;
g_clear_object (&element);
}
g_free (element_name);
g_clear_object (&element);
g_clear_object (&other_pad);
return is_dmabuf_capable;
}