Ver código fonte

linux-v4l2: Fix build when missing CAP_DEVICE_CAPS

Improve compatibility with older versions of the api by not requiring
V4L2_CAP_DEVICE_CAPS. If we don't have this, we fall back to using the
capabilities member for the whole device instead of the device_caps
member for the currently selected subdevice. Just like we would do if
the device would not support this.
The new device_caps field was introduced with Linux 3.3.
fryshorts 10 anos atrás
pai
commit
85518e7cca
1 arquivos alterados com 10 adições e 0 exclusões
  1. 10 0
      plugins/linux-v4l2/v4l2-input.c

+ 10 - 0
plugins/linux-v4l2/v4l2-input.c

@@ -298,9 +298,14 @@ static void v4l2_device_list(obs_property_t *prop, obs_data_t *settings)
 			continue;
 		}
 
+#ifndef V4L2_CAP_DEVICE_CAPS
+		caps = video_cap.capabilities;
+#else
+		/* ... since Linux 3.3 */
 		caps = (video_cap.capabilities & V4L2_CAP_DEVICE_CAPS)
 			? video_cap.device_caps
 			: video_cap.capabilities;
+#endif
 
 		if (!(caps & V4L2_CAP_VIDEO_CAPTURE)) {
 			blog(LOG_INFO, "%s seems to not support video capture",
@@ -924,6 +929,11 @@ static void *v4l2_create(obs_data_t *settings, obs_source_t *source)
 	data->dev = -1;
 	data->source = source;
 
+	/* Bitch about build problems ... */
+#ifndef V4L2_CAP_DEVICE_CAPS
+	blog(LOG_WARNING, "Plugin built without device caps support!");
+#endif
+
 	v4l2_update(data, settings);
 
 #if HAVE_UDEV