diff --git a/lib/media.js b/lib/media.js index b3671031..ee6b6077 100644 --- a/lib/media.js +++ b/lib/media.js @@ -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() + + '' + + '' + options.profileToken + '' + + '' + options.configurationToken + '' + + '' + + 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() + + '' + + '' + options.profileToken + '' + + '' + options.configurationToken + '' + + '' + + 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() + + '' + + '' + options.profileToken + '' + + '' + options.configurationToken + '' + + '' + + 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() + + '' + + '' + options.profileToken + '' + + '' + options.configurationToken + '' + + '' + + 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() + + '' + + '' + profileToken + '' + + '' + + 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() + + '' + + '' + profileToken + '' + + '' + + 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) { diff --git a/test/media.coffee b/test/media.coffee index 174d4c4b..944d1c11 100644 --- a/test/media.coffee +++ b/test/media.coffee @@ -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) -> @@ -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) -> diff --git a/test/serverMockup/media.AddAudioEncoderConfiguration.xml b/test/serverMockup/media.AddAudioEncoderConfiguration.xml new file mode 100644 index 00000000..4d8641d5 --- /dev/null +++ b/test/serverMockup/media.AddAudioEncoderConfiguration.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/test/serverMockup/media.AddAudioSourceConfiguration.xml b/test/serverMockup/media.AddAudioSourceConfiguration.xml new file mode 100644 index 00000000..13be1dfd --- /dev/null +++ b/test/serverMockup/media.AddAudioSourceConfiguration.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/test/serverMockup/media.AddVideoEncoderConfiguration.xml b/test/serverMockup/media.AddVideoEncoderConfiguration.xml new file mode 100644 index 00000000..5a5b8c26 --- /dev/null +++ b/test/serverMockup/media.AddVideoEncoderConfiguration.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/test/serverMockup/media.AddVideoSourceConfiguration.xml b/test/serverMockup/media.AddVideoSourceConfiguration.xml new file mode 100644 index 00000000..43321853 --- /dev/null +++ b/test/serverMockup/media.AddVideoSourceConfiguration.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/test/serverMockup/media.RemoveAudioEncoderConfiguration.xml b/test/serverMockup/media.RemoveAudioEncoderConfiguration.xml new file mode 100644 index 00000000..ea6bd1aa --- /dev/null +++ b/test/serverMockup/media.RemoveAudioEncoderConfiguration.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/test/serverMockup/media.RemoveAudioSourceConfiguration.xml b/test/serverMockup/media.RemoveAudioSourceConfiguration.xml new file mode 100644 index 00000000..cfd76a3d --- /dev/null +++ b/test/serverMockup/media.RemoveAudioSourceConfiguration.xml @@ -0,0 +1,5 @@ + + + + +