|
|
|
@ -441,6 +441,7 @@ CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPa
|
|
|
|
|
m_cameraStatus = false;
|
|
|
|
|
m_sensorsStatus = false;
|
|
|
|
|
m_lastTime = 0;
|
|
|
|
|
m_shouldStopWaiting = false;
|
|
|
|
|
|
|
|
|
|
RegisterHandlerForSignal(SIGUSR2);
|
|
|
|
|
|
|
|
|
@ -1690,9 +1691,11 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
}
|
|
|
|
|
else if (mPhotoInfo.mediaType == 0 && (mPhotoInfo.cameraType == CAM_TYPE_SERIAL))
|
|
|
|
|
{
|
|
|
|
|
// if (photoInfo.mediaType == 0) {
|
|
|
|
|
// CameraPhotoCmd(time(NULL), channel, MOVE_PRESETNO, 0, type);
|
|
|
|
|
// std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
|
|
|
if (photoInfo.preset != 0 && photoInfo.preset != 0xFF)
|
|
|
|
|
{
|
|
|
|
|
CameraPhotoCmd(time(NULL), photoInfo.channel, MOVE_PRESETNO, 0, photoInfo.preset);
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
|
|
|
}
|
|
|
|
|
time_t ts = time(NULL);
|
|
|
|
|
CameraPhotoCmd(ts, photoInfo.channel, 0, 6, 0);
|
|
|
|
|
TakePTZPhotoCb(3, photoInfo);
|
|
|
|
@ -1783,7 +1786,9 @@ bool CPhoneDevice::OpenPTZSensors(int sec)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> lock(m_cameraLocker);
|
|
|
|
|
if (!m_cameraStatus && !m_sensorsStatus) {
|
|
|
|
|
// std::unique_lock<std::mutex> lock(m_cameraLocker);
|
|
|
|
|
if (!m_cameraStatus && !m_sensorsStatus)
|
|
|
|
|
{
|
|
|
|
|
m_sensorsStatus = true;
|
|
|
|
|
OpenSensors(MAIN_POWER_OPEN);
|
|
|
|
|
OpenSensors(CAMERA_SENSOR_OPEN);
|
|
|
|
@ -1792,25 +1797,55 @@ bool CPhoneDevice::OpenPTZSensors(int sec)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_sensorsStatus && !m_cameraStatus)
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(sec));
|
|
|
|
|
{
|
|
|
|
|
auto start = std::chrono::steady_clock::now();
|
|
|
|
|
while (std::chrono::steady_clock::now() - start < std::chrono::seconds(sec))
|
|
|
|
|
{
|
|
|
|
|
if (m_shouldStopWaiting.load())
|
|
|
|
|
{
|
|
|
|
|
CloseSensors(CAMERA_SENSOR_OPEN);
|
|
|
|
|
CloseSensors(MAIN_POWER_OPEN);
|
|
|
|
|
m_cameraStatus = false;
|
|
|
|
|
m_sensorsStatus = false;
|
|
|
|
|
m_shouldStopWaiting.store(false);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if(m_sensorsStatus && !m_cameraStatus)
|
|
|
|
|
// std::this_thread::sleep_for(std::chrono::seconds(sec));
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> lock(m_cameraLocker);
|
|
|
|
|
if (!m_cameraStatus && m_sensorsStatus) {
|
|
|
|
|
// std::unique_lock<std::mutex> lock(m_cameraLocker);
|
|
|
|
|
if (!m_cameraStatus && m_sensorsStatus)
|
|
|
|
|
{
|
|
|
|
|
m_cameraStatus = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m_cameraStatus;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPhoneDevice::ClosePTZSensors()
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> lock(m_cameraLocker);
|
|
|
|
|
CloseSensors(CAMERA_SENSOR_OPEN);
|
|
|
|
|
CloseSensors(MAIN_POWER_OPEN);
|
|
|
|
|
m_cameraStatus = false;
|
|
|
|
|
m_sensorsStatus = false;
|
|
|
|
|
if(m_sensorsStatus && !m_cameraStatus)
|
|
|
|
|
{
|
|
|
|
|
m_shouldStopWaiting.store(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> lock(m_cameraLocker);
|
|
|
|
|
// std::unique_lock<std::mutex> lock(m_cameraLocker);
|
|
|
|
|
CloseSensors(CAMERA_SENSOR_OPEN);
|
|
|
|
|
CloseSensors(MAIN_POWER_OPEN);
|
|
|
|
|
m_cameraStatus = false;
|
|
|
|
|
m_sensorsStatus = false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|