title: Android device node name for attached usb device
body: <p>I am currently writing an application for an Android nexus 5 phone. The application uses gstreamer that runs natively to access a usb webcam that has been plugged into the device. In order to access the webcam I need the device node location of the webcam. Generally it is /dev/video3 but sometimes it changes values, ie /dev/video4</p>
  
  <p>Currently I have to set the device node location manually for this to work. I wish to render the process automatic. Especially given the case where a user could disconnect and reconnect the webcam.</p>
  
  <p>So far, I can determine the vendorID, productID from Java, I then pass this info to my C code using JNI. </p>
  
  <p>I use the following to detect the USB device info :</p>
  
  <pre><code>if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) 
          {
              deviceFound = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
  
              Log.i("TAG", "USB DEVICE ATTACHED");
  
              deviceFound.getDeviceName();
              deviceFound.getVendorId();
              deviceFound.getProductId();
  
          }
  </code></pre>
  
  <p>getDeviceName returns a string that contains "/dev/bus/usb/001/002". If I try using this to access my webcam using gstreamer I get the following error "Error getting capabilities for device '/dev/bus/usb/001/002': It isn't a v4l2 driver"</p>
  
  <p>I'm assuming that /dev/bus/usb/002/001 isn't quite the same as /dev/video3 in this case. A few questions :</p>
  
  <p>1) Can I obtain the correct device node ie /dev/video3 using /dev/bus/usb/001/002 ?</p>
  
  <p>2) Is there a way of directly obtaining the device node (/dev/video*) given the USB device's vendor &amp; product identifiers programmatically ?</p>
  
  <p>Thanks.</p>