v4l2provider: Fix device type detection

The type detection would lead to assertion as it would try
to create a device without having found any type for it. It
also didn't detect MPLANE devices properly.
This commit is contained in:
Nicolas Dufresne 2016-07-11 18:30:18 -04:00
parent f0678d73b1
commit ab075b2013

View file

@ -136,22 +136,30 @@ gst_v4l2_device_provider_probe_device (GstV4l2DeviceProvider * provider,
gst_structure_set (props, "v4l2.device.device_caps", G_TYPE_UINT,
v4l2obj->vcap.device_caps, NULL);
if (v4l2obj->device_caps & V4L2_CAP_VIDEO_CAPTURE)
if (v4l2obj->device_caps &
(V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE))
type = GST_V4L2_DEVICE_TYPE_SOURCE;
if (v4l2obj->device_caps & V4L2_CAP_VIDEO_OUTPUT) {
/* Morph it in case our initial guess was wrong */
v4l2obj->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
if (type == GST_V4L2_DEVICE_TYPE_INVALID)
type = GST_V4L2_DEVICE_TYPE_SINK;
else
/* We ignore M2M devices that are both capture and output for now
* The provider is not for them
*/
if (v4l2obj->device_caps &
(V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE)) {
/* We ignore M2M devices that are both capture and output for now
* The provider is not for them */
if (type != GST_V4L2_DEVICE_TYPE_INVALID)
goto close;
type = GST_V4L2_DEVICE_TYPE_SINK;
/* We have opened as a capture as we didn't know, now that know,
* let's fixed it */
if (v4l2obj->device_caps & V4L2_CAP_VIDEO_OUTPUT_MPLANE)
v4l2obj->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
else
v4l2obj->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
}
if (type == GST_V4L2_DEVICE_TYPE_INVALID)
goto close;
caps = gst_v4l2_object_get_caps (v4l2obj, NULL);
if (caps == NULL)