feat: add subscriber type

This commit is contained in:
langhuihui
2024-12-18 13:23:10 +08:00
parent 0042568dff
commit 6037cbe18d
19 changed files with 1309 additions and 722 deletions

View File

@@ -12,8 +12,14 @@ import (
"m7s.live/v5/pkg"
)
const (
RecordModeAuto RecordMode = "auto"
RecordModeEvent RecordMode = "event"
)
type (
IRecorder interface {
RecordMode = string
IRecorder interface {
task.ITask
GetRecordJob() *RecordJob
}
@@ -29,7 +35,7 @@ type (
FilePath string
recorder IRecorder
EventId string `json:"eventId" desc:"事件编号"`
RecordMode string `json:"recordMode" desc:"事件类型,0=连续录像模式,1=事件录像模式"`
RecordMode RecordMode `json:"recordMode" desc:"事件类型,auto=连续录像模式,event=事件录像模式"`
BeforeDuration time.Duration `json:"beforeDuration" desc:"事件前缓存时长"`
AfterDuration time.Duration `json:"afterDuration" desc:"事件后缓存时长"`
EventDesc string `json:"eventDesc" desc:"事件描述"`
@@ -44,7 +50,7 @@ type (
ID uint `gorm:"primarykey"`
StartTime, EndTime time.Time `gorm:"default:'1970-01-01 00:00:00'"`
EventId string `json:"eventId" desc:"事件编号" gorm:"type:varchar(255);comment:事件编号"`
RecordMode string `json:"recordMode" desc:"事件类型,0=连续录像模式,1=事件录像模式" gorm:"type:varchar(255);comment:事件类型,0=连续录像模式,1=事件录像模式;default:'0'"`
RecordMode RecordMode `json:"recordMode" desc:"事件类型,auto=连续录像模式,event=事件录像模式" gorm:"type:varchar(255);comment:事件类型,auto=连续录像模式,event=事件录像模式;default:'auto'"`
EventName string `json:"eventName" desc:"事件名称" gorm:"type:varchar(255);comment:事件名称"`
BeforeDuration time.Duration `json:"beforeDuration" desc:"事件前缓存时长" gorm:"type:BIGINT;comment:事件前缓存时长;default:30000000000"`
AfterDuration time.Duration `json:"afterDuration" desc:"事件后缓存时长" gorm:"type:BIGINT;comment:事件后缓存时长;default:30000000000"`
@@ -78,7 +84,7 @@ func (p *RecordJob) Subscribe() (err error) {
p.Subscriber, err = p.Plugin.Subscribe(p.recorder.GetTask().Context, p.StreamPath)
}
if p.Subscriber != nil {
p.Subscriber.Internal = true
p.Subscriber.Type = SubscribeTypeVod
}
return
}