You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

496 lines
38 KiB

#ifndef __PONVIF_CLASS_HEADER__
#define __PONVIF_CLASS_HEADER__
// Based on PHP Onvif library
#include <curl/curl.h>
#include <vector>
#include <openssl/sha.h>
#include <pthread.h>
#include "../protocol/xmlParser.h"
#include "../../alg/generic/base64.h"
#include "../../components/base/basicTypes.h"
#include "../../components/base/basicLogCollection.h"
//#define DEBUG_ONVIF_PRINTOUT_MESSAGES
//#define DEBUG_ONVIF_TRAFFIC
#define PONVIF_DEFAULT_DISCOVERYBINDIP "0.0.0.0"
#define PONVIF_DEFAULT_DISCOVERYMCASTIP "239.255.255.250"
#define PONVIF_DEFAULT_DISCOVERYMCASTPORT 3702
#define PONVIF_DEFAULT_DISCOVERYTIMEOUT 12
#define PONVIF_PACK_DISCOVERY "<?xml version=\"1.0\" encoding=\"UTF-8\"?><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\"><e: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></e:Header><e:Body><d:Probe><d:Types>dn:NetworkVideoTransmitter</d:Types></d:Probe></e:Body></e:Envelope>"
#define PONVIF_PACK_GET_SYS_DTS "<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 "<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 "<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 "<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 "<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 "<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 "<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\">%%STREAM%%</Stream><Transport xmlns=\"http://www.onvif.org/ver10/schema\"><Protocol>%%PROTOCOL%%</Protocol></Transport></StreamSetup><ProfileToken>%%PROFILETOKEN%%</ProfileToken></GetStreamUri></s:Body></s:Envelope>"
#define PONVIF_PACK_GET_PICTURE_URI "<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 "<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 "<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 "<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_GOTO_PRESET "<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=\"%%SPEEDPANTILTX%%\" y=\"%%SPEEDPANTILTY%%\" xmlns=\"http://www.onvif.org/ver10/schema\"/><Zoom x=\"%%SPEEDZOOMX%%\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Speed></GotoPreset></s:Body></s:Envelope>"
#define PONVIF_PACK_REMOVE_PRESET "<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 "<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 "<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=\"%%TRANSLATIONPANTILTX%%\" y=\"%%TRANSLATIONPANTILTY%%\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Translation><Speed><PanTilt x=\"%%SPEEDPANTILTX%%\" y=\"%%SPEEDPANTILTY%%\" 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 "<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=\"%%ZOOM%%\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Translation><Speed><Zoom x=\"%%SPEEDZOOM%%\" 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 "<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.5f\" y=\"%0.5f\" space=\"http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/><Zoom x=\"%0.5f\" space=\"http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace\" xmlns=\"http://www.onvif.org/ver10/schema\"/></Position></AbsoluteMove></s:Body></s:Envelope>"
#define PONVIF_PACK_CONTINUOUS_MOVE "<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=\"%%VELOCITYPANTILTX%%\" y=\"%%VELOCITYPANTILTY%%\" 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_ZOOM "<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=\"%%ZOOM%%\" 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 "<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>%%PANTILT%%</PanTilt><Zoom>%%ZOOM%%</Zoom></Stop></s:Body></s:Envelope>"
#define PONVIF_ENVELOPE_EXT "<?xml version=\"1.0\" encoding=\"UTF-8\"?><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>"
#define PONVIF_ENVELOPE_SIM "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">%s%s</s:Envelope>"
#define PONVIF_BODY "<s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">%s</s:Body>"
#define PONVIF_HEADER_PROBE "<e: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></e:Header>"
#define PONVIF_HEADER_SECUR "<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>"
#define PONVIF_PCK_GET_CAPABILITIES "<GetCapabilities xmlns=\"http://www.onvif.org/ver10/device/wsdl\"><Category>All</Category></GetCapabilities>"
typedef struct S_accessToken{
char USERNAME[CTEXT];
char PASSDIGEST[CTEXT];//SHA_DIGEST_LENGTH];
char NONCE[CTEXT];//SHA_DIGEST_LENGTH];
char TIMESTAMP[CTEXT];
} accessToken;
typedef struct S_videoSourceProfile{
char sourcetoken[CTEXT];
char profiletoken[CTEXT];
char profilename[CTEXT];
char encoding[16];
int width;
int height;
int fps;
int bitrate;
} videoSourceProfile;
typedef struct S_onvifVideoResolution{
int Width;
int Height;
}onvifVideoResolution;
typedef struct S_onvifBacklightCompensation{
bool Mode;
float Level;
}onvifBacklightCompensation;
typedef enum E_onvifExposurePriority{
LowNoise = 0,
FrameRate
}onvifExposurePriority;
typedef struct S_onvifRectangle{
int x;
int y;
int width;
int height;
}onvifRectangle;
typedef struct S_onvifExposure{
bool Mode;
onvifExposurePriority Priority;
onvifRectangle Window;
float MinExposureTime;
float MaxExposureTime;
float MinGain;
float MaxGain;
float MinIris;
float MaxIris;
float ExposureTime;
float Gain;
float Iris;
}onvifExposure;
typedef enum E_onvifOnOffAuto{
ON = 0,
OFF,
AUTO
}onvifOnOffAuto;
typedef struct S_onvifFocusConfiguration{
bool AutoFocusMode;
float DefaultSpeed;
float NearLimit;
float FarLimit;
}onvifFocusConfiguration;
typedef struct S_onvifWideDynamicRange{
bool Mode;
float Level;
}onvifWideDynamicRange;
typedef struct S_onvifWhiteBalanceExtension{
}onvifWhiteBalanceExtension;
typedef struct S_onvifWhiteBalance{
bool Mode;
float CrGain;
float CbGain;
onvifWhiteBalanceExtension * Extension;
}onvifWhiteBalance;
typedef struct S_onvifImagingSettingsExtension{
}onvifImagingSettingsExtension;
typedef struct S_onvifImagingSettings{
onvifBacklightCompensation * BacklightCompensation;
float Brightness;
float ColorSaturation;
float Contrast;
onvifExposure * Exposure;
onvifFocusConfiguration * Focus;
onvifOnOffAuto IrCutFilter;
float Sharpness;
onvifWideDynamicRange * WideDynamicRange;
onvifWhiteBalance * WhiteBalance;
onvifImagingSettingsExtension * Extension;
}onvifImagingSettings;
typedef struct S_onvifVideoSourceExtension{
onvifImagingSettings * Imaging;
}onvifVideoSourceExtension;
typedef struct S_onvifVideoSource{
char token[CTEXT];
float Framerate;
onvifVideoResolution Resolution;
onvifImagingSettings * Imaging;
onvifVideoSourceExtension * Extension;
}videoSource;
typedef struct S_onvifSupportedVersions{
int Major;
int Minor;
}onvifSupportedVersions;
typedef struct S_onvifNetworkCapabilitiesExtension2{
}onvifNetworkCapabilitiesExtension2;
typedef struct S_onvifNetworkCapabilitiesExtension{
bool Dot11Configuration;
onvifNetworkCapabilitiesExtension2 * Extension;
}onvifNetworkCapabilitiesExtension;
typedef struct S_onvifNetworkCapabilities{
bool IPFilter;
bool ZeroConfiguration;
bool IPVersion6;
bool DynDNS;
onvifNetworkCapabilitiesExtension * Extension;
}onvifNetworkCapabilities;
typedef struct S_onvifIOCapabilitiesExtension2{
}onvifIOCapabilitiesExtension2;
typedef struct S_onvifIOAuxiliaryData{
}onvifIOAuxiliaryData;
typedef struct S_onvifIOCapabilitiesExtension{
bool Auxiliary;
onvifIOAuxiliaryData * AuxiliaryCommands;
onvifIOCapabilitiesExtension2 * Extension;
}onvifIOCapabilitiesExtension;
typedef struct S_onvifIOCapabilities{
int InputConnectors;
int RelayOutputs;
onvifIOCapabilitiesExtension * Extension;
}onvifIOCapabilities;
typedef struct S_onvifSecurityCapabilitiesExtension2{
bool Dot1X;
int SupportedEAPMethod;
bool RemoteUserHandling;
}onvifSecurityCapabilitiesExtension2;
typedef struct S_onvifSecurityCapabilitiesExtension{
bool TLS1_0;
onvifSecurityCapabilitiesExtension2 * Extension;
}onvifSecurityCapabilitiesExtension;
typedef struct S_onvifSecurityCapabilities{
bool TLS1_1;
bool TLS1_2;
bool OnboardKeyGeneration;
bool AccessPolicyConfig;
bool X_509Token;
bool SAMLToken;
bool KerberosToken;
bool RELToken;
onvifSecurityCapabilitiesExtension * Extension;
}onvifSecurityCapabilities;
typedef struct S_onvifSystemCapabilitiesExtension2{
}onvifSystemCapabilitiesExtension2;
typedef struct S_onvifSystemCapabilitiesExtension{
bool HttpFirmwareUpgrade;
bool HttpSystemBackup;
bool HttpSystemLogging;
bool HttpSupportInformation;
onvifSystemCapabilitiesExtension2 * Extension;
}onvifSystemCapabilitiesExtension;
typedef struct S_onvifSystemCapabilities{
bool DiscoveryResolve;
bool DiscoveryBye;
bool RemoteDiscovery;
bool SystemBackup;
bool SystemLogging;
bool FirmwareUpgrade;
onvifSupportedVersions * SupportedVersions;
onvifSystemCapabilitiesExtension * Extension;
}onvifSystemCapabilities;
typedef struct S_onvifDeviceCapabilitiesExtension{
}onvifDeviceCapabilitiesExtension;
typedef struct S_onvifAnalyticsCapabilities{
char XAddr[CTEXT];
bool RuleSupport;
bool AnalyticsModuleSupport;
}onvifAnalyticsCapabilities;
typedef struct S_onvifDeviceCapabilities{
char XAddr[CTEXT];
onvifNetworkCapabilities * Network;
onvifSystemCapabilities * System;
onvifIOCapabilities * IO;
onvifSecurityCapabilities * Security;
onvifDeviceCapabilitiesExtension * Extension;
}onvifDeviceCapabilities;
typedef struct S_onvifEventCapabilities{
char XAddr[CTEXT];
bool WSSubscriptionPolicySupport;
bool WSPullPointSupport;
bool WSPausableSubscriptionManagerInterfaceSupport;
}onvifEventCapabilities;
typedef struct S_onvifImagingCapabilities{
char XAddr[CTEXT];
}onvifImagingCapabilities;
typedef struct S_onvifRealTimeStreamingCapabilitiesExtension{
}onvifRealTimeStreamingCapabilitiesExtension;
typedef struct S_onvifRealTimeStreamingCapabilities{
bool RTPMulticast;
bool RTP_TCP;
bool RTP_RTSP_TCP;
onvifRealTimeStreamingCapabilitiesExtension * Extension;
}onvifRealTimeStreamingCapabilities;
typedef struct S_onvifProfileCapabilities{
int MaximumNumberOfProfiles;
}onvifProfileCapabilities;
typedef struct S_onvifMediaCapabilitiesExtension{
onvifProfileCapabilities * ProfileCapabilities;
}onvifMediaCapabilitiesExtension;
typedef struct S_onvifMediaCapabilities{
char XAddr[CTEXT];
onvifRealTimeStreamingCapabilities * StreamingCapabilities;
onvifMediaCapabilitiesExtension * Extension;
}onvifMediaCapabilities;
typedef struct S_onvifPTZCapabilities{
char XAddr[CTEXT];
}onvifPTZCapabilities;
typedef struct S_onvifDeviceIOCapabilities{
char XAddr[CTEXT];
int VideoSources;
int VideoOutputs;
int AudioSources;
int AudioOutputs;
int RelayOutputs;
}onvifDeviceIOCapabilities;
typedef struct S_onvifDisplayCapabilities{
char XAddr[CTEXT];
bool FixedLayout;
}onvifDisplayCapabilities;
typedef struct S_onvifRecordingCapabilities{
char XAddr[CTEXT];
bool ReceiverSource;
bool MediaProfileSource;
bool DynamicRecordings;
bool DynamicTracks;
int MaxStringLength;
}onvifRecordingCapabilities;
typedef struct S_onvifSearchCapabilities{
char XAddr[CTEXT];
bool MetadataSearch;
}onvifSearchCapabilities;
typedef struct S_onvifReplayCapabilities{
char XAddr[CTEXT];
}onvifReplayCapabilities;
typedef struct S_onvifReceiverCapabilities{
char XAddr[CTEXT];
bool RTP_Multicast;
bool RTP_TCP;
bool RTP_RTSP_TCP;
int SupportedReceivers;
int MaximumRTSPURILength;
}onvifReceiverCapabilities;
typedef struct S_onvifAnalyticsDeviceExtension{
}onvifAnalyticsDeviceExtension;
typedef struct S_onvifAnalyticsDeviceCapabilities{
char XAddr[CTEXT];
bool RuleSupport;
onvifAnalyticsDeviceExtension * Extension;
}onvifAnalyticsDeviceCapabilities;
typedef struct S_onvifCapabilitiesExtension2{
}onvifCapabilitiesExtension2;
typedef struct S_onvifCapabilitiesExtension{
onvifDeviceIOCapabilities * DeviceIO;
onvifDisplayCapabilities * Display;
onvifRecordingCapabilities * Recording;
onvifSearchCapabilities * Search;
onvifReplayCapabilities * Replay;
onvifReceiverCapabilities * Receiver;
onvifAnalyticsDeviceCapabilities * AnalyticsDevice;
onvifCapabilitiesExtension2 * Extensions;
}onvifCapabilitiesExtension;
typedef struct S_nodeCapability{
onvifAnalyticsCapabilities * Analytics;
onvifDeviceCapabilities * Device;
onvifEventCapabilities * Events;
onvifImagingCapabilities * Imaging;
onvifMediaCapabilities * Media;
onvifPTZCapabilities * PTZ;
onvifCapabilitiesExtension * Extension;
}nodeCapability;
typedef struct S_discoveryNodeInfo{
char endpoint_uid[64];
char types[CTEXT];
char scopes[CTEXT];
char x_addrs[CTEXT];
char meta_version[10];
char ip_addrs[32];
}discoveryNodeInfo;
typedef std::vector<videoSourceProfile *> videoSourceProfiles;
typedef std::vector<videoSource *> videoSources;
typedef std::vector<discoveryNodeInfo *> discoveryResults;
class pOnvif{
private:
CURL * m_pCURL;
basicLogCollection * m_pLog;
CSTR m_pIpAddress;
CSTR m_pUsername;
CSTR m_pPassword;
CSTR m_pDeviceURI;
int m_pLastIndex;
CSTR m_pMediaURI;
CSTR m_pSnapshotURI;
CSTR m_pPTZURI;
CSTR m_pBaseURI;
onvifSupportedVersions m_sOnvifVersion;
time_t m_nDeltaTime;
videoSources m_vVideoSources;
videoSourceProfiles m_vVideoProfiles;
videoSourceProfiles m_vActiveSources;
nodeCapability m_sCapabilities;
CSTR m_pProxyHost;
int m_nProxyPort;
CSTR m_pProxyUsername;
CSTR m_pProxyPassword;
CSTR m_pLastResponse;
bool m_bIntransingent;
time_t m_nDiscoveryTimeout;
CSTR m_pDiscoveryBindIP;
CSTR m_pDiscoveryMCastIP;
int m_nDiscoveryMCastPort;
bool m_bDiscoveryHideDuplicates;
static int _writer( char *data, size_t size, size_t nmemb, pOnvif *Ptr );
public:
pOnvif();
~pOnvif();
bool setProxyHost( CSTR proxyHost );
CSTR getProxyHost( void );
bool setProxyPort( int proxyPort);
int getProxyPort( void );
bool setProxyUsername( CSTR proxyUsername );
CSTR getProxyUsername( void );
bool setProxyPassword( CSTR proxyPassword );
CSTR getProxyPassword( void );
bool setUsername( CSTR username );
CSTR getUsername( void );
bool setPassword( CSTR password );
CSTR getPassword( void );
CSTR getDeviceUri( void );
bool setDeviceUri( CSTR deviceUri );
CSTR getIPAddress( void );
bool setIPAddress( CSTR ipAddress );
videoSources * getSources( void );
videoSourceProfiles * getProfiles( void );
videoSourceProfiles * getActiveProfiles( void );
CSTR getMediaUri( void );
CSTR getPTZUri( void );
CSTR getBaseUrl( void );
void getSupportedVersion( void );
nodeCapability * getCapabilities( void );
bool setBreakOnError( bool intransingent );
CSTR getLastResponse( void );
bool setDiscoveryTimeout( int discoverytimeout );
bool setDiscoveryBindIp( CSTR discoverybindip );
bool setDiscoveryMcastIp( CSTR discoverymcastip );
bool setDiscoveryMcastPort( int discoverymcastport );
bool setDiscoveryHideDuplicates( bool discoveryhideduplicates );
CSTR getSnapshotUri( void );
discoveryResults discover( void );
bool create( void );
struct tm * core_GetSystemDateAndTime( void );
bool core_GetCapabilities();
bool core_GetDeviceInformation();
bool media_GetVideoSources();
bool media_GetProfiles();
bool media_GetServices();
CSTR media_GetStreamUri( CSTR profileToken, CSTR stream="RTP-Unicast", CSTR protocol="RTSP" );
CSTR media_GetSnapshotUri( CSTR profileToken );
bool ptz_GetPresets( CSTR profileToken );
bool ptz_GetNode( CSTR ptzNodeToken );
bool ptz_GetStatus( CSTR profileToken );
bool ptz_GotoPreset( CSTR profileToken, CSTR presetToken, float speed_pantilt_x, float speed_pantilt_y, float speed_zoom_x );
bool ptz_RemovePreset( CSTR profileToken, CSTR presetToken );
bool ptz_SetPreset( CSTR profileToken, CSTR presetName );
bool ptz_RelativeMove( CSTR profileToken, float translation_pantilt_x, float translation_pantilt_y, float speed_pantilt_x, float speed_pantilt_y );
bool ptz_RelativeMoveZoom( CSTR profileToken, float zoom, float speedZoom );
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 );
bool ptz_Stop( CSTR profileToken, bool pantilt, bool zoom );
/*
Internal functions
*/
private:
accessToken _makeToken( void );
void _getOnvifVersion( nodeCapability &capabilities );
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 );
bool _send_request( CSTR url, CSTR post_string );
};
#endif