refactor: 参数化 ONVIF 连接
This commit is contained in:
@ -5,21 +5,12 @@ import (
|
||||
)
|
||||
|
||||
type Connection struct {
|
||||
Params DeviceParams `json:"params"`
|
||||
Device *onvif.Device `json:"device"`
|
||||
}
|
||||
|
||||
type DeviceParams struct {
|
||||
Xaddr string `json:"xaddr"`
|
||||
EndpointRefAddress string `json:"endpointRefAddress"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
AuthMode string `json:"authMode"`
|
||||
}
|
||||
|
||||
func NewConnection(addr string, username string, password string) (*Connection, error) {
|
||||
func NewConnection(xaddr string, username string, password string) (*Connection, error) {
|
||||
dev, err := onvif.NewDevice(onvif.DeviceParams{
|
||||
Xaddr: addr,
|
||||
Xaddr: xaddr,
|
||||
Username: username,
|
||||
Password: password,
|
||||
})
|
||||
@ -27,14 +18,5 @@ func NewConnection(addr string, username string, password string) (*Connection,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Connection{
|
||||
Params: DeviceParams{
|
||||
Xaddr: dev.GetDeviceParams().Xaddr,
|
||||
EndpointRefAddress: dev.GetDeviceParams().EndpointRefAddress,
|
||||
Username: dev.GetDeviceParams().Username,
|
||||
Password: dev.GetDeviceParams().Password,
|
||||
AuthMode: dev.GetDeviceParams().AuthMode,
|
||||
},
|
||||
Device: dev,
|
||||
}, nil
|
||||
return &Connection{Device: dev}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user