294 entries across the client, the discovery package and the server package, generated from the source on every deploy. Client methods take a context.Context first.
No method matches that. Try a shorter word.
Device
Information, capabilities, hostname, DNS, NTP, network and users.
func (c *Client) CreateUsers(ctx context.Context, users []*User) error
CreateUsers creates new user accounts.
func (c *Client) DeleteUsers(ctx context.Context, usernames []string) error
DeleteUsers deletes user accounts.
func (c *Client) GetCapabilities(ctx context.Context) (*Capabilities, error)
GetCapabilities retrieves device capabilities.
func (c *Client) GetDNS(ctx context.Context) (*DNSInformation, error)
GetDNS retrieves DNS configuration.
func (c *Client) GetDeviceInformation(ctx context.Context) (*DeviceInformation, error)
GetDeviceInformation retrieves device information.
func (c *Client) GetDiscoveryMode(ctx context.Context) (DiscoveryMode, error)
GetDiscoveryMode gets the discovery mode of a device.
func (c *Client) GetEndpointReference(ctx context.Context) (string, error)
GetEndpointReference gets the endpoint reference GUID.
func (c *Client) GetHostname(ctx context.Context) (*HostnameInformation, error)
GetHostname retrieves the device's hostname.
func (c *Client) GetNTP(ctx context.Context) (*NTPInformation, error)
GetNTP retrieves NTP configuration.
func (c *Client) GetNetworkDefaultGateway(ctx context.Context) (*NetworkGateway, error)
GetNetworkDefaultGateway gets the default gateway settings from a device.
func (c *Client) GetNetworkInterfaces(ctx context.Context) ([]*NetworkInterface, error)
GetNetworkInterfaces retrieves network interface configuration.
func (c *Client) GetNetworkProtocols(ctx context.Context) ([]*NetworkProtocol, error)
GetNetworkProtocols gets defined network protocols from a device.
func (c *Client) GetRemoteDiscoveryMode(ctx context.Context) (DiscoveryMode, error)
GetRemoteDiscoveryMode gets the remote discovery mode.
func (c *Client) GetScopes(ctx context.Context) ([]*Scope, error)
GetScopes retrieves configured scopes.
func (c *Client) GetServiceCapabilities(ctx context.Context) (*DeviceServiceCapabilities, error)
GetServiceCapabilities returns the capabilities of the device service.
func (c *Client) GetServices(ctx context.Context, includeCapability bool) ([]*Service, error)
GetServices returns information about services on the device.
func (c *Client) GetSystemDateAndTime(ctx context.Context) (interface{}, error)
GetSystemDateAndTime retrieves the device's system date and time.
Deprecated: Use GetSystemDateAndTimeTyped, which exposes the response as a
SystemDateTime instead of interface{}.
func (c *Client) GetSystemDateAndTimeTyped(ctx context.Context) (*SystemDateTime, error)
GetSystemDateAndTimeTyped retrieves the device's system date and time.
func (c *Client) GetUsers(ctx context.Context) ([]*User, error)
GetUsers retrieves user accounts.
func (c *Client) SetDiscoveryMode(ctx context.Context, mode DiscoveryMode) error
SetDiscoveryMode sets the discovery mode of a device.
func (c *Client) SetHostname(ctx context.Context, name string) error
SetHostname sets the device's hostname.
func (c *Client) SetNetworkDefaultGateway(ctx context.Context, gateway *NetworkGateway) error
SetNetworkDefaultGateway sets the default gateway settings on a device.
func (c *Client) SetNetworkProtocols(ctx context.Context, protocols []*NetworkProtocol) error
SetNetworkProtocols configures defined network protocols on a device.
func (c *Client) SetRemoteDiscoveryMode(ctx context.Context, mode DiscoveryMode) error
SetRemoteDiscoveryMode sets the remote discovery mode.
func (c *Client) SetUser(ctx context.Context, user *User) error
SetUser modifies an existing user account.
func (c *Client) SystemReboot(ctx context.Context) (string, error)
SystemReboot reboots the device.
Device: extended
Further device configuration.
func (c *Client) AddScopes(ctx context.Context, scopeItems []string) error
AddScopes adds new configurable scope parameters to a device.
func (c *Client) FixedGetSystemDateAndTime(ctx context.Context) (*SystemDateTime, error)
FixedGetSystemDateAndTime retrieves the device's system date and time with proper typing.
Deprecated: Use GetSystemDateAndTimeTyped.
func (c *Client) GetRelayOutputs(ctx context.Context) ([]*RelayOutput, error)
GetRelayOutputs gets a list of all available relay outputs and their settings.
func (c *Client) GetSystemBackup(ctx context.Context) ([]*BackupFile, error)
GetSystemBackup retrieves system backup configuration files from a device.
func (c *Client) GetSystemLog(ctx context.Context, logType SystemLogType) (*SystemLog, error)
GetSystemLog gets a system log from the device.
func (c *Client) GetSystemSupportInformation(ctx context.Context) (*SupportInformation, error)
GetSystemSupportInformation gets arbitrary device diagnostics information.
func (c *Client) GetSystemUris(
ctx context.Context,
) (uriList *SystemLogURIList, systemBackupURI, systemLogURI string, err error)
GetSystemUris retrieves URIs from which system information may be downloaded.
func (c *Client) RemoveScopes(ctx context.Context, scopeItems []string) ([]string, error)
RemoveScopes deletes scope-configurable scope parameters from a device.
func (c *Client) RestoreSystem(ctx context.Context, backupFiles []*BackupFile) error
RestoreSystem restores the system backup configuration files.
func (c *Client) SendAuxiliaryCommand(ctx context.Context, command AuxiliaryData) (AuxiliaryData, error)
SendAuxiliaryCommand sends an auxiliary command to the device.
func (c *Client) SetDNS(ctx context.Context, fromDHCP bool, searchDomain []string, dnsManual []IPAddress) error
SetDNS sets the DNS settings on a device.
func (c *Client) SetHostnameFromDHCP(ctx context.Context, fromDHCP bool) (bool, error)
SetHostnameFromDHCP controls whether the hostname is set manually or retrieved via DHCP.
func (c *Client) SetNTP(ctx context.Context, fromDHCP bool, ntpManual []NetworkHost) error
SetNTP sets the NTP settings on a device.
func (c *Client) SetRelayOutputSettings(ctx context.Context, token string, settings *RelayOutputSettings) error
SetRelayOutputSettings sets the settings of a relay output.
func (c *Client) SetRelayOutputState(ctx context.Context, token string, state RelayLogicalState) error
SetRelayOutputState sets the state of a relay output.
func (c *Client) SetScopes(ctx context.Context, scopes []string) error
SetScopes sets the scope parameters of a device.
func (c *Client) SetSystemDateAndTime(ctx context.Context, dateTime *SystemDateTime) error
SetSystemDateAndTime sets the device system date and time.
func (c *Client) SetSystemFactoryDefault(ctx context.Context, factoryDefault FactoryDefaultType) error
SetSystemFactoryDefault reloads the parameters on the device to their factory default values.
func (c *Client) StartFirmwareUpgrade(
ctx context.Context,
) (uploadURI, uploadDelay, expectedDownTime string, err error)
StartFirmwareUpgrade initiates a firmware upgrade using the HTTP POST mechanism.
func (c *Client) StartSystemRestore(ctx context.Context) (uploadURI, expectedDownTime string, err error)
StartSystemRestore initiates a system restore from backed up configuration data.
Media
Profiles, stream and snapshot URIs, and encoder, source and metadata configuration.
func (c *Client) AddAudioDecoderConfiguration(ctx context.Context, profileToken, configurationToken string) error
AddAudioDecoderConfiguration adds an audio decoder configuration to a profile.
func (c *Client) AddAudioEncoderConfiguration(ctx context.Context, profileToken, configurationToken string) error
AddAudioEncoderConfiguration adds audio encoder configuration to a profile.
func (c *Client) AddAudioOutputConfiguration(ctx context.Context, profileToken, configurationToken string) error
AddAudioOutputConfiguration adds an audio output configuration to a profile.
func (c *Client) AddAudioSourceConfiguration(ctx context.Context, profileToken, configurationToken string) error
AddAudioSourceConfiguration adds audio source configuration to a profile.
func (c *Client) AddMetadataConfiguration(ctx context.Context, profileToken, configurationToken string) error
AddMetadataConfiguration adds metadata configuration to a profile.
func (c *Client) AddPTZConfiguration(ctx context.Context, profileToken, configurationToken string) error
AddPTZConfiguration adds PTZ configuration to a profile.
func (c *Client) AddVideoAnalyticsConfiguration(ctx context.Context, profileToken, configurationToken string) error
AddVideoAnalyticsConfiguration adds a video analytics configuration to a profile.
func (c *Client) AddVideoEncoderConfiguration(ctx context.Context, profileToken, configurationToken string) error
AddVideoEncoderConfiguration adds video encoder configuration to a profile.
func (c *Client) AddVideoSourceConfiguration(ctx context.Context, profileToken, configurationToken string) error
AddVideoSourceConfiguration adds video source configuration to a profile.
func (c *Client) CreateOSD(
ctx context.Context,
videoSourceConfigurationToken string,
osd *OSDConfiguration,
) (*OSDConfiguration, error)
CreateOSD creates a new OSD configuration.
func (c *Client) CreateProfile(ctx context.Context, name, token string) (*Profile, error)
CreateProfile creates a new media profile.
func (c *Client) DeleteOSD(ctx context.Context, osdToken string) error
DeleteOSD deletes an OSD configuration.
func (c *Client) DeleteProfile(ctx context.Context, profileToken string) error
DeleteProfile deletes a media profile.
func (c *Client) GetAudioDecoderConfiguration(
ctx context.Context,
configurationToken string,
) (*AudioDecoderConfiguration, error)
GetAudioDecoderConfiguration retrieves a specific audio decoder configuration.
func (c *Client) GetAudioDecoderConfigurationOptions(
ctx context.Context,
configurationToken string,
) (*AudioDecoderConfigurationOptions, error)
GetAudioDecoderConfigurationOptions retrieves available options for audio decoder configuration.
func (c *Client) GetAudioDecoderConfigurations(ctx context.Context) ([]*AudioDecoderConfiguration, error)
GetAudioDecoderConfigurations retrieves all audio decoder configurations.
func (c *Client) GetAudioEncoderConfiguration(
ctx context.Context,
configurationToken string,
) (*AudioEncoderConfiguration, error)
GetAudioEncoderConfiguration retrieves audio encoder configuration.
func (c *Client) GetAudioEncoderConfigurationOptions(
ctx context.Context,
configurationToken, profileToken string,
) (*AudioEncoderConfigurationOptions, error)
GetAudioEncoderConfigurationOptions retrieves available options for audio encoder configuration.
func (c *Client) GetAudioEncoderConfigurations(ctx context.Context) ([]*AudioEncoderConfiguration, error)
GetAudioEncoderConfigurations retrieves all audio encoder configurations.
func (c *Client) GetAudioOutputConfiguration(ctx context.Context, configurationToken string) (*AudioOutputConfiguration, error)
GetAudioOutputConfiguration retrieves audio output configuration.
func (c *Client) GetAudioOutputConfigurationOptions(
ctx context.Context,
configurationToken string,
) (*AudioOutputConfigurationOptions, error)
GetAudioOutputConfigurationOptions retrieves available options for audio output configuration.
func (c *Client) GetAudioOutputConfigurations(ctx context.Context) ([]*AudioOutputConfiguration, error)
GetAudioOutputConfigurations retrieves all audio output configurations.
func (c *Client) GetAudioOutputs(ctx context.Context) ([]*AudioOutput, error)
GetAudioOutputs retrieves all audio outputs.
func (c *Client) GetAudioSourceConfiguration(ctx context.Context, configurationToken string) (*AudioSourceConfiguration, error)
GetAudioSourceConfiguration retrieves a specific audio source configuration.
func (c *Client) GetAudioSourceConfigurationOptions(
ctx context.Context,
configurationToken, profileToken string,
) (*AudioSourceConfigurationOptions, error)
GetAudioSourceConfigurationOptions retrieves available options for audio source configuration.
func (c *Client) GetAudioSourceConfigurations(ctx context.Context) ([]*AudioSourceConfiguration, error)
GetAudioSourceConfigurations retrieves all audio source configurations.
func (c *Client) GetAudioSources(ctx context.Context) ([]*AudioSource, error)
GetAudioSources retrieves all audio sources.
func (c *Client) GetCompatibleAudioDecoderConfigurations(ctx context.Context, profileToken string) ([]*AudioDecoderConfiguration, error)
GetCompatibleAudioDecoderConfigurations retrieves compatible audio decoder configurations for a profile.
func (c *Client) GetCompatibleAudioEncoderConfigurations(
ctx context.Context,
profileToken string,
) ([]*AudioEncoderConfiguration, error)
GetCompatibleAudioEncoderConfigurations retrieves compatible audio encoder configurations for a profile.
func (c *Client) GetCompatibleAudioOutputConfigurations(ctx context.Context, profileToken string) ([]*AudioOutputConfiguration, error)
GetCompatibleAudioOutputConfigurations retrieves compatible audio output configurations for a profile.
func (c *Client) GetCompatibleAudioSourceConfigurations(ctx context.Context, profileToken string) ([]*AudioSourceConfiguration, error)
GetCompatibleAudioSourceConfigurations retrieves compatible audio source configurations for a profile.
func (c *Client) GetCompatibleMetadataConfigurations(ctx context.Context, profileToken string) ([]*MetadataConfiguration, error)
GetCompatibleMetadataConfigurations retrieves compatible metadata configurations for a profile.
func (c *Client) GetCompatiblePTZConfigurations(ctx context.Context, profileToken string) ([]*PTZConfiguration, error)
GetCompatiblePTZConfigurations retrieves compatible PTZ configurations for a profile.
func (c *Client) GetCompatibleVideoAnalyticsConfigurations(ctx context.Context, profileToken string) ([]*VideoAnalyticsConfiguration, error)
GetCompatibleVideoAnalyticsConfigurations retrieves compatible video analytics configurations for a profile.
func (c *Client) GetCompatibleVideoEncoderConfigurations(
ctx context.Context,
profileToken string,
) ([]*VideoEncoderConfiguration, error)
GetCompatibleVideoEncoderConfigurations retrieves compatible video encoder configurations for a profile.
func (c *Client) GetCompatibleVideoSourceConfigurations(
ctx context.Context,
profileToken string,
) ([]*VideoSourceConfiguration, error)
GetCompatibleVideoSourceConfigurations retrieves compatible video source configurations for a profile.
func (c *Client) GetGuaranteedNumberOfVideoEncoderInstances(
ctx context.Context,
configurationToken string,
) (*GuaranteedNumberOfVideoEncoderInstances, error)
GetGuaranteedNumberOfVideoEncoderInstances retrieves the guaranteed number of video encoder instances.
func (c *Client) GetMediaServiceCapabilities(ctx context.Context) (*MediaServiceCapabilities, error)
GetMediaServiceCapabilities retrieves media service capabilities.
func (c *Client) GetMetadataConfiguration(
ctx context.Context,
configurationToken string,
) (*MetadataConfiguration, error)
GetMetadataConfiguration retrieves metadata configuration.
func (c *Client) GetMetadataConfigurationOptions(
ctx context.Context,
configurationToken, profileToken string,
) (*MetadataConfigurationOptions, error)
GetMetadataConfigurationOptions retrieves available options for metadata configuration.
func (c *Client) GetMetadataConfigurations(ctx context.Context) ([]*MetadataConfiguration, error)
GetMetadataConfigurations retrieves all metadata configurations.
func (c *Client) GetOSD(ctx context.Context, osdToken string) (*OSDConfiguration, error)
GetOSD retrieves a specific OSD configuration.
func (c *Client) GetOSDOptions(ctx context.Context, configurationToken string) (*OSDConfigurationOptions, error)
GetOSDOptions retrieves available options for OSD configuration.
func (c *Client) GetOSDs(ctx context.Context, configurationToken string) ([]*OSDConfiguration, error)
GetOSDs retrieves all OSD configurations.
func (c *Client) GetProfile(ctx context.Context, profileToken string) (*Profile, error)
GetProfile retrieves a specific media profile.
func (c *Client) GetProfiles(ctx context.Context) ([]*Profile, error)
GetProfiles retrieves all media profiles.
func (c *Client) GetSnapshotURI(ctx context.Context, profileToken string) (*MediaURI, error)
GetSnapshotURI retrieves the snapshot URI for a profile.
func (c *Client) GetStreamURI(ctx context.Context, profileToken string) (*MediaURI, error)
GetStreamURI retrieves the stream URI for a profile.
func (c *Client) GetVideoAnalyticsConfiguration(
ctx context.Context,
configurationToken string,
) (*VideoAnalyticsConfiguration, error)
GetVideoAnalyticsConfiguration retrieves a specific video analytics configuration.
func (c *Client) GetVideoAnalyticsConfigurationOptions(
ctx context.Context,
configurationToken, profileToken string,
) (*VideoAnalyticsConfigurationOptions, error)
GetVideoAnalyticsConfigurationOptions retrieves available options for video analytics configuration.
func (c *Client) GetVideoAnalyticsConfigurations(ctx context.Context) ([]*VideoAnalyticsConfiguration, error)
GetVideoAnalyticsConfigurations retrieves all video analytics configurations.
func (c *Client) GetVideoEncoderConfiguration(
ctx context.Context,
configurationToken string,
) (*VideoEncoderConfiguration, error)
GetVideoEncoderConfiguration retrieves video encoder configuration.
func (c *Client) GetVideoEncoderConfigurationOptions(
ctx context.Context, configurationToken string,
) (*VideoEncoderConfigurationOptions, error)
GetVideoEncoderConfigurationOptions retrieves available options for video encoder configuration.
func (c *Client) GetVideoEncoderConfigurations(ctx context.Context) ([]*VideoEncoderConfiguration, error)
GetVideoEncoderConfigurations retrieves all video encoder configurations.
func (c *Client) GetVideoSourceConfiguration(
ctx context.Context,
configurationToken string,
) (*VideoSourceConfiguration, error)
GetVideoSourceConfiguration retrieves a specific video source configuration.
func (c *Client) GetVideoSourceConfigurationOptions(
ctx context.Context,
configurationToken, profileToken string,
) (*VideoSourceConfigurationOptions, error)
GetVideoSourceConfigurationOptions retrieves available options for video source configuration.
func (c *Client) GetVideoSourceConfigurations(ctx context.Context) ([]*VideoSourceConfiguration, error)
GetVideoSourceConfigurations retrieves all video source configurations.
func (c *Client) GetVideoSourceModes(ctx context.Context, videoSourceToken string) ([]*VideoSourceMode, error)
GetVideoSourceModes retrieves available video source modes.
func (c *Client) GetVideoSources(ctx context.Context) ([]*VideoSource, error)
GetVideoSources retrieves all video sources.
func (c *Client) RemoveAudioDecoderConfiguration(ctx context.Context, profileToken string) error
RemoveAudioDecoderConfiguration removes an audio decoder configuration from a profile.
func (c *Client) RemoveAudioEncoderConfiguration(ctx context.Context, profileToken string) error
RemoveAudioEncoderConfiguration removes audio encoder configuration from a profile.
func (c *Client) RemoveAudioOutputConfiguration(ctx context.Context, profileToken string) error
RemoveAudioOutputConfiguration removes an audio output configuration from a profile.
func (c *Client) RemoveAudioSourceConfiguration(ctx context.Context, profileToken string) error
RemoveAudioSourceConfiguration removes audio source configuration from a profile.
func (c *Client) RemoveMetadataConfiguration(ctx context.Context, profileToken string) error
RemoveMetadataConfiguration removes metadata configuration from a profile.
func (c *Client) RemovePTZConfiguration(ctx context.Context, profileToken string) error
RemovePTZConfiguration removes PTZ configuration from a profile.
func (c *Client) RemoveVideoAnalyticsConfiguration(ctx context.Context, profileToken string) error
RemoveVideoAnalyticsConfiguration removes a video analytics configuration from a profile.
func (c *Client) RemoveVideoEncoderConfiguration(ctx context.Context, profileToken string) error
RemoveVideoEncoderConfiguration removes video encoder configuration from a profile.
func (c *Client) RemoveVideoSourceConfiguration(ctx context.Context, profileToken string) error
RemoveVideoSourceConfiguration removes video source configuration from a profile.
func (c *Client) SetAudioDecoderConfiguration(ctx context.Context, config *AudioDecoderConfiguration, forcePersistence bool) error
SetAudioDecoderConfiguration sets audio decoder configuration.
func (c *Client) SetAudioEncoderConfiguration(
ctx context.Context,
config *AudioEncoderConfiguration,
forcePersistence bool,
) error
SetAudioEncoderConfiguration sets audio encoder configuration.
func (c *Client) SetAudioOutputConfiguration(ctx context.Context, config *AudioOutputConfiguration, forcePersistence bool) error
SetAudioOutputConfiguration sets audio output configuration.
func (c *Client) SetAudioSourceConfiguration(ctx context.Context, config *AudioSourceConfiguration, forcePersistence bool) error
SetAudioSourceConfiguration sets audio source configuration.
func (c *Client) SetMetadataConfiguration(
ctx context.Context,
config *MetadataConfiguration,
forcePersistence bool,
) error
SetMetadataConfiguration sets metadata configuration.
func (c *Client) SetOSD(ctx context.Context, osd *OSDConfiguration) error
SetOSD sets OSD configuration.
func (c *Client) SetProfile(ctx context.Context, profile *Profile) error
SetProfile sets profile configuration.
func (c *Client) SetSynchronizationPoint(ctx context.Context, profileToken string) error
SetSynchronizationPoint sets a synchronization point for the stream.
func (c *Client) SetVideoAnalyticsConfiguration(ctx context.Context, config *VideoAnalyticsConfiguration, forcePersistence bool) error
SetVideoAnalyticsConfiguration sets video analytics configuration.
func (c *Client) SetVideoEncoderConfiguration(
ctx context.Context,
config *VideoEncoderConfiguration,
forcePersistence bool,
) error
SetVideoEncoderConfiguration sets video encoder configuration.
func (c *Client) SetVideoSourceConfiguration(
ctx context.Context,
config *VideoSourceConfiguration,
forcePersistence bool,
) error
SetVideoSourceConfiguration sets video source configuration.
func (c *Client) SetVideoSourceMode(ctx context.Context, videoSourceToken, modeToken string) error
SetVideoSourceMode sets the video source mode.
func (c *Client) StartMulticastStreaming(ctx context.Context, profileToken string) error
StartMulticastStreaming starts multicast streaming.
func (c *Client) StopMulticastStreaming(ctx context.Context, profileToken string) error
StopMulticastStreaming stops multicast streaming.
Discovery package
Find cameras with WS-Discovery, or answer probes for your own devices.
const DefaultType = "{" + nsONVIFNet + "}NetworkVideoTransmitter"
DefaultType is the type a registered device advertises when it lists none:
dn:NetworkVideoTransmitter, which is what ONVIF clients probe for.
var (
// ErrNoProbeMatches is returned when no probe matches are found during discovery.
ErrNoProbeMatches = errors.New("no probe matches found")
// ErrNetworkInterfaceNotFound is returned when a network interface is not found.
ErrNetworkInterfaceNotFound = errors.New("network interface not found")
)
var ErrInvalidDevice = errors.New("invalid device")
ErrInvalidDevice is returned by Responder.Register for a device that cannot
be advertised.
var ErrMalformedProbe = errors.New("malformed probe")
ErrMalformedProbe marks a Probe the responder cannot interpret.
func StableEndpointRef(seed string) string
StableEndpointRef derives a "urn:uuid:" endpoint reference from seed. The
same seed always yields the same reference, on any host and across restarts,
so a device keeps its identity without anything being persisted. Use a name
that is stable for the device (for example "farm1/cam-07"); an empty seed is
valid but gives every caller the same reference.
type Device struct {
// Device endpoint address
EndpointRef string
// XAddrs contains the device service addresses
XAddrs []string
// Types contains the device types
Types []string
// Scopes contains the device scopes (name, location, etc.)
Scopes []string
// Metadata version
MetadataVersion int
}
Device represents a discovered ONVIF device.
func Discover(ctx context.Context, timeout time.Duration) ([]*Device, error)
Discover performs ONVIF device discovery using WS-Discovery protocol.
For advanced options like specifying a network interface, use DiscoverWithOptions.
func DiscoverWithOptions(ctx context.Context, timeout time.Duration, opts *DiscoverOptions) ([]*Device, error)
DiscoverWithOptions discovers ONVIF devices with custom options.
func (d *Device) GetDeviceEndpoint() string
GetDeviceEndpoint extracts the primary device endpoint from XAddrs.
func (d *Device) GetLocation() string
GetLocation extracts the device location from scopes.
func (d *Device) GetName() string
GetName extracts the device name from scopes.
type DiscoverOptions struct {
// NetworkInterface specifies the network interface to use for multicast.
// If empty, the system will choose the default interface.
// Examples: "eth0", "wlan0", "192.168.1.100"
NetworkInterface string
// ProbeAddress, when set, sends the probe by unicast to this UDP address
// ("host:port") from an ephemeral local port instead of using the
// WS-Discovery multicast group. It needs no multicast routing, so it works
// in containers and CI, and it pairs with ResponderConfig.ListenAddr.
// NetworkInterface is ignored when it is set.
ProbeAddress string
}
DiscoverOptions contains options for device discovery.
type NetworkInterface struct {
// Name of the interface (e.g., "eth0", "wlan0")
Name string
// IP addresses assigned to this interface
Addresses []string
// Up indicates if the interface is up
Up bool
// Multicast indicates if the interface supports multicast
Multicast bool
}
NetworkInterface represents a network interface.
func ListNetworkInterfaces() ([]NetworkInterface, error)
ListNetworkInterfaces returns all available network interfaces with their addresses.
type ProbeMatch struct {
XMLName xml.Name `xml:"ProbeMatch"`
EndpointRef string `xml:"EndpointReference>Address"`
Types string `xml:"Types"`
Scopes string `xml:"Scopes"`
XAddrs string `xml:"XAddrs"`
MetadataVersion int `xml:"MetadataVersion"`
}
ProbeMatch represents a WS-Discovery probe match.
type ProbeMatches struct {
XMLName xml.Name `xml:"ProbeMatches"`
ProbeMatch []ProbeMatch `xml:"ProbeMatch"`
}
ProbeMatches represents WS-Discovery probe matches.
type Responder struct {
// contains filtered or unexported fields
}
Responder is a WS-Discovery target service. One Responder owns one socket
and answers Probe messages on behalf of every registered Device, so a fleet
of virtual cameras on one host shares a single multicast membership.
Supported: Probe/ProbeMatches with Types and Scopes filtering (MatchBy
rfc3986, strcmp0 and none), Hello on start, Bye on stop. Not supported:
Resolve/ResolveMatches, the ldap and uuid scope rules (such a probe matches
nothing), the 2009/01 (WS-Discovery 1.1) namespace, and managed mode with a
discovery proxy. Duplicate probes are answered each time.
func NewResponder(cfg *ResponderConfig) *Responder
NewResponder returns a Responder. A nil cfg uses multicast defaults.
func (r *Responder) Addr() net.Addr
Addr returns the bound socket address, or nil before Start has bound it.
func (r *Responder) Register(d *Device) error
Register advertises d. EndpointRef is required and identifies the device; a
second Register with the same EndpointRef replaces the first. Types entries
are "{namespace}Local" or the prefixed forms "dn:Local" (ONVIF network
namespace) and "tds:Local" (ONVIF device namespace); no Types means
DefaultType. If the responder is running, Register sends a Hello.
func (r *Responder) Start(ctx context.Context) error
Start binds the socket, sends Hello for every registered device, and answers
probes until ctx is canceled, then sends Bye for every device still
registered and returns nil. A bind failure is returned immediately.
func (r *Responder) Unregister(endpointRef string)
Unregister stops advertising the device with the given EndpointRef. If the
responder is running, it sends a Bye.
type ResponderConfig struct {
// NetworkInterface selects the interface that joins the multicast group,
// by name or IP address, as in DiscoverOptions. Ignored when ListenAddr
// is set.
NetworkInterface string
// ListenAddr switches the responder to unicast mode. It binds this UDP
// address (for example "127.0.0.1:0") instead of joining
// 239.255.255.250:3702, so it needs no multicast routing and several
// responders can coexist on one host. Pair it with
// DiscoverOptions.ProbeAddress. Intended for tests and CI.
ListenAddr string
// AnnounceAddr is where Hello and Bye messages are sent. It defaults to
// the WS-Discovery multicast group in multicast mode. In unicast mode it
// defaults to empty, which disables announcements.
AnnounceAddr string
// MaxResponseDelay bounds a random pause before each ProbeMatches reply,
// which WS-Discovery recommends (APP_MAX_DELAY, 500ms) to keep a large
// fleet from answering one probe in the same instant. The default, zero,
// replies immediately.
MaxResponseDelay time.Duration
// Ready, when non-nil, is closed by Start once the socket is bound and
// Addr is valid. It is closed at most once.
Ready chan<- struct{}
}
ResponderConfig configures a Responder.
Server package
A virtual ONVIF camera: Device, Media, PTZ and Imaging services, with stable identities.
var (
// ErrVideoSourceNotFound is returned when a video source is not found.
// Aliased to the client package's sentinel so errors.Is matches
// regardless of whether the caller is comparing against the server or
// client package's error variable.
ErrVideoSourceNotFound = onvif.ErrVideoSourceNotFound
// ErrProfileNotFound is returned when a profile is not found.
ErrProfileNotFound = onvif.ErrProfileNotFound
// ErrSnapshotNotSupported is returned when snapshot is not supported for a profile.
ErrSnapshotNotSupported = onvif.ErrSnapshotNotSupported
// ErrPTZNotSupported is returned when PTZ is not supported for a profile.
ErrPTZNotSupported = onvif.ErrPTZNotSupported
// ErrPresetNotFound is returned when a preset is not found.
ErrPresetNotFound = onvif.ErrPresetNotFound
// ErrSubscriptionNotFound is returned when there is no active pull-point
// event subscription.
ErrSubscriptionNotFound = errors.New("no active pull-point subscription")
// ErrInvalidDuration is returned when an ISO-8601 duration string cannot
// be parsed.
ErrInvalidDuration = errors.New("invalid duration")
)
type AudioEncoderConfig struct {
Encoding string // G711, G726, AAC
Bitrate int // Bitrate in kbps
SampleRate int // Sample rate in Hz
}
AudioEncoderConfig represents audio encoder configuration.
type AudioSourceConfig struct {
Token string // Audio source token
Name string // Audio source name
SampleRate int // Sample rate in Hz (e.g., 8000, 16000, 48000)
Bitrate int // Bitrate in kbps
}
AudioSourceConfig represents audio source configuration.
type BacklightCompensation struct {
Mode string // OFF, ON
Level float64 // 0-100
}
BacklightCompensation represents backlight compensation settings.
type Bounds struct {
X int
Y int
Width int
Height int
}
Bounds represents video bounds.
type Config struct {
// Server settings
Host string // Bind address (e.g., "0.0.0.0")
Port int // Server port (default: 8080)
BasePath string // Base path for services (default: "/onvif")
Timeout time.Duration // Request timeout
// Device information
DeviceInfo DeviceInfo
// EndpointUUID is the device's stable endpoint identity, returned by
// GetEndpointReference (and the address WS-Discovery advertises). It may
// be given bare ("12345678-...") or as a "urn:uuid:" URI; the server
// always reports the URI form, which is what real cameras return. When
// empty, New generates one that stays fixed for the server's lifetime.
EndpointUUID string
// EndpointSeed derives the endpoint UUID from a stable name (see
// discovery.StableEndpointRef) when EndpointUUID is empty, so a restarted
// service gets the same identity back without persisting anything.
// EndpointUUID wins if both are set.
EndpointSeed string
// Authentication
Username string
Password string
// Camera profiles (supports multi-lens cameras)
Profiles []ProfileConfig
// Capabilities
SupportPTZ bool
SupportImaging bool
SupportEvents bool
// Output receives the human-readable startup banner and shutdown notice.
// It defaults to os.Stdout when nil, preserving the behavior of callers
// written before this field existed.
//
// Set it to io.Discard to silence the server. Do that in tests, where one
// banner per server instance is noise, and in any program whose stdout
// carries framed protocol data rather than console text - banner output
// would corrupt it. ServerInfo returns the same information as a string for
// callers that would rather place it themselves.
Output io.Writer
// Ready, when non-nil, is closed by Start once the listener is bound and
// accepting connections, so a caller need not sleep or poll-dial before
// its first request. It is closed at most once even if Start is called
// again.
Ready chan<- struct{}
}
Config represents the ONVIF server configuration.
func DefaultConfig() *Config
DefaultConfig returns a default server configuration with a multi-lens camera setup.
func (c *Config) ServiceEndpoints(host string) map[string]string
ServiceEndpoints returns the service endpoint URLs.
type DeviceInfo struct {
Manufacturer string
Model string
FirmwareVersion string
SerialNumber string
HardwareID string
}
DeviceInfo contains device identification information.
type ExposureSettings struct {
Mode string // AUTO, MANUAL
Priority string // LowNoise, FrameRate
MinExposure float64
MaxExposure float64
MinGain float64
MaxGain float64
ExposureTime float64
Gain float64
}
ExposureSettings represents exposure settings.
type FocusSettings struct {
AutoFocusMode string // AUTO, MANUAL
DefaultSpeed float64
NearLimit float64
FarLimit float64
CurrentPos float64
}
FocusSettings represents focus settings.
type ImagingState struct {
Brightness float64
Contrast float64
Saturation float64
Sharpness float64
BacklightComp BacklightCompensation
Exposure ExposureSettings
Focus FocusSettings
WhiteBalance WhiteBalanceSettings
WideDynamicRange WDRSettings
IrCutFilter string // ON, OFF, AUTO
}
ImagingState represents the current imaging settings state.
type PTZConfig struct {
NodeToken string // PTZ node token
PanRange Range // Pan range in degrees
TiltRange Range // Tilt range in degrees
ZoomRange Range // Zoom range
DefaultSpeed PTZSpeed // Default speed
SupportsContinuous bool // Supports continuous move
SupportsAbsolute bool // Supports absolute move
SupportsRelative bool // Supports relative move
Presets []Preset // Predefined presets
}
PTZConfig represents PTZ configuration.
type PTZPosition struct {
Pan float64 // Pan position
Tilt float64 // Tilt position
Zoom float64 // Zoom position
}
PTZPosition represents PTZ position.
type PTZSpeed struct {
Pan float64 // Pan speed (-1.0 to 1.0)
Tilt float64 // Tilt speed (-1.0 to 1.0)
Zoom float64 // Zoom speed (-1.0 to 1.0)
}
PTZSpeed represents PTZ movement speed.
type PTZState struct {
Position PTZPosition
Moving bool
PanMoving bool
TiltMoving bool
ZoomMoving bool
LastUpdate time.Time
// contains filtered or unexported fields
}
PTZState represents the current PTZ state.
type Preset struct {
Token string // Preset token
Name string // Preset name
Position PTZPosition // Position
}
Preset represents a PTZ preset position.
type ProfileConfig struct {
Token string // Profile token (unique identifier)
Name string // Profile name
VideoSource VideoSourceConfig // Video source configuration
AudioSource *AudioSourceConfig // Audio source configuration (optional)
VideoEncoder VideoEncoderConfig // Video encoder configuration
AudioEncoder *AudioEncoderConfig // Audio encoder configuration (optional)
PTZ *PTZConfig // PTZ configuration (optional)
Snapshot SnapshotConfig // Snapshot configuration
}
ProfileConfig represents a camera profile configuration.
func (p *ProfileConfig) ToONVIFProfile() *onvif.Profile
ToONVIFProfile converts a ProfileConfig to an ONVIF Profile.
type Range struct {
Min float64
Max float64
}
Range represents a numeric range.
type Resolution struct {
Width int
Height int
}
Resolution represents video resolution.
type Server struct {
// contains filtered or unexported fields
}
Server represents the ONVIF server.
func New(config *Config) (*Server, error)
New creates a new ONVIF server with the given configuration.
func (s *Server) Addr() string
Addr returns the address the server is listening on, or "" before Start has
bound one. With Config.Port set to 0 this is how a caller learns the port the
OS assigned.
func (s *Server) DiscoveryDevice() *discovery.Device
DiscoveryDevice describes this server as a WS-Discovery target, ready to
pass to discovery.Responder.Register. It carries the stable endpoint
reference (see Config.EndpointUUID), the device service XAddr, and the
standard ONVIF name, hardware, type and Streaming-profile scopes derived
from Config.DeviceInfo.
The XAddr uses the bound port, so call it after Start has bound the
listener (Config.Ready signals this); before that it reports Config.Port,
which is wrong for an OS-assigned port 0.
func (s *Server) EndpointReference() string
EndpointReference returns the device's endpoint identity in "urn:uuid:"
form, as reported by GetEndpointReference.
func (s *Server) GetConfig() *Config
GetConfig returns the server configuration.
func (s *Server) GetImagingState(videoSourceToken string) (*ImagingState, bool)
GetImagingState returns the current imaging state for a video source.
func (s *Server) GetPTZState(profileToken string) (*PTZState, bool)
GetPTZState returns the current PTZ state for a profile.
func (s *Server) GetStreamConfig(profileToken string) (*StreamConfig, bool)
GetStreamConfig returns the stream configuration for a profile.
func (s *Server) ListProfiles() []ProfileConfig
ListProfiles returns all configured profiles.
func (s *Server) ServerInfo() string
ServerInfo returns human-readable server information.
func (s *Server) Start(ctx context.Context) error
Start starts the ONVIF server.
func (s *Server) UpdateStreamURI(profileToken, uri string) error
UpdateStreamURI updates the RTSP URI for a profile.
type SnapshotConfig struct {
Enabled bool // Whether snapshots are supported
Resolution Resolution // Snapshot resolution
Quality float64 // JPEG quality (0-100)
}
SnapshotConfig represents snapshot configuration.
type StreamConfig struct {
ProfileToken string // Associated profile token
RTSPPath string // RTSP path (e.g., "/stream1")
StreamURI string // Full RTSP URI
}
StreamConfig represents an RTSP stream configuration.
type VideoEncoderConfig struct {
Encoding string // JPEG, H264, H265, MPEG4
Resolution Resolution // Video resolution
Quality float64 // Quality (0-100)
Framerate int // Frames per second
Bitrate int // Bitrate in kbps
GovLength int // GOP length
}
VideoEncoderConfig represents video encoder configuration.
type VideoSourceConfig struct {
Token string // Video source token
Name string // Video source name
Resolution Resolution
Framerate int
Bounds Bounds
}
VideoSourceConfig represents video source configuration.
type WDRSettings struct {
Mode string // OFF, ON
Level float64 // 0-100
}
WDRSettings represents wide dynamic range settings.
type WhiteBalanceSettings struct {
Mode string // AUTO, MANUAL
CrGain float64
CbGain float64
}
WhiteBalanceSettings represents white balance settings.