mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
refactor broadcast pipeline.
This commit is contained in:
parent
4debddf27d
commit
c9c8cc67ca
@ -12,20 +12,28 @@ import (
|
||||
)
|
||||
|
||||
type BroacastManagerCtx struct {
|
||||
logger zerolog.Logger
|
||||
mu sync.Mutex
|
||||
pipelineStr string
|
||||
logger zerolog.Logger
|
||||
mu sync.Mutex
|
||||
|
||||
pipeline *gst.Pipeline
|
||||
started bool
|
||||
url string
|
||||
pipelineStr string
|
||||
pipelineMu sync.Mutex
|
||||
|
||||
url string
|
||||
started bool
|
||||
}
|
||||
|
||||
func broadcastNew(pipelineStr string) *BroacastManagerCtx {
|
||||
logger := log.With().
|
||||
Str("module", "capture").
|
||||
Str("submodule", "broadcast").
|
||||
Logger()
|
||||
|
||||
return &BroacastManagerCtx{
|
||||
logger: log.With().Str("module", "capture").Str("submodule", "broadcast").Logger(),
|
||||
logger: logger,
|
||||
pipelineStr: pipelineStr,
|
||||
started: false,
|
||||
url: "",
|
||||
started: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,14 +66,23 @@ func (manager *BroacastManagerCtx) Stop() {
|
||||
}
|
||||
|
||||
func (manager *BroacastManagerCtx) Started() bool {
|
||||
manager.mu.Lock()
|
||||
defer manager.mu.Unlock()
|
||||
|
||||
return manager.started
|
||||
}
|
||||
|
||||
func (manager *BroacastManagerCtx) Url() string {
|
||||
manager.mu.Lock()
|
||||
defer manager.mu.Unlock()
|
||||
|
||||
return manager.url
|
||||
}
|
||||
|
||||
func (manager *BroacastManagerCtx) createPipeline() error {
|
||||
manager.pipelineMu.Lock()
|
||||
defer manager.pipelineMu.Unlock()
|
||||
|
||||
if manager.pipeline != nil {
|
||||
return types.ErrCapturePipelineAlreadyExists
|
||||
}
|
||||
@ -89,6 +106,9 @@ func (manager *BroacastManagerCtx) createPipeline() error {
|
||||
}
|
||||
|
||||
func (manager *BroacastManagerCtx) destroyPipeline() {
|
||||
manager.pipelineMu.Lock()
|
||||
defer manager.pipelineMu.Unlock()
|
||||
|
||||
if manager.pipeline == nil {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user