mirror of
https://github.com/Monibuca/plugin-record.git
synced 2025-10-05 16:56:53 +08:00
增加文件抽象和文件流过滤
This commit is contained in:
15
main.go
15
main.go
@@ -2,6 +2,7 @@ package record
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
@@ -25,6 +26,18 @@ type FlvFileInfo struct {
|
||||
Duration uint32
|
||||
}
|
||||
|
||||
type FileWr interface {
|
||||
io.Reader
|
||||
io.Writer
|
||||
io.Seeker
|
||||
io.Closer
|
||||
}
|
||||
|
||||
var ExtraConfig struct {
|
||||
CreateFileFn func(filename string) (FileWr,error)
|
||||
AutoRecordFilter func(stream string) bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
InstallPlugin(&PluginConfig{
|
||||
Name: "Record",
|
||||
@@ -115,7 +128,7 @@ func run() {
|
||||
|
||||
func onPublish(v interface{}) {
|
||||
p := v.(*Stream)
|
||||
if config.AutoRecord {
|
||||
if config.AutoRecord || (ExtraConfig.AutoRecordFilter != nil && ExtraConfig.AutoRecordFilter(p.StreamPath)) {
|
||||
SaveFlv(p.StreamPath, false)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user