In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "Go language open source library how to achieve Onvif protocol client device search", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Go language open source library how to achieve Onvif protocol client device search" bar!
1. Preface
We have briefly introduced the open source scheme of use-go before, which is also encapsulated through other open source schemes, providing a preliminary interface. Here, we use the learning of onvif protocol, and then combine the open source library for device discovery, device IP setting, Profiles token acquisition, streaming media Uri address acquisition, PTZ head control, preset point setting and other functions for further implementation and encapsulation. In order to deepen the understanding of Onvif protocol and deepen the use of Go language.
2. Equipment search ideas
This is not a clear principle to take a look at our Onvif learning equipment search there content, mainly through WS-Discovery device search, you can simply understand as local area network broadcast and multicast said: I am looking for settings in line with the Onvif protocol, and then the device replied: I am, and will send relevant device ip and other information to the client.
The Go open source solution we use here provides a corresponding interface for searching devices, and we can just use it directly.
3 、 Search for device Go source code package clientimport ("fmt"github.com/beevik/etree" goonvif "github.com/use-go/onvif"github.com/use-go/onvif/device"github.com/use-go/onvif/gosoap"github.com/use-go/onvif/media"github.com/use-go/onvif/ptz"github" .com/use-go/onvif/xsd "" github.com/use-go/onvif/xsd/onvif "" io/ioutil "" log "" net/http "" strings ") type Code int32const (OK Code = 0 SearchErr Code =-1 ConnectErr Code =-2 CreateUserErr Code =-20 GetProfilesErr Code =-30 GetStreamUriErr Code =-40 PTZErr Code =-50 SetPresetErr Code =-70 GotoPresetErr Code =-71 RemovePresetErr Code =-72 GetSnapShotUriErr Code =-100) type returnInfo struct {/ / status code Code Code / / error or return message ErrInfo string} / * * @ Description: search for devices Return the list of devices searched * @ Author:ZY * @ time: 2021-03-25 14:23:04 * @ receiver client * @ return returnInfo * / func (client * GoOnvifClient) SearchDevice () returnInfo {devices: = goonvif.GetAvailableDevicesAtSpecificEthernetInterface ("eth0") if devices = = nil {return returnInfo {SearchErr, "search devices failed."} client.Devices = devices return returnInfo {OK, "search device success"}}
Client is our defined caller, a structure that contains all kinds of information we need to transmit, simulating the Onvif client created by object-oriented thinking, that is, creating an Onvif client, which handles the data interaction between external call parameters and internal processing libraries, and simplifies the interface parameters displayed to the outside.
4. Problems
A major problem is how to distinguish when we search for multiple devices that comply with the Onvif protocol. At present, we first use violent polling to obtain device information for each device, and then parse the returned XML information combined with our search criteria (such as device type, device mac address, etc.) to further distinguish.
Thank you for your reading, the above is the content of "Go language open source library how to achieve Onvif protocol client device search". After the study of this article, I believe you have a deeper understanding of how Go language open source library realizes Onvif protocol client device search, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.