From 53967fc72a5012c8928687cd97ca1bef804570e1 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Tue, 2 May 2023 09:36:38 +0300 Subject: [PATCH] Update ONVIF discovery request #397 --- pkg/onvif/helpers.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/onvif/helpers.go b/pkg/onvif/helpers.go index dd12e6bc..c772ee02 100644 --- a/pkg/onvif/helpers.go +++ b/pkg/onvif/helpers.go @@ -6,6 +6,7 @@ import ( "net/url" "regexp" "strconv" + "strings" "time" ) @@ -30,17 +31,19 @@ func DiscoveryStreamingHosts() ([]string, error) { return nil, err } + // https://www.onvif.org/wp-content/uploads/2016/12/ONVIF_Feature_Discovery_Specification_16.07.pdf + // 5.3 Discovery Procedure: msg := ` http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe - uuid:` + UUID() + ` + urn:uuid:` + UUID() + ` urn:schemas-xmlsoap-org:ws:2005:04:discovery - tds:Device - onvif://www.onvif.org/Profile/Streaming + + ` @@ -67,6 +70,13 @@ func DiscoveryStreamingHosts() ([]string, error) { break } + // ignore printers, etc + if !strings.Contains(string(b[:n]), "onvif") { + continue + } + + //log.Printf("[onvif] discovery response:\n%s", b[:n]) + rawURL := FindTagValue(b[:n], "XAddrs") if rawURL == "" { continue