X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;ds=sidebyside;f=app%2Fsrc%2Fmain%2Fjni%2FUVCCamera.cpp;fp=app%2Fsrc%2Fmain%2Fjni%2FUVCCamera.cpp;h=0000000000000000000000000000000000000000;hb=4d7fc85844bbd24cc1b15f60fed3b8aaa507962f;hp=4fcd52566ef8d2a9418bf8154a11d11e27c0488f;hpb=d0d496554f96cebf84db3e9b3cf507577272ef8c;p=rtmpclient.git diff --git a/app/src/main/jni/UVCCamera.cpp b/app/src/main/jni/UVCCamera.cpp deleted file mode 100644 index 4fcd525..0000000 --- a/app/src/main/jni/UVCCamera.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// -// Created by Peng Li on 14/5/2018. -// - -#include "UVCCamera.h" -//#include -#include "log.h" -#include "libuvc/libuvc.h" - - - -UVCCamera::~UVCCamera() -{ -} - -//jint UVCCamera::nativeOnLoad(JavaVM *jvm, void* reserved) -//{ - // N.B. within the context of a JVM thread here - // get a JNIEnv by attempting to get it directly -// JNIEnv *env; -// if (jvm) jvm->GetEnv (reinterpret_cast(&env), JNI_VERSION_1_2); - - // get a handle to the Java class in the JVM - // and cache it becuse FindClass doesn't work in native worker threads because Java is stupid - // http://developer.android.com/training/articles/perf-jni.html#faq_FindClass -// jclass local_ref = 0; -// if (env) local_ref = env->FindClass ("com/cisco/ecc/testapp/EccTestApp"); -// jclass global_ref = reinterpret_cast (env->NewGlobalRef (local_ref)); - - // Create the singleton -// singleton.reset (new EccTestApp (jvm, global_ref)); - - // return the JNI version needed. I think we can basicaly return anything other than 1.1 here - // unless it turns out we need some specific JNI methods from a later version -// return JNI_VERSION_1_2; - // return 0; -//} - -void UVCCamera::init() -{ - LOGE("UVCCamera::init"); -} - -int UVCCamera::open(int vid, int pid, int fd, int busnum, int devaddr, const char* usbFsName) -{ - LOGE("UVCCamera::open"); - - uvc_context_t *ctx; - uvc_device_t *dev; - uvc_device_handle_t *devh; - uvc_error_t res; - - 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"); -// 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("uvc_get_device_with_fd"); - - //uvc_print_diag(mDeviceHandle, stderr); - - if ((res = uvc_open(dev, &devh)) < 0){ - 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_exit(ctx); - return 1; -}