Loading core/jni/android_hardware_Camera.cpp +33 −5 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <camera/StringUtils.h> #include <camera/StringUtils.h> #include <com_android_internal_camera_flags.h> #include <com_android_internal_camera_flags.h> #include <cutils/properties.h> #include <cutils/properties.h> #include <gui/Flags.h> #include <gui/GLConsumer.h> #include <gui/GLConsumer.h> #include <gui/Surface.h> #include <gui/Surface.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/JNIHelp.h> Loading Loading @@ -715,16 +716,20 @@ static void android_hardware_Camera_setPreviewSurface(JNIEnv *env, jobject thiz, sp<Camera> camera = get_native_camera(env, thiz, NULL); sp<Camera> camera = get_native_camera(env, thiz, NULL); if (camera == 0) return; if (camera == 0) return; sp<IGraphicBufferProducer> gbp; sp<Surface> surface; sp<Surface> surface; if (jSurface) { if (jSurface) { surface = android_view_Surface_getSurface(env, jSurface); surface = android_view_Surface_getSurface(env, jSurface); } #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES if (camera->setPreviewTarget(surface) != NO_ERROR) { #else sp<IGraphicBufferProducer> gbp; if (surface != NULL) { if (surface != NULL) { gbp = surface->getIGraphicBufferProducer(); gbp = surface->getIGraphicBufferProducer(); } } } if (camera->setPreviewTarget(gbp) != NO_ERROR) { if (camera->setPreviewTarget(gbp) != NO_ERROR) { #endif jniThrowException(env, "java/io/IOException", "setPreviewTexture failed"); jniThrowException(env, "java/io/IOException", "setPreviewTexture failed"); } } } } Loading @@ -736,6 +741,9 @@ static void android_hardware_Camera_setPreviewTexture(JNIEnv *env, sp<Camera> camera = get_native_camera(env, thiz, NULL); sp<Camera> camera = get_native_camera(env, thiz, NULL); if (camera == 0) return; if (camera == 0) return; #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES sp<Surface> surface; #endif sp<IGraphicBufferProducer> producer = NULL; sp<IGraphicBufferProducer> producer = NULL; if (jSurfaceTexture != NULL) { if (jSurfaceTexture != NULL) { producer = SurfaceTexture_getProducer(env, jSurfaceTexture); producer = SurfaceTexture_getProducer(env, jSurfaceTexture); Loading @@ -744,10 +752,16 @@ static void android_hardware_Camera_setPreviewTexture(JNIEnv *env, "SurfaceTexture already released in setPreviewTexture"); "SurfaceTexture already released in setPreviewTexture"); return; return; } } #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES surface = new Surface(producer); #endif } } #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES if (camera->setPreviewTarget(surface) != NO_ERROR) { #else if (camera->setPreviewTarget(producer) != NO_ERROR) { if (camera->setPreviewTarget(producer) != NO_ERROR) { #endif jniThrowException(env, "java/io/IOException", jniThrowException(env, "java/io/IOException", "setPreviewTexture failed"); "setPreviewTexture failed"); } } Loading @@ -761,18 +775,32 @@ static void android_hardware_Camera_setPreviewCallbackSurface(JNIEnv *env, sp<Camera> camera = get_native_camera(env, thiz, &context); sp<Camera> camera = get_native_camera(env, thiz, &context); if (camera == 0) return; if (camera == 0) return; #if !WB_LIBCAMERASERVICE_WITH_DEPENDENCIES sp<IGraphicBufferProducer> gbp; sp<IGraphicBufferProducer> gbp; #endif sp<Surface> surface; sp<Surface> surface; if (jSurface) { if (jSurface) { surface = android_view_Surface_getSurface(env, jSurface); surface = android_view_Surface_getSurface(env, jSurface); if (surface == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", "android_view_Surface_getSurface failed"); return; } #if !WB_LIBCAMERASERVICE_WITH_DEPENDENCIES if (surface != NULL) { if (surface != NULL) { gbp = surface->getIGraphicBufferProducer(); gbp = surface->getIGraphicBufferProducer(); } } #endif } } // Clear out normal preview callbacks // Clear out normal preview callbacks context->setCallbackMode(env, false, false); context->setCallbackMode(env, false, false); // Then set up callback surface // Then set up callback surface #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES if (camera->setPreviewCallbackTarget(surface) != NO_ERROR) { #else if (camera->setPreviewCallbackTarget(gbp) != NO_ERROR) { if (camera->setPreviewCallbackTarget(gbp) != NO_ERROR) { #endif jniThrowException(env, "java/io/IOException", "setPreviewCallbackTarget failed"); jniThrowException(env, "java/io/IOException", "setPreviewCallbackTarget failed"); } } } } Loading Loading
core/jni/android_hardware_Camera.cpp +33 −5 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <camera/StringUtils.h> #include <camera/StringUtils.h> #include <com_android_internal_camera_flags.h> #include <com_android_internal_camera_flags.h> #include <cutils/properties.h> #include <cutils/properties.h> #include <gui/Flags.h> #include <gui/GLConsumer.h> #include <gui/GLConsumer.h> #include <gui/Surface.h> #include <gui/Surface.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/JNIHelp.h> Loading Loading @@ -715,16 +716,20 @@ static void android_hardware_Camera_setPreviewSurface(JNIEnv *env, jobject thiz, sp<Camera> camera = get_native_camera(env, thiz, NULL); sp<Camera> camera = get_native_camera(env, thiz, NULL); if (camera == 0) return; if (camera == 0) return; sp<IGraphicBufferProducer> gbp; sp<Surface> surface; sp<Surface> surface; if (jSurface) { if (jSurface) { surface = android_view_Surface_getSurface(env, jSurface); surface = android_view_Surface_getSurface(env, jSurface); } #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES if (camera->setPreviewTarget(surface) != NO_ERROR) { #else sp<IGraphicBufferProducer> gbp; if (surface != NULL) { if (surface != NULL) { gbp = surface->getIGraphicBufferProducer(); gbp = surface->getIGraphicBufferProducer(); } } } if (camera->setPreviewTarget(gbp) != NO_ERROR) { if (camera->setPreviewTarget(gbp) != NO_ERROR) { #endif jniThrowException(env, "java/io/IOException", "setPreviewTexture failed"); jniThrowException(env, "java/io/IOException", "setPreviewTexture failed"); } } } } Loading @@ -736,6 +741,9 @@ static void android_hardware_Camera_setPreviewTexture(JNIEnv *env, sp<Camera> camera = get_native_camera(env, thiz, NULL); sp<Camera> camera = get_native_camera(env, thiz, NULL); if (camera == 0) return; if (camera == 0) return; #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES sp<Surface> surface; #endif sp<IGraphicBufferProducer> producer = NULL; sp<IGraphicBufferProducer> producer = NULL; if (jSurfaceTexture != NULL) { if (jSurfaceTexture != NULL) { producer = SurfaceTexture_getProducer(env, jSurfaceTexture); producer = SurfaceTexture_getProducer(env, jSurfaceTexture); Loading @@ -744,10 +752,16 @@ static void android_hardware_Camera_setPreviewTexture(JNIEnv *env, "SurfaceTexture already released in setPreviewTexture"); "SurfaceTexture already released in setPreviewTexture"); return; return; } } #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES surface = new Surface(producer); #endif } } #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES if (camera->setPreviewTarget(surface) != NO_ERROR) { #else if (camera->setPreviewTarget(producer) != NO_ERROR) { if (camera->setPreviewTarget(producer) != NO_ERROR) { #endif jniThrowException(env, "java/io/IOException", jniThrowException(env, "java/io/IOException", "setPreviewTexture failed"); "setPreviewTexture failed"); } } Loading @@ -761,18 +775,32 @@ static void android_hardware_Camera_setPreviewCallbackSurface(JNIEnv *env, sp<Camera> camera = get_native_camera(env, thiz, &context); sp<Camera> camera = get_native_camera(env, thiz, &context); if (camera == 0) return; if (camera == 0) return; #if !WB_LIBCAMERASERVICE_WITH_DEPENDENCIES sp<IGraphicBufferProducer> gbp; sp<IGraphicBufferProducer> gbp; #endif sp<Surface> surface; sp<Surface> surface; if (jSurface) { if (jSurface) { surface = android_view_Surface_getSurface(env, jSurface); surface = android_view_Surface_getSurface(env, jSurface); if (surface == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", "android_view_Surface_getSurface failed"); return; } #if !WB_LIBCAMERASERVICE_WITH_DEPENDENCIES if (surface != NULL) { if (surface != NULL) { gbp = surface->getIGraphicBufferProducer(); gbp = surface->getIGraphicBufferProducer(); } } #endif } } // Clear out normal preview callbacks // Clear out normal preview callbacks context->setCallbackMode(env, false, false); context->setCallbackMode(env, false, false); // Then set up callback surface // Then set up callback surface #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES if (camera->setPreviewCallbackTarget(surface) != NO_ERROR) { #else if (camera->setPreviewCallbackTarget(gbp) != NO_ERROR) { if (camera->setPreviewCallbackTarget(gbp) != NO_ERROR) { #endif jniThrowException(env, "java/io/IOException", "setPreviewCallbackTarget failed"); jniThrowException(env, "java/io/IOException", "setPreviewCallbackTarget failed"); } } } } Loading