mirror of
https://github.com/cedricve/go-onvif.git
synced 2025-09-26 20:41:34 +08:00
Remove some API for now
This commit is contained in:
75
device.go
75
device.go
@@ -1,7 +1,6 @@
|
||||
package onvif
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -43,25 +42,6 @@ func (device Device) GetInformation() (DeviceInformation, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetSystemDateAndTime fetch date and time from ONVIF camera
|
||||
func (device Device) GetSystemDateAndTime() (string, error) {
|
||||
// Create SOAP
|
||||
soap := SOAP{
|
||||
Body: "</tds:GetSystemDateAndTime>",
|
||||
XMLNs: deviceXMLNs,
|
||||
}
|
||||
|
||||
// Send SOAP request
|
||||
response, err := soap.SendRequest(device.XAddr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Parse response
|
||||
dateTime, _ := response.ValueForPathString("Envelope.Body.GetSystemDateAndTimeResponse.SystemDateAndTime")
|
||||
return dateTime, nil
|
||||
}
|
||||
|
||||
// GetCapabilities fetch info of ONVIF camera's capabilities
|
||||
func (device Device) GetCapabilities() (DeviceCapabilities, error) {
|
||||
// Create SOAP
|
||||
@@ -211,62 +191,7 @@ func (device Device) GetHostname() (HostnameInformation, error) {
|
||||
if mapHostInfo, ok := ifaceHostInfo.(map[string]interface{}); ok {
|
||||
hostnameInfo.Name = interfaceToString(mapHostInfo["Name"])
|
||||
hostnameInfo.FromDHCP = interfaceToBool(mapHostInfo["FromDHCP"])
|
||||
hostnameInfo.Extension = interfaceToString(mapHostInfo["Extension"])
|
||||
}
|
||||
|
||||
return hostnameInfo, nil
|
||||
}
|
||||
|
||||
// GetDNS fetch DNS of an ONVIF camera
|
||||
func (device Device) GetDNS() (string, error) {
|
||||
// Create SOAP
|
||||
soap := SOAP{
|
||||
Body: "<tds:GetDNS/>",
|
||||
XMLNs: deviceXMLNs,
|
||||
}
|
||||
|
||||
// Send SOAP request
|
||||
response, err := soap.SendRequest(device.XAddr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
bt, _ := response.JsonIndent("", " ")
|
||||
fmt.Println(string(bt))
|
||||
|
||||
// Parse response
|
||||
DNS, _ := response.ValueForPathString("Envelope.Body.GetDNSResponse.DNSInformation")
|
||||
return DNS, nil
|
||||
}
|
||||
|
||||
// GetDNS fetch DNS of an ONVIF camera
|
||||
func (device Device) GetNetworkInterfaces() (string, error) {
|
||||
// Create SOAP
|
||||
soap := SOAP{
|
||||
Body: "<tds:GetNetworkInterfaces/>",
|
||||
XMLNs: deviceXMLNs,
|
||||
}
|
||||
|
||||
// Send SOAP request
|
||||
response, err := soap.SendRequest(device.XAddr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
bt, _ := response.JsonIndent("", " ")
|
||||
fmt.Println(string(bt))
|
||||
|
||||
// Parse response
|
||||
DNS, _ := response.ValueForPathString("Envelope.Body.GetDNSResponse.DNSInformation")
|
||||
return DNS, nil
|
||||
}
|
||||
|
||||
func interfaceToString(src interface{}) string {
|
||||
str, _ := src.(string)
|
||||
return str
|
||||
}
|
||||
|
||||
func interfaceToBool(src interface{}) bool {
|
||||
strBool := interfaceToString(src)
|
||||
return strings.ToLower(strBool) == "true"
|
||||
}
|
||||
|
5
model.go
5
model.go
@@ -35,7 +35,6 @@ type DeviceCapabilities struct {
|
||||
|
||||
// HostnameInformation contains hostname info of an ONVIF camera
|
||||
type HostnameInformation struct {
|
||||
Name string
|
||||
FromDHCP bool
|
||||
Extension string
|
||||
Name string
|
||||
FromDHCP bool
|
||||
}
|
||||
|
21
utils.go
Normal file
21
utils.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package onvif
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func interfaceToString(src interface{}) string {
|
||||
str, _ := src.(string)
|
||||
return str
|
||||
}
|
||||
|
||||
func interfaceToBool(src interface{}) bool {
|
||||
strBool := interfaceToString(src)
|
||||
return strings.ToLower(strBool) == "true"
|
||||
}
|
||||
|
||||
func prettyJSON(src interface{}) string {
|
||||
result, _ := json.MarshalIndent(&src, "", " ")
|
||||
return string(result)
|
||||
}
|
Reference in New Issue
Block a user