网络连续拍照不重复自检

rtmpsuck
XI.CHEN 6 months ago
parent 5007405469
commit e4b9245bed

@ -35,6 +35,7 @@ size_t GpioControl::turnOnImpl(const IOT_PARAM& param)
std::vector<ITEM>::iterator it; std::vector<ITEM>::iterator it;
int res = 0; int res = 0;
int fd = -1; int fd = -1;
time_t now = time(NULL);
fd = open(GPIO_NODE_MP, O_RDONLY); fd = open(GPIO_NODE_MP, O_RDONLY);
if( fd > 0 ) if( fd > 0 )
@ -49,13 +50,16 @@ size_t GpioControl::turnOnImpl(const IOT_PARAM& param)
it->references++; it->references++;
// it->closeTime = 0; // it->closeTime = 0;
references = it->references; references = it->references;
if(it->openTime == 0)
it->openTime = now;
SetCamerastatus(it->cmd, true); SetCamerastatus(it->cmd, true);
break; break;
} }
} }
if (it == m_items.end()) if (it == m_items.end())
{ {
ITEM item = {param.cmd, references, 0, 0}; ITEM item = {param.cmd, references, 0, 0, 0};
item.openTime = now;
m_items.push_back(item); m_items.push_back(item);
SetCamerastatus(param.cmd, true); SetCamerastatus(param.cmd, true);
} }
@ -328,7 +332,10 @@ bool GpioControl::SetCamerastatus(int cmd, bool status)
#endif #endif
#ifdef USING_PLZ #ifdef USING_PLZ
if(cmd == CMD_SET_PTZ_PWR_ENABLE) if(cmd == CMD_SET_PTZ_PWR_ENABLE)
{
m_cameraPowerStatus = status; m_cameraPowerStatus = status;
}
#endif #endif
return true; return true;
} }
@ -337,6 +344,28 @@ bool GpioControl::GetCamerastatus()
return m_cameraPowerStatus; return m_cameraPowerStatus;
} }
bool GpioControl::GetSelftestStatus(time_t wait_time)
{
int cmd;
#ifdef USING_N938
cmd = CMD_SET_PIC1_POWER;
#endif
#ifdef USING_PLZ
cmd = CMD_SET_PTZ_PWR_ENABLE;
#endif
time_t now = time(NULL);
std::vector<ITEM>::iterator it;
for (it = m_items.begin(); it != m_items.end(); ++it)
{
if (it->cmd == cmd && (now - it->openTime >= wait_time))
{
return true;
}
}
return false;
}
void GpioControl::PowerControlThreadProc() void GpioControl::PowerControlThreadProc()
{ {
time_t ts = 0; time_t ts = 0;
@ -389,6 +418,7 @@ void GpioControl::PowerControlThreadProc()
// close it directly // close it directly
setInt(it->cmd, 0); setInt(it->cmd, 0);
it->closeTime = 0; it->closeTime = 0;
it->openTime = 0;
#ifdef _DEBUG #ifdef _DEBUG
ALOGI("PWR THREAD DO TurnOff cmd=%d", it->cmd); ALOGI("PWR THREAD DO TurnOff cmd=%d", it->cmd);
#endif #endif

@ -154,6 +154,7 @@ public:
size_t references; size_t references;
size_t closeCmds; size_t closeCmds;
time_t closeTime; time_t closeTime;
time_t openTime;
}; };
private: private:
@ -179,6 +180,7 @@ public:
static size_t TurnOffImmediately(int cmd); static size_t TurnOffImmediately(int cmd);
static bool SetCamerastatus(int cmd, bool status); static bool SetCamerastatus(int cmd, bool status);
static bool GetCamerastatus(); static bool GetCamerastatus();
static bool GetSelftestStatus(time_t wait_time);
static void PowerControlThreadProc(); static void PowerControlThreadProc();

@ -1491,8 +1491,11 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
// AutoEnv autoEnv(pThis->m_vm); // AutoEnv autoEnv(pThis->m_vm);
time_t ts = time(NULL); time_t ts = time(NULL);
uint32_t waitTime = localPhotoInfo.selfTestingTime; uint32_t waitTime = localPhotoInfo.selfTestingTime;
waitTime = (waitTime!= 0) ? (waitTime * 1024) : 10240; if(!GpioControl::GetSelftestStatus(waitTime))
std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); {
waitTime = (waitTime != 0) ? (waitTime * 1024) : 10240;
std::this_thread::sleep_for(std::chrono::milliseconds(waitTime));
}
SetStaticIp(); SetStaticIp();
std::this_thread::sleep_for(std::chrono::milliseconds(256)); std::this_thread::sleep_for(std::chrono::milliseconds(256));

Loading…
Cancel
Save