当前位置:网站首页>The RTSP video structured intelligent analysis platform easynvr stops calling the PTZ interface through the onvif protocol to troubleshoot the pending status

The RTSP video structured intelligent analysis platform easynvr stops calling the PTZ interface through the onvif protocol to troubleshoot the pending status

2022-06-24 16:36:00 Tsingsee green rhino video

When the camera device supports PTZ , Video structured security intelligent platform EasyNVR Is to support the adoption of onvif Protocol to call the PTZ control of the camera , But during the call , If the user name and password are wrong , Call stop PTZ control interface will always be in pending state .

Through the browser debugging interface, you can see the pending state , No content has been returned .

Analyze the back end interface , Find specific to StopPTZ There is something wrong with the logic in the method , The logic currently used is as follows :

func StopPTZ(host, username, password, deviceUrl string) (err error) {
   if dll == nil {
      err = fmt.Errorf("onvif dll not init")
      return
   }
   ptz := fmt.Sprintf("stop ptz host[%s] username[%s] password[%s] deviceUrl[%s]", host, username, password, deviceUrl)
   global.OperationLogger.Info(ptz)
   _host := uintptr(unsafe.Pointer(syscall.StringBytePtr(host)))
   _username := uintptr(unsafe.Pointer(syscall.StringBytePtr(username)))
   _password := uintptr(unsafe.Pointer(syscall.StringBytePtr(password)))
   _deviceUrl := uintptr(unsafe.Pointer(syscall.StringBytePtr(deviceUrl)))
 
   i := 1
   for i <= 500 {
      r1, _, _ := procStopPtz.Call(_host, _username, _password, _deviceUrl)
      if r1 == 0 {
         break
      }
      if i == 500 {
         log.Printf("EasyOnvifClient_StopPtz failed, ret[%d], retryed 5s", r1)
         err = fmt.Errorf("EasyOnvifClient_StopPtz failed, ret[%d]", r1)
      }
      time.Sleep(10 * time.Millisecond)
   }
 
   return
}
 

We will i := 1 Change the logic , And time.Sleep Place for 1 Not for 10, Problem solvable . The modified logic code reference is as follows :

func StopPTZ(host, username, password, deviceUrl string) (err error) {
   if dll == nil {
      err = fmt.Errorf("onvif dll not init")
      return
   }
   ptz := fmt.Sprintf("stop ptz host[%s] username[%s] password[%s] deviceUrl[%s]", host, username, password, deviceUrl)
   global.OperationLogger.Info(ptz)
   _host := uintptr(unsafe.Pointer(syscall.StringBytePtr(host)))
   _username := uintptr(unsafe.Pointer(syscall.StringBytePtr(username)))
   _password := uintptr(unsafe.Pointer(syscall.StringBytePtr(password)))
   _deviceUrl := uintptr(unsafe.Pointer(syscall.StringBytePtr(deviceUrl)))
 
   for i := 0; i <= 500; i += 100 {
      r1, _, _ := procStopPtz.Call(_host, _username, _password, _deviceUrl)
      if r1 == 0 {
         return
      }
      if i == 500 {
         log.Printf("EasyOnvifClient_StopPtz failed, ret[%d], retryed 5s", r1)
         err = fmt.Errorf("EasyOnvifClient_StopPtz failed, ret[%d], timeout 5s", r1)
      }
      time.Sleep(1 * time.Millisecond)
   }
 
   return
}
 

Rerun and call the interface check , You can see that the above error content disappears , Problem solved :

Onvif The agreement expanded EasyNVR Compatibility and control of devices , We've introduced before EasyNVR in onvif Protocol standard instructions and configuration mode , If you are interested, you can learn something about , If you want to know more about onvif perhaps EasyNVR Related content of , Welcome to follow us .

原网站

版权声明
本文为[Tsingsee green rhino video]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/04/20210416144526981Z.html

随机推荐