ONVIF code refactoring
This commit is contained in:
@@ -15,6 +15,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const PathDevice = "/onvif/device_service"
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
url *url.URL
|
url *url.URL
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
PathDevice = "/onvif/device_service"
|
|
||||||
)
|
|
||||||
|
|
||||||
func FindTagValue(b []byte, tag string) string {
|
func FindTagValue(b []byte, tag string) string {
|
||||||
re := regexp.MustCompile(`<[^/>]*` + tag + `[^>]*>([^<]+)`)
|
re := regexp.MustCompile(`<[^/>]*` + tag + `[^>]*>([^<]+)`)
|
||||||
m := re.FindSubmatch(b)
|
m := re.FindSubmatch(b)
|
||||||
@@ -45,7 +41,7 @@ func DiscoveryStreamingURLs() ([]string, error) {
|
|||||||
</s:Header>
|
</s:Header>
|
||||||
<s:Body>
|
<s:Body>
|
||||||
<d:Probe xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery">
|
<d:Probe xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery">
|
||||||
<d:Types />
|
<d:Types />
|
||||||
<d:Scopes />
|
<d:Scopes />
|
||||||
</d:Probe>
|
</d:Probe>
|
||||||
</s:Body>
|
</s:Body>
|
||||||
|
|||||||
+9
-9
@@ -45,12 +45,12 @@ func GetRequestAction(b []byte) string {
|
|||||||
func GetCapabilitiesResponse(host string) string {
|
func GetCapabilitiesResponse(host string) string {
|
||||||
return `<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
return `<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||||
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
|
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
|
||||||
<s:Body>
|
<s:Body>
|
||||||
<tds:GetCapabilitiesResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
|
<tds:GetCapabilitiesResponse xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
|
||||||
<tds:Capabilities xmlns:tt="http://www.onvif.org/ver10/schema">
|
<tds:Capabilities xmlns:tt="http://www.onvif.org/ver10/schema">
|
||||||
<tt:Device>
|
<tt:Device>
|
||||||
<tt:XAddr>http://` + host + `/onvif/device_service</tt:XAddr>
|
<tt:XAddr>http://` + host + `/onvif/device_service</tt:XAddr>
|
||||||
</tt:Device>
|
</tt:Device>
|
||||||
<tt:Media>
|
<tt:Media>
|
||||||
<tt:XAddr>http://` + host + `/onvif/media_service</tt:XAddr>
|
<tt:XAddr>http://` + host + `/onvif/media_service</tt:XAddr>
|
||||||
<tt:StreamingCapabilities>
|
<tt:StreamingCapabilities>
|
||||||
@@ -59,9 +59,9 @@ func GetCapabilitiesResponse(host string) string {
|
|||||||
<tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP>
|
<tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP>
|
||||||
</tt:StreamingCapabilities>
|
</tt:StreamingCapabilities>
|
||||||
</tt:Media>
|
</tt:Media>
|
||||||
</tds:Capabilities>
|
</tds:Capabilities>
|
||||||
</tds:GetCapabilitiesResponse>
|
</tds:GetCapabilitiesResponse>
|
||||||
</s:Body>
|
</s:Body>
|
||||||
</s:Envelope>`
|
</s:Envelope>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user