broadcast naming convention & on destroy.

This commit is contained in:
Miroslav Šedivý 2020-11-14 13:46:12 +01:00
parent bd45e81afe
commit d09b6dcb10
2 changed files with 27 additions and 25 deletions

View File

@ -4,7 +4,26 @@ import (
"demodesk/neko/internal/capture/gst" "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 var err error
if manager.broadcast != nil || !manager.BroadcastEnabled() { if manager.broadcast != nil || !manager.BroadcastEnabled() {
@ -32,7 +51,7 @@ func (manager *CaptureManagerCtx) StartBroadcastPipeline() {
manager.logger.Info().Msgf("starting broadcast pipeline") manager.logger.Info().Msgf("starting broadcast pipeline")
} }
func (manager *CaptureManagerCtx) StopBroadcastPipeline() { func (manager *CaptureManagerCtx) destroyBroadcastPipeline() {
if manager.broadcast == nil { if manager.broadcast == nil {
return return
} }
@ -41,22 +60,3 @@ func (manager *CaptureManagerCtx) StopBroadcastPipeline() {
manager.logger.Info().Msgf("stopping broadcast pipeline") manager.logger.Info().Msgf("stopping broadcast pipeline")
manager.broadcast = nil 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
}

View File

@ -42,16 +42,16 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt
} }
func (manager *CaptureManagerCtx) Start() { func (manager *CaptureManagerCtx) Start() {
manager.StartBroadcastPipeline() manager.createBroadcastPipeline()
manager.desktop.OnBeforeScreenSizeChange(func() { manager.desktop.OnBeforeScreenSizeChange(func() {
manager.destroyVideoPipeline() manager.destroyVideoPipeline()
manager.StopBroadcastPipeline() manager.destroyBroadcastPipeline()
}) })
manager.desktop.OnAfterScreenSizeChange(func() { manager.desktop.OnAfterScreenSizeChange(func() {
manager.createVideoPipeline() manager.createVideoPipeline()
manager.StartBroadcastPipeline() manager.createBroadcastPipeline()
}) })
go func() { go func() {
@ -75,8 +75,10 @@ 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.emit_stop <- true
manager.StopStream() manager.StopStream()
manager.destroyBroadcastPipeline()
manager.emit_stop <- true
return nil return nil
} }