修复部分获取视频逻辑

This commit is contained in:
lijun 2025-01-14 22:53:42 +08:00
parent 31fddec772
commit 3aaf9b77b3
2 changed files with 6 additions and 3 deletions

View File

@ -64,6 +64,7 @@ func init() {
for _, device := range proto.Config.DeviceInfo { for _, device := range proto.Config.DeviceInfo {
service.DeviceRWMap[device.ID] = sync.RWMutex{} service.DeviceRWMap[device.ID] = sync.RWMutex{}
service.DeviceCurrentFrameMap[device.ID] = gocv.NewMat() service.DeviceCurrentFrameMap[device.ID] = gocv.NewMat()
service.DeviceIsStop[device.ID] = true
} }
} }

View File

@ -109,6 +109,10 @@ func Get(url string) int {
} }
func GetVideoStream(id int) { func GetVideoStream(id int) {
if DeviceIsStop[id] == false {
fmt.Println("device:", id, " is running!")
return
}
for { for {
var device proto.DeviceInfo var device proto.DeviceInfo
var index int var index int
@ -129,14 +133,12 @@ func GetVideoStream(id int) {
DeviceIsStop[id] = true DeviceIsStop[id] = true
break break
} }
if DeviceIsStop[id] == false {
break
}
//设置设备控制信息 //设置设备控制信息
status := Get(device.Control) status := Get(device.Control)
DeviceIsStop[id] = false DeviceIsStop[id] = false
log.Println("device:", device.ID, " set control info status:", status) log.Println("device:", device.ID, " set control info status:", status)
getVideoFrame(device) getVideoFrame(device)
DeviceIsStop[id] = true //停止之后,设置已停止信息
} }
} }