stream pushing ok without access permission of /dev/video0
[rtmpclient.git] / app / src / main / jni / libuvc-0.0.6 / src / device.c
index a987735..57474ff 100644 (file)
@@ -263,6 +263,37 @@ uint8_t uvc_get_device_address(uvc_device_t *dev) {
   return libusb_get_device_address(dev->usb_dev);
 }
 
+/**
+ * XXX add for non-rooted Android device, >= Android7
+ * generate fake libusb_device according to specific params
+ * and set it to uvc_device_t to access UVC device on Android7 or later
+ */
+uvc_error_t uvc_get_device_with_fd(uvc_context_t *ctx, uvc_device_t **device,
+               int vid, int pid, const char *serial, int fd, int busnum, int devaddr) {
+
+
+       //LOGD("call libusb_get_device_with_fd");
+    UVC_DEBUG("call uvc_get_device_with_fd");
+       struct libusb_device *usb_dev = libusb_get_device_with_fd(ctx->usb_ctx, vid, pid, serial, fd, busnum, devaddr);
+
+       if (usb_dev != NULL) {
+               *device = malloc(sizeof(uvc_device_t/* *device */));
+               (*device)->ctx = ctx;
+               (*device)->ref = 0;
+               (*device)->usb_dev = usb_dev;
+//             libusb_set_device_fd(usb_dev, fd);      // assign fd to libusb_device for non-rooted Android devices
+               uvc_ref_device(*device);
+               UVC_EXIT(UVC_SUCCESS);
+               //RETURN(UVC_SUCCESS, int);
+       } else {
+        UVC_DEBUG("could not find specific device");
+               *device = NULL;
+               UVC_EXIT(UVC_ERROR_NO_DEVICE);
+               //RETURN(UVC_ERROR_NO_DEVICE, int);
+       }
+}
+
+
 /** @brief Open a UVC device
  * @ingroup device
  *