feat: source timer
This commit is contained in:
parent
7c34e374ce
commit
8b65a3573c
@ -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()
|
||||
|
||||
|
@ -31,6 +31,7 @@ type BuildInfo struct {
|
||||
type Source struct {
|
||||
Container Container
|
||||
Live bool
|
||||
LiveChangedAt time.Time
|
||||
Listeners int
|
||||
Tracks []string
|
||||
RTMPURL string
|
||||
|
@ -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()
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user