diff --git a/app/app.go b/app/app.go index 4b7a909..3fdfda8 100644 --- a/app/app.go +++ b/app/app.go @@ -75,7 +75,7 @@ func Run(ctx context.Context, params RunParams) error { }) defer mp.Close() - const uiUpdateInterval = 2 * time.Second + const uiUpdateInterval = time.Second uiUpdateT := time.NewTicker(uiUpdateInterval) defer uiUpdateT.Stop() diff --git a/domain/types.go b/domain/types.go index ee0fec1..32c2938 100644 --- a/domain/types.go +++ b/domain/types.go @@ -31,6 +31,7 @@ type BuildInfo struct { type Source struct { Container Container Live bool + LiveChangedAt time.Time Listeners int Tracks []string RTMPURL string diff --git a/mediaserver/actor.go b/mediaserver/actor.go index 06598e4..76c6b52 100644 --- a/mediaserver/actor.go +++ b/mediaserver/actor.go @@ -204,6 +204,7 @@ func (s *Actor) actorLoop(containerStateC <-chan domain.Container, errC <-chan e } if ingressState.ready != s.state.Live || ingressState.listeners != s.state.Listeners { s.state.Live = ingressState.ready + s.state.LiveChangedAt = time.Now() s.state.Listeners = ingressState.listeners resetFetchTracksT(time.Second) sendState() diff --git a/mediaserver/integration_test.go b/mediaserver/integration_test.go index 93ad4e4..f560556 100644 --- a/mediaserver/integration_test.go +++ b/mediaserver/integration_test.go @@ -60,7 +60,9 @@ func TestIntegrationMediaServerStartStop(t *testing.T) { t, func() bool { currState := mediaServer.State() - return currState.Live && currState.Container.HealthState == "healthy" + return currState.Live && + !currState.LiveChangedAt.IsZero() && + currState.Container.HealthState == "healthy" }, time.Second*5, time.Second, diff --git a/terminal/terminal.go b/terminal/terminal.go index 1933c00..dd7cfd9 100644 --- a/terminal/terminal.go +++ b/terminal/terminal.go @@ -7,6 +7,7 @@ import ( "log/slog" "strconv" "strings" + "time" "git.netflux.io/rob/octoplex/domain" "github.com/gdamore/tcell/v2" @@ -319,7 +320,12 @@ func (ui *UI) redrawFromState(state domain.AppState) { ui.sourceViews.tracks.SetText(tracks) if state.Source.Live { - ui.sourceViews.status.SetText("[black:green]receiving") + var durStr string + if !state.Source.LiveChangedAt.IsZero() { + durStr = fmt.Sprintf(" (%s)", time.Since(state.Source.LiveChangedAt).Round(time.Second)) + } + + ui.sourceViews.status.SetText("[black:green]receiving" + durStr) } else if state.Source.Container.State == "running" && state.Source.Container.HealthState == "healthy" { ui.sourceViews.status.SetText("[black:yellow]ready") } else {