You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.0 KiB
C
73 lines
2.0 KiB
C
2 years ago
|
#ifndef __CAMERA_H__
|
||
|
#define __CAMERA_H__
|
||
|
|
||
|
|
||
|
|
||
|
// Must come before NdkCameraCaptureSession.h
|
||
|
#include <camera/NdkCaptureRequest.h>
|
||
|
|
||
|
#include <camera/NdkCameraCaptureSession.h>
|
||
|
#include <camera/NdkCameraDevice.h>
|
||
|
#include <camera/NdkCameraError.h>
|
||
|
#include <camera/NdkCameraManager.h>
|
||
|
#include <cstdlib>
|
||
|
#include <cstring>
|
||
|
#include <string>
|
||
|
#include <jni.h>
|
||
|
#include <media/NdkImage.h>
|
||
|
#include <media/NdkImageReader.h>
|
||
|
|
||
|
|
||
|
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__
|