neko/internal/capture/broadcast.go

63 lines
1.4 KiB
Go
Raw Normal View History

2020-11-02 04:09:48 +13:00
package capture
import (
"demodesk/neko/internal/capture/gst"
)
func (manager *CaptureManagerCtx) StartBroadcastPipeline() {
var err error
2020-11-02 05:34:47 +13:00
if manager.broadcast != nil || !manager.BroadcastEnabled() {
2020-11-02 04:09:48 +13:00
return
}
manager.logger.Info().
Str("audio_device", manager.config.Device).
Str("video_display", manager.config.Display).
2020-11-02 05:34:47 +13:00
Str("broadcast_pipeline", manager.config.BroadcastPipeline).
2020-11-02 04:09:48 +13:00
Msgf("Creating broadcast pipeline...")
manager.broadcast, err = gst.CreateRTMPPipeline(
manager.config.Device,
manager.config.Display,
manager.config.BroadcastPipeline,
manager.broadcast_url,
)
if err != nil {
manager.logger.Panic().Err(err).Msg("unable to create broadcast pipeline")
}
manager.broadcast.Play()
manager.logger.Info().Msgf("Starting broadcast pipeline...")
}
func (manager *CaptureManagerCtx) StopBroadcastPipeline() {
2020-11-02 05:34:47 +13:00
if manager.broadcast == nil {
2020-11-02 04:09:48 +13:00
return
}
2020-11-02 08:18:19 +13:00
manager.broadcast.Stop()
2020-11-02 05:34:47 +13:00
manager.logger.Info().Msgf("Stopping broadcast pipeline...")
2020-11-02 04:09:48 +13:00
manager.broadcast = nil
}
func (manager *CaptureManagerCtx) StartBroadcast(url string) {
manager.broadcast_url = url
2020-11-02 05:34:47 +13:00
manager.broadcasting = true
2020-11-02 04:09:48 +13:00
manager.StartBroadcastPipeline()
}
func (manager *CaptureManagerCtx) StopBroadcast() {
2020-11-02 05:34:47 +13:00
manager.broadcasting = false
2020-11-02 04:09:48 +13:00
manager.StopBroadcastPipeline()
}
2020-11-02 05:34:47 +13:00
func (manager *CaptureManagerCtx) BroadcastEnabled() bool {
return manager.broadcasting
2020-11-02 04:09:48 +13:00
}
func (manager *CaptureManagerCtx) BroadcastUrl() string {
return manager.broadcast_url
}