ONVIF client library for Go — discover and control IP cameras via the ONVIF protocol.
go get github.com/sonnt85/gonvif- WS-Discovery to find ONVIF devices on a network interface
- Connect to ONVIF devices by address with optional HTTP client
- Automatic capability discovery (Media, PTZ, Imaging, Events, Analytics)
- WS-Security (UsernameToken) authentication
- Call arbitrary ONVIF SOAP methods via
CallMethod - Structured types for Device, Media, PTZ, Imaging, Event, and Analytics services
- ISO 8601 duration support
// Discover NVT devices on an interface
devices := gonvif.GetAvailableDevicesAtSpecificEthernetInterface("eth0")
// Connect to a known camera
dev, err := gonvif.NewDevice(gonvif.DeviceParams{
Xaddr: "192.168.1.100",
Username: "admin",
Password: "secret",
})
if err != nil {
log.Fatal(err)
}
// List discovered service endpoints
fmt.Println(dev.GetServices())
// Call a ONVIF method (e.g., GetProfiles from media package)
resp, err := dev.CallMethod(media.GetProfiles{})Device— represents an ONVIF device; holds endpoints and device infoDeviceParams— connection parameters (address, credentials, HTTP client)DeviceType— NVD / NVS / NVA / NVT constantsDeviceInfo— device information returned by GetDeviceInformation
NewDevice(params DeviceParams) (*Device, error)— connect to a device and discover its capabilitiesGetAvailableDevicesAtSpecificEthernetInterface(iface string) []Device— WS-Discovery probe on a network interface
CallMethod(method interface{}) (*http.Response, error)— call any ONVIF SOAP methodGetServices() map[string]string— return discovered service endpoint URLsGetDeviceInfo() DeviceInfo— return device informationGetEndpoint(name string) string— return endpoint URL for a named service
device— Device service types and operationsmedia— Media service typesptz— PTZ service typesevent— Event service types (Subscribe, PullMessages, etc.)Imaging— Imaging service typesanalytics— Analytics service typeswsdiscovery— WS-Discovery probe implementationgosoap— SOAP message builder with WS-Security supportonvifutils— ONVIF utility helpersxsd— XSD built-in and ONVIF schema types
sonnt85 — thanhson.rf@gmail.com
MIT License - see LICENSE for details.