diff --git a/docs/getting-started/configuration.md b/docs/getting-started/configuration.md index 3688a21d..0c1f9f2f 100644 --- a/docs/getting-started/configuration.md +++ b/docs/getting-started/configuration.md @@ -107,9 +107,11 @@ nat1to1: #### `NEKO_BROADCAST_PIPELINE`: - Makes it possible to create custom gstreamer pipeline used for broadcasting, strings `{url}`, `{device}` and `{display}` will be replaced. #### `NEKO_BROADCAST_URL`: - - Set a default URL for broadcast streams. Setting this value will automatically enable broadcasting when n.eko starts. It can be disabled/changed later by admins in the GUI. + - Set a default URL for broadcast streams. It can be disabled/changed later by admins in the GUI. - e.g. `rtmp://:1935/ingest/` - +#### `NEKO_BROADCAST_AUTOSTART`: + - Automatically start broadcasting when neko starts and broadcast_url is set. + - e.g. `true` ### Server #### `NEKO_BIND`: diff --git a/server/internal/capture/broadcast.go b/server/internal/capture/broadcast.go index f1e81335..a3aa48ca 100644 --- a/server/internal/capture/broadcast.go +++ b/server/internal/capture/broadcast.go @@ -22,7 +22,7 @@ type BroacastManagerCtx struct { started bool } -func broadcastNew(pipelineFn func(url string) (string, error), defaultUrl string) *BroacastManagerCtx { +func broadcastNew(pipelineFn func(url string) (string, error), url string, started bool) *BroacastManagerCtx { logger := log.With(). Str("module", "capture"). Str("submodule", "broadcast"). @@ -31,8 +31,8 @@ func broadcastNew(pipelineFn func(url string) (string, error), defaultUrl string return &BroacastManagerCtx{ logger: logger, pipelineFn: pipelineFn, - url: defaultUrl, - started: defaultUrl != "", + url: url, + started: started, } } diff --git a/server/internal/capture/manager.go b/server/internal/capture/manager.go index 00f2d529..0cc48325 100644 --- a/server/internal/capture/manager.go +++ b/server/internal/capture/manager.go @@ -31,7 +31,7 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt // sinks broadcast: broadcastNew(func(url string) (string, error) { return NewBroadcastPipeline(config.AudioDevice, config.Display, config.BroadcastPipeline, url) - }, config.BroadcastUrl), + }, config.BroadcastUrl, config.BroadcastAutostart), audio: streamSinkNew(config.AudioCodec, func() (string, error) { return NewAudioPipeline(config.AudioCodec, config.AudioDevice, config.AudioPipeline, config.AudioBitrate) }, "audio"), diff --git a/server/internal/config/capture.go b/server/internal/config/capture.go index 7c4dbecd..2db0be6b 100644 --- a/server/internal/config/capture.go +++ b/server/internal/config/capture.go @@ -34,8 +34,9 @@ type Capture struct { AudioPipeline string // broadcast - BroadcastPipeline string - BroadcastUrl string + BroadcastPipeline string + BroadcastUrl string + BroadcastAutostart bool } func (Capture) Init(cmd *cobra.Command) error { @@ -155,11 +156,16 @@ func (Capture) Init(cmd *cobra.Command) error { return err } - cmd.PersistentFlags().String("broadcast_url", "", "URL for broadcasting, setting this value will automatically enable broadcasting") + cmd.PersistentFlags().String("broadcast_url", "", "a default default URL for broadcast streams, can be disabled/changed later by admins in the GUI") if err := viper.BindPFlag("broadcast_url", cmd.PersistentFlags().Lookup("broadcast_url")); err != nil { return err } + cmd.PersistentFlags().Bool("broadcast_autostart", true, "automatically start broadcasting when neko starts and broadcast_url is set") + if err := viper.BindPFlag("broadcast_autostart", cmd.PersistentFlags().Lookup("broadcast_autostart")); err != nil { + return err + } + return nil } @@ -247,4 +253,5 @@ func (s *Capture) Set() { s.BroadcastPipeline = viper.GetString("broadcast_pipeline") s.BroadcastUrl = viper.GetString("broadcast_url") + s.BroadcastAutostart = viper.GetBool("broadcast_autostart") }