 toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  ONVIF behind NAT: use the reachable address for the camera's services and URIs
Tested with the real camera reached as 2.54.237.28:8080 (port forward). It
reports its services and URIs at its LAN address 192.168.200.118:
GetCapabilities XAddrs http://192.168.200.118:8080/onvif/..., stream URIs
rtsp://192.168.200.118:554/...
toto.php
- initialize(): a service URL (media, device, ptz) on another host than
the one the device service was reached at is moved to that address,
keeping its path (_reachableUri). GetVideoSources went to
192.168.200.118 and failed with "Couldn't connect", and the UI said
"Credentials are Wrong!". A service on the same host is unchanged.
doCameraOperation.php
- Stream / snapshot URIs are split with parse_url (camMediaUri):
protocol, port (scheme default if none) and path + query, whatever the
host is. Before, only "proto://<ip of the record>" was removed, so with
the LAN host the whole URL was stored as the path. The two copies of
that code are replaced by the helper.
Real camera, request of the camera editor (CID=5, AU=7, CMD=3) through
the real login (users table / session): before, status "error" (LAN
address unreachable). Now status "ok", credentials, auth mode and PTZ
token stored, 3 profiles: mainStream 1920x1080
/Streaming/Channels/101?..., subStream, thirdStream; snapshot http:8080
/onvif-http/snapshot?Profile_n.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  ONVIF behind NAT: use the reachable address for the camera's services and URIs
Tested with the real camera reached as 2.54.237.28:8080 (port forward). It
reports its services and URIs at its LAN address 192.168.200.118:
GetCapabilities XAddrs http://192.168.200.118:8080/onvif/..., stream URIs
rtsp://192.168.200.118:554/...
toto.php
- initialize(): a service URL (media, device, ptz) on another host than
the one the device service was reached at is moved to that address,
keeping its path (_reachableUri). GetVideoSources went to
192.168.200.118 and failed with "Couldn't connect", and the UI said
"Credentials are Wrong!". A service on the same host is unchanged.
doCameraOperation.php
- Stream / snapshot URIs are split with parse_url (camMediaUri):
protocol, port (scheme default if none) and path + query, whatever the
host is. Before, only "proto://<ip of the record>" was removed, so with
the LAN host the whole URL was stored as the path. The two copies of
that code are replaced by the helper.
Real camera, request of the camera editor (CID=5, AU=7, CMD=3) through
the real login (users table / session): before, status "error" (LAN
address unreachable). Now status "ok", credentials, auth mode and PTZ
token stored, 3 profiles: mainStream 1920x1080
/Streaming/Channels/101?..., subStream, thirdStream; snapshot http:8080
/onvif-http/snapshot?Profile_n.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago  toto.php: no PHP Error past try/catch in initialize()
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
2 hours ago |
|
<?php
class Ponvif {
protected $ipaddress=''; protected $username=''; protected $password=''; protected $mediauri=''; protected $snapshoturi=''; protected $deviceuri=''; protected $ptzuri=''; protected $baseuri=''; protected $onvifversion=array(); protected $deltatime=0; protected $capabilities=array(); protected $videosources=array(); protected $sources=array(); protected $profiles=array(); protected $proxyhost=''; protected $proxyport=''; protected $proxyusername=''; protected $proxypassword=''; protected $lastresponse=''; protected $intransingent=true; protected $discoverytimeout=2; protected $discoverybindip='0.0.0.0'; protected $discoverymcastip='239.255.255.250'; protected $discoverymcastport=3702; protected $discoveryhideduplicates=true; protected $AuthMethod = 0;
public function setProxyHost($proxyHost) { $this->proxyhost = $proxyHost; } public function getProxyHost() { return $this->proxyhost; } public function setProxyPort($proxyPort) { $this->proxyport = $proxyPort; } public function getProxyPort() { return $this->proxyport; } public function setProxyUsername($proxyUsername) { $this->proxyusername = $proxyUsername; } public function getProxyUsername() { return $this->proxyusername; } public function setProxyPassword($proxyPassword) { $this->proxypassword = $proxyPassword; } public function getProxyPassword() { return $this->proxypassword; } public function setUsername($username) { $this->username = $username; } public function getUsername() { return $this->username; } public function setPassword($password) { $this->password = $password; } public function getPassword() { return $this->password; } public function getDeviceUri() { return $this->mediauri; } public function setDeviceUri($deviceUri) { $this->mediauri=$deviceUrl; } public function getIPAddress($ipAddress) { return $this->ipaddress; } public function setIPAddress($ipAddress) { $this->ipaddress=$ipAddress; } public function getSources() { return $this->sources; } public function getMediaUri() { return $this->mediauri; } public function getPTZUri() { return $this->ptzuri; } public function getBaseUrl() { return $this->baseuri; } public function getSupportedVersion() { return $this->onvifversion; } public function getCapabilities() { return $this->capabilities; } public function setBreakOnError($intransingent) { $this->intransingent=$intransingent; } public function getLastResponse() { return $this->lastresponse; } public function setDiscoveryTimeout($discoverytimeout) { $this->discoverytimeout = $discoverytimeout; } public function setDiscoveryBindIp($discoverybindip) { $this->discoverybindip = $discoverybindip; } public function setDiscoveryMcastIp($discoverymcastip) { $this->discoverymcastip = $discoverymcastip; } public function setDiscoveryMcastPort($discoverymcastport) { $this->discoverymcastport = $discoverymcastport; } public function setDiscoveryHideDuplicates($discoveryhideduplicates) { $this->discoveryhideduplicates = $discoveryhideduplicates; } public function getSnapshotUri() { return $this->snapshoturi; } public function setAuthMethod( $A ){ $this->AuthMethod = $A; }
/* Constructor & Destructor */ public function __construct() { // nothing to do
}
public function __destruct() { // nothing to do
}
/* WS-Discovery */ public function discover(){ $result = array(); $timeout = time() + $this->discoverytimeout; $post_string = '<?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>'; try { if(FALSE == ($sock = @socket_create(AF_INET, SOCK_DGRAM, SOL_UDP))){ echo('Create socket error: ['.socket_last_error().'] '.socket_strerror(socket_last_error())); } if(FALSE == @socket_bind($sock, $this->discoverybindip, rand(20000, 40000))){ echo('Bind socket error: ['.socket_last_error().'] '.socket_strerror(socket_last_error())); } if( $this->ipaddress == '' ){ socket_set_option($sock, IPPROTO_IP, MCAST_JOIN_GROUP, array('group' => $this->discoverymcastip)); socket_sendto($sock, $post_string, strlen($post_string), 0, $this->discoverymcastip, $this->discoverymcastport); } else { socket_sendto($sock, $post_string, strlen($post_string), 0, $this->ipaddress, $this->discoverymcastport ); }; socket_set_nonblock($sock); while( time() < $timeout ){ if(FALSE !== @socket_recvfrom($sock, $response, 9999, 0, $from, $this->discoverymcastport)){ if($response != NULL && $response != $post_string){ $response = $this->_xml2array($response); if(!$this->isFault($response)){ $response['Envelope']['Body']['ProbeMatches']['ProbeMatch']['IPAddr'] = $from; if($this->discoveryhideduplicates){ $result[$from] = $response['Envelope']['Body']['ProbeMatches']['ProbeMatch']; }else{ $result[] = $response['Envelope']['Body']['ProbeMatches']['ProbeMatch']; } } } } } socket_close($sock); } catch (Exception $e) {} sort($result); return $result; }
/* Public functions (basic initialization method and other collaterals) */ /* Errors here must be Exceptions: the callers use try { initialize() } catch (Exception $e). Before, a camera answering GetVideoSources with an HTML page (e.g. HTTP 401) or with no <VideoSources> made PHP 8 throw an Error / TypeError ($xml->getName() on false, count(null)) that went past catch (Exception) and ended the whole request. */ public function initialize() { $this->mediauri='http://'.$this->ipaddress.'/onvif/device_service';
try { $datetime=$this->core_GetSystemDateAndTime(); if (is_array($datetime) && isset($datetime['Time']) && isset($datetime['Date'])) { $timestamp=mktime($datetime['Time']['Hour'], $datetime['Time']['Minute'], $datetime['Time']['Second'], $datetime['Date']['Month'], $datetime['Date']['Day'], $datetime['Date']['Year']); $this->deltatime=time()-$timestamp-5; } } catch (Throwable $e) {}
try { $this->capabilities=$this->core_GetCapabilities(); if (!is_array($this->capabilities) || !isset($this->capabilities['Media']['XAddr'])) throw new Exception('GetCapabilities: no media service in the reply'); $onvifVersion=$this->_getOnvifVersion($this->capabilities); $this->mediauri=$this->_reachableUri($onvifVersion['media']); $this->deviceuri=$this->_reachableUri($onvifVersion['device']); $this->ptzuri=$this->_reachableUri($onvifVersion['ptz']); preg_match("/^http(.*)onvif\//",$this->mediauri,$matches); $this->baseuri=isset($matches[0]) ? $matches[0] : ''; $this->onvifversion=array('major'=>$onvifVersion['major'],'minor'=>$onvifVersion['minor']); $this->videosources=$this->media_GetVideoSources(); if (!is_array($this->videosources) || count($this->videosources)==0) throw new Exception('GetVideoSources: no video source in the reply'); $this->profiles=$this->media_GetProfiles(); if (!is_array($this->profiles) || count($this->profiles)==0) throw new Exception('GetProfiles: no media profile in the reply'); $this->sources=$this->_getActiveSources($this->videosources,$this->profiles); } catch (Exception $e) { throw $e; } catch (Throwable $e) { throw new Exception('ONVIF initialize: '.$e->getMessage(), 0, $e); } }
public function isFault($response) { // Useful to check if response contains a fault
if( is_array( $response ) ){ if( array_key_exists('Fault', $response ) ) return true; if( array_key_exists('Envelope', $response ) ) if( is_array( $response['Envelope'] ) ) if( array_key_exists('Body', $response['Envelope'] ) ) if( is_array( $response['Envelope']['Body'] ) ) if( array_key_exists('Fault', $response['Envelope']['Body'] ) ) return true; }; return false; }
/* Public wrappers for a subset of ONVIF primitives */ public function core_GetSystemDateAndTime() { $post_string='<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>'; if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { if ($this->intransingent) throw new Exception('GetSystemDateAndTime: Communication error'.$this->_faultText()); } else { return $response['Envelope']['Body']['GetSystemDateAndTimeResponse']['SystemDateAndTime']['UTCDateTime']; } }
public function core_GetCapabilities() { $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'])), $post_string); if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { if ($this->intransingent) throw new Exception('GetCapabilities: Communication error'.$this->_faultText()); } else return $response['Envelope']['Body']['GetCapabilitiesResponse']['Capabilities']; }
public function media_GetVideoSources() { $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'])), $post_string); //echo "POST STRING:" . $post_string . "\n\n";
if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { if ($this->intransingent) throw new Exception('GetVideoSources: Communication error'.$this->_faultText()); } else // var_dump( $response );
return isset($response['Envelope']['Body']['GetVideoSourcesResponse']['VideoSources']) ? $response['Envelope']['Body']['GetVideoSourcesResponse']['VideoSources'] : null; }
public function media_GetProfiles() { $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'])), $post_string); if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { if ($this->intransingent) throw new Exception('GetProfiles: Communication error'.$this->_faultText()); } else return $response['Envelope']['Body']['GetProfilesResponse']['Profiles']; }
public function media_GetServices() { $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'])), $post_string); if ($this->isFault($this->_send_request($this->mediauri,$post_string))) { if ($this->intransingent) throw new Exception('GetServices: Communication error'.$this->_faultText()); } }
public function core_GetDeviceInformation() { $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'])), $post_string); if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { if ($this->intransingent) throw new Exception('GetDeviceInformation: Communication error'.$this->_faultText()); } else return $response['Envelope']['Body']['GetDeviceInformationResponse']; }
public function media_GetStreamUri($profileToken,$stream="RTP-Unicast",$protocol="RTSP") { $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>'; $post_string=str_replace( array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%", "%%STREAM%%", "%%PROTOCOL%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken, $stream, $protocol)), $post_string ); if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { if ($this->intransingent) throw new Exception('GetStreamUri: Communication error'.$this->_faultText()); } else return $response['Envelope']['Body']['GetStreamUriResponse']['MediaUri']['Uri']; }
public function media_GetSnapshotUri($profileToken) { $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</ProfileToken></GetSnapshotUri></s:Body></s:Envelope>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken)), $post_string); if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) { if ($this->intransingent) throw new Exception('GetSnapshotUri: Communication error'.$this->_faultText()); var_dump($response); } else return $response['Envelope']['Body']['GetSnapshotUriResponse']['MediaUri']['Uri']; }
public function ptz_GetPresets($profileToken) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</ProfileToken></GetPresets></s:Body></s:Envelope>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken)), $post_string); if ($this->isFault($response=$this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('GetPresets: Communication error'.$this->_faultText()); } else { $getpresetsresponse=$response['Envelope']['Body']['GetPresetsResponse']['Preset']; $presets=array(); foreach ($getpresetsresponse as $preset) { $presets[]=array('Token'=>$preset['@attributes']['token'], 'Name'=>$preset['Name'], 'PTZPosition'=>$preset['PTZPosition']); } return $presets; } }
public function ptz_GetNode($ptzNodeToken) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%NODETOKEN%%</NodeToken></GetNode></s:Body></s:Envelope>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%NODETOKEN%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $ptzNodeToken)), $post_string); if ($this->isFault($response=$this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('GetNode: Communication error'.$this->_faultText()); } else return $response['Envelope']['Body']['GetNodeResponse']; }
public function ptz_GotoPreset($profileToken,$presetToken,$speed_pantilt_x,$speed_pantilt_y,$speed_zoom_x) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</ProfileToken><PresetToken>%%PRESETTOKEN%%</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>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%", "%%PRESETTOKEN%%", "%%SPEEDPANTILTX%%", "%%SPEEDPANTILTY%%", "%%SPEEDZOOMX%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken, $presetToken, $speed_pantilt_x, $speed_pantilt_y, $speed_zoom_x)), $post_string); if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('GotoPreset: Communication error'.$this->_faultText()); } }
public function ptz_RemovePreset($profileToken,$presetToken) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</ProfileToken><PresetToken>%%PRESETTOKEN%%</PresetToken></RemovePreset></s:Body></s:Envelope>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%", "%%PRESETTOKEN%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken, $presetToken)), $post_string); if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('RemovePreset: Communication error'.$this->_faultText()); } }
public function ptz_SetPreset($profileToken,$presetName) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</ProfileToken><PresetName>%%PRESETNAME%%</PresetName></SetPreset></s:Body></s:Envelope>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%", "%%PRESETNAME%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken, $presetName)), $post_string); if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('SetPreset: Communication error'.$this->_faultText()); } }
public function ptz_RelativeMove($profileToken,$translation_pantilt_x,$translation_pantilt_y,$speed_pantilt_x,$speed_pantilt_y) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</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>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%", "%%TRANSLATIONPANTILTX%%", "%%TRANSLATIONPANTILTY%%", "%%SPEEDPANTILTX%%", "%%SPEEDPANTILTY%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken, $translation_pantilt_x, $translation_pantilt_y, $speed_pantilt_x, $speed_pantilt_y)), $post_string); if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('RelativeMove: Communication error'.$this->_faultText()); } }
public function ptz_RelativeMoveZoom($profileToken,$zoom,$speedZoom) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</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>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%", "%%SPEEDZOOM%%", "%%ZOOM%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken, $speedZoom, $zoom)), $post_string); if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('RelativeMoveZoom: Communication error'.$this->_faultText()); } }
public function ptz_GetStatus( $profileToken ){ $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</ProfileToken></GetStatus></s:Body></s:Envelope>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken)), $post_string); if ($this->isFault($response = $this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('ptz Get Status: Communication error'); } else { var_dump( $response ); $cpos=$response['Envelope']['Body']['GetStatusResponse']['PTZStatus']['Position']; return $cpos; }; }
public function ptz_AbsoluteMove($profileToken,$position_pantilt_x,$position_pantilt_y,$zoom, $PSpeed=1.0, $TSpeed=1.0, $ZSpeed=1.0 ) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</ProfileToken><Position><PanTilt x="%%POSITIONPANTILTX%%" y="%%POSITIONPANTILTY%%" space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace" xmlns="http://www.onvif.org/ver10/schema"/><Zoom x="%%ZOOM%%" space="http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace" xmlns="http://www.onvif.org/ver10/schema"/></Position><Speed><PanTilt x="%%SPEEDPANTILTX%%" y="%%SPEEDPANTILTY%%" xmlns="http://www.onvif.org/ver10/schema"/><Zoom x="%%SPEEDZOOMX%%" xmlns="http://www.onvif.org/ver10/schema"/></Speed></AbsoluteMove></s:Body></s:Envelope>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%", "%%POSITIONPANTILTX%%", "%%POSITIONPANTILTY%%", "%%ZOOM%%", "%%SPEEDPANTILTX%%", "%%SPEEDPANTILTY%%", "%%SPEEDZOOMX%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken, $position_pantilt_x, $position_pantilt_y, $zoom, $PSpeed, $TSpeed, $ZSpeed)), $post_string); if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('AbsoluteMove: Communication error'.$this->_faultText()); } }
public function ptz_ContinuousMove($profileToken,$velocity_pantilt_x,$velocity_pantilt_y) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</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>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%", "%%VELOCITYPANTILTX%%", "%%VELOCITYPANTILTY%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken, $velocity_pantilt_x, $velocity_pantilt_y)), $post_string); if ( $this->isFault($this->_send_request($this->ptzuri,$post_string))) { if( $this->intransingent ) throw new Exception('ContinuousMove: Communication error'.$this->_faultText()); } }
public function ptz_ContinuousMoveZoom($profileToken,$zoom) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</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>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%", "%%ZOOM%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken, $zoom)), $post_string); if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('ContinuousMoveZoom: Communication error'.$this->_faultText()); } }
public function ptz_Stop($profileToken,$pantilt,$zoom) { if ($this->ptzuri=='') return array(); $REQ=$this->_makeToken(); $post_string='<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>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</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>%%PROFILETOKEN%%</ProfileToken><PanTilt>%%PANTILT%%</PanTilt><Zoom>%%ZOOM%%</Zoom></Stop></s:Body></s:Envelope>'; $post_string=str_replace(array("%%USERNAME%%", "%%PASSWORD%%", "%%NONCE%%", "%%CREATED%%", "%%PROFILETOKEN%%", "%%PANTILT%%", "%%ZOOM%%"), $this->_xescAll(array($REQ['USERNAME'], $REQ['PASSDIGEST'], $REQ['NONCE'], $REQ['TIMESTAMP'], $profileToken, $pantilt, $zoom)), $post_string); if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) { if ($this->intransingent) throw new Exception('Stop: Communication error'.$this->_faultText()); } }
/* Internal functions */ protected function _makeToken() { $timestamp=time()-$this->deltatime; return $this->_passwordDigest($this->username,$this->password,date('Y-m-d\TH:i:s.000\Z',$timestamp)); }
protected function _getOnvifVersion($capabilities) { $version=array('major'=>0,'minor'=>0); $sv=isset($capabilities['Device']['System']['SupportedVersions']) ? $capabilities['Device']['System']['SupportedVersions'] : null; if (is_array($sv) && isset($sv['Major'])) { // NVT supports a specific onvif version
$version['major']=$sv['Major']; $version['minor']=isset($sv['Minor']) ? $sv['Minor'] : 0; } elseif (is_array($sv)) { // NVT supports more onvif versions
foreach ($sv as $cver) { if (is_array($cver) && isset($cver['Major']) && $cver['Major']>$version['major']) { $version['major']=$cver['Major']; $version['minor']=isset($cver['Minor']) ? $cver['Minor'] : 0; } } } $version['media']=isset($capabilities['Media']['XAddr']) ? $capabilities['Media']['XAddr'] : ''; $version['device']=isset($capabilities['Device']['XAddr']) ? $capabilities['Device']['XAddr'] : ''; $version['event']=isset($capabilities['Events']['XAddr']) ? $capabilities['Events']['XAddr'] : ''; $version['ptz']=isset($capabilities['PTZ']['XAddr']) ? $capabilities['PTZ']['XAddr'] : ''; return $version; }
/* A camera behind NAT / port forwarding reports its services at its LAN address (e.g. http://192.168.200.118:8080/onvif/media while it is reached as 2.54.237.28:8080): the next request went to an address that cannot be reached and the UI said "Credentials are Wrong". A service URL on another host is moved to the address the device service was reached at (same scheme, host and port), keeping its path. A service on the same host is kept as is. */ protected function _reachableUri($url) { if (!is_string($url) || $url=='') return $url; $u=parse_url($url); $r=parse_url('http://'.$this->ipaddress); if ($u===false || $r===false || !isset($u['host']) || !isset($r['host'])) return $url; if (strcasecmp($u['host'], $r['host'])==0) return $url; return 'http://'.$this->ipaddress.(isset($u['path']) ? $u['path'] : '/').(isset($u['query']) ? '?'.$u['query'] : ''); }
// Why the last request failed: " (HTTP 401: reply is not a SOAP envelope)" or the SOAP Fault reason
protected function _faultText() { $r=$this->lastresponse; if (is_array($r) && isset($r['Fault']) && is_string($r['Fault'])) return ' ('.$r['Fault'].')'; if (is_array($r) && isset($r['Envelope']['Body']['Fault']['Reason']['Text'])) { $t=$r['Envelope']['Body']['Fault']['Reason']['Text']; if (is_string($t)) return ' ('.$t.')'; } return ''; }
// One XML element decodes to an associative array, several to a list: always return a list
protected function _asList($v) { if (!is_array($v)) return array(); if (isset($v['@attributes']) || !array_key_exists(0, $v)) return array($v); return $v; }
protected function _getActiveSources($videoSources,$profiles) { $sources=array(); if (!is_array($videoSources)) return $sources;
if (isset($videoSources['@attributes'])) { // NVT is a camera
$sources[0]['sourcetoken']=$videoSources['@attributes']['token']; $this->_getProfileData($sources,0,$profiles); } else { // NVT is an encoder
$videoSources=$this->_asList($videoSources); for ($i=0;$i<count($videoSources);$i++) { if (isset($videoSources[$i]['@attributes']['SignalActive']) && strtolower($videoSources[$i]['@attributes']['SignalActive'])=='true') { $sources[$i]['sourcetoken']=$videoSources[$i]['@attributes']['token']; $this->_getProfileData($sources,$i,$profiles); } } // for
}
return $sources; }
protected function _getProfileData(&$sources,$i,$profiles) { $inprofile=0; // A camera with ONE profile: count() counted the fields of that profile, no source was found
$profiles=$this->_asList($profiles); for ($y=0; $y < count($profiles); $y++) { if (isset($profiles[$y]['VideoSourceConfiguration']['SourceToken']) && $profiles[$y]['VideoSourceConfiguration']['SourceToken']==$sources[$i]['sourcetoken']) { $sources[$i][$inprofile]['profilename']=$profiles[$y]['Name']; $sources[$i][$inprofile]['profiletoken']=$profiles[$y]['@attributes']['token']; if ( isset($profiles[$y]['VideoEncoderConfiguration'])) { // RateControl (and in theory Resolution) are optional in ONVIF
$vec=$profiles[$y]['VideoEncoderConfiguration']; $sources[$i][$inprofile]['encoding']=isset($vec['Encoding']) ? $vec['Encoding'] : ''; $sources[$i][$inprofile]['width']=isset($vec['Resolution']['Width']) ? $vec['Resolution']['Width'] : 0; $sources[$i][$inprofile]['height']=isset($vec['Resolution']['Height']) ? $vec['Resolution']['Height'] : 0; $sources[$i][$inprofile]['fps']=isset($vec['RateControl']['FrameRateLimit']) ? $vec['RateControl']['FrameRateLimit'] : 0; $sources[$i][$inprofile]['bitrate']=isset($vec['RateControl']['BitrateLimit']) ? $vec['RateControl']['BitrateLimit'] : 0; } if ( isset($profiles[$y]['PTZConfiguration'])) { $sources[$i][$inprofile]['ptz']['name']=$profiles[$y]['PTZConfiguration']['Name']; $sources[$i][$inprofile]['ptz']['nodetoken']=$profiles[$y]['PTZConfiguration']['NodeToken']; } $inprofile++; } } }
// Not SOAP XML (empty, HTML error page ...): a Fault instead of a PHP Error / Exception
protected function _xml2array($response) { try { if (!is_string($response) || trim($response)=='') return array('Fault'=>'empty reply'); $prev=libxml_use_internal_errors(true); $sxe = new SimpleXMLElement($response); $dom_sxe = dom_import_simplexml($sxe); $dom = new DOMDocument('1.0'); $dom_sxe = $dom->importNode($dom_sxe, true); $dom_sxe = $dom->appendChild($dom_sxe); $element = $dom->childNodes->item(0); foreach ($sxe->getDocNamespaces() as $name => $uri) { $element->removeAttributeNS($uri, $name); } $xmldata=$dom->saveXML(); $b=strpos($xmldata,"<Envelope>"); $e=strpos($xmldata,"</Envelope>"); if ($b===false || $e===false) { libxml_use_internal_errors($prev); return array('Fault'=>'reply is not a SOAP envelope'); } $xmldata=substr($xmldata,$b,$e+strlen("</Envelope>")-$b); $xml=simplexml_load_string($xmldata); libxml_use_internal_errors($prev); if ($xml===false) return array('Fault'=>'reply is not valid XML'); $data=json_decode(json_encode((array)$xml),1); $data=array($xml->getName()=>$data); return $data; } catch (Throwable $e) { if (isset($prev)) libxml_use_internal_errors($prev); return array('Fault'=>'reply is not XML: '.$e->getMessage()); } }
/* Values put into the XML of a request (user name, profile / preset / node tokens, preset name ...) must be XML-escaped: a user name like "a&b" or a token with "&" or "<" made the request malformed - the camera rejected it and the UI reported "Credentials are Wrong!". Only strings are escaped: numbers and booleans are replaced as before. */ protected function _xesc($v) { return is_string($v) ? htmlspecialchars($v, ENT_XML1 | ENT_QUOTES, 'UTF-8') : $v; }
protected function _xescAll($values) { return array_map(array($this, '_xesc'), $values); }
protected function _passwordDigest( $username, $password, $timestamp = "default", $nonce = "default" ) { if ($timestamp=='default') $timestamp=date('Y-m-d\TH:i:s.000\Z'); if ($nonce=='default') $nonce=mt_rand(); $REQ=array(); $passdigest = base64_encode(pack('H*', sha1(pack('H*', $nonce) . pack('a*',$timestamp).pack('a*',$password)))); //$passdigest=base64_encode(sha1($nonce.$timestamp.$password,true)); // alternative
$REQ['USERNAME']=$username; $REQ['PASSDIGEST']=$passdigest; $REQ['NONCE']=base64_encode(pack('H*', $nonce)); //$REQ['NONCE']=base64_encode($nonce); // alternative
$REQ['TIMESTAMP']=$timestamp; return $REQ; }
protected function _send_request($url,$post_string) { $soap_do = curl_init(); curl_setopt($soap_do, CURLOPT_URL, $url ); if ($this->proxyhost!='' && $this->proxyport!='') { curl_setopt($soap_do, CURLOPT_PROXY, $this->proxyhost); curl_setopt($soap_do, CURLOPT_PROXYPORT, $this->proxyport); if ($this->proxyusername!='' && $this->proxypassword!='') curl_setopt($soap_do, CURLOPT_PROXYUSERPWD, $this->proxyusername.':'.$this->proxypassword); } curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 2 ); curl_setopt($soap_do, CURLOPT_TIMEOUT, 2 ); curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true ); curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); //curl_setopt($soap_do, CURLOPT_VERBOSE, true);
//curl_setopt($soap_do, CURLOPT_DEBUG, true);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($soap_do, CURLOPT_POST, true ); curl_setopt($soap_do, CURLOPT_POSTFIELDS, $post_string); curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Expect:', 'Content-Type: application/soap+xml; charset=utf-8', 'Content-Length: '.strlen($post_string) )); switch( $this->AuthMethod ){ case 0: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ); break; case 1: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST ); break; case 2: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST_IE ); break; case 3: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_BEARER ); break; case 4: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_NEGOTIATE ); break; case 5: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_NTLM ); break; case 6: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_NTLM_WB ); break; case 7: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_ANY ); break; case 8: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_ANYSAFE ); break; case 9: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_ONLY ); break; case 10: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_AWS_SIGV4 ); break; }; curl_setopt($soap_do, CURLOPT_USERPWD, $this->username . ":" . $this->password); // HTTP authentication
if ( ($result = curl_exec($soap_do)) === false) { $err = curl_error($soap_do); $this->lastresponse=array("Fault"=>$err); } else { //echo "QU: {$url}\n";
//echo "\n------------------\n";
//var_dump( $post_string );
//echo "\n~~~~~~~~~~~~~~~~~~\n";
//var_dump( $result );
$this->lastresponse=$this->_xml2array($result); if (isset($this->lastresponse['Fault']) && is_string($this->lastresponse['Fault'])) { $code=curl_getinfo($soap_do, CURLINFO_HTTP_CODE); $this->lastresponse['Fault']='HTTP '.$code.': '.$this->lastresponse['Fault']; // e.g. "HTTP 401: reply is not a SOAP envelope"
} } return $this->lastresponse; }
} // end class
?>
|