mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
63 lines
1.4 KiB
Go
63 lines
1.4 KiB
Go
package capture
|
|
|
|
import (
|
|
"demodesk/neko/internal/capture/gst"
|
|
)
|
|
|
|
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
|
|
|
|
if manager.broadcast != nil || !manager.BroadcastEnabled() {
|
|
return
|
|
}
|
|
|
|
manager.logger.Info().
|
|
Str("audio_device", manager.config.Device).
|
|
Str("video_display", manager.config.Display).
|
|
Str("broadcast_pipeline", manager.config.BroadcastPipeline).
|
|
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) destroyBroadcastPipeline() {
|
|
if manager.broadcast == nil {
|
|
return
|
|
}
|
|
|
|
manager.broadcast.Stop()
|
|
manager.logger.Info().Msgf("stopping broadcast pipeline")
|
|
manager.broadcast = nil
|
|
}
|