From 99ee66139bd95d6fd31c7c9752af27f0d4254c65 Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 18 Dec 2024 14:48:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=87=87=E6=A0=B7=E5=91=A8?= =?UTF-8?q?=E6=9C=9F=E8=AE=BE=E7=BD=AE=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/MicroPhoto.cpp | 36 ++++++++++++++++---------------- app/src/main/cpp/PhoneDevice.cpp | 20 +++++++++--------- app/src/main/cpp/PhoneDevice.h | 12 +++++------ 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/app/src/main/cpp/MicroPhoto.cpp b/app/src/main/cpp/MicroPhoto.cpp index 2d0e18d9..5f290e1e 100644 --- a/app/src/main/cpp/MicroPhoto.cpp +++ b/app/src/main/cpp/MicroPhoto.cpp @@ -154,9 +154,9 @@ void posix_signal_handler(int sig, siginfo_t *siginfo, void *context) class Runner { 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); } @@ -369,17 +369,17 @@ Java_com_xypower_mpapp_MicroPhotoService_notifyToTakePhoto( } 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(); 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 { uint32_t packetType = channel; packetType &= 0xFF; - pTerminal->RequestSampling(packetType, (unsigned long)scheduleTime, 0); + pTerminal->RequestSampling(packetType, (uint64_t)scheduleTime, 0); } return JNI_TRUE; @@ -568,7 +568,7 @@ Java_com_xypower_mpapp_MicroPhotoService_getPhotoTimeData2( vector dataArray; dataArray.reserve(numberOfData); - unsigned long val = 0; + uint64_t val = 0; jint channel = 0; for (map>::const_iterator it = photoTime.cbegin(); it != photoTime.cend(); ++it) { @@ -585,11 +585,11 @@ Java_com_xypower_mpapp_MicroPhotoService_getPhotoTimeData2( for (vector::const_iterator it2 = it->second.cbegin(); it2 != it->second.cend(); ++it2) { // time - val = ((unsigned long)((*it2) & 0xFFFFFF00)) << 24; + val = ((uint64_t)((*it2) & 0xFFFFFF00)) << 24; // channel - val |= ((unsigned long)channel) << 16; + val |= ((uint64_t)channel) << 16; // preset - val |= ((unsigned long)((*it2) & 0xFF)) << 8; + val |= ((uint64_t)((*it2) & 0xFF)) << 8; dataArray.push_back((jlong)val); } @@ -639,14 +639,14 @@ Java_com_xypower_mpapp_MicroPhotoService_getPhotoTimeData( dataArray.push_back((jlong)scheduleTime); dataArray.push_back((jlong)channelsAndPresets.size()); - unsigned long val = 0; + uint64_t val = 0; for (std::vector >::const_iterator it = channelsAndPresets.cbegin(); it != channelsAndPresets.cend(); ++it) { - val = (unsigned long)scheduleTime << 28; + val = (((uint64_t)scheduleTime) << 28); // channel - val |= ((unsigned long)(it->first)) << 12; + val |= (((uint64_t)(it->first)) << 12); // preset - val |= ((unsigned long)(it->second)) << 4; + val |= (((uint64_t)(it->second)) << 4); dataArray.push_back((jlong)val); } @@ -761,7 +761,7 @@ Java_com_xypower_mpapp_MicroPhotoService_captureFinished( if (result == JNI_FALSE || bitmap == NULL) { 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; } AndroidBitmapInfo info = { 0 }; @@ -785,7 +785,7 @@ Java_com_xypower_mpapp_MicroPhotoService_captureFinished( 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 } else { @@ -802,7 +802,7 @@ Java_com_xypower_mpapp_MicroPhotoService_captureFinished( 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) { cv::Mat mat; - ((CPhoneDevice *)dev)->OnCaptureReady(true, false, mat, (unsigned long)photoId); + ((CPhoneDevice *)dev)->OnCaptureReady(true, false, mat, (uint64_t)photoId); return; } @@ -863,7 +863,7 @@ Java_com_xypower_mpapp_MicroPhotoService_recordingFinished( } // camera->Open(pathStr, fileNameStr); - unsigned long photoId = videoId; + uint64_t photoId = videoId; ((CPhoneDevice *)dev)->OnVideoReady(photoOrVideo != JNI_FALSE, result != JNI_FALSE, pathStr, photoId); if (path != NULL) { diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 3151b6b8..ec9c468e 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -552,8 +552,8 @@ CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPa } m_timerUidFeed = time(NULL) * 1000; - m_wakelockIdFeed = (unsigned long)m_timerUidFeed; - m_uniqueIdFeed = (unsigned long)m_timerUidFeed; + m_wakelockIdFeed = (uint64_t)m_timerUidFeed; + m_uniqueIdFeed = (uint64_t)m_timerUidFeed; #ifdef USING_NRSEC 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 itimerspec ts = { 0 }; @@ -1351,7 +1351,7 @@ IDevice::timer_uid_t CPhoneDevice::RegisterTimer(unsigned int timerType, unsigne 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_nsec = (timeout % 1000) * 1000; if (times != 1) @@ -1393,9 +1393,9 @@ bool CPhoneDevice::UnregisterTimer(IDevice::timer_uid_t uid) 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; name += to_string(wakelockId); @@ -1425,7 +1425,7 @@ unsigned long CPhoneDevice::RequestWakelock(unsigned long timeout) return wakelockId; } -bool CPhoneDevice::ReleaseWakelock(unsigned long wakelock) +bool CPhoneDevice::ReleaseWakelock(uint64_t wakelock) { // ALOGI("ReleaseWakelock=%lld", wakelock); 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)) { - unsigned long wid_serial = RequestWakelock(0); + uint64_t wid_serial = RequestWakelock(0); CPhoneDevice* pThis = this; IDevice::PHOTO_INFO localPhotoInfo = mPhotoInfo; 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; 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, leftTopOSD, rightTopOSD, rightBottomOSD, leftBottomOSD); @@ -1898,7 +1898,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< bool CPhoneDevice::OpenPTZSensors(uint32_t sec) { - unsigned long wid = RequestWakelock(0); + uint64_t wid = RequestWakelock(0); unsigned long long time_now = GetMicroTimeStamp(); if(time_now < localDelayTime-1000) { diff --git a/app/src/main/cpp/PhoneDevice.h b/app/src/main/cpp/PhoneDevice.h index ee444c0d..2c3aa177 100644 --- a/app/src/main/cpp/PhoneDevice.h +++ b/app/src/main/cpp/PhoneDevice.h @@ -202,10 +202,10 @@ public: { CPhoneDevice* device; unsigned int timerType; - unsigned long times; + uint64_t times; void* data; - unsigned long expectedTimes; - unsigned long uid; + uint64_t expectedTimes; + uint64_t uid; }; 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 bool TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector& osds, const std::string& path); 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 unsigned long RequestWakelock(unsigned long timeout); - virtual bool ReleaseWakelock(unsigned long wakelock); + virtual uint64_t RequestWakelock(uint64_t timeout); + virtual bool ReleaseWakelock(uint64_t wakelock); virtual int GetWData(WEATHER_INFO *weatherInfo); virtual int GetIceData(ICE_INFO *iceInfo, ICE_TAIL *icetail, D_SENSOR_PARAM *sensorParam);