80,351
社区成员
发帖
与我相关
我的任务
分享
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width,
int height) {
// mCamera = Camera.open();
try {
mCamera.setPreviewTexture(surface);
mCamera.startPreview();
} catch (IOException ioe) {
// Something bad happened
}
}
static void android_hardware_Camera_setPreviewTexture(JNIEnv *env,
jobject thiz, jobject jSurfaceTexture)
{
ALOGV("setPreviewTexture");
sp<Camera> camera = get_native_camera(env, thiz, NULL);
if (camera == 0) return;
sp<IGraphicBufferProducer> producer = NULL;
if (jSurfaceTexture != NULL) {
producer = SurfaceTexture_getProducer(env, jSurfaceTexture);
if (producer == NULL) {
jniThrowException(env, "java/lang/IllegalArgumentException",
"SurfaceTexture already released in setPreviewTexture");
return;
}
}
if (camera->setPreviewTarget(producer) != NO_ERROR) {
jniThrowException(env, "java/io/IOException",
"setPreviewTexture failed");
}
}
static void android_hardware_Camera_setPreviewTexture(JNIEnv *env,
jobject thiz, jobject jSurfaceTexture)
{
ALOGV("setPreviewTexture");
sp<Camera> camera = get_native_camera(env, thiz, NULL);
if (camera == 0) return;
sp<IGraphicBufferProducer> producer = NULL;
if (jSurfaceTexture != NULL) {
producer = SurfaceTexture_getProducer(env, jSurfaceTexture);
if (producer == NULL) {
jniThrowException(env, "java/lang/IllegalArgumentException",
"SurfaceTexture already released in setPreviewTexture");
return;
}
}
if (camera->setPreviewTarget(producer) != NO_ERROR) {
jniThrowException(env, "java/io/IOException",
"setPreviewTexture failed");
}
}