导出config

This commit is contained in:
banshan
2022-10-30 16:08:22 +08:00
parent 2bac84c571
commit f7393135de
6 changed files with 11 additions and 11 deletions

8
flv.go
View File

@@ -13,16 +13,16 @@ type FLVRecorder struct {
Recorder
}
func (r *FLVRecorder) Start(streamPath string) (err error){
r.Record = &recordConfig.Flv
func (r *FLVRecorder) Start(streamPath string) (err error) {
r.Record = &RecordPluginConfig.Flv
r.ID = streamPath + "/flv"
return plugin.Subscribe(streamPath, r)
}
func (r *FLVRecorder) start() {
recordConfig.recordings.Store(r.ID, r)
RecordPluginConfig.recordings.Store(r.ID, r)
r.PlayFLV()
recordConfig.recordings.Delete(r.ID)
RecordPluginConfig.recordings.Delete(r.ID)
r.Close()
}

2
hls.go
View File

@@ -23,7 +23,7 @@ type HLSRecorder struct {
}
func (h *HLSRecorder) Start(streamPath string) error {
h.Record = &recordConfig.Hls
h.Record = &RecordPluginConfig.Hls
h.ID = streamPath + "/hls"
return plugin.Subscribe(streamPath, h)
}

View File

@@ -21,7 +21,7 @@ type RecordConfig struct {
recordings sync.Map
}
var recordConfig = &RecordConfig{
var RecordPluginConfig = &RecordConfig{
Subscribe: config.Subscribe{
SubAudio: true,
SubVideo: true,
@@ -48,7 +48,7 @@ var recordConfig = &RecordConfig{
},
}
var plugin = InstallPlugin(recordConfig)
var plugin = InstallPlugin(RecordPluginConfig)
func (conf *RecordConfig) OnEvent(event any) {
switch v := event.(type) {

2
mp4.go
View File

@@ -68,7 +68,7 @@ func NewMP4Recorder() *MP4Recorder {
}
func (r *MP4Recorder) Start(streamPath string) (err error) {
r.Record = &recordConfig.Mp4
r.Record = &RecordPluginConfig.Mp4
r.ID = streamPath + "/mp4"
return plugin.Subscribe(streamPath, r)
}

2
raw.go
View File

@@ -15,7 +15,7 @@ type RawRecorder struct {
}
func (r *RawRecorder) Start(streamPath string) error {
r.Record = &recordConfig.Raw
r.Record = &RecordPluginConfig.Raw
r.ID = streamPath + "/raw"
return plugin.Subscribe(streamPath, r)
}

View File

@@ -16,9 +16,9 @@ type Recorder struct {
}
func (r *Recorder) start() {
recordConfig.recordings.Store(r.ID, r)
RecordPluginConfig.recordings.Store(r.ID, r)
r.PlayRaw()
recordConfig.recordings.Delete(r.ID)
RecordPluginConfig.recordings.Delete(r.ID)
r.Close()
}