simple mod to github.com/use-go/onvif

This commit is contained in:
Edward
2020-04-29 10:53:49 +08:00
parent 331969745b
commit 928207d461
11 changed files with 371 additions and 418 deletions

View File

@@ -1,8 +1,8 @@
package analytics
import (
"github.com/use-go/goonvif/xsd"
"github.com/use-go/goonvif/xsd/onvif"
"github.com/use-go/onvif/xsd"
"github.com/use-go/onvif/xsd/onvif"
)
type GetSupportedRules struct {

View File

@@ -1,4 +1,4 @@
package goonvif
package onvif
import (
"encoding/xml"
@@ -11,10 +11,10 @@ import (
"strings"
"github.com/beevik/etree"
"github.com/use-go/goonvif/device"
"github.com/use-go/goonvif/networking"
"github.com/yakovlevdmv/WS-Discovery"
"github.com/yakovlevdmv/gosoap"
"github.com/use-go/onvif/device"
"github.com/use-go/onvif/gosoap"
"github.com/use-go/onvif/networking"
wsdiscovery "github.com/use-go/onvif/ws-discovery"
)
//Xlmns XML Scheam
@@ -99,9 +99,9 @@ func readResponse(resp *http.Response) string {
//GetAvailableDevicesAtSpecificEthernetInterface ...
func GetAvailableDevicesAtSpecificEthernetInterface(interfaceName string) []Device {
/*
Call an WS-Discovery Probe Message to Discover NVT type Devices
Call an ws-discovery Probe Message to Discover NVT type Devices
*/
devices := WS_Discovery.SendProbe(interfaceName, nil, []string{"dn:" + NVT.String()}, map[string]string{"dn": "http://www.onvif.org/ver10/network/wsdl"})
devices := wsdiscovery.SendProbe(interfaceName, nil, []string{"dn:" + NVT.String()}, map[string]string{"dn": "http://www.onvif.org/ver10/network/wsdl"})
nvtDevices := make([]Device, 0)
////fmt.Println(devices)
for _, j := range devices {
@@ -144,7 +144,7 @@ func GetAvailableDevicesAtSpecificEthernetInterface(interfaceName string) []Devi
}
func (dev *Device) getSupportedServices(resp *http.Response) {
//resp, err := dev.CallMethod(Device.GetCapabilities{Category:"All"})
//resp, err := dev.CallMethod(device.GetCapabilities{Category:"All"})
//if err != nil {
// log.Println(err.Error())
//return
@@ -195,7 +195,7 @@ func (dev *Device) addEndpoint(Key, Value string) {
dev.endpoints[lowCaseKey] = Value
}
//Authenticate function authenticate client in the ONVIF Device.
//Authenticate function authenticate client in the ONVIF device.
//Function takes <username> and <password> params.
//You should use this function to allow authorized requests to the ONVIF Device
//To change auth data call this function again.
@@ -252,52 +252,15 @@ func (dev Device) CallMethod(method interface{}) (*http.Response, error) {
pkgPath := strings.Split(reflect.TypeOf(method).PkgPath(), "/")
pkg := strings.ToLower(pkgPath[len(pkgPath)-1])
if endpoint, err := dev.getEndpoint(pkg); err != nil {
return nil, err
} else {
if dev.login != "" && dev.password != "" {
return dev.callAuthorizedMethod(endpoint, method)
} else {
return dev.callNonAuthorizedMethod(endpoint, method)
}
}
}
//CallNonAuthorizedMethod functions call an method, defined <method> struct without authentication data
func (dev Device) callNonAuthorizedMethod(endpoint string, method interface{}) (*http.Response, error) {
//TODO: Get endpoint automatically
/*
Converting <method> struct to xml string representation
*/
output, err := xml.MarshalIndent(method, " ", " ")
endpoint, err := dev.getEndpoint(pkg)
if err != nil {
//log.Printf("error: %v\n", err.Error())
return nil, err
}
/*
Build an SOAP request with <method>
*/
soap, err := buildMethodSOAP(string(output))
if err != nil {
//log.Printf("error: %v\n", err)
return nil, err
}
/*
Adding namespaces
*/
soap.AddRootNamespaces(Xlmns)
/*
Sending request and returns the response
*/
return networking.SendSoap(endpoint, soap.String())
return dev.callMethodDo(endpoint, method)
}
//CallMethod functions call an method, defined <method> struct with authentication data
func (dev Device) callAuthorizedMethod(endpoint string, method interface{}) (*http.Response, error) {
func (dev Device) callMethodDo(endpoint string, method interface{}) (*http.Response, error) {
/*
Converting <method> struct to xml string representation
*/
@@ -306,7 +269,7 @@ func (dev Device) callAuthorizedMethod(endpoint string, method interface{}) (*ht
//log.Printf("error: %v\n", err.Error())
return nil, err
}
//fmt.Println(gosoap.SoapMessage(string(output)).StringIndent())
/*
Build an SOAP request with <method>
*/
@@ -316,12 +279,21 @@ func (dev Device) callAuthorizedMethod(endpoint string, method interface{}) (*ht
return nil, err
}
//fmt.Println(soap.StringIndent())
/*
Adding namespaces and WS-Security headers
*/
soap.AddRootNamespaces(Xlmns)
soap.AddWSSecurity(dev.login, dev.password)
//fmt.Println(soap.StringIndent())
//Header handling
soap.AddAction()
//Auth Handling
if dev.login != "" && dev.password != "" {
soap.AddWSSecurity(dev.login, dev.password)
}
//fmt.Println(soap.StringIndent())
/*
Sending request and returns the response
*/

View File

@@ -1,8 +1,8 @@
package device
import (
"github.com/use-go/goonvif/xsd"
"github.com/use-go/goonvif/xsd/onvif"
"github.com/use-go/onvif/xsd"
"github.com/use-go/onvif/xsd/onvif"
)
type Service struct {

View File

@@ -1,21 +1,124 @@
package event
import (
"github.com/use-go/goonvif/xsd"
"github.com/use-go/onvif/xsd"
)
type FilterType xsd.String
//Address Alias
type Address xsd.String
//<xsd:union memberTypes="xsd:dateTime xsd:duration"/>
//CurrentTime alias
type CurrentTime xsd.DateTime //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
//TerminationTime alias
type TerminationTime xsd.DateTime //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
//FixedTopicSet alias
type FixedTopicSet xsd.Boolean //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
//Documentation alias
type Documentation xsd.AnyType //wstop http://docs.oasis-open.org/wsn/t-1.xsd
//TopicExpressionDialect alias
type TopicExpressionDialect xsd.AnyURI
//Message alias
type Message xsd.AnyType
//ActionType for AttributedURIType
type ActionType AttributedURIType
//AttributedURIType in ws-addr
type AttributedURIType xsd.AnyURI //wsa https://www.w3.org/2005/08/addressing/ws-addr.xsd
//AbsoluteOrRelativeTimeType <xsd:union memberTypes="xsd:dateTime xsd:duration"/>
type AbsoluteOrRelativeTimeType struct { //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
xsd.DateTime
xsd.Duration
}
type SubscriptionPolicy struct { //tev http://www.onvif.org/ver10/events/wsdl
ChangedOnly xsd.Boolean `xml:"ChangedOnly,attr"`
//EndpointReferenceType in ws-addr
type EndpointReferenceType struct { //wsa http://www.w3.org/2005/08/addressing/ws-addr.xsd
Address AttributedURIType `xml:"wsnt:Address"`
ReferenceParameters ReferenceParametersType `xml:"wsnt:ReferenceParameters"`
Metadata MetadataType `xml:"wsnt:Metadata"`
}
// FilterType struct
type FilterType struct {
TopicExpression TopicExpressionType `xml:"wsnt:TopicExpression"`
MessageContent QueryExpressionType `xml:"wsnt:MessageContent"`
}
//EndpointReference alais
type EndpointReference EndpointReferenceType
//ReferenceParametersType in ws-addr
type ReferenceParametersType struct { //wsa https://www.w3.org/2005/08/addressing/ws-addr.xsd
//Here can be anyAttribute
}
//Metadata in ws-addr
type Metadata MetadataType //wsa https://www.w3.org/2005/08/addressing/ws-addr.xsd
//MetadataType in ws-addr
type MetadataType struct { //wsa https://www.w3.org/2005/08/addressing/ws-addr.xsd
//Here can be anyAttribute
}
//TopicSet alias
type TopicSet TopicSetType //wstop http://docs.oasis-open.org/wsn/t-1.xsd
//TopicSetType alias
type TopicSetType struct { //wstop http://docs.oasis-open.org/wsn/t-1.xsd
ExtensibleDocumented
//here can be any element
}
//ExtensibleDocumented struct
type ExtensibleDocumented struct { //wstop http://docs.oasis-open.org/wsn/t-1.xsd
Documentation Documentation //к xsd-документе documentation с маленькой буквы начинается
//here can be anyAttribute
}
//ProducerReference Alias
type ProducerReference EndpointReferenceType
//SubscriptionReference Alias
type SubscriptionReference EndpointReferenceType
//NotificationMessageHolderType Alias
type NotificationMessageHolderType struct {
SubscriptionReference SubscriptionReference //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
Topic Topic
ProducerReference ProducerReference
Message Message
}
//NotificationMessage Alias
type NotificationMessage NotificationMessageHolderType //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
//QueryExpressionType struct for wsnt:MessageContent
type QueryExpressionType struct { //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
Dialect xsd.AnyURI `xml:"Dialect,attr"`
MessageKind xsd.String `xml:",chardata"` // boolean(ncex:Producer="15")
}
//MessageContentType Alias
type MessageContentType QueryExpressionType
//QueryExpression Alias
type QueryExpression QueryExpressionType
//TopicExpressionType struct for wsnt:TopicExpression
type TopicExpressionType struct { //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
Dialect xsd.AnyURI `xml:"Dialect,attr"`
TopicKinds xsd.String `xml:",chardata"`
}
//Topic Alias
type Topic TopicExpressionType
// Capabilities of event
type Capabilities struct { //tev
WSSubscriptionPolicySupport xsd.Boolean `xml:"WSSubscriptionPolicySupport,attr"`
WSPullPointSupport xsd.Boolean `xml:"WSPullPointSupport,attr"`
@@ -25,172 +128,50 @@ type Capabilities struct { //tev
PersistentNotificationStorage xsd.Boolean `xml:"PersistentNotificationStorage,attr"`
}
type EndpointReferenceType struct { //wsa http://www.w3.org/2005/08/addressing/ws-addr.xsd
Address AttributedURIType
ReferenceParameters ReferenceParametersType
Metadata // todo:разобраться с этим: понять, на какой тип ссылается
}
type AttributedURIType struct { //wsa https://www.w3.org/2005/08/addressing/ws-addr.xsd
Any xsd.AnyURI //extension
//Here can be anyAttribute
}
type ReferenceParametersType struct { //wsa https://www.w3.org/2005/08/addressing/ws-addr.xsd
Any string
//Here can be anyAttribute
}
type Metadata MetadataType //wsa https://www.w3.org/2005/08/addressing/ws-addr.xsd
type MetadataType struct { //wsa https://www.w3.org/2005/08/addressing/ws-addr.xsd
Any string
//Here can be anyAttribute
}
type CurrentTime xsd.DateTime //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
type TerminationTime xsd.DateTime //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
type FixedTopicSet xsd.Boolean //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
type TopicSet TopicSetType //wstop http://docs.oasis-open.org/wsn/t-1.xsd
type TopicSetType struct { //wstop http://docs.oasis-open.org/wsn/t-1.xsd
ExtensibleDocumented
//here can be any element
}
type ExtensibleDocumented struct { //wstop http://docs.oasis-open.org/wsn/t-1.xsd
Documentation Documentation //к xsd-документе documentation с маленькой буквы начинается
//here can be anyAttribute
}
type Documentation xsd.AnyType //wstop http://docs.oasis-open.org/wsn/t-1.xsd
type TopicExpressionDialect xsd.AnyURI
type NotificationMessage NotificationMessageHolderType //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
type NotificationMessageHolderType struct {
SubscriptionReference SubscriptionReference //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
Topic Topic
ProducerReference ProducerReference
Message Message
}
type SubscriptionReference EndpointReferenceType
type Topic TopicExpressionType
type ProducerReference EndpointReferenceType
type Message xsd.AnyType
type TopicExpressionType struct { //wsnt http://docs.oasis-open.org/wsn/b-2.xsd
Dialect xsd.AnyURI `xml:"Dialect,attr"`
}
//Event main types
type GetServiceCapabilities struct {
XMLName string `xml:"tev:GetServiceCapabilities"`
}
type GetServiceCapabilitiesResponse struct {
Capabilities Capabilities
}
//BUG(r) Bad AbsoluteOrRelativeTimeType type
type CreatePullPointSubscription struct {
XMLName string `xml:"tev:CreatePullPointSubscription"`
Filter FilterType `xml:"tev:Filter"`
InitialTerminationTime AbsoluteOrRelativeTimeType `xml:"tev:InitialTerminationTime"`
SubscriptionPolicy SubscriptionPolicy `xml:"tev:SubscriptionPolicy"`
}
type CreatePullPointSubscriptionResponse struct {
SubscriptionReference EndpointReferenceType
CurrentTime CurrentTime
TerminationTime TerminationTime
}
//ResourceUnknownFault response type
type ResourceUnknownFault struct {
}
//InvalidFilterFault response type
type InvalidFilterFault struct {
}
//TopicExpressionDialectUnknownFault response type
type TopicExpressionDialectUnknownFault struct {
}
//InvalidTopicExpressionFault response type
type InvalidTopicExpressionFault struct {
}
//TopicNotSupportedFault response type
type TopicNotSupportedFault struct {
}
//InvalidProducerPropertiesExpressionFault response type
type InvalidProducerPropertiesExpressionFault struct {
}
//InvalidMessageContentExpressionFault response type
type InvalidMessageContentExpressionFault struct {
}
//UnacceptableInitialTerminationTimeFault response type
type UnacceptableInitialTerminationTimeFault struct {
}
//UnrecognizedPolicyRequestFault response type
type UnrecognizedPolicyRequestFault struct {
}
//UnsupportedPolicyRequestFault response type
type UnsupportedPolicyRequestFault struct {
}
//NotifyMessageNotSupportedFault response type
type NotifyMessageNotSupportedFault struct {
}
//SubscribeCreationFailedFault response type
type SubscribeCreationFailedFault struct {
}
type GetEventProperties struct {
XMLName string `xml:"tev:GetEventProperties"`
}
type GetEventPropertiesResponse struct {
TopicNamespaceLocation xsd.AnyURI
FixedTopicSet FixedTopicSet
TopicSet TopicSet
TopicExpressionDialect TopicExpressionDialect
MessageContentFilterDialect xsd.AnyURI
ProducerPropertiesFilterDialect xsd.AnyURI
MessageContentSchemaLocation xsd.AnyURI
}
//Port type PullPointSubscription
type PullMessages struct {
XMLName string `xml:"tev:PullMessages"`
Timeout xsd.Duration `xml:"tev:Timeout"`
MessageLimit xsd.Int `xml:"tev:MessageLimit"`
}
type PullMessagesResponse struct {
CurrentTime CurrentTime
TerminationTime TerminationTime
NotificationMessage NotificationMessage
}
type PullMessagesFaultResponse struct {
MaxTimeout xsd.Duration
MaxMessageLimit xsd.Int
}
type Seek struct {
XMLName string `xml:"tev:Seek"`
UtcTime xsd.DateTime `xml:"tev:UtcTime"`
Reverse xsd.Boolean `xml:"tev:Reverse"`
}
type SeekResponse struct {
}
type SetSynchronizationPoint struct {
XMLName string `xml:"tev:SetSynchronizationPoint"`
}
type SetSynchronizationPointResponse struct {
}

View File

@@ -1,8 +1,8 @@
package imaging
import (
"github.com/use-go/goonvif/xsd"
"github.com/use-go/goonvif/xsd/onvif"
"github.com/use-go/onvif/xsd"
"github.com/use-go/onvif/xsd/onvif"
)
type GetServiceCapabilities struct {

View File

@@ -1,8 +1,8 @@
package media
import (
"github.com/use-go/goonvif/xsd"
"github.com/use-go/goonvif/xsd/onvif"
"github.com/use-go/onvif/xsd"
"github.com/use-go/onvif/xsd/onvif"
)
type Capabilities struct {
@@ -86,7 +86,7 @@ type GetProfiles struct {
}
type GetProfilesResponse struct {
Profiles onvif.Profile
Profiles []onvif.Profile
}
type AddVideoEncoderConfiguration struct {

View File

@@ -1,8 +1,8 @@
package ptz
import (
"github.com/use-go/goonvif/xsd"
"github.com/use-go/goonvif/xsd/onvif"
"github.com/use-go/onvif/xsd"
"github.com/use-go/onvif/xsd/onvif"
)
type Capabilities struct {

View File

@@ -12,10 +12,10 @@ import (
"github.com/beevik/etree"
"github.com/gin-gonic/gin"
"github.com/yakovlevdmv/WS-Discovery"
"github.com/use-go/goonvif"
"github.com/use-go/goonvif/networking"
"github.com/yakovlevdmv/gosoap"
"github.com/use-go/onvif"
"github.com/use-go/onvif/gosoap"
"github.com/use-go/onvif/networking"
wsdiscovery "github.com/use-go/onvif/ws-discovery"
)
func RunApi() {
@@ -50,7 +50,8 @@ func RunApi() {
interfaceName := context.GetHeader("interface")
var response = "["
devices := WS_Discovery.SendProbe(interfaceName, nil, []string{"dn:NetworkVideoTransmitter"}, map[string]string{"dn": "http://www.onvif.org/ver10/network/wsdl"})
devices := wsdiscovery.SendProbe(interfaceName, nil, []string{"dn:NetworkVideoTransmitter"}, map[string]string{"dn": "http://www.onvif.org/ver10/network/wsdl"})
for _, j := range devices {
doc := etree.NewDocument()
if err := doc.ReadFromString(j); err != nil {
@@ -143,7 +144,7 @@ func callNecessaryMethod(serviceName, methodName, acceptedData, username, passwo
soap := gosoap.NewEmptySOAP()
soap.AddStringBodyContent(*resp)
soap.AddRootNamespaces(goonvif.Xlmns)
soap.AddRootNamespaces(onvif.Xlmns)
soap.AddWSSecurity(username, password)
servResp, err := networking.SendSoap(endpoint, soap.String())
@@ -160,7 +161,7 @@ func callNecessaryMethod(serviceName, methodName, acceptedData, username, passwo
}
func getEndpoint(service, xaddr string) (string, error) {
dev, err := goonvif.NewDevice(xaddr)
dev, err := onvif.NewDevice(xaddr)
if err != nil {
return "", err
}

View File

@@ -1,70 +1,71 @@
package api
import (
"github.com/use-go/goonvif/ptz"
"errors"
"github.com/use-go/goonvif/device"
"github.com/use-go/goonvif/Media"
"github.com/use-go/onvif/device"
"github.com/use-go/onvif/media"
"github.com/use-go/onvif/ptz"
)
func getPTZStructByName(name string) (interface{}, error) {
switch name {
case "GetServiceCapabilities":
return &PTZ.GetServiceCapabilities{}, nil
return &ptz.GetServiceCapabilities{}, nil
case "GetNodes":
return &PTZ.GetNodes{}, nil
return &ptz.GetNodes{}, nil
case "GetNode":
return &PTZ.GetNode{}, nil
return &ptz.GetNode{}, nil
case "GetConfiguration":
return &PTZ.GetConfiguration{}, nil
return &ptz.GetConfiguration{}, nil
case "GetConfigurations":
return &PTZ.GetConfigurations{}, nil
return &ptz.GetConfigurations{}, nil
case "SetConfiguration":
return &PTZ.SetConfiguration{}, nil
return &ptz.SetConfiguration{}, nil
case "GetConfigurationOptions":
return &PTZ.GetConfigurationOptions{}, nil
return &ptz.GetConfigurationOptions{}, nil
case "SendAuxiliaryCommand":
return &PTZ.SendAuxiliaryCommand{}, nil
return &ptz.SendAuxiliaryCommand{}, nil
case "GetPresets":
return &PTZ.GetPresets{}, nil
return &ptz.GetPresets{}, nil
case "SetPreset":
return &PTZ.SetPreset{}, nil
return &ptz.SetPreset{}, nil
case "RemovePreset":
return &PTZ.RemovePreset{}, nil
return &ptz.RemovePreset{}, nil
case "GotoPreset":
return &PTZ.GotoPreset{}, nil
return &ptz.GotoPreset{}, nil
case "GotoHomePosition":
return &PTZ.GotoHomePosition{}, nil
return &ptz.GotoHomePosition{}, nil
case "SetHomePosition":
return &PTZ.SetHomePosition{}, nil
return &ptz.SetHomePosition{}, nil
case "ContinuousMove":
return &PTZ.ContinuousMove{}, nil
return &ptz.ContinuousMove{}, nil
case "RelativeMove":
return &PTZ.RelativeMove{}, nil
return &ptz.RelativeMove{}, nil
case "GetStatus":
return &PTZ.GetStatus{}, nil
return &ptz.GetStatus{}, nil
case "AbsoluteMove":
return &PTZ.AbsoluteMove{}, nil
return &ptz.AbsoluteMove{}, nil
case "GeoMove":
return &PTZ.GeoMove{}, nil
return &ptz.GeoMove{}, nil
case "Stop":
return &PTZ.Stop{}, nil
return &ptz.Stop{}, nil
case "GetPresetTours":
return &PTZ.GetPresetTours{}, nil
return &ptz.GetPresetTours{}, nil
case "GetPresetTour":
return &PTZ.GetPresetTour{}, nil
return &ptz.GetPresetTour{}, nil
case "GetPresetTourOptions":
return &PTZ.GetPresetTourOptions{}, nil
return &ptz.GetPresetTourOptions{}, nil
case "CreatePresetTour":
return &PTZ.CreatePresetTour{}, nil
return &ptz.CreatePresetTour{}, nil
case "ModifyPresetTour":
return &PTZ.ModifyPresetTour{}, nil
return &ptz.ModifyPresetTour{}, nil
case "OperatePresetTour":
return &PTZ.OperatePresetTour{}, nil
return &ptz.OperatePresetTour{}, nil
case "RemovePresetTour":
return &PTZ.RemovePresetTour{}, nil
return &ptz.RemovePresetTour{}, nil
case "GetCompatibleConfigurations":
return &PTZ.GetCompatibleConfigurations{}, nil
return &ptz.GetCompatibleConfigurations{}, nil
default:
return nil, errors.New("there is no such method in the PTZ service")
}
@@ -73,354 +74,352 @@ func getPTZStructByName(name string) (interface{}, error) {
func getDeviceStructByName(name string) (interface{}, error) {
switch name {
case "GetServices":
return &Device.GetServices{}, nil
return &device.GetServices{}, nil
case "GetServiceCapabilities":
return &Device.GetServiceCapabilities{}, nil
return &device.GetServiceCapabilities{}, nil
case "GetDeviceInformation":
return &Device.GetDeviceInformation{}, nil
return &device.GetDeviceInformation{}, nil
case "SetSystemDateAndTime":
return &Device.SetSystemDateAndTime{}, nil
return &device.SetSystemDateAndTime{}, nil
case "GetSystemDateAndTime":
return &Device.GetSystemDateAndTime{}, nil
return &device.GetSystemDateAndTime{}, nil
case "SetSystemFactoryDefault":
return &Device.SetSystemFactoryDefault{}, nil
return &device.SetSystemFactoryDefault{}, nil
case "UpgradeSystemFirmware":
return &Device.UpgradeSystemFirmware{}, nil
return &device.UpgradeSystemFirmware{}, nil
case "SystemReboot":
return &Device.SystemReboot{}, nil
return &device.SystemReboot{}, nil
case "RestoreSystem":
return &Device.RestoreSystem{}, nil
return &device.RestoreSystem{}, nil
case "GetSystemBackup":
return &Device.GetSystemBackup{}, nil
return &device.GetSystemBackup{}, nil
case "GetSystemLog":
return &Device.GetSystemLog{}, nil
return &device.GetSystemLog{}, nil
case "GetSystemSupportInformation":
return &Device.GetSystemSupportInformation{}, nil
return &device.GetSystemSupportInformation{}, nil
case "GetScopes":
return &Device.GetScopes{}, nil
return &device.GetScopes{}, nil
case "SetScopes":
return &Device.SetScopes{}, nil
return &device.SetScopes{}, nil
case "AddScopes":
return &Device.AddScopes{}, nil
return &device.AddScopes{}, nil
case "RemoveScopes":
return &Device.RemoveScopes{}, nil
return &device.RemoveScopes{}, nil
case "GetDiscoveryMode":
return &Device.GetDiscoveryMode{}, nil
return &device.GetDiscoveryMode{}, nil
case "SetDiscoveryMode":
return &Device.SetDiscoveryMode{}, nil
return &device.SetDiscoveryMode{}, nil
case "GetRemoteDiscoveryMode":
return &Device.GetRemoteDiscoveryMode{}, nil
return &device.GetRemoteDiscoveryMode{}, nil
case "SetRemoteDiscoveryMode":
return &Device.SetRemoteDiscoveryMode{}, nil
return &device.SetRemoteDiscoveryMode{}, nil
case "GetDPAddresses":
return &Device.GetDPAddresses{}, nil
return &device.GetDPAddresses{}, nil
case "SetDPAddresses":
return &Device.SetDPAddresses{}, nil
return &device.SetDPAddresses{}, nil
case "GetEndpointReference":
return &Device.GetEndpointReference{}, nil
return &device.GetEndpointReference{}, nil
case "GetRemoteUser":
return &Device.GetRemoteUser{}, nil
return &device.GetRemoteUser{}, nil
case "SetRemoteUser":
return &Device.SetRemoteUser{}, nil
return &device.SetRemoteUser{}, nil
case "GetUsers":
return &Device.GetUsers{}, nil
return &device.GetUsers{}, nil
case "CreateUsers":
return &Device.CreateUsers{}, nil
return &device.CreateUsers{}, nil
case "DeleteUsers":
return &Device.DeleteUsers{}, nil
return &device.DeleteUsers{}, nil
case "SetUser":
return &Device.SetUser{}, nil
return &device.SetUser{}, nil
case "GetWsdlUrl":
return &Device.GetWsdlUrl{}, nil
return &device.GetWsdlUrl{}, nil
case "GetCapabilities":
return &Device.GetCapabilities{}, nil
return &device.GetCapabilities{}, nil
case "GetHostname":
return &Device.GetHostname{}, nil
return &device.GetHostname{}, nil
case "SetHostname":
return &Device.SetHostname{}, nil
return &device.SetHostname{}, nil
case "SetHostnameFromDHCP":
return &Device.SetHostnameFromDHCP{}, nil
return &device.SetHostnameFromDHCP{}, nil
case "GetDNS":
return &Device.GetDNS{}, nil
return &device.GetDNS{}, nil
case "SetDNS":
return &Device.SetDNS{}, nil
return &device.SetDNS{}, nil
case "GetNTP":
return &Device.GetNTP{}, nil
return &device.GetNTP{}, nil
case "SetNTP":
return &Device.SetNTP{}, nil
return &device.SetNTP{}, nil
case "GetDynamicDNS":
return &Device.GetDynamicDNS{}, nil
return &device.GetDynamicDNS{}, nil
case "SetDynamicDNS":
return &Device.SetDynamicDNS{}, nil
return &device.SetDynamicDNS{}, nil
case "GetNetworkInterfaces":
return &Device.GetNetworkInterfaces{}, nil
return &device.GetNetworkInterfaces{}, nil
case "SetNetworkInterfaces":
return &Device.SetNetworkInterfaces{}, nil
return &device.SetNetworkInterfaces{}, nil
case "GetNetworkProtocols":
return &Device.GetNetworkProtocols{}, nil
return &device.GetNetworkProtocols{}, nil
case "SetNetworkProtocols":
return &Device.SetNetworkProtocols{}, nil
return &device.SetNetworkProtocols{}, nil
case "GetNetworkDefaultGateway":
return &Device.GetNetworkDefaultGateway{}, nil
return &device.GetNetworkDefaultGateway{}, nil
case "SetNetworkDefaultGateway":
return &Device.SetNetworkDefaultGateway{}, nil
return &device.SetNetworkDefaultGateway{}, nil
case "GetZeroConfiguration":
return &Device.GetZeroConfiguration{}, nil
return &device.GetZeroConfiguration{}, nil
case "SetZeroConfiguration":
return &Device.SetZeroConfiguration{}, nil
return &device.SetZeroConfiguration{}, nil
case "GetIPAddressFilter":
return &Device.GetIPAddressFilter{}, nil
return &device.GetIPAddressFilter{}, nil
case "SetIPAddressFilter":
return &Device.SetIPAddressFilter{}, nil
return &device.SetIPAddressFilter{}, nil
case "AddIPAddressFilter":
return &Device.AddIPAddressFilter{}, nil
return &device.AddIPAddressFilter{}, nil
case "RemoveIPAddressFilter":
return &Device.RemoveIPAddressFilter{}, nil
return &device.RemoveIPAddressFilter{}, nil
case "GetAccessPolicy":
return &Device.GetAccessPolicy{}, nil
return &device.GetAccessPolicy{}, nil
case "SetAccessPolicy":
return &Device.SetAccessPolicy{}, nil
return &device.SetAccessPolicy{}, nil
case "CreateCertificate":
return &Device.CreateCertificate{}, nil
return &device.CreateCertificate{}, nil
case "GetCertificates":
return &Device.GetCertificates{}, nil
return &device.GetCertificates{}, nil
case "GetCertificatesStatus":
return &Device.GetCertificatesStatus{}, nil
return &device.GetCertificatesStatus{}, nil
case "SetCertificatesStatus":
return &Device.SetCertificatesStatus{}, nil
return &device.SetCertificatesStatus{}, nil
case "DeleteCertificates":
return &Device.DeleteCertificates{}, nil
return &device.DeleteCertificates{}, nil
case "GetPkcs10Request":
return &Device.GetPkcs10Request{}, nil
return &device.GetPkcs10Request{}, nil
case "LoadCertificates":
return &Device.LoadCertificates{}, nil
return &device.LoadCertificates{}, nil
case "GetClientCertificateMode":
return &Device.GetClientCertificateMode{}, nil
return &device.GetClientCertificateMode{}, nil
case "SetClientCertificateMode":
return &Device.SetClientCertificateMode{}, nil
return &device.SetClientCertificateMode{}, nil
case "GetRelayOutputs":
return &Device.GetRelayOutputs{}, nil
return &device.GetRelayOutputs{}, nil
case "SetRelayOutputSettings":
return &Device.SetRelayOutputSettings{}, nil
return &device.SetRelayOutputSettings{}, nil
case "SetRelayOutputState":
return &Device.SetRelayOutputState{}, nil
return &device.SetRelayOutputState{}, nil
case "SendAuxiliaryCommand":
return &Device.SendAuxiliaryCommand{}, nil
return &device.SendAuxiliaryCommand{}, nil
case "GetCACertificates":
return &Device.GetCACertificates{}, nil
return &device.GetCACertificates{}, nil
case "LoadCertificateWithPrivateKey":
return &Device.LoadCertificateWithPrivateKey{}, nil
return &device.LoadCertificateWithPrivateKey{}, nil
case "GetCertificateInformation":
return &Device.GetCertificateInformation{}, nil
return &device.GetCertificateInformation{}, nil
case "LoadCACertificates":
return &Device.LoadCACertificates{}, nil
return &device.LoadCACertificates{}, nil
case "CreateDot1XConfiguration":
return &Device.CreateDot1XConfiguration{}, nil
return &device.CreateDot1XConfiguration{}, nil
case "SetDot1XConfiguration":
return &Device.SetDot1XConfiguration{}, nil
return &device.SetDot1XConfiguration{}, nil
case "GetDot1XConfiguration":
return &Device.GetDot1XConfiguration{}, nil
return &device.GetDot1XConfiguration{}, nil
case "GetDot1XConfigurations":
return &Device.GetDot1XConfigurations{}, nil
return &device.GetDot1XConfigurations{}, nil
case "DeleteDot1XConfiguration":
return &Device.DeleteDot1XConfiguration{}, nil
return &device.DeleteDot1XConfiguration{}, nil
case "GetDot11Capabilities":
return &Device.GetDot11Capabilities{}, nil
return &device.GetDot11Capabilities{}, nil
case "GetDot11Status":
return &Device.GetDot11Status{}, nil
return &device.GetDot11Status{}, nil
case "ScanAvailableDot11Networks":
return &Device.ScanAvailableDot11Networks{}, nil
return &device.ScanAvailableDot11Networks{}, nil
case "GetSystemUris":
return &Device.GetSystemUris{}, nil
return &device.GetSystemUris{}, nil
case "StartFirmwareUpgrade":
return &Device.StartFirmwareUpgrade{}, nil
return &device.StartFirmwareUpgrade{}, nil
case "StartSystemRestore":
return &Device.StartSystemRestore{}, nil
return &device.StartSystemRestore{}, nil
case "GetStorageConfigurations":
return &Device.GetStorageConfigurations{}, nil
return &device.GetStorageConfigurations{}, nil
case "CreateStorageConfiguration":
return &Device.CreateStorageConfiguration{}, nil
return &device.CreateStorageConfiguration{}, nil
case "GetStorageConfiguration":
return &Device.GetStorageConfiguration{}, nil
return &device.GetStorageConfiguration{}, nil
case "SetStorageConfiguration":
return &Device.SetStorageConfiguration{}, nil
return &device.SetStorageConfiguration{}, nil
case "DeleteStorageConfiguration":
return &Device.DeleteStorageConfiguration{}, nil
return &device.DeleteStorageConfiguration{}, nil
case "GetGeoLocation":
return &Device.GetGeoLocation{}, nil
return &device.GetGeoLocation{}, nil
case "SetGeoLocation":
return &Device.SetGeoLocation{}, nil
return &device.SetGeoLocation{}, nil
case "DeleteGeoLocation":
return &Device.DeleteGeoLocation{}, nil
return &device.DeleteGeoLocation{}, nil
default:
return nil, errors.New("there is no such method in the Device service")
}
}
func getMediaStructByName(name string) (interface{}, error) {
switch name {
case "GetServiceCapabilities":
return &Media.GetServiceCapabilities{}, nil
return &media.GetServiceCapabilities{}, nil
case "GetVideoSources":
return &Media.GetVideoSources{}, nil
return &media.GetVideoSources{}, nil
case "GetAudioSources":
return &Media.GetAudioSources{}, nil
return &media.GetAudioSources{}, nil
case "GetAudioOutputs":
return &Media.GetAudioOutputs{}, nil
return &media.GetAudioOutputs{}, nil
case "CreateProfile":
return &Media.CreateProfile{}, nil
return &media.CreateProfile{}, nil
case "GetProfile":
return &Media.GetProfile{}, nil
return &media.GetProfile{}, nil
case "GetProfiles":
return &Media.GetProfiles{}, nil
return &media.GetProfiles{}, nil
case "AddVideoEncoderConfiguration":
return &Media.AddVideoEncoderConfiguration{}, nil
return &media.AddVideoEncoderConfiguration{}, nil
case "RemoveVideoEncoderConfiguration":
return &Media.RemoveVideoEncoderConfiguration{}, nil
return &media.RemoveVideoEncoderConfiguration{}, nil
case "AddVideoSourceConfiguration":
return &Media.AddVideoSourceConfiguration{}, nil
return &media.AddVideoSourceConfiguration{}, nil
case "RemoveVideoSourceConfiguration":
return &Media.RemoveVideoSourceConfiguration{}, nil
return &media.RemoveVideoSourceConfiguration{}, nil
case "AddAudioEncoderConfiguration":
return &Media.AddAudioEncoderConfiguration{}, nil
return &media.AddAudioEncoderConfiguration{}, nil
case "RemoveAudioEncoderConfiguration":
return &Media.RemoveAudioEncoderConfiguration{}, nil
return &media.RemoveAudioEncoderConfiguration{}, nil
case "AddAudioSourceConfiguration":
return &Media.AddAudioSourceConfiguration{}, nil
return &media.AddAudioSourceConfiguration{}, nil
case "RemoveAudioSourceConfiguration":
return &Media.RemoveAudioSourceConfiguration{}, nil
return &media.RemoveAudioSourceConfiguration{}, nil
case "AddPTZConfiguration":
return &Media.AddPTZConfiguration{}, nil
return &media.AddPTZConfiguration{}, nil
case "RemovePTZConfiguration":
return &Media.RemovePTZConfiguration{}, nil
return &media.RemovePTZConfiguration{}, nil
case "AddVideoAnalyticsConfiguration":
return &Media.AddVideoAnalyticsConfiguration{}, nil
return &media.AddVideoAnalyticsConfiguration{}, nil
case "RemoveVideoAnalyticsConfiguration":
return &Media.RemoveVideoAnalyticsConfiguration{}, nil
return &media.RemoveVideoAnalyticsConfiguration{}, nil
case "AddMetadataConfiguration":
return &Media.AddMetadataConfiguration{}, nil
return &media.AddMetadataConfiguration{}, nil
case "RemoveMetadataConfiguration":
return &Media.RemoveMetadataConfiguration{}, nil
return &media.RemoveMetadataConfiguration{}, nil
case "AddAudioOutputConfiguration":
return &Media.AddAudioOutputConfiguration{}, nil
return &media.AddAudioOutputConfiguration{}, nil
case "RemoveAudioOutputConfiguration":
return &Media.RemoveAudioOutputConfiguration{}, nil
return &media.RemoveAudioOutputConfiguration{}, nil
case "AddAudioDecoderConfiguration":
return &Media.AddAudioDecoderConfiguration{}, nil
return &media.AddAudioDecoderConfiguration{}, nil
case "RemoveAudioDecoderConfiguration":
return &Media.RemoveAudioDecoderConfiguration{}, nil
return &media.RemoveAudioDecoderConfiguration{}, nil
case "DeleteProfile":
return &Media.DeleteProfile{}, nil
return &media.DeleteProfile{}, nil
case "GetVideoSourceConfigurations":
return &Media.GetVideoSourceConfigurations{}, nil
return &media.GetVideoSourceConfigurations{}, nil
case "GetVideoEncoderConfigurations":
return &Media.GetVideoEncoderConfigurations{}, nil
return &media.GetVideoEncoderConfigurations{}, nil
case "GetAudioSourceConfigurations":
return &Media.GetAudioSourceConfigurations{}, nil
return &media.GetAudioSourceConfigurations{}, nil
case "GetAudioEncoderConfigurations":
return &Media.GetAudioEncoderConfigurations{}, nil
return &media.GetAudioEncoderConfigurations{}, nil
case "GetVideoAnalyticsConfigurations":
return &Media.GetVideoAnalyticsConfigurations{}, nil
return &media.GetVideoAnalyticsConfigurations{}, nil
case "GetMetadataConfigurations":
return &Media.GetMetadataConfigurations{}, nil
return &media.GetMetadataConfigurations{}, nil
case "GetAudioOutputConfigurations":
return &Media.GetAudioOutputConfigurations{}, nil
return &media.GetAudioOutputConfigurations{}, nil
case "GetAudioDecoderConfigurations":
return &Media.GetAudioDecoderConfigurations{}, nil
return &media.GetAudioDecoderConfigurations{}, nil
case "GetVideoSourceConfiguration":
return &Media.GetVideoSourceConfiguration{}, nil
return &media.GetVideoSourceConfiguration{}, nil
case "GetVideoEncoderConfiguration":
return &Media.GetVideoEncoderConfiguration{}, nil
return &media.GetVideoEncoderConfiguration{}, nil
case "GetAudioSourceConfiguration":
return &Media.GetAudioSourceConfiguration{}, nil
return &media.GetAudioSourceConfiguration{}, nil
case "GetAudioEncoderConfiguration":
return &Media.GetAudioEncoderConfiguration{}, nil
return &media.GetAudioEncoderConfiguration{}, nil
case "GetVideoAnalyticsConfiguration":
return &Media.GetVideoAnalyticsConfiguration{}, nil
return &media.GetVideoAnalyticsConfiguration{}, nil
case "GetMetadataConfiguration":
return &Media.GetMetadataConfiguration{}, nil
return &media.GetMetadataConfiguration{}, nil
case "GetAudioOutputConfiguration":
return &Media.GetAudioOutputConfiguration{},nil
return &media.GetAudioOutputConfiguration{}, nil
case "GetAudioDecoderConfiguration":
return &Media.GetAudioDecoderConfiguration{}, nil
return &media.GetAudioDecoderConfiguration{}, nil
case "GetCompatibleVideoEncoderConfigurations":
return &Media.GetCompatibleVideoEncoderConfigurations{}, nil
return &media.GetCompatibleVideoEncoderConfigurations{}, nil
case "GetCompatibleVideoSourceConfigurations":
return &Media.GetCompatibleVideoSourceConfigurations{}, nil
return &media.GetCompatibleVideoSourceConfigurations{}, nil
case "GetCompatibleAudioEncoderConfigurations":
return &Media.GetCompatibleAudioEncoderConfigurations{}, nil
return &media.GetCompatibleAudioEncoderConfigurations{}, nil
case "GetCompatibleAudioSourceConfigurations":
return &Media.GetCompatibleAudioSourceConfigurations{}, nil
return &media.GetCompatibleAudioSourceConfigurations{}, nil
case "GetCompatibleVideoAnalyticsConfigurations":
return &Media.GetCompatibleVideoAnalyticsConfigurations{}, nil
return &media.GetCompatibleVideoAnalyticsConfigurations{}, nil
case "GetCompatibleMetadataConfigurations":
return &Media.GetCompatibleMetadataConfigurations{}, nil
return &media.GetCompatibleMetadataConfigurations{}, nil
case "GetCompatibleAudioOutputConfigurations":
return &Media.GetCompatibleAudioOutputConfigurations{}, nil
return &media.GetCompatibleAudioOutputConfigurations{}, nil
case "GetCompatibleAudioDecoderConfigurations":
return &Media.GetCompatibleAudioDecoderConfigurations{}, nil
return &media.GetCompatibleAudioDecoderConfigurations{}, nil
case "SetVideoSourceConfiguration":
return &Media.SetVideoSourceConfiguration{}, nil
return &media.SetVideoSourceConfiguration{}, nil
case "SetVideoEncoderConfiguration":
return &Media.SetVideoEncoderConfiguration{}, nil
return &media.SetVideoEncoderConfiguration{}, nil
case "SetAudioSourceConfiguration":
return &Media.SetAudioSourceConfiguration{}, nil
return &media.SetAudioSourceConfiguration{}, nil
case "SetAudioEncoderConfiguration":
return &Media.SetAudioEncoderConfiguration{}, nil
return &media.SetAudioEncoderConfiguration{}, nil
case "SetVideoAnalyticsConfiguration":
return &Media.SetVideoAnalyticsConfiguration{}, nil
return &media.SetVideoAnalyticsConfiguration{}, nil
case "SetMetadataConfiguration":
return &Media.SetMetadataConfiguration{}, nil
return &media.SetMetadataConfiguration{}, nil
case "SetAudioOutputConfiguration":
return &Media.SetAudioOutputConfiguration{}, nil
return &media.SetAudioOutputConfiguration{}, nil
case "SetAudioDecoderConfiguration":
return &Media.SetAudioDecoderConfiguration{}, nil
return &media.SetAudioDecoderConfiguration{}, nil
case "GetVideoSourceConfigurationOptions":
return &Media.GetVideoSourceConfigurationOptions{}, nil
return &media.GetVideoSourceConfigurationOptions{}, nil
case "GetVideoEncoderConfigurationOptions":
return &Media.GetVideoEncoderConfigurationOptions{}, nil
return &media.GetVideoEncoderConfigurationOptions{}, nil
case "GetAudioSourceConfigurationOptions":
return &Media.GetAudioSourceConfigurationOptions{}, nil
return &media.GetAudioSourceConfigurationOptions{}, nil
case "GetAudioEncoderConfigurationOptions":
return &Media.GetAudioEncoderConfigurationOptions{}, nil
return &media.GetAudioEncoderConfigurationOptions{}, nil
case "GetMetadataConfigurationOptions":
return &Media.GetMetadataConfigurationOptions{}, nil
return &media.GetMetadataConfigurationOptions{}, nil
case "GetAudioOutputConfigurationOptions":
return &Media.GetAudioOutputConfigurationOptions{}, nil
return &media.GetAudioOutputConfigurationOptions{}, nil
case "GetAudioDecoderConfigurationOptions":
return &Media.GetAudioDecoderConfigurationOptions{}, nil
return &media.GetAudioDecoderConfigurationOptions{}, nil
case "GetGuaranteedNumberOfVideoEncoderInstances":
return &Media.GetGuaranteedNumberOfVideoEncoderInstances{}, nil
return &media.GetGuaranteedNumberOfVideoEncoderInstances{}, nil
case "GetStreamUri":
return &Media.GetStreamUri{}, nil
return &media.GetStreamUri{}, nil
case "StartMulticastStreaming":
return &Media.StartMulticastStreaming{}, nil
return &media.StartMulticastStreaming{}, nil
case "StopMulticastStreaming":
return &Media.StopMulticastStreaming{}, nil
return &media.StopMulticastStreaming{}, nil
case "SetSynchronizationPoint":
return &Media.SetSynchronizationPoint{}, nil
return &media.SetSynchronizationPoint{}, nil
case "GetSnapshotUri":
return &Media.GetSnapshotUri{}, nil
return &media.GetSnapshotUri{}, nil
case "GetVideoSourceModes":
return &Media.GetVideoSourceModes{}, nil
return &media.GetVideoSourceModes{}, nil
case "SetVideoSourceMode":
return &Media.SetVideoSourceMode{}, nil
return &media.SetVideoSourceMode{}, nil
case "GetOSDs":
return &Media.GetOSDs{}, nil
return &media.GetOSDs{}, nil
case "GetOSD":
return &Media.GetOSD{}, nil
return &media.GetOSD{}, nil
case "GetOSDOptions":
return &Media.GetOSDOptions{}, nil
return &media.GetOSDOptions{}, nil
case "SetOSD":
return &Media.SetOSD{}, nil
return &media.SetOSD{}, nil
case "CreateOSD":
return &Media.CreateOSD{}, nil
return &media.CreateOSD{}, nil
case "DeleteOSD":
return &Media.DeleteOSD{}, nil
return &media.DeleteOSD{}, nil
default:
return nil, errors.New("there is no such method in the Media service")
}
}
}

4
doc.go
View File

@@ -1,2 +1,2 @@
//package goonvif is developed to provide an ONVIF client implementation on Go programming language
package goonvif
//Package onvif is developed to provide an ONVIF client implementation on Go programming language
package onvif

View File

@@ -6,10 +6,10 @@ import (
"log"
"net/http"
"github.com/use-go/goonvif"
"github.com/use-go/goonvif/device"
"github.com/use-go/goonvif/xsd/onvif"
"github.com/yakovlevdmv/gosoap"
goonvif "github.com/use-go/onvif"
"github.com/use-go/onvif/device"
"github.com/use-go/onvif/gosoap"
"github.com/use-go/onvif/xsd/onvif"
)
const (
@@ -62,7 +62,7 @@ func main() {
log.Println(err)
} else {
/*
You could use https://github.com/yakovlevdmv/gosoap for pretty printing response
You could use https://github.com/use-go/onvif/gosoap for pretty printing response
*/
fmt.Println(gosoap.SoapMessage(readResponse(createUserResponse)).StringIndent())
}