onvif icon indicating copy to clipboard operation
onvif copied to clipboard

Improve `getAudioEncoderConfigurationOptions`.

Open bl0ggy opened this issue 5 years ago • 11 comments

Permit to get an AudioEncoderConfigurationOption with either a ConfigurationToken, a ProfileToken or both as first argument. Update JSDoc.

This breaks backward compatibility. But I wonder, I updated the response XML file because with the cameras I have (Samsung and HIK Vision), it's very different. First, there are tt:Options tags inside the trt:Options tag, second, the elements in lists are not tt:List but tt:Items. Did the structure change over years ? Are there cameras still responding the old way ? If that's the case, we will have to convert one structure into the other.

bl0ggy avatar Feb 21 '20 10:02 bl0ggy

Coverage Status

Coverage increased (+0.02%) to 87.929% when pulling f89f99287c5291f782f6025773e8b9ef67d431a9 on bl0ggy:improve_getAudioEncoderConfigurationOptions into f8ee914a9f5a8cab0acdb70f4efb0e4d0f56836f on agsh:master.

coveralls avatar Feb 21 '20 10:02 coveralls

Did the structure change over the years.....

Yes the structure did change. Originally we had the Media Service https://www.onvif.org/ver10/media/wsdl/media.wsdl

Now we also have Media2 (Media Service Version 2.0 and the URL has ver20 in it) https://www.onvif.org/ver20/media/wsdl/media.wsdl

So we need to check if a camera uses Media1 or Media2 and then parse the XML differently depending on which Media Service (media 1 or media 2) the camera supports.

RogerHardiman avatar Feb 29 '20 06:02 RogerHardiman

Just to add some extra info. In the original ONVIF spec we had to get the System Date and Time and then call GetCapabilities to get the URLs for each 'Service' (media, imaging, PTZ, device etc) The ONVIF Library's constructor does this as shown below (from cam.js)

/**

  • Connect to the camera and fill device information properties

  • @param {Cam~ConnectionCallback} callback */ Cam.prototype.connect = function(callback) {

     // Must execute getSystemDataAndTime (and wait for callback)
    
     this.getSystemDateAndTime(function(err, date, xml) {
             if (err) {
                     return callback.call(this, err, null, xml);
             }
             this.getCapabilities(function(err, data, xml) {
    

If you read the latest ONVIF Core Specification it says we are supposed to call getSystemDateAndTime and then call GetServices

The old GetCapabilities ONVIF command is now deprecated and left in for backwards compatibility.

8.1.2.4 GetCapabilities This method provides a backward compatible interface for the base capabilities. Refer to GetServices for a full set of capabilities.

So actually there is a larger issue here. What we need the ONVIF library to do is a) getSystemDateAndTime b) try GetServices. If it works we will know if we are using Media1 or Media2 c) if GetServices fails, we need to fall back to GetCapabilities

So before we can implement this PR we need to fix some other things in the library.

Let me know if you need any more info.

Roger

RogerHardiman avatar Feb 29 '20 07:02 RogerHardiman

Hi. Just a reminder you need to modify the commit to handle 'media' and 'media2' as the APIs are different.

RogerHardiman avatar Mar 15 '20 09:03 RogerHardiman

I have a few questions.

  • Should I discard the changes I made to the xml response ? Because media v1 does not have tt:List anymore
  • Should I make a getAudioEncoderConfigurationOptionsV2 function ?
  • The xmlns in the request must be modified from ver10 to ver20 too, how to know which version to use ?
  • I can't find where I read it but I remember that media is for Profile S while media2 is for Profile T, is that correct ?

bl0ggy avatar Mar 17 '20 07:03 bl0ggy

Old ONVIF used the GetCapabilities command to get the ONVIF Services like device and media.

New ONVIF uses the GetServices command to get the Device Services like Media2.

So first step is to edit the library when it first connects to the camera. You need to try Get Services first and fail back to GetCapabilities. If GetServices works you can check if it reports Media or Media2 support.

You need to set a global flag for the class and use it to decide what format XML to send.

Roger

RogerHardiman avatar Mar 17 '20 08:03 RogerHardiman

Hi @bl0ggy . Do you still have access to your Samsung and Hik cameras?

RogerHardiman avatar Apr 10 '21 06:04 RogerHardiman

Hi Jessy, I've made use of your changes to detect Media2 in my 'roger' branch on github. You can now use this to create a Media2 specific version of getAutioEncoderConfigurationOptions that handles the different XML format.

For getProfiles, getStreamUri and getSnapshotUri I made the function handle media1 and media2 and I modified the result so Media2 results look like Media1 results. But your suggestion of having functionNameV2() with V2 added is a good idea.

Roger

RogerHardiman avatar Apr 11 '21 11:04 RogerHardiman

Hi @RogerHardiman, yes I still have access to some Samsung cameras and at least one Hik. Unfortunately I don't have much time for that, but I have a coworker who may be able to do it. We will keep you informed.

bl0ggy avatar Apr 11 '21 12:04 bl0ggy

@bl0ggy . Just wanted to let you know that in the summer I added code to detect Media API and Media2 API for video. So we could re-visit your code for parsing the Audio Sources

RogerHardiman avatar Oct 04 '21 07:10 RogerHardiman

@RogerHardiman I saw your improvements and tried to copy them to the typescript version. So, what to do you think now?

agsh avatar Feb 15 '22 04:02 agsh