From d09b6dcb10f2205dafa2900620f97b81b119f232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 14 Nov 2020 13:46:12 +0100 Subject: [PATCH] broadcast naming convention & on destroy. --- internal/capture/broadcast.go | 42 +++++++++++++++++------------------ internal/capture/manager.go | 10 +++++---- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/internal/capture/broadcast.go b/internal/capture/broadcast.go index 19b08508..28a3a7d8 100644 --- a/internal/capture/broadcast.go +++ b/internal/capture/broadcast.go @@ -4,7 +4,26 @@ import ( "demodesk/neko/internal/capture/gst" ) -func (manager *CaptureManagerCtx) StartBroadcastPipeline() { +func (manager *CaptureManagerCtx) StartBroadcast(url string) { + manager.broadcast_url = url + manager.broadcasting = true + manager.createBroadcastPipeline() +} + +func (manager *CaptureManagerCtx) StopBroadcast() { + manager.broadcasting = false + manager.destroyBroadcastPipeline() +} + +func (manager *CaptureManagerCtx) BroadcastEnabled() bool { + return manager.broadcasting +} + +func (manager *CaptureManagerCtx) BroadcastUrl() string { + return manager.broadcast_url +} + +func (manager *CaptureManagerCtx) createBroadcastPipeline() { var err error if manager.broadcast != nil || !manager.BroadcastEnabled() { @@ -32,7 +51,7 @@ func (manager *CaptureManagerCtx) StartBroadcastPipeline() { manager.logger.Info().Msgf("starting broadcast pipeline") } -func (manager *CaptureManagerCtx) StopBroadcastPipeline() { +func (manager *CaptureManagerCtx) destroyBroadcastPipeline() { if manager.broadcast == nil { return } @@ -41,22 +60,3 @@ func (manager *CaptureManagerCtx) StopBroadcastPipeline() { manager.logger.Info().Msgf("stopping broadcast pipeline") manager.broadcast = nil } - -func (manager *CaptureManagerCtx) StartBroadcast(url string) { - manager.broadcast_url = url - manager.broadcasting = true - manager.StartBroadcastPipeline() -} - -func (manager *CaptureManagerCtx) StopBroadcast() { - manager.broadcasting = false - manager.StopBroadcastPipeline() -} - -func (manager *CaptureManagerCtx) BroadcastEnabled() bool { - return manager.broadcasting -} - -func (manager *CaptureManagerCtx) BroadcastUrl() string { - return manager.broadcast_url -} diff --git a/internal/capture/manager.go b/internal/capture/manager.go index dae54eb7..1feb688c 100644 --- a/internal/capture/manager.go +++ b/internal/capture/manager.go @@ -42,16 +42,16 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt } func (manager *CaptureManagerCtx) Start() { - manager.StartBroadcastPipeline() + manager.createBroadcastPipeline() manager.desktop.OnBeforeScreenSizeChange(func() { manager.destroyVideoPipeline() - manager.StopBroadcastPipeline() + manager.destroyBroadcastPipeline() }) manager.desktop.OnAfterScreenSizeChange(func() { manager.createVideoPipeline() - manager.StartBroadcastPipeline() + manager.createBroadcastPipeline() }) go func() { @@ -75,8 +75,10 @@ func (manager *CaptureManagerCtx) Start() { func (manager *CaptureManagerCtx) Shutdown() error { manager.logger.Info().Msgf("capture shutting down") - manager.emit_stop <- true manager.StopStream() + + manager.destroyBroadcastPipeline() + manager.emit_stop <- true return nil }