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.
70 lines
2.3 KiB
C
70 lines
2.3 KiB
C
2 years ago
|
#ifndef __PHONE_DEVICE_H__
|
||
|
#define __PHONE_DEVICE_H__
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <fcntl.h>
|
||
|
#include <unistd.h>
|
||
|
#include <errno.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
#include <time.h>
|
||
|
|
||
|
#include <camera/NdkCameraManager.h>
|
||
|
#include <camera/NdkCameraError.h>
|
||
|
#include <camera/NdkCameraDevice.h>
|
||
|
#include <camera/NdkCameraMetadataTags.h>
|
||
|
#include <media/NdkImageReader.h>
|
||
|
#include <android/log.h>
|
||
|
// #define LOG_TAG "native-camera2-jni"
|
||
|
#define PD_LOG_TAG "PhoneDev"
|
||
|
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,PD_LOG_TAG,__VA_ARGS__)
|
||
|
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,PD_LOG_TAG,__VA_ARGS__)
|
||
|
#include <Client/Device.h>
|
||
|
#include <string>
|
||
|
|
||
|
class CPhoneDevice : public IDevice
|
||
|
{
|
||
|
public:
|
||
|
CPhoneDevice();
|
||
|
~CPhoneDevice();
|
||
|
|
||
|
virtual bool TakePhoto(unsigned char channel, unsigned char preset, const string& path, bool photo);
|
||
|
virtual timer_uid_t registerTimer(unsigned int timerType, unsigned int timeout);
|
||
|
virtual bool unregisterTimer(timer_uid_t uid);
|
||
|
virtual bool onTimeout(timer_uid_t uid, unsigned int timerType, unsigned int times);
|
||
|
|
||
|
protected:
|
||
|
|
||
|
ACameraCaptureSession_stateCallbacks *GetSessionListener();
|
||
|
std::string GetFileName() const;
|
||
|
|
||
|
static void camera_device_on_disconnected(void *context, ACameraDevice *device);
|
||
|
static void camera_device_on_error(void *context, ACameraDevice *device, int error);
|
||
|
static void capture_session_on_ready(void *context, ACameraCaptureSession *session);
|
||
|
static void capture_session_on_active(void *context, ACameraCaptureSession *session);
|
||
|
static void capture_session_on_closed(void *context, ACameraCaptureSession *session);
|
||
|
|
||
|
void ImageCallback(AImageReader *reader);
|
||
|
static void OnImageCallback(void *ctx, AImageReader *reader);
|
||
|
static bool WriteFile(CPhoneDevice* pThis, AImage *image);
|
||
|
|
||
|
protected:
|
||
|
|
||
|
std::string mPath;
|
||
|
|
||
|
AImageReader *mAImageReader;
|
||
|
ANativeWindow *theNativeWindow;
|
||
|
ACameraDevice *cameraDevice;
|
||
|
ACaptureRequest *captureRequest;
|
||
|
ACameraOutputTarget *cameraOutputTarget;
|
||
|
ACaptureSessionOutput *sessionOutput;
|
||
|
ACaptureSessionOutputContainer *captureSessionOutputContainer;
|
||
|
ACameraCaptureSession *captureSession;
|
||
|
|
||
|
ACameraDevice_StateCallbacks deviceStateCallbacks;
|
||
|
ACameraCaptureSession_stateCallbacks captureSessionStateCallbacks;
|
||
|
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif // __PHONE_DEVICE_H__
|