Archived
2
0
This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
neko-custom/server/internal/broadcast/manager.go
2020-04-06 03:42:42 +00:00

41 lines
831 B
Go

package broadcast
import (
"github.com/rs/zerolog"
"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
}
}
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")
}
manager.pipeline.Start()
}
func (manager *BroadcastManager) Shutdown() error {
if (manager.pipeline != nil) {
manager.pipeline.Stop()
}
}