name confusion Enabled -> Started.

This commit is contained in:
Miroslav Šedivý 2021-02-05 14:03:53 +01:00
parent 18b6fa0a03
commit 36b7eca43c
6 changed files with 25 additions and 25 deletions

View File

@ -16,7 +16,7 @@ type BroadcastStatusPayload struct {
func (h *RoomHandler) broadcastStatus(w http.ResponseWriter, r *http.Request) { func (h *RoomHandler) broadcastStatus(w http.ResponseWriter, r *http.Request) {
broadcast := h.capture.Broadcast() broadcast := h.capture.Broadcast()
utils.HttpSuccess(w, BroadcastStatusPayload{ utils.HttpSuccess(w, BroadcastStatusPayload{
IsActive: broadcast.Enabled(), IsActive: broadcast.Started(),
URL: broadcast.Url(), URL: broadcast.Url(),
}) })
} }
@ -33,7 +33,7 @@ func (h *RoomHandler) boradcastStart(w http.ResponseWriter, r *http.Request) {
} }
broadcast := h.capture.Broadcast() broadcast := h.capture.Broadcast()
if broadcast.Enabled() { if broadcast.Started() {
utils.HttpUnprocessableEntity(w, "Server is already broadcasting.") utils.HttpUnprocessableEntity(w, "Server is already broadcasting.")
return return
} }
@ -46,7 +46,7 @@ func (h *RoomHandler) boradcastStart(w http.ResponseWriter, r *http.Request) {
h.sessions.AdminBroadcast( h.sessions.AdminBroadcast(
message.BroadcastStatus{ message.BroadcastStatus{
Event: event.BORADCAST_STATUS, Event: event.BORADCAST_STATUS,
IsActive: broadcast.Enabled(), IsActive: broadcast.Started(),
URL: broadcast.Url(), URL: broadcast.Url(),
}, nil) }, 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) { func (h *RoomHandler) boradcastStop(w http.ResponseWriter, r *http.Request) {
broadcast := h.capture.Broadcast() broadcast := h.capture.Broadcast()
if !broadcast.Enabled() { if !broadcast.Started() {
utils.HttpUnprocessableEntity(w, "Server is not broadcasting.") utils.HttpUnprocessableEntity(w, "Server is not broadcasting.")
return return
} }
@ -65,7 +65,7 @@ func (h *RoomHandler) boradcastStop(w http.ResponseWriter, r *http.Request) {
h.sessions.AdminBroadcast( h.sessions.AdminBroadcast(
message.BroadcastStatus{ message.BroadcastStatus{
Event: event.BORADCAST_STATUS, Event: event.BORADCAST_STATUS,
IsActive: broadcast.Enabled(), IsActive: broadcast.Started(),
URL: broadcast.Url(), URL: broadcast.Url(),
}, nil) }, nil)

View File

@ -16,7 +16,7 @@ type BroacastManagerCtx struct {
mu sync.Mutex mu sync.Mutex
pipelineStr string pipelineStr string
pipeline *gst.Pipeline pipeline *gst.Pipeline
enabled bool started bool
url string url string
} }
@ -24,7 +24,7 @@ func broadcastNew(pipelineStr string) *BroacastManagerCtx {
return &BroacastManagerCtx{ return &BroacastManagerCtx{
logger: log.With().Str("module", "capture").Str("submodule", "broadcast").Logger(), logger: log.With().Str("module", "capture").Str("submodule", "broadcast").Logger(),
pipelineStr: pipelineStr, pipelineStr: pipelineStr,
enabled: false, started: false,
url: "", url: "",
} }
} }
@ -45,7 +45,7 @@ func (manager *BroacastManagerCtx) Start(url string) error {
} }
manager.url = url manager.url = url
manager.enabled = true manager.started = true
return nil return nil
} }
@ -53,12 +53,12 @@ func (manager *BroacastManagerCtx) Stop() {
manager.mu.Lock() manager.mu.Lock()
defer manager.mu.Unlock() defer manager.mu.Unlock()
manager.enabled = false manager.started = false
manager.destroyPipeline() manager.destroyPipeline()
} }
func (manager *BroacastManagerCtx) Enabled() bool { func (manager *BroacastManagerCtx) Started() bool {
return manager.enabled return manager.started
} }
func (manager *BroacastManagerCtx) Url() string { func (manager *BroacastManagerCtx) Url() string {

View File

@ -70,18 +70,18 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt
} }
func (manager *CaptureManagerCtx) Start() { func (manager *CaptureManagerCtx) Start() {
if manager.broadcast.Enabled() { if manager.broadcast.Started() {
if err := manager.broadcast.createPipeline(); err != nil { if err := manager.broadcast.createPipeline(); err != nil {
manager.logger.Panic().Err(err).Msg("unable to create broadcast pipeline") manager.logger.Panic().Err(err).Msg("unable to create broadcast pipeline")
} }
} }
manager.desktop.OnBeforeScreenSizeChange(func() { manager.desktop.OnBeforeScreenSizeChange(func() {
if manager.video.Enabled() { if manager.video.Started() {
manager.video.destroyPipeline() manager.video.destroyPipeline()
} }
if manager.broadcast.Enabled() { if manager.broadcast.Started() {
manager.broadcast.destroyPipeline() manager.broadcast.destroyPipeline()
} }
@ -91,13 +91,13 @@ func (manager *CaptureManagerCtx) Start() {
}) })
manager.desktop.OnAfterScreenSizeChange(func() { manager.desktop.OnAfterScreenSizeChange(func() {
if manager.video.Enabled() { if manager.video.Started() {
if err := manager.video.createPipeline(); err != nil { if err := manager.video.createPipeline(); err != nil {
manager.logger.Panic().Err(err).Msg("unable to recreate video pipeline") 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 { if err := manager.broadcast.createPipeline(); err != nil {
manager.logger.Panic().Err(err).Msg("unable to recreate broadcast pipeline") manager.logger.Panic().Err(err).Msg("unable to recreate broadcast pipeline")
} }

View File

@ -23,7 +23,7 @@ type StreamManagerCtx struct {
emmiter events.EventEmmiter emmiter events.EventEmmiter
emitUpdate chan bool emitUpdate chan bool
emitStop chan bool emitStop chan bool
enabled bool started bool
} }
func streamNew(codec codec.RTPCodec, pipelineStr string) *StreamManagerCtx { func streamNew(codec codec.RTPCodec, pipelineStr string) *StreamManagerCtx {
@ -34,7 +34,7 @@ func streamNew(codec codec.RTPCodec, pipelineStr string) *StreamManagerCtx {
emmiter: events.New(), emmiter: events.New(),
emitUpdate: make(chan bool), emitUpdate: make(chan bool),
emitStop: make(chan bool), emitStop: make(chan bool),
enabled: false, started: false,
} }
go func() { go func() {
@ -82,7 +82,7 @@ func (manager *StreamManagerCtx) Start() error {
return err return err
} }
manager.enabled = true manager.started = true
return nil return nil
} }
@ -90,12 +90,12 @@ func (manager *StreamManagerCtx) Stop() {
manager.mu.Lock() manager.mu.Lock()
defer manager.mu.Unlock() defer manager.mu.Unlock()
manager.enabled = false manager.started = false
manager.destroyPipeline() manager.destroyPipeline()
} }
func (manager *StreamManagerCtx) Enabled() bool { func (manager *StreamManagerCtx) Started() bool {
return manager.enabled return manager.started
} }
func (manager *StreamManagerCtx) createPipeline() error { func (manager *StreamManagerCtx) createPipeline() error {

View File

@ -11,7 +11,7 @@ type Sample media.Sample
type BroadcastManager interface { type BroadcastManager interface {
Start(url string) error Start(url string) error
Stop() Stop()
Enabled() bool Started() bool
Url() string Url() string
} }
@ -27,7 +27,7 @@ type StreamManager interface {
Start() error Start() error
Stop() Stop()
Enabled() bool Started() bool
} }
type CaptureManager interface { type CaptureManager interface {

View File

@ -81,7 +81,7 @@ func (h *MessageHandlerCtx) systemAdmin(session types.Session) error {
Event: event.SYSTEM_ADMIN, Event: event.SYSTEM_ADMIN,
ScreenSizesList: screenSizesList, ScreenSizesList: screenSizesList,
BroadcastStatus: message.BroadcastStatus{ BroadcastStatus: message.BroadcastStatus{
IsActive: broadcast.Enabled(), IsActive: broadcast.Started(),
URL: broadcast.Url(), URL: broadcast.Url(),
}, },
}) })