Loading camera/ndk/Android.bp +78 −0 Original line number Diff line number Diff line Loading @@ -70,3 +70,81 @@ cc_library_shared { ], version_script: "libcamera2ndk.map.txt", } cc_library_shared { name: "libcamera2ndk_vendor", vendor_available: true, srcs: [ "ndk_vendor/impl/ACameraDevice.cpp", "ndk_vendor/impl/ACameraManager.cpp", "ndk_vendor/impl/utils.cpp", "impl/ACameraMetadata.cpp", "impl/ACameraCaptureSession.cpp", "NdkCameraMetadata.cpp", "NdkCameraCaptureSession.cpp", "NdkCameraManager.cpp", "NdkCameraDevice.cpp", "NdkCaptureRequest.cpp", ], export_include_dirs: ["include"], export_shared_lib_headers: [ "libcutils", ], local_include_dirs: [ ".", "include", "impl", ], cflags: [ "-fvisibility=hidden", "-DEXPORT=__attribute__((visibility(\"default\")))", "-D__ANDROID_VNDK__", ], shared_libs: [ "libhwbinder", "libfmq", "libhidlbase", "libhardware", "libnativewindow", "liblog", "libutils", "libstagefright_foundation", "libcutils", "libcamera_metadata", "libmediandk", "android.frameworks.cameraservice.device@2.0", "android.frameworks.cameraservice.common@2.0", "android.frameworks.cameraservice.service@2.0", ], static_libs: [ "android.hardware.camera.common@1.0-helper", "libarect", ], product_variables: { pdk: { enabled: false, }, }, } cc_test { name: "AImageReaderVendorTest", vendor: true, srcs: ["ndk_vendor/tests/AImageReaderVendorTest.cpp"], shared_libs: [ "libhwbinder", "libcamera2ndk_vendor", "libmediandk", "libnativewindow", "libutils", "libui", "libcutils", "liblog", ], cflags: [ "-D__ANDROID_VNDK__", ], } camera/ndk/NdkCameraDevice.cpp +15 −7 Original line number Diff line number Diff line Loading @@ -24,7 +24,15 @@ #include <camera/NdkCameraDevice.h> #include "impl/ACameraCaptureSession.h" using namespace android; using namespace android::acam; bool areWindowTypesEqual(ACameraWindowType *a, ACameraWindowType *b) { #ifdef __ANDROID_VNDK__ return utils::isWindowNativeHandleEqual(a, b); #else return a == b; #endif } EXPORT camera_status_t ACameraDevice_close(ACameraDevice* device) { Loading Loading @@ -96,7 +104,7 @@ void ACaptureSessionOutputContainer_free(ACaptureSessionOutputContainer* contain EXPORT camera_status_t ACaptureSessionOutput_create( ANativeWindow* window, /*out*/ACaptureSessionOutput** out) { ACameraWindowType* window, /*out*/ACaptureSessionOutput** out) { ATRACE_CALL(); if (window == nullptr || out == nullptr) { ALOGE("%s: Error: bad argument. window %p, out %p", Loading @@ -109,7 +117,7 @@ camera_status_t ACaptureSessionOutput_create( EXPORT camera_status_t ACaptureSessionSharedOutput_create( ANativeWindow* window, /*out*/ACaptureSessionOutput** out) { ACameraWindowType* window, /*out*/ACaptureSessionOutput** out) { ATRACE_CALL(); if (window == nullptr || out == nullptr) { ALOGE("%s: Error: bad argument. window %p, out %p", Loading @@ -122,7 +130,7 @@ camera_status_t ACaptureSessionSharedOutput_create( EXPORT camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out, ANativeWindow* window) { ACameraWindowType* window) { ATRACE_CALL(); if ((window == nullptr) || (out == nullptr)) { ALOGE("%s: Error: bad argument. window %p, out %p", Loading @@ -134,7 +142,7 @@ camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out, __FUNCTION__); return ACAMERA_ERROR_INVALID_OPERATION; } if (out->mWindow == window) { if (areWindowTypesEqual(out->mWindow, window)) { ALOGE("%s: Error trying to add the same window associated with the output configuration", __FUNCTION__); return ACAMERA_ERROR_INVALID_PARAMETER; Loading @@ -147,7 +155,7 @@ camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out, EXPORT camera_status_t ACaptureSessionSharedOutput_remove(ACaptureSessionOutput *out, ANativeWindow* window) { ACameraWindowType* window) { ATRACE_CALL(); if ((window == nullptr) || (out == nullptr)) { ALOGE("%s: Error: bad argument. window %p, out %p", Loading @@ -159,7 +167,7 @@ camera_status_t ACaptureSessionSharedOutput_remove(ACaptureSessionOutput *out, __FUNCTION__); return ACAMERA_ERROR_INVALID_OPERATION; } if (out->mWindow == window) { if (areWindowTypesEqual(out->mWindow, window)) { ALOGE("%s: Error trying to remove the same window associated with the output configuration", __FUNCTION__); return ACAMERA_ERROR_INVALID_PARAMETER; Loading camera/ndk/NdkCameraManager.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -22,10 +22,15 @@ #include <utils/Trace.h> #include <camera/NdkCameraManager.h> #ifdef __ANDROID_VNDK__ #include "ndk_vendor/impl/ACameraManager.h" #else #include "impl/ACameraManager.h" #endif #include "impl/ACameraMetadata.h" using namespace android; using namespace android::acam; EXPORT ACameraManager* ACameraManager_create() { Loading camera/ndk/NdkCaptureRequest.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ EXPORT camera_status_t ACameraOutputTarget_create( ANativeWindow* window, ACameraOutputTarget** out) { ACameraWindowType* window, ACameraOutputTarget** out) { ATRACE_CALL(); if (window == nullptr) { ALOGE("%s: Error: input window is null", __FUNCTION__); Loading camera/ndk/impl/ACameraCaptureSession.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ using namespace android; ACameraCaptureSession::~ACameraCaptureSession() { ALOGV("~ACameraCaptureSession: %p notify device end of life", this); sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev != nullptr && !dev->isClosed()) { dev->lockDeviceForSessionOps(); { Loading @@ -48,7 +48,7 @@ ACameraCaptureSession::closeByApp() { mClosedByApp = true; } sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev != nullptr) { dev->lockDeviceForSessionOps(); } Loading @@ -73,7 +73,7 @@ ACameraCaptureSession::closeByApp() { camera_status_t ACameraCaptureSession::stopRepeating() { sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return ACAMERA_ERROR_SESSION_CLOSED; Loading @@ -91,7 +91,7 @@ ACameraCaptureSession::stopRepeating() { camera_status_t ACameraCaptureSession::abortCaptures() { sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return ACAMERA_ERROR_SESSION_CLOSED; Loading @@ -112,7 +112,7 @@ ACameraCaptureSession::setRepeatingRequest( /*optional*/ACameraCaptureSession_captureCallbacks* cbs, int numRequests, ACaptureRequest** requests, /*optional*/int* captureSequenceId) { sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return ACAMERA_ERROR_SESSION_CLOSED; Loading @@ -133,7 +133,7 @@ camera_status_t ACameraCaptureSession::capture( /*optional*/ACameraCaptureSession_captureCallbacks* cbs, int numRequests, ACaptureRequest** requests, /*optional*/int* captureSequenceId) { sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return ACAMERA_ERROR_SESSION_CLOSED; Loading @@ -149,7 +149,7 @@ camera_status_t ACameraCaptureSession::capture( } camera_status_t ACameraCaptureSession::updateOutputConfiguration(ACaptureSessionOutput *output) { sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return ACAMERA_ERROR_SESSION_CLOSED; Loading @@ -168,7 +168,7 @@ camera_status_t ACameraCaptureSession::updateOutputConfiguration(ACaptureSession ACameraDevice* ACameraCaptureSession::getDevice() { Mutex::Autolock _l(mSessionLock); sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return nullptr; Loading @@ -182,9 +182,9 @@ ACameraCaptureSession::closeByDevice() { mIsClosed = true; } sp<CameraDevice> sp<acam::CameraDevice> ACameraCaptureSession::getDeviceSp() { sp<CameraDevice> device = mDevice.promote(); sp<acam::CameraDevice> device = mDevice.promote(); if (device == nullptr || device->isClosed()) { ALOGW("Device is closed but session %d is not notified", mId); return nullptr; Loading Loading
camera/ndk/Android.bp +78 −0 Original line number Diff line number Diff line Loading @@ -70,3 +70,81 @@ cc_library_shared { ], version_script: "libcamera2ndk.map.txt", } cc_library_shared { name: "libcamera2ndk_vendor", vendor_available: true, srcs: [ "ndk_vendor/impl/ACameraDevice.cpp", "ndk_vendor/impl/ACameraManager.cpp", "ndk_vendor/impl/utils.cpp", "impl/ACameraMetadata.cpp", "impl/ACameraCaptureSession.cpp", "NdkCameraMetadata.cpp", "NdkCameraCaptureSession.cpp", "NdkCameraManager.cpp", "NdkCameraDevice.cpp", "NdkCaptureRequest.cpp", ], export_include_dirs: ["include"], export_shared_lib_headers: [ "libcutils", ], local_include_dirs: [ ".", "include", "impl", ], cflags: [ "-fvisibility=hidden", "-DEXPORT=__attribute__((visibility(\"default\")))", "-D__ANDROID_VNDK__", ], shared_libs: [ "libhwbinder", "libfmq", "libhidlbase", "libhardware", "libnativewindow", "liblog", "libutils", "libstagefright_foundation", "libcutils", "libcamera_metadata", "libmediandk", "android.frameworks.cameraservice.device@2.0", "android.frameworks.cameraservice.common@2.0", "android.frameworks.cameraservice.service@2.0", ], static_libs: [ "android.hardware.camera.common@1.0-helper", "libarect", ], product_variables: { pdk: { enabled: false, }, }, } cc_test { name: "AImageReaderVendorTest", vendor: true, srcs: ["ndk_vendor/tests/AImageReaderVendorTest.cpp"], shared_libs: [ "libhwbinder", "libcamera2ndk_vendor", "libmediandk", "libnativewindow", "libutils", "libui", "libcutils", "liblog", ], cflags: [ "-D__ANDROID_VNDK__", ], }
camera/ndk/NdkCameraDevice.cpp +15 −7 Original line number Diff line number Diff line Loading @@ -24,7 +24,15 @@ #include <camera/NdkCameraDevice.h> #include "impl/ACameraCaptureSession.h" using namespace android; using namespace android::acam; bool areWindowTypesEqual(ACameraWindowType *a, ACameraWindowType *b) { #ifdef __ANDROID_VNDK__ return utils::isWindowNativeHandleEqual(a, b); #else return a == b; #endif } EXPORT camera_status_t ACameraDevice_close(ACameraDevice* device) { Loading Loading @@ -96,7 +104,7 @@ void ACaptureSessionOutputContainer_free(ACaptureSessionOutputContainer* contain EXPORT camera_status_t ACaptureSessionOutput_create( ANativeWindow* window, /*out*/ACaptureSessionOutput** out) { ACameraWindowType* window, /*out*/ACaptureSessionOutput** out) { ATRACE_CALL(); if (window == nullptr || out == nullptr) { ALOGE("%s: Error: bad argument. window %p, out %p", Loading @@ -109,7 +117,7 @@ camera_status_t ACaptureSessionOutput_create( EXPORT camera_status_t ACaptureSessionSharedOutput_create( ANativeWindow* window, /*out*/ACaptureSessionOutput** out) { ACameraWindowType* window, /*out*/ACaptureSessionOutput** out) { ATRACE_CALL(); if (window == nullptr || out == nullptr) { ALOGE("%s: Error: bad argument. window %p, out %p", Loading @@ -122,7 +130,7 @@ camera_status_t ACaptureSessionSharedOutput_create( EXPORT camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out, ANativeWindow* window) { ACameraWindowType* window) { ATRACE_CALL(); if ((window == nullptr) || (out == nullptr)) { ALOGE("%s: Error: bad argument. window %p, out %p", Loading @@ -134,7 +142,7 @@ camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out, __FUNCTION__); return ACAMERA_ERROR_INVALID_OPERATION; } if (out->mWindow == window) { if (areWindowTypesEqual(out->mWindow, window)) { ALOGE("%s: Error trying to add the same window associated with the output configuration", __FUNCTION__); return ACAMERA_ERROR_INVALID_PARAMETER; Loading @@ -147,7 +155,7 @@ camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out, EXPORT camera_status_t ACaptureSessionSharedOutput_remove(ACaptureSessionOutput *out, ANativeWindow* window) { ACameraWindowType* window) { ATRACE_CALL(); if ((window == nullptr) || (out == nullptr)) { ALOGE("%s: Error: bad argument. window %p, out %p", Loading @@ -159,7 +167,7 @@ camera_status_t ACaptureSessionSharedOutput_remove(ACaptureSessionOutput *out, __FUNCTION__); return ACAMERA_ERROR_INVALID_OPERATION; } if (out->mWindow == window) { if (areWindowTypesEqual(out->mWindow, window)) { ALOGE("%s: Error trying to remove the same window associated with the output configuration", __FUNCTION__); return ACAMERA_ERROR_INVALID_PARAMETER; Loading
camera/ndk/NdkCameraManager.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -22,10 +22,15 @@ #include <utils/Trace.h> #include <camera/NdkCameraManager.h> #ifdef __ANDROID_VNDK__ #include "ndk_vendor/impl/ACameraManager.h" #else #include "impl/ACameraManager.h" #endif #include "impl/ACameraMetadata.h" using namespace android; using namespace android::acam; EXPORT ACameraManager* ACameraManager_create() { Loading
camera/ndk/NdkCaptureRequest.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ EXPORT camera_status_t ACameraOutputTarget_create( ANativeWindow* window, ACameraOutputTarget** out) { ACameraWindowType* window, ACameraOutputTarget** out) { ATRACE_CALL(); if (window == nullptr) { ALOGE("%s: Error: input window is null", __FUNCTION__); Loading
camera/ndk/impl/ACameraCaptureSession.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ using namespace android; ACameraCaptureSession::~ACameraCaptureSession() { ALOGV("~ACameraCaptureSession: %p notify device end of life", this); sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev != nullptr && !dev->isClosed()) { dev->lockDeviceForSessionOps(); { Loading @@ -48,7 +48,7 @@ ACameraCaptureSession::closeByApp() { mClosedByApp = true; } sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev != nullptr) { dev->lockDeviceForSessionOps(); } Loading @@ -73,7 +73,7 @@ ACameraCaptureSession::closeByApp() { camera_status_t ACameraCaptureSession::stopRepeating() { sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return ACAMERA_ERROR_SESSION_CLOSED; Loading @@ -91,7 +91,7 @@ ACameraCaptureSession::stopRepeating() { camera_status_t ACameraCaptureSession::abortCaptures() { sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return ACAMERA_ERROR_SESSION_CLOSED; Loading @@ -112,7 +112,7 @@ ACameraCaptureSession::setRepeatingRequest( /*optional*/ACameraCaptureSession_captureCallbacks* cbs, int numRequests, ACaptureRequest** requests, /*optional*/int* captureSequenceId) { sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return ACAMERA_ERROR_SESSION_CLOSED; Loading @@ -133,7 +133,7 @@ camera_status_t ACameraCaptureSession::capture( /*optional*/ACameraCaptureSession_captureCallbacks* cbs, int numRequests, ACaptureRequest** requests, /*optional*/int* captureSequenceId) { sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return ACAMERA_ERROR_SESSION_CLOSED; Loading @@ -149,7 +149,7 @@ camera_status_t ACameraCaptureSession::capture( } camera_status_t ACameraCaptureSession::updateOutputConfiguration(ACaptureSessionOutput *output) { sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return ACAMERA_ERROR_SESSION_CLOSED; Loading @@ -168,7 +168,7 @@ camera_status_t ACameraCaptureSession::updateOutputConfiguration(ACaptureSession ACameraDevice* ACameraCaptureSession::getDevice() { Mutex::Autolock _l(mSessionLock); sp<CameraDevice> dev = getDeviceSp(); sp<acam::CameraDevice> dev = getDeviceSp(); if (dev == nullptr) { ALOGE("Error: Device associated with session %p has been closed!", this); return nullptr; Loading @@ -182,9 +182,9 @@ ACameraCaptureSession::closeByDevice() { mIsClosed = true; } sp<CameraDevice> sp<acam::CameraDevice> ACameraCaptureSession::getDeviceSp() { sp<CameraDevice> device = mDevice.promote(); sp<acam::CameraDevice> device = mDevice.promote(); if (device == nullptr || device->isClosed()) { ALOGW("Device is closed but session %d is not notified", mId); return nullptr; Loading