Commit 0df049ac authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fixed cameras detection limited to 2

parent 6dbb3f1f
......@@ -42,6 +42,11 @@ public class AndroidVideoApi5JniWrapper {
public static native void putImage(long nativePtr, byte[] buffer);
static public int detectCamerasCount() {
AndroidCamera[] cameras = AndroidCameraConfiguration.retrieveCameras();
return cameras.length;
}
static public int detectCameras(int[] indexes, int[] frontFacing, int[] orientation) {
Log.d("detectCameras\n");
AndroidCamera[] cameras = AndroidCameraConfiguration.retrieveCameras();
......
......@@ -24,6 +24,11 @@ import android.graphics.ImageFormat;
import android.hardware.Camera;
public class AndroidVideoApi8JniWrapper {
static public int detectCamerasCount() {
return AndroidVideoApi5JniWrapper.detectCamerasCount();
}
static public int detectCameras(int[] indexes, int[] frontFacing, int[] orientation) {
return AndroidVideoApi5JniWrapper.detectCameras(indexes, frontFacing, orientation);
}
......
......@@ -31,6 +31,11 @@ import android.os.Build;
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public class AndroidVideoApi9JniWrapper {
static public int detectCamerasCount() {
return AndroidVideoApi5JniWrapper.detectCamerasCount();
}
static public int detectCameras(int[] indexes, int[] frontFacing, int[] orientation) {
return AndroidVideoApi5JniWrapper.detectCameras(indexes, frontFacing, orientation);
}
......
......@@ -425,16 +425,17 @@ static void video_capture_detect(MSWebCamManager *obj){
JNIEnv *env = ms_get_jni_env();
jclass helperClass = getHelperClassGlobalRef(env);
if (helperClass==NULL) return;
if (helperClass == NULL) return;
// create 3 int arrays - assuming 2 webcams at most
jintArray indexes = (jintArray)env->NewIntArray(2);
jintArray frontFacing = (jintArray)env->NewIntArray(2);
jintArray orientation = (jintArray)env->NewIntArray(2);
jmethodID countMethod = env->GetStaticMethodID(helperClass,"detectCamerasCount", "()I");
int count = env->CallStaticIntMethod(helperClass, countMethod);
jmethodID method = env->GetStaticMethodID(helperClass,"detectCameras", "([I[I[I)I");
jintArray indexes = (jintArray)env->NewIntArray(count);
jintArray frontFacing = (jintArray)env->NewIntArray(count);
jintArray orientation = (jintArray)env->NewIntArray(count);
int count = env->CallStaticIntMethod(helperClass, method, indexes, frontFacing, orientation);
jmethodID method = env->GetStaticMethodID(helperClass,"detectCameras", "([I[I[I)I");
env->CallStaticIntMethod(helperClass, method, indexes, frontFacing, orientation);
ms_message("%d cards detected", count);
for(int i=0; i<count; i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment