onvif

package module
v0.0.0-...-a9630c7 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 18 Imported by: 0

README

Onvif Golang Client SDK

使用方法

go get github.com/zijiemeng/go-onvif

支持协议

https://github.com/onvif/specs.git
branch: 22.12

使用方法

device, _ := NewDevice(DeviceParams{
    Xaddr:      address,    // IP:Port
    Username:   username,
    Password:   password,
    HttpClient: &http.Client{Timeout: 6 * time.Second},
})

endpoints := dev.EndpointManager
eptDevice := endpoints.Device
if eptDevice != nil {
    capabilities, _ := eptDevice.OptGetCapabilities(device.GetCapabilities{})
	fmt.Printf("%#v\n", capabilities)
}

eptMedia := endpoints.Media // endpoints.Media.Media -> onvif v10, endpoints.Media.Media2 -> onvif v20
if eptMedia != nil && eptMedia.Media != nil {
    capabilities, _ := eptMedia.Media.OptGetServiceCapabilities(media.GetServiceCapabilities{})
    fmt.Printf("%#v\n", capabilities)
}

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 (
	ErrorOffline         = fmt.Errorf("device is offline")
	ErrorUnauthorized    = fmt.Errorf("device is unauthorized")
	ErrorServiceNotFound = fmt.Errorf("service not found")
)
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 SetLoginHttpClient

func SetLoginHttpClient(client *http.Client)

Types

type Device

type Device struct {
	Endpoints map[string]string

	*onvif.EndpointManager
	// 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

GetAvailableDevicesAtSpecificEthernetInterface ...

func NewDevice

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

NewDevice function construct a ONVIF Device entity

func (Device) CallMethod

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

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

func (Device) CallMethodUnmarshal

func (dev Device) CallMethodUnmarshal(endpoint string, method interface{}, result interface{}) *common.Fault

func (*Device) GetDeviceInfo

func (dev *Device) GetDeviceInfo() common.DeviceInfo

GetServices return available endpoints

func (*Device) GetEndpoint

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

GetEndpoint returns specific ONVIF service endpoint address

func (Device) GetParam

func (dev Device) GetParam() DeviceParams

func (*Device) GetServices

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

GetServices return available endpoints

type DeviceParams

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

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

Jump to

Keyboard shortcuts

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