Skip to content

Commit

Permalink
Merge pull request #151 from bl0ggy/add_requests_to_add_remove_config…
Browse files Browse the repository at this point in the history
…urations

Add new requests to add/remove configurations to/from profiles.
  • Loading branch information
RogerHardiman committed Feb 29, 2020
2 parents f7b4bb5 + 2a141ae commit 0cf06ca
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 2 deletions.
180 changes: 179 additions & 1 deletion lib/media.js
Expand Up @@ -687,7 +687,185 @@ module.exports = function(Cam) {
}.bind(this));
};

// TODO AddVideoEncoderConfiguration
/**
* @callback Cam~AddAudioEncoderConfigurationCallback
* @property {?Error} error
* @property {null}
* @property {string} xml Raw XML response
*/

/**
* This operation adds an AudioEncoderConfiguration to an existing media profile. If a configuration exists in the media profile, it will be replaced. The change shall be persistent. A device shall support adding a compatible AudioEncoderConfiguration to a profile containing an AudioSourceConfiguration and shall support streaming audio data of such a profile.
* @param {object} options
* @param {string} options.profileToken Reference to the profile where the configuration should be added
* @param {string} options.configurationToken Contains a reference to the AudioSourceConfiguration to add
* @param {Cam~AddAudioEncoderConfigurationCallback} callback
*/
Cam.prototype.addAudioEncoderConfiguration = function(options,callback) {
let body = this._envelopeHeader() +
'<AddAudioEncoderConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl">' +
'<ProfileToken>' + options.profileToken + '</ProfileToken>' +
'<ConfigurationToken>' + options.configurationToken + '</ConfigurationToken>' +
'</AddAudioEncoderConfiguration>' +
this._envelopeFooter();
this._request({
service: 'media',
body: body,
}, function(err, data, xml) {
if (callback) {
callback.call(this, err, null, xml);
}
}.bind(this));
};

/**
* @callback Cam~AddAudioSourceConfigurationCallback
* @property {?Error} error
* @property {null}
* @property {string} xml Raw XML response
*/

/**
* This operation adds an AudioSourceConfiguration to an existing media profile. If a configuration exists in the media profile, it will be replaced. The change shall be persistent.
* @param {object} options
* @param {string} options.profileToken Reference to the profile where the configuration should be added
* @param {string} options.configurationToken Contains a reference to the AudioSourceConfiguration to add
* @param {Cam~AddAudioSourceConfigurationCallback} callback
*/
Cam.prototype.addAudioSourceConfiguration = function(options,callback) {
let body = this._envelopeHeader() +
'<AddAudioSourceConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl">' +
'<ProfileToken>' + options.profileToken + '</ProfileToken>' +
'<ConfigurationToken>' + options.configurationToken + '</ConfigurationToken>' +
'</AddAudioSourceConfiguration>' +
this._envelopeFooter();
this._request({
service: 'media',
body: body,
}, function(err, data, xml) {
if (callback) {
callback.call(this, err, null, xml);
}
}.bind(this));
};

/**
* @callback Cam~AddVideoEncoderConfigurationCallback
* @property {?Error} error
* @property {null}
* @property {string} xml Raw XML response
*/

/**
* This operation adds a VideoEncoderConfiguration to an existing media profile. If a configuration exists in the media profile, it will be replaced. The change shall be persistent. A device shall support adding a compatible VideoEncoderConfiguration to a Profile containing a VideoSourceConfiguration and shall support streaming video data of such a profile.
* @param {object} options
* @param {string} options.profileToken Reference to the profile where the configuration should be added
* @param {string} options.configurationToken Contains a reference to the VideoEncoderConfiguration to add
* @param {Cam~AddVideoEncoderConfigurationCallback} callback
*/
Cam.prototype.addVideoEncoderConfiguration = function(options,callback) {
let body = this._envelopeHeader() +
'<AddVideoEncoderConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl">' +
'<ProfileToken>' + options.profileToken + '</ProfileToken>' +
'<ConfigurationToken>' + options.configurationToken + '</ConfigurationToken>' +
'</AddVideoEncoderConfiguration>' +
this._envelopeFooter();
this._request({
service: 'media',
body: body,
}, function(err, data, xml) {
if (callback) {
callback.call(this, err, null, xml);
}
}.bind(this));
};

/**
* @callback Cam~AddVideoSourceConfigurationCallback
* @property {?Error} error
* @property {null}
* @property {string} xml Raw XML response
*/

/**
* This operation adds a VideoSourceConfiguration to an existing media profile. If such a configuration exists in the media profile, it will be replaced. The change shall be persistent.
* @param {object} options
* @param {string} options.profileToken Reference to the profile where the configuration should be added
* @param {string} options.configurationToken Contains a reference to the VideoSourceConfiguration to add
* @param {Cam~AddVideoSourceConfigurationCallback} callback
*/
Cam.prototype.addVideoSourceConfiguration = function(options,callback) {
let body = this._envelopeHeader() +
'<AddVideoSourceConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl">' +
'<ProfileToken>' + options.profileToken + '</ProfileToken>' +
'<ConfigurationToken>' + options.configurationToken + '</ConfigurationToken>' +
'</AddVideoSourceConfiguration>' +
this._envelopeFooter();
this._request({
service: 'media',
body: body,
}, function(err, data, xml) {
if (callback) {
callback.call(this, err, null, xml);
}
}.bind(this));
};

/**
* @callback Cam~RemoveAudioEncoderConfigurationCallback
* @property {?Error} error
* @property {null}
* @property {string} xml Raw XML response
*/

/**
* This operation removes an AudioEncoderConfiguration from an existing media profile. If the media profile does not contain an AudioEncoderConfiguration, the operation has no effect. The removal shall be persistent.
* @param {string} profileToken Contains a reference to the media profile from which the AudioEncoderConfiguration shall be removed.
* @param {Cam~RemoveAudioEncoderConfigurationCallback} callback
*/
Cam.prototype.removeAudioEncoderConfiguration = function(profileToken,callback) {
let body = this._envelopeHeader() +
'<RemoveAudioEncoderConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl">' +
'<ProfileToken>' + profileToken + '</ProfileToken>' +
'</RemoveAudioEncoderConfiguration>' +
this._envelopeFooter();
this._request({
service: 'media',
body: body,
}, function(err, data, xml) {
if (callback) {
callback.call(this, err, null, xml);
}
}.bind(this));
};

/**
* @callback Cam~RemoveAudioSourceConfigurationCallback
* @property {?Error} error
* @property {null}
* @property {string} xml Raw XML response
*/

/**
* This operation removes an AudioSourceConfiguration from an existing media profile. If the media profile does not contain an AudioSourceConfiguration, the operation has no effect. The removal shall be persistent. Audio source configurations should only be removed after removing an AudioEncoderConfiguration from the media profile.
* @param {string} profileToken Contains a reference to the media profile from which the AudioOutputConfiguration shall be removed.
* @param {Cam~RemoveAudioSourceConfigurationCallback} callback
*/
Cam.prototype.removeAudioSourceConfiguration = function(profileToken,callback) {
let body = this._envelopeHeader() +
'<RemoveAudioSourceConfiguration xmlns="http://www.onvif.org/ver10/media/wsdl">' +
'<ProfileToken>' + profileToken + '</ProfileToken>' +
'</RemoveAudioSourceConfiguration>' +
this._envelopeFooter();
this._request({
service: 'media',
body: body,
}, function(err, data, xml) {
if (callback) {
callback.call(this, err, null, xml);
}
}.bind(this));
};

/*
Cam.prototype.getVideoEncoderConfigurationOptions = function(options, callback) {
Expand Down
49 changes: 48 additions & 1 deletion test/media.coffee
Expand Up @@ -195,7 +195,6 @@ describe 'Media', () ->
delete serverMockup.conf.bad
done()


describe 'getAudioEncoderConfiguration', () ->
it 'should return a configuration for the first token in #videoEncoderConfigurations array', (done) ->
cam.getAudioEncoderConfiguration (err, res) ->
Expand All @@ -210,6 +209,54 @@ describe 'Media', () ->
!!res[prop]
done()

describe 'addAudioEncoderConfiguration', () ->
it 'should add an AudioEncoderConfiguration to a Profile', (done) ->
cam.addAudioEncoderConfiguration {
profileToken: 'profileToken',
configurationToken: 'configurationToken',
}, (err, res) ->
assert.equal err, null
done()

describe 'addAudioSourceConfiguration', () ->
it 'should add an AudioSourceConfiguration to a Profile', (done) ->
cam.addAudioSourceConfiguration {
profileToken: 'profileToken',
configurationToken: 'configurationToken',
}, (err, res) ->
assert.equal err, null
done()

describe 'addVideoEncoderConfiguration', () ->
it 'should add a VideoEncoderConfiguration to a Profile', (done) ->
cam.addVideoEncoderConfiguration {
profileToken: 'profileToken',
configurationToken: 'configurationToken',
}, (err, res) ->
assert.equal err, null
done()

describe 'addVideoSourceConfiguration', () ->
it 'should add a VideoSourceConfiguration to a Profile', (done) ->
cam.addVideoSourceConfiguration {
profileToken: 'profileToken',
configurationToken: 'configurationToken',
}, (err, res) ->
assert.equal err, null
done()

describe 'removeAudioEncoderConfiguration', () ->
it 'should remove an AudioEncoderConfiguration from a Profile', (done) ->
cam.removeAudioEncoderConfiguration 'profileToken', (err, res) ->
assert.equal err, null
done()

describe 'removeAudioSourceConfiguration', () ->
it 'should remove an AudioSourceConfiguration from a Profile', (done) ->
cam.removeAudioSourceConfiguration 'profileToken', (err, res) ->
assert.equal err, null
done()

describe 'getMediaServiceCapabilities', () ->
it 'should return a configuration for the first token in #videoEncoderConfigurations array', (done) ->
cam.getMediaServiceCapabilities (err, res) ->
Expand Down
5 changes: 5 additions & 0 deletions test/serverMockup/media.AddAudioEncoderConfiguration.xml
@@ -0,0 +1,5 @@
<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:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
<SOAP-ENV:Body>
<tds:AddAudioEncoderConfigurationResponse></tds:AddAudioEncoderConfigurationResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
5 changes: 5 additions & 0 deletions test/serverMockup/media.AddAudioSourceConfiguration.xml
@@ -0,0 +1,5 @@
<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:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
<SOAP-ENV:Body>
<tds:AddAudioSourceConfigurationResponse></tds:AddAudioSourceConfigurationResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
5 changes: 5 additions & 0 deletions test/serverMockup/media.AddVideoEncoderConfiguration.xml
@@ -0,0 +1,5 @@
<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:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
<SOAP-ENV:Body>
<tds:AddVideoEncoderConfigurationResponse></tds:AddVideoEncoderConfigurationResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
5 changes: 5 additions & 0 deletions test/serverMockup/media.AddVideoSourceConfiguration.xml
@@ -0,0 +1,5 @@
<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:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
<SOAP-ENV:Body>
<tds:AddVideoSourceConfigurationResponse></tds:AddVideoSourceConfigurationResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
5 changes: 5 additions & 0 deletions test/serverMockup/media.RemoveAudioEncoderConfiguration.xml
@@ -0,0 +1,5 @@
<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:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
<SOAP-ENV:Body>
<tds:RemoveAudioEncoderConfigurationResponse></tds:RemoveAudioEncoderConfigurationResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

0 comments on commit 0cf06ca

Please sign in to comment.