From 3aaf9b77b3c725ee66d66f312646557fea69e968 Mon Sep 17 00:00:00 2001 From: lijun Date: Tue, 14 Jan 2025 22:53:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=A7=86=E9=A2=91=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 1 + service/tool.go | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index c36a0b6..fcd7bb7 100644 --- a/main.go +++ b/main.go @@ -64,6 +64,7 @@ func init() { for _, device := range proto.Config.DeviceInfo { service.DeviceRWMap[device.ID] = sync.RWMutex{} service.DeviceCurrentFrameMap[device.ID] = gocv.NewMat() + service.DeviceIsStop[device.ID] = true } } diff --git a/service/tool.go b/service/tool.go index 91c4658..f3885eb 100644 --- a/service/tool.go +++ b/service/tool.go @@ -109,6 +109,10 @@ func Get(url string) int { } func GetVideoStream(id int) { + if DeviceIsStop[id] == false { + fmt.Println("device:", id, " is running!") + return + } for { var device proto.DeviceInfo var index int @@ -129,14 +133,12 @@ func GetVideoStream(id int) { DeviceIsStop[id] = true break } - if DeviceIsStop[id] == false { - break - } //设置设备控制信息 status := Get(device.Control) DeviceIsStop[id] = false log.Println("device:", device.ID, " set control info status:", status) getVideoFrame(device) + DeviceIsStop[id] = true //停止之后,设置已停止信息 } }