patrickmichalina / onvif-rx

📹 Communicate with ONVIF devices and cameras in server and browser environments.
MIT License
22 stars 11 forks source link
camera node nodejs onvif onvif-camera onvif-client ptz rxjs typescript

onvif-rx

Interact with ONVIF cameras and devices using TypeScript and RXJS.

circeci

greenkeeper greenkeeper greenkeeper

semantic-release npm latest version

0930282e-7f18-11e6-948a-00546393fd93

About

This library aims to provide an easy way to interact with ONVIF devices from within Node. It is built with TypeScript to provide IDE's easy access to documentation and typing information.

The API is generated dynamically by reading ONVIF WSDL and XSD files.

This library is very early and not garaunteed to work for evey camera. Feel free to create a Github issue if it's not working for you.

This library does not "discover" devices on the network - for that try onvif-probe-rx

Docs

For more information about the TypeScript API checkout the generated API docs.

Roadmap

Node Installation

This package is designed to be run in both the browser and node environments.

npm i onvif-rx

Browser Installation (expiremental)

<head>
 <!-- simplest method, gets the latest version, but not minifed -->
 <script src="https://unpkg.com/onvif-rx"></script>

 <!-- RECOMMENDED: use a specific version to avoid a redirect and get a minified version --> 
 <script src="https://unpkg.com/onvif-rx@x.x.x/dist/onvif-rx-umd.min.js"></script>
</head>

Usage

The library is designed to be used in 2 distinct ways.

Managed Usage

import { createManagedDeviceInNode } from 'onvif-rx'

const device = createManagedDeviceInNode({
  deviceUrl: 'http://192.168.1.11/onvif/device_service',
  password: 'admin',
  username: '1234'
})

device.api.Device.GetUsers()
  .toPromise()
  .then(res=> {
    res.match({ // results are wrapped in a managed object for safer processing
      ok: success => console.log(success.json), // successful response object
      fail: railure => console.log(railure.status, railure.statusMessage) // request failure object
    })
  }) 

Ad Hoc Usage

import { Device } from 'onvif-rx'
import { maybe } from 'typescript-monads'

Device.GetUsers()
  .run({
    system: DEFAULT_NODE_ENV,
    deviceUrl: 'http://192.168.1.11/onvif/device_service',
    user: maybe({ // currently requires a wrapper object, will improve in the future
      username: 'admin',
      password: '1234'
    })
  })
  .toPromise()
  .then(res=> {
    res.match({
      ok: success => console.log(success.json), // successful response object
      fail: railure => console.log(railure.status, railure.statusMessage) // request failure object
    })
  })