The node-onvif is a Node.js module which allows you to communicate with the network camera which supports the ONVIF specifications.
The ONVIF (Open Network Video Interface) is an open industry forum promoting and developing global standards for interfaces of IP-based physical security products such as network cameras. The ONVIF specifications are available in their web site.
Recently, most of network cameras for business support the ONVIF standard. Furthermore, some network cameras for home support it though the implementation is partial. The node-onvif allows you to control network cameras which implement the ONVIF standard.
The node-onvif provides you with the APIs as follows:
- Discovery the ONVIF network cameras
- Access some services supported by the ONVIF network cameras as follows:
- Device Management Service
- Media Service
- PTZ Service
Besides, the node-onvif provides you with simple APIs that allow you to control ONVIF network cameras easily even if you are not familiar with the ONVIF specifications.
$ npm install xml2js
$ npm install html
$ npm install node-onvif
This package includes a sample application "ONVIF Network Camera Manager". You can try this module with your PTZ ONVIF network camera easily.
- Quick Start
Onvif
objectOnvifDevice
object- ONVIF commands
OnvifServiceDevice
objectgetCapabilities(callback)
methodgetWsdlUrl(callback)
methodgetDiscoveryMode(callback)
methodgetScopes(callback)
methodsetScopes(params, callback)
methodaddScopes(params, callback)
methodremoveScopes(params, callback)
methodgetHostname(callback)
methodsetHostname(params, callback)
methodgetDNS(callback)
methodsetDNS(params, callback)
methodgetNetworkInterfaces(callback)
methodgetNetworkProtocols(callback)
methodsetNetworkProtocols(params, callback)
methodgetNetworkDefaultGateway(callback)
methodsetNetworkDefaultGateway(params, callback)
methodgetDeviceInformation(callback)
methodgetSystemDateAndTime(callback)
methodreboot(callback)
methodgetUsers(callback)
methodcreateUsers(params, callback)
methoddeleteUsers(params, callback)
methodsetUser(params, callback)
methodgetRelayOutputs(callback)
methodgetNTP(callback)
methodsetNTP(params, callback)
methodgetDynamicDNS(callback)
methodgetZeroConfiguration(callback)
methodgetServices(params, callback)
methodgetServiceCapabilities(callback)
method
OnvifServiceMedia
objectgetStreamUri(params, callback)
methodgetVideoEncoderConfigurations(callback)
methodgetVideoEncoderConfiguration(params, callback)
methodgetCompatibleVideoEncoderConfigurations(params, callback)
methodgetVideoEncoderConfigurationOptions(params, callback)
methodgetGuaranteedNumberOfVideoEncoderInstances(params, callback)
methodgetProfiles(callback)
methodgetProfile(params, callback)
methodcreateProfile(params, callback)
methoddeleteProfile(params, callback)
methodgetVideoSources(callback)
methodgetVideoSourceConfiguration(params, callback)
methodgetVideoSourceConfigurations(callback)
methodgetCompatibleVideoSourceConfigurations(params, callback)
methodgetVideoSourceConfigurationOptions(params, callback)
methodgetMetadataConfiguration(params, callback)
methodgetMetadataConfigurations(callback)
methodgetCompatibleMetadataConfigurations(params, callback)
methodgetMetadataConfigurationOptions(params, callback)
methodgetAudioSources(callback)
methodgetAudioSourceConfiguration(params, callback)
methodgetAudioSourceConfigurations(callback)
methodgetCompatibleAudioSourceConfigurations(params, callback)
methodgetAudioSourceConfigurationOptions(params, callback)
methodgetAudioEncoderConfiguration(params, callback)
methodgetAudioEncoderConfigurations(callback)
methodgetCompatibleAudioEncoderConfigurations(params, callback)
methodgetAudioEncoderConfigurationOptions(params, callback)
methodgetSnapshotUri(params, callback)
method
OnvifServicePtz
objectgetNodes(*callback*)
methodgetNode(*params, callback*)
methodgetConfigurations(*callback*)
methodgetConfiguration(*params, callback*)
methodgetConfigurationOptions(*params, callback*)
methodgetStatus(*params, callback*)
methodcontinuousMove(*params, callback*)
methodabsoluteMove(*params, callback*)
methodrelativeMove(*params, callback*)
methodstop(*params, callback*)
methodgotoHomePosition(*params, callback*)
methodsetHomePosition(*params, callback*)
methodsetPreset(*params, callback*)
methodgetPresets(*params, callback*)
methodgotoPreset(*params, callback*)
methodremovePreset(*params, callback*)
method
- References
- License
This section shows how to discover ONVIF network cameras, how to get the device information, and how to control the PTZ of the device.
This sample code shows how to discover ONVIF network cameras.
var onvif = require('node-onvif');
console.log('Start the discovery process.');
// Find the ONVIF network cameras
onvif.startDiscovery((info) => {
// Show the device name and the URL of the end point
console.log('- ' + info.urn);
console.log(' - ' + info.name);
console.log(' - ' + info.xaddrs[0]);
});
// Stop the discovery process in 3 seconds
setTimeout(() => {
onvif.stopDiscovery(() => {
console.log('Stopped the discovery process.');
process.exit();
});
}, 3000);
The code above will output the result like this:
Start the discovery process.
- urn:uuid:4d454930-0000-1000-8000-bcc34217e292
- Panasonic BB-SC384B
- http://192.168.10.17/onvif/device_service
- urn:uuid:812b12f7-45a0-11b5-8404-c056e3a2e020
- Vstarcam
- http://192.168.10.14:10080/onvif/device_service
- urn:uuid:6b2be733-6ad1-4467-8bd0-747bd8efd206
- Avantgarde-Test
- http://192.168.10.22:36000/onvif/device_service
Stopped the discovery process.
The most important information for controlling the device is the URL of the end point of the device. You can get the URL from the code info.xaddrs[0]
above.
In order to control the ONVIF network camera, you have to create an OnfivDevice
object for the device. This sample code shows how to create an OnvifDevice
object and get the detailed information of the device.
var onvif = require('node-onvif');
// Create an OnvifDevice object
var device = new onvif.OnvifDevice({
xaddr: 'http://192.168.10.14:10080/onvif/device_service',
user : 'admin',
pass : '123456'
});
// Initialize the OnvifDevice object
device.init((error) => {
if(error) {
console.log('[ERROR] ' + error.message);
} else {
// Get the detailed device information
var device_info = device.getInformation();
// Show the result
console.log(JSON.stringify(device_info, null, ' '));
}
});
The code above will output the result like this:
{
"Manufacturer": "Vstarcam",
"Model": "Hi3518eV100",
"FirmwareVersion": "2.4",
"SerialNumber": "3056894",
"HardwareId": "1.0"
}
This sample code shows how to get the UDP stream URL.
var onvif = require('node-onvif');
// Create an OnvifDevice object
var device = new onvif.OnvifDevice({
xaddr: 'http://192.168.10.14:10080/onvif/device_service',
user : 'admin',
pass : '123456'
});
// Initialize the OnvifDevice object
device.init((error) => {
if(error) {
console.log('[ERROR] ' + error.message);
} else {
// Get the UDP stream URL
var url = device.getUdpStreamUrl();
console.log(url);
}
});
The code above will output the result like this:
rtsp://192.168.10.14:10554/tcp/av0_0
This sample code shows how to get the data of the snapshot and save it to a file.
var onvif = require('node-onvif');
var fs = require('fs');
// Create an OnvifDevice object
var device = new onvif.OnvifDevice({
xaddr: 'http://192.168.10.14:10080/onvif/device_service',
user : 'admin',
pass : '123456'
});
// Initialize the OnvifDevice object
device.init((error) => {
if(error) {
console.log('[ERROR] ' + error.message);
return;
}
// Get the data of the snapshot
console.log('fetching the data of the snapshot...');
device.fetchSnapshot((error, res) => {
if(error) {
console.log(error.message);
return;
}
// Save the data to a file
fs.writeFile('snapshot.jpg', res.body, function (error) {
if(error) {
console.log(error.message);
} else {
console.log('Done!');
}
});
});
});
The code above will output the result like this:
fetching the data of the snapshot...
Done!
You will find a JPEG file named snapshot.jpg
in the current directory.
This sample code shows how to pan, tilt, and zoom the ONVIF network camera.
var onvif = require('node-onvif');
// Create an OnvifDevice object
var device = new onvif.OnvifDevice({
xaddr: 'http://192.168.10.14:10080/onvif/device_service',
user : 'admin',
pass : '123456'
});
// Initialize the OnvifDevice object
device.init((error) => {
if(error) {
console.log('[ERROR] ' + error.message);
return;
}
// Create the parameters
var params = {
'speed': {
x: 1.0, // Speed of pan (in the range of 0 to 1.0)
y: 0.0, // Speed of tilt (in the range of 0 to 1.0)
z: 0.0 // Speed of zoom (in the range of 0 to 1.0)
},
'timeout': 1 // seconds
};
// Move the camera
device.ptzMove(params, (error) => {
if(error) {
console.log(error.message);
} else {
console.log('Done!');
}
});
});
If this code has been successfully finished, you could find that the camera turns to the right for a second at the highest speed.
In order to use the node-onvif module, you have to load the node-onvif module as follows:
var onvif = require('node-onvif');
The variable onvif
in the code above is the Onvif
object.
This section describes the methods implemented in the Onvif
object.
This method starts the discovery process and tries to find the ONVIF network camera devices. Whenever an ONVIF network camera device is found, the callback
function specified to the 1st argument will be called.
When a device is found, the callback
will be passed a hash object as the 1st argument. The properties set to the hash object are as follows:
Property | Type | Description |
---|---|---|
urn |
String | The URN (Uniform Resource Name) assigned to the device (e.g., "urn:uuid:6b2be733-6ad1-4467-8bd0-747bd8efd206") |
name |
String | The product name of the device (e.g., "Panasonic BB-SC384B"). |
hardware |
String | The description of the hardware of the device (e.g., "BB-SC384B"). |
location |
String | The physical location of the device (e.g., "China", "shenzhen", "office"). |
types |
Array | The list of types supported by the device (e.g., "dn:NetworkVideoTransmitter", "tds:Device"). Basically, this module is for "dn:NetworkVideoTransmitter". |
xaddrs |
Array | The list of URLs of the end points (e.g., "http://192.168.10.17/onvif/device_service", "http://[2408:12:2e20:d000:bec3:42ff:fe17:e292]/onvif/device_service"). |
scopes |
Array | The list of scopes set to the device (e.g., "onvif://www.onvif.org/Profile/Streaming", "onvif://www.onvif.org/location/office"). |
The sample code below shows the structure of the hash object representing the found device.
var onvif = require('node-onvif');
// Find the ONVIF network cameras
onvif.startDiscovery((info) => {
// Show the information of the found device
console.log(JSON.stringify(info, null, ' '));
});
The code above will output the result like this:
{
"urn": "urn:uuid:4d454930-0000-1000-8000-bcc34217e292",
"name": "Panasonic BB-SC384B",
"hardware": "BB-SC384B",
"location": "office",
"types": [
"dn:NetworkVideoTransmitter",
"tds:Device"
],
"xaddrs": [
"http://192.168.10.17/onvif/device_service",
"http://[2408:12:2e20:d000:bec3:42ff:fe17:e292]/onvif/device_service"
],
"scopes": [
"onvif://www.onvif.org/Profile/Streaming",
"onvif://www.onvif.org/hardware/BB-SC384B",
"onvif://www.onvif.org/location/office",
"onvif://www.onvif.org/name/Panasonic_BB-SC384B",
""
]
}
This method stops the discovery process asynchronously. If you want to do something waiting for stopping the discovery process successfully, you can pass a callback function to this method as the 1st argument.
var onvif = require('node-onvif');
// Start the discovery process
onvif.startDiscovery((info) => {
// Do something
});
// Stop the discovery process in 3 seconds
setTimeout(() => {
onvif.stopDiscovery(() => {
// If you want to do something after stopping
// the discovery process successfully, write
// codes here.
});
}, 3000);
If you don't need to do anything after the discovery process has been terminated successfully, you can do this:
onvif.stopDiscovery();
The OnvifDevice
object represents an ONVIF network camera device. You can control the ONVIF network camera through this object.
In order to control an ONVIF network camera, you have to create an OnvifDevice
object from the OnvifDevice
constructor by yourself as follows:
var onvif = require('node-onvif');
// Create an OnvifDevice object
var device = new onvif.OnvifDevice({
xaddr: 'http://192.168.10.14:10080/onvif/device_service',
user : 'admin',
pass : '123456'
});
The variable device
represents an OnvifDevice
object in the code above. The OnvifDevice
constructor requires a hash object consisting of some properties as follows:
Property | Type | Required | Description |
---|---|---|---|
xaddr |
String | required | URL of the end point of the targeted device. |
user |
String | optional | User name for the user authentication. |
pass |
String | optional | Password for the user authentication. |
If you know the value of the xaddr
property (the URL of the end point of the targeted device) in advance, you don't need to run the discover process(i.e., you don't need to call the startDiscovery()
method).
The OnvifDevice
object provides some properties as follows:
Property | Type | Description | |
---|---|---|---|
services |
Object |
| `device` | Object | [`OnvifServiceDevice`](#OnvifServiceDevice-object) object
| `media` | Object | [`OnvifServiceMedia`](#OnvifServiceMedia-object) object
| `ptz` | Object | [`OnvifServicePtz`](#OnvifServicePtz-object) object
See the section "ONVIF commands" for details.
This method Initializes the OnvifDevice
object. This method must be called before you control the targeted device. Actually, this method retrieves several information essential to control the device from the device.
var onvif = require('node-onvif');
// Create an OnvifDevice object
var device = new onvif.OnvifDevice({
xaddr: 'http://192.168.10.14:10080/onvif/device_service',
user : 'admin',
pass : '888888'
});
// Initialize the OnvifDevice object
device.init((error) => {
if(error) {
console.log('[ERROR] ' + error.message);
} else {
console.log('The OnvifDevice object has been initialized successfully.')
// Do something.
}
});
This method is executed asynchronously. The process of this method takes a little time to be completed because this method sends several commands to the targeted device and waits for the all relevant responses. Though the callback function is optional, you have to wait for the completion of this method to control the device. Therefore, the code below will doesn't work well:
// Never do this
device.init();
var info = device.getInformation();
...
Instead, do this:
device.init((error) => {
if(!error) {
var info = device.getInformation();
...
}
});
This method returns a hash object consisting of several device information as follow:
Property | Type | Description |
---|---|---|
Manufacturer |
String | The manufactor of the device. |
Model |
String | The device model. |
FirmwareVersion |
String | The firmware version in the device. |
SerialNumber |
String | The serial number of the device. |
HardwareId |
String | The hardware ID of the device. |
var info = device.getInformation();
console.log(JSON.stringify(info, null, ' '));
The code above will output the result like this:
{
"Manufacturer": "Vstarcam",
"Model": "Hi3518eV100",
"FirmwareVersion": "2.4",
"SerialNumber": "3056894",
"HardwareId": "1.0"
}
The ONVIF network cameras have several profiles by default. The profile is a set of configuration values such as the resolution of the video encoder, the URL of the snapshot, the URL of the video stream, the range of PTZ, and so on.
The OnvifDevice
object is sure to select one of them and each method implemented in the OnvifDevice
object is executed using the selected profile. By default, the OnvifDevice
object selects the profile found first in the initialization process.
This method returns a hash object containing the information of the profile currently selected by the OnvifDevice
object.
var profile = device.getCurrentProfile();
console.log(JSON.stringify(profile, null, ' '));
The code above will output the result like this:
{
"token": "PROFILE_000",
"name": "PROFILE_000",
"snapshot": "http://192.168.10.14:81/snapshot.cgi",
"stream": {
"udp": "rtsp://192.168.10.14:10554/tcp/av0_0",
"http": "rtsp://192.168.10.14:10554/tcp/av0_0",
"rtsp": "rtsp://192.168.10.14:10554/tcp/av0_0"
},
"video": {
"source": {
"token": "V_SRC_000",
"name": "V_SRC_000",
"bounds": {
"width": 1280,
"height": 720,
"x": 0,
"y": 0
}
},
"encoder": {
"token": "V_ENC_000",
"name": "V_ENC_000",
"resolution": {
"width": 1280,
"height": 720
},
"quality": 4,
"framerate": 25,
"bitrate": 2048,
"encoding": "H264"
}
},
"audio": {
"source": {
"token": "A_SRC_000",
"name": "A_SRC_000"
},
"encoder": {
"token": "A_ENC_000",
"name": "A_ENC_000",
"bitrate": 64,
"samplerate": 8,
"encoding": "G711"
}
},
"ptz": {
"range": {
"x": {
"min": -1,
"max": 1
},
"y": {
"min": -1,
"max": 1
},
"z": {
"min": 0,
"max": 1
}
}
}
}
This method returns a list of the profiles set to the device as an Array object. Each element in the Array object is a hash object whose structure is as same as the hash object which can be retrieved by the getCurrentProfile()
method.
See the section "changeProfile()
method" for details.
This method changes the current profile to the profile corresponding to the index
specified as the 1st argument, then returns a hash object representing the newly selected profile. The index
is the position in the profile list which can be obtained through the getProfileList()
method, which is in the range of 0 to the length of the list minus 1.
The sample code below shows how to change the current profile to the profile whose video resolution is the smallest:
// Get the current profile
var profile = device.getCurrentProfile();
// Show the video resolution of the current profile
var reso = profile['video']['encoder']['resolution'];
console.log('- Before: ' + reso['width'] + ' x ' + reso['height']);
// Get a list of the profiles set in the device
var profile_list = device.getProfileList();
// Find the profile whose video resolution is the smallest
var min_square = 4000 * 2000;
var min_index = 0;
for(var i=0; i<profile_list.length; i++) {
var resolution = profile_list[i]['video']['encoder']['resolution'];
var square = resolution['width'] * resolution['height'];
if(square < min_square) {
min_square = square;
min_index = i;
}
}
// Change the current profile
profile = device.changeProfile(min_index);
// Show the video resolution
reso = profile['video']['encoder']['resolution'];
console.log('- After: ' + reso['width'] + ' x ' + reso['height']);
This sample code will output the result like this:
- Before: 1280 x 720
- After: 320 x 180
This method returns the UDP Stream URL. Though the URL can be obtained from the result of the getCurrentProfile()
method as well, this method makes that easy.
var url = device.getUdpStreamUrl();
console.log(url);
The code above will output the result like this:
rtsp://192.168.10.14:10554/tcp/av0_0
This method fetches a snapshot captured by the camera at the time. The snapshot is obtained as a Buffer
object representing the image data of the snapshot.
As the snapshot is obtained asynchronously, a callback function has to be passed to this method as the 1st argument.
If an error occurs, an Error
object is passed to the callback function as the 1st argument. If the snapshot is captured successfully, a hash object is passed to the callback function as the 2nd argument. The hash object consists of some properties as follows:
Property | Type | Description |
---|---|---|
headers |
Object | headers object representing the HTTP response header. This object is of the http module of Node.js. |
body |
Object | Buffer object representing the image data of the snapshot. |
The code blow shows how to get the snapshot and save it as an image file:
device.fetchSnapshot((error, res) => {
if(error) {
console.log(error.message);
return;
}
// Determine the file extention
var ext = 'bin';
var mime_pair = res.headers['content-type'].split('/');
if(mime_pair[0] === 'image') {
ext = mime_pair[1];
}
// Save the data to a file
var fname = 'snapshot.' + ext;
fs.writeFile(fname, res.body, function (error) {
if(error) {
console.log(error.message);
} else {
console.log('Done!');
}
});
});
This method pans, tilts, zooms the camera if the ONVIF network camera supports the PTZ service. 2 arguments have to be passed to this method: the 1st argument is a hash object, the 2nd argument is a callback function.
The structure of the hash object to be passed as the 1st argument is as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
speed |
Object | required |
| `x` | Float | required | Speed of pan in the range of -1.0 to 1.0.
| `y` | Float | required | Speed of tilt in the range of -1.0 to 1.0.
| `z` | Float | required | Speed of zoom in the range of -1.0 to 1.0.
timeout
| | Integer | optional | Timeout in seconds (Default: 1)
The speed.x
represents the speed of horizontal movement of the camera. If the value of the speed.x
is positive, the camera will turn to the right. If the value is negative, the camera will turn to the left. If the value is zero, the camera won't move in a horizontal direction.
The speed.y
represents the speed of vertical movement of the camera. If the value of the speed.y
is positive, the camera will turn to the top. If the value is negative, the camera will turn to the bottom. If the value is zero, the camera won't move in a vertical direction.
The speed.z
represents the speed of the zoom of the camera. If the value of the speed.z
is positive, the camera will zoom in. If the value is negative, the camera will zoom out. if the value is zero, the camera won't zoom.
// Create the parameters
var params = {
'speed': {
x: 1.0, // Speed of pan (in the range of -1.0 to 1.0)
y: 0.0, // Speed of tilt (in the range of -1.0 to 1.0)
z: 0.0 // Speed of zoom (in the range of -1.0 to 1.0)
},
'timeout': 1 // seconds
};
// Move the camera
device.ptzMove(params, (error) => {
if(error) {
console.log(error.message);
} else {
console.log('Done!');
}
});
This method stops the movement of the camera caused by the ptzMove()
method.
// Create the parameters
var params = {
'speed': {x: 0.5, y: 0.0, z: 0.0},
'timeout': 60 // seconds
};
// Supposed to move the camera for 60 seconds
device.ptzMove(params, (error) => {
if(error) {
console.log(error.message);
} else {
console.log('Succeeded to move.');
}
});
// Stop to the PTZ in 2 seconds
setTimeout(() => {
device.ptzStop((error) => {
if(error) {
console.log(error.message);
} else {
console.log('Succeeded to stop.');
}
})
}, 2000);
Note that the all sections below are for those who are familiar with the ONVIF specifications.
The ONVIF specifications define a lot of SOAP-based commands. This module implements part of the commands. Actually, most of the methods described in the previous sections are implemented using the methods representing the commands described the sections below.
The methods for the ONVIF commands are exposed in the OnvifServiceDevice
object, the OnvifServiceMedia
object, and OnvifServicePtz
object, which are available from the OnvifDevice.device
property, the OnvifDevice.media
property, and the OnvifDevice.ptz
property, respectively.
For example, if you want to call the GotoHomePosition
command, you can use the gotoHomePosition
method implemented in the OnvifServicePtz
object like this:
// Create a OnvifDevice object
var device = new onvif.OnvifDevice({
xaddr: 'http://192.168.10.14:10080/onvif/device_service',
user : 'admin',
pass : '123456'
});
// Initialize the OnvifDevice object
device.init((error) => {
if(error) {
console.log('[ERROR] ' + error.message);
return;
}
// The OnvifServicePtz object
var ptz = device.services.ptz;
if(ptz) {
// The parameters for the gotoHomePosition() method
var profile = device.getCurrentProfile();
var params = {
'ProfileToken': profile['token'],
'Speed' : 1
};
// Send the GotoHomePosition command using the gotoHomePosition() method
ptz.gotoHomePosition(params, (error, result) => {
if(error) {
console.log('[ERROR] ' + error.message);
} else {
console.log(JSON.stringify(result.data, null, ' '));
}
});
} else {
console.log('[ERROR] Your ONVIF network camera does not support the PTZ service.');
}
});
The code above will output the result like this:
{
"GotoHomePositionResponse": {
"$": {
"xmlns": "http://www.onvif.org/ver20/ptz/wsdl"
}
}
}
Actually, the response from the targeted ONVIF network camera is SOAP. This module provides some representations of the response. the variable result
in the code above consists of some properties as follows:
Property | Type | Description |
---|---|---|
soap |
String | Raw SOAP response |
formatted |
String | Formatted SOAP response in order to be human readable |
converted |
Object | JavaScript object converted from SOAP response by xml2js module |
data |
Object | JavaScript object converted from the data in the <Body> element in the SOAP response |
In most cases, only data
property would be enough. If you need to evaluate the response in more detail, you can use the preferable property other than the data
property.
The value of the soap
property would be:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns: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:rpc="http://www.w3.org/2003/05/soap-rpc" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema"><env:Body><GotoHomePositionResponse xmlns="http://www.onvif.org/ver20/ptz/wsdl"></GotoHomePositionResponse></env:Body></env:Envelope>
The value of the formatted
property would be:
<?xml version="1.0" encoding="UTF-8" ?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns: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:rpc="http://www.w3.org/2003/05/soap-rpc" xmlns:xop="http://www.w3.org/2004/08/xop/include"
xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema">
<env:Body>
<GotoHomePositionResponse xmlns="http://www.onvif.org/ver20/ptz/wsdl"></GotoHomePositionResponse>
</env:Body>
</env:Envelope>
The value of the converted
property would be:
{
"$": {
"xmlns:env": "http://www.w3.org/2003/05/soap-envelope",
"xmlns: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:rpc": "http://www.w3.org/2003/05/soap-rpc",
"xmlns:xop": "http://www.w3.org/2004/08/xop/include",
"xmlns:tptz": "http://www.onvif.org/ver20/ptz/wsdl",
"xmlns:tt": "http://www.onvif.org/ver10/schema"
},
"Body": {
"GotoHomePositionResponse": {
"$": {
"xmlns": "http://www.onvif.org/ver20/ptz/wsdl"
}
}
}
}
All methods representing the ONVIF commands return the same structured object as one described above. So in the description for each methods described in the sections below, only parameters to be passed to the method are listed.
Note that the first character of the method name implemented in this module is lower case though the corresponding letter of the ONVIF command name is upper case. For example, the ContinuousMove
command specified in the ONVIF specification corresponds to the continuousMove
method implemented in the OnvifServicePtz
object.
This object represents the ONVIF Device Management Service.
This method sends a GetCapabilities
command.
This method sends a GetWsdlUrl
command.
This method sends a GetDiscoveryMode
command.
This method sends a GetScopes
command.
This method sends a SetScopes
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
Scopes |
Array | required | a list of URI |
The code below shows how to set some scopes:
var params = {
'Scopes': [
'onvif://www.onvif.org/location/town/Nerima',
'onvif://www.onvif.org/location/city/Tokyo'
]
};
device.services.device.setScopes(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
If you want to delete all configurable scopes, specify an empty Array
object as the Scope
property:
var params = {'Scopes': []}
This method sends a AddScopes
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
Scopes |
Array | required | a list of URI |
The code below shows how to set some scopes:
var params = {
'Scopes': [
'onvif://www.onvif.org/location/town/Nerima',
'onvif://www.onvif.org/location/city/Tokyo'
]
};
device.services.device.addScopes(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a RemoveScopes
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
Scopes |
Array | required | a list of URI |
The code below shows how to set some scopes:
var params = {
'Scopes': [
'onvif://www.onvif.org/location/town/Nerima',
'onvif://www.onvif.org/location/city/Tokyo'
]
};
device.services.device.removeScopes(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetHostname
command.
This method sends a SetHostname
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
Name |
String | required | a host name |
The code below shows how to set some scopes:
var params = {
'Name': 'cam001'
};
device.services.device.setHostname(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetDNS
command.
This method sends a SetDNS
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
FromDHCP |
boolean | required | true or false | |
SearchDomain |
Array | optional | a list of search domains | |
DNSManual |
Array | optional | a list of DNS addresses |
| `Type` | String | required | "IPv4" or "IPv6"
| `IPv4Address` | String | optional | IPv4 address
| `IPv6Address` | String | optional | IPv6 address
var params = {
'FromDHCP' : false,
'SearchDomain': ['example.jp'],
'DNSManual' : [
{'Type': 'IPv4', 'IPv4Address': '192.168.10.1'}
]
};
device.services.device.setDNS(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetNetworkProtocols
command.
This method sends a GetNetworkProtocols
command.
This method sends a SetNetworkProtocols
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
NetworkProtocols |
Array | required |
| `Name` | String | required |
| `Enabled` | Boolean | optional |
| `Port` | Integer | optional |
var params = {
'NetworkProtocols': [
{'Name': 'HTTP', 'Enabled': true, 'Port': 80},
{'Name': 'RTSP', 'Enabled': true, 'Port': 554}
]
};
device.services.device.setNetworkProtocols(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetNetworkDefaultGateway
command.
This method sends a SetNetworkDefaultGateway
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
NetworkGateway |
Array | required | a list of IP addresses of gateways |
var params = {
'NetworkGateway': [
{'IPv4Address': '192.168.10.1'}
]
};
device.services.device.setNetworkDefaultGateway(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetDeviceInformation
command.
This method sends a GetSystemDateAndTime
command.
This method sends a Reboot
command.
This method sends a GetUsers
command.
This method sends a CreateUsers
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
User |
Array | required | a list of users |
| `Username` | String | required | Username
| `Password` | String | required | Password
| `UserLevel` | String | required | Either "Administrator", "Operator", "User", or "Anonymous"
var params = {
'User' : [
{'Username': 'test1', 'Password' : 'password', 'UserLevel': 'Administrator'},
{'Username': 'test2', 'Password' : 'password', 'UserLevel': 'Operator'},
{'Username': 'test3', 'Password' : 'password', 'UserLevel': 'User'}
]
};
device.services.device.createUsers(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a DeleteUsers
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
User |
Array | required | a list of users |
| `Username` | String | required | Username
var params = {
'User' : [
{'Username': 'test1'},
{'Username': 'test2'},
{'Username': 'test3'}
]
};
device.services.device.deleteUsers(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a SetUser
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
User |
Array | required | a list of users |
| `Username` | String | required | Username
| `Password` | String | required | Password
| `UserLevel` | String | required | Either "Administrator", "Operator", "User", or "Anonymous"
var params = {
'User' : [
{'Username': 'test1', 'Password' : 'password', 'UserLevel': 'Administrator'},
{'Username': 'test2', 'Password' : 'password', 'UserLevel': 'Operator'},
{'Username': 'test3', 'Password' : 'password', 'UserLevel': 'User'}
]
};
device.services.device.setUser(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a RetRelayOutputs
command.
This method sends a GetNTP
command.
This method sends a SetNTP
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
FromDHCP |
Boolean | required | true or false | |
NTPManual |
Object | optional |
| `Type` | String | required | "IPv4" or "IPv6"
| `IPv4Address` | String | optional | IPv4 address
| `IPv6Address` | String | optional | IPv6 address
var params = {
'FromDHCP': false,
'NTPManual': {'Type': "IPv4", 'IPv4Address': '192.168.10.1'}
};
device.services.device.setNTP(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetDynamicDNS
command.
This method sends a GetZeroConfiguration
command.
This method sends a GetServices
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
IncludeCapability |
Boolean | required | true or false |
var params = {
'IncludeCapability': true
};
device.services.device.getServices(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetServiceCapabilities
command.
This object represents the ONVIF Media Service.
This method sends a GetStreamUri
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
Protocol |
String | required | "UDP", "HTTP", or "RTSP" |
var params = {
'ProfileToken': '2_def_profile6',
'Protocol': 'UDP',
};
device.services.media.getStreamUri(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetVideoEncoderConfigurations
command.
This method sends a GetVideoEncoderConfiguration
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ConfigurationToken |
String | required | a token of the configurationToken |
var params = {
'ConfigurationToken': '2_def_conf6'
};
device.services.media.getVideoEncoderConfiguration(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetCompatibleVideoEncoderConfigurations
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
var params = {
'ProfileToken': '2_def_profile6',
};
device.services.media.getCompatibleVideoEncoderConfigurations(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetVideoEncoderConfigurationOptions
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | optional | a token of the profile |
ConfigurationToken |
String | optional | a token of the configuration |
var params = {
'ProfileToken': '2_def_profile6',
'ConfigurationToken': '2_def_conf6'
};
device.services.media.getVideoEncoderConfigurationOptions(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetGuaranteedNumberOfVideoEncoderInstances
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ConfigurationToken |
String | required | a token of the configuration |
var params = {
'ConfigurationToken': '2_def_conf6',
};
device.services.media.getGuaranteedNumberOfVideoEncoderInstances(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetProfiles
command.
This method sends a GetProfile
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
var params = {
'ProfileToken': '2_def_profile6'
};
device.services.media.getProfile(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a CreateProfile
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
Name |
String | required | a name of the profile |
Token |
String | optional | a token of the profile |
var params = {
'Name': 'TestProfile1',
'Token': 'TestProfile1'
};
device.services.media.createProfile(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a DeleteProfile
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
Token |
String | required | a token of the profile |
var params = {
'ProfileToken': 'TestProfile1'
};
device.services.media.deleteProfile(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetVideoSources
command.
This method sends a GetVideoSourceConfiguration
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ConfigurationToken |
String | required | a token of the configuration |
var params = {
'ConfigurationToken': '2_def_conf6'
};
device.services.media.getVideoSourceConfiguration(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetVideoSourceConfigurations
command.
This method sends a GetCompatibleVideoSourceConfigurations
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
Token |
String | required | a token of the profile |
var params = {
'ProfileToken': '2_def_profile6'
};
device.services.media.getCompatibleVideoSourceConfigurations(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetVideoSourceConfigurationOptions
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | optional | a token of the profile |
ConfigurationToken |
String | optional | a token of the configuration |
var params = {
'ProfileToken': '2_def_profile6',
'ConfigurationToken': '2_def_conf6'
};
device.services.media.getVideoSourceConfigurationOptions(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetMetadataConfiguration
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ConfigurationToken |
String | required | a token of the configuration |
var params = {
'ConfigurationToken': 'metadata1',
};
device.services.media.getMetadataConfiguration(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetMetadataConfigurations
command.
This method sends a GetCompatibleMetadataConfigurations
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
var params = {
'ProfileToken': '2_def_profile6'
};
device.services.media.getCompatibleMetadataConfigurations(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetMetadataConfigurationOptions
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | optional | a token of the profile |
ConfigurationToken |
String | optional | a token of the configuration |
var params = {
'ProfileToken': '2_def_profile6',
'ConfigurationToken': 'Conf001'
};
device.services.media.getMetadataConfigurationOptions(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetAudioSources
command.
This method sends a GetAudioSourceConfiguration
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ConfigurationToken |
String | required | a token of the configuration |
var params = {
'ConfigurationToken': 'AudioSourceConfig',
};
device.services.media.getAudioSourceConfiguration(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetAudioSourceConfigurations
command.
This method sends a GetCompatibleAudioSourceConfigurations
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
var params = {
'ProfileToken': '2_def_profile6'
};
device.services.media.getCompatibleAudioSourceConfigurations(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetAudioSourceConfigurationOptions
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | optional | a token of the profile |
ConfigurationToken |
String | optional | a token of the configuration |
var params = {
'ConfigurationToken': 'AudioSourceConfig'
};
device.services.media.getAudioSourceConfigurationOptions(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetAudioEncoderConfiguration
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ConfigurationToken |
String | required | a token of the configuration |
var params = {
'ConfigurationToken': 'AudioSourceConfig'
};
device.services.media.getAudioEncoderConfiguration(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetAudioEncoderConfigurations
command.
This method sends a GetCompatibleAudioEncoderConfigurations
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
var params = {
'ProfileToken': '2_def_profile6'
};
device.services.media.getCompatibleAudioEncoderConfigurations(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetAudioEncoderConfigurationOptions
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | optional | a token of the profile |
ConfigurationToken |
String | optional | a token of the configuration |
var params = {
'ProfileToken': '2_def_profile6',
'ConfigurationToken': 'AudioSourceConfig'
};
device.services.media.getAudioEncoderConfigurationOptions(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a getSnapshotUri
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
var params = {
'ProfileToken': '2_def_profile6'
};
device.services.media.getSnapshotUri(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This object represents the ONVIF PTZ Service.
This method sends a getNodes
command.
This method sends a GetNode
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
NodeToken |
String | required | a token of the node |
var params = {
'NodeToken': 'PtzNode'
};
device.services.ptz.getNode(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetConfigurations
command.
This method sends a GetConfiguration
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ConfigurationToken |
String | required | a token of the targeted PTZ node |
var params = {
'ConfigurationToken': 'PtzConf1'
};
device.services.ptz.getConfiguration(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetConfigurationOptions
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ConfigurationToken |
String | required | a token of the targeted PTZ node |
var params = {
'ConfigurationToken': 'PtzConf1'
};
device.services.ptz.getConfigurationOptions(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
### <a name="OnvifServicePtz-getStatus-method">getStatus(*params, callback*) method</a>
This method sends a `GetStatus` command. The 1st argument `params` must be a hash object consisting of the properties as follows:
Property | Type | Required |Description
:--------------------|:--------|:---------|:----------
`ProfileToken` | String | required | a token of the targeted PTZ node
```JavaScript
var params = {
'ProfileToken': 'PtzConf1'
};
device.services.ptz.getStatus(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
### <a name="OnvifServicePtz-continuousMove-method">continuousMove(*params, callback*) method</a>
This method sends a `ContinuousMove` command. The 1st argument `params` must be a hash object consisting of the properties as follows:
Property | | Type | Required |Description
:--------------|:----|:---------|:---------|:----------
`ProfileToken` | | String | required | a token of the profile
`Velocity` | | Object | required |
| `x` | Float | required | Speed of pan (in the range of -1.0 to 1.0)
| `y` | Float | required | Speed of tilt (in the range of -1.0 to 1.0)
| `z` | Float | required | Speed of zoom (in the range of -1.0 to 1.0)
`Timeout` | | Intenger | optional | Timeout (seconds)
```JavaScript
var params = {
'ProfileToken': '2_def_profile6',
'Velocity' : {'x': -1, 'y': 0, 'z': 0},
'Timeout' : 1
};
device.services.ptz.continuousMove(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a AbsoluteMove
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
ProfileToken |
String | required | a token of the profile | |
Position |
Object | required |
| `x` | Float | required | Position of pan (The range depends on the profile)
| `y` | Float | required | Position of tilt (The range depends on the profile)
| `z` | Float | required | Position of zoom (The range depends on the profile)
Speed
| | Object | required |
| x
| Float | required | Speed of pan (in the range of -1.0 to 1.0)
| y
| Float | required | Speed of tilt (in the range of -1.0 to 1.0)
| z
| Float | required | Speed of zoom (in the range of -1.0 to 1.0)
var params = {
'ProfileToken': cam['ProfileToken'],
'Position' : {'x': 0, 'y': 0, 'z': 0.003},
'Speed' : {'x': 1, 'y': 1, 'z': 1}
};
device.services.ptz.absoluteMove(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a RelativeMove
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
ProfileToken |
String | required | a token of the profile | |
Translation |
Object | required |
| `x` | Float | required | Translation of pan (in the range of -1.0 to 1.0)
| `y` | Float | required | Translation of tilt (in the range of -1.0 to 1.0)
| `z` | Float | required | Translation of zoom (in the range of -1.0 to 1.0)
Timeout
| | Intenger | optional | Timeout (seconds)
var params = {
'ProfileToken': '2_def_profile6',
'Translation' : {'x': 0.1, 'y': 0.1, 'z': 0}
'Timeout' : 1
};
device.services.ptz.relativeMove(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a stop
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
PanTilt |
Boolean | optional | true or false |
Zoom |
Boolean | optional | true or false |
var params = {
'ProfileToken': '2_def_profile6',
'PanTilt': true,
'Zoom': true
};
device.services.ptz.stop(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GotoHomePosition
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
Speed |
Float | optional | Speed in the range of 0.0 to 1.0 |
var params = {
'ProfileToken': '2_def_profile6',
'Speed': 0.5
};
device.services.ptz.gotoHomePosition(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a SetHomePosition
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
var params = {
'ProfileToken': '2_def_profile6'
};
device.services.ptz.SetHomePosition(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a SetPreset
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
PresetToken |
String | optional | a token of the preset |
PresetName |
String | optional | a name of the preset |
var params = {
'ProfileToken': '2_def_profile6',
'PresetToken' : '12',
'PresetName' : 'PresetTest1'
};
device.services.ptz.setPreset(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GetPresets
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description |
---|---|---|---|
ProfileToken |
String | required | a token of the profile |
var params = {
'ProfileToken': '2_def_profile6'
};
device.services.ptz.getPresets(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a GotoPreset
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
ProfileToken |
String | required | a token of the profile | |
PresetToken |
String | required | a token of the preset | |
Speed |
Object | required |
| `x` | Float | required | Speed of pan (in the range of 0.0 to 1.0)
| `y` | Float | required | Speed of tilt (in the range of 0.0 to 1.0)
| `z` | Float | required | Speed of zoom (in the range of 0.0 to 1.0)
var params = {
'ProfileToken': '2_def_profile6',
'PresetToken' : '12',
'Speed' : {'x': 1, 'y': 1, 'z': 1}
};
device.services.ptz.gotoPreset(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This method sends a RemovePreset
command. The 1st argument params
must be a hash object consisting of the properties as follows:
Property | Type | Required | Description | |
---|---|---|---|---|
ProfileToken |
String | required | a token of the profile | |
PresetToken |
String | required | a token of the preset |
var params = {
'ProfileToken': '2_def_profile6',
'PresetToken' : '12'
};
device.services.ptz.removePreset(params, (error, result) => {
console.log(JSON.stringify(result['data'], null, ' '));
});
This module is based on the ONVIF specifications:
- ONVIF Core Specification ver 16.06
- ONVIF Media Service Specification ver 16.06
- ONVIF PTZ Service Specification ver 2.6.1
- ONVIF Profile S Specification ver 1.1.1
- ONVIF Device Management Service WSDL, ver 16.06
- ONVIF Media Service WSDL, ver 2.6
- ONVIF PTZ Service WSDL, ver 16.06
- ONVIF Application Programmer's Guide ver 1.0
The MIT License (MIT)
Copyright 2016 Futomi Hatano
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.