discovery.go 921 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "time"
  6. "github.com/kr/pretty"
  7. "lc/common/onvif/discovery"
  8. "lc/common/onvif/profiles/devicemgmt"
  9. "lc/common/onvif/profiles/media"
  10. "lc/common/onvif/soap"
  11. )
  12. func main() {
  13. // discovery devices
  14. devices, err := discovery.StartDiscovery(5 * time.Second)
  15. if err != nil {
  16. return
  17. }
  18. if len(devices) == 0 {
  19. fmt.Printf("No devices descovered\n")
  20. return
  21. }
  22. // Create soap client
  23. client := soap.NewClient(
  24. soap.WithTimeout(time.Second * 5),
  25. )
  26. client.AddHeader(soap.NewWSSSecurityHeader("video", "123456qwe"))
  27. for _, d := range devices {
  28. dev := devicemgmt.NewDevice(client, d.XAddr)
  29. {
  30. dev.GetDeviceInformation(&devicemgmt.GetDeviceInformation{})
  31. }
  32. {
  33. dev.GetServices(&devicemgmt.GetServices{})
  34. }
  35. {
  36. dev.GetCapabilities(&devicemgmt.GetCapabilities{})
  37. }
  38. m := media.NewMedia(client, d.XAddr)
  39. {
  40. m.GetStreamUri(&media.GetStreamUri{})
  41. }
  42. }
  43. }