+ if (asprintf (&mrl, "v4l2://%s", 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, ITEM_TYPE_CARD,
+ };
+
+ return Open (obj, &subsys);
+}
+
+
+#ifdef HAVE_ALSA
+/*** Advanced Linux Sound Architecture support ***/
+#include <alsa/asoundlib.h>
+
+static int alsa_get_device (struct udev_device *dev, unsigned *restrict pcard,
+ unsigned *restrict pdevice)
+{
+ const char *node = udev_device_get_devpath (dev);
+ char type;
+
+ node = strrchr (node, '/');
+ if (node == NULL)
+ return -1;
+ if (sscanf (node, "/pcmC%uD%u%c", pcard, pdevice, &type) < 3)
+ return -1;
+ if (type != 'c')
+ return -1;
+ return 0;
+}
+
+
+static char *alsa_get_mrl (struct udev_device *dev)
+{
+ /* Determine media location */
+ char *mrl;
+ unsigned card, device;
+
+ if (alsa_get_device (dev, &card, &device))
+ return NULL;
+
+ if (asprintf (&mrl, "alsa://plughw:%u,%u", card, device) == -1)
+ mrl = NULL;
+ return mrl;
+}
+
+static char *alsa_get_name (struct udev_device *dev)
+{
+ char *name = NULL;
+ unsigned card, device;
+
+ if (alsa_get_device (dev, &card, &device))
+ return NULL;
+
+ char card_name[4 + 3 * sizeof (int)];
+ snprintf (card_name, sizeof (card_name), "hw:%u", card);
+
+ snd_ctl_t *ctl;
+ if (snd_ctl_open (&ctl, card_name, 0))
+ return NULL;
+
+ snd_pcm_info_t *pcm_info;
+ snd_pcm_info_alloca (&pcm_info);
+ snd_pcm_info_set_device (pcm_info, device);
+ snd_pcm_info_set_subdevice (pcm_info, 0);
+ snd_pcm_info_set_stream (pcm_info, SND_PCM_STREAM_CAPTURE);
+ if (snd_ctl_pcm_info (ctl, pcm_info))
+ goto out;
+
+ name = strdup (snd_pcm_info_get_name (pcm_info));
+out:
+ snd_ctl_close (ctl);
+ return name;
+}
+
+static char *alsa_get_cat (struct udev_device *dev)
+{
+ const char *vnd;