【開發記錄】HIKSDK/RTSP/Ehome視訊平臺EasyCVR如何通過GB28181協議增加告警功能?
阿新 • • 發佈:2020-12-23
告警功能作為安防視訊雲服務搭建中的一個新功能,在越來越多的安防場景中發揮了作用。隨著TSINGSEE青犀視訊開發的國標GB28181協議視訊平臺EasyGBS內告警功能的成功運用,我們打算逐步在更多的平臺內運用告警功能。
因此在EasyCVR的新版本中我們增加了告警功能的呼叫介面,目前我們開發的告警功能主要是通過GB28181協議進行接收,因此EasyCVR內告警功能同EasyGBS內告警的開發大致相同。EasyCVR接收國標message中的alarm告警訊息,然後通過介面展示。
在message新增如下方法:
case "alarm": deviceId := "" if el := doc.Root().SelectElement("DeviceID"); el != nil { deviceId = el.Text() } limiter := Limiter.GetLimiter(fmt.Sprintf("%s:%s", serial, deviceId)) if !limiter.Allow() { return } alarmPriority := "" if el := doc.Root().SelectElement("AlarmPriority"); el != nil { alarmPriority = el.Text() } alarmMethod := "" if el := doc.Root().SelectElement("AlarmMethod"); el != nil { alarmMethod = el.Text() } alarmType := "" if el := doc.Root().SelectElement("Info").SelectElement("AlarmType"); el != nil { alarmType = el.Text() } alarmTime := "" if el := doc.Root().SelectElement("AlarmTime"); el != nil { alarmTime = el.Text() } body := fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?>\r <Response>\r <CmdType>Alarm</CmdType>\r <SN>%s</SN>\r <DeviceID>%s</DeviceID>\r <Result>OK</Result>\r </Response>\r`, sn, deviceId) c.Req.MakeResponse().EnsureToTag().SetHeader("Content-Type", "Application/MANSCDP+xml") c.Req.MakeResponse().EnsureToTag().SetBody(body) channels := models.GetChannel(deviceId, serial) if channels == nil { log.Println("alarm find channel is nil") return }
通過以上介面呼叫檢視,可以得到告警列表,測試後滿足要求。
EasyCVR的新版本在近期就會上線,到時候大家可以下載試用,如果還想了解更多關於EasyCVR的相關內容,可以關注我們,另外,TSINGSEE青犀視訊還開發了多種不同協議的安防視訊雲服務平臺,包括EasyNVR、EasyGBS、EasyDSS等,都可以下載試用,歡迎諮詢。