Add native video frame ingest descriptor

This commit is contained in:
Meta Vens 2026-05-21 18:31:36 +01:00
commit 493b9ac3c7
14 changed files with 89 additions and 5 deletions

View file

@ -8,6 +8,13 @@
"enabled": true,
"adapter": "native"
},
{
"sourceId": "leap-stereo-ir",
"kind": "Video",
"origin": "LocalDevice",
"enabled": true,
"adapter": "native"
},
{
"sourceId": "host-focusrite",
"kind": "Audio",

View file

@ -57,6 +57,10 @@ latency, and confidence.
Local devices should feed through native push adapters; process-backed
sources are compatibility edges for network/diagnostic command ingest, not
the six-camera capture foundation.
- `MimirVideoFrameDescriptor` is the first video-frame hot-path descriptor:
dimensions, pixel format, stride, device timestamp, and optional native/GPU
handle. Leap stereo IR should enter Mimir through this native descriptor,
with OpenCV kept out of the hot loop.
- `config/perfect-machine.example.json` declares the contract shape for six cameras, six microphones, reservoir typed views, native authorities, outputs, and the demotion of bridge scripts to tooling.
- `native/reservoir` is the first native Rust crate. It implements one
shared-edge five-second rolling buffer with typed views and proves that

View file

@ -96,6 +96,9 @@ The first cut should be deliberately boring:
- `IMimirStreamSource` is the adapter seam for local devices and network feeds.
- `MimirNativeIngestStreamSource` is the low-overhead push seam for native
camera/audio adapters that already own buffers or handles.
- `MimirVideoFrameDescriptor` carries video shape, pixel format, device
timestamp, stride, and optional native/GPU handle metadata. Leap stereo IR
should enter here, not through OpenCV.
- `MimirProcessStreamSource` is a compatibility adapter for network or
diagnostic command sources. It is not the six-camera local capture foundation.
@ -118,6 +121,10 @@ through `MimirNativeIngestStreamSource`. Process-backed FFmpeg ingest is allowed
for remote SRT/diagnostic edges, but local six-camera ingest should stay close
to the driver, GPU, and capture APIs.
Leap should be treated as the timing-camera candidate only when the native
adapter preserves device timestamps or captures a monotonic timestamp
immediately on frame receipt. OpenCV arrival timing is too soft for that job.
## Cut Line
Do not add a new registry, bridge daemon, JSON live store, OBS plugin, or

View file

@ -70,7 +70,9 @@ rolling buffer per configured audio/video stream, source polling through
`IMimirStreamSource`, and runtime UI readouts for stream/buffer health.
Local six-camera ingest should push native handles through
`MimirNativeIngestStreamSource`; process-backed ingest remains a compatibility
edge for network SRT or diagnostics.
edge for network SRT or diagnostics. `MimirVideoFrameDescriptor` carries
dimensions, pixel format, stride, device timestamp, and optional native/GPU
handle metadata so Leap stereo IR can enter Mimir without OpenCV owning timing.
```mermaid
flowchart TD

View file

@ -52,6 +52,9 @@ Get-Content .\state\evidence.jsonl -Tail 8
adapters feed buffers through `IMimirStreamSource`. Local six-camera ingest
should use native push adapters such as `MimirNativeIngestStreamSource`, not
FFmpeg stdout/process capture except as a network or diagnostic edge.
`MimirVideoFrameDescriptor` now carries video shape, pixel format, stride,
device timestamp, and optional native/GPU handle metadata for close-to-metal
frame ingest; Leap stereo IR is the timing-camera candidate for this path.
- The reservoir is now one native time-ordered rolling buffer with typed
indexes/views. The previous typed-ring crate is gone.
- Native reservoir samples carry provenance flags; diagnostic/fallback samples

View file

@ -19,7 +19,8 @@ public sealed class MimirNativeIngestStreamSource : IMimirStreamSource
long arrivalNs,
ulong payloadHandle,
int byteLength = 0,
ReadOnlyMemory<byte> data = default)
ReadOnlyMemory<byte> data = default,
MimirVideoFrameDescriptor? videoFrame = null)
{
samples.Enqueue(new MimirStreamSample(
Descriptor.SourceId,
@ -30,7 +31,27 @@ public sealed class MimirNativeIngestStreamSource : IMimirStreamSource
sequence++,
payloadHandle,
byteLength,
data));
data,
videoFrame));
}
public void PushVideoFrame(
MimirVideoFrameDescriptor frame,
long arrivalNs,
ReadOnlyMemory<byte> data = default)
{
if (Descriptor.Kind != MimirStreamKind.Video)
{
throw new InvalidOperationException("Video frames can only be pushed into a video stream source.");
}
Push(
frame.DeviceTimestampNs,
arrivalNs,
frame.NativeHandle,
data.Length,
data,
frame);
}
public bool TryRead(out MimirStreamSample sample)

View file

@ -85,7 +85,8 @@ public sealed class MimirProcessStreamSource : IMimirStreamSource
sequence++,
0,
buffer.Length,
buffer));
buffer,
null));
}
}

View file

@ -93,6 +93,11 @@ public sealed class MimirRuntimeConfiguration
private static IMimirStreamSource? TryCreateSource(MimirStreamConfig stream)
{
if (string.Equals(stream.Adapter, "native", StringComparison.OrdinalIgnoreCase))
{
return new MimirNativeIngestStreamSource(ToDescriptor(stream));
}
if (!string.Equals(stream.Adapter, "process", StringComparison.OrdinalIgnoreCase))
{
return null;

View file

@ -9,4 +9,5 @@ public readonly record struct MimirStreamSample(
ulong Sequence,
ulong PayloadHandle,
int ByteLength = 0,
ReadOnlyMemory<byte> Data = default);
ReadOnlyMemory<byte> Data = default,
MimirVideoFrameDescriptor? VideoFrame = null);

View file

@ -0,0 +1,21 @@
namespace Mimir.Runtime.Synchronization;
public enum MimirVideoPixelFormat
{
Unknown,
Gray8,
R8,
Rg8,
Bgra8,
Nv12,
LeapStereoIr,
}
public sealed record MimirVideoFrameDescriptor(
int Width,
int Height,
MimirVideoPixelFormat PixelFormat,
int StrideBytes,
long DeviceTimestampNs,
ulong NativeHandle = 0,
string NativeHandleKind = "");

View file

@ -99,3 +99,4 @@
{"ts": "2026-05-21T12:14:26+00:00", "type": "implementation", "status": "ok", "note": "Mimir now owns a C# app solution: Mimir.slnx contains src/Mimir.App, which launches AquariumHost from Aquarium Engine, and src/Mimir.Runtime, which provides the Aquarium runtime factory over Aquarium.LocalCast. Aquarium Engine remains the windowing/rendering/D3D12 library reference."}
{"ts": "2026-05-21T12:33:01+00:00", "type": "implementation", "status": "ok", "note": "Mimir.Runtime now owns the first synchronization spine: MimirRuntime wraps Aquarium LocalCast rendering, initializes per-stream rolling buffers through MimirSynchronizationHub, polls registered IMimirStreamSource adapters each update, and defaults buffer duration to five seconds with env overrides for local/network audio/video stream ids."}
{"ts": "2026-05-21T17:27:12+00:00", "type": "decision", "status": "ok", "note": "For six local cameras, Mimir ingest should stay close to driver/GPU capture surfaces. MimirNativeIngestStreamSource is the preferred local adapter seam carrying payload handles and optional memory into rolling buffers; MimirProcessStreamSource remains a network/diagnostic compatibility edge, not the local camera foundation."}
{"ts": "2026-05-21T17:31:13+00:00", "type": "implementation", "status": "ok", "note": "OpenCV is cut out of the Mimir video hot-path contract: MimirVideoFrameDescriptor carries dimensions, pixel format, stride, device timestamp, and optional native/GPU handle; MimirNativeIngestStreamSource can push LeapStereoIr or other camera frames directly into rolling buffers while process-backed ingest remains a network/diagnostic edge."}

View file

@ -81,6 +81,10 @@ accepted_design:
optional memory spans into Mimir buffers. `MimirProcessStreamSource` is a
compatibility path for network SRT or diagnostics, not the local camera
foundation.
- `MimirVideoFrameDescriptor` is the first native video-frame descriptor for
the C# runtime: width, height, pixel format, stride, device timestamp, and
optional native/GPU handle. Leap stereo IR should use this path as the
timing-camera candidate instead of OpenCV arrival timing.
- `native/reservoir` is the first native Rust crate. It now uses one
time-ordered rolling buffer with typed views, so retention has exactly one
owner while Aquarium/Faust still get kind-scoped queries.

View file

@ -17,5 +17,7 @@ No active scratch subgoal.
- Local six-camera ingest should stay close to the metal: native push sources
carry payload handles into buffers; process sources are network/diagnostic
compatibility, not the main local camera path.
- `MimirVideoFrameDescriptor` is the hot-path video descriptor for native camera
workers. Leap stereo IR should push device timestamps/handles through it.
- Keep scratch short and disposable.
- Promote only durable lessons into `state/evidence.jsonl` or the map.

View file

@ -49,9 +49,14 @@ class MimirAppContractTests(unittest.TestCase):
self.assertIn("MIMIR_LOCAL_AUDIO_STREAMS", settings)
native_source = (ROOT / "src" / "Mimir.Runtime" / "Synchronization" / "MimirNativeIngestStreamSource.cs").read_text(encoding="utf-8")
process_source = (ROOT / "src" / "Mimir.Runtime" / "Synchronization" / "MimirProcessStreamSource.cs").read_text(encoding="utf-8")
frame_descriptor = (ROOT / "src" / "Mimir.Runtime" / "Synchronization" / "MimirVideoFrameDescriptor.cs").read_text(encoding="utf-8")
self.assertIn("payloadHandle", native_source)
self.assertIn("PushVideoFrame", native_source)
self.assertIn("ReadOnlyMemory<byte>", native_source)
self.assertIn("LeapStereoIr", frame_descriptor)
self.assertIn("DeviceTimestampNs", frame_descriptor)
self.assertIn("NativeHandle", frame_descriptor)
self.assertIn("RedirectStandardOutput", process_source)