onvif

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 9 Imported by: 0

README

go-onvif - ONVIF Client and Server Library for Go

Go Reference Go Report Card License GitHub stars GitHub issues

Modern, high-performance Go library for ONVIF IP camera integration - Control surveillance cameras, NVRs, and video devices with comprehensive ONVIF Profile S/T/G support. Includes both client and server implementations for complete ONVIF camera simulation and testing.

A production-ready, feature-rich Go (Golang) library for communicating with ONVIF-compliant IP cameras, network video recorders (NVR), and surveillance devices. Perfect for building video management systems (VMS), security camera applications, IoT projects, and camera testing frameworks.

🎯 Key Features at a Glance

  • ONVIF Client & Server - Both client library and virtual camera server
  • Production Ready - Battle-tested with multiple camera brands
  • Full Protocol Support - Device, Media, PTZ, Imaging, Discovery services
  • Type Safe - Comprehensive Go types for all ONVIF operations
  • Well Documented - Extensive examples and API documentation
  • Camera Tested - Verified with Hikvision, Axis, Dahua, Bosch cameras
  • Testing Framework - Built-in mock server and testing utilities

🔑 What is ONVIF?

ONVIF (Open Network Video Interface Forum) is an open industry standard for IP-based security products. This library allows you to:

  • 🎥 Control IP cameras from any manufacturer (Bosch, Hikvision, Axis, Dahua, etc.)
  • 📹 Get RTSP video streams and snapshots
  • 🎮 Pan, tilt, and zoom cameras remotely
  • 🔧 Configure camera settings (exposure, focus, white balance)
  • 🔍 Discover cameras on your network automatically
  • 🧪 Test ONVIF implementations without physical hardware

Features

📡 ONVIF Client

Modern Go Design

  • Context support for cancellation and timeouts
  • Concurrent-safe operations
  • Type-safe API with comprehensive error handling
  • Connection pooling for optimal performance

🎥 Comprehensive ONVIF Support

  • Device Management: Get device info, capabilities, system date/time, reboot
  • Media Services: Profiles, stream URIs (RTSP/HTTP), snapshot URIs, encoder configuration
  • PTZ Control: Continuous, absolute, and relative movement, presets, status
  • Imaging: Get/set brightness, contrast, exposure, focus, white balance, WDR
  • Discovery: Automatic camera detection via WS-Discovery multicast
🎬 ONVIF Server (NEW!)

🎥 Virtual IP Camera Simulator

  • Multi-Lens Camera Support: Simulate up to 10 independent camera profiles
  • Complete ONVIF Implementation: Device, Media, PTZ, and Imaging services
  • Flexible Configuration: CLI and library interfaces for easy setup
  • PTZ Simulation: Full pan-tilt-zoom control with preset positions
  • Imaging Control: Brightness, contrast, exposure, focus, and more
  • Testing & Development: Perfect for testing ONVIF clients without physical cameras

🔐 Security

  • WS-Security with UsernameToken authentication
  • Password digest (SHA-1) support
  • Configurable timeout and HTTP client options

📦 Easy Integration

  • Simple, intuitive API
  • Well-documented with examples
  • No external dependencies beyond Go standard library and golang.org/x/net

Installation

go get github.com/0x524A/go-onvif

Quick Start

Discover Cameras on Network
package main

import (
    "context"
    "fmt"
    "log"
    "time"

    "github.com/0x524A/go-onvif/discovery"
)

func main() {
    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
    defer cancel()

    devices, err := discovery.Discover(ctx, 5*time.Second)
    if err != nil {
        log.Fatal(err)
    }

    for _, device := range devices {
        fmt.Printf("Found: %s at %s\n", 
            device.GetName(), 
            device.GetDeviceEndpoint())
    }
}
Connect to a Camera
package main

import (
    "context"
    "fmt"
    "log"
    "time"

    "github.com/0x524A/go-onvif"
)

func main() {
    // Create client
    client, err := onvif.NewClient(
        "http://192.168.1.100/onvif/device_service",
        onvif.WithCredentials("admin", "password"),
        onvif.WithTimeout(30*time.Second),
    )
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    // Get device information
    info, err := client.GetDeviceInformation(ctx)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Camera: %s %s\n", info.Manufacturer, info.Model)
    fmt.Printf("Firmware: %s\n", info.FirmwareVersion)

    // Initialize and discover service endpoints
    if err := client.Initialize(ctx); err != nil {
        log.Fatal(err)
    }

    // Get media profiles
    profiles, err := client.GetProfiles(ctx)
    if err != nil {
        log.Fatal(err)
    }

    // Get stream URI
    if len(profiles) > 0 {
        streamURI, err := client.GetStreamURI(ctx, profiles[0].Token)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Stream URI: %s\n", streamURI.URI)
    }
}
PTZ Control
// Continuous movement
velocity := &onvif.PTZSpeed{
    PanTilt: &onvif.Vector2D{X: 0.5, Y: 0.0}, // Move right
}
timeout := "PT2S" // 2 seconds
err := client.ContinuousMove(ctx, profileToken, velocity, &timeout)

// Stop movement
err = client.Stop(ctx, profileToken, true, true)

// Absolute positioning
position := &onvif.PTZVector{
    PanTilt: &onvif.Vector2D{X: 0.0, Y: 0.0}, // Center
    Zoom:    &onvif.Vector1D{X: 0.5},         // 50% zoom
}
err = client.AbsoluteMove(ctx, profileToken, position, nil)

// Go to preset
presets, err := client.GetPresets(ctx, profileToken)
if len(presets) > 0 {
    err = client.GotoPreset(ctx, profileToken, presets[0].Token, nil)
}
Imaging Settings
// Get current settings
settings, err := client.GetImagingSettings(ctx, videoSourceToken)

// Modify settings
brightness := 60.0
settings.Brightness = &brightness

contrast := 55.0
settings.Contrast = &contrast

// Apply settings
err = client.SetImagingSettings(ctx, videoSourceToken, settings, true)

API Overview

Client Creation
client, err := onvif.NewClient(
    endpoint,
    onvif.WithCredentials(username, password),
    onvif.WithTimeout(30*time.Second),
    onvif.WithHTTPClient(customHTTPClient),
)
Device Service
Method Description
GetDeviceInformation() Get manufacturer, model, firmware version
GetCapabilities() Get device capabilities and service endpoints
GetSystemDateAndTime() Get device system time
SystemReboot() Reboot the device
Initialize() Discover and cache service endpoints
GetHostname() Get device hostname configuration
SetHostname() Set device hostname
GetDNS() Get DNS configuration
GetNTP() Get NTP configuration
GetNetworkInterfaces() Get network interface configuration
GetScopes() Get configured discovery scopes
GetUsers() Get list of user accounts
CreateUsers() Create new user accounts
DeleteUsers() Delete user accounts
SetUser() Modify existing user account
Media Service
Method Description
GetProfiles() Get all media profiles
GetStreamURI() Get RTSP/HTTP stream URI
GetSnapshotURI() Get snapshot image URI
GetVideoEncoderConfiguration() Get video encoder settings
GetVideoSources() Get all video sources
GetAudioSources() Get all audio sources
GetAudioOutputs() Get all audio outputs
CreateProfile() Create new media profile
DeleteProfile() Delete media profile
SetVideoEncoderConfiguration() Set video encoder configuration
PTZ Service
Method Description
ContinuousMove() Start continuous PTZ movement
AbsoluteMove() Move to absolute position
RelativeMove() Move relative to current position
Stop() Stop PTZ movement
GetStatus() Get current PTZ status and position
GetPresets() Get list of PTZ presets
GotoPreset() Move to a preset position
SetPreset() Save current position as preset
RemovePreset() Delete a preset
GotoHomePosition() Move to home position
SetHomePosition() Set current position as home
GetConfiguration() Get PTZ configuration
GetConfigurations() Get all PTZ configurations
Imaging Service
Method Description
GetImagingSettings() Get imaging settings (brightness, contrast, etc.)
SetImagingSettings() Set imaging settings
Move() Perform focus move operations
GetOptions() Get available imaging options and ranges
GetMoveOptions() Get available focus move options
StopFocus() Stop focus movement
GetImagingStatus() Get current imaging/focus status
Discovery Service
Method Description
Discover() Discover ONVIF devices on network

ONVIF Server

The library now includes a complete ONVIF server implementation that simulates multi-lens IP cameras!

Quick Start
# Install the server CLI
go install ./cmd/onvif-server

# Run with default settings (3 camera profiles)
onvif-server

# Or customize
onvif-server -profiles 5 -username admin -password mypass -port 9000
Using the Server Library
package main

import (
    "context"
    "log"

    "github.com/0x524A/go-onvif/server"
)

func main() {
    // Create server with default multi-lens camera configuration
    srv, err := server.New(server.DefaultConfig())
    if err != nil {
        log.Fatal(err)
    }

    // Start server
    ctx := context.Background()
    if err := srv.Start(ctx); err != nil {
        log.Fatal(err)
    }
}
Server Features
  • 🎥 Multi-Lens Simulation: Support for up to 10 independent camera profiles
  • 🎮 Full PTZ Control: Pan, tilt, zoom with preset positions
  • 📷 Imaging Settings: Brightness, contrast, exposure, focus, white balance
  • 🌐 Complete ONVIF Services: Device, Media, PTZ, and Imaging services
  • 🔐 WS-Security: Digest authentication support
  • ⚙️ Flexible Configuration: CLI and library interfaces
Use Cases
  • Testing ONVIF client implementations
  • Developing video management systems
  • CI/CD integration testing
  • Demonstrations without physical cameras
  • Learning ONVIF protocol

For complete documentation, see server/README.md.

Examples

The examples directory contains complete working examples:

Client Examples
Server Examples
  • onvif-server: Multi-lens camera server with custom configuration

To run an example:

cd examples/discovery
go run main.go

Architecture

go-onvif/
├── client.go           # Main ONVIF client
├── types.go            # ONVIF data types
├── errors.go           # Error definitions
├── device.go           # Device service implementation
├── media.go            # Media service implementation
├── ptz.go              # PTZ service implementation
├── imaging.go          # Imaging service implementation
├── soap/               # SOAP client with WS-Security
│   └── soap.go
├── discovery/          # WS-Discovery implementation
│   └── discovery.go
├── server/             # ONVIF server implementation
│   ├── server.go       # Main server
│   ├── types.go        # Server types and configuration
│   ├── device.go       # Device service handlers
│   ├── media.go        # Media service handlers
│   ├── ptz.go          # PTZ service handlers
│   ├── imaging.go      # Imaging service handlers
│   └── soap/           # SOAP server handler
│       └── handler.go
├── cmd/
│   ├── onvif-cli/      # Client CLI tool
│   └── onvif-server/   # Server CLI tool
└── examples/           # Usage examples
    ├── discovery/
    ├── device-info/
    ├── ptz-control/
    ├── imaging-settings/
    └── onvif-server/   # Multi-lens camera server example

Design Principles

  1. Context-Aware: All network operations accept context.Context for cancellation and timeouts
  2. Type Safety: Strong typing with comprehensive struct definitions
  3. Error Handling: Typed errors with clear error messages
  4. Concurrency Safe: Thread-safe operations with proper locking
  5. Performance: Connection pooling and efficient HTTP client reuse
  6. Standards Compliant: Follows ONVIF specifications for SOAP/XML messaging

Compatibility

  • Go Version: 1.21+
  • ONVIF Versions: Compatible with ONVIF Profile S, Profile T, Profile G
  • Tested Cameras: Works with most ONVIF-compliant IP cameras including:
    • Axis
    • Hikvision
    • Dahua
    • Bosch
    • Hanwha (Samsung)
    • And many others

Testing

# Run tests
go test ./...

# Run tests with coverage
go test -cover ./...

# Run tests with race detection
go test -race ./...

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Roadmap

  • Event service implementation
  • Analytics service implementation
  • Recording service implementation
  • Replay service implementation
  • Advanced security features (TLS, X.509 certificates)
  • Comprehensive test suite with mock cameras
  • Performance benchmarks
  • CLI tool for camera management

Debugging Tools

🔍 Diagnostic Utility

Comprehensive camera testing and analysis with optional XML capture:

go build -o onvif-diagnostics ./cmd/onvif-diagnostics/

# Standard diagnostic report
./onvif-diagnostics \
  -endpoint "http://camera-ip/onvif/device_service" \
  -username "admin" \
  -password "pass" \
  -verbose

# With raw SOAP XML capture for debugging
./onvif-diagnostics \
  -endpoint "http://camera-ip/onvif/device_service" \
  -username "admin" \
  -password "pass" \
  -capture-xml \
  -verbose

Generates:

  • camera-logs/Manufacturer_Model_Firmware_timestamp.json - Diagnostic report
  • camera-logs/Manufacturer_Model_Firmware_xmlcapture_timestamp.tar.gz - Raw XML (with -capture-xml)

See: XML_DEBUGGING_SOLUTION.md for complete debugging workflow

🧪 Camera Test Framework

Automated regression testing using captured camera responses:

# 1. Capture from camera
./onvif-diagnostics -endpoint "http://camera/onvif/device_service" \
  -username "user" -password "pass" -capture-xml

# 2. Generate test
go build -o generate-tests ./cmd/generate-tests/
./generate-tests -capture camera-logs/*_xmlcapture_*.tar.gz -output testdata/captures/

# 3. Run tests
go test -v ./testdata/captures/

Benefits:

  • Test without physical cameras
  • Prevent regressions across camera models
  • Fast CI/CD integration
  • Real camera response validation

See: testdata/captures/README.md for complete testing guide

🌟 Star History

If you find this project useful, please consider giving it a star! ⭐

Star History Chart

📊 Project Stats

GitHub repo size GitHub code size GitHub go.mod Go version GitHub last commit

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Inspired by the original use-go/onvif library
  • ONVIF specifications from ONVIF.org
  • Thanks to all contributors and the Go community

Support

Keywords

onvif ip-camera surveillance golang rtsp ptz camera-control video-streaming security-camera nvr vms iot cctv hikvision axis dahua bosch camera-sdk golang-library soap ws-discovery


Made with ❤️ for the Go and IoT community

Documentation

Overview

Package onvif provides a modern, performant Go library for communicating with ONVIF-compliant IP cameras.

This package implements the ONVIF (Open Network Video Interface Forum) specification, providing a simple and type-safe API for controlling IP cameras and video devices.

Features

  • Device Management: Get device information, capabilities, system settings
  • Media Services: Access video streams, snapshots, and encoder configurations
  • PTZ Control: Pan, tilt, and zoom control with presets
  • Imaging: Adjust brightness, contrast, exposure, focus, and other image settings
  • Discovery: Automatic device discovery via WS-Discovery
  • Security: WS-Security authentication with password digest

Basic Usage

Create a client and connect to a camera:

client, err := onvif.NewClient(
    "http://192.168.1.100/onvif/device_service",
    onvif.WithCredentials("admin", "password"),
    onvif.WithTimeout(30*time.Second),
)
if err != nil {
    log.Fatal(err)
}

ctx := context.Background()

// Get device information
info, err := client.GetDeviceInformation(ctx)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Camera: %s %s\n", info.Manufacturer, info.Model)

Discovery

Discover ONVIF devices on the network:

devices, err := discovery.Discover(ctx, 5*time.Second)
for _, device := range devices {
    fmt.Printf("Found: %s at %s\n",
        device.GetName(),
        device.GetDeviceEndpoint())
}

Media Streaming

Get stream URIs for video playback:

profiles, err := client.GetProfiles(ctx)
if len(profiles) > 0 {
    streamURI, err := client.GetStreamURI(ctx, profiles[0].Token)
    fmt.Printf("RTSP Stream: %s\n", streamURI.URI)
}

PTZ Control

Control camera movement:

// Continuous movement
velocity := &onvif.PTZSpeed{
    PanTilt: &onvif.Vector2D{X: 0.5, Y: 0.0},
}
timeout := "PT2S"
client.ContinuousMove(ctx, profileToken, velocity, &timeout)

// Go to preset
presets, _ := client.GetPresets(ctx, profileToken)
client.GotoPreset(ctx, profileToken, presets[0].Token, nil)

Imaging Settings

Adjust camera image settings:

settings, err := client.GetImagingSettings(ctx, videoSourceToken)
brightness := 60.0
settings.Brightness = &brightness
client.SetImagingSettings(ctx, videoSourceToken, settings, true)

For more examples, see the examples directory in the repository.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidEndpoint is returned when the endpoint is invalid
	ErrInvalidEndpoint = errors.New("invalid endpoint")

	// ErrAuthenticationRequired is returned when authentication is required but not provided
	ErrAuthenticationRequired = errors.New("authentication required")

	// ErrAuthenticationFailed is returned when authentication fails
	ErrAuthenticationFailed = errors.New("authentication failed")

	// ErrServiceNotSupported is returned when a service is not supported by the device
	ErrServiceNotSupported = errors.New("service not supported")

	// ErrInvalidResponse is returned when the response is invalid
	ErrInvalidResponse = errors.New("invalid response")

	// ErrTimeout is returned when a request times out
	ErrTimeout = errors.New("request timeout")

	// ErrConnectionFailed is returned when connection to the device fails
	ErrConnectionFailed = errors.New("connection failed")

	// ErrInvalidParameter is returned when a parameter is invalid
	ErrInvalidParameter = errors.New("invalid parameter")

	// ErrNotInitialized is returned when the client is not initialized
	ErrNotInitialized = errors.New("client not initialized")
)

Functions

func IsONVIFError

func IsONVIFError(err error) bool

IsONVIFError checks if an error is an ONVIF error

Types

type AbsoluteFocusOptions

type AbsoluteFocusOptions struct {
	Position FloatRange
	Speed    FloatRange
}

AbsoluteFocusOptions represents absolute focus options

type AnalyticsCapabilities

type AnalyticsCapabilities struct {
	XAddr                  string
	RuleSupport            bool
	AnalyticsModuleSupport bool
}

AnalyticsCapabilities represents analytics service capabilities

type AudioEncoderConfiguration

type AudioEncoderConfiguration struct {
	Token          string
	Name           string
	UseCount       int
	Encoding       string // G711, G726, AAC
	Bitrate        int
	SampleRate     int
	Multicast      *MulticastConfiguration
	SessionTimeout time.Duration
}

AudioEncoderConfiguration represents audio encoder configuration

type AudioOutput

type AudioOutput struct {
	Token string
}

AudioOutput represents an audio output

type AudioSource

type AudioSource struct {
	Token    string
	Channels int
}

AudioSource represents an audio source

type AudioSourceConfiguration

type AudioSourceConfiguration struct {
	Token       string
	Name        string
	UseCount    int
	SourceToken string
}

AudioSourceConfiguration represents audio source configuration

type BacklightCompensation

type BacklightCompensation struct {
	Mode  string // OFF, ON
	Level float64
}

BacklightCompensation represents backlight compensation

type BacklightCompensationOptions

type BacklightCompensationOptions struct {
	Mode  []string
	Level *FloatRange
}

BacklightCompensationOptions represents backlight compensation options

type Capabilities

type Capabilities struct {
	Analytics *AnalyticsCapabilities
	Device    *DeviceCapabilities
	Events    *EventCapabilities
	Imaging   *ImagingCapabilities
	Media     *MediaCapabilities
	PTZ       *PTZCapabilities
	Extension *CapabilitiesExtension
}

Capabilities represents the device capabilities

type CapabilitiesExtension

type CapabilitiesExtension struct{}

Extension types

type Client

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

Client represents an ONVIF client for communicating with IP cameras

func NewClient

func NewClient(endpoint string, opts ...ClientOption) (*Client, error)

NewClient creates a new ONVIF client

func (*Client) AbsoluteMove

func (c *Client) AbsoluteMove(ctx context.Context, profileToken string, position *PTZVector, speed *PTZSpeed) error

AbsoluteMove moves PTZ to an absolute position

func (*Client) ContinuousMove

func (c *Client) ContinuousMove(ctx context.Context, profileToken string, velocity *PTZSpeed, timeout *string) error

ContinuousMove starts continuous PTZ movement

func (*Client) CreateProfile

func (c *Client) CreateProfile(ctx context.Context, name, token string) (*Profile, error)

CreateProfile creates a new media profile

func (*Client) CreateUsers

func (c *Client) CreateUsers(ctx context.Context, users []*User) error

CreateUsers creates new user accounts

func (*Client) DeleteProfile

func (c *Client) DeleteProfile(ctx context.Context, profileToken string) error

DeleteProfile deletes a media profile

func (*Client) DeleteUsers

func (c *Client) DeleteUsers(ctx context.Context, usernames []string) error

DeleteUsers deletes user accounts

func (*Client) Endpoint

func (c *Client) Endpoint() string

Endpoint returns the device endpoint

func (*Client) GetAudioOutputs

func (c *Client) GetAudioOutputs(ctx context.Context) ([]*AudioOutput, error)

GetAudioOutputs retrieves all audio outputs

func (*Client) GetAudioSources

func (c *Client) GetAudioSources(ctx context.Context) ([]*AudioSource, error)

GetAudioSources retrieves all audio sources

func (*Client) GetCapabilities

func (c *Client) GetCapabilities(ctx context.Context) (*Capabilities, error)

GetCapabilities retrieves device capabilities

func (*Client) GetConfiguration

func (c *Client) GetConfiguration(ctx context.Context, configurationToken string) (*PTZConfiguration, error)

GetConfiguration retrieves PTZ configuration

func (*Client) GetConfigurations

func (c *Client) GetConfigurations(ctx context.Context) ([]*PTZConfiguration, error)

GetConfigurations retrieves all PTZ configurations

func (*Client) GetCredentials

func (c *Client) GetCredentials() (string, string)

GetCredentials returns the current credentials

func (*Client) GetDNS

func (c *Client) GetDNS(ctx context.Context) (*DNSInformation, error)

GetDNS retrieves DNS configuration

func (*Client) GetDeviceInformation

func (c *Client) GetDeviceInformation(ctx context.Context) (*DeviceInformation, error)

GetDeviceInformation retrieves device information

Example

Example test

// Create client
client, err := NewClient(
	"http://192.168.1.100/onvif/device_service",
	WithCredentials("admin", "password"),
	WithTimeout(30*time.Second),
)
if err != nil {
	panic(err)
}

// Get device information
ctx := context.Background()
info, err := client.GetDeviceInformation(ctx)
if err != nil {
	panic(err)
}

fmt.Printf("Camera: %s %s\n", info.Manufacturer, info.Model)
fmt.Printf("Firmware: %s\n", info.FirmwareVersion)

func (*Client) GetHostname

func (c *Client) GetHostname(ctx context.Context) (*HostnameInformation, error)

GetHostname retrieves the device's hostname

func (*Client) GetImagingSettings

func (c *Client) GetImagingSettings(ctx context.Context, videoSourceToken string) (*ImagingSettings, error)

GetImagingSettings retrieves imaging settings for a video source

func (*Client) GetImagingStatus

func (c *Client) GetImagingStatus(ctx context.Context, videoSourceToken string) (*ImagingStatus, error)

GetImagingStatus retrieves imaging status

func (*Client) GetMoveOptions

func (c *Client) GetMoveOptions(ctx context.Context, videoSourceToken string) (*MoveOptions, error)

GetMoveOptions retrieves imaging move options for focus

func (*Client) GetNTP

func (c *Client) GetNTP(ctx context.Context) (*NTPInformation, error)

GetNTP retrieves NTP configuration

func (*Client) GetNetworkInterfaces

func (c *Client) GetNetworkInterfaces(ctx context.Context) ([]*NetworkInterface, error)

GetNetworkInterfaces retrieves network interface configuration

func (*Client) GetOptions

func (c *Client) GetOptions(ctx context.Context, videoSourceToken string) (*ImagingOptions, error)

GetOptions retrieves imaging options for a video source

func (*Client) GetPresets

func (c *Client) GetPresets(ctx context.Context, profileToken string) ([]*PTZPreset, error)

GetPresets retrieves PTZ presets

func (*Client) GetProfiles

func (c *Client) GetProfiles(ctx context.Context) ([]*Profile, error)

GetProfiles retrieves all media profiles

func (*Client) GetScopes

func (c *Client) GetScopes(ctx context.Context) ([]*Scope, error)

GetScopes retrieves configured scopes

func (*Client) GetSnapshotURI

func (c *Client) GetSnapshotURI(ctx context.Context, profileToken string) (*MediaURI, error)

GetSnapshotURI retrieves the snapshot URI for a profile

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context, profileToken string) (*PTZStatus, error)

GetStatus retrieves PTZ status

func (*Client) GetStreamURI

func (c *Client) GetStreamURI(ctx context.Context, profileToken string) (*MediaURI, error)

GetStreamURI retrieves the stream URI for a profile

func (*Client) GetSystemDateAndTime

func (c *Client) GetSystemDateAndTime(ctx context.Context) (interface{}, error)

GetSystemDateAndTime retrieves the device's system date and time

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context) ([]*User, error)

GetUsers retrieves user accounts

func (*Client) GetVideoEncoderConfiguration

func (c *Client) GetVideoEncoderConfiguration(ctx context.Context, configurationToken string) (*VideoEncoderConfiguration, error)

GetVideoEncoderConfiguration retrieves video encoder configuration

func (*Client) GetVideoSources

func (c *Client) GetVideoSources(ctx context.Context) ([]*VideoSource, error)

GetVideoSources retrieves all video sources

func (*Client) GotoHomePosition

func (c *Client) GotoHomePosition(ctx context.Context, profileToken string, speed *PTZSpeed) error

GotoHomePosition moves PTZ to home position

func (*Client) GotoPreset

func (c *Client) GotoPreset(ctx context.Context, profileToken, presetToken string, speed *PTZSpeed) error

GotoPreset moves PTZ to a preset position

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context) error

Initialize discovers and initializes service endpoints

func (*Client) Move

func (c *Client) Move(ctx context.Context, videoSourceToken string, focus *FocusMove) error

Move performs a focus move operation

func (*Client) RelativeMove

func (c *Client) RelativeMove(ctx context.Context, profileToken string, translation *PTZVector, speed *PTZSpeed) error

RelativeMove moves PTZ relative to current position

func (*Client) RemovePreset

func (c *Client) RemovePreset(ctx context.Context, profileToken, presetToken string) error

RemovePreset removes a preset

func (*Client) SetCredentials

func (c *Client) SetCredentials(username, password string)

SetCredentials updates the authentication credentials

func (*Client) SetHomePosition

func (c *Client) SetHomePosition(ctx context.Context, profileToken string) error

SetHomePosition sets the current position as home position

func (*Client) SetHostname

func (c *Client) SetHostname(ctx context.Context, name string) error

SetHostname sets the device's hostname

func (*Client) SetImagingSettings

func (c *Client) SetImagingSettings(ctx context.Context, videoSourceToken string, settings *ImagingSettings, forcePersistence bool) error

SetImagingSettings sets imaging settings for a video source

func (*Client) SetPreset

func (c *Client) SetPreset(ctx context.Context, profileToken, presetName, presetToken string) (string, error)

SetPreset sets a preset position

func (*Client) SetUser

func (c *Client) SetUser(ctx context.Context, user *User) error

SetUser modifies an existing user account

func (*Client) SetVideoEncoderConfiguration

func (c *Client) SetVideoEncoderConfiguration(ctx context.Context, config *VideoEncoderConfiguration, forcePersistence bool) error

SetVideoEncoderConfiguration sets video encoder configuration

func (*Client) Stop

func (c *Client) Stop(ctx context.Context, profileToken string, panTilt, zoom bool) error

Stop stops PTZ movement

func (*Client) StopFocus

func (c *Client) StopFocus(ctx context.Context, videoSourceToken string) error

StopFocus stops focus movement

func (*Client) SystemReboot

func (c *Client) SystemReboot(ctx context.Context) (string, error)

SystemReboot reboots the device

type ClientOption

type ClientOption func(*Client)

ClientOption is a functional option for configuring the Client

func WithCredentials

func WithCredentials(username, password string) ClientOption

WithCredentials sets the authentication credentials

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient sets a custom HTTP client

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout sets the HTTP client timeout

type ContinuousFocusOptions

type ContinuousFocusOptions struct {
	Speed FloatRange
}

ContinuousFocusOptions represents continuous focus options

type DNSInformation

type DNSInformation struct {
	FromDHCP     bool
	SearchDomain []string
	DNSFromDHCP  []IPAddress
	DNSManual    []IPAddress
}

DNSInformation represents DNS configuration

type DeviceCapabilities

type DeviceCapabilities struct {
	XAddr    string
	Network  *NetworkCapabilities
	System   *SystemCapabilities
	IO       *IOCapabilities
	Security *SecurityCapabilities
}

DeviceCapabilities represents device service capabilities

type DeviceInformation

type DeviceInformation struct {
	Manufacturer    string
	Model           string
	FirmwareVersion string
	SerialNumber    string
	HardwareID      string
}

DeviceInformation contains basic device information

type EventCapabilities

type EventCapabilities struct {
	XAddr                         string
	WSSubscriptionPolicySupport   bool
	WSPullPointSupport            bool
	WSPausableSubscriptionSupport bool
}

EventCapabilities represents event service capabilities

type EventSubscription

type EventSubscription struct {
	Filter *FilterType
}

EventSubscription represents event subscription

type Exposure

type Exposure struct {
	Mode            string // AUTO, MANUAL
	Priority        string // LowNoise, FrameRate
	MinExposureTime float64
	MaxExposureTime float64
	MinGain         float64
	MaxGain         float64
	MinIris         float64
	MaxIris         float64
	ExposureTime    float64
	Gain            float64
	Iris            float64
}

Exposure represents exposure settings

type ExposureOptions

type ExposureOptions struct {
	Mode            []string
	Priority        []string
	MinExposureTime *FloatRange
	MaxExposureTime *FloatRange
	MinGain         *FloatRange
	MaxGain         *FloatRange
	MinIris         *FloatRange
	MaxIris         *FloatRange
	ExposureTime    *FloatRange
	Gain            *FloatRange
	Iris            *FloatRange
}

ExposureOptions represents exposure options

type FilterType

type FilterType struct {
}

FilterType represents filter type

type FloatRange

type FloatRange struct {
	Min float64
	Max float64
}

FloatRange represents a float range

type FocusConfiguration

type FocusConfiguration struct {
	AutoFocusMode string // AUTO, MANUAL
	DefaultSpeed  float64
	NearLimit     float64
	FarLimit      float64
}

FocusConfiguration represents focus configuration

type FocusMove

type FocusMove struct {
}

FocusMove represents a focus move operation (placeholder for focus move types)

type FocusOptions

type FocusOptions struct {
	AutoFocusModes []string
	DefaultSpeed   *FloatRange
	NearLimit      *FloatRange
	FarLimit       *FloatRange
}

FocusOptions represents focus options

type FocusStatus

type FocusStatus struct {
	Position   float64
	MoveStatus string
	Error      string
}

FocusStatus represents focus status

type H264Configuration

type H264Configuration struct {
	GovLength   int
	H264Profile string
}

H264Configuration represents H264 configuration

type HostnameInformation

type HostnameInformation struct {
	FromDHCP bool
	Name     string
}

HostnameInformation represents hostname configuration

type IOCapabilities

type IOCapabilities struct {
	InputConnectors int
	RelayOutputs    int
	Extension       *IOCapabilitiesExtension
}

IOCapabilities represents I/O capabilities

type IOCapabilitiesExtension

type IOCapabilitiesExtension struct{}

type IPAddress

type IPAddress struct {
	Type        string // IPv4 or IPv6
	Address     string
	IPv4Address string
	IPv6Address string
}

IPAddress represents an IP address

type IPv4Configuration

type IPv4Configuration struct {
	Manual []PrefixedIPv4Address
	DHCP   bool
}

IPv4Configuration represents IPv4 configuration

type IPv4NetworkInterface

type IPv4NetworkInterface struct {
	Enabled bool
	Config  IPv4Configuration
}

IPv4NetworkInterface represents IPv4 configuration

type IPv6Configuration

type IPv6Configuration struct {
	Manual []PrefixedIPv6Address
	DHCP   bool
}

IPv6Configuration represents IPv6 configuration

type IPv6NetworkInterface

type IPv6NetworkInterface struct {
	Enabled bool
	Config  IPv6Configuration
}

IPv6NetworkInterface represents IPv6 configuration

type ImagingCapabilities

type ImagingCapabilities struct {
	XAddr string
}

ImagingCapabilities represents imaging service capabilities

type ImagingOptions

type ImagingOptions struct {
	BacklightCompensation *BacklightCompensationOptions
	Brightness            *FloatRange
	ColorSaturation       *FloatRange
	Contrast              *FloatRange
	Exposure              *ExposureOptions
	Focus                 *FocusOptions
	IrCutFilterModes      []string
	Sharpness             *FloatRange
	WideDynamicRange      *WideDynamicRangeOptions
	WhiteBalance          *WhiteBalanceOptions
}

ImagingOptions represents available imaging options

type ImagingSettings

type ImagingSettings struct {
	BacklightCompensation *BacklightCompensation
	Brightness            *float64
	ColorSaturation       *float64
	Contrast              *float64
	Exposure              *Exposure
	Focus                 *FocusConfiguration
	IrCutFilter           *string
	Sharpness             *float64
	WideDynamicRange      *WideDynamicRange
	WhiteBalance          *WhiteBalance
	Extension             *ImagingSettingsExtension
}

ImagingSettings represents imaging settings

type ImagingSettingsExtension

type ImagingSettingsExtension struct{}

ImagingSettingsExtension represents imaging settings extension

type ImagingStatus

type ImagingStatus struct {
	FocusStatus *FocusStatus
}

ImagingStatus represents imaging status

type IntRectangle

type IntRectangle struct {
	X      int
	Y      int
	Width  int
	Height int
}

IntRectangle represents a rectangle with integer coordinates

type MPEG4Configuration

type MPEG4Configuration struct {
	GovLength    int
	MPEG4Profile string
}

MPEG4Configuration represents MPEG4 configuration

type MediaCapabilities

type MediaCapabilities struct {
	XAddr                 string
	StreamingCapabilities *StreamingCapabilities
}

MediaCapabilities represents media service capabilities

type MediaURI

type MediaURI struct {
	URI                 string
	InvalidAfterConnect bool
	InvalidAfterReboot  bool
	Timeout             time.Duration
}

MediaURI represents a media URI

type MetadataConfiguration

type MetadataConfiguration struct {
	Token          string
	Name           string
	UseCount       int
	PTZStatus      *PTZFilter
	Events         *EventSubscription
	Analytics      bool
	Multicast      *MulticastConfiguration
	SessionTimeout time.Duration
}

MetadataConfiguration represents metadata configuration

type MoveOptions

type MoveOptions struct {
	Absolute   *AbsoluteFocusOptions
	Relative   *RelativeFocusOptions
	Continuous *ContinuousFocusOptions
}

MoveOptions represents imaging move options

type MulticastConfiguration

type MulticastConfiguration struct {
	Address   *IPAddress
	Port      int
	TTL       int
	AutoStart bool
}

MulticastConfiguration represents multicast configuration

type NTPInformation

type NTPInformation struct {
	FromDHCP    bool
	NTPFromDHCP []NetworkHost
	NTPManual   []NetworkHost
}

NTPInformation represents NTP configuration

type NetworkCapabilities

type NetworkCapabilities struct {
	IPFilter          bool
	ZeroConfiguration bool
	IPVersion6        bool
	DynDNS            bool
	Extension         *NetworkCapabilitiesExtension
}

NetworkCapabilities represents network capabilities

type NetworkCapabilitiesExtension

type NetworkCapabilitiesExtension struct{}

type NetworkHost

type NetworkHost struct {
	Type        string // IPv4, IPv6, DNS
	IPv4Address string
	IPv6Address string
	DNSname     string
}

NetworkHost represents a network host

type NetworkInterface

type NetworkInterface struct {
	Token   string
	Enabled bool
	Info    NetworkInterfaceInfo
	IPv4    *IPv4NetworkInterface
	IPv6    *IPv6NetworkInterface
}

NetworkInterface represents a network interface

type NetworkInterfaceInfo

type NetworkInterfaceInfo struct {
	Name      string
	HwAddress string
	MTU       int
}

NetworkInterfaceInfo represents network interface info

type ONVIFError

type ONVIFError struct {
	Code    string
	Reason  string
	Message string
}

ONVIFError represents an ONVIF-specific error

func NewONVIFError

func NewONVIFError(code, reason, message string) *ONVIFError

NewONVIFError creates a new ONVIF error

func (*ONVIFError) Error

func (e *ONVIFError) Error() string

Error implements the error interface

type PTZCapabilities

type PTZCapabilities struct {
	XAddr string
}

PTZCapabilities represents PTZ service capabilities

type PTZConfiguration

type PTZConfiguration struct {
	Token                                  string
	Name                                   string
	UseCount                               int
	NodeToken                              string
	DefaultAbsolutePantTiltPositionSpace   string
	DefaultAbsoluteZoomPositionSpace       string
	DefaultRelativePanTiltTranslationSpace string
	DefaultRelativeZoomTranslationSpace    string
	DefaultContinuousPanTiltVelocitySpace  string
	DefaultContinuousZoomVelocitySpace     string
	DefaultPTZSpeed                        *PTZSpeed
	DefaultPTZTimeout                      time.Duration
	PanTiltLimits                          *PanTiltLimits
	ZoomLimits                             *ZoomLimits
}

PTZConfiguration represents PTZ configuration

type PTZFilter

type PTZFilter struct {
	Status   bool
	Position bool
}

PTZFilter represents PTZ filter

type PTZMoveStatus

type PTZMoveStatus struct {
	PanTilt string // IDLE, MOVING, UNKNOWN
	Zoom    string // IDLE, MOVING, UNKNOWN
}

PTZMoveStatus represents PTZ movement status

type PTZPreset

type PTZPreset struct {
	Token       string
	Name        string
	PTZPosition *PTZVector
}

PTZPreset represents a PTZ preset

type PTZSpeed

type PTZSpeed struct {
	PanTilt *Vector2D
	Zoom    *Vector1D
}

PTZSpeed represents PTZ speed

type PTZStatus

type PTZStatus struct {
	Position   *PTZVector
	MoveStatus *PTZMoveStatus
	Error      string
	UTCTime    time.Time
}

PTZStatus represents PTZ status

type PTZVector

type PTZVector struct {
	PanTilt *Vector2D
	Zoom    *Vector1D
}

PTZVector represents PTZ position

type PanTiltLimits

type PanTiltLimits struct {
	Range *Space2DDescription
}

PanTiltLimits represents pan/tilt limits

type PrefixedIPv4Address

type PrefixedIPv4Address struct {
	Address      string
	PrefixLength int
}

PrefixedIPv4Address represents an IPv4 address with prefix

type PrefixedIPv6Address

type PrefixedIPv6Address struct {
	Address      string
	PrefixLength int
}

PrefixedIPv6Address represents an IPv6 address with prefix

type Profile

type Profile struct {
	Token                     string
	Name                      string
	VideoSourceConfiguration  *VideoSourceConfiguration
	AudioSourceConfiguration  *AudioSourceConfiguration
	VideoEncoderConfiguration *VideoEncoderConfiguration
	AudioEncoderConfiguration *AudioEncoderConfiguration
	PTZConfiguration          *PTZConfiguration
	MetadataConfiguration     *MetadataConfiguration
	Extension                 *ProfileExtension
}

Profile represents a media profile

type ProfileExtension

type ProfileExtension struct{}

ProfileExtension represents profile extension

type RelativeFocusOptions

type RelativeFocusOptions struct {
	Distance FloatRange
	Speed    FloatRange
}

RelativeFocusOptions represents relative focus options

type Scope

type Scope struct {
	ScopeDef  string
	ScopeItem string
}

Scope represents a device scope

type SecurityCapabilities

type SecurityCapabilities struct {
	TLS11                bool
	TLS12                bool
	OnboardKeyGeneration bool
	AccessPolicyConfig   bool
	X509Token            bool
	SAMLToken            bool
	KerberosToken        bool
	RELToken             bool
	Extension            *SecurityCapabilitiesExtension
}

SecurityCapabilities represents security capabilities

type SecurityCapabilitiesExtension

type SecurityCapabilitiesExtension struct{}

type Space1DDescription

type Space1DDescription struct {
	URI    string
	XRange *FloatRange
}

Space1DDescription represents 1D space description

type Space2DDescription

type Space2DDescription struct {
	URI    string
	XRange *FloatRange
	YRange *FloatRange
}

Space2DDescription represents 2D space description

type StreamSetup

type StreamSetup struct {
	Stream    string // RTP-Unicast, RTP-Multicast
	Transport *Transport
}

StreamSetup represents stream setup parameters

type StreamingCapabilities

type StreamingCapabilities struct {
	RTPMulticast bool
	RTP_TCP      bool
	RTP_RTSP_TCP bool
	Extension    *StreamingCapabilitiesExtension
}

StreamingCapabilities represents streaming capabilities

type StreamingCapabilitiesExtension

type StreamingCapabilitiesExtension struct{}

type SystemCapabilities

type SystemCapabilities struct {
	DiscoveryResolve  bool
	DiscoveryBye      bool
	RemoteDiscovery   bool
	SystemBackup      bool
	SystemLogging     bool
	FirmwareUpgrade   bool
	SupportedVersions []string
	Extension         *SystemCapabilitiesExtension
}

SystemCapabilities represents system capabilities

type SystemCapabilitiesExtension

type SystemCapabilitiesExtension struct{}

type Transport

type Transport struct {
	Protocol string // UDP, TCP, RTSP, HTTP
	Tunnel   *Tunnel
}

Transport represents transport parameters

type Tunnel

type Tunnel struct{}

Tunnel represents tunnel parameters

type User

type User struct {
	Username  string
	Password  string
	UserLevel string // Administrator, Operator, User
}

User represents a user account

type Vector1D

type Vector1D struct {
	X     float64
	Space string
}

Vector1D represents a 1D vector

type Vector2D

type Vector2D struct {
	X     float64
	Y     float64
	Space string
}

Vector2D represents a 2D vector

type VideoEncoderConfiguration

type VideoEncoderConfiguration struct {
	Token          string
	Name           string
	UseCount       int
	Encoding       string // JPEG, MPEG4, H264
	Resolution     *VideoResolution
	Quality        float64
	RateControl    *VideoRateControl
	MPEG4          *MPEG4Configuration
	H264           *H264Configuration
	Multicast      *MulticastConfiguration
	SessionTimeout time.Duration
}

VideoEncoderConfiguration represents video encoder configuration

type VideoRateControl

type VideoRateControl struct {
	FrameRateLimit   int
	EncodingInterval int
	BitrateLimit     int
}

VideoRateControl represents video rate control

type VideoResolution

type VideoResolution struct {
	Width  int
	Height int
}

VideoResolution represents video resolution

type VideoSource

type VideoSource struct {
	Token      string
	Framerate  float64
	Resolution *VideoResolution
	Imaging    *ImagingSettings
}

VideoSource represents a video source

type VideoSourceConfiguration

type VideoSourceConfiguration struct {
	Token       string
	Name        string
	UseCount    int
	SourceToken string
	Bounds      *IntRectangle
}

VideoSourceConfiguration represents video source configuration

type WhiteBalance

type WhiteBalance struct {
	Mode   string // AUTO, MANUAL
	CrGain float64
	CbGain float64
}

WhiteBalance represents white balance settings

type WhiteBalanceOptions

type WhiteBalanceOptions struct {
	Mode   []string
	YrGain *FloatRange
	YbGain *FloatRange
}

WhiteBalanceOptions represents white balance options

type WideDynamicRange

type WideDynamicRange struct {
	Mode  string // OFF, ON
	Level float64
}

WideDynamicRange represents WDR settings

type WideDynamicRangeOptions

type WideDynamicRangeOptions struct {
	Mode  []string
	Level *FloatRange
}

WideDynamicRangeOptions represents WDR options

type ZoomLimits

type ZoomLimits struct {
	Range *Space1DDescription
}

ZoomLimits represents zoom limits

Directories

Path Synopsis
cmd
onvif-cli command
onvif-quick command
onvif-server command
examples
complete-demo command
debug-soap command
debug-streamuri command
device-info command
discovery command
onvif-server command
ptz-control command
simple-server command
test-server command

Jump to

Keyboard shortcuts

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