X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjni%2FUVCCamera.cpp;h=4fcd52566ef8d2a9418bf8154a11d11e27c0488f;hb=410441c06aa4257d7d9dcb1b581abb4017c67c50;hp=c7c5146dc6896c10c0459ee3fae7e972b31aea4f;hpb=061580c83656bf358b01a6b78fd22ae9bd497728;p=rtmpclient.git diff --git a/app/src/main/jni/UVCCamera.cpp b/app/src/main/jni/UVCCamera.cpp index c7c5146..4fcd525 100644 --- a/app/src/main/jni/UVCCamera.cpp +++ b/app/src/main/jni/UVCCamera.cpp @@ -41,7 +41,7 @@ void UVCCamera::init() LOGE("UVCCamera::init"); } -int UVCCamera::open() +int UVCCamera::open(int vid, int pid, int fd, int busnum, int devaddr, const char* usbFsName) { LOGE("UVCCamera::open"); @@ -50,25 +50,42 @@ int UVCCamera::open() uvc_device_handle_t *devh; uvc_error_t res; - if((res = uvc_init(&ctx, NULL)) < 0){ + char *mUsbFs = strdup(usbFsName); + + fd = dup(fd); + res = uvc_init2(&ctx, NULL, mUsbFs); + if(res < 0){ +// if((res = uvc_init(&ctx, NULL)) < 0){ uvc_perror(res, "unc_init"); return res; } LOGE("UVC Initialized"); - if ((res = uvc_find_device(ctx, &dev, 0, 0, NULL)) < 0){ - uvc_perror(res, "uvc_find_device"); +// if ((res = uvc_find_device(ctx, &dev, 0, 0, NULL)) < 0){ +// uvc_perror(res, "uvc_find_device"); +// return res; +// } +// LOGE("Device Found"); +// + + res = uvc_get_device_with_fd(ctx, &dev, vid, pid, NULL, fd, busnum, devaddr); + if (res < 0){ + LOGE("uvc_get_device_with_fd: %d", __LINE__); + uvc_perror(res, uvc_strerror(res)); + LOGE("uvc_get_device_with_fd error: %s(%d)", uvc_strerror(res), res); return res; } - LOGE("Device Found"); + LOGE("uvc_get_device_with_fd"); + + //uvc_print_diag(mDeviceHandle, stderr); if ((res = uvc_open(dev, &devh)) < 0){ - uvc_perror(res, "uvc_open"); + uvc_perror(res, uvc_strerror(res)); + LOGE("uvc_open error: %s(%d)", uvc_strerror(res), res); return res; } - LOGE("Device Opened"); - uvc_print_diag(devh, stderr); +// uvc_print_diag(devh, stderr); uvc_exit(ctx); return 1;