Skip to content

Commit

Permalink
Merge pull request #152 from bl0ggy/add_request_getMediaServiceCapabi…
Browse files Browse the repository at this point in the history
…lities

Add new request GetServiceCapabilities for media service.
  • Loading branch information
RogerHardiman committed Feb 29, 2020
2 parents f8ee914 + 6e26662 commit f7b4bb5
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
55 changes: 55 additions & 0 deletions lib/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,4 +875,59 @@ module.exports = function(Cam) {
}
}.bind(this));
};

/**
* @typedef Cam~ProfileCapabilities
* @property {number} $.maximumNumberOfProfiles Maximum number of profiles supported.
*/

/**
* @typedef Cam~StreamCapabilities
* @property {boolean} $.RTPMulticast Indicates support for RTP multicast.
* @property {boolean} $.TRP_TCP Indicates support for RTP over TCP.
* @property {boolean} $.TRP_RTSP_TCP Indicates support for RTP/RTSP/TCP.
* @property {boolean} $.NonAggregateControl Indicates support for non aggregate RTSP control.
* @property {boolean} $.NoRTSPStreaming Indicates the device does not support live media streaming via RTSP.
*/

/**
* @typedef Cam~MediaCapabilities
* @property {boolean} $.SnapshotUri Indicates if GetSnapshotUri is supported.
* @property {boolean} $.Rotation Indicates whether or not Rotation feature is supported.
* @property {boolean} $.VideoSourceMode Indicates the support for changing video source mode.
* @property {boolean} $.OSD Indicates if OSD is supported.
* @property {boolean} $.TemporaryOSDText Indicates the support for temporary osd text configuration.
* @property {boolean} $.EXICompression Indicates the support for the Efficient XML Interchange (EXI) binary XML format.
* @property {Cam~ProfileCapabilities} profileCapabilities Media profile capabilities.
* @property {Cam~StreamCapabilities} streamCapabilities Streaming capabilities.
*/

/**
* @callback Cam~GetServiceCapabilitiesCallback
* @property {?Error} error
* @property {Cam~MediaCapabilities} mediaCapabilities The capabilities for the media service is returned in the Capabilities element.
* @property {string} xml Raw XML response
*/

/**
* Returns the capabilities of the media service. The result is returned in a typed answer.
* @param {Cam~GetServiceCapabilitiesCallback} callback
*/
Cam.prototype.getMediaServiceCapabilities = function(callback) {
this._request({
service: 'media'
, body: this._envelopeHeader() +
'<GetServiceCapabilities xmlns="http://www.onvif.org/ver10/media/wsdl" />' +
this._envelopeFooter()
}, function(err, data, xml) {
if (callback) {
if (!err) {
data = linerase(data[0].getServiceCapabilitiesResponse[0].capabilities);
this.mediaCapabilities = data;
}
callback.call(this, err, data, xml);
}
}.bind(this));
};
};
16 changes: 15 additions & 1 deletion test/media.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,18 @@ describe 'Media', () ->
assert.ok ['name', '$', 'multicast'].every (prop) ->
!!res[prop]
done()


describe 'getMediaServiceCapabilities', () ->
it 'should return a configuration for the first token in #videoEncoderConfigurations array', (done) ->
cam.getMediaServiceCapabilities (err, res) ->
assert.equal err, null
assert.deepEqual res, cam.mediaCapabilities
assert.ok ['SnapshotUri', 'Rotation', 'VideoSourceMode','OSD','TemporaryOSDText','EXICompression'].every (prop) ->
res.$.hasOwnProperty(prop)
assert.ok res.profileCapabilities
assert.ok ['MaximumNumberOfProfiles'].every (prop) ->
res.profileCapabilities.$.hasOwnProperty(prop)
assert.ok res.streamingCapabilities
assert.ok ['RTPMulticast', 'RTP_TCP', 'RTP_RTSP_TCP', 'NonAggregateControl'].every (prop) ->
res.streamingCapabilities.$.hasOwnProperty(prop)
done()
11 changes: 11 additions & 0 deletions test/serverMockup/media.GetServiceCapabilities.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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: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>
<trt:GetServiceCapabilitiesResponse>
<trt:Capabilities SnapshotUri="true" Rotation="false" VideoSourceMode="false" OSD="true" TemporaryOSDText="true" EXICompression="false">
<trt:ProfileCapabilities MaximumNumberOfProfiles="10"/>
<trt:StreamingCapabilities RTPMulticast="true" RTP_TCP="true" RTP_RTSP_TCP="true" NonAggregateControl="false" NoRTSPStreaming="false"/>
</trt:Capabilities>
</trt:GetServiceCapabilitiesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

0 comments on commit f7b4bb5

Please sign in to comment.