edit broadcast.

This commit is contained in:
Miroslav Šedivý 2020-11-01 17:34:47 +01:00
parent 507fce7862
commit 7fb977faa4
4 changed files with 12 additions and 8 deletions

View File

@ -7,14 +7,14 @@ import (
func (manager *CaptureManagerCtx) StartBroadcastPipeline() {
var err error
if manager.IsBoradcasting() || manager.broadcast_url == "" {
if manager.broadcast != nil || !manager.BroadcastEnabled() {
return
}
manager.logger.Info().
Str("audio_device", manager.config.Device).
Str("video_display", manager.config.Display).
Str("rtmp_pipeline_src", manager.broadcast.Src).
Str("broadcast_pipeline", manager.config.BroadcastPipeline).
Msgf("Creating broadcast pipeline...")
manager.broadcast, err = gst.CreateRTMPPipeline(
@ -33,26 +33,28 @@ func (manager *CaptureManagerCtx) StartBroadcastPipeline() {
}
func (manager *CaptureManagerCtx) StopBroadcastPipeline() {
if !manager.IsBoradcasting() {
if manager.broadcast == nil {
return
}
manager.broadcast.DestroyPipeline()
manager.logger.Info().Msgf("Stopping broadcast pipeline...")
manager.broadcast = nil
}
func (manager *CaptureManagerCtx) StartBroadcast(url string) {
manager.broadcast_url = url
manager.broadcasting = true
manager.StartBroadcastPipeline()
}
func (manager *CaptureManagerCtx) StopBroadcast() {
manager.broadcast_url = ""
manager.broadcasting = false
manager.StopBroadcastPipeline()
}
func (manager *CaptureManagerCtx) IsBoradcasting() bool {
return manager.broadcast != nil
func (manager *CaptureManagerCtx) BroadcastEnabled() bool {
return manager.broadcasting
}
func (manager *CaptureManagerCtx) BroadcastUrl() string {

View File

@ -21,6 +21,7 @@ type CaptureManagerCtx struct {
shutdown chan bool
emmiter events.EventEmmiter
streaming bool
broadcasting bool
broadcast_url string
desktop types.DesktopManager
}
@ -32,6 +33,7 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt
emmiter: events.New(),
config: config,
streaming: false,
broadcasting: false,
broadcast_url: "",
desktop: desktop,
}

View File

@ -24,6 +24,6 @@ type CaptureManager interface {
// broacast
StartBroadcast(url string)
StopBroadcast()
IsBoradcasting() bool
BroadcastEnabled() bool
BroadcastUrl() string
}

View File

@ -45,7 +45,7 @@ func (h *MessageHandlerCtx) boradcastStatus(session types.Session) error {
if err := session.Send(
message.BroadcastStatus{
Event: event.BORADCAST_STATUS,
IsActive: h.capture.IsBoradcasting(),
IsActive: h.capture.BroadcastEnabled(),
URL: h.capture.BroadcastUrl(),
}); err != nil {
h.logger.Warn().Err(err).Msgf("sending event %s has failed", event.BORADCAST_STATUS)