接口查看设备是否在获取图像
This commit is contained in:
parent
b00537b5ec
commit
7d55d68c90
|
|
@ -102,6 +102,14 @@ func GetVideoStream(c *gin.Context) {
|
||||||
c.JSON(400, gin.H{"error": "key error"})
|
c.JSON(400, gin.H{"error": "key error"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//查看设备是否在获取
|
||||||
|
isGetting := worker.GetRedis(fmt.Sprintf("device_%d_is_getting", deviceID))
|
||||||
|
if isGetting != "true" {
|
||||||
|
c.JSON(400, gin.H{"error": "device is not getting or not exist"})
|
||||||
|
log.Printf("stream device_id:%d is not getting or not exist", deviceID)
|
||||||
|
return
|
||||||
|
}
|
||||||
//设备流
|
//设备流
|
||||||
c.Stream(func(w io.Writer) bool {
|
c.Stream(func(w io.Writer) bool {
|
||||||
var count int
|
var count int
|
||||||
|
|
@ -186,6 +194,12 @@ func GetRealTimeImage(c *gin.Context) {
|
||||||
}
|
}
|
||||||
worker.SetRedisWithExpire(strconv.Itoa(int(device.ID))+"_is_play", "1", time.Minute*5)
|
worker.SetRedisWithExpire(strconv.Itoa(int(device.ID))+"_is_play", "1", time.Minute*5)
|
||||||
log.Printf("device_id:%d has set is_play to 1", deviceIdInt)
|
log.Printf("device_id:%d has set is_play to 1", deviceIdInt)
|
||||||
|
isGetting = worker.GetRedis(fmt.Sprintf("device_%d_is_getting", device.ID))
|
||||||
|
if isGetting != "true" {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 5, "message": "device is not getting or not exist"})
|
||||||
|
log.Printf("device_id:%d is not getting or not exist", deviceIdInt)
|
||||||
|
return
|
||||||
|
}
|
||||||
go subscribeAndHandleMessagesV3(ws, deviceIdInt)
|
go subscribeAndHandleMessagesV3(ws, deviceIdInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue