onvif

package module
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: MIT Imports: 15 Imported by: 0

README

[!CAUTION] This library is intended solely for my personal use, so I may not fix bugs, actively support the project, and do ongoing maintenance.

ONVIF

Simple management of onvif IP-devices cameras. onvif is an implementation of ONVIF protocol for managing onvif IP devices. The purpose of this library is convenient and easy management of IP cameras and other devices that support ONVIF standard.

Installation

To install the library, use go get:

go get github.com/av1ppp/onvif

Supported services

The following services are implemented:

  • Device
  • Media
  • PTZ
  • Imaging
  • Event
  • Discovery
  • Authentication
  • SOAP
  • Error handling

Using

General concept
  1. Connecting to the device
  2. Authentication (if necessary)
  3. Carrying out the required method
Connecting to the device

If there is a device on the network at the address 192.168.12.34, and its ONVIF services use the 5678 port, then you can connect to the device in the following way:

dev, err := onvif.NewDevice(onvif.DeviceParams{
    Xaddr: "192.168.12.34:5678",
})

The ONVIF port may differ depending on the device , to find out which port to use, you can go to the web interface of the device. Usually this is 80 port.

Authentication

If ONVIF requires authentication, you can pass the username and password in the DeviceParams when creating a new device instance:

device := onvif.NewDevice(onvif.DeviceParams{
    Xaddr: "192.168.12.34:5678",
    Username: username,
    Password: password,
})
Example

You can find a simple example of using in the examples/device-service/main.go.

ONVIF Specifications

Almost all documentation you can find here.

Service specifications
Core specifications

Documentation

Overview

Package onvif is developed to provide an ONVIF client implementation on Go programming language.

Index

Constants

This section is empty.

Variables

View Source
var Xlmns = map[string]string{
	"onvif":   "http://www.onvif.org/ver10/schema",
	"tds":     "http://www.onvif.org/ver10/device/wsdl",
	"trt":     "http://www.onvif.org/ver10/media/wsdl",
	"tev":     "http://www.onvif.org/ver10/events/wsdl",
	"tptz":    "http://www.onvif.org/ver20/ptz/wsdl",
	"timg":    "http://www.onvif.org/ver20/imaging/wsdl",
	"tan":     "http://www.onvif.org/ver20/analytics/wsdl",
	"xmime":   "http://www.w3.org/2005/05/xmlmime",
	"wsnt":    "http://docs.oasis-open.org/wsn/b-2",
	"xop":     "http://www.w3.org/2004/08/xop/include",
	"wsa":     "http://www.w3.org/2005/08/addressing",
	"wstop":   "http://docs.oasis-open.org/wsn/t-1",
	"wsntw":   "http://docs.oasis-open.org/wsn/bw-2",
	"wsrf-rw": "http://docs.oasis-open.org/wsrf/rw-2",
	"wsaw":    "http://www.w3.org/2006/05/addressing/wsdl",
}

Xlmns XML Scheam

Functions

func Do added in v0.0.10

func Do[B any](ctx context.Context, dev *Device, request *Req[B]) (*http.Response, error)

Types

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device for a new device of onvif and DeviceInfo struct represents an abstract ONVIF device. It contains methods, which helps to communicate with ONVIF device

func GetAvailableDevicesAtSpecificEthernetInterface

func GetAvailableDevicesAtSpecificEthernetInterface(interfaceName string) ([]Device, error)

GetAvailableDevicesAtSpecificEthernetInterface ...

func NewDevice

func NewDevice(params DeviceParams) (*Device, error)

NewDevice function construct a ONVIF Device entity

func (*Device) GetDeviceInfo

func (dev *Device) GetDeviceInfo() DeviceInfo

GetDeviceInfo return available endpoints

func (*Device) GetDeviceParams

func (dev *Device) GetDeviceParams() DeviceParams

GetDeviceParams return available endpoints

func (*Device) GetEndpoint

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

GetEndpoint returns specific ONVIF service endpoint address

func (*Device) GetLogger added in v0.0.12

func (self *Device) GetLogger() *logx.Logger

func (*Device) GetServices

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

GetServices return available endpoints

type DeviceInfo

type DeviceInfo struct {
	Manufacturer    string
	Model           string
	FirmwareVersion string
	SerialNumber    string
	HardwareId      string
}

DeviceInfo struct contains general information about ONVIF device

type DeviceParams

type DeviceParams struct {
	Xaddr      string
	Username   string
	Password   string
	HttpClient *http.Client
	Logger     *logx.Logger
}

type DeviceType

type DeviceType int

DeviceType alias for int

const (
	NVD DeviceType = iota
	NVS
	NVA
	NVT
)

Onvif Device Tyoe

func (DeviceType) String

func (devType DeviceType) String() string

type Req added in v0.0.10

type Req[B any] struct {
	Body     B
	Header   any
	Endpoint string
}

func Request added in v0.0.10

func Request[T any](body T) *Req[T]

Directories

Path Synopsis
examples
device-service command
sdk
codegen command
ptz
xsd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL