summaryrefslogtreecommitdiffstats
path: root/services/camera/libcameraservice/CameraService.h
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2013-02-20 17:15:11 -0800
committerIgor Murashkin <iam@google.com>2013-02-22 10:50:14 -0800
commit634a51509ee50475f3e9f8ccf897e90fc72ded31 (patch)
tree5d9fc437299a8b5adc391eb721d55c9df00afc87 /services/camera/libcameraservice/CameraService.h
parent1d88023e1de6b9f370eb4be944dd9c4480d01f11 (diff)
downloadframeworks_av-634a51509ee50475f3e9f8ccf897e90fc72ded31.zip
frameworks_av-634a51509ee50475f3e9f8ccf897e90fc72ded31.tar.gz
frameworks_av-634a51509ee50475f3e9f8ccf897e90fc72ded31.tar.bz2
Camera: Add ProCamera private binder interface for an API2-light functionality
Change-Id: I2af7a807c99df75ea659e6e6acc9c4fca6a56274
Diffstat (limited to 'services/camera/libcameraservice/CameraService.h')
-rw-r--r--services/camera/libcameraservice/CameraService.h147
1 files changed, 123 insertions, 24 deletions
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 41365a0..9e0f62a 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -18,6 +18,7 @@
#ifndef ANDROID_SERVERS_CAMERA_CAMERASERVICE_H
#define ANDROID_SERVERS_CAMERA_CAMERASERVICE_H
+#include <utils/Vector.h>
#include <binder/BinderService.h>
#include <camera/ICameraService.h>
#include <hardware/camera.h>
@@ -40,27 +41,32 @@ class CameraService :
friend class BinderService<CameraService>;
public:
class Client;
+ class BasicClient;
+
+ // Implementation of BinderService<T>
static char const* getServiceName() { return "media.camera"; }
CameraService();
virtual ~CameraService();
+ /////////////////////////////////////////////////////////////////////
+ // ICameraService
virtual int32_t getNumberOfCameras();
virtual status_t getCameraInfo(int cameraId,
struct CameraInfo* cameraInfo);
virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient, int cameraId);
- virtual void removeClient(const sp<ICameraClient>& cameraClient);
- // returns plain pointer of client. Note that mClientLock should be acquired to
- // prevent the client from destruction. The result can be NULL.
- virtual Client* getClientByIdUnsafe(int cameraId);
- virtual Mutex* getClientLockById(int cameraId);
-
- virtual sp<Client> getClientByRemote(const wp<IBinder>& cameraClient);
+ virtual sp<IProCameraUser>
+ connect(const sp<IProCameraCallbacks>& cameraCb, int cameraId);
- virtual status_t dump(int fd, const Vector<String16>& args);
+ // Extra permissions checks
virtual status_t onTransact(uint32_t code, const Parcel& data,
Parcel* reply, uint32_t flags);
- virtual void onFirstRef();
+
+ virtual status_t dump(int fd, const Vector<String16>& args);
+
+ /////////////////////////////////////////////////////////////////////
+ // Client functionality
+ virtual void removeClientByRemote(const wp<IBinder>& remoteBinder);
enum sound_kind {
SOUND_SHUTTER = 0,
@@ -72,7 +78,53 @@ public:
void playSound(sound_kind kind);
void releaseSound();
- class Client : public BnCamera
+
+ /////////////////////////////////////////////////////////////////////
+ // CameraClient functionality
+
+ // returns plain pointer of client. Note that mClientLock should be acquired to
+ // prevent the client from destruction. The result can be NULL.
+ virtual Client* getClientByIdUnsafe(int cameraId);
+ virtual Mutex* getClientLockById(int cameraId);
+
+ class BasicClient : public virtual RefBase {
+ public:
+ virtual status_t initialize(camera_module_t *module) = 0;
+
+ virtual void disconnect() = 0;
+
+ wp<IBinder> getRemote() {
+ return mRemoteCallback;
+ }
+
+ protected:
+ BasicClient(const sp<CameraService>& cameraService,
+ const sp<IBinder>& remoteCallback,
+ int cameraId,
+ int cameraFacing,
+ int clientPid,
+ int servicePid);
+
+ virtual ~BasicClient();
+
+ // the instance is in the middle of destruction. When this is set,
+ // the instance should not be accessed from callback.
+ // CameraService's mClientLock should be acquired to access this.
+ // - subclasses should set this to true in their destructors.
+ bool mDestructionStarted;
+
+ // these are initialized in the constructor.
+ sp<CameraService> mCameraService; // immutable after constructor
+ int mCameraId; // immutable after constructor
+ int mCameraFacing; // immutable after constructor
+ pid_t mClientPid;
+ pid_t mServicePid; // immutable after constructor
+
+ // - The app-side Binder interface to receive callbacks from us
+ wp<IBinder> mRemoteCallback; // immutable after constructor
+ };
+
+ class Client : public BnCamera, public BasicClient
{
public:
// ICamera interface (see ICamera for details)
@@ -112,38 +164,82 @@ public:
return mCameraClient;
}
- virtual status_t initialize(camera_module_t *module) = 0;
-
- virtual status_t dump(int fd, const Vector<String16>& args) = 0;
-
protected:
static Mutex* getClientLockFromCookie(void* user);
// convert client from cookie. Client lock should be acquired before getting Client.
static Client* getClientFromCookie(void* user);
- // the instance is in the middle of destruction. When this is set,
- // the instance should not be accessed from callback.
- // CameraService's mClientLock should be acquired to access this.
- bool mDestructionStarted;
+ // Initialized in constructor
- // these are initialized in the constructor.
- sp<CameraService> mCameraService; // immutable after constructor
+ // - The app-side Binder interface to receive callbacks from us
sp<ICameraClient> mCameraClient;
- int mCameraId; // immutable after constructor
- int mCameraFacing; // immutable after constructor
- pid_t mClientPid;
- pid_t mServicePid; // immutable after constructor
+ };
+
+ class ProClient : public BnProCameraUser, public BasicClient {
+ public:
+ ProClient(const sp<CameraService>& cameraService,
+ const sp<IProCameraCallbacks>& remoteCallback,
+ int cameraId,
+ int cameraFacing,
+ int clientPid,
+ int servicePid);
+
+ virtual ~ProClient();
+
+ const sp<IProCameraCallbacks>& getRemoteCallback() {
+ return mRemoteCallback;
+ }
+
+ // BasicClient implementation
+ virtual status_t initialize(camera_module_t *module);
+
+ /***
+ IProCamera implementation
+ ***/
+
+
+ virtual status_t connect(
+ const sp<IProCameraCallbacks>& callbacks);
+ virtual void disconnect();
+
+ virtual status_t exclusiveTryLock();
+ virtual status_t exclusiveLock();
+ virtual status_t exclusiveUnlock();
+
+ virtual bool hasExclusiveLock();
+
+ // Note that the callee gets a copy of the metadata.
+ virtual int submitRequest(camera_metadata_t* metadata,
+ bool streaming = false);
+ virtual status_t cancelRequest(int requestId);
+
+ virtual status_t requestStream(int streamId);
+ virtual status_t cancelStream(int streamId);
+
+ protected:
+ sp<IProCameraCallbacks> mRemoteCallback;
};
private:
+
+ // Delay-load the Camera HAL module
+ virtual void onFirstRef();
+
+ virtual sp<BasicClient> getClientByRemote(const wp<IBinder>& cameraClient);
+
Mutex mServiceLock;
wp<Client> mClient[MAX_CAMERAS]; // protected by mServiceLock
Mutex mClientLock[MAX_CAMERAS]; // prevent Client destruction inside callbacks
int mNumberOfCameras;
+ typedef wp<ProClient> weak_pro_client_ptr;
+ Vector<weak_pro_client_ptr> mProClientList[MAX_CAMERAS];
+
// needs to be called with mServiceLock held
sp<Client> findClientUnsafe(const wp<IBinder>& cameraClient, int& outIndex);
+ sp<ProClient> findProClientUnsafe(
+ const wp<IBinder>& cameraCallbacksRemote);
// atomics to record whether the hardware is allocated to some client.
volatile int32_t mBusy[MAX_CAMERAS];
@@ -161,6 +257,9 @@ private:
// IBinder::DeathRecipient implementation
virtual void binderDied(const wp<IBinder> &who);
+
+ // Helpers
+ int getDeviceVersion(int cameraId, int* facing);
};
} // namespace android