diff --git a/internal/api/room/broadcast.go b/internal/api/room/broadcast.go index 21a14b90..a8f7e84c 100644 --- a/internal/api/room/broadcast.go +++ b/internal/api/room/broadcast.go @@ -16,7 +16,7 @@ type BroadcastStatusPayload struct { func (h *RoomHandler) broadcastStatus(w http.ResponseWriter, r *http.Request) { broadcast := h.capture.Broadcast() utils.HttpSuccess(w, BroadcastStatusPayload{ - IsActive: broadcast.Enabled(), + IsActive: broadcast.Started(), URL: broadcast.Url(), }) } @@ -33,7 +33,7 @@ func (h *RoomHandler) boradcastStart(w http.ResponseWriter, r *http.Request) { } broadcast := h.capture.Broadcast() - if broadcast.Enabled() { + if broadcast.Started() { utils.HttpUnprocessableEntity(w, "Server is already broadcasting.") return } @@ -46,7 +46,7 @@ func (h *RoomHandler) boradcastStart(w http.ResponseWriter, r *http.Request) { h.sessions.AdminBroadcast( message.BroadcastStatus{ Event: event.BORADCAST_STATUS, - IsActive: broadcast.Enabled(), + IsActive: broadcast.Started(), URL: broadcast.Url(), }, nil) @@ -55,7 +55,7 @@ func (h *RoomHandler) boradcastStart(w http.ResponseWriter, r *http.Request) { func (h *RoomHandler) boradcastStop(w http.ResponseWriter, r *http.Request) { broadcast := h.capture.Broadcast() - if !broadcast.Enabled() { + if !broadcast.Started() { utils.HttpUnprocessableEntity(w, "Server is not broadcasting.") return } @@ -65,7 +65,7 @@ func (h *RoomHandler) boradcastStop(w http.ResponseWriter, r *http.Request) { h.sessions.AdminBroadcast( message.BroadcastStatus{ Event: event.BORADCAST_STATUS, - IsActive: broadcast.Enabled(), + IsActive: broadcast.Started(), URL: broadcast.Url(), }, nil) diff --git a/internal/capture/broadcast.go b/internal/capture/broadcast.go index e28ac174..7bcce951 100644 --- a/internal/capture/broadcast.go +++ b/internal/capture/broadcast.go @@ -16,7 +16,7 @@ type BroacastManagerCtx struct { mu sync.Mutex pipelineStr string pipeline *gst.Pipeline - enabled bool + started bool url string } @@ -24,7 +24,7 @@ func broadcastNew(pipelineStr string) *BroacastManagerCtx { return &BroacastManagerCtx{ logger: log.With().Str("module", "capture").Str("submodule", "broadcast").Logger(), pipelineStr: pipelineStr, - enabled: false, + started: false, url: "", } } @@ -45,7 +45,7 @@ func (manager *BroacastManagerCtx) Start(url string) error { } manager.url = url - manager.enabled = true + manager.started = true return nil } @@ -53,12 +53,12 @@ func (manager *BroacastManagerCtx) Stop() { manager.mu.Lock() defer manager.mu.Unlock() - manager.enabled = false + manager.started = false manager.destroyPipeline() } -func (manager *BroacastManagerCtx) Enabled() bool { - return manager.enabled +func (manager *BroacastManagerCtx) Started() bool { + return manager.started } func (manager *BroacastManagerCtx) Url() string { diff --git a/internal/capture/manager.go b/internal/capture/manager.go index a75434af..f551c641 100644 --- a/internal/capture/manager.go +++ b/internal/capture/manager.go @@ -70,18 +70,18 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt } func (manager *CaptureManagerCtx) Start() { - if manager.broadcast.Enabled() { + if manager.broadcast.Started() { if err := manager.broadcast.createPipeline(); err != nil { manager.logger.Panic().Err(err).Msg("unable to create broadcast pipeline") } } manager.desktop.OnBeforeScreenSizeChange(func() { - if manager.video.Enabled() { + if manager.video.Started() { manager.video.destroyPipeline() } - if manager.broadcast.Enabled() { + if manager.broadcast.Started() { manager.broadcast.destroyPipeline() } @@ -91,13 +91,13 @@ func (manager *CaptureManagerCtx) Start() { }) manager.desktop.OnAfterScreenSizeChange(func() { - if manager.video.Enabled() { + if manager.video.Started() { if err := manager.video.createPipeline(); err != nil { manager.logger.Panic().Err(err).Msg("unable to recreate video pipeline") } } - if manager.broadcast.Enabled() { + if manager.broadcast.Started() { if err := manager.broadcast.createPipeline(); err != nil { manager.logger.Panic().Err(err).Msg("unable to recreate broadcast pipeline") } diff --git a/internal/capture/stream.go b/internal/capture/stream.go index 5c7df80e..1a34cbc7 100644 --- a/internal/capture/stream.go +++ b/internal/capture/stream.go @@ -23,7 +23,7 @@ type StreamManagerCtx struct { emmiter events.EventEmmiter emitUpdate chan bool emitStop chan bool - enabled bool + started bool } func streamNew(codec codec.RTPCodec, pipelineStr string) *StreamManagerCtx { @@ -34,7 +34,7 @@ func streamNew(codec codec.RTPCodec, pipelineStr string) *StreamManagerCtx { emmiter: events.New(), emitUpdate: make(chan bool), emitStop: make(chan bool), - enabled: false, + started: false, } go func() { @@ -82,7 +82,7 @@ func (manager *StreamManagerCtx) Start() error { return err } - manager.enabled = true + manager.started = true return nil } @@ -90,12 +90,12 @@ func (manager *StreamManagerCtx) Stop() { manager.mu.Lock() defer manager.mu.Unlock() - manager.enabled = false + manager.started = false manager.destroyPipeline() } -func (manager *StreamManagerCtx) Enabled() bool { - return manager.enabled +func (manager *StreamManagerCtx) Started() bool { + return manager.started } func (manager *StreamManagerCtx) createPipeline() error { diff --git a/internal/types/capture.go b/internal/types/capture.go index 9a979e5e..7cde4ed4 100644 --- a/internal/types/capture.go +++ b/internal/types/capture.go @@ -11,7 +11,7 @@ type Sample media.Sample type BroadcastManager interface { Start(url string) error Stop() - Enabled() bool + Started() bool Url() string } @@ -27,7 +27,7 @@ type StreamManager interface { Start() error Stop() - Enabled() bool + Started() bool } type CaptureManager interface { diff --git a/internal/websocket/handler/system.go b/internal/websocket/handler/system.go index ae82707c..fe1ea104 100644 --- a/internal/websocket/handler/system.go +++ b/internal/websocket/handler/system.go @@ -81,7 +81,7 @@ func (h *MessageHandlerCtx) systemAdmin(session types.Session) error { Event: event.SYSTEM_ADMIN, ScreenSizesList: screenSizesList, BroadcastStatus: message.BroadcastStatus{ - IsActive: broadcast.Enabled(), + IsActive: broadcast.Started(), URL: broadcast.Url(), }, })