如何更改相机闪光灯JNI功能的状态?我希望能够进行ON / OFF状态控制,就像在Java CameraManager.setTorchMode(cameraId, state);
方法中一样。我试图在原生相机API中搜索它,但没有成功。以下是我到目前为止所做的事情:
#include <jni.h>
#include <assert.h>
#include <jni.h>
#include <pthread.h>
#include <android/native_window_jni.h>
#include <camera/NdkCameraDevice.h>
#include <camera/NdkCameraManager.h>
#include <android/asset_manager.h>
#include "messages-internal.h"
JNIEXPORT void JNICALL
Java_com_android_rxjava_flashlightflicker_MainActivity_flasher(JNIEnv *env, jobject instance) {
ACameraIdList *cameraIdList = NULL;
const char *selectedCameraId = NULL;
ACameraManager *cameraManager = ACameraManager_create();
camera_status_t camera_status = ACAMERA_OK;
camera_status = ACameraManager_getCameraIdList(cameraManager, &cameraIdList);
/// Camera status not ok
if (camera_status != ACAMERA_OK) {
LOGE("Camera is bad id: %d \n", camera_status);
return;
}
// There is no camera
if (cameraIdList->numCameras < 1 ) {
LOGE("Camera is not present on the device.");
return;
}
selectedCameraId = cameraIdList->cameraIds[0];
ACameraMetadata *cameraMetedata = NULL;
ACameraManager_getCameraCharacteristics(cameraManager, selectedCameraId, &cameraMetedata);
// ACaptureSessionOutput_create()
}
我也试过看资产经理但没有成功,任何有NDK相机经验的人能帮我一把吗?
提前致谢!
答案 0 :(得分:0)
此方法仅适用于Java API。您可以通过JNI访问它,但IMO在Java中编写包装器静态方法并使用C ++代码调用此包装器会更容易,更安全。