summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camera/ICameraService.cpp36
-rw-r--r--include/camera/ICameraService.h5
-rw-r--r--services/camera/libcameraservice/CameraService.cpp37
-rw-r--r--services/camera/libcameraservice/CameraService.h2
4 files changed, 80 insertions, 0 deletions
diff --git a/camera/ICameraService.cpp b/camera/ICameraService.cpp
index 3debe22..5fc89fb 100644
--- a/camera/ICameraService.cpp
+++ b/camera/ICameraService.cpp
@@ -33,6 +33,7 @@
#include <camera/ICameraClient.h>
#include <camera/camera2/ICameraDeviceUser.h>
#include <camera/camera2/ICameraDeviceCallbacks.h>
+#include <camera/CameraMetadata.h>
namespace android {
@@ -119,6 +120,29 @@ public:
return result;
}
+ // get camera characteristics (static metadata)
+ virtual status_t getCameraCharacteristics(int cameraId,
+ CameraMetadata* cameraInfo) {
+ Parcel data, reply;
+ data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
+ data.writeInt32(cameraId);
+ remote()->transact(BnCameraService::GET_CAMERA_CHARACTERISTICS, data, &reply);
+
+ if (readExceptionCode(reply)) return -EPROTO;
+ status_t result = reply.readInt32();
+
+ CameraMetadata out;
+ if (reply.readInt32() != 0) {
+ out.readFromParcel(&reply);
+ }
+
+ if (cameraInfo != NULL) {
+ cameraInfo->swap(out);
+ }
+
+ return result;
+ }
+
// connect to camera service (android.hardware.Camera)
virtual status_t connect(const sp<ICameraClient>& cameraClient, int cameraId,
const String16 &clientPackageName, int clientUid,
@@ -239,6 +263,18 @@ status_t BnCameraService::onTransact(
reply->writeInt32(cameraInfo.orientation);
return NO_ERROR;
} break;
+ case GET_CAMERA_CHARACTERISTICS: {
+ CHECK_INTERFACE(ICameraService, data, reply);
+ CameraMetadata info;
+ status_t result = getCameraCharacteristics(data.readInt32(), &info);
+ reply->writeNoException();
+ reply->writeInt32(result);
+
+ // out-variables are after exception and return value
+ reply->writeInt32(1); // means the parcelable is included
+ info.writeToParcel(reply);
+ return NO_ERROR;
+ } break;
case CONNECT: {
CHECK_INTERFACE(ICameraService, data, reply);
sp<ICameraClient> cameraClient =
diff --git a/include/camera/ICameraService.h b/include/camera/ICameraService.h
index 0e10699..f342122 100644
--- a/include/camera/ICameraService.h
+++ b/include/camera/ICameraService.h
@@ -30,6 +30,7 @@ class IProCameraCallbacks;
class ICameraServiceListener;
class ICameraDeviceUser;
class ICameraDeviceCallbacks;
+class CameraMetadata;
class ICameraService : public IInterface
{
@@ -45,6 +46,7 @@ public:
CONNECT_DEVICE,
ADD_LISTENER,
REMOVE_LISTENER,
+ GET_CAMERA_CHARACTERISTICS,
};
enum {
@@ -58,6 +60,9 @@ public:
virtual status_t getCameraInfo(int cameraId,
struct CameraInfo* cameraInfo) = 0;
+ virtual status_t getCameraCharacteristics(int cameraId,
+ CameraMetadata* cameraInfo) = 0;
+
// Returns 'OK' if operation succeeded
// - Errors: ALREADY_EXISTS if the listener was already added
virtual status_t addListener(const sp<ICameraServiceListener>& listener)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index fe16314..5e84aaf 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -225,6 +225,43 @@ status_t CameraService::getCameraInfo(int cameraId,
return rc;
}
+status_t CameraService::getCameraCharacteristics(int cameraId,
+ CameraMetadata* cameraInfo) {
+ if (!cameraInfo) {
+ ALOGE("%s: cameraInfo is NULL", __FUNCTION__);
+ return BAD_VALUE;
+ }
+
+ if (!mModule) {
+ ALOGE("%s: camera hardware module doesn't exist", __FUNCTION__);
+ return -ENODEV;
+ }
+
+ if (mModule->common.module_api_version < CAMERA_MODULE_API_VERSION_2_0) {
+ // TODO: Remove this check once HAL1 shim is in place.
+ ALOGE("%s: Only HAL module version V2 or higher supports static metadata", __FUNCTION__);
+ return BAD_VALUE;
+ }
+
+ if (cameraId < 0 || cameraId >= mNumberOfCameras) {
+ ALOGE("%s: Invalid camera id: %d", __FUNCTION__, cameraId);
+ return BAD_VALUE;
+ }
+
+ int facing;
+ if (getDeviceVersion(cameraId, &facing) == CAMERA_DEVICE_API_VERSION_1_0) {
+ // TODO: Remove this check once HAL1 shim is in place.
+ ALOGE("%s: HAL1 doesn't support static metadata yet", __FUNCTION__);
+ return BAD_VALUE;
+ }
+
+ struct camera_info info;
+ status_t ret = mModule->get_camera_info(cameraId, &info);
+ *cameraInfo = info.static_camera_characteristics;
+
+ return ret;
+}
+
int CameraService::getDeviceVersion(int cameraId, int* facing) {
struct camera_info info;
if (mModule->get_camera_info(cameraId, &info) != OK) {
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index b34a0f6..ad6a582 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -71,6 +71,8 @@ public:
virtual int32_t getNumberOfCameras();
virtual status_t getCameraInfo(int cameraId,
struct CameraInfo* cameraInfo);
+ virtual status_t getCameraCharacteristics(int cameraId,
+ CameraMetadata* cameraInfo);
virtual status_t connect(const sp<ICameraClient>& cameraClient, int cameraId,
const String16& clientPackageName, int clientUid,