Documentation
¶
Index ¶
- Variables
- func SendToThirdPartyAPI(exception *Exception)
- type EventRecord
- type Exception
- type FLVKeyframe
- type FLVRecorder
- func (r *FLVRecorder) Close() (err error)
- func (r *FLVRecorder) GetRecordModeString(mode RecordMode) string
- func (r *FLVRecorder) OnEvent(event any)
- func (r *FLVRecorder) SetId(streamPath string)
- func (r *FLVRecorder) Start(streamPath string) (err error)
- func (r *FLVRecorder) StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
- func (r *FLVRecorder) StartWithFileName(streamPath string, fileName string) error
- func (r *FLVRecorder) StopTimerRecord(reason ...zapcore.Field)
- func (r *FLVRecorder) UpdateTimeout(timeout time.Duration)
- type FMP4Recorder
- func (r *FMP4Recorder) Close() (err error)
- func (r *FMP4Recorder) GetRecordModeString(mode RecordMode) string
- func (r *FMP4Recorder) OnEvent(event any)
- func (r *FMP4Recorder) SetId(string)
- func (r *FMP4Recorder) Start(streamPath string) (err error)
- func (r *FMP4Recorder) StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
- func (r *FMP4Recorder) StartWithFileName(streamPath string, fileName string) error
- func (r *FMP4Recorder) UpdateTimeout(timeout time.Duration)
- type FileWr
- type FileWriter
- type HLSRecorder
- func (r *HLSRecorder) Close() (err error)
- func (h *HLSRecorder) CreateFile() (fw FileWr, err error)
- func (h *HLSRecorder) GetRecordModeString(mode RecordMode) string
- func (h *HLSRecorder) OnEvent(event any)
- func (h *HLSRecorder) SetId(string)
- func (h *HLSRecorder) Start(streamPath string) error
- func (h *HLSRecorder) StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
- func (h *HLSRecorder) StartWithFileName(streamPath string, fileName string) error
- func (h *HLSRecorder) UpdateTimeout(timeout time.Duration)
- type IRecorder
- type MP4Recorder
- func (r *MP4Recorder) Close() (err error)
- func (r *MP4Recorder) GetRecordModeString(mode RecordMode) string
- func (r *MP4Recorder) OnEvent(event any)
- func (r *MP4Recorder) SetId(string)
- func (r *MP4Recorder) Start(streamPath string) (err error)
- func (r *MP4Recorder) StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
- func (r *MP4Recorder) StartWithFileName(streamPath string, fileName string) error
- func (r *MP4Recorder) UpdateTimeout(timeout time.Duration)
- type RawRecorder
- func (r *RawRecorder) Close() (err error)
- func (r *RawRecorder) GetRecordModeString(mode RecordMode) string
- func (r *RawRecorder) OnEvent(event any)
- func (r *RawRecorder) SetId(string)
- func (r *RawRecorder) Start(streamPath string) error
- func (r *RawRecorder) StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
- func (r *RawRecorder) StartWithFileName(streamPath string, fileName string) error
- func (r *RawRecorder) UpdateTimeout(timeout time.Duration)
- type Record
- type RecordConfig
- func (conf *RecordConfig) API_alarm_list(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_event_list(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_event_pull(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_event_start(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_list(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_list_page(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_list_recording(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_list_recording_page(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_recordfile_delete(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_recordfile_modify(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_start(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) API_stop(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) CheckRecordDB()
- func (conf *RecordConfig) Download_flv_(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) OnEvent(event any)
- func (conf *RecordConfig) Play_flv_(w http.ResponseWriter, r *http.Request)
- func (conf *RecordConfig) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type RecordMode
- type Recorder
- type StorageConfig
- type VideoFileInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRecordExist = errors.New("recorder exist")
View Source
var RecordPluginConfig = &RecordConfig{ Flv: Record{ Path: "record/flv", Ext: ".flv", GetDurationFn: getFLVDuration, }, Fmp4: Record{ Path: "record/fmp4", Ext: ".mp4", }, Mp4: Record{ Path: "record/mp4", Ext: ".mp4", }, Hls: Record{ Path: "record/hls", Ext: ".m3u8", }, Raw: Record{ Path: "record/raw", Ext: ".", }, RawAudio: Record{ Path: "record/raw", Ext: ".", }, beforeDuration: 30, afterDuration: 30, MysqlDSN: "", ExceptionPostUrl: "http://www.163.com", SqliteDbPath: "./m7sv4.db", DiskMaxPercent: 80.00, LocalIp: getLocalIP(), RecordFileExpireDays: 0, RecordPathNotShowStreamPath: true, }
View Source
var WritingFiles sync.Map
Functions ¶
func SendToThirdPartyAPI ¶ added in v4.8.0
func SendToThirdPartyAPI(exception *Exception)
向第三方发送异常报警
Types ¶
type EventRecord ¶ added in v4.8.0
type EventRecord struct {
Id uint `json:"id" desc:"自增长id" gorm:"primaryKey;autoIncrement"`
StreamPath string `json:"streamPath" desc:"流路径" gorm:"type:varchar(255);comment:流路径"`
RecId string `json:"RecId" desc:"录制编号" gorm:"type:varchar(255);comment:录制编号"`
RecordMode string `` /* 171-byte string literal not displayed */
EventName string `json:"eventName" desc:"事件名称" gorm:"type:varchar(255);comment:事件名称"`
BeforeDuration string `json:"beforeDuration" desc:"事件前缓存时长" gorm:"type:varchar(255);comment:事件前缓存时长"`
AfterDuration string `json:"afterDuration" desc:"事件后缓存时长" gorm:"type:varchar(255);comment:事件后缓存时长"`
CreateTime string `json:"createTime" desc:"录像时间" gorm:"type:varchar(255);comment:录像时间"`
StartTime string `json:"startTime" desc:"录像开始时间" gorm:"type:varchar(255);comment:录像开始时间"`
EndTime string `json:"endTime" desc:"录像结束时间" gorm:"type:varchar(255);comment:录像结束时间"`
Filepath string `json:"filePath" desc:"录像文件物理路径" gorm:"type:varchar(255);comment:录像文件物理路径"`
Urlpath string `json:"urlPath" desc:"录像文件下载URL路径" gorm:"type:varchar(255);comment:录像文件下载URL路径"`
IsDelete string `` /* 177-byte string literal not displayed */
UserId string `json:"useId" desc:"用户id" gorm:"type:varchar(255);comment:用户id"`
Filename string `json:"fileName" desc:"文件名" gorm:"type:varchar(255);comment:文件名"`
Fragment string `json:"fragment" desc:"切片大小" gorm:"type:varchar(255);comment:切片大小;default:'0'"`
EventDesc string `json:"eventDesc" desc:"事件描述" gorm:"type:varchar(255);comment:事件描述"`
Type string `json:"type" desc:"录像文件类型" gorm:"type:varchar(255);comment:录像文件类型,flv,mp4,raw,fmp4,hls"`
EventLevel string `` /* 223-byte string literal not displayed */
}
mysql数据库eventrecord表
type Exception ¶ added in v4.8.0
type Exception struct {
CreateTime string `json:"createTime" gorm:"type:varchar(50)"`
AlarmType string `json:"alarmType" gorm:"type:varchar(50)"`
AlarmDesc string `json:"alarmDesc" gorm:"type:varchar(50)"`
ServerIP string `json:"serverIP" gorm:"type:varchar(50)"`
StreamPath string `json:"streamPath" gorm:"type:varchar(50)"`
FileName string `json:"fileName" gorm:"type:varchar(100)"`
}
mysql数据库里Exception 定义异常结构体
type FLVKeyframe ¶ added in v4.8.0
type FLVKeyframe struct {
FLVFileName string `gorm:"not null"`
FrameOffset int64 `gorm:"not null"`
FrameAbstime uint32 `gorm:"not null"`
CreatedAt time.Time `gorm:"autoCreateTime"`
}
sqlite数据库用来存放每个flv文件的关键帧对应的offset及abstime数据
type FLVRecorder ¶
type FLVRecorder struct {
Recorder
Offset int64
RecordMode
// contains filtered or unexported fields
}
func NewFLVRecorder ¶
func NewFLVRecorder(mode RecordMode) (r *FLVRecorder)
func (*FLVRecorder) Close ¶
func (r *FLVRecorder) Close() (err error)
func (*FLVRecorder) GetRecordModeString ¶ added in v4.8.0
func (r *FLVRecorder) GetRecordModeString(mode RecordMode) string
func (*FLVRecorder) OnEvent ¶
func (r *FLVRecorder) OnEvent(event any)
func (*FLVRecorder) SetId ¶ added in v4.8.0
func (r *FLVRecorder) SetId(streamPath string)
func (*FLVRecorder) Start ¶
func (r *FLVRecorder) Start(streamPath string) (err error)
func (*FLVRecorder) StartWithDynamicTimeout ¶ added in v4.8.0
func (r *FLVRecorder) StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
func (*FLVRecorder) StartWithFileName ¶ added in v4.6.0
func (r *FLVRecorder) StartWithFileName(streamPath string, fileName string) error
func (*FLVRecorder) StopTimerRecord ¶ added in v4.8.0
func (r *FLVRecorder) StopTimerRecord(reason ...zapcore.Field)
停止定时录像
func (*FLVRecorder) UpdateTimeout ¶ added in v4.8.0
func (r *FLVRecorder) UpdateTimeout(timeout time.Duration)
type FMP4Recorder ¶
type FMP4Recorder struct {
Recorder
// contains filtered or unexported fields
}
func NewFMP4Recorder ¶
func NewFMP4Recorder() *FMP4Recorder
func (*FMP4Recorder) Close ¶
func (r *FMP4Recorder) Close() (err error)
func (*FMP4Recorder) GetRecordModeString ¶ added in v4.8.0
func (r *FMP4Recorder) GetRecordModeString(mode RecordMode) string
func (*FMP4Recorder) OnEvent ¶
func (r *FMP4Recorder) OnEvent(event any)
func (*FMP4Recorder) SetId ¶ added in v4.8.0
func (r *FMP4Recorder) SetId(string)
func (*FMP4Recorder) Start ¶
func (r *FMP4Recorder) Start(streamPath string) (err error)
func (*FMP4Recorder) StartWithDynamicTimeout ¶ added in v4.8.0
func (r *FMP4Recorder) StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
func (*FMP4Recorder) StartWithFileName ¶ added in v4.6.0
func (r *FMP4Recorder) StartWithFileName(streamPath string, fileName string) error
func (*FMP4Recorder) UpdateTimeout ¶ added in v4.8.0
func (r *FMP4Recorder) UpdateTimeout(timeout time.Duration)
type FileWriter ¶
type FileWriter struct {
io.Reader
io.Writer
io.Seeker
io.Closer
// contains filtered or unexported fields
}
func (*FileWriter) Close ¶
func (f *FileWriter) Close() error
type HLSRecorder ¶
type HLSRecorder struct {
Recorder
MemoryTs
// contains filtered or unexported fields
}
func NewHLSRecorder ¶
func NewHLSRecorder() (r *HLSRecorder)
func (*HLSRecorder) Close ¶
func (r *HLSRecorder) Close() (err error)
func (*HLSRecorder) CreateFile ¶
func (h *HLSRecorder) CreateFile() (fw FileWr, err error)
创建一个新的ts文件
func (*HLSRecorder) GetRecordModeString ¶ added in v4.8.0
func (h *HLSRecorder) GetRecordModeString(mode RecordMode) string
func (*HLSRecorder) OnEvent ¶
func (h *HLSRecorder) OnEvent(event any)
func (*HLSRecorder) SetId ¶ added in v4.8.0
func (h *HLSRecorder) SetId(string)
func (*HLSRecorder) Start ¶
func (h *HLSRecorder) Start(streamPath string) error
func (*HLSRecorder) StartWithDynamicTimeout ¶ added in v4.8.0
func (h *HLSRecorder) StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
func (*HLSRecorder) StartWithFileName ¶ added in v4.6.0
func (h *HLSRecorder) StartWithFileName(streamPath string, fileName string) error
func (*HLSRecorder) UpdateTimeout ¶ added in v4.8.0
func (h *HLSRecorder) UpdateTimeout(timeout time.Duration)
type IRecorder ¶
type IRecorder interface {
ISubscriber
GetRecorder() *Recorder
Start(streamPath string) error
StartWithFileName(streamPath string, fileName string) error
io.Closer
CreateFile() (FileWr, error)
StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
UpdateTimeout(timeout time.Duration)
GetRecordModeString(mode RecordMode) string
SetId(streamPath string)
}
type MP4Recorder ¶
type MP4Recorder struct {
Recorder
*mp4.Movmuxer `json:"-" yaml:"-"`
// contains filtered or unexported fields
}
func NewMP4Recorder ¶
func NewMP4Recorder() *MP4Recorder
func (*MP4Recorder) Close ¶
func (r *MP4Recorder) Close() (err error)
func (*MP4Recorder) GetRecordModeString ¶ added in v4.8.0
func (r *MP4Recorder) GetRecordModeString(mode RecordMode) string
func (*MP4Recorder) OnEvent ¶
func (r *MP4Recorder) OnEvent(event any)
func (*MP4Recorder) SetId ¶ added in v4.8.0
func (r *MP4Recorder) SetId(string)
func (*MP4Recorder) Start ¶
func (r *MP4Recorder) Start(streamPath string) (err error)
func (*MP4Recorder) StartWithDynamicTimeout ¶ added in v4.8.0
func (r *MP4Recorder) StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
func (*MP4Recorder) StartWithFileName ¶ added in v4.6.0
func (r *MP4Recorder) StartWithFileName(streamPath string, fileName string) error
func (*MP4Recorder) UpdateTimeout ¶ added in v4.8.0
func (r *MP4Recorder) UpdateTimeout(timeout time.Duration)
type RawRecorder ¶
func NewRawAudioRecorder ¶
func NewRawAudioRecorder() (r *RawRecorder)
func NewRawRecorder ¶
func NewRawRecorder() (r *RawRecorder)
func (*RawRecorder) Close ¶
func (r *RawRecorder) Close() (err error)
func (*RawRecorder) GetRecordModeString ¶ added in v4.8.0
func (r *RawRecorder) GetRecordModeString(mode RecordMode) string
func (*RawRecorder) OnEvent ¶
func (r *RawRecorder) OnEvent(event any)
func (*RawRecorder) SetId ¶ added in v4.8.0
func (r *RawRecorder) SetId(string)
func (*RawRecorder) Start ¶
func (r *RawRecorder) Start(streamPath string) error
func (*RawRecorder) StartWithDynamicTimeout ¶ added in v4.8.0
func (r *RawRecorder) StartWithDynamicTimeout(streamPath, fileName string, timeout time.Duration) error
func (*RawRecorder) StartWithFileName ¶ added in v4.6.0
func (r *RawRecorder) StartWithFileName(streamPath string, fileName string) error
func (*RawRecorder) UpdateTimeout ¶ added in v4.8.0
func (r *RawRecorder) UpdateTimeout(timeout time.Duration)
type Record ¶
type Record struct {
Ext string `desc:"文件扩展名"` //文件扩展名
Path string `desc:"存储文件的目录"` //存储文件的目录
AutoRecord bool `desc:"是否自动录制"` //是否自动录制
Filter config.Regexp `desc:"录制过滤器"` //录制过滤器
Fragment time.Duration `desc:"分片大小,0表示不分片"` //分片大小,0表示不分片
Duration time.Duration `desc:"视频最大录制时长,0表示不限制"` //分片大小,0表示不分片
http.Handler `json:"-" yaml:"-"`
CreateFileFn func(filename string, append bool) (FileWr, error) `json:"-" yaml:"-"`
GetDurationFn func(file io.ReadSeeker) uint32 `json:"-" yaml:"-"`
}
func (*Record) NeedRecord ¶
type RecordConfig ¶
type RecordConfig struct {
config.Subscribe
config.HTTP
Flv Record `desc:"flv录制配置"`
Mp4 Record `desc:"mp4录制配置"`
Fmp4 Record `desc:"fmp4录制配置"`
Hls Record `desc:"hls录制配置"`
Raw Record `desc:"视频裸流录制配置"`
RawAudio Record `desc:"音频裸流录制配置"`
MysqlDSN string `desc:"mysql数据库连接字符串"`
ExceptionPostUrl string `desc:"第三方异常上报地址"`
SqliteDbPath string `desc:"sqlite数据库路径"`
DiskMaxPercent float64 `desc:"硬盘使用百分之上限值,超过后报警"`
LocalIp string `desc:"本机IP"`
RecordFileExpireDays int `desc:"录像自动删除的天数,0或未设置表示不自动删除"`
RecordPathNotShowStreamPath bool `desc:"录像路径中是否包含streamPath,默认true"`
Storage StorageConfig `desc:"MINIO 配置"`
// contains filtered or unexported fields
}
func (*RecordConfig) API_alarm_list ¶ added in v4.8.0
func (conf *RecordConfig) API_alarm_list(w http.ResponseWriter, r *http.Request)
录像报警列表
func (*RecordConfig) API_event_list ¶ added in v4.8.0
func (conf *RecordConfig) API_event_list(w http.ResponseWriter, r *http.Request)
事件录像列表
func (*RecordConfig) API_event_pull ¶ added in v4.8.0
func (conf *RecordConfig) API_event_pull(w http.ResponseWriter, r *http.Request)
根据事件id拉取录像流
func (*RecordConfig) API_event_start ¶ added in v4.8.0
func (conf *RecordConfig) API_event_start(w http.ResponseWriter, r *http.Request)
事件录像
func (*RecordConfig) API_list ¶
func (conf *RecordConfig) API_list(w http.ResponseWriter, r *http.Request)
func (*RecordConfig) API_list_page ¶ added in v4.6.0
func (conf *RecordConfig) API_list_page(w http.ResponseWriter, r *http.Request)
func (*RecordConfig) API_list_recording ¶
func (conf *RecordConfig) API_list_recording(w http.ResponseWriter, r *http.Request)
func (*RecordConfig) API_list_recording_page ¶ added in v4.6.0
func (conf *RecordConfig) API_list_recording_page(w http.ResponseWriter, r *http.Request)
func (*RecordConfig) API_recordfile_delete ¶ added in v4.6.0
func (conf *RecordConfig) API_recordfile_delete(w http.ResponseWriter, r *http.Request)
func (*RecordConfig) API_recordfile_modify ¶ added in v4.6.0
func (conf *RecordConfig) API_recordfile_modify(w http.ResponseWriter, r *http.Request)
func (*RecordConfig) API_start ¶
func (conf *RecordConfig) API_start(w http.ResponseWriter, r *http.Request)
func (*RecordConfig) API_stop ¶
func (conf *RecordConfig) API_stop(w http.ResponseWriter, r *http.Request)
func (*RecordConfig) CheckRecordDB ¶ added in v4.9.0
func (conf *RecordConfig) CheckRecordDB()
查询所有正在录制中的记录
func (*RecordConfig) Download_flv_ ¶ added in v4.8.0
func (conf *RecordConfig) Download_flv_(w http.ResponseWriter, r *http.Request)
func (*RecordConfig) OnEvent ¶
func (conf *RecordConfig) OnEvent(event any)
func (*RecordConfig) Play_flv_ ¶ added in v4.8.0
func (conf *RecordConfig) Play_flv_(w http.ResponseWriter, r *http.Request)
func (*RecordConfig) ServeHTTP ¶
func (conf *RecordConfig) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RecordMode ¶ added in v4.8.0
type RecordMode int
录像类型
const ( OrdinaryMode RecordMode = iota // iota 初始值为 0,表示普通录像(连续录像),包括自动录像和手动录像 EventMode // 1,表示事件录像 )
使用常量块和 iota 来定义枚举值
type Recorder ¶
type Recorder struct {
Subscriber
Storage StorageConfig
SkipTS uint32
Record `json:"-" yaml:"-"`
File FileWr `json:"-" yaml:"-"`
FileName string // 自定义文件名,分段录像无效
// contains filtered or unexported fields
}
func (*Recorder) CreateFile ¶
func (*Recorder) GetRecorder ¶
func (*Recorder) RemoveRecordById ¶ added in v4.9.0
func (r *Recorder) RemoveRecordById()
更新录像文件表中记录,包括录像文件的大小、结束时间以及录像状态
func (*Recorder) UploadFile ¶ added in v4.4.8
type StorageConfig ¶ added in v4.4.8
type VideoFileInfo ¶
Click to show internal directories.
Click to hide internal directories.