Compare commits
No commits in common. "7d55d68c904274a4637c4456a1965abb39fbb43c" and "1e6a0996a053f3b88a217748a123d44995d68049" have entirely different histories.
7d55d68c90
...
1e6a0996a0
|
|
@ -102,14 +102,6 @@ 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
|
||||||
|
|
@ -128,9 +120,8 @@ func GetVideoStream(c *gin.Context) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
cnt := service.GetDeviceCurrentFrameV2(&frame, deviceID)
|
cnt := service.GetDeviceCurrentFrameV2(&frame, deviceID)
|
||||||
if cnt == count || cnt == -1 {
|
if cnt == count {
|
||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
log.Printf("stream device:%d ,cnt =%d,count=%d,errCount=%d", deviceID, cnt, count, errCount)
|
|
||||||
errCount++
|
errCount++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -194,12 +185,6 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,11 +203,6 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
|
||||||
//从service获取当前帧
|
//从service获取当前帧
|
||||||
c := service.GetDeviceCurrentFrameV2(&img, device_id)
|
c := service.GetDeviceCurrentFrameV2(&img, device_id)
|
||||||
if c != count {
|
if c != count {
|
||||||
if c == -1 {
|
|
||||||
log.Printf("device:%d get frame err!", device_id)
|
|
||||||
worker.SetRedisSetRemove(online_conn_key, con_id)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
//将img转[]byte
|
//将img转[]byte
|
||||||
if img.Empty() {
|
if img.Empty() {
|
||||||
log.Printf("device:%d img is empty! count = %d \n", device_id, c)
|
log.Printf("device:%d img is empty! count = %d \n", device_id, c)
|
||||||
|
|
|
||||||
17
main.go
17
main.go
|
|
@ -183,16 +183,13 @@ func JWTAuthMiddleware() gin.HandlerFunc {
|
||||||
if worker.IsContainSet("super_permission_tokens", tokenString) {
|
if worker.IsContainSet("super_permission_tokens", tokenString) {
|
||||||
s_id := c.Request.Header.Get("super_id")
|
s_id := c.Request.Header.Get("super_id")
|
||||||
if s_id == "" {
|
if s_id == "" {
|
||||||
s_id = c.Query("super_id")
|
c.AbortWithStatus(200)
|
||||||
if s_id == "" {
|
c.JSON(200, gin.H{
|
||||||
c.AbortWithStatus(200)
|
"message": "NOT_LOGIN",
|
||||||
c.JSON(200, gin.H{
|
"error": "super_id is empty",
|
||||||
"message": "NOT_LOGIN",
|
"code": 3,
|
||||||
"error": "super_id is empty",
|
})
|
||||||
"code": 3,
|
return
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
id, _ := strconv.Atoi(s_id)
|
id, _ := strconv.Atoi(s_id)
|
||||||
//查看s_id类型
|
//查看s_id类型
|
||||||
|
|
|
||||||
|
|
@ -115,25 +115,16 @@ func GetDeviceCurrentFrameV2(frame *gocv.Mat, deviceId int) int {
|
||||||
if (*frame).Empty() {
|
if (*frame).Empty() {
|
||||||
*frame = gocv.NewMatWithSize(Device1CurrentFrame.Rows(), Device1CurrentFrame.Cols(), Device1CurrentFrame.Type())
|
*frame = gocv.NewMatWithSize(Device1CurrentFrame.Rows(), Device1CurrentFrame.Cols(), Device1CurrentFrame.Type())
|
||||||
}
|
}
|
||||||
if Device1CurrentFrame.Empty() {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
Device1CurrentFrame.CopyTo(frame)
|
Device1CurrentFrame.CopyTo(frame)
|
||||||
case 50:
|
case 50:
|
||||||
if (*frame).Empty() {
|
if (*frame).Empty() {
|
||||||
*frame = gocv.NewMatWithSize(Device50CurrentFrame.Rows(), Device50CurrentFrame.Cols(), Device50CurrentFrame.Type())
|
*frame = gocv.NewMatWithSize(Device50CurrentFrame.Rows(), Device50CurrentFrame.Cols(), Device50CurrentFrame.Type())
|
||||||
}
|
}
|
||||||
if Device50CurrentFrame.Empty() {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
Device50CurrentFrame.CopyTo(frame)
|
Device50CurrentFrame.CopyTo(frame)
|
||||||
case 73:
|
case 73:
|
||||||
if (*frame).Empty() {
|
if (*frame).Empty() {
|
||||||
*frame = gocv.NewMatWithSize(Device73CurrentFrame.Rows(), Device73CurrentFrame.Cols(), Device73CurrentFrame.Type())
|
*frame = gocv.NewMatWithSize(Device73CurrentFrame.Rows(), Device73CurrentFrame.Cols(), Device73CurrentFrame.Type())
|
||||||
}
|
}
|
||||||
if Device73CurrentFrame.Empty() {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
Device73CurrentFrame.CopyTo(frame)
|
Device73CurrentFrame.CopyTo(frame)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue