summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2010-05-06 16:36:58 +0800
committerChih-Chung Chang <chihchung@google.com>2010-05-10 11:21:14 +0800
commit35a055b8bfc6f3cbea409b2897caf936654519cb (patch)
treef2167d55486fd370d24e68aabe1ae37879cde8ec /camera
parentd8a30349da270715156d3f658b165481ce10cf71 (diff)
downloadframeworks_av-35a055b8bfc6f3cbea409b2897caf936654519cb.zip
frameworks_av-35a055b8bfc6f3cbea409b2897caf936654519cb.tar.gz
frameworks_av-35a055b8bfc6f3cbea409b2897caf936654519cb.tar.bz2
Support multiple cameras in framework.
Change-Id: I081f0fbdca4b633715ea7c3b3d42f8662d27598a
Diffstat (limited to 'camera')
-rw-r--r--camera/Camera.cpp11
-rw-r--r--camera/ICameraService.cpp19
2 files changed, 26 insertions, 4 deletions
diff --git a/camera/Camera.cpp b/camera/Camera.cpp
index f19c502..3346b1f 100644
--- a/camera/Camera.cpp
+++ b/camera/Camera.cpp
@@ -95,13 +95,20 @@ Camera::~Camera()
disconnect();
}
-sp<Camera> Camera::connect()
+int32_t Camera::getNumberOfCameras()
+{
+ const sp<ICameraService>& cs = getCameraService();
+ if (cs == 0) return 0;
+ return cs->getNumberOfCameras();
+}
+
+sp<Camera> Camera::connect(int cameraId)
{
LOGV("connect");
sp<Camera> c = new Camera();
const sp<ICameraService>& cs = getCameraService();
if (cs != 0) {
- c->mCamera = cs->connect(c);
+ c->mCamera = cs->connect(c, cameraId);
}
if (c->mCamera != 0) {
c->mCamera->asBinder()->linkToDeath(c);
diff --git a/camera/ICameraService.cpp b/camera/ICameraService.cpp
index 46b5478..db1dca6 100644
--- a/camera/ICameraService.cpp
+++ b/camera/ICameraService.cpp
@@ -34,12 +34,22 @@ public:
{
}
+ // get number of cameras available
+ virtual int32_t getNumberOfCameras()
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
+ remote()->transact(BnCameraService::GET_NUMBER_OF_CAMERAS, data, &reply);
+ return reply.readInt32();
+ }
+
// connect to camera service
- virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient)
+ virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient, int cameraId)
{
Parcel data, reply;
data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
data.writeStrongBinder(cameraClient->asBinder());
+ data.writeInt32(cameraId);
remote()->transact(BnCameraService::CONNECT, data, &reply);
return interface_cast<ICamera>(reply.readStrongBinder());
}
@@ -53,10 +63,15 @@ status_t BnCameraService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch(code) {
+ case GET_NUMBER_OF_CAMERAS: {
+ CHECK_INTERFACE(ICameraService, data, reply);
+ reply->writeInt32(getNumberOfCameras());
+ return NO_ERROR;
+ } break;
case CONNECT: {
CHECK_INTERFACE(ICameraService, data, reply);
sp<ICameraClient> cameraClient = interface_cast<ICameraClient>(data.readStrongBinder());
- sp<ICamera> camera = connect(cameraClient);
+ sp<ICamera> camera = connect(cameraClient, data.readInt32());
reply->writeStrongBinder(camera->asBinder());
return NO_ERROR;
} break;