2021-06-04 00:52:20 -03:00
|
|
|
/*
|
|
|
|
* This file is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Code by Michael Oborne and Siddharth Bharat Purohit, Cubepilot Pty.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2022-02-28 21:19:13 -04:00
|
|
|
#include <AP_HAL/AP_HAL_Boards.h>
|
2021-06-14 13:56:42 -03:00
|
|
|
|
|
|
|
#if ENABLE_ONVIF
|
2021-06-23 13:44:26 -03:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wshadow"
|
2021-06-26 12:48:37 -03:00
|
|
|
#pragma GCC diagnostic ignored "-Wsuggest-override"
|
2021-06-04 00:52:20 -03:00
|
|
|
#include <AP_ONVIF/onvifDeviceBindingProxy.h>
|
|
|
|
#include <AP_ONVIF/onvifMediaBindingProxy.h>
|
|
|
|
#include <AP_ONVIF/onvifPTZBindingProxy.h>
|
|
|
|
#include <plugin/wsseapi-lite.h>
|
2021-08-22 05:33:00 -03:00
|
|
|
#pragma GCC diagnostic pop
|
2021-06-04 00:52:20 -03:00
|
|
|
#include <AP_Math/AP_Math.h>
|
|
|
|
|
|
|
|
class AP_ONVIF {
|
|
|
|
public:
|
2021-06-14 13:51:03 -03:00
|
|
|
AP_ONVIF();
|
|
|
|
|
|
|
|
/* Do not allow copies */
|
|
|
|
AP_ONVIF(const AP_ONVIF &other) = delete;
|
|
|
|
AP_ONVIF &operator=(const AP_ONVIF&) = delete;
|
|
|
|
|
2021-06-14 13:56:42 -03:00
|
|
|
// Start ONVIF client with username, password and service host url
|
2021-06-14 13:51:03 -03:00
|
|
|
bool start(const char *user, const char *pass, const char *httphostname);
|
2021-06-14 13:56:42 -03:00
|
|
|
|
|
|
|
// Turn ONVIF camera to mentioned pan, tilt and zoom, normalised
|
|
|
|
// between limits
|
2021-06-04 00:52:20 -03:00
|
|
|
bool set_absolutemove(float pan, float tilt, float zoom);
|
2021-06-14 13:56:42 -03:00
|
|
|
|
|
|
|
// returns pan/tilt command max limit
|
2021-06-14 13:51:03 -03:00
|
|
|
Vector2f get_pan_tilt_limit_max() const { return pan_tilt_limit_max; }
|
2021-06-14 13:56:42 -03:00
|
|
|
|
|
|
|
// returns pan/tilt command min limit
|
2021-06-14 13:51:03 -03:00
|
|
|
Vector2f get_pan_tilt_limit_min() const { return pan_tilt_limit_min; }
|
2021-06-04 00:52:20 -03:00
|
|
|
|
|
|
|
// get singleton instance
|
2021-06-14 13:51:03 -03:00
|
|
|
static AP_ONVIF *get_singleton() { return _singleton; }
|
2021-06-04 00:52:20 -03:00
|
|
|
|
|
|
|
private:
|
2021-06-14 13:56:42 -03:00
|
|
|
|
|
|
|
// prepares security header of SOAP message going to be sent immmediately after
|
2021-06-23 13:44:26 -03:00
|
|
|
bool set_credentials();
|
2021-06-14 13:56:42 -03:00
|
|
|
|
|
|
|
// convert error message from gSOAP lib into human readable string and print
|
2021-06-04 00:52:20 -03:00
|
|
|
void report_error();
|
2021-06-14 13:56:42 -03:00
|
|
|
|
|
|
|
// detect onvif server present on the network
|
2021-06-04 00:52:20 -03:00
|
|
|
bool probe_onvif_server();
|
2021-06-14 13:56:42 -03:00
|
|
|
|
|
|
|
// Generate Random Nonce value
|
2021-06-26 11:49:52 -03:00
|
|
|
bool rand_nonce(char *nonce, size_t noncelen);
|
2021-06-04 00:52:20 -03:00
|
|
|
|
|
|
|
Vector2f pan_tilt_limit_min;
|
|
|
|
Vector2f pan_tilt_limit_max;
|
2021-06-14 13:51:03 -03:00
|
|
|
float pan_norm, tilt_norm, zoom_norm;
|
2021-06-04 00:52:20 -03:00
|
|
|
float last_pan_cmd, last_tilt_cmd;
|
|
|
|
|
|
|
|
float zoom_min, zoom_max;
|
2021-06-23 13:44:26 -03:00
|
|
|
char* profile_token;
|
|
|
|
size_t profile_token_size;
|
2021-06-04 00:52:20 -03:00
|
|
|
struct soap *soap;
|
|
|
|
DeviceBindingProxy *proxy_device;
|
|
|
|
MediaBindingProxy *proxy_media;
|
|
|
|
PTZBindingProxy *proxy_ptz;
|
|
|
|
static AP_ONVIF *_singleton;
|
2021-06-14 13:51:03 -03:00
|
|
|
|
2021-06-26 12:48:37 -03:00
|
|
|
char* username;
|
|
|
|
size_t username_len;
|
|
|
|
|
|
|
|
char* password;
|
|
|
|
size_t password_len;
|
|
|
|
|
|
|
|
size_t hostname_len;
|
2021-06-14 13:51:03 -03:00
|
|
|
|
2021-06-23 13:44:26 -03:00
|
|
|
char* device_endpoint;
|
|
|
|
char* media_endpoint;
|
|
|
|
char* ptz_endpoint;
|
2021-06-14 13:56:42 -03:00
|
|
|
bool initialised;
|
2021-06-04 00:52:20 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-06-14 13:51:03 -03:00
|
|
|
namespace AP {
|
|
|
|
AP_ONVIF &onvif();
|
|
|
|
};
|
2021-06-14 13:56:42 -03:00
|
|
|
#endif // #if ENABLE_ONVIF
|