{"name":"onvif","version":"0.6.6","author":{"name":"Andrew D.Laptev","email":"a.d.laptev@gmail.com"},"description":"Client to ONVIF NVT devices Profile S: cameras","main":"lib/onvif.js","scripts":{"jsdoc":"jsdoc ./lib/*.js --readme ./README.md --destination ./docs","gh-pages":"jsdoc ./lib/*.js --readme ./README.md --destination ./","lint":"eslint lib/*.js","pretest":"npm run lint","test":"nyc mocha","test-on-travis":"nyc npm test && nyc report --reporter=text-lcov | coveralls","mockserver":"node startServerMockup.js"},"contributors":[{"name":"Andrew D.Laptev","email":"a.d.laptev@gmail.com","url":"https://github.com/agsh/onvif"},{"name":"Chris Wiggins","email":"chris@wiggins.nz","url":"https://github.com/chriswiggins"},{"name":"Jeff Galbraith","email":"jgalbraith@intelliviewtech.com","url":"http://intelliviewtech.com"},{"name":"Roger Hardiman","email":"opensource@rjh.org.uk","url":"http://www.rjh.org.uk"}],"repository":{"type":"git","url":"git+https://github.com/agsh/onvif.git"},"dependencies":{"lodash.get":"^4.4.2","xml2js":"^0.4.23"},"keywords":["onvif","video","PTZ","camera","RTSP"],"license":"MIT","engines":{"node":">=6.0"},"devDependencies":{"coveralls":"^3.1.1","dot":"^1.1.3","eslint":"^8.3.0","eslint-plugin-node":"^11.1.0","keypress":"^0.2.1","mocha":"^9.1.3","mocha-lcov-reporter":"^1.3.0","nimble":"^0.0.2","nyc":"^15.1.0","ip":"^1.1.5"},"gitHead":"50289f10b62481dc9d5e7aa5b167baa35c37e290","bugs":{"url":"https://github.com/agsh/onvif/issues"},"homepage":"https://github.com/agsh/onvif#readme","_id":"onvif@0.6.6","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"integrity":"sha512-n+VZEvRNP8AW7zDq83X9oNm3VFDDBvflO7xfapwn/E6bqop/aKMDiZ3EALRDjQaCvmlgLqtZrp+7Pl99dJhv2g==","shasum":"8ae7f5f479d3b759ee780e78f83c930b0b5aa1ab","tarball":"https://registry.npmmirror.com/onvif/-/onvif-0.6.6.tgz","fileCount":100,"unpackedSize":736349,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF0vJG0oQn2p7I/HRoUhZD/jSH6PmBTNI7voMOeBR7L3AiATCsa0vxBWWZH80WIs8nA3ZZgrLf9icanky5yPAi4YcQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJisdT2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoNRA//SX2KMPtatdJxR32iMqy71mjxl7NWNfaGo3O0vwSUsT/+zTLa\r\nljHs8cfYgL2sPxvwU/3hhyxg1gJ/QRJmIRZ3MMOpzhybLWZMSztouEaEmftq\r\npV3okENbKToTFcsei0+qC6XdbeY2HUA10xrL+No2ogfhAtRc0BSjvuvYeiwd\r\n+SHWIh2VR0+NzMu/2xRc3dreHcQYAcpinBl/7gRkqlb4M8r/lGAtSTbeZXB1\r\nZyrO8tX4UuapgdxIz2NFjyGAL9Zo5zkmdBzCL/fWbPWhv8IR+xJOKoJPFY84\r\nDVrAMiZt8JhjSQmlLktVkp3lheIOU4OjJoSUs1k1F6Q8PiqHD3F8Y8sWJ05R\r\npIIalPM5QT30T72122VBSRc3tTmGKndZsFtKejxkONl2i6022Dkkds79Ax5r\r\nUcQ1vafXHKzf81ZC6IOfA9a8Un2ZM0iSu7jSAWiDNf3eWErLHmYfqXoSh7lj\r\nW1y+RO2nh5Jh/17MbqZSLFiVLow6nRnCu7jKojm/rlhanfOfXDW9TEwC/GuL\r\nyqQkqadMPGELVU8n3inoSfRdMI7iivy419i+fCeROBAF0uyYek7Ibttq222f\r\nMu3Z3StyA6CY9uXKmkI93L8kOjNM29JcwCTE8eT4DMZoV22Y1SJpTbaIhcc1\r\nN2d3RH+t7I5vQLwJ+rmBAzaKEjiLKka6rq4=\r\n=uSgQ\r\n-----END PGP SIGNATURE-----\r\n","size":99273},"_npmUser":{"name":"agsh","email":"a.d.laptev@gmail.com"},"directories":{},"maintainers":[{"name":"agsh","email":"a.d.laptev@gmail.com"},{"name":"chriswiggins","email":"chris@wiggins.nz"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onvif_0.6.6_1655821557858_0.8406247417530266"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-06-21T14:58:08.323Z","readme":"# ONVIF\n\n[![Build Status](https://travis-ci.org/agsh/onvif.png)](https://travis-ci.org/agsh/onvif)\n[![Coverage Status](https://img.shields.io/coveralls/agsh/onvif.svg)](https://coveralls.io/r/agsh/onvif?branch=master)\n[![NPM version](https://img.shields.io/npm/v/onvif.svg)](https://www.npmjs.com/package/onvif)\n\nONVIF Client protocol Profile S (Live Streaming) and Profile G (Replay) Node.js implementation.\n\nThis is a wrapper to ONVIF protocol which allows you to get information about your NVT (network video transmitter)\ndevice, its media sources, control PTZ (pan-tilt-zoom) movements and manage presets, detect devices in your network and control its events.\nIt will also allow you to get information about your NVR (network video recorder) Profile G device and obtain a list of recordings.\n\nThe library uses NodeJS.\n\n[![ONVIF](https://www.onvif.org/wp-content/themes/onvif-public/images/logo.png)](http://onvif.org)\n\n## Installation\n\n### NPM\n\n`npm install onvif` - install latest stable version\n\n`npm install agsh/onvif` - install latest version from GitHub\n\n`npm install agsh/onvif#dev` - install latest development version\n\n### Clone the latest version from github\n`git clone https://github.com/agsh/onvif.git`\n\n### Tests\nIn the library directory run `npm test`\n\nBy default the tests use a mockup server to generate ONVIF replies.\n\nTo test with the real device, set appropriate environment variables `HOSTNAME`, `USERNAME`, `PASSWORD`, `PORT` and run\ntests.\n\n### Documentation\nTo build jsdoc for the library with default theme run `npm run jsdoc`. Otherwise use `jsdoc` with sources from\n`./lib/*.js`\n\n## Quick example\nThis example asks your camera to look up and starts a web server at port 3030 that distributes a web page with vlc-plugin\ncontainer which translates video from the camera.\n```javascript\nvar\n http = require('http'),\n Cam = require('onvif').Cam;\n\nnew Cam({\n hostname: ,\n username: ,\n password: \n}, function(err) {\n this.absoluteMove({x: 1, y: 1, zoom: 1});\n this.getStreamUri({protocol:'RTSP'}, function(err, stream) {\n http.createServer(function (req, res) {\n res.writeHead(200, {'Content-Type': 'text/html'});\n res.end('' +\n '' +\n '');\n }).listen(3030);\n });\n});\n```\n\n## Other examples (located in the Examples Folder on the Github)\n* example.js - Move camera to a pre-defined position then server the RTSP URL up via a HTTP Server. Click on the RTSP address in a browser to open the video (if you have the VLC plugin installed)\n* example2.js - takes an IP address range, scans the range for ONVIF devices (brute force scan) and displays information about each device found including make and model and RTSP URLs\nFor Profile S Cameras and Encoders it displays the default RTSP address\nFor Profile G Recorders it displays the RTSP address of the first recording\n* example3.js - reads the command line cursor keys and sends PTZ commands to the Camera\n* example4.js - uses Discovery to find cameras on the local network \n* example5.js - connect to a camera via SOCKS proxy. Note SSH includes a SOCKS proxy so you can use this example to connect to remote cameras via SSH\n* example6.js - ONVIF Events. Example can be switched btween using Pull Point Subscriptions and using Base Subscribe with a built in mini HTTP Server\n* example7.js - example using a Promise API. It uses 'promisify' to convert the ONVIF Library to return promises and uses Await to wait for responses\n* example8.js - example setting OSD On Screen Display. (also uses Promises API)\n\n## Troubleshooting\nDifferent cameras have different ONVIF implementation. I've tested this module only with a couple of devices. So if you got different problems with this library, please let me know via e-mail. Else please just send the model of your\ncamera to me.\n\n# API\n\n## You can find this page and full API class documentation here: [http://agsh.github.io/onvif/](http://agsh.github.io/onvif/) ##\n\nShort description of library possibilities is below.\n\n## Discovery\nSince 0.2.7 version library supports WS-Discovery of NVT devices. Currently it uses only `Probe` SOAP method that just works well.\nYou can find devices in your subnetwork using `probe` method of the Discovery singleton.\nDiscovery is an EventEmitter inheritor, so you can wait until discovery timeout, or subscribe on `device` event.\nYou must subscribe to the `error` event as a device on your network could reply with bad XML\nHere some examples:\n\n```js\nvar onvif = require('onvif');\nonvif.Discovery.on('device', function(cam){\n// function will be called as soon as NVT responds\n\tcam.username = ;\n\tcam.password = ;\n\tcam.connect(console.log);\n})\n// Must have an error handler to catch bad replies from the network\nonvif.Discovery.on('error', function (err,xml) {\n // function called as soon as NVT responds, but this library could not parse the response\n console.log('Discovery error ' + err);\n});\nonvif.Discovery.probe();\n```\n\n```js\nvar onvif = require('onvif');\n// Must have an error handler to catch bad replies from the network\nonvif.Discovery.on('error', function (err,xml) {\n console.log('Discovery error ' + err);\n});\nonvif.Discovery.probe(function(err, cams) {\n// function will be called only after timeout (5 sec by default)\n\tif (err) { \n // There is a device on the network returning bad discovery data\n // Probe results will be incomplete\n throw err;\n }\n\tcams.forEach(function(cam) {\n\t\tcam.username = ;\n\t\tcam.password = ;\n\t\tcam.connect(console.log);\n\t});\n});\n```\n\nIn all of that cases you've got disconnected cameras. To access each camera (and issue ONVIF commands) you normally need\nthe tuple `username:password`. So, as shown in the examples, you can assign these properties and call `connect` method to\nget full functionality.\n\n### Discovery.probe(options, callback)\nOptions\n\n- `timeout`, number. Time the probe method will wait NVT responses in ms\n- `resolve`, boolean. If this argument is false, all discovered NVTs would be presented as data object instead of Cam instance\n\n### Discovery events\n- `device(cam, remoteInfo, responseXML)` fires on device discover. `cam` is a Cam instance, remoteInfo is an object with network information\n and responseXML is a body of SOAP response\n- `error(error)` fires on some UDP error or on bad SOAP response from NVT\n\n## Cam class\n\n```javascript\nvar Cam = require('onvif').Cam;\n```\n\n## new Cam(options, callback)\n\nOptions are:\n- hostname\n- username, password (optional, to deal with majority of functions)\n- port (optional)\n\nThe library calls connect() automatically which executes the `getSystemDateAndTime`, `getCapabilities` and other methods.\nNote on username and password:\n- Some cameras do not require username:password credentials.\n- If a camera does require a username:password but you do not provide them, you will be limited to executing a few ONVIF methods that can operate without credentials, for example you can execute only `getSystemDateAndTime` method.\n\nCallback (optional) executes when the cam is initialised. Single argument for this function is possible error.\n\n#### Technical description\n\nWhen the cam object is created it automatically sends a `getCapabilities` command to the ONVIF device. If the device is a camera or encoder (NVT) it sends two commands to the ONVIF device:\n`getVideoSources` and `getProfiles`. It fills corresponding properties of an object:\n\n+ capabilities\n - device\n - events\n - imaging\n - media\n - PTZ\n - extension\n+ uri (this is a links to different NVT services)\n+ videoSources\n - $.token\n - framerate\n - resolution\n+ profiles, array of profile object\n - name\n - videoSourceConfiguration\n - videoEncoderConfiguration\n - PTZConfiguration\n\nAfter that it runs `getActiveSources` method. It iterates over all video sources and tries to find out proper configuration\nfor profile and videosource. First matching profile becomes a member of defaultProfiles array and video source configuration\nwith ptz configuration becomes a member of activeSources array.\n\nConfiguration for the first or the only one video source becomes defaultProfile and activeSource properties. All methods\nwithout passing options object use it. You can change it manually at any time.\n\n+ defaultProfile (link to the first profile in profiles)\n+ activeSource (based on the default profile)\n - sourceToken\n - profileToken\n - encoding\n - width\n - height\n - fps\n - bitrate\n - ptz\n\n### connect(callback)\nConnect to the camera and fill device information properties with `getSystemDateAndTime`, `getCapabilities`, `getVideoSources`, `getProfiles` methods\n\nSee more detailed information at http://www.onvif.org/ver10/media/wsdl/media.wsdl\nAfter cam initialisation we can run several ONVIF commands.\nThere are several common methods that work without credentials. Here are they: `getSystemDateAndTime`.\n\n### getSystemDateAndTime(callback)\nReturns a Date object with current camera datetime in the callback.\nThe ONVIF Standard says this would work without credentials (passed `username` and `password` arguments) so that the timeShift difference between the local clock and the NVT's onboard clock can be calculated for SOAP Authentication. However some devices claiming ONVIF support require a password and the library will re-try the connection if a username and password are available.\n\n### getDeviceInformation(callback)\n*Device.* Returns a device information, such as manufacturer, model and firmware version in the callback\n\n### getServices(callback)\n*Device.* Returns in callback and assigns to `#services` property an array consists of objects with properties: `namespace`, `XAddr`, `version`\n\n### getServiceCapabilities(callback)\n*Device.* Returns in callback and assigns to `#serviceCapabilities` property the capabilities of the device service (not media):\nnetwork, security and system. If your device supports some auxiliary capabilities they will be there too.\n\n### getStreamUri(options, callback)\n*Media.* Returns a URI that can be used to initiate a live media stream using RTSP as the control protocol\nThe options are:\n\n- `stream` (optional) - defines if a multicast or unicast stream is requested. Possible values are: 'RTP-Unicast' (default), 'RTP-Multicast'\n- `protocol` (optional) - defines the network protocol for streaming. Possible values are: 'UDP', 'TCP', 'RTSP' (default), 'HTTP'\n- `profileToken` (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is `#activeSource.profileToken`\n\n### getSnapshotUri(options, callback)\n*Media.* Obtain a JPEG snapshot URI from the device.\n\n### getPresets(options, callback)\nReturns the saved presets as an a key-value object where the key is the name of a preset and a value is a preset token.\nThis method also stores the presets information in a `#presets` property of an object.\n\nThe options are:\n\n* `profileToken` (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is `#activeSource.profileToken`\n\n### gotoPreset(options, callback)\n*PTZ.* Operation to go to a saved preset position for the PTZ node in the selected profile.\n\nThe options are:\n\n* `profileToken` (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is `#activeSource.profileToken`\n* `preset` - the name of preset. List of presets you can get by `#getPresets` method or in `#presets` property.\n\n### setPreset(options, callback)\n*PTZ.* Operation to set the current position as a preset for the PTZ node in the selected profile. If `presetToken` is passed as an option, then the preset for which that token is attached will be replaced. After success, you should re-fetch the presets with `#getPresets` method.\n\nThe options are:\n\n* `profileToken` (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is `#activeSource.profileToken`\n* `presetName` - the name to give to the preset. (optional) is this is a preset update.\n\n### removePreset(options, callback)\n*PTZ.* Operation to remove a preset specified by the preset token. After success, you should re-fetch the presets with `#getPresets` method.\n\nThe options are:\n\n* `profileToken` (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is `#activeSource.profileToken`\n* `presetToken` - the preset token to use for preset removal (this will be the `value` of a preset object found in `#presets` after calling the `#getPresets` method.\n\n### gotoHomePosition(options, callback)\n*PTZ.* Operation to go to the saved `home` position for the PTZ node in the selected profile. If no `home` position has been saved, the ONVIF camera will do nothing.\n\nThe options are:\n\n* `profileToken` (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is `#activeSource.profileToken`\n* `speed` An object with properties\n - `x` Pan speed, float within 0 to 1\n - `y` Tilt speed, float within 0 to 1\n - `zoom` Zoom speed, float within 0 to 1\n\n If the speed option is omitted, the default speed set by the PTZConfiguration will be used.\n\n### setHomePosition(options, callback)\n*PTZ.* Operation to set the current position as the `home` position for the PTZ node in the selected profile.\n\nThe options are:\n\n* `profileToken` (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is `#activeSource.profileToken`\n\n### getNodes(callback)\n*PTZ.* Returns the properties of the current PTZ node, if it exists.\nUse this function to get maximum number of presets, ranges of admitted values for x, y, zoom, iris, focus.\nSets all information into `#nodes` property.\n\n### relativeMove(options, callback)\n*PTZ.* This is a relative pan-tilt-zoom method. Options for this method is a delta between desired and current position of the camera.\n\nThe options are:\n\n- `x` Pan, number or a string within -1 to 1, optional\n- `y` Tilt, number or a string within -1 to 1, optional\n- `zoom` Zoom, number or a string within 0 to 1, optional\n- `speed` An object with properties\n * `x` Pan speed, float within 0 to 1\n * `y` Tilt speed, float within 0 to 1\n * `zoom` Zoom speed, float within 0 to 1\n\n If the speed option is omitted, the default speed set by the PTZConfiguration will be used.\n\nCallback is optional and means essentially nothing\n\n### absoluteMove(options, callback)\n*PTZ.* This is an absolute pan-tilt-zoom method. Options for this method is an absolute position of the camera.\n\nThe options are:\n\n- `x` Pan, number or a string within -1 to 1, optional\n- `y` Tilt, number or a string within -1 to 1, optional\n- `zoom` Zoom, number or a string within 0 to 1, optional\n- `speed` An object with properties\n * `x` Pan speed, float within 0 to 1\n * `y` Tilt speed, float within 0 to 1\n * `zoom` Zoom speed, float within 0 to 1\n\n If the speed option is omitted, the default speed set by the PTZConfiguration will be used.\n\nCallback is optional and means essentially nothing\n\n### continuousMove(options, callback)\n*PTZ.* Operation for continuous Pan/Tilt and Zoom movements\n\nThe options are:\n\n- `x` Pan velocity, number or a string within -1 to 1, optional\n- `y` Tilt velocity, number or a string within -1 to 1, optional\n- `zoom` Zoom velocity, number or a string within -1 to 1, optional\n- `timeout` Timeout in milliseconds, number. If timeout is omitted, movement will continue until `stop` command\n\n### stop(options, callback)\n*PTZ.* Stop ongoing pan, tilt and zoom movements of absolute, relative and continuous type\n\nOptions and callback are optional. The options properties are:\n\n- `profileToken` (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is `#activeSource.profileToken`\n- `panTilt` (optional) - set true when we want to stop ongoing pan and tilt movements. If `panTilt` arguments are not present, this command stops these movements.\n- `zoom` (optional) - set true when we want to stop ongoing zoom movement. If `zoom` arguments are not present, this command stops ongoing zoom movement.\n\n### getStatus(options, callback)\n*PTZ.* Returns an object with the current PTZ values.\n```javascript\n{\n\tposition: {\n\t\tx: 'pan position'\n\t\t, y: 'tilt position'\n\t\t, zoom: 'zoom'\n\t}\n\t, moveStatus: {} // camera moving\n\t, utcTime: 'current camera datetime'\n}\n```\n\n### getConfigurations(callback)\n*PTZ.* Get all the existing PTZConfigurations from the device. Configurations saved into `#configurations` property\n\n### getConfigurationOptions(configurationToken, callback)\n*PTZ.* Get supported coordinate systems including their range limitations for selected configuration. Extends corresponding\nconfiguration object\n\n## Supported methods\n* GetSystemDateAndTime\n* GetCapabilities\n* GetVideoSources\n* GetProfiles\n* GetServices\n* GetDeviceInformation\n* GetStreamUri\n* GetSnapshotUri\n* GetPresets\n* GotoPreset\n* RelativeMove\n* AbsoluteMove\n* ContinuousMove\n* Stop\n* GetStatus\n* SystemReboot\n* GetImagingSettings\n* SetImagingSettings\n* GetHostname\n* GetScopes\n* SetScopes\n* GetRecordings\n* GetReplayUri\n\n## Changelog\n- 0.6.5 Add MEDIA2 support, Profile T and GetServices XAddrs support for H265 cameras. Add support for HTTPS. Add Discovery.on('error') to examples. Add flag to only send Zoom, or only send Pan/Tilt for some broken cameras (Sony XP1 Xiongmai). Fix bug in GetServices. Improve setNTP command. API changed on getNetworkInterfaces and other methods that could return an Array or a Single Item. We now return an Array in all cases. Add example converting library so it uses Promises with Promisify. Enable 3702 Discovery on Windows for MockServer. Add MockServer test cases)\n- 0.6.1 Workaround for cams that don't send date-time\n- 0.6.0 Refactor modules for proper import in electron-based environment\n- 0.5.5 Added ptz.`gotoHomePosition`, ptz.`setHomePosition`. Fixed exceptions in ptz.`getConfigurations` and utils.`parseSOAPString`. Added tests for ptz.`setPreset`, ptz.`removePreset`, ptz.`gotoHomePosition`, and ptz.`setHomePosition`.\n- 0.5.4 Bumped for NPM.\n- 0.5.3 Some fixes. Tests\n- 0.5.2 `preserveAddress` property for NAT devices, discovery with multiple network interfaces (@Climax777)\n- 0.5.1 Critical bugfix in SOAP-auth for some cams\n- 0.5.0 Profile G support (@RogerHardiman), proper SOAP auth, nodejs support >= 0.12\n- 0.4.2 Bugfixes\n- 0.4.1 Improved discovery (@sousandrei, @RogerHardiman)\n- 0.4.0 Encoder support (@chriswiggins), Imaging service (@EastL)\n- 0.3.1 EventEmitter-based events\n- 0.3.0 Refactoring, documentation, event service basics\n- 0.2.7 WS-Discovery\n\n## Links\nWSDL schemes and docs:\n- [Operations index](http://www.onvif.org/onvif/ver20/util/operationIndex.html)\n- http://www.onvif.org/onvif/ver10/tc/onvif_core_ver10.pdf\n- http://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl\n- http://www.onvif.org/ver10/media/wsdl/media.wsdl\n- http://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl\n- http://www.onvif.org/onvif/ver10/recording.wsdl\n- http://www.onvif.org/onvif/ver10/replay.wsdl\n- [ONVIF Application Programmer's Guide](http://www.onvif.org/Portals/0/documents/WhitePapers/ONVIF_WG-APG-Application_Programmer's_Guide.pdf)\n"}