#ifndef __CAMERA_H__ #define __CAMERA_H__ // Must come before NdkCameraCaptureSession.h #include #include #include #include #include #include #include #include #include #include #include class CCamera { public: CCamera(); ~CCamera(); int initCamera(ANativeWindow *imgReaderAnw); bool isCapabilitySupported(acamera_metadata_enum_android_request_available_capabilities_t cap); bool isCameraReady() { return mIsCameraReady; } void closeCamera(); int takePicture(); static void onDeviceDisconnected(void * /*obj*/, ACameraDevice * /*device*/) {} static void onDeviceError(void * /*obj*/, ACameraDevice * /*device*/, int /*errorCode*/) {} static void onSessionClosed(void * /*obj*/, ACameraCaptureSession * /*session*/) {} static void onSessionReady(void * /*obj*/, ACameraCaptureSession * /*session*/) {} static void onSessionActive(void * /*obj*/, ACameraCaptureSession * /*session*/) {} private: ACameraDevice_StateCallbacks mDeviceCb{ this, onDeviceDisconnected, onDeviceError }; ACameraCaptureSession_stateCallbacks mSessionCb{ this, onSessionClosed, onSessionReady, onSessionActive }; ANativeWindow *mImgReaderAnw{ nullptr }; // not owned by us. // Camera manager ACameraManager *mCameraManager{ nullptr }; ACameraIdList *mCameraIdList{ nullptr }; // Camera device ACameraMetadata *mCameraMetadata{ nullptr }; ACameraDevice *mDevice{ nullptr }; // Capture session ACaptureSessionOutputContainer *mOutputs{ nullptr }; ACaptureSessionOutput *mImgReaderOutput{ nullptr }; ACameraCaptureSession *mSession{ nullptr }; // Capture request ACaptureRequest *mCaptureRequest{ nullptr }; ACameraOutputTarget *mReqImgReaderOutput{ nullptr }; bool mIsCameraReady{ false }; const char *mCameraId{ nullptr }; private: }; #endif // __CAMERA_H__