Open rickerd opened 7 years ago
I think the library should already be able to do what you want, although I don't have a PTZ capable camera to test it with.
If you go to this page: https://www.onvif.org/profiles/specifications/ you can use that page as documentation for this library. The services listed on that page are exposed as properties on the Onvif class. So for example if you want to retrieve a snapshot of the camera using the library, you would go to the media service on that page here (I find the wsdl version easier to read): https://www.onvif.org/ver10/media/wsdl/media.wsdl search for snapshot and you will find the GetSnapshotUri function that takes a ProfileToken argument. To use that function in this library you would do the following:
You pass the parameters in as an associative array
$ov = new Rockyjvec\Onvif("http://camera.host:port/onvif/device_service', 'username', 'password');
$result = $ov->media->GetSnapshotUri(['ProfileToken' => 'the-profile-token-you-want-to-use']);
$snapshotUri = $result->Uri;
Similarly for the live video:
$result = $ov->media->GetStreamUri(['StreamSetup' => ['Stream' => 'RTP-Unicast', 'Protocol' => 'RTSP'], 'ProfileToken' => 'the-profile-token-you-want-to-use']);
As I said, I don't have a PTZ camera to test with, but something like this should work (from: https://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl):
$ov->ptz->GotoHomePosition()
It looks like a lot of the ptz functions use complex types. You can look at this doc to see what the complex types actually are: https://www.onvif.org/ver10/schema/common.xsd
For example, Vector2D looks to be something like ['x' => float, 'y' => float] so I'm guessing for the ContinuousMove function it would be something like this:
$ov->ptz->ContinuousMove([
'ProfileToken' => 'the-profile-token-you-want-to-use',
'Velocity' => [
'PanTilt' => [
'x' => 1.0,
'y' => 1.0
]
]
];
You can also check the capabilities of the camera using:
$ov->device->GetCapabilities()
I hope that helps.
Great comment. But it seems that i need a big practice in SOAP. For me as a simple developer it's easier to just call a method that returns something without passing some data or stuff to the method.
What's the thought to add such array values? I'm trying some things like to get a snapshot tonight but it's not working yet.
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] End of file or no input: Operation interrupted or timed out in /Users/rick/Projects/onvif/vendor/rockyjvec/onvif/src/Rockyjvec/Onvif/Soap/SoapClient.php:61 Stack trace: #0
/Users/rick/Projects/onvif/vendor/rockyjvec/onvif/src/Rockyjvec/Onvif/Soap/SoapClient.php(61): SoapClient->__call('GetSnapshotUri', Array)
#1 /Users/rick/Projects/onvif/index.php(31): Rockyjvec\Onvif\Soap\SoapClient->__call('GetSnapshotUri', Array) #2 {main} thrown in /Users/rick/Projects/onvif/vendor/rockyjvec/onvif/src/Rockyjvec/Onvif/Soap/SoapClient.php on line 61
It sounds like it is having a hard time communicating with the camera for some reason.
Does getting the device capabilities work?
var_dump($ov->device->GetCapabilities());
Also, you could try going to the camera onvif URL in a web browser to verify that it's working. It should return something like "SOAP-ENV:ClientHTTP GET method not implemented". The camera might also use a different port for onvif. For my camera I have to use port 8000.
Where to get the profile token? If i send the request the camera dies and reboots itself.
Strange. You can get the profile tokens using var_dump($ov->media->GetProfiles());
What camera are you using? Maybe there is a firmware update.
I use this one https://www.aliexpress.com/item/Vandal-Proof-Indoor-Outdoor-Dome-Camera-IP-3MP-HI3516D-1-3-AR0330-H-265-IP-Camera/32767179623.html
If i use $ov->media->GetProfiles(); i do get the information but i have no clue how to get or make the profiletoken.
Could you send me a short example how to subscribing to motion events?
Good library but i'm missing things. I'm looking for ways to control the camera trough PTZ and also retrieve a snapshot of the camera or live video.
I want to help i i can but i don't know how since i've almost never done anything with soap.