Create a vendor available version of libcamera2ndk.
Bug: 110364143
Test: mm -j64
Test: AImageReaderVendorTest
Change-Id: Ic9343cc7fb10eb374197945b72be59e7ce8282fe
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
diff --git a/camera/ndk/impl/ACameraCaptureSession.cpp b/camera/ndk/impl/ACameraCaptureSession.cpp
index f60e5fd..fb72bdb 100644
--- a/camera/ndk/impl/ACameraCaptureSession.cpp
+++ b/camera/ndk/impl/ACameraCaptureSession.cpp
@@ -23,7 +23,7 @@
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();
{
@@ -48,7 +48,7 @@
mClosedByApp = true;
}
- sp<CameraDevice> dev = getDeviceSp();
+ sp<acam::CameraDevice> dev = getDeviceSp();
if (dev != nullptr) {
dev->lockDeviceForSessionOps();
}
@@ -73,7 +73,7 @@
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;
@@ -91,7 +91,7 @@
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;
@@ -112,7 +112,7 @@
/*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;
@@ -133,7 +133,7 @@
/*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;
@@ -149,7 +149,7 @@
}
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;
@@ -168,7 +168,7 @@
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;
@@ -182,9 +182,9 @@
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;
diff --git a/camera/ndk/impl/ACameraCaptureSession.h b/camera/ndk/impl/ACameraCaptureSession.h
index a2068e7..133c2c8 100644
--- a/camera/ndk/impl/ACameraCaptureSession.h
+++ b/camera/ndk/impl/ACameraCaptureSession.h
@@ -19,12 +19,17 @@
#include <set>
#include <hardware/camera3.h>
#include <camera/NdkCameraDevice.h>
+
+#ifdef __ANDROID_VNDK__
+#include "ndk_vendor/impl/ACameraDevice.h"
+#include "ndk_vendor/impl/ACameraCaptureSessionVendor.h"
+#else
#include "ACameraDevice.h"
using namespace android;
struct ACaptureSessionOutput {
- explicit ACaptureSessionOutput(ANativeWindow* window, bool isShared = false) :
+ explicit ACaptureSessionOutput(ACameraWindowType* window, bool isShared = false) :
mWindow(window), mIsShared(isShared) {};
bool operator == (const ACaptureSessionOutput& other) const {
@@ -40,11 +45,12 @@
return mWindow > other.mWindow;
}
- ANativeWindow* mWindow;
- std::set<ANativeWindow *> mSharedWindows;
+ ACameraWindowType* mWindow;
+ std::set<ACameraWindowType *> mSharedWindows;
bool mIsShared;
int mRotation = CAMERA3_STREAM_ROTATION_0;
};
+#endif
struct ACaptureSessionOutputContainer {
std::set<ACaptureSessionOutput> mOutputs;
@@ -60,7 +66,7 @@
int id,
const ACaptureSessionOutputContainer* outputs,
const ACameraCaptureSession_stateCallbacks* cb,
- CameraDevice* device) :
+ android::acam::CameraDevice* device) :
mId(id), mOutput(*outputs), mUserSessionCallback(*cb),
mDevice(device) {}
@@ -97,18 +103,18 @@
ACameraDevice* getDevice();
private:
- friend class CameraDevice;
+ friend class android::acam::CameraDevice;
// Close session because app close camera device, camera device got ERROR_DISCONNECTED,
// or a new session is replacing this session.
void closeByDevice();
- sp<CameraDevice> getDeviceSp();
+ sp<android::acam::CameraDevice> getDeviceSp();
const int mId;
const ACaptureSessionOutputContainer mOutput;
const ACameraCaptureSession_stateCallbacks mUserSessionCallback;
- const wp<CameraDevice> mDevice;
+ const wp<android::acam::CameraDevice> mDevice;
bool mIsClosed = false;
bool mClosedByApp = false;
Mutex mSessionLock;
diff --git a/camera/ndk/impl/ACameraDevice.cpp b/camera/ndk/impl/ACameraDevice.cpp
index ac3be25..00da54e 100644
--- a/camera/ndk/impl/ACameraDevice.cpp
+++ b/camera/ndk/impl/ACameraDevice.cpp
@@ -27,9 +27,9 @@
#include "ACaptureRequest.h"
#include "ACameraCaptureSession.h"
-using namespace android;
-
namespace android {
+namespace acam {
+
// Static member definitions
const char* CameraDevice::kContextKey = "Context";
const char* CameraDevice::kDeviceKey = "Device";
@@ -1513,5 +1513,5 @@
return ret;
}
-
+} // namespace acam
} // namespace android
diff --git a/camera/ndk/impl/ACameraDevice.h b/camera/ndk/impl/ACameraDevice.h
index 7d64081..8f56d3f 100644
--- a/camera/ndk/impl/ACameraDevice.h
+++ b/camera/ndk/impl/ACameraDevice.h
@@ -41,6 +41,7 @@
#include "ACameraMetadata.h"
namespace android {
+namespace acam {
// Wrap ACameraCaptureFailure so it can be ref-counted
struct CameraCaptureFailure : public RefBase, public ACameraCaptureFailure {};
@@ -286,6 +287,7 @@
};
+} // namespace acam;
} // namespace android;
/**
@@ -295,7 +297,7 @@
struct ACameraDevice {
ACameraDevice(const char* id, ACameraDevice_StateCallbacks* cb,
sp<ACameraMetadata> chars) :
- mDevice(new CameraDevice(id, cb, chars, this)) {}
+ mDevice(new android::acam::CameraDevice(id, cb, chars, this)) {}
~ACameraDevice() {};
@@ -331,7 +333,7 @@
}
private:
- android::sp<android::CameraDevice> mDevice;
+ android::sp<android::acam::CameraDevice> mDevice;
};
#endif // _ACAMERA_DEVICE_H
diff --git a/camera/ndk/impl/ACameraManager.cpp b/camera/ndk/impl/ACameraManager.cpp
index ee67677..7d6ecac 100644
--- a/camera/ndk/impl/ACameraManager.cpp
+++ b/camera/ndk/impl/ACameraManager.cpp
@@ -26,9 +26,10 @@
#include <stdlib.h>
#include <camera/VendorTagDescriptor.h>
-using namespace android;
+using namespace android::acam;
namespace android {
+namespace acam {
// Static member definitions
const char* CameraManagerGlobal::kCameraIdKey = "CameraId";
const char* CameraManagerGlobal::kCallbackFpKey = "CallbackFp";
@@ -345,6 +346,7 @@
}
}
+} // namespace acam
} // namespace android
/**
diff --git a/camera/ndk/impl/ACameraManager.h b/camera/ndk/impl/ACameraManager.h
index ce65769..55bfa7e 100644
--- a/camera/ndk/impl/ACameraManager.h
+++ b/camera/ndk/impl/ACameraManager.h
@@ -35,6 +35,7 @@
#include <map>
namespace android {
+namespace acam {
/**
* Per-process singleton instance of CameraManger. Shared by all ACameraManager
@@ -172,6 +173,7 @@
~CameraManagerGlobal();
};
+} // namespace acam;
} // namespace android;
/**
@@ -180,7 +182,7 @@
*/
struct ACameraManager {
ACameraManager() :
- mGlobalManager(&(android::CameraManagerGlobal::getInstance())) {}
+ mGlobalManager(&(android::acam::CameraManagerGlobal::getInstance())) {}
~ACameraManager();
camera_status_t getCameraIdList(ACameraIdList** cameraIdList);
static void deleteCameraIdList(ACameraIdList* cameraIdList);
@@ -196,7 +198,7 @@
kCameraIdListNotInit = -1
};
android::Mutex mLock;
- android::sp<android::CameraManagerGlobal> mGlobalManager;
+ android::sp<android::acam::CameraManagerGlobal> mGlobalManager;
};
#endif //_ACAMERA_MANAGER_H
diff --git a/camera/ndk/impl/ACameraMetadata.h b/camera/ndk/impl/ACameraMetadata.h
index e76b80c..f21dbaf 100644
--- a/camera/ndk/impl/ACameraMetadata.h
+++ b/camera/ndk/impl/ACameraMetadata.h
@@ -22,7 +22,13 @@
#include <utils/Mutex.h>
#include <utils/RefBase.h>
#include <utils/Vector.h>
+
+#ifdef __ANDROID_VNDK__
+#include <CameraMetadata.h>
+using CameraMetadata = android::hardware::camera::common::V1_0::helper::CameraMetadata;
+#else
#include <camera/CameraMetadata.h>
+#endif
#include <camera/NdkCameraMetadata.h>
diff --git a/camera/ndk/impl/ACaptureRequest.h b/camera/ndk/impl/ACaptureRequest.h
index b11dafb..5c82ab7 100644
--- a/camera/ndk/impl/ACaptureRequest.h
+++ b/camera/ndk/impl/ACaptureRequest.h
@@ -21,8 +21,11 @@
using namespace android;
+#ifdef __ANDROID_VNDK__
+#include "ndk_vendor/impl/ACaptureRequestVendor.h"
+#else
struct ACameraOutputTarget {
- explicit ACameraOutputTarget(ANativeWindow* window) : mWindow(window) {};
+ explicit ACameraOutputTarget(ACameraWindowType* window) : mWindow(window) {};
bool operator == (const ACameraOutputTarget& other) const {
return mWindow == other.mWindow;
@@ -37,8 +40,9 @@
return mWindow > other.mWindow;
}
- ANativeWindow* mWindow;
+ ACameraWindowType* mWindow;
};
+#endif
struct ACameraOutputTargets {
std::set<ACameraOutputTarget> mOutputs;