-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrelay.go
82 lines (72 loc) · 2.05 KB
/
relay.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package onvif
import "github.com/golang/glog"
func (device Device) GetReplayConfiguration() (interface{}, error) {
// create soap
soap := SOAP{
User: device.User,
Password: device.Password,
Body: `<GetReplayConfiguration xmlns="http://www.onvif.org/ver10/replay/wsdl"/>`,
}
var result interface{}
// send request
response, err := soap.SendRequest(device.XAddr)
if err != nil {
return result, err
}
// parse response
data, err := response.ValueForPath("Envelope.Body.GetReplayConfigurationResponse")
if err != nil {
return result, err
}
glog.Infof("Data %v", data)
return result, nil
}
func (device Device) GetReplayServiceCapabilities() (interface{}, error) {
// create soap
soap := SOAP{
User: device.User,
Password: device.Password,
Body: `<GetServiceCapabilities xmlns="http://www.onvif.org/ver10/replay/wsdl"/>`,
}
var result interface{}
// send request
response, err := soap.SendRequest(device.XAddr)
if err != nil {
return result, err
}
// parse response
data, err := response.ValueForPath("Envelope.Body.GetServiceCapabilitiesResponse")
if err != nil {
return result, err
}
glog.Infof("Data %v", data)
return result, nil
}
func (device Device) GetReplayUri(recordingToken string) (string, error) {
// create soap
soap := SOAP{
User: device.User,
Password: device.Password,
Body: `<GetReplayUri xmlns="http://www.onvif.org/ver10/replay/wsdl">
<RecordingToken>` + recordingToken + `</RecordingToken>
<StreamSetup>
<Stream xmlns="http://www.onvif.org/ver10/schema">RTP-Unicast</Stream>
<Transport xmlns="http://www.onvif.org/ver10/schema">
<Protocol xmlns="http://www.onvif.org/ver10/schema">TCP</Protocol>
</Transport>
</StreamSetup>
</GetReplayUri>`,
}
var result = ""
// send request
response, err := soap.SendRequest(device.XAddr)
if err != nil {
return result, err
}
// parse response
data, err := response.ValueForPath("Envelope.Body.GetReplayUriResponse.Uri")
if err != nil {
return result, err
}
return interfaceToString(data), nil
}