Skip to content

Commit

Permalink
feature: 添加gb28181的fi指令支持
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Apr 19, 2023
1 parent 4a25393 commit 0b84a8f
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions gb28181/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const (
PtzDown = 2
PtzLeft = 1
PtzRight = 0

FiIrisReduce = 3
FiIrisExpand = 2
FiFocusNear = 1
FiFocusAway = 0
)

type Cmd []int
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
}

0 comments on commit 0b84a8f

Please sign in to comment.