增加文件抽象和文件流过滤

This commit is contained in:
banshan
2021-06-27 14:42:39 +08:00
parent ead7f0ac39
commit 5ee1de64a3
2 changed files with 27 additions and 8 deletions

15
main.go
View File

@@ -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)
}
}