neko/server/internal/broadcast/manager.go

44 lines
860 B
Go
Raw Normal View History

2020-04-06 15:42:42 +12:00
package broadcast
import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
2020-04-06 15:42:42 +12:00
"n.eko.moe/neko/internal/gst"
"n.eko.moe/neko/internal/types/config"
)
type BroadcastManager struct {
logger zerolog.Logger
pipeline *gst.Pipeline
config *config.Broadcast
}
func New(config *config.Broadcast) *BroadcastManager {
return &BroadcastManager{
logger: log.With().Str("module", "remote").Logger(),
config: config,
2020-04-06 15:42:42 +12:00
}
}
func (manager *BroadcastManager) Start() {
var err error
manager.pipeline, err = gst.CreateRTMPPipeline(
manager.config.Device,
manager.config.Display,
manager.config.RTMP,
)
if err != nil {
manager.logger.Panic().Err(err).Msg("unable to create rtmp pipeline")
}
2020-04-06 15:42:42 +12:00
manager.pipeline.Start()
2020-04-06 15:42:42 +12:00
}
func (manager *BroadcastManager) Shutdown() error {
if manager.pipeline != nil {
manager.pipeline.Stop()
}
return nil
2020-04-06 15:42:42 +12:00
}