# onvif protocol
Simple management of onvif IP-devices cameras. onvif is an implementation of ONVIF protocol for managing onvif IP devices. The purpose of this library is convenient and easy management of IP cameras and other devices that support ONVIF standard.
## Installation
To install the library, use **go get**:
```go
go get github.com/use-go/onvif
```
## Supported services
The following services are implemented:
- Device
- Media
- PTZ
- Imaging
- Event
- Discovery
- Auth(More Options)
- Soap
## Using
### General concept
1) Connecting to the device
2) Authentication (if necessary)
3) Defining Data Types
4) Carrying out the required method
#### Connecting to the device
If there is a device on the network at the address *192.168.13.42*, and its ONVIF services use the *1234* port, then you can connect to the device in the following way:
```go
dev, err := onvif.NewDevice(onvif.DeviceParams{Xaddr: "192.168.13.42:1234"})
```
*The ONVIF port may differ depending on the device , to find out which port to use, you can go to the web interface of the device. **Usually this is 80 port.***
#### Authentication
If any function of the ONVIF services requires authentication, you must use the `Authenticate` method.
```go
device := onvif.NewDevice(onvif.DeviceParams{Xaddr: "192.168.13.42:1234", Username: "username", Password: password})
```
#### Defining Data Types
Each ONVIF service in this library has its own package, in which all data types of this service are defined, and the package name is identical to the service name and begins with a capital letter. onvif defines the structures for each function of each ONVIF service supported by this library. Define the data type of the `GetCapabilities` function of the Device service. This is done as follows:
```go
capabilities := device.GetCapabilities{Category:"All"}
```
Why does the `GetCapabilities` structure have the Category field and why is the value of this field `All`?
The figure below shows the documentation for the [GetCapabilities](https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl). It can be seen that the function takes one Category parameter and its value should be one of the following: 'All', 'Analytics',' Device ',' Events', 'Imaging', 'Media' or 'PTZ'`.
![Device GetCapabilities](docs/img/exmp_GetCapabilities.png)
An example of defining the data type of `GetServiceCapabilities` function in [PTZ](https://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl):
```go
ptzCapabilities := ptz.GetServiceCapabilities{}
```
The figure below shows that `GetServiceCapabilities` does not accept any arguments.
![PTZ GetServiceCapabilities](docs/img/GetServiceCapabilities.png)
*Common data types are in the xsd/onvif package. The types of data (structures) that can be shared by all services are defined in the onvif package.*
An example of how to define the data type of the CreateUsers function in [Devicemgmt](https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl):
```go
createUsers := device.CreateUsers{User: onvif.User{Username:"admin", Password:"qwerty", UserLevel:"User"}}
```
The figure below shows that ,in this example, the `CreateUsers` structure field must be a User whose data type is the User structure containing the Username, Password, UserLevel, and optional Extension fields. The User structure is in the onvif package.
![Device CreateUsers](docs/img/exmp_CreateUsers.png)
#### Carrying out the required method
To perform any function of one of the ONVIF services whose structure has been defined, you must use the `CallMethod` of the device object.
```go
createUsers := device.CreateUsers{User: onvif.User{Username:"admin", Password:"qwerty", UserLevel:"User"}}
device := onvif.NewDevice(onvif.DeviceParams{Xaddr: "192.168.13.42:1234", Username: "username", Password: password})
device.Authenticate("username", "password")
resp, err := dev.CallMethod(createUsers)
```
## Great Thanks
Enhanced and Improved from: [goonvif](https://github.com/yakovlevdmv/goonvif)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
onvif-golang.zip (65个子文件)
onvif-golang
Device.go 7KB
.vscode
settings.json 1KB
analytics
types.go 3KB
go.mod 275B
media
types.go 22KB
device
types.go 23KB
go.sum 5KB
networking
networking.go 345B
ws-discovery
networking.go 3KB
ws-discovery.go 2KB
LICENSE 1KB
Imaging
types.go 2KB
api
api.go 9KB
get_structs.go 15KB
xsd
built_in.go 17KB
iso8601
iso8601_duration.go 3KB
onvif
r-2.xsd 1KB
xml.xsd 9KB
ws-addr.xsd 5KB
t-1.xsd 5KB
onvif.go 51KB
examples
DeviceService.go 2KB
discovery_test.go 2KB
docs
img
exmp_CreateUsers.png 40KB
exmp_GetProfiles.png 14KB
exmp_ContinuousMove.png 29KB
GetServiceCapabilities.png 25KB
exmp_GetCapabilities.png 19KB
wsdl
imaging.wsdl 25KB
recording.wsdl 47KB
provisioning.wsdl 24KB
event.wsdl 37KB
media.wsdl 168KB
deviceio.wsdl 63KB
doorcontrol.wsdl 51KB
analytics.wsdl 29KB
devicemgmt.wsdl 172KB
search.wsdl 41KB
actionengine.wsdl 54KB
advancedsecurity.wsdl 149KB
WS-Resource.wsdl 1006B
receiver.wsdl 16KB
replay.wsdl 10KB
credential.wsdl 56KB
analyticsdevice.wsdl 30KB
thermal.wsdl 33KB
accesscontrol.wsdl 36KB
accessrules.wsdl 26KB
ptz.wsdl 54KB
WS-BaseNotification.wsdl 13KB
display.wsdl 23KB
schedule.wsdl 51KB
event-vs.wsdl 38KB
media2.wsdl 106KB
ONVIF-Core-Specification.pdf 1.46MB
README.md 79B
event
operation.go 4KB
types.go 5KB
ptz
types.go 8KB
doc.go 112B
README.md 4KB
gosoap
ws-action.go 1KB
ws-security.go 3KB
soap-builder.go 7KB
README.md 9B
共 65 条
- 1
资源评论
大神小小生
- 粉丝: 1
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功