[SEN] 修复实时监看按需拉流循环等待 (#54) #55

Open
ila wants to merge 34 commits from agent/codex/54-sense-liveview-on-demand into agent/codex/51-sense-auto-liveview
Showing only changes of commit e2c2a8686f - Show all commits
+34
View File
@@ -125,6 +125,40 @@ func (s *Service) Reconcile(ctx context.Context, actor identity.Principal, id st
identity.RecordAudit(ctx, actor.UserID, "media.reconcile", id, "success", map[string]any{"actual": route.Actual})
return route, nil
}
// Refresh reads the MediaMTX runtime state without reapplying configuration or
// exposing the source URI. It is safe to call while a playback session polls.
func (s *Service) Refresh(ctx context.Context, id string) (Route, error) {
route, err := s.store.Get(ctx, id)
if err != nil {
return Route{}, err
}
if route.Desired != "running" {
return route, nil
}
status, err := s.controller.Status(ctx, route.Path)
if err != nil {
return route, nil
}
actual := "waiting"
detail := "等待播放器连接并按需拉流"
if status.Ready {
actual = "ready"
detail = "上游拉流正常"
}
if route.Actual == actual && route.Detail == detail && route.Readers == status.Readers {
return route, nil
}
route.Actual = actual
route.Detail = detail
route.Readers = status.Readers
route.Version++
route.UpdatedAt = s.now().UTC()
if err := s.store.Save(ctx, route); err != nil {
return Route{}, err
}
return route, nil
}
func (s *Service) Stop(ctx context.Context, actor identity.Principal, id string) (Route, error) {
route, err := s.store.Get(ctx, id)
if err != nil {