Documentation
¶
Index ¶
- Constants
- func FindTagValue(b []byte, tag string) string
- func GetCapabilitiesResponse(host string) []byte
- func GetDeviceInformationResponse(manuf, model, firmware, serial string) []byte
- func GetPosixTZ(current time.Time) string
- func GetProfileResponse(token, name string) []byte
- func GetProfilesResponse(profiles []StreamProfile) []byte
- func GetRequestAction(b []byte) string
- func GetScopesResponse(scopeName string) []byte
- func GetServicesResponse(host string) []byte
- func GetSnapshotUriResponse(uri string) []byte
- func GetStreamUriResponse(uri string) []byte
- func GetSystemDateAndTimeResponse() []byte
- func GetVideoEncoderConfigurationResponse() []byte
- func GetVideoEncoderConfigurationsResponse() []byte
- func GetVideoSourceConfigurationResponse(name string) []byte
- func GetVideoSourceConfigurationsResponse(names []string) []byte
- func GetVideoSourcesResponse(names []string) []byte
- func StaticResponse(operation, scopeName string) []byte
- type Config
- type Discovery
- type DiscoveryConfig
- type Envelope
- type Server
- type StreamProfile
- type StreamProvider
Constants ¶
const ( ServiceGetServiceCapabilities = "GetServiceCapabilities" DeviceGetCapabilities = "GetCapabilities" DeviceGetDeviceInformation = "GetDeviceInformation" DeviceGetDiscoveryMode = "GetDiscoveryMode" DeviceGetDNS = "GetDNS" DeviceGetHostname = "GetHostname" DeviceGetNetworkDefaultGateway = "GetNetworkDefaultGateway" DeviceGetNetworkInterfaces = "GetNetworkInterfaces" DeviceGetNetworkProtocols = "GetNetworkProtocols" DeviceGetNTP = "GetNTP" DeviceGetScopes = "GetScopes" DeviceGetServices = "GetServices" DeviceGetSystemDateAndTime = "GetSystemDateAndTime" DeviceSetSystemDateAndTime = "SetSystemDateAndTime" DeviceSystemReboot = "SystemReboot" MediaGetAudioEncoderConfigurations = "GetAudioEncoderConfigurations" MediaGetAudioSources = "GetAudioSources" MediaGetAudioSourceConfigurations = "GetAudioSourceConfigurations" MediaGetProfile = "GetProfile" MediaGetProfiles = "GetProfiles" MediaGetSnapshotUri = "GetSnapshotUri" MediaGetStreamUri = "GetStreamUri" MediaGetVideoEncoderConfiguration = "GetVideoEncoderConfiguration" MediaGetVideoEncoderConfigurations = "GetVideoEncoderConfigurations" MediaGetVideoEncoderConfigurationOptions = "GetVideoEncoderConfigurationOptions" MediaGetVideoSources = "GetVideoSources" MediaGetVideoSourceConfiguration = "GetVideoSourceConfiguration" MediaGetVideoSourceConfigurations = "GetVideoSourceConfigurations" )
ONVIF SOAP 操作名常量,与 go2rtc 对齐以便兼容 HA 等客户端。
Variables ¶
This section is empty.
Functions ¶
func FindTagValue ¶
FindTagValue 从 XML 中提取首个匹配标签的文本内容。
func GetCapabilitiesResponse ¶
GetCapabilitiesResponse 返回 Device/Media 服务地址,HA 依赖 Media 段。
func GetDeviceInformationResponse ¶
GetDeviceInformationResponse 返回设备信息,SerialNumber 供 HA 作为唯一 ID。
func GetProfileResponse ¶
GetProfileResponse 返回单个 Profile。
func GetProfilesResponse ¶
func GetProfilesResponse(profiles []StreamProfile) []byte
GetProfilesResponse 将全部流映射为 ONVIF Profile 列表。
func GetRequestAction ¶
GetRequestAction 从 SOAP 请求体解析操作名(如 GetCapabilities)。
func GetScopesResponse ¶
GetScopesResponse 返回设备 Scope 列表。
func GetServicesResponse ¶
GetServicesResponse 列出设备与媒体服务端点。
func GetSnapshotUriResponse ¶
GetSnapshotUriResponse 返回截图 HTTP 地址。
func GetStreamUriResponse ¶
GetStreamUriResponse 返回 RTSP 播放地址。
func GetSystemDateAndTimeResponse ¶
func GetSystemDateAndTimeResponse() []byte
GetSystemDateAndTimeResponse 返回当前系统时间,HA 接入必需。
func GetVideoEncoderConfigurationResponse ¶
func GetVideoEncoderConfigurationResponse() []byte
GetVideoEncoderConfigurationResponse 返回单个编码器配置。
func GetVideoEncoderConfigurationsResponse ¶
func GetVideoEncoderConfigurationsResponse() []byte
GetVideoEncoderConfigurationsResponse 返回编码器配置列表。
func GetVideoSourceConfigurationResponse ¶
GetVideoSourceConfigurationResponse 返回单个视频源配置。
func GetVideoSourceConfigurationsResponse ¶
GetVideoSourceConfigurationsResponse 返回视频源配置列表。
func GetVideoSourcesResponse ¶
GetVideoSourcesResponse 返回视频源列表。
func StaticResponse ¶
StaticResponse 返回预置或动态生成的静态 SOAP 响应。
Types ¶
type Config ¶
type Config struct {
Manufacturer string // 制造商
Model string // 型号
Version string // 固件版本
SerialNumber string // 序列号,HA 用作设备唯一标识
ScopeName string // GetScopes 中的 onvif name 段,默认 owl
Username string // WS-Security 用户名,与 Password 同时配置时启用鉴权
Password string // WS-Security 密码
AdvertiseHost string // SOAP XAddr 对外 IP,请求 Host 为回环时替换
}
Config ONVIF 虚拟设备元数据。
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery 在 UDP 3702 应答 Probe,供 HA 等客户端自动发现。
func NewDiscovery ¶
func NewDiscovery(cfg DiscoveryConfig) (*Discovery, error)
NewDiscovery 创建 WS-Discovery 服务;HTTPPort 必须大于 0。
type DiscoveryConfig ¶
type DiscoveryConfig struct {
HTTPPort int // SOAP 与 Web 共用端口,写入 XAddrs
Host string // 对外宣告 IP/主机名,空则按 Probe 来源网卡自动探测
Name string // onvif://www.onvif.org/name/ 段
EndpointID string // wsa:Address,空则启动时生成 uuid
}
DiscoveryConfig WS-Discovery 服务端(对外广播本机 ONVIF 设备)配置。
type Envelope ¶
type Envelope struct {
// contains filtered or unexported fields
}
Envelope 用于拼接 SOAP 响应体,避免 encoding/xml 的命名空间问题。
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server 可嵌入的 ONVIF Device/Media SOAP 服务端。
type StreamProfile ¶
StreamProfile 一条 ONVIF Profile:Token 必须唯一,Name 供客户端展示。
type StreamProvider ¶
type StreamProvider interface {
// ListStreamProfiles 返回全部通道对应的 Profile(含离线通道)。
ListStreamProfiles() []StreamProfile
// GetStreamURI 根据 Profile Token 与 HTTP Host 生成 RTSP 地址。
GetStreamURI(profileToken, requestHost string) string
// GetSnapshotURI 根据 Profile Token 与 HTTP Host 生成截图地址,无截图可返回空串。
GetSnapshotURI(profileToken, requestHost string) string
}
StreamProvider 由宿主应用实现,向 ONVIF 服务端提供可暴露的流列表与地址。