+
+/*** Video4Linux support ***/
+static bool is_v4l_legacy (struct udev_device *dev)
+{
+ const char *version;
+
+ version = udev_device_get_property_value (dev, "ID_V4L_VERSION");
+ return version && !strcmp (version, "1");
+}
+
+static char *v4l_get_mrl (struct udev_device *dev)
+{
+ /* Determine media location */
+ const char *scheme = "v4l2";
+ if (is_v4l_legacy (dev))
+ scheme = "v4l";
+ const char *node = udev_device_get_devnode (dev);
+ char *mrl;
+
+ if (asprintf (&mrl, "%s://%s", scheme, node) == -1)
+ mrl = NULL;
+ return mrl;
+}
+
+static char *v4l_get_name (struct udev_device *dev)
+{
+ const char *prd = udev_device_get_property_value (dev, "ID_V4L_PRODUCT");
+ return prd ? strdup (prd) : NULL;
+}
+
+static char *v4l_get_cat (struct udev_device *dev)
+{
+ return decode_property (dev, "ID_VENDOR_ENC");
+}
+
+int OpenV4L (vlc_object_t *obj)
+{
+ static const struct subsys subsys = {
+ "video4linux", v4l_get_mrl, v4l_get_name, v4l_get_cat,
+ };
+
+ return Open (obj, &subsys);
+}