diff options
author | Chih-Chung Chang <chihchung@google.com> | 2010-06-10 13:32:16 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2010-06-11 16:47:33 +0800 |
commit | ddbdb35d176266b5ab64c30178f5cb76c5b1b4b4 (patch) | |
tree | 9a3115e77421f95a8505067cfa60b5a73518ad68 | |
parent | 0a5baa9b411fe086013d2a5e9126ed63fbad046c (diff) | |
download | frameworks_av-ddbdb35d176266b5ab64c30178f5cb76c5b1b4b4.zip frameworks_av-ddbdb35d176266b5ab64c30178f5cb76c5b1b4b4.tar.gz frameworks_av-ddbdb35d176266b5ab64c30178f5cb76c5b1b4b4.tar.bz2 |
Change camera interface to support multiple cameras.
Change-Id: Ie88fe706d2278acf762eca87780de349434778a4
-rw-r--r-- | camera/Camera.cpp | 7 | ||||
-rw-r--r-- | camera/ICameraService.cpp | 22 | ||||
-rw-r--r-- | include/camera/Camera.h | 28 | ||||
-rw-r--r-- | include/camera/CameraHardwareInterface.h | 11 | ||||
-rw-r--r-- | include/camera/ICameraService.h | 3 |
5 files changed, 69 insertions, 2 deletions
diff --git a/camera/Camera.cpp b/camera/Camera.cpp index 2fbddd5..0037399 100644 --- a/camera/Camera.cpp +++ b/camera/Camera.cpp @@ -107,6 +107,13 @@ int32_t Camera::getNumberOfCameras() return cs->getNumberOfCameras(); } +status_t Camera::getCameraInfo(int cameraId, + struct CameraInfo* cameraInfo) { + const sp<ICameraService>& cs = getCameraService(); + if (cs == 0) return UNKNOWN_ERROR; + return cs->getCameraInfo(cameraId, cameraInfo); +} + sp<Camera> Camera::connect(int cameraId) { LOGV("connect"); diff --git a/camera/ICameraService.cpp b/camera/ICameraService.cpp index db1dca6..85f1a29 100644 --- a/camera/ICameraService.cpp +++ b/camera/ICameraService.cpp @@ -43,6 +43,18 @@ public: return reply.readInt32(); } + // get information about a camera + virtual status_t getCameraInfo(int cameraId, + struct CameraInfo* cameraInfo) { + Parcel data, reply; + data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); + data.writeInt32(cameraId); + remote()->transact(BnCameraService::GET_CAMERA_INFO, data, &reply); + cameraInfo->facing = reply.readInt32(); + cameraInfo->orientation = reply.readInt32(); + return reply.readInt32(); + } + // connect to camera service virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient, int cameraId) { @@ -68,6 +80,16 @@ status_t BnCameraService::onTransact( reply->writeInt32(getNumberOfCameras()); return NO_ERROR; } break; + case GET_CAMERA_INFO: { + CHECK_INTERFACE(ICameraService, data, reply); + CameraInfo cameraInfo; + memset(&cameraInfo, 0, sizeof(cameraInfo)); + status_t result = getCameraInfo(data.readInt32(), &cameraInfo); + reply->writeInt32(cameraInfo.facing); + reply->writeInt32(cameraInfo.orientation); + reply->writeInt32(result); + return NO_ERROR; + } break; case CONNECT: { CHECK_INTERFACE(ICameraService, data, reply); sp<ICameraClient> cameraClient = interface_cast<ICameraClient>(data.readStrongBinder()); diff --git a/include/camera/Camera.h b/include/camera/Camera.h index 1beac27..9974f2f 100644 --- a/include/camera/Camera.h +++ b/include/camera/Camera.h @@ -93,6 +93,32 @@ enum { CAMERA_ERROR_SERVER_DIED = 100 }; +enum { + CAMERA_FACING_BACK = 0, + CAMERA_FACING_FRONT = 1 /* The camera faces to the user */ +}; + +struct CameraInfo { + + /** + * The direction that the camera faces to. It should be + * CAMERA_FACING_BACK or CAMERA_FACING_FRONT. + */ + int facing; + + /** + * The orientation of the camera image. The value is the angle that the + * camera image needs to be rotated clockwise so it shows correctly on + * the display in its natural orientation. It should be 0, 90, 180, or 270. + * + * For example, suppose a device has a naturally tall screen, but the camera + * sensor is mounted in landscape. If the top side of the camera sensor is + * aligned with the right edge of the display in natural orientation, the + * value should be 90. + */ + int orientation; +}; + class ICameraService; class ICamera; class Surface; @@ -114,6 +140,8 @@ public: // construct a camera client from an existing remote static sp<Camera> create(const sp<ICamera>& camera); static int32_t getNumberOfCameras(); + static status_t getCameraInfo(int cameraId, + struct CameraInfo* cameraInfo); static sp<Camera> connect(int cameraId); ~Camera(); void init(); diff --git a/include/camera/CameraHardwareInterface.h b/include/camera/CameraHardwareInterface.h index d877c74..1529db7 100644 --- a/include/camera/CameraHardwareInterface.h +++ b/include/camera/CameraHardwareInterface.h @@ -213,8 +213,15 @@ public: virtual status_t dump(int fd, const Vector<String16>& args) const = 0; }; -/** factory function to instantiate a camera hardware object */ -extern "C" sp<CameraHardwareInterface> openCameraHardware(); +/** + * The functions need to be provided by the camera HAL. + * + * If getNumberOfCameras() returns N, the valid cameraId for getCameraInfo() + * and openCameraHardware() is 0 to N-1. + */ +extern "C" int HAL_getNumberOfCameras(); +extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo* cameraInfo); +extern "C" sp<CameraHardwareInterface> HAL_openCameraHardware(int cameraId); }; // namespace android diff --git a/include/camera/ICameraService.h b/include/camera/ICameraService.h index dcd434f..7d70c1e 100644 --- a/include/camera/ICameraService.h +++ b/include/camera/ICameraService.h @@ -31,6 +31,7 @@ class ICameraService : public IInterface public: enum { GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION, + GET_CAMERA_INFO, CONNECT }; @@ -38,6 +39,8 @@ public: DECLARE_META_INTERFACE(CameraService); virtual int32_t getNumberOfCameras() = 0; + virtual status_t getCameraInfo(int cameraId, + struct CameraInfo* cameraInfo) = 0; virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient, int cameraId) = 0; }; |