Browse Source

la_mojo pOnvif: ONVIF compliance fixes (report points 1-6)

1. Faults are no longer reported as success: every request waits for the
   answer, checks the HTTP status and the SOAP Fault (logged with
   Code/Subcode/Reason); getLastError()/getLastFault() tell the caller.
   protocolPTZ_ONVIF clears m_bStatus (-> reconnect) only on
   communication errors, not on a Fault from a reachable camera.
   AbsoluteMove now waits for its answer too.
2. Request/reply race: already fixed in #11 (checked).
3. NULL-safe parsing of optional elements (safeCopy/safeAtoi/safeAtof),
   videoSource zero-filled, Imaging values parsed as float, IrCutFilter
   AUTO no longer read as OFF, missing XAddr no longer becomes "(null)",
   GetSystemDateAndTime without UTCDateTime no longer breaks the token
   time (falls back to the local clock).
4. GetProfiles parses PTZConfiguration; the PTZ profile is the first one
   that has it (fallback to profile 0 with an error log); create() fails
   cleanly when the device has no profiles instead of throwing.
5. Pan/tilt and zoom in one ContinuousMove with Timeout PT10S
   (PONVIF_CONTINUOUS_MOVE_TIMEOUT_S); Stop honours its pantilt/zoom flags.
6. WS-Security: 16-byte RAND_bytes nonce, no fixed-size digest buffer,
   header only when a user name is set (anonymous devices), user name and
   all string arguments XML-escaped. Requests are built by _buildRequest()
   from body templates. HTTP auth mode 0 now uses CURLAUTH_ANY (sends no
   password until the device asks; Digest preferred) instead of Basic;
   no HTTP auth without credentials.

Also: Content-Type without the trailing ';', GetServices/
GetDeviceInformation sent to the device service, printf format-string
bugs on device replies fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
pull/13/head
Claude 8 hours ago
parent
commit
3d4a1f243d
Failed to extract signature
  1. 816
      lib/data/ponvif/ponvif.cpp
  2. 129
      lib/data/ponvif/ponvif.h
  3. 69
      lib/data/protocol/protocolPTZ_ONVIF.cpp
  4. 1
      lib/data/protocol/protocolPTZ_ONVIF.h

816
lib/data/ponvif/ponvif.cpp
File diff suppressed because it is too large
View File

129
lib/data/ponvif/ponvif.h

@ -34,49 +34,59 @@
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:w=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:d=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\" xmlns:dn=\"http://www.onvif.org/ver10/network/wsdl\"><s:Header><w:MessageID>uuid:84ede3de-7dec-11d0-c360-f01234567890</w:MessageID><w:To e:mustUnderstand=\"true\">urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To><w:Action a:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</w:Action></s:Header><s:Body><d:Probe><d:Types>dn:NetworkVideoTransmitter</d:Types></d:Probe></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_SYS_DTS \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetSystemDateAndTime xmlns=\"http://www.onvif.org/ver10/device/wsdl\"/></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_CAPABILITIES \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetCapabilities xmlns=\"http://www.onvif.org/ver10/device/wsdl\"><Category>All</Category></GetCapabilities></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_VIDEO_SOURCES \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetVideoSources xmlns=\"http://www.onvif.org/ver10/media/wsdl\"/></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_PROFILES \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetProfiles xmlns=\"http://www.onvif.org/ver10/media/wsdl\"/></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_SERVICES \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetServices xmlns=\"http://www.onvif.org/ver10/device/wsdl\"><IncludeCapability>false</IncludeCapability></GetServices></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_DEV_INFO \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetDeviceInformation xmlns=\"http://www.onvif.org/ver10/device/wsdl\"/></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_STREAM_URI \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetStreamUri xmlns=\"http://www.onvif.org/ver10/media/wsdl\"><StreamSetup><Stream xmlns=\"http://www.onvif.org/ver10/schema\">%s</Stream><Transport xmlns=\"http://www.onvif.org/ver10/schema\"><Protocol>%s</Protocol></Transport></StreamSetup><ProfileToken>%s</ProfileToken></GetStreamUri></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_PICTURE_URI \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetSnapshotUri xmlns=\"http://www.onvif.org/ver10/media/wsdl\"><ProfileToken>%s</ProfileToken></GetSnapshotUri></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_PRESETS \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetPresets xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken></GetPresets></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_PTZ_NODE \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetNode xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><NodeToken>%s</NodeToken></GetNode></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_PTZ_STATUS \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetStatus xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken></GetStatus></s:Body></s:Envelope>"
#define PONVIF_PACK_PTZ_GET_SERVICE_CAPS \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GetServiceCapabilities xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"/></s:Body></s:Envelope>"
#define PONVIF_PACK_GOTO_PRESET \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><GotoPreset xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><PresetToken>%s</PresetToken><Speed><PanTilt x=\"%0.3f\" y=\"%0.3f\" xmlns=\"http://www.onvif.org/ver10/schema\"/><Zoom x=\"%0.3f\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Speed></GotoPreset></s:Body></s:Envelope>"
#define PONVIF_PACK_REMOVE_PRESET \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><RemovePreset xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><PresetToken>%s</PresetToken></RemovePreset></s:Body></s:Envelope>"
#define PONVIF_PACK_SET_PRESET \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><SetPreset xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><PresetName>%s</PresetName></SetPreset></s:Body></s:Envelope>"
#define PONVIF_PACK_RELATIVE_MOVE \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><RelativeMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Translation><PanTilt x=\"%0.2f\" y=\"%0.2f\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Translation><Speed><PanTilt x=\"%0.2f\" y=\"%0.2f\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Speed></RelativeMove></s:Body></s:Envelope>"
#define PONVIF_PACK_RELATIVE_ZOOM \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><RelativeMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Translation><Zoom x=\"%0.2f\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Translation><Speed><Zoom x=\"%0.2f\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Speed></RelativeMove></s:Body></s:Envelope>"
#define PONVIF_PACK_ABSOLUTE_MOVE \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><AbsoluteMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Position><PanTilt x=\"%0.6f\" y=\"%0.6f\" xmlns=\"http://www.onvif.org/ver10/schema\"/><Zoom x=\"%0.6f\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Position><Speed><PanTilt x=\"1\" y=\"1\" xmlns=\"http://www.onvif.org/ver10/schema\"/><Zoom x=\"1\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Speed></AbsoluteMove></s:Body></s:Envelope>"
#define PONVIF_PACK_CONTINUOUS_MOVE \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><ContinuousMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Velocity><PanTilt x=\"%0.2f\" y=\"%0.2f\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Velocity></ContinuousMove></s:Body></s:Envelope>"
// #define PONVIF_PACK_CONTINUOUS_MOVE_A (CSTR)"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tptz=\"http://www.onvif.org/ver20/ptz/wsdl\"
// xmlns:tt=\"http://www.onvif.org/ver10/schema\"><soap:Body><tptz:ContinuousMove><tptz:ProfileToken>Profile_1</tptz:ProfileToken><tptz:Velocity><tt:PanTilt x=\"1\" y=\"1\"/><tt:Zoom
// x=\"1\"/></tptz:Velocity></tptz:ContinuousMove></soap:Body></soap:Envelope>"
#define PONVIF_PACK_CONTINUOUS_ZOOM \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><ContinuousMove xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><Velocity><Zoom x=\"%0.2f\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Velocity></ContinuousMove></s:Body></s:Envelope>"
#define PONVIF_PACK_PTZ_STOP \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Security s:mustUnderstand=\"1\" xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><UsernameToken><Username>%s</Username><Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest\">%s</Password><Nonce EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">%s</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">%s</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Stop xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\"><ProfileToken>%s</ProfileToken><PanTilt>true</PanTilt><Zoom>true</Zoom></Stop></s:Body></s:Envelope>"
/*
Request bodies (the SOAP envelope and the optional WS-Security header are added by pOnvif::_buildRequest).
String arguments must be XML-escaped by the caller (pOnvif::_xmlEscape).
*/
#define PONVIF_NS_DEVICE "http://www.onvif.org/ver10/device/wsdl"
#define PONVIF_NS_MEDIA "http://www.onvif.org/ver10/media/wsdl"
#define PONVIF_NS_PTZ "http://www.onvif.org/ver20/ptz/wsdl"
#define PONVIF_NS_SCHEMA "http://www.onvif.org/ver10/schema"
#define PONVIF_BODY_GET_CAPABILITIES "<GetCapabilities xmlns=\"" PONVIF_NS_DEVICE "\"><Category>All</Category></GetCapabilities>"
#define PONVIF_BODY_GET_SERVICES "<GetServices xmlns=\"" PONVIF_NS_DEVICE "\"><IncludeCapability>false</IncludeCapability></GetServices>"
#define PONVIF_BODY_GET_DEV_INFO "<GetDeviceInformation xmlns=\"" PONVIF_NS_DEVICE "\"/>"
#define PONVIF_BODY_GET_VIDEO_SOURCES "<GetVideoSources xmlns=\"" PONVIF_NS_MEDIA "\"/>"
#define PONVIF_BODY_GET_PROFILES "<GetProfiles xmlns=\"" PONVIF_NS_MEDIA "\"/>"
#define PONVIF_BODY_GET_STREAM_URI \
"<GetStreamUri xmlns=\"" PONVIF_NS_MEDIA "\"><StreamSetup><Stream xmlns=\"" PONVIF_NS_SCHEMA "\">%s</Stream><Transport xmlns=\"" PONVIF_NS_SCHEMA \
"\"><Protocol>%s</Protocol></Transport></StreamSetup><ProfileToken>%s</ProfileToken></GetStreamUri>"
#define PONVIF_BODY_GET_SNAPSHOT_URI "<GetSnapshotUri xmlns=\"" PONVIF_NS_MEDIA "\"><ProfileToken>%s</ProfileToken></GetSnapshotUri>"
#define PONVIF_BODY_PTZ_GET_SERVICE_CAPS "<GetServiceCapabilities xmlns=\"" PONVIF_NS_PTZ "\"/>"
#define PONVIF_BODY_GET_PRESETS "<GetPresets xmlns=\"" PONVIF_NS_PTZ "\"><ProfileToken>%s</ProfileToken></GetPresets>"
#define PONVIF_BODY_GET_PTZ_NODE "<GetNode xmlns=\"" PONVIF_NS_PTZ "\"><NodeToken>%s</NodeToken></GetNode>"
#define PONVIF_BODY_GET_PTZ_STATUS "<GetStatus xmlns=\"" PONVIF_NS_PTZ "\"><ProfileToken>%s</ProfileToken></GetStatus>"
#define PONVIF_BODY_GOTO_PRESET \
"<GotoPreset xmlns=\"" PONVIF_NS_PTZ "\"><ProfileToken>%s</ProfileToken><PresetToken>%s</PresetToken><Speed><PanTilt x=\"%0.3f\" y=\"%0.3f\" xmlns=\"" PONVIF_NS_SCHEMA \
"\"/><Zoom x=\"%0.3f\" xmlns=\"" PONVIF_NS_SCHEMA "\"/></Speed></GotoPreset>"
#define PONVIF_BODY_REMOVE_PRESET "<RemovePreset xmlns=\"" PONVIF_NS_PTZ "\"><ProfileToken>%s</ProfileToken><PresetToken>%s</PresetToken></RemovePreset>"
#define PONVIF_BODY_SET_PRESET "<SetPreset xmlns=\"" PONVIF_NS_PTZ "\"><ProfileToken>%s</ProfileToken><PresetName>%s</PresetName></SetPreset>"
#define PONVIF_BODY_RELATIVE_MOVE \
"<RelativeMove xmlns=\"" PONVIF_NS_PTZ "\"><ProfileToken>%s</ProfileToken><Translation><PanTilt x=\"%0.4f\" y=\"%0.4f\" " \
"space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace\" xmlns=\"" PONVIF_NS_SCHEMA "\"/></Translation><Speed><PanTilt " \
"x=\"%0.3f\" y=\"%0.3f\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace\" xmlns=\"" PONVIF_NS_SCHEMA \
"\"/></Speed></RelativeMove>"
#define PONVIF_BODY_RELATIVE_ZOOM \
"<RelativeMove xmlns=\"" PONVIF_NS_PTZ "\"><ProfileToken>%s</ProfileToken><Translation><Zoom x=\"%0.4f\" xmlns=\"" PONVIF_NS_SCHEMA \
"\"/></Translation><Speed><Zoom x=\"%0.3f\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace\" xmlns=\"" PONVIF_NS_SCHEMA "\"/></Speed></RelativeMove>"
#define PONVIF_BODY_ABSOLUTE_MOVE \
"<AbsoluteMove xmlns=\"" PONVIF_NS_PTZ "\"><ProfileToken>%s</ProfileToken><Position><PanTilt x=\"%0.6f\" y=\"%0.6f\" xmlns=\"" PONVIF_NS_SCHEMA \
"\"/><Zoom x=\"%0.6f\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace\" xmlns=\"" PONVIF_NS_SCHEMA \
"\"/></Position><Speed><PanTilt x=\"1\" y=\"1\" xmlns=\"" PONVIF_NS_SCHEMA "\"/><Zoom x=\"1\" xmlns=\"" PONVIF_NS_SCHEMA "\"/></Speed></AbsoluteMove>"
// ContinuousMove is assembled from these parts (pan/tilt and zoom in one request)
#define PONVIF_BODY_CONTINUOUS_MOVE_BEGIN "<ContinuousMove xmlns=\"" PONVIF_NS_PTZ "\"><ProfileToken>%s</ProfileToken><Velocity>"
#define PONVIF_BODY_CONTINUOUS_MOVE_PT \
"<PanTilt x=\"%0.3f\" y=\"%0.3f\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace\" xmlns=\"" \
PONVIF_NS_SCHEMA "\"/>"
#define PONVIF_BODY_CONTINUOUS_MOVE_ZOOM \
"<Zoom x=\"%0.3f\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace\" xmlns=\"" PONVIF_NS_SCHEMA "\"/>"
#define PONVIF_BODY_CONTINUOUS_MOVE_END "</Velocity><Timeout>PT%dS</Timeout></ContinuousMove>"
#define PONVIF_BODY_PTZ_STOP "<Stop xmlns=\"" PONVIF_NS_PTZ "\"><ProfileToken>%s</ProfileToken><PanTilt>%s</PanTilt><Zoom>%s</Zoom></Stop>"
// Default ContinuousMove timeout: the camera stops by itself if the Stop request is lost
#define PONVIF_CONTINUOUS_MOVE_TIMEOUT_S 10
// WS-Security nonce length (bytes before Base64)
#define PONVIF_NONCE_LEN 16
#define PONVIF_ENVELOPE_EXT \
(CSTR)"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><e:Envelope xmlns:e=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:w=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:d=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\" xmlns:dn=\"http://www.onvif.org/ver10/network/wsdl\">%s%s</e:Envelope>"
@ -100,8 +110,20 @@ typedef struct S_videoSourceProfile
int height;
int fps;
int bitrate;
bool ptz; // profile has a PTZConfiguration (PTZ commands need such a profile)
char ptznodetoken[CTEXT]; // PTZConfiguration/NodeToken
} videoSourceProfile;
// Result of the last request (pOnvif::getLastError)
typedef enum E_onvifError
{
PONVIF_OK = 0,
PONVIF_ERR_COMM, // no answer: connection error, timeout, request could not be queued
PONVIF_ERR_HTTP, // HTTP status other than 200 without a SOAP Fault (e.g. 401 HTML page)
PONVIF_ERR_FAULT, // the device answered with a SOAP Fault (see getLastFault)
PONVIF_ERR_PARSE // reply is not the expected XML
} onvifError;
typedef struct S_onvifVideoResolution
{
int Width;
@ -516,6 +538,9 @@ class pOnvif
void * volatile m_pPendingRequest; // reply that _send_request is waiting for
basicMutex m_mParserLock; // parser() vs. _send_request bookkeeping
uint8_t m_bAuthMode;
volatile long m_nLastHttpCode; // HTTP status of the last reply (set by parser())
onvifError m_eLastError;
char m_cLastFault[CTEXT];
#ifndef CURL_MANAGER
static int _writer(char * data, size_t size, size_t nmemb, pOnvif * Ptr);
#endif
@ -558,6 +583,10 @@ class pOnvif
bool setDiscoveryMcastPort(int discoverymcastport);
bool setDiscoveryHideDuplicates(bool discoveryhideduplicates);
CSTR getSnapshotUri(void);
onvifError getLastError(void);
CSTR getLastFault(void);
// First profile that has a PTZConfiguration, NULL if none
videoSourceProfile * getPTZProfile(void);
discoveryResults discover(void);
bool create(void);
@ -586,10 +615,18 @@ class pOnvif
bool ptz_AbsoluteMove(CSTR profileToken, float position_pantilt_x, float position_pantilt_y, float zoom);
bool ptz_ContinuousMove(CSTR profileToken, float velocity_pantilt_x, float velocity_pantilt_y);
bool ptz_ContinuousMoveZoom(CSTR profileToken, float zoom);
// One ContinuousMove for pan/tilt and zoom; axes with has* == false are left out of the request
bool ptz_ContinuousMoveAll(CSTR profileToken, bool hasPanTilt, float velocity_pantilt_x, float velocity_pantilt_y, bool hasZoom, float velocity_zoom,
int timeoutSec = PONVIF_CONTINUOUS_MOVE_TIMEOUT_S);
bool ptz_Stop(CSTR profileToken, bool pantilt, bool zoom);
/*
Internal functions
*/
public:
// XML-escape src into dst (&, <, >, ", '); always NUL-terminates
static char * _xmlEscape(const char * src, char * dst, size_t dstSize);
private:
accessToken _makeToken(void);
@ -597,7 +634,11 @@ class pOnvif
void _getActiveSources(videoSourceProfiles & videoSources, videoSourceProfiles profiles);
void _getProfileData(videoSourceProfiles & videoSources, videoSourceProfiles profiles);
// protected function _xml2array($response);
accessToken _passwordDigest(CSTR username, CSTR password, time_t timestamp = 0, uint32_t nonce = 0);
accessToken _passwordDigest(CSTR username, CSTR password, time_t timestamp = 0);
bool _hasCredentials(void);
// Envelope + (WS-Security header if credentials are set) + body built from bodyFmt
bool _buildRequest(char * out, size_t outSize, const char * bodyFmt, ...) __attribute__((format(printf, 4, 5)));
bool _checkReply(void);
bool _send_request(CSTR url, CSTR post_string, bool mr = true);
bool _post_request(CSTR url, CSTR post_string);
};

69
lib/data/protocol/protocolPTZ_ONVIF.cpp

@ -203,7 +203,19 @@ bool protocolPTZ_ONVIF::create(void)
LOG("PROTOCREATE");
if (m_pOnVif->create())
{
m_pProfile = m_pOnVif->getProfiles()->at(0);
// PTZ commands need a profile with a PTZConfiguration
m_pProfile = m_pOnVif->getPTZProfile();
if (m_pProfile == NULL)
{
// Non-conformant devices sometimes accept PTZ on a profile without PTZConfiguration: keep the old behaviour
m_pProfile = m_pOnVif->getProfiles()->at(0);
LOG_ERROR("No media profile with a PTZConfiguration, using the first profile");
}
{
char tB[CTEXT * 2];
snprintf(tB, sizeof(tB), "PTZ profile: %s (%s)", m_pProfile->profiletoken, m_pProfile->profilename);
LOG(tB);
}
detectStatusSupport();
LOG("DONE");
m_bStatus = 1;
@ -315,26 +327,12 @@ bool protocolPTZ_ONVIF::move(uint32_t MoveMatrix)
{
Speed_z = -m_dZoomSpeed;
};
bool res = true;
if ((MoveMatrix & (PTZ_DRIVE_PAN_MASK | PTZ_DRIVE_TILT_MASK)) != 0)
{
res = m_pOnVif->ptz_ContinuousMove(m_pProfile->profiletoken, Speed_x, Speed_y);
};
if (res)
{
if ((MoveMatrix & PTZ_DRIVE_ZOOM_MASK) != 0)
{
res = m_pOnVif->ptz_ContinuousMoveZoom(m_pProfile->profiletoken, Speed_z);
};
};
m_bStatus = (res) ? 1 : 0;
// One request for all axes (two separate ContinuousMoves may stop each other)
bool hasPT = ((MoveMatrix & (PTZ_DRIVE_PAN_MASK | PTZ_DRIVE_TILT_MASK)) != 0);
bool hasZ = ((MoveMatrix & PTZ_DRIVE_ZOOM_MASK) != 0);
return commandResult(m_pOnVif->ptz_ContinuousMoveAll(m_pProfile->profiletoken, hasPT, Speed_x, Speed_y, hasZ, Speed_z));
}
else
{
m_bStatus = (m_pOnVif->ptz_Stop(m_pProfile->profiletoken, true, true)) ? 1 : 0;
};
return (m_bStatus > 0);
return commandResult(m_pOnVif->ptz_Stop(m_pProfile->profiletoken, true, true));
#else
if (m_bStatus == 0)
{
@ -398,6 +396,25 @@ bool protocolPTZ_ONVIF::move(uint32_t MoveMatrix)
#include <time.h>
#ifdef USE_PONVIF
/*
Maps a pOnvif command result to the connection status: only a communication error means the camera is
lost (m_bStatus = 0 -> validate() fails -> reconnect). A SOAP Fault / HTTP error is an answer from a
reachable camera: the command failed, the connection is fine.
*/
bool protocolPTZ_ONVIF::commandResult(bool ok)
{
if (ok)
{
m_bStatus = 1;
return true;
}
if (m_pOnVif == NULL || m_pOnVif->getLastError() == PONVIF_ERR_COMM)
{
m_bStatus = 0;
}
return false;
}
static long ptzOnvifNowMs(void)
{
struct timespec tTS;
@ -587,9 +604,9 @@ bool protocolPTZ_ONVIF::goAbsolute(float dPan, float dTilt, float dZoom)
m_fTargetTilt = dTilt;
m_fTargetZoom = dZoom;
m_bTargetValid = true;
if (m_pOnVif->ptz_AbsoluteMove(m_pProfile->profiletoken, dPan, dTilt, dZoom))
{
};
// A SOAP Fault (e.g. position out of range) is logged by pOnvif; like before, the camera node is not
// restarted because of it. Only a lost connection clears m_bStatus (validate() -> reconnect).
commandResult(m_pOnVif->ptz_AbsoluteMove(m_pProfile->profiletoken, dPan, dTilt, dZoom));
return true;
#else
if (m_bStatus == 0)
@ -642,11 +659,7 @@ bool protocolPTZ_ONVIF::goPreset(char * PresetToken)
};
// 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;
}
return (m_bStatus > 0);
return commandResult(m_pOnVif->ptz_GotoPreset(m_pProfile->profiletoken, PresetToken, 1.0f, 1.0f, 1.0f));
#else
if (m_bStatus == 0)
{

1
lib/data/protocol/protocolPTZ_ONVIF.h

@ -55,6 +55,7 @@ class protocolPTZ_ONVIF : public protocolPTZ
float m_fTargetZoom;
void detectStatusSupport(void);
bool commandResult(bool ok);
bool fixedMoveWait(long alreadyWaitedMs);
#endif

Loading…
Cancel
Save