使用分离方式,修改视频流返回方式
This commit is contained in:
parent
abea9bd374
commit
de9b8d23ac
|
|
@ -144,7 +144,13 @@ func GetRealTimeImage(c *gin.Context) {
|
|||
}
|
||||
//查看设备是否在获取
|
||||
isGet, ok := service.DeviceIsGettingFrame.Load(device.ID)
|
||||
if !ok || isGet == false {
|
||||
if !ok {
|
||||
c.JSON(http.StatusOK, gin.H{"code": 4, "message": "device not getting frame or not exist"})
|
||||
log.Printf("device:%d not found,isGet:%v , ok = %v", device.ID, isGet, ok)
|
||||
return
|
||||
}
|
||||
isGet_ := isGet.(bool)
|
||||
if isGet_ == false {
|
||||
//直接返回
|
||||
c.JSON(http.StatusOK, gin.H{"code": 4, "message": "device not getting frame or not exist"})
|
||||
log.Printf("device:%d not found,isGet:%v , ok = %v", device.ID, isGet, ok)
|
||||
|
|
|
|||
5
main.go
5
main.go
|
|
@ -96,7 +96,8 @@ func ReadConfigAndSetSystem() {
|
|||
}
|
||||
//检测是否需要获取设备流,如果需要则开启
|
||||
for _, device := range proto.Config.DeviceInfo {
|
||||
is_get, ok := service.DeviceIsGettingFrame.Load(device.ID)
|
||||
isGet, ok := service.DeviceIsGettingFrame.Load(device.ID)
|
||||
isGet_ := isGet.(bool)
|
||||
if !ok {
|
||||
//说明没有这个设备,需初始化添加
|
||||
service.DeviceRWMap.Store(device.ID, &sync.RWMutex{})
|
||||
|
|
@ -104,7 +105,7 @@ func ReadConfigAndSetSystem() {
|
|||
service.DeviceFrameCount[device.ID] = 0
|
||||
service.DeviceIsGettingFrame.Store(device.ID, false)
|
||||
}
|
||||
if is_get == false && device.NextStop == false { //如果设备流已经停止且不暂停,则开启
|
||||
if isGet_ == false && device.NextStop == false { //如果设备流已经停止且不暂停,则开启
|
||||
switch device.ID {
|
||||
case 1:
|
||||
service.Device1CurrentFrame = gocv.NewMat()
|
||||
|
|
|
|||
|
|
@ -329,7 +329,12 @@ func GetVideoStream(id int) {
|
|||
break
|
||||
}
|
||||
is_get, ok = DeviceIsGettingFrame.Load(id)
|
||||
if is_get == true {
|
||||
if !ok {
|
||||
log.Printf("device: %d not found", id)
|
||||
break
|
||||
}
|
||||
isGet := is_get.(bool)
|
||||
if isGet == true {
|
||||
log.Printf("for device:%d is running!", id)
|
||||
break
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue