package module
Version: v0.0.0-...-fe8f6f0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2021 License: MIT Imports: 13 Imported by: 0



Easy management of IP devices, including cameras. Goonvif is an ONVIF implementation for managing IP devices. The purpose of this library is to manage IP cameras and other devices that support the ONVIF standard easily and conveniently.


To install the library, use the go get utility:

go get

Supported services

The following services are fully implemented:

  • Device
  • Media
  • PTZ
  • Imaging


General concept
  1. Connection to the device
  2. Authentication (if required)
  3. Definition of data types
  4. Execution of the required method
Connect to device

If there is a device at in the network, and its ONVIF services use port 1234, then you can connect to the device using the following method:

dev, err := goonvif.NewDevice("")

*ONVIF port may be different depending on the device and to find out which port to use, you can go to the web interface of the device. **Usually it's port 80.


If any function of one of the ONVIF services requires authentication, the Authenticate method must be used.

device := onvif.NewDevice("")
device.Authenticate("username", "password")
Data Type Definition

Each ONVIF service in this library has its own package in which all data types of this service are defined, and the name of the package is identical to the service name and starts with a capital letter. Goonvif has defined structures for each function of each ONVIF service supported by this library. Let's define the data type of the GetCapabilities function of the Device service. This is done as follows:

capabilities := Device.GetCapabilities{Category: "All"}

Why does the GetCapabilities structure have a Category field and why is the value of this field All?

The figure below shows the documentation of the GetCapabilities function. You can see that the function takes one parameter Category and its value should be one of the following: 'All', 'Analytics', 'Device', 'Events', 'Imaging', 'Media' or 'PTZ'.

Device GetCapabilities

An example of the GetServiceCapabilities function data type definition PTZ:

ptzCapabilities := PTZ.GetServiceCapabilities{}

You can see in the figure below that GetServiceCapabilities takes no arguments.

PTZ GetServiceCapabilities

*General data types are in the xsd/onvif package. Data types (structures) that can be common to all services are defined in the onvif package.

An example of the data type of the CreateUsers function of the Device service:

CreateUsers := Device.CreateUsers{User: onvif.User{Username: "admin", Password: "qwerty", UserLevel: "User"}}

You can see from the figure below that in this example the CreateUsers structure field should be User, the data type of which is a User structure containing Username, Password, UserLevel fields and an optional Extension. The User structure is located in the onvif package.

Device CreateUsers

Executing the required method

To execute any function of one of the ONVIF services whose structure has been defined, the ``CallMethod'' of the device object must be used.

createUsers := Device.CreateUsers{User: onvif.User{Username: "admin", Password: "qwerty", UserLevel: "User"}
device := = onvif.NewDevice("")
device.Authenticate("username", "password")
resp, err := dev.CallMethod(createUsers)



package goonvif is developed to provide an ONVIF client implementation on Go programming language



This section is empty.


View Source
var Xlmns = map[string]string{
	"onvif":   "",
	"tds":     "",
	"trt":     "",
	"tev":     "",
	"tptz":    "",
	"timg":    "",
	"tan":     "",
	"xmime":   "",
	"wsnt":    "",
	"xop":     "",
	"wsa":     "",
	"wstop":   "",
	"wsntw":   "",
	"wsrf-rw": "",
	"wsaw":    "",


This section is empty.


type DeviceType

type DeviceType int
const (
	NVD DeviceType = iota

func (DeviceType) String

func (devType DeviceType) String() string

type OnvifDevice

type OnvifDevice struct {
	// contains filtered or unexported fields

deviceInfo struct represents an abstract ONVIF OnvifDevice. It contains methods, which helps to communicate with ONVIF OnvifDevice

func GetAvailableDevicesAtSpecificEthernetInterface

func GetAvailableDevicesAtSpecificEthernetInterface(interfaceName string) []OnvifDevice

func NewDevice

func NewDevice(xaddr string) (*OnvifDevice, error)

NewDevice function construct a ONVIF Device entity

func (*OnvifDevice) Authenticate

func (dev *OnvifDevice) Authenticate(username, password string)

Authenticate function authenticate client in the ONVIF Device. Function takes <username> and <password> params. You should use this function to allow authorized requests to the ONVIF Device To change auth data call this function again.

func (OnvifDevice) CallMethod

func (dev OnvifDevice) CallMethod(method interface{}) (*http.Response, error)

CallMethod functions call an method, defined <method> struct. You should use Authenticate method to call authorized requests.

func (*OnvifDevice) GetEndpoint

func (dev *OnvifDevice) GetEndpoint(name string) string

GetEndpoint returns specific ONVIF service endpoint address

func (*OnvifDevice) GetServices

func (dev *OnvifDevice) GetServices() map[string]string

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL