+43
Waiting for user's reply

Onvif-protocol for easy setup of IP-camera’s

Theo Derks - NL (distributor) 7 years ago in Products / Other drivers updated by Dennis Piet 6 months ago 32
Installers that are working in security-industry are asking us: is it possible to implement the Onvif-protocol for easy setup of IP-camera’s etc?

Please see www.onvif.org (http://www.onvif.org)

Is this module still in working condition?

I cannot get it to work with any of my customer's ONVIF cameras.

Scanning for ONVIF cameras in my network gives no results, even though I have 5 of them. All of them are found with ODM.

Also scanning would only work within your own network, not for adding cameras that reside elsewhere on the internet. I think there should be an option to manually add camera's, by inputting the address.

When I manually add one of the cameras in the code to temp_data_json (line 4 of GUImain), I only get:

SCRIPT Script exception: TypeError: C:\Users\Dennis\AppData\Roaming\iRidium Mobile\iRidiumStudio\iRidium pro documents\Studio\Temp\project88565921\scripts\GUICam.js:28: Tried to use undefined as an object

I have also tested this module in i3 Lite, but there also the scanner does not find any camera's.

It would be nice to have an example project of how to use this module in your own project, without the scanner / GUI / option settings.   The videostream I can get with the normal rtsp in project cameras, but I need to add PTZ control to that.

Thanks for the quick response Vladimir.  I just tried your version.

This seems a little bit better. Now my manually added ONVIF-camera shows up in the GUI, but it now gives an "Authorization fail..." and a iR_Loading animation.

In the logfile: SCRIPT Script exception: TypeError: C:\Users\Dennis\AppData\Roaming\iRidium Mobile\iRidiumStudio\iRidium pro documents\Studio\Temp\project9454765\scripts\UNITOnvifCam.js:456: Tried to use undefined as an object

Should I start a new topic to get some attention, or can we continue in this 6 year old topic ?

Hello.

Tell us the ONVIF firmware version.

You can install a third-party client for ONVIF and see if it works there.

One camera has Onvif 2.4, another has 2.21


As I wrote you 2 weeks ago:  All of them are found and work with ODM (= Onvif Device Manager), the same as the link you give above.

It is not an explanation of the error in UNITOnvifCam.js:456

Example of one camera:

Hello.

1. Try adding the camera via the scanner and check if the error persists.
2. Tell us the i3 pro version.

1. I told you the scanner does not work.

"Scanning for ONVIF cameras in my network gives no results, even though I have 5 of them. All of them are found with ODM.

Also scanning would only work within your own network, not for adding cameras that reside elsewhere on the internet. I think there should be an option to manually add camera's, by inputting the address."

2. I always have the latest Iridium release

iRidium Environment: 1.3.25.0.23568

iRidium Studio: 2.0.15.23568 (64 bit)
Transfer: 1.1.3.14538 (32 bit)
iRidium: 1.3.25.23568 (64 bit)
Server: 1.3.25.23568 (32 bit)

iRidium lite: 1.3.13.19979 (32 bit)
Server lite: 1.3.13.19979 (32 bit)

Hi Vladimir, I did some more debugging, dumping the XML responses to IR.Log and found the camera I'm testing with uses 

NS.S="env", NS.D="env". So I got it to work manually. But I guess those parameters are different for many camera's.

So now, I'm trying to figure out how to use this module, without the scanner that does not work. Also in my project the GUI from the module would not be used.

I think there should be an option to manually add camera's, by inputting the address.

Normally all you need is the IP-adres, port, login and password.  Functions in the ONVIF module should handle everything else.

Can you please make sure that comments in Modules are in English instead of Russian? Having to use Google translate all the time during figuring out how this works, does not really help.

Thank you for your helpful suggestions. We will take them into account, because we plan to create a native ONVIF driver.


For the scripting module is: does the web interface of your camera?

What do you mean by "does the web interface of your camera?"

We mean, is it possible to view the video of this camera via the web interface? If available, then give us AnyDesk (create a separate ticket, in which you specify the access details).

Now that I got my test-camera working, I tried connecting to my clients PTZ cameras.

I already found out they use NS.S="SOAP-ENV", so I can manually add them.

I run into the next problem:  GetSystemDateAndTime   is requesting without authentication. Yes, I know the Onvif specs allow for this, BUT many cameras (including the Everfocus and Provision cameras my client has), do not allow unauthenicated.

The author of the working node.js Onvif implementaion writes about this:

/ The ONVIF spec says this should work without a Password as we need to know any difference in the
// remote NVT's time relative to our own time clock (called the timeShift) so we can calculate the
// correct timestamp in nonce authentication header.
// But.. Panasonic and Digital Barriers both have devices that implement ONVIF that only work with
// authenticated getSystemDateAndTime

His solution is:

if (xml && xml.toLowerCase().includes('sender not authorized')) {
// Try again with a Username and Password

I see that Onvif Device Manager uses this same work around. So can we implement this in the Iridium Onvif Module?

I managed to change the ONVIF module a little to get it working with a camera that needs authentication for GetSystemDateAndTime.

First I changed in SOAP Unit:

this.GetSystemDateAndTime = function (in_oAuthData)

{

if (typeof in_oAuthData !== 'undefined')

{

return getAuthWrap(DATA.GetSystemDateAndTime.Data, in_oAuthData);

}

else

{

return getWrap(DATA.GetSystemDateAndTime.Data);

}

};

And then I changed in UNITOnvifCam:

function SyncTime()

{

//GCam.StateLoading(true);

l_oSubDevice.SetFeedback("StateLoading", true);

Send(SOAP.GetSystemDateAndTime(AuthData), SOAP.DATA.GetSystemDateAndTime.Action, syncTimeParse, Service);

l_bServicesError = false;

}

Now I can connect to the PTZ cameras and view their live stream

But: PTZ commands are NOT working :-(

Also : the arrows on the PTZ controls in the Module are wrong.  OK, this is just cosmetic and I can easily fix it myself, but thought you should now and fix it in the official module too.

Hello.

You reported that the camera rotation control does not work. Please specify: have you solved this issue yourself? We have taken the task of controlling the rotation for the module into operation, but the readiness period is still unknown. Do you need help with this part now?

No, I cannot get the PTZ control to work.

I have started logging response messages and see that the camera is complaining about unknown profiletoken "quality_h264".  This seems to be hardcoded in the XMLData unit.  Why ?

I also used Wireshark to compare what Iridium OnvifModule is sending to the camera and what Onvif Device Manager is sending.  The XML differs alot, especially where Iridium is using "tptz:" and "tt:" namespaces, where ODM just omits this.

Yesterday we installed the PTZ-camera at the clients location, so I do not have direct access to it anymore.

Now I use the external address to access the camera. This works fine in ODM, but the Iridium Onvif Module shows no image. I guess this is because the module uses the adres reported by the camera as the RTSP stream ?

Started

Hello.

We re-started the project with ONVIF. We will report the result within a month.

That is good news! Ofcourse a native onvif-driver that works just like other Iridium drivers is the best.

In the meantime I will give it a go to try and fix the current javascripts to make PTZ work.  We just installed the PTZ-camera at the clients location, so now he is getting a little bit impatient to play with his new toy on his control-screen.

Hello.

In the meantime I will give it a go to try and fix the current javascripts to make PTZ work. We just installed the PTZ-camera at the clients location, so now he is getting a little bit impatient to play with his new toy on his control-screen.

Update the i3 pro client. How does PTZ work in ODM? That is, whether you can control the camera rotation or zoom. If it works, can you provide a camera with PTZ for some time for edits, so that you can already navigate by it? Or simply provide access, and we will do everything necessary.

Hello, Dennis.

Is your question relevant?

Update the i3 pro client. How does PTZ work in ODM? That is, whether you can control the camera rotation or zoom. If it works, can you provide a camera with PTZ for some time for edits, so that you can already navigate by it? Or simply provide access, and we will do everything necessary.

Yes, it still is relevant.   2 clients want to control their PTZ camera from their Iridium based security panels.

I have asked them if I can give you access, but they are bound by their privacy-contracts and therefore cannot give access to third parties.

I myself have access to the cameras via VPN, so if you want me to test something I can do it.

Both cameras are working fine in ODM.


They also work with the node.js ONVIF library (https://github.com/agsh/onvif), so I think that implementation could be a good startingpoint for the Iridium implementation.

Waiting for user's reply

Hello.

Onvif Pro.irpz

You need the names of cameras with PTZ support, video, so that it can be seen that this is managed with ODM. Then you also need logs from i3 pro (go to the PTZ tab and use the control buttons there and send the i3 pro log with what you received). The scanner does not work via VPN. You need to disable the VPN and check-the scanner should work.

Thanks Vladimir, good to see you working on Onvif again.

About the Onvifscanner: this is still broken.   


But I found something interesting: when I'm using your Onvifmodule to scan, there is nothing happening but the spinning circle of dots ....

At that time I decided to start ODM to see if my Onvif camera's can still be found and at the same time: tada!  The onvifmodule still running in Iridium started to show my current 3 Onvif devices.

My guess was: OnvifScanner is not sending out the right discovery messages, but it is still listening to responses.


To prove this I compared with Wireshark ODM to Onvifscanner.

With ODM I see UDP/XML packets going to 239.255.255.250 port 3702

With Onvifscanner I see no UDP/XML packets at all. So I think Onvifscanner is not sending them at all.

Next I will try to get the remote PTZ-camera's working ......

Hello, Dennis.

We need the names of the PTZ-enabled cameras, the video, so that it can be seen that this is controlled using ODM.
Then we will also need the logs from the i3 pro (go to the PTZ tab, use the control buttons there, and send the i3 pro log with what you received).


Have you checked the ONVIF scanner without a VPN?

Yes Vladimir, I have tried the ONVIF scanner without VPN.  It does NOT work, because I see no UDP traffic coming from Iridium with Wireshark.

But: when I start ODM at the same time,ODM will start sending the correct UDP discovery packets and then Iridium can receive the responses from my local ONVIF devices.

I already told you: the 2 PTZ camera's are remote.  And even if I can arrange Anydesk access to a computer in the remote network, the ONVIF scanner does not work ......


The problems with current ONVIF module are:

- There is no easy way to manually add camera. Why should this be so difficult? Normally it would be enough to know the address (URL or IP) and login+password. The ONVIF module should do the rest.

- Current ONVIF module needs the scanner to find the N,D,S namespaces.   Why is this needed?  Other ONVIF-libraries just remove namespaces. This makes everything much easier.  Also: scanner depends on UDP, so this does only work for local cameras. The ONVIF module should not depend on the scanner.

- Many cameras need authentication for the GetSystemDateAndTime action. See my comment about this 2 months ago.  Current ONVIF module does not provide this, so I had to put this in myself.

- Current ONVIF module sets the image-stream to the URL provided by the ONVIF camera. This means for a remote camera it will try to use the local IP-address of that camera. Of course this will not work, because normally remote cameras are behind NAT.   So there should be an option to enforce the address that the user has provided. See how the Node.js does this, or how ODM does this.

So in an effort to get thing working .....

First I wiresharked the traffic from ODM to the remote PTZ camera. And I think I found the namespaces:

"NS":{"S":"SOAP-ENV", "D":"wsse", "A":"wsa"}


I have manually put in all known data in GUImain:

/**

* Файл графической части, пересоздания объектов камер    (again: could you please put all comments in English?)

*/

var temp_data_json = {

"http://remoteurl.dynamicdns.com:8282/onvif/device_service":

{"Name":"IP-Camera",

"UAdress":"http://remoteurl.dynamicdns.com:8282/onvif/device_service",

"Hardware":"88", "Adress":"remoteurl.dynamicdns.com:8282",

"Service":"/onvif/device_service",

"Login":"login",

"Password":"password",

"NS":{"S":"SOAP-ENV", "D":"wsse", "A":"wsa"}

}

};

IR.SetVariable("Global.Cameras",JSON.Stringify(temp_data_json));

//IR.SetVariable("Global.Cameras",{});


This far, it will give me the authentication error because of the failing synctime.

So I had to change SOAP unit and UNITOnvifCam (see how in my comment 2 months agao).

After that it will connect and authenticate and I can see it reports PTZ support.

But I cannot see the image. This is because the image is set to local IP of the camera and not to the URL I have provided.

So I have to connect to the remote network to get the image to work.

Then I can go to the PTZ controls, but when I hit the controls nothing happens.

In the logfile I see your logging of the PTZ controls.

To see what the camera's response is, I added extra logging myself:


function PTZStopResponse(in_sText)

{

IR.Log("PTZ response: " + in_sText)

}

function PTZContinuousMoveResponse(in_sText)

{

IR.Log("PTZ response: " + in_sText)

}


See the logfile below. There is no response from the camera.


[30-04-2021 09:58:41.329] DEBUG DIALOGSYSTEM CDialogSystem::ShowPage(Home)
[30-04-2021 09:58:41.410] INFO CORE *** The client started to work, version 1.3.27.24320 ***
[30-04-2021 09:58:41.426] DEBUG DIALOGSYSTEM CDialogSystem::ShowPage(Home)
[30-04-2021 09:58:41.757] INFO SCRIPT tag_change, tag = StateConnected value = true
[30-04-2021 09:58:42.032] INFO SCRIPT tag_change, tag = PTZSupport value = true
[30-04-2021 09:58:42.506] INFO SCRIPT tag_change, tag = StateAuth value = true
[30-04-2021 09:58:42.982] INFO SCRIPT tag_change, tag = SetImage value = rtsp://login:password@192.168.1.2:554/Streaming/Channels/1
[30-04-2021 09:58:43.012] INFO SCRIPT tag_change, tag = StateLoading value = false
[30-04-2021 10:00:38.667] INFO SCRIPT Value Left
[30-04-2021 10:00:38.671] INFO SCRIPT in_x = -0.5 in_y 0
[30-04-2021 10:00:39.048] INFO SCRIPT Value Stop
[30-04-2021 10:00:39.478] INFO SCRIPT Value TopLeft
[30-04-2021 10:00:39.482] INFO SCRIPT in_x = -0.5 in_y 0.5
[30-04-2021 10:00:39.799] INFO SCRIPT Value Stop
[30-04-2021 10:00:40.507] INFO SCRIPT Value Right
[30-04-2021 10:00:40.523] INFO SCRIPT in_x = 0.5 in_y 0
[30-04-2021 10:00:40.612] INFO SCRIPT Value Stop
[30-04-2021 10:00:41.020] INFO SCRIPT Value Right
[30-04-2021 10:00:41.026] INFO SCRIPT in_x = 0.5 in_y 0
[30-04-2021 10:00:41.160] INFO SCRIPT Value Stop

I have put in extra logging in the Send function.

Now I see massive amounts of GetStreamUri calls being send to the camera.  

Why so many? They get send in a rate of 30 calls per second !!!

Whenever an answer from the camera is the received, it is always the same:

rtsp://192.168.1.2:554/Streaming/Channels/1

I guess the camera is flooded with the GetStreamUri calls, so it does not even have time to respond to PTZ calls?

I finally found out why the above flooding of GetStreamURI calls happened.

The camera returned timeout = PT0H0M3S, which is a valid ISO duration

But, there is an error in your function parseTimout that makes l_nTimeOfTimeOut = 0 !

So, I have replaced parseTimout with this:

function parseTimout(in_sTiomout)

{

var reptms = /^PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?$/;

var hours = 0, minutes = 0, seconds = 0, totalseconds;

if (reptms.test(in_sTiomout))

{

var matches = reptms.exec(in_sTiomout);

if (matches[1]) hours = Number(matches[1]);

if (matches[2]) minutes = Number(matches[2]);

if (matches[3]) seconds = Number(matches[3]);

totalseconds = hours * 3600 + minutes * 60 + seconds;

}

return (totalseconds*1000);

}

Now, the timeout is parsed correct to milliseconds and the GetStreamURI functions normal.

Still PTZ is not working ......

OMG!   2 months ago I reported a problem with a hardcoded "quality_h264" profile. Did you read that comment above and do something about it ?

I guess not, since the error coming back from the camera says : "The requested profile token quality_h264 does not exist."


So after an afternoon of debugging, I finally got some of the PTZ working

First, I had to replace this.AuthTemplate with the correct template.  You probably once have inserted a different template containing the quality_h264 token and other body contents for testing? Only you forgot to take it out, causing many problems for me.

Then PTZ was still not working, so I started comparing with Wireshark de messages from ODM to the ones from Iridium.

Again I came to the same conclusion as my comments of 2 months ago : the "tptz:" and "tt:" namespaces are not correct!

Also I found the xmls were in the wrong places.


I corrected ContinuesMove to the following:


this.PTZContinuousMove = function (in_oAuthData, in_sToken, in_x, in_y)

{

var Xml = getAuthHeader(in_oAuthData);

// IR.Log("Header : " + Xml.toXMLString());

// Xml["s:Envelope"]["@xmlns:tptz"] = "http://www.onvif.org/ver20/ptz/wsdl";

//Xml["s:Envelope"]["@xmlns:tt"] = "http://www.onvif.org/ver10/schema";

Xml["s:Envelope"]["s:Body"]["ContinuousMove"] = {};

Xml["s:Envelope"]["s:Body"]["ContinuousMove"]["@xmlns"] = "http://www.onvif.org/ver20/ptz/wsdl";

Xml["s:Envelope"]["s:Body"]["ContinuousMove"]["ProfileToken"] = in_sToken;

Xml["s:Envelope"]["s:Body"]["ContinuousMove"]["Velocity"] = {};

Xml["s:Envelope"]["s:Body"]["ContinuousMove"]["Velocity"]["PanTilt"] = {};

Xml["s:Envelope"]["s:Body"]["ContinuousMove"]["Velocity"]["PanTilt"]["@xmlns"] = "http://www.onvif.org/ver10/schema";

Xml["s:Envelope"]["s:Body"]["ContinuousMove"]["Velocity"]["PanTilt"]["@x"] = in_x;

Xml["s:Envelope"]["s:Body"]["ContinuousMove"]["Velocity"]["PanTilt"]["@y"] = in_y;

//Xml["s:Envelope"]["s:Body"]["tptz:ContinuousMove"]["tptz:Velocity"]["tt:Zoom"] = {};

//Xml["s:Envelope"]["s:Body"]["tptz:ContinuousMove"]["tptz:Velocity"]["tt:Zoom"]["@x"] = 0;

return Xml.toXMLString();

};

And yesssssssssssss, finally some PTZ is working !!!!!

Later I will check the other functions.