From 0b84a8fc09d079ca142332f526a5fb3fb57047e2 Mon Sep 17 00:00:00 2001 From: "yangteng@class100.com" Date: Wed, 19 Apr 2023 13:40:08 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=B7=BB=E5=8A=A0gb28181=E7=9A=84fi?= =?UTF-8?q?=E6=8C=87=E4=BB=A4=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gb28181/cmd.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/gb28181/cmd.go b/gb28181/cmd.go index 7068a27..6d63dbc 100644 --- a/gb28181/cmd.go +++ b/gb28181/cmd.go @@ -14,6 +14,11 @@ const ( PtzDown = 2 PtzLeft = 1 PtzRight = 0 + + FiIrisReduce = 3 + FiIrisExpand = 2 + FiFocusNear = 1 + FiFocusAway = 0 ) type Cmd []int @@ -65,6 +70,25 @@ type ( } ) +type ( + FiIrisParam struct { + // 放大为1 缩小为-1 + Direction int `json:"direction" validate:"oneof=-1 0 1"` + Speed int `json:"speed" validate:"min=0,max=255"` + } + + FiFocusParam struct { + // 聚焦近为1 聚焦远为-1 + Direction int `json:"direction" validate:"oneof=-1 0 1"` + Speed int `json:"speed" validate:"min=0,max=255"` + } + + FiConfig struct { + Iris *FiIrisParam `json:"iris"` + Focus *FiFocusParam `json:"focus"` + } +) + func NewPtzCmd(config PtzConfig) Cmd { cmd := newCmd() @@ -103,3 +127,33 @@ func NewPtzCmd(config PtzConfig) Cmd { return cmd } + +func NewFiCmd(config FiConfig) Cmd { + cmd := newCmd() + // 表示是fi指令 + cmd[3] += 1 << 6 + + if config.Iris != nil { + if config.Iris.Direction == -1 { + cmd[3] += 1 << FiIrisReduce + } + if config.Iris.Direction == 1 { + cmd[3] += 1 << FiIrisExpand + } + + cmd[5] = config.Iris.Speed + } + + if config.Focus != nil { + if config.Focus.Direction == -1 { + cmd[3] += 1 << FiFocusNear + } + if config.Focus.Direction == 1 { + cmd[3] += 1 << FiFocusAway + } + + cmd[4] = config.Focus.Speed + } + + return cmd +}