DreamineVMS 1.0.0.0
Windows PC의 RTSP·USB 카메라 영상을 HLS로 변환해 원격 CCTV Viewer에 전달하는 데스크톱 에이전트입니다.
로딩중...
검색중...
일치하는것 없음
DreamineVMS.Blazor.ViewModels.LivePageViewModel 클래스 참조sealed

더 자세히 ...

DreamineVMS.Blazor.ViewModels.LivePageViewModel에 대한 상속 다이어그램 :
DreamineVMS.Blazor.ViewModels.LivePageViewModel에 대한 협력 다이어그램:

Public 멤버 함수

 LivePageViewModel (IVmsCameraRepository repository, ICameraRuntimeStateService runtimeState, IJSRuntime jsRuntime)
void Initialize ()
async Task OnAfterRenderAsync (bool firstRender)
async Task SynchronizePlayersAsync ()
async ValueTask DisposeAsync ()

정적 Public 멤버 함수

static string GetPlayerId (CameraDevice camera)

속성

IReadOnlyList< CameraDeviceCameras = Array.Empty<CameraDevice>() [get, private set]

이벤트

EventHandler? PlayersNeedSync

Private 멤버 함수

async Task EnsurePlayerAsync (CameraDevice camera)
async Task DestroyPlayerAsync (CameraDevice camera, string? reason)
void OnRuntimeStateChanged (object? sender, CameraRuntimeState state)

정적 Private 멤버 함수

static string BuildVersionedHlsUrl (CameraDevice camera, CameraRuntimeState state)

Private 속성

readonly IVmsCameraRepository _repository
readonly ICameraRuntimeStateService _runtimeState
readonly IJSRuntime _jsRuntime
readonly object _gate = new()
bool _isInitialized
bool _isDisposed

상세한 설명

Live Blazor 페이지의 ViewModel입니다.

FFmpeg HLS 스트림의 시작/재시작은 BackgroundService가 담당합니다. 이 ViewModel은 RuntimeState와 video element를 동기화합니다. StopAll → StartAll 사이클에서 기존 hls.js 인스턴스를 제거하고, 다시 Connected/Connecting 상태가 되면 안전하게 재연결합니다.

LivePageViewModel.cs 파일의 24 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ LivePageViewModel()

DreamineVMS.Blazor.ViewModels.LivePageViewModel.LivePageViewModel ( IVmsCameraRepository repository,
ICameraRuntimeStateService runtimeState,
IJSRuntime jsRuntime )
inline

LivePageViewModel 클래스의 새 인스턴스를 초기화합니다.

매개변수
repository카메라 Repository입니다.
runtimeState카메라 런타임 상태 서비스입니다.
jsRuntimeBlazor JSRuntime입니다.
예외
ArgumentNullException필수 입력 인자 중 하나가 null인 경우 발생합니다.

LivePageViewModel.cs 파일의 121 번째 라인에서 정의되었습니다.

125 {
126 _repository = repository ?? throw new ArgumentNullException(nameof(repository));
127 _runtimeState = runtimeState ?? throw new ArgumentNullException(nameof(runtimeState));
128 _jsRuntime = jsRuntime ?? throw new ArgumentNullException(nameof(jsRuntime));
129 }

다음을 참조함 : _jsRuntime, _repository, _runtimeState.

멤버 함수 문서화

◆ BuildVersionedHlsUrl()

string DreamineVMS.Blazor.ViewModels.LivePageViewModel.BuildVersionedHlsUrl ( CameraDevice camera,
CameraRuntimeState state )
inlinestaticprivate

Versioned Hls Url 값을 구성합니다.

매개변수
cameracamera에 사용할 CameraDevice 값입니다.
statestate에 사용할 CameraRuntimeState 값입니다.
반환값
Build Versioned Hls Url 작업에서 생성한 string 결과입니다.

LivePageViewModel.cs 파일의 353 번째 라인에서 정의되었습니다.

354 {
355 ArgumentNullException.ThrowIfNull(camera);
356 ArgumentNullException.ThrowIfNull(state);
357
358 string separator = camera.HlsUrl.Contains('?', StringComparison.Ordinal) ? "&" : "?";
359 return $"{camera.HlsUrl}{separator}session={state.RestartCount}";
360 }

다음을 참조함 : DreamineVMS.Models.CameraDevice.HlsUrl.

다음에 의해서 참조됨 : EnsurePlayerAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ DestroyPlayerAsync()

async Task DreamineVMS.Blazor.ViewModels.LivePageViewModel.DestroyPlayerAsync ( CameraDevice camera,
string? reason )
inlineprivate

Destroy Player Async 작업을 수행합니다.

매개변수
cameracamera에 사용할 CameraDevice 값입니다.
reasonreason에 사용할 string? 값입니다.
반환값
Destroy Player Async 작업에서 생성한 Task 결과입니다.

LivePageViewModel.cs 파일의 440 번째 라인에서 정의되었습니다.

441 {
442 try
443 {
444 await _jsRuntime.InvokeVoidAsync(
445 "dreamineVmsHls.destroy",
446 GetPlayerId(camera),
447 string.IsNullOrWhiteSpace(reason) ? "Stream stopped." : reason);
448 }
449 catch (JSDisconnectedException)
450 {
451 // Circuit이 끊긴 상태는 무시합니다.
452 }
453 catch
454 {
455 // 화면 종료 중 JS 런타임이 이미 끊긴 경우는 무시합니다.
456 }
457 }

다음을 참조함 : _jsRuntime, GetPlayerId().

다음에 의해서 참조됨 : DisposeAsync(), SynchronizePlayersAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ DisposeAsync()

async ValueTask DreamineVMS.Blazor.ViewModels.LivePageViewModel.DisposeAsync ( )
inline

이 인스턴스가 소유한 리소스를 해제합니다.

반환값
Dispose Async 작업에서 생성한 ValueTask 결과입니다.

LivePageViewModel.cs 파일의 296 번째 라인에서 정의되었습니다.

297 {
298 lock (_gate)
299 {
300 if (_isDisposed)
301 {
302 return;
303 }
304
305 _isDisposed = true;
306
307 if (_isInitialized)
308 {
309 _runtimeState.StateChanged -= OnRuntimeStateChanged;
310 _isInitialized = false;
311 }
312 }
313
314 foreach (CameraDevice camera in Cameras)
315 {
316 await DestroyPlayerAsync(camera, "Live view disposed.");
317 }
318 }

다음을 참조함 : _gate, _isDisposed, _isInitialized, Cameras, DestroyPlayerAsync(), OnRuntimeStateChanged().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ EnsurePlayerAsync()

async Task DreamineVMS.Blazor.ViewModels.LivePageViewModel.EnsurePlayerAsync ( CameraDevice camera)
inlineprivate

Ensure Player Async 작업을 수행합니다.

매개변수
cameracamera에 사용할 CameraDevice 값입니다.
반환값
Ensure Player Async 작업에서 생성한 Task 결과입니다.

LivePageViewModel.cs 파일의 386 번째 라인에서 정의되었습니다.

387 {
388 try
389 {
390 CameraRuntimeState state = _runtimeState.GetState(camera.Id);
391 string source = BuildVersionedHlsUrl(camera, state);
392
393 await _jsRuntime.InvokeVoidAsync(
394 "dreamineVmsHls.init",
395 GetPlayerId(camera),
396 source);
397 }
398 catch (JSDisconnectedException)
399 {
400 // Circuit이 끊긴 상태는 무시합니다.
401 }
402 catch (Exception ex)
403 {
404 System.Diagnostics.Debug.WriteLine($"[LivePageViewModel] player init failed: {camera.Id}: {ex}");
405 }
406 }

다음을 참조함 : _jsRuntime, _runtimeState, BuildVersionedHlsUrl(), GetPlayerId(), DreamineVMS.Models.CameraDevice.Id.

다음에 의해서 참조됨 : SynchronizePlayersAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GetPlayerId()

string DreamineVMS.Blazor.ViewModels.LivePageViewModel.GetPlayerId ( CameraDevice camera)
inlinestatic

Live 화면에서 사용하는 video element ID를 반환합니다.

매개변수
camera카메라 정보입니다.
반환값
HTML video element ID입니다.

LivePageViewModel.cs 파일의 274 번째 라인에서 정의되었습니다.

275 {
276 ArgumentNullException.ThrowIfNull(camera);
277 return $"video-{camera.Id}";
278 }

다음에 의해서 참조됨 : DestroyPlayerAsync(), EnsurePlayerAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ Initialize()

void DreamineVMS.Blazor.ViewModels.LivePageViewModel.Initialize ( )
inline

Live 화면 진입 시 카메라 목록을 로드하고 RuntimeState 변경을 구독합니다.

LivePageViewModel.cs 파일의 159 번째 라인에서 정의되었습니다.

160 {
161 lock (_gate)
162 {
163 if (_isInitialized || _isDisposed)
164 {
165 return;
166 }
167
168 Cameras = _repository.GetAll()
169 .Where(camera => camera.Enabled)
170 .OrderBy(camera => camera.DisplayOrder)
171 .Take(5)
172 .ToArray();
173
174 _runtimeState.StateChanged += OnRuntimeStateChanged;
175 _isInitialized = true;
176 }
177 }

다음을 참조함 : _gate, _isDisposed, _isInitialized, _repository, Cameras, OnRuntimeStateChanged().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ OnAfterRenderAsync()

async Task DreamineVMS.Blazor.ViewModels.LivePageViewModel.OnAfterRenderAsync ( bool firstRender)
inline

Video DOM이 생성된 뒤 player 상태를 RuntimeState와 동기화합니다.

매개변수
firstRender첫 렌더링 여부입니다.
반환값
비동기 작업입니다.

LivePageViewModel.cs 파일의 203 번째 라인에서 정의되었습니다.

204 {
205 if (!firstRender)
206 {
207 return;
208 }
209
210 await SynchronizePlayersAsync();
211 }

다음을 참조함 : SynchronizePlayersAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ OnRuntimeStateChanged()

void DreamineVMS.Blazor.ViewModels.LivePageViewModel.OnRuntimeStateChanged ( object? sender,
CameraRuntimeState state )
inlineprivate

Runtime State Changed 이벤트 또는 상태 변경을 처리합니다.

매개변수
sender이벤트를 발생시킨 객체입니다.
statestate에 사용할 CameraRuntimeState 값입니다.

LivePageViewModel.cs 파일의 483 번째 라인에서 정의되었습니다.

484 {
485 if (Cameras.All(c => c.Id != state.CameraId))
486 {
487 return;
488 }
489
490 if (_isDisposed)
491 {
492 return;
493 }
494
495 PlayersNeedSync?.Invoke(this, EventArgs.Empty);
496 }

다음을 참조함 : _isDisposed, DreamineVMS.Models.CameraRuntimeState.CameraId, Cameras, PlayersNeedSync.

다음에 의해서 참조됨 : DisposeAsync(), Initialize().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ SynchronizePlayersAsync()

async Task DreamineVMS.Blazor.ViewModels.LivePageViewModel.SynchronizePlayersAsync ( )
inline

현재 RuntimeState에 맞춰 hls.js player를 생성 또는 제거합니다.

반환값
비동기 작업입니다.

LivePageViewModel.cs 파일의 229 번째 라인에서 정의되었습니다.

230 {
231 if (_isDisposed)
232 {
233 return;
234 }
235
236 foreach (CameraDevice camera in Cameras)
237 {
238 CameraRuntimeState state = _runtimeState.GetState(camera.Id);
239
240 if (state.State is CameraConnectionState.Connected or CameraConnectionState.Connecting)
241 {
242 await EnsurePlayerAsync(camera);
243 continue;
244 }
245
246 await DestroyPlayerAsync(camera, state.LastMessage);
247 }
248 }

다음을 참조함 : _isDisposed, _runtimeState, Cameras, DestroyPlayerAsync(), EnsurePlayerAsync(), DreamineVMS.Models.CameraDevice.Id, DreamineVMS.Models.CameraRuntimeState.LastMessage, DreamineVMS.Models.CameraRuntimeState.State.

다음에 의해서 참조됨 : OnAfterRenderAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ _gate

readonly object DreamineVMS.Blazor.ViewModels.LivePageViewModel._gate = new()
private

gate 값을 보관합니다.

LivePageViewModel.cs 파일의 61 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DisposeAsync(), Initialize().

◆ _isDisposed

bool DreamineVMS.Blazor.ViewModels.LivePageViewModel._isDisposed
private

is Disposed 값을 보관합니다.

LivePageViewModel.cs 파일의 79 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DisposeAsync(), Initialize(), OnRuntimeStateChanged(), SynchronizePlayersAsync().

◆ _isInitialized

bool DreamineVMS.Blazor.ViewModels.LivePageViewModel._isInitialized
private

is Initialized 값을 보관합니다.

LivePageViewModel.cs 파일의 70 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DisposeAsync(), Initialize().

◆ _jsRuntime

readonly IJSRuntime DreamineVMS.Blazor.ViewModels.LivePageViewModel._jsRuntime
private

js Runtime 값을 보관합니다.

LivePageViewModel.cs 파일의 52 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DestroyPlayerAsync(), EnsurePlayerAsync(), LivePageViewModel().

◆ _repository

readonly IVmsCameraRepository DreamineVMS.Blazor.ViewModels.LivePageViewModel._repository
private

repository 값을 보관합니다.

LivePageViewModel.cs 파일의 34 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Initialize(), LivePageViewModel().

◆ _runtimeState

readonly ICameraRuntimeStateService DreamineVMS.Blazor.ViewModels.LivePageViewModel._runtimeState
private

runtime State 값을 보관합니다.

LivePageViewModel.cs 파일의 43 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : EnsurePlayerAsync(), LivePageViewModel(), SynchronizePlayersAsync().

속성 문서화

◆ Cameras

IReadOnlyList<CameraDevice> DreamineVMS.Blazor.ViewModels.LivePageViewModel.Cameras = Array.Empty<CameraDevice>()
getprivate set

Live 화면에 표시할 카메라 목록입니다.

LivePageViewModel.cs 파일의 149 번째 라인에서 정의되었습니다.

149{ get; private set; } = Array.Empty<CameraDevice>();

다음에 의해서 참조됨 : DisposeAsync(), Initialize(), OnRuntimeStateChanged(), SynchronizePlayersAsync().

이벤트 문서화

◆ PlayersNeedSync

EventHandler? DreamineVMS.Blazor.ViewModels.LivePageViewModel.PlayersNeedSync

RuntimeState 변경으로 player 동기화가 필요할 때 발생합니다.

LivePageViewModel.cs 파일의 139 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : OnRuntimeStateChanged().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: