X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjni%2Flibuvc-0.0.6%2Fsrc%2Fdevice.c;h=57474fff8aa1c9b573f0cc6d64399aa2f58190e2;hb=d0d496554f96cebf84db3e9b3cf507577272ef8c;hp=a987735bb29cece1e92aa629191da08d31220e9d;hpb=577426ccc66649228285c4a0b6ba8752836059c6;p=rtmpclient.git diff --git a/app/src/main/jni/libuvc-0.0.6/src/device.c b/app/src/main/jni/libuvc-0.0.6/src/device.c index a987735..57474ff 100644 --- a/app/src/main/jni/libuvc-0.0.6/src/device.c +++ b/app/src/main/jni/libuvc-0.0.6/src/device.c @@ -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 *