mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
unify capture shutdown.
This commit is contained in:
parent
7902d7b1f1
commit
58ea3665b0
@ -25,6 +25,12 @@ func broadcastNew(config *config.Capture) *BroacastManagerCtx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (manager *BroacastManagerCtx) shutdown() {
|
||||||
|
manager.logger.Info().Msgf("shutting down")
|
||||||
|
|
||||||
|
manager.destroyPipeline()
|
||||||
|
}
|
||||||
|
|
||||||
func (manager *BroacastManagerCtx) Start(url string) error {
|
func (manager *BroacastManagerCtx) Start(url string) error {
|
||||||
manager.url = url
|
manager.url = url
|
||||||
manager.enabled = true
|
manager.enabled = true
|
||||||
|
@ -81,11 +81,11 @@ func (manager *CaptureManagerCtx) Start() {
|
|||||||
func (manager *CaptureManagerCtx) Shutdown() error {
|
func (manager *CaptureManagerCtx) Shutdown() error {
|
||||||
manager.logger.Info().Msgf("capture shutting down")
|
manager.logger.Info().Msgf("capture shutting down")
|
||||||
|
|
||||||
manager.broadcast.destroyPipeline()
|
manager.broadcast.shutdown()
|
||||||
manager.screencast.destroyPipeline()
|
manager.screencast.shutdown()
|
||||||
manager.screencast.shutdown <- true
|
|
||||||
manager.audio.Shutdown()
|
manager.audio.shutdown()
|
||||||
manager.video.Shutdown()
|
manager.video.shutdown()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ type ScreencastManagerCtx struct {
|
|||||||
pipeline *gst.Pipeline
|
pipeline *gst.Pipeline
|
||||||
enabled bool
|
enabled bool
|
||||||
started bool
|
started bool
|
||||||
shutdown chan bool
|
emitStop chan bool
|
||||||
refresh chan bool
|
emitUpdate chan bool
|
||||||
expired int32
|
expired int32
|
||||||
sample chan types.Sample
|
sample chan types.Sample
|
||||||
image types.Sample
|
image types.Sample
|
||||||
@ -34,8 +34,8 @@ func screencastNew(config *config.Capture) *ScreencastManagerCtx {
|
|||||||
config: config,
|
config: config,
|
||||||
enabled: config.Screencast,
|
enabled: config.Screencast,
|
||||||
started: false,
|
started: false,
|
||||||
shutdown: make(chan bool),
|
emitStop: make(chan bool),
|
||||||
refresh: make(chan bool),
|
emitUpdate: make(chan bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
if !manager.enabled {
|
if !manager.enabled {
|
||||||
@ -44,16 +44,16 @@ func screencastNew(config *config.Capture) *ScreencastManagerCtx {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
ticker := time.NewTicker(5 * time.Second)
|
ticker := time.NewTicker(5 * time.Second)
|
||||||
manager.logger.Debug().Msg("subroutine started")
|
manager.logger.Debug().Msg("started emitting samples")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-manager.shutdown:
|
case <-manager.emitStop:
|
||||||
manager.logger.Debug().Msg("shutting down")
|
manager.logger.Debug().Msg("stopped emitting samples")
|
||||||
ticker.Stop()
|
ticker.Stop()
|
||||||
return
|
return
|
||||||
case <-manager.refresh:
|
case <-manager.emitUpdate:
|
||||||
manager.logger.Debug().Msg("subroutine updated")
|
manager.logger.Debug().Msg("update emitting samples")
|
||||||
case sample := <-manager.sample:
|
case sample := <-manager.sample:
|
||||||
manager.image = sample
|
manager.image = sample
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
@ -67,6 +67,13 @@ func screencastNew(config *config.Capture) *ScreencastManagerCtx {
|
|||||||
return manager
|
return manager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (manager *ScreencastManagerCtx) shutdown() {
|
||||||
|
manager.logger.Info().Msgf("shutting down")
|
||||||
|
|
||||||
|
manager.destroyPipeline()
|
||||||
|
manager.emitStop <- true
|
||||||
|
}
|
||||||
|
|
||||||
func (manager *ScreencastManagerCtx) Enabled() bool {
|
func (manager *ScreencastManagerCtx) Enabled() bool {
|
||||||
return manager.enabled
|
return manager.enabled
|
||||||
}
|
}
|
||||||
@ -144,7 +151,7 @@ func (manager *ScreencastManagerCtx) createPipeline() error {
|
|||||||
manager.logger.Info().Msgf("starting pipeline")
|
manager.logger.Info().Msgf("starting pipeline")
|
||||||
|
|
||||||
manager.sample = manager.pipeline.Sample
|
manager.sample = manager.pipeline.Sample
|
||||||
manager.refresh <-true
|
manager.emitUpdate <-true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ func streamNew(codec codec.RTPCodec, pipelineDevice string, pipelineSrc string)
|
|||||||
return manager
|
return manager
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *StreamManagerCtx) Shutdown() {
|
func (manager *StreamManagerCtx) shutdown() {
|
||||||
manager.logger.Info().Msgf("shutting down")
|
manager.logger.Info().Msgf("shutting down")
|
||||||
|
|
||||||
manager.destroyPipeline()
|
manager.destroyPipeline()
|
||||||
|
@ -22,8 +22,6 @@ type ScreencastManager interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type StreamManager interface {
|
type StreamManager interface {
|
||||||
Shutdown()
|
|
||||||
|
|
||||||
Codec() codec.RTPCodec
|
Codec() codec.RTPCodec
|
||||||
OnSample(listener func(sample Sample))
|
OnSample(listener func(sample Sample))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user