diff options
Diffstat (limited to 'include/camera/Camera.h')
-rw-r--r-- | include/camera/Camera.h | 118 |
1 files changed, 48 insertions, 70 deletions
diff --git a/include/camera/Camera.h b/include/camera/Camera.h index 234e165..79682b8 100644 --- a/include/camera/Camera.h +++ b/include/camera/Camera.h @@ -18,41 +18,20 @@ #define ANDROID_HARDWARE_CAMERA_H #include <utils/Timers.h> -#include <gui/ISurfaceTexture.h> +#include <gui/IGraphicBufferProducer.h> #include <system/camera.h> #include <camera/ICameraClient.h> #include <camera/ICameraRecordingProxy.h> #include <camera/ICameraRecordingProxyListener.h> +#include <camera/ICameraService.h> +#include <camera/ICamera.h> +#include <camera/CameraBase.h> namespace android { -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. The - * back-facing camera sensor is mounted in landscape. You are looking at - * the screen. If the top side of the camera sensor is aligned with the - * right edge of the screen in natural orientation, the value should be - * 90. If the top side of a front-facing camera sensor is aligned with the - * right of the screen, the value should be 270. - */ - int orientation; -}; - -class ICameraService; -class ICamera; class Surface; -class Mutex; class String8; +class String16; // ref-counted object for callbacks class CameraListener: virtual public RefBase @@ -64,32 +43,47 @@ public: virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) = 0; }; -class Camera : public BnCameraClient, public IBinder::DeathRecipient +class Camera; + +template <> +struct CameraTraits<Camera> +{ + typedef CameraListener TCamListener; + typedef ICamera TCamUser; + typedef ICameraClient TCamCallbacks; + typedef status_t (ICameraService::*TCamConnectService)(const sp<ICameraClient>&, + int, const String16&, int, + /*out*/ + sp<ICamera>&); + static TCamConnectService fnConnectService; +}; + + +class Camera : + public CameraBase<Camera>, + public BnCameraClient { public: + enum { + USE_CALLING_UID = ICameraService::USE_CALLING_UID + }; + // 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); + static sp<Camera> connect(int cameraId, + const String16& clientPackageName, + int clientUid); + virtual ~Camera(); - void init(); status_t reconnect(); - void disconnect(); status_t lock(); status_t unlock(); - status_t getStatus() { return mStatus; } + // pass the buffered IGraphicBufferProducer to the camera service + status_t setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer); - // pass the buffered Surface to the camera service - status_t setPreviewDisplay(const sp<Surface>& surface); - - // pass the buffered ISurfaceTexture to the camera service - status_t setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture); - - // start preview mode, must call setPreviewDisplay first + // start preview mode, must call setPreviewTarget first status_t startPreview(); // stop preview mode @@ -98,7 +92,7 @@ public: // get preview state bool previewEnabled(); - // start recording mode, must call setPreviewDisplay first + // start recording mode, must call setPreviewTarget first status_t startRecording(); // stop recording mode @@ -133,7 +127,15 @@ public: void setListener(const sp<CameraListener>& listener); void setRecordingProxyListener(const sp<ICameraRecordingProxyListener>& listener); + + // Configure preview callbacks to app. Only one of the older + // callbacks or the callback surface can be active at the same time; + // enabling one will disable the other if active. Flags can be + // disabled by calling it with CAMERA_FRAME_CALLBACK_FLAG_NOOP, and + // Target by calling it with a NULL interface. void setPreviewCallbackFlags(int preview_callback_flag); + status_t setPreviewCallbackTarget( + const sp<IGraphicBufferProducer>& callbackProducer); sp<ICameraRecordingProxy> getRecordingProxy(); @@ -143,8 +145,6 @@ public: camera_frame_metadata_t *metadata); virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr); - sp<ICamera> remote(); - class RecordingProxy : public BnCameraRecordingProxy { public: @@ -159,36 +159,14 @@ public: sp<Camera> mCamera; }; -private: - Camera(); +protected: + Camera(int cameraId); Camera(const Camera&); Camera& operator=(const Camera); - virtual void binderDied(const wp<IBinder>& who); - - class DeathNotifier: public IBinder::DeathRecipient - { - public: - DeathNotifier() { - } - - virtual void binderDied(const wp<IBinder>& who); - }; - - static sp<DeathNotifier> mDeathNotifier; - - // helper function to obtain camera service handle - static const sp<ICameraService>& getCameraService(); - - sp<ICamera> mCamera; - status_t mStatus; - - sp<CameraListener> mListener; - sp<ICameraRecordingProxyListener> mRecordingProxyListener; - friend class DeathNotifier; + sp<ICameraRecordingProxyListener> mRecordingProxyListener; - static Mutex mLock; - static sp<ICameraService> mCameraService; + friend class CameraBase; }; }; // namespace android |