diff --git a/lib/App/common/deviceNodeCamera.cpp b/lib/App/common/deviceNodeCamera.cpp index d25e3a60..f1b31092 100644 --- a/lib/App/common/deviceNodeCamera.cpp +++ b/lib/App/common/deviceNodeCamera.cpp @@ -45,6 +45,7 @@ deviceNodeCamera::deviceNodeCamera(uint32_t NodeID) : // m_pLog = basicLogCollection::getInstance(); m_pBEH = basicEventHeap::getInstance(); m_bSkeepPositioningWait = true; + m_bNoMoveDoneReport = false; m_bNoAbsPositionning = false; m_bCameraOnHomePosition = false; m_tTimeTSeconds = 0; @@ -77,6 +78,7 @@ deviceNodeCamera::deviceNodeCamera(DBC_NODE_DATA * Data) : // m_pLog = basicLogCollection::getInstance(); m_pBEH = basicEventHeap::getInstance(); m_bSkeepPositioningWait = true; + m_bNoMoveDoneReport = false; m_bNoAbsPositionning = false; m_bCameraOnHomePosition = false; m_tTimeTSeconds = 0; @@ -578,6 +580,7 @@ bool deviceNodeCamera::create() load_presets(); mojoKernel * tKRNL = mojoKernel::getInstance(); + m_bNoMoveDoneReport = false; if (tKRNL) { m_bSkeepPositioningWait = ((tKRNL->getMediaMode() & EVE_OUTPUT_VIDEO) == EVE_OUTPUT_VIDEO); @@ -1342,6 +1345,7 @@ void deviceNodeCamera::m_fThreadProc(void) load_presets(); mojoKernel * tKRNL = mojoKernel::getInstance(); + m_bNoMoveDoneReport = false; if (tKRNL) { m_bSkeepPositioningWait = ((tKRNL->getMediaMode() & EVE_OUTPUT_VIDEO) == EVE_OUTPUT_VIDEO); @@ -1740,45 +1744,9 @@ void deviceNodeCamera::m_fThreadProc(void) } else { - // Waiting Movement finish - if (m_bSkeepPositioningWait) - { -#ifdef DEBUG_EXTRA - LOG("INSTANT BCAST CAM ONPOS"); -#endif - // Send Capture event -#ifndef NO_CAMERA_FUSION_ENGINE - DBC_SNAPSHOT_DATA * tData = fusion_translate_ROI(m_pCurrentROI); -#else - DBC_SNAPSHOT_DATA * tData = NULL; -#endif - if (tData != NULL) - { - if (m_pBEH) - { - EVENT_CONTAINER * tEVT = createBasicEvent(m_sNodeData.node_id, EVT_CLASS_CAMERA_CTRL, EVT_CAMERA_ON_POSITION, NULL, NULL, tData); - if (tEVT) - { - m_pBEH->broadcast(tEVT); - } - else - { - //free(tData); - delete(tData); - }; - } - else - { - //free(tData); - delete(tData); - }; - }; - setWM(CAM_WS_READY); - } - else - { - setWM(CAM_WS_WAIT_ONPOS); - }; + // EVT_CAMERA_ON_POSITION is sent from CAM_WS_WAIT_ONPOS once the move is done + // (before, with video output it was sent right after the command). + setWM(CAM_WS_WAIT_ONPOS); }; }; } @@ -1806,16 +1774,19 @@ void deviceNodeCamera::m_fThreadProc(void) #ifdef DEBUG_EXTRA LOG("Start Waiting Cam On Position!"); #endif - if (! m_bSkeepPositioningWait) + // Target-driven ABS / preset move: EVT_CAMERA_ON_POSITION only after the move is done. + // Protocols that cannot report the end of a move get a fixed wait. + if (! m_bNoMoveDoneReport) { if (! m_pProtocol->waitMoveIsDone()) { - m_bSkeepPositioningWait = true; + LOG("Protocol cannot report the end of a move -> fixed wait"); + m_bNoMoveDoneReport = true; } }; - if (m_bSkeepPositioningWait) + if (m_bNoMoveDoneReport) { - SLEEP(3000); + SLEEP(CAM_MOVE_FIXED_WAIT_MS); } #ifdef DEBUG_EXTRA LOG("Done Waiting Cam On Position!"); diff --git a/lib/App/common/deviceNodeCamera.h b/lib/App/common/deviceNodeCamera.h index a44ad84c..f5277735 100644 --- a/lib/App/common/deviceNodeCamera.h +++ b/lib/App/common/deviceNodeCamera.h @@ -42,6 +42,9 @@ #define CAM_CTRL_PROTO_T28181 5 #define CAM_CTRL_PROTO_BRCP 6 +// Wait before EVT_CAMERA_ON_POSITION when the protocol cannot report the end of a move +#define CAM_MOVE_FIXED_WAIT_MS 3000 + #define UART_TYPE_HARDWARE 1 #define UART_TYPE_SOL 2 @@ -186,6 +189,7 @@ class deviceNodeCamera : public deviceNode, public basicThread float m_fCP_Zoom; bool m_bSkeepPositioningWait; + bool m_bNoMoveDoneReport; // protocol cannot report the end of a move -> fixed wait before EVT_CAMERA_ON_POSITION bool m_bNoAbsPositionning; bool m_bCameraIsStatic; // IR functionality diff --git a/lib/data/protocol/protocolPTZ_ONVIF.cpp b/lib/data/protocol/protocolPTZ_ONVIF.cpp index fc1a2329..8f015402 100644 --- a/lib/data/protocol/protocolPTZ_ONVIF.cpp +++ b/lib/data/protocol/protocolPTZ_ONVIF.cpp @@ -640,6 +640,8 @@ bool protocolPTZ_ONVIF::goPreset(char * PresetToken) LOG_ERROR("No PTZ Profile!!"); return false; }; + // A preset move has no known target: waitMoveIsDone() must not compare with an old AbsoluteMove target + m_bTargetValid = false; if (! m_pOnVif->ptz_GotoPreset(m_pProfile->profiletoken, PresetToken, 1.0f, 1.0f, 1.0f)) { m_bStatus = 0;