Multi-scene webcam (schema v3/v4): singleton Webcam + per-scene WebcamSceneConfig, right-click OBS-style border/context menu, persisted round-to-rect restore + legacy-square 16:9 heal, dark MenuItem template, tests (25 passing)

This commit is contained in:
2026-08-07 08:24:18 -07:00
parent f31ce9fdb7
commit e037ba027b
23 changed files with 1405 additions and 287 deletions
+22
View File
@@ -122,6 +122,28 @@ public sealed class CameraManager : IDisposable
toStop.PreviewBitmap = null;
}
/// <summary>
/// Releases a device unconditionally (every ref), regardless of how many scenes
/// hold it. Used on identity changes (webcam swap, layout reload) where the old
/// device's refcount isn't known after the scenes are replaced.
/// </summary>
public async Task ReleaseAllAsync(string deviceId)
{
CameraSession? toStop = null;
lock (_gate)
{
if (!_sessions.TryGetValue(deviceId, out var session)) return;
session.RefCount = 0;
_sessions.Remove(deviceId);
toStop = session;
}
if (toStop == null) return;
toStop.Source.FrameAvailable -= toStop.FrameHandler;
await SafeStopAsync(toStop.Source);
toStop.PreviewBitmap = null;
}
public VideoFrame? GetLatestFrame(string deviceId)
{
lock (_gate)