完善采样周期设置的实现

N938
Matthew 6 months ago
parent b24798af08
commit 99ee66139b

@ -154,9 +154,9 @@ void posix_signal_handler(int sig, siginfo_t *siginfo, void *context)
class Runner class Runner
{ {
public: public:
static void RequestCapture(CTerminal* pTerminal, unsigned int channel, unsigned int preset, unsigned int type, unsigned long scheduleTime); static void RequestCapture(CTerminal* pTerminal, unsigned int channel, unsigned int preset, unsigned int type, uint64_t scheduleTime);
}; };
void Runner::RequestCapture(CTerminal* pTerminal, unsigned int channel, unsigned int preset, unsigned int type, unsigned long scheduleTime) void Runner::RequestCapture(CTerminal* pTerminal, unsigned int channel, unsigned int preset, unsigned int type, uint64_t scheduleTime)
{ {
pTerminal->RequestCapture(channel, preset, type, scheduleTime); pTerminal->RequestCapture(channel, preset, type, scheduleTime);
} }
@ -369,17 +369,17 @@ Java_com_xypower_mpapp_MicroPhotoService_notifyToTakePhoto(
} }
unsigned char type = photoOrVideo ? 0 : 1; unsigned char type = photoOrVideo ? 0 : 1;
// std::thread th(&Runner::RequestCapture, pTerminal, (unsigned int)channel, (unsigned int)preset, type, (unsigned long)scheduleTime, 0, true); // std::thread th(&Runner::RequestCapture, pTerminal, (unsigned int)channel, (unsigned int)preset, type, (uint64_t)scheduleTime, 0, true);
// th.detach(); // th.detach();
if (channel < 0x100) if (channel < 0x100)
{ {
pTerminal->RequestCapture((uint32_t)channel, (unsigned int)preset, type, (unsigned long)scheduleTime, 0, true); pTerminal->RequestCapture((uint32_t)channel, (unsigned int)preset, type, (uint64_t)scheduleTime, 0, true);
} }
else else
{ {
uint32_t packetType = channel; uint32_t packetType = channel;
packetType &= 0xFF; packetType &= 0xFF;
pTerminal->RequestSampling(packetType, (unsigned long)scheduleTime, 0); pTerminal->RequestSampling(packetType, (uint64_t)scheduleTime, 0);
} }
return JNI_TRUE; return JNI_TRUE;
@ -568,7 +568,7 @@ Java_com_xypower_mpapp_MicroPhotoService_getPhotoTimeData2(
vector<jlong> dataArray; vector<jlong> dataArray;
dataArray.reserve(numberOfData); dataArray.reserve(numberOfData);
unsigned long val = 0; uint64_t val = 0;
jint channel = 0; jint channel = 0;
for (map<unsigned char, vector<unsigned int>>::const_iterator it = photoTime.cbegin(); it != photoTime.cend(); ++it) for (map<unsigned char, vector<unsigned int>>::const_iterator it = photoTime.cbegin(); it != photoTime.cend(); ++it)
{ {
@ -585,11 +585,11 @@ Java_com_xypower_mpapp_MicroPhotoService_getPhotoTimeData2(
for (vector<unsigned int>::const_iterator it2 = it->second.cbegin(); it2 != it->second.cend(); ++it2) for (vector<unsigned int>::const_iterator it2 = it->second.cbegin(); it2 != it->second.cend(); ++it2)
{ {
// time // time
val = ((unsigned long)((*it2) & 0xFFFFFF00)) << 24; val = ((uint64_t)((*it2) & 0xFFFFFF00)) << 24;
// channel // channel
val |= ((unsigned long)channel) << 16; val |= ((uint64_t)channel) << 16;
// preset // preset
val |= ((unsigned long)((*it2) & 0xFF)) << 8; val |= ((uint64_t)((*it2) & 0xFF)) << 8;
dataArray.push_back((jlong)val); dataArray.push_back((jlong)val);
} }
@ -639,14 +639,14 @@ Java_com_xypower_mpapp_MicroPhotoService_getPhotoTimeData(
dataArray.push_back((jlong)scheduleTime); dataArray.push_back((jlong)scheduleTime);
dataArray.push_back((jlong)channelsAndPresets.size()); dataArray.push_back((jlong)channelsAndPresets.size());
unsigned long val = 0; uint64_t val = 0;
for (std::vector<std::pair<uint16_t, uint8_t> >::const_iterator it = channelsAndPresets.cbegin(); it != channelsAndPresets.cend(); ++it) for (std::vector<std::pair<uint16_t, uint8_t> >::const_iterator it = channelsAndPresets.cbegin(); it != channelsAndPresets.cend(); ++it)
{ {
val = (unsigned long)scheduleTime << 28; val = (((uint64_t)scheduleTime) << 28);
// channel // channel
val |= ((unsigned long)(it->first)) << 12; val |= (((uint64_t)(it->first)) << 12);
// preset // preset
val |= ((unsigned long)(it->second)) << 4; val |= (((uint64_t)(it->second)) << 4);
dataArray.push_back((jlong)val); dataArray.push_back((jlong)val);
} }
@ -761,7 +761,7 @@ Java_com_xypower_mpapp_MicroPhotoService_captureFinished(
if (result == JNI_FALSE || bitmap == NULL) if (result == JNI_FALSE || bitmap == NULL)
{ {
cv::Mat mat; cv::Mat mat;
((CPhoneDevice *)dev)->OnCaptureReady(photoOrVideo != JNI_FALSE, result != JNI_FALSE, mat, (unsigned long)photoId); ((CPhoneDevice *)dev)->OnCaptureReady(photoOrVideo != JNI_FALSE, result != JNI_FALSE, mat, (uint64_t)photoId);
return; return;
} }
AndroidBitmapInfo info = { 0 }; AndroidBitmapInfo info = { 0 };
@ -785,7 +785,7 @@ Java_com_xypower_mpapp_MicroPhotoService_captureFinished(
cv::cvtColor(mat, mat, cv::COLOR_RGB2BGR); cv::cvtColor(mat, mat, cv::COLOR_RGB2BGR);
((CPhoneDevice *)dev)->OnCaptureReady(photoOrVideo != JNI_FALSE, result != JNI_FALSE, mat, (unsigned long)photoId); ((CPhoneDevice *)dev)->OnCaptureReady(photoOrVideo != JNI_FALSE, result != JNI_FALSE, mat, (uint64_t)photoId);
#endif // 0 #endif // 0
} else } else
{ {
@ -802,7 +802,7 @@ Java_com_xypower_mpapp_MicroPhotoService_captureFinished(
AndroidBitmap_unlockPixels(env, bitmap); AndroidBitmap_unlockPixels(env, bitmap);
((CPhoneDevice *)dev)->OnCaptureReady(photoOrVideo != JNI_FALSE, result != JNI_FALSE, mat, (unsigned long)photoId); ((CPhoneDevice *)dev)->OnCaptureReady(photoOrVideo != JNI_FALSE, result != JNI_FALSE, mat, (uint64_t)photoId);
} }
} }
} }
@ -830,7 +830,7 @@ Java_com_xypower_mpapp_MicroPhotoService_burstCaptureFinished(
if (result == JNI_FALSE) if (result == JNI_FALSE)
{ {
cv::Mat mat; cv::Mat mat;
((CPhoneDevice *)dev)->OnCaptureReady(true, false, mat, (unsigned long)photoId); ((CPhoneDevice *)dev)->OnCaptureReady(true, false, mat, (uint64_t)photoId);
return; return;
} }
@ -863,7 +863,7 @@ Java_com_xypower_mpapp_MicroPhotoService_recordingFinished(
} }
// camera->Open(pathStr, fileNameStr); // camera->Open(pathStr, fileNameStr);
unsigned long photoId = videoId; uint64_t photoId = videoId;
((CPhoneDevice *)dev)->OnVideoReady(photoOrVideo != JNI_FALSE, result != JNI_FALSE, pathStr, photoId); ((CPhoneDevice *)dev)->OnVideoReady(photoOrVideo != JNI_FALSE, result != JNI_FALSE, pathStr, photoId);
if (path != NULL) if (path != NULL)
{ {

@ -552,8 +552,8 @@ CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPa
} }
m_timerUidFeed = time(NULL) * 1000; m_timerUidFeed = time(NULL) * 1000;
m_wakelockIdFeed = (unsigned long)m_timerUidFeed; m_wakelockIdFeed = (uint64_t)m_timerUidFeed;
m_uniqueIdFeed = (unsigned long)m_timerUidFeed; m_uniqueIdFeed = (uint64_t)m_timerUidFeed;
#ifdef USING_NRSEC #ifdef USING_NRSEC
GpioControl::setCam3V3Enable(true); GpioControl::setCam3V3Enable(true);
@ -1321,7 +1321,7 @@ void CPhoneDevice::handleRebootTimer(union sigval v)
// { // {
// } // }
IDevice::timer_uid_t CPhoneDevice::RegisterTimer(unsigned int timerType, unsigned int timeout, void* data, unsigned long times/* = 0*/) IDevice::timer_uid_t CPhoneDevice::RegisterTimer(unsigned int timerType, unsigned int timeout, void* data, uint64_t times/* = 0*/)
{ {
struct sigevent evp = { 0 }; struct sigevent evp = { 0 };
struct itimerspec ts = { 0 }; struct itimerspec ts = { 0 };
@ -1351,7 +1351,7 @@ IDevice::timer_uid_t CPhoneDevice::RegisterTimer(unsigned int timerType, unsigne
return INVALID_TIMER_UID; return INVALID_TIMER_UID;
} }
context->uid = (unsigned long)timer; context->uid = (uint64_t)timer;
ts.it_value.tv_sec = (timeout / 1000); ts.it_value.tv_sec = (timeout / 1000);
ts.it_value.tv_nsec = (timeout % 1000) * 1000; ts.it_value.tv_nsec = (timeout % 1000) * 1000;
if (times != 1) if (times != 1)
@ -1393,9 +1393,9 @@ bool CPhoneDevice::UnregisterTimer(IDevice::timer_uid_t uid)
return false; return false;
} }
unsigned long CPhoneDevice::RequestWakelock(unsigned long timeout) uint64_t CPhoneDevice::RequestWakelock(uint64_t timeout)
{ {
unsigned long wakelockId = m_wakelockIdFeed.fetch_add(1); uint64_t wakelockId = m_wakelockIdFeed.fetch_add(1);
std::string name = WAKELOCK_NAME; std::string name = WAKELOCK_NAME;
name += to_string(wakelockId); name += to_string(wakelockId);
@ -1425,7 +1425,7 @@ unsigned long CPhoneDevice::RequestWakelock(unsigned long timeout)
return wakelockId; return wakelockId;
} }
bool CPhoneDevice::ReleaseWakelock(unsigned long wakelock) bool CPhoneDevice::ReleaseWakelock(uint64_t wakelock)
{ {
// ALOGI("ReleaseWakelock=%lld", wakelock); // ALOGI("ReleaseWakelock=%lld", wakelock);
std::string name = WAKELOCK_NAME; std::string name = WAKELOCK_NAME;
@ -1765,7 +1765,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
} }
else if (mPhotoInfo.mediaType == 0 && (mPhotoInfo.cameraType == CAM_TYPE_SERIAL)) else if (mPhotoInfo.mediaType == 0 && (mPhotoInfo.cameraType == CAM_TYPE_SERIAL))
{ {
unsigned long wid_serial = RequestWakelock(0); uint64_t wid_serial = RequestWakelock(0);
CPhoneDevice* pThis = this; CPhoneDevice* pThis = this;
IDevice::PHOTO_INFO localPhotoInfo = mPhotoInfo; IDevice::PHOTO_INFO localPhotoInfo = mPhotoInfo;
IDevice::SerialsPhotoParam param = { "", 0, 0 }; IDevice::SerialsPhotoParam param = { "", 0, 0 };
@ -1878,7 +1878,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
int orientation = mPhotoInfo.orientation == 0 ? -1 : (mPhotoInfo.orientation - 1) * 90; int orientation = mPhotoInfo.orientation == 0 ? -1 : (mPhotoInfo.orientation - 1) * 90;
jboolean photoOrVideo = mPhotoInfo.mediaType == 0 ? JNI_TRUE : JNI_FALSE; jboolean photoOrVideo = mPhotoInfo.mediaType == 0 ? JNI_TRUE : JNI_FALSE;
env->CallVoidMethod(m_javaService, mStartRecordingMid, photoOrVideo, mPhotoInfo.cameraId, (unsigned long)mPhotoInfo.photoId, env->CallVoidMethod(m_javaService, mStartRecordingMid, photoOrVideo, mPhotoInfo.cameraId, (uint64_t)mPhotoInfo.photoId,
mPhotoInfo.duration, mPhotoInfo.width, mPhotoInfo.height, mPhotoInfo.duration, orientation, mPhotoInfo.duration, mPhotoInfo.width, mPhotoInfo.height, mPhotoInfo.duration, orientation,
leftTopOSD, rightTopOSD, rightBottomOSD, leftBottomOSD); leftTopOSD, rightTopOSD, rightBottomOSD, leftBottomOSD);
@ -1898,7 +1898,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
bool CPhoneDevice::OpenPTZSensors(uint32_t sec) bool CPhoneDevice::OpenPTZSensors(uint32_t sec)
{ {
unsigned long wid = RequestWakelock(0); uint64_t wid = RequestWakelock(0);
unsigned long long time_now = GetMicroTimeStamp(); unsigned long long time_now = GetMicroTimeStamp();
if(time_now < localDelayTime-1000) if(time_now < localDelayTime-1000)
{ {

@ -202,10 +202,10 @@ public:
{ {
CPhoneDevice* device; CPhoneDevice* device;
unsigned int timerType; unsigned int timerType;
unsigned long times; uint64_t times;
void* data; void* data;
unsigned long expectedTimes; uint64_t expectedTimes;
unsigned long uid; uint64_t uid;
}; };
CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPath, unsigned int netId, unsigned int versionCode, const std::string& nativeLibDir); CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPath, unsigned int netId, unsigned int versionCode, const std::string& nativeLibDir);
@ -226,10 +226,10 @@ public:
virtual timer_uid_t RegisterHeartbeat(unsigned int timerType, unsigned int timeout, time_t tsForNextPhoto); virtual timer_uid_t RegisterHeartbeat(unsigned int timerType, unsigned int timeout, time_t tsForNextPhoto);
virtual bool TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<OSD_INFO>& osds, const std::string& path); virtual bool TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<OSD_INFO>& osds, const std::string& path);
virtual bool CloseCamera(); virtual bool CloseCamera();
virtual timer_uid_t RegisterTimer(unsigned int timerType, unsigned int timeout, void* data, unsigned long times = 0); virtual timer_uid_t RegisterTimer(unsigned int timerType, unsigned int timeout, void* data, uint64_t times = 0);
virtual bool UnregisterTimer(timer_uid_t uid); virtual bool UnregisterTimer(timer_uid_t uid);
virtual unsigned long RequestWakelock(unsigned long timeout); virtual uint64_t RequestWakelock(uint64_t timeout);
virtual bool ReleaseWakelock(unsigned long wakelock); virtual bool ReleaseWakelock(uint64_t wakelock);
virtual int GetWData(WEATHER_INFO *weatherInfo); virtual int GetWData(WEATHER_INFO *weatherInfo);
virtual int GetIceData(ICE_INFO *iceInfo, ICE_TAIL *icetail, D_SENSOR_PARAM *sensorParam); virtual int GetIceData(ICE_INFO *iceInfo, ICE_TAIL *icetail, D_SENSOR_PARAM *sensorParam);

Loading…
Cancel
Save