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.
124 lines
3.4 KiB
C++
124 lines
3.4 KiB
C++
#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 <map>
|
|
#include <atomic>
|
|
#include <filesystem>
|
|
|
|
#include <camera/NdkCameraManager.h>
|
|
#include <camera/NdkCameraError.h>
|
|
#include <camera/NdkCameraDevice.h>
|
|
#include <camera/NdkCameraMetadataTags.h>
|
|
#include <media/NdkImageReader.h>
|
|
#include <Client/Device.h>
|
|
#include <string>
|
|
|
|
#include "camera2/Camera2Helper.h"
|
|
#include "camera2/ndkcamera.h"
|
|
|
|
|
|
class CPhoneDevice : public IDevice
|
|
{
|
|
public:
|
|
|
|
class CPhoneCamera : public NdkCamera {
|
|
public:
|
|
CPhoneCamera(CPhoneDevice* dev, int32_t width, int32_t height);
|
|
virtual bool on_image(const cv::Mat& rgb);
|
|
virtual void on_error(const std::string& msg);
|
|
|
|
protected:
|
|
CPhoneDevice* m_dev;
|
|
};
|
|
|
|
CPhoneDevice(JavaVM* vm, jobject service);
|
|
virtual ~CPhoneDevice();
|
|
|
|
virtual void SetListener(IListener* listener);
|
|
virtual bool UpdateTime(time_t ts);
|
|
virtual bool UpdateSchedules();
|
|
virtual bool QuerySystemProperties(map<string, string>& properties);
|
|
virtual bool Reboot(int resetType);
|
|
virtual bool EnableGPS(bool enabled);
|
|
virtual bool RequestPosition();
|
|
virtual timer_uid_t RegisterHeartbeat(unsigned int timerType, unsigned int timeout);
|
|
virtual bool TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<OSD_INFO>& osds, const std::string& path);
|
|
virtual bool CloseCamera();
|
|
virtual timer_uid_t RegisterTimer(unsigned int timerType, unsigned int timeout, unsigned long times = 0);
|
|
virtual bool UnregisterTimer(timer_uid_t uid);
|
|
virtual unsigned long RequestWakelock(unsigned long timeout);
|
|
virtual bool ReleaseWakelock(unsigned long wakelock);
|
|
|
|
virtual bool FireTimer(timer_uid_t uid, unsigned long times);
|
|
|
|
bool GetNextScheduleItem(uint32_t tsBasedZero, uint32_t scheduleTime, vector<uint32_t>& items);
|
|
|
|
void UpdatePosition(double lon, double lat, time_t ts);
|
|
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 QueryPowerInfo(std::map<std::string, std::string>& powerInfo);
|
|
std::string QueryCpuTemperature();
|
|
|
|
bool OnImageReady(const cv::Mat& mat);
|
|
void onError(const std::string& msg);
|
|
|
|
static void CloseCamera2(CPhoneCamera* camera);
|
|
protected:
|
|
|
|
JavaVM* m_vm;
|
|
jobject m_javaService;
|
|
|
|
jmethodID mRegisterTimerMid;
|
|
jmethodID mRegisterHeartbeatMid;
|
|
jmethodID mUnregisterTimerMid;
|
|
jmethodID mUpdateTimeMid;
|
|
|
|
jmethodID mRequestWakelockMid;
|
|
jmethodID mReleaseWakelockMid;
|
|
|
|
jmethodID mGetSystemInfoMid;
|
|
|
|
jmethodID mRebootMid;
|
|
jmethodID mEnableGpsMid;
|
|
jmethodID mRequestPositionMid;
|
|
|
|
std::string mPath;
|
|
IDevice::PHOTO_INFO mPhotoInfo;
|
|
vector<IDevice::OSD_INFO> mOsds;
|
|
IListener* m_listener;
|
|
|
|
atomic_ulong m_timerUidFeed;
|
|
atomic_ulong m_wakelockIdFeed;
|
|
std::map<IDevice::timer_uid_t, unsigned long> mTimers;
|
|
|
|
mutable CPhoneCamera* mCamera;
|
|
|
|
time_t mHeartbeatStartTime;
|
|
unsigned int mHeartbeatDuration;
|
|
};
|
|
|
|
|
|
#endif // __PHONE_DEVICE_H__
|