#ifndef __PHONE_DEVICE_H__ #define __PHONE_DEVICE_H__ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // #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 #include #include "Camera2Helper.h" #include "camera2/ndkcamera.h" class CPhoneDevice : public IDevice { public: CPhoneDevice(JavaVM* vm, jobject service); virtual ~CPhoneDevice(); virtual void SetListener(IListener* listener); virtual bool UpdateTime(time_t ts); virtual bool QuerySystemProperties(map& properties); virtual bool Reboot(); virtual timer_uid_t RegisterHeartbeat(unsigned int timerType, unsigned int timeout); virtual bool TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector& osds, const string& path); virtual timer_uid_t RegisterTimer(unsigned int timerType, unsigned int timeout); virtual bool UnregisterTimer(timer_uid_t uid); virtual bool FireTimer(timer_uid_t uid); bool GetNextScheduleItem(uint32_t tsBasedZero, uint32_t scheduleTime, vector& items); protected: std::string GetFileName() const; bool SendBroadcastMessage(std::string action, int value); // bool MatchCaptureSizeRequest(ACameraManager *cameraManager, const char *selectedCameraId, unsigned int width, unsigned int height, uint32_t cameraOrientation_, inline bool TakePhotoCb(bool res, const IDevice::PHOTO_INFO& photoInfo, const string& path, time_t photoTime) const { if (m_listener != NULL) { return m_listener->OnPhotoTaken(res, photoInfo, path, photoTime); } return false; } void OnImageReady(const cv::Mat& mat) const; protected: JavaVM* m_vm; jobject m_javaService; jmethodID mRegisterTimerMid; jmethodID mRegisterHeartbeatMid; jmethodID mUnregisterTimerMid; jmethodID mUpdateTimeMid; std::string mPath; IDevice::PHOTO_INFO mPhotoInfo; vector mOsds; IListener* m_listener; atomic_ulong m_timerUidFeed; std::map mTimers; class CPhoneCamera : public NdkCamera { public: CPhoneCamera(CPhoneDevice* dev, int32_t width, int32_t height); virtual void on_image(const cv::Mat& rgb) const; protected: CPhoneDevice* m_dev; }; mutable CPhoneCamera* mCamera; time_t mHeartbeatStartTime; unsigned int mHeartbeatDuration; }; #endif // __PHONE_DEVICE_H__