DreamineVMS 1.0.0.0
Windows PC의 RTSP·USB 카메라 영상을 HLS로 변환해 원격 CCTV Viewer에 전달하는 데스크톱 에이전트입니다.
로딩중...
검색중...
일치하는것 없음
CameraRuntimeStateService.cs
이 파일의 문서화 페이지로 가기
2using System.Collections.Concurrent;
3
5
15{
24 private readonly ConcurrentDictionary<string, CameraRuntimeState> _states = new();
25
34 public event EventHandler<CameraRuntimeState>? StateChanged;
35
60 public CameraRuntimeState GetState(string cameraId)
61 {
62 return _states.GetOrAdd(cameraId, id => new CameraRuntimeState { CameraId = id });
63 }
64
81 public IReadOnlyList<CameraRuntimeState> GetAll()
82 {
83 return _states.Values.OrderBy(state => state.CameraId).ToArray();
84 }
85
126 public void SetState(string cameraId, CameraConnectionState state, string message, string? error = null)
127 {
128 CameraRuntimeState runtimeState = GetState(cameraId);
129
130 // Connecting은 새 HLS 출력 세션의 시작으로 봅니다.
131 // StopAll → StartAll 후 playlist URL이 같아도 Blazor/hls.js가 새 세션을 구분할 수 있게
132 // RestartCount를 세션 버전으로 함께 사용합니다.
133 if (state == CameraConnectionState.Connecting && runtimeState.State != CameraConnectionState.Connecting)
134 {
135 runtimeState.RestartCount++;
136 }
137
138 runtimeState.State = state;
139 runtimeState.LastMessage = message;
140 runtimeState.LastError = error;
141 runtimeState.LastUpdated = DateTimeOffset.Now;
142 StateChanged?.Invoke(this, runtimeState);
143 }
144
169 public void IncrementRestart(string cameraId, string message)
170 {
171 CameraRuntimeState runtimeState = GetState(cameraId);
172 runtimeState.RestartCount++;
173 runtimeState.LastMessage = message;
174 runtimeState.LastUpdated = DateTimeOffset.Now;
175 StateChanged?.Invoke(this, runtimeState);
176 }
177}
readonly ConcurrentDictionary< string, CameraRuntimeState > _states
void SetState(string cameraId, CameraConnectionState state, string message, string? error=null)