agsh / onvif

ONVIF node.js implementation
https://onvif.pages.dev
MIT License
707 stars 240 forks source link

ptz move issues #267

Open vladmandic opened 2 years ago

vladmandic commented 2 years ago

i have ptz move issues with reolink c2-pro

first, absoluteMove does not work at all, returns SOAP error.
instead using continousMove which does work, but - only if both x and y are present and non-zero.

for example:

cam.continuousMove({ x: 1, y: 1, zoom: 0 }); // works and pans right and tilts up
cam.continuousMove({ x: 1, y: -1, zoom: 0 }); // works and pans right and tilts down
cam.continuousMove({ x: 1, y: 0, zoom: 0 }); // does not do anything and there are no errors in callback
cam.continuousMove({ x: 1, zoom: 0 }); // does not do anything and there are no errors in callback

which basically means i can only move diagonally (pan & tilt at the same time), i cannot just pan or just tilt.

any ideas?

vladmandic commented 2 years ago

update: using underlying private methods in cam.onvif.ptz seems to work ok with just pan or tilt:

const profileToken = cam.defaultProfile.['PTZConfiguration']?.['token'] || '';
const velocity = { panTilt: { x, y }, zoom: { x: zoom } };
cam.onvif.ptz.continuousMove({ profileToken, velocity, timeout: 1000 });
agsh commented 2 years ago

@vladmandic Hi! Can you send the xml error responses from absoluteMove? I think that the trouble is in https://github.com/agsh/onvif/blob/master/lib/ptz.js#L525 method. But I'm not sure. Can you test you cam with other software and send me the xml requests and responses fjr the move commands?

agsh commented 2 years ago

Oh I guess that's the problem @RogerHardiman mentioned here: https://github.com/agsh/onvif/blob/master/lib/ptz.js#L471

vladmandic commented 2 years ago

Can you send the xml error responses from absoluteMove?

callback for absoluteMove:

  err: Error: ONVIF SOAP Fault: {"value":"SOAP-ENV:Sender"}
      at rs (/home/vlado/branches/onvif/src/utils.ts:106:11)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5),
  data: undefined

Oh I guess that's the problem @RogerHardiman mentioned here: https://github.com/agsh/onvif/blob/master/lib/ptz.js#L471

similar :)

agsh commented 2 years ago

Wow! You are using a new version written in typescript, as I can see :smile: /onvif/src/utils.ts:106:11 It is not ready yet and has never been published. Thanks! Can you add at this line the xml response from camera and send it?

    throw new Error(`ONVIF SOAP Fault: ${reason}${detail} ${rawXml}`);
vladmandic commented 2 years ago

Wow! You are using a new version written in typescript

yeah, sorry :)

Can you add at this line the xml response from camera and send it?

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:ns1="http://www.onvif.org/ver10/actionengine/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:ns10="http://www.onvif.org/ver10/events/wsdl/PullPointBinding" xmlns:ns11="http://www.onvif.org/ver10/events/wsdl/CreatePullPointBinding" xmlns:ns12="http://www.onvif.org/ver10/events/wsdl/PausableSubscriptionManagerBinding" xmlns:ns13="http://www.onvif.org/ver10/network/wsdl/RemoteDiscoveryBinding" xmlns:ns14="http://www.onvif.org/ver10/network/wsdl/DiscoveryLookupBinding" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:ns3="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding" xmlns:ns4="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:ns5="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" xmlns:ns6="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:ns7="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:ns8="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:ns9="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding" xmlns:tad="http://www.onvif.org/ver10/analyticsdevice/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tls="http://www.onvif.org/ver10/display/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:trv="http://www.onvif.org/ver10/receiver/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><SOAP-ENV:Fault><SOAP-ENV:Code><SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value></SOAP-ENV:Code><SOAP-ENV:Reason><SOAP-ENV:Text xml:lang="en"/></SOAP-ENV:Reason></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
agsh commented 2 years ago

This is ok, thank you for your interest!) I'm just try to rewrite the old js code with callbacks into typescript and promises. And any bug reports are welcome) And this response <SOAP-ENV:Fault> tell us that device can't understand the request and maybe doesn't support this command. So, the simplest way is to try absolute move via different ONVIF client, my favorite is https://sourceforge.net/projects/onvifdm/ and check that absolute move works for this device. If all is ok, please send me the xml request for this command, I'll try to reproduce it and change the request here: https://github.com/agsh/onvif/blob/v1/src/ptz.ts#L486

vladmandic commented 2 years ago

And this response tell us that device can't understand the request and maybe doesn't support this command.

That's what I thought - seems ReoLink capabilities are quite limited.
continousMove works and I can control stops using cam.stop call via setTimeout.
But even velocity values don't matter, its basically x > 0 = right and x < 0 left at constant speed.

Anyhow, I just did a clean http digest auth (zero dependencies) so i can actually use what's behind getSnapshotUri and that works nicely.

vladmandic commented 2 years ago

totally off-topic, i just noticed your rtsp-ffmpeg package
i did https://github.com/vladmandic/stream-rtsp for the same purpose, just didn't want to depend on ffmpeg.

RogerHardiman commented 2 years ago

Hi. You may find that the Reolink cannot handle Pan and Tilt and Zoom all at the same time (like the Sony camera I had. Sony have now fixed their firmware following a video chat with the engineers in Japan)

Many of the small CCTV cameras have basic (and sometimes buggy) ONVIF support especially if the electronics inside were made by a Chinese company called XM.

RogerHardiman commented 2 years ago

I'm interested in the RTSP to browser work too

vladmandic commented 2 years ago

@RogerHardiman issue here is different:

and quite likely, issue is related to new (unreleased) typescript branch

agsh commented 2 years ago

Oh, this is my mistake in compatibility module here, I suppose: https://github.com/agsh/onvif/blob/v1/src/compatibility/cam.ts#L248 I'll check when I have free time