Add native render packet descriptor

This commit is contained in:
Meta Vens 2026-05-19 12:10:57 +01:00
commit 59ff1b8d6d
8 changed files with 181 additions and 3 deletions

View file

@ -34,6 +34,10 @@ shape removes independent per-kind storage from the live foundation.
caller-owned float32 interleaved audio blocks. The reservoir stores only the
descriptor pointer as a payload handle; audio memory remains owned by
native/Faust producers.
- `LocalcastRenderPacketDescriptor` gives render packets the same typed
descriptor boundary: caller-owned point buffer, point count/stride, target
size, source window, present time, audio-alignment time, and optional
metadata handle.
- Repo-local persistence machinery.
- First architecture map.
- Example config for one video source plus two audio sources.
@ -125,9 +129,11 @@ shape removes independent per-kind storage from the live foundation.
Aquarium now has a safe-code native reservoir binding layer, injected frame
source seam, and native `ILocalCastVisualFrameSource` that reads render
packet handles through `ILocalCastNativeRuntime` with an injected payload
decoder. It also has the matching safe-code audio block descriptor binding.
The next Aquarium cut is wiring the real payload decoder/runtime creation
path.
decoder. It also has the matching safe-code audio block and render packet
descriptor bindings, plus a render descriptor decoder that reads timing and
target metadata from native payload handles while leaving point-buffer
decoding injectable. The next Aquarium cut is wiring native runtime creation
and real point-buffer decode into the app path.
3. Move camera/mic/loopback ingest into native capture workers that use
`LocalcastProducer` to append typed sample handles.
4. Move feature extraction, flow, cross-view matching, LOD reconciliation,

View file

@ -80,6 +80,9 @@ Typed payload descriptors may cross the ABI when they clarify ownership without
copying data. `LocalcastAudioBlockDescriptor` describes caller-owned interleaved
float32 audio blocks for native/Faust producers; the reservoir stores its
address as the payload handle and does not own the bytes.
`LocalcastRenderPacketDescriptor` does the same for visual render packets:
caller-owned point buffers and timing metadata are explicit, while Aquarium owns
decode/upload/rendering.
## Authoritative Boundaries

View file

@ -60,6 +60,16 @@ runtime path:
stores the descriptor pointer as the sample payload handle;
- the reservoir still does not copy or own audio memory.
`LocalcastRenderPacketDescriptor` is the visual equivalent:
- it describes the caller-owned point buffer handle, point count/stride, target
dimensions, source-time span, presentation time, audio-alignment time, and an
optional metadata handle;
- `localcast_producer_push_render_packet` only accepts `RenderPacket`
producers and stores the descriptor pointer as the sample payload handle;
- Aquarium owns decoding and GPU upload. The reservoir only indexes when this
render packet exists in the shared rolling window.
Payload handles are owned by the caller. Aquarium should treat them as handles
to GPU/native visual memory; Faust/native DSP should treat them as handles to
audio buffers. This crate does not interpret those bytes. It is the clocked

View file

@ -52,6 +52,19 @@ typedef struct LocalcastAudioBlockDescriptor {
uint64_t channel_layout_hash;
} LocalcastAudioBlockDescriptor;
typedef struct LocalcastRenderPacketDescriptor {
uint64_t point_buffer_handle;
uint32_t point_count;
uint32_t point_stride_bytes;
uint32_t target_width;
uint32_t target_height;
uint64_t source_time_min_ns;
uint64_t source_time_max_ns;
uint64_t present_time_ns;
uint64_t audio_alignment_time_ns;
uint64_t metadata_handle;
} LocalcastRenderPacketDescriptor;
typedef struct LocalcastRuntimeStatus {
uint64_t edge_ns;
uint64_t window_start_ns;
@ -166,6 +179,15 @@ bool localcast_producer_push_audio_block(
LocalcastSampleHandle *out_sample
);
bool localcast_producer_push_render_packet(
LocalcastProducer *producer,
LocalcastRuntime *runtime,
uint64_t timestamp_ns,
uint64_t arrival_ns,
const LocalcastRenderPacketDescriptor *descriptor,
LocalcastSampleHandle *out_sample
);
#ifdef __cplusplus
}
#endif

View file

@ -196,6 +196,21 @@ pub struct LocalcastAudioBlockDescriptor {
pub channel_layout_hash: u64,
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct LocalcastRenderPacketDescriptor {
pub point_buffer_handle: u64,
pub point_count: u32,
pub point_stride_bytes: u32,
pub target_width: u32,
pub target_height: u32,
pub source_time_min_ns: u64,
pub source_time_max_ns: u64,
pub present_time_ns: u64,
pub audio_alignment_time_ns: u64,
pub metadata_handle: u64,
}
pub struct LocalcastReservoir {
inner: RollingReservoir<LocalcastSampleHandle>,
}
@ -764,6 +779,35 @@ pub extern "C" fn localcast_producer_push_audio_block(
)
}
#[unsafe(no_mangle)]
pub extern "C" fn localcast_producer_push_render_packet(
producer_ptr: *mut LocalcastProducer,
runtime_ptr: *mut LocalcastRuntime,
timestamp_ns: u64,
arrival_ns: u64,
descriptor: *const LocalcastRenderPacketDescriptor,
out_sample: *mut LocalcastSampleHandle,
) -> bool {
let Some(producer) = (unsafe { producer_ptr.as_mut() }) else {
return false;
};
if producer.kind != SampleKind::RenderPacket {
return false;
}
if descriptor.is_null() {
return false;
}
let payload_handle = descriptor as u64;
localcast_producer_push(
producer_ptr,
runtime_ptr,
timestamp_ns,
arrival_ns,
payload_handle,
out_sample,
)
}
fn localcast_runtime_push_typed(
ptr: *mut LocalcastRuntime,
kind: SampleKind,
@ -832,6 +876,21 @@ mod tests {
}
}
fn render_descriptor(point_buffer_handle: u64) -> LocalcastRenderPacketDescriptor {
LocalcastRenderPacketDescriptor {
point_buffer_handle,
point_count: 4096,
point_stride_bytes: 64,
target_width: 1920,
target_height: 1080,
source_time_min_ns: 1_000,
source_time_max_ns: 2_000,
present_time_ns: 2_350,
audio_alignment_time_ns: 2_300,
metadata_handle: 88,
}
}
#[test]
fn rolling_reservoir_expires_every_kind_from_one_edge() {
let mut reservoir = RollingReservoir::new(DEFAULT_RESERVOIR_NS);
@ -1341,6 +1400,70 @@ mod tests {
localcast_runtime_destroy(runtime);
}
#[test]
fn render_packet_descriptor_is_typed_payload_boundary_not_reservoir_storage() {
let runtime = localcast_runtime_create(DEFAULT_RESERVOIR_NS);
let producer = localcast_producer_create(SampleKind::RenderPacket.id(), 88, 12);
let descriptor = render_descriptor(1_000);
let mut sample = handle(0, 0, 0, 0, 0);
assert_eq!(std::mem::size_of::<LocalcastRenderPacketDescriptor>(), 64);
assert!(localcast_producer_push_render_packet(
producer,
runtime,
2_000,
2_010,
&descriptor,
&mut sample,
));
assert_eq!(88, sample.sensor_id_hash);
assert_eq!(12, sample.sequence);
assert_eq!(
(&descriptor as *const LocalcastRenderPacketDescriptor) as u64,
sample.payload_handle
);
assert_eq!(
1,
localcast_runtime_view_len(runtime, SampleKind::RenderPacket.id())
);
localcast_producer_destroy(producer);
localcast_runtime_destroy(runtime);
}
#[test]
fn render_packet_descriptor_push_rejects_wrong_kind_and_null_descriptor() {
let runtime = localcast_runtime_create(DEFAULT_RESERVOIR_NS);
let audio_producer = localcast_producer_create(SampleKind::AudioBlock.id(), 88, 12);
let render_producer = localcast_producer_create(SampleKind::RenderPacket.id(), 89, 0);
let descriptor = render_descriptor(1_000);
assert!(!localcast_producer_push_render_packet(
audio_producer,
runtime,
2_000,
2_010,
&descriptor,
std::ptr::null_mut(),
));
assert!(!localcast_producer_push_render_packet(
render_producer,
runtime,
2_000,
2_010,
std::ptr::null(),
std::ptr::null_mut(),
));
assert_eq!(
0,
localcast_runtime_view_len(runtime, SampleKind::RenderPacket.id())
);
localcast_producer_destroy(audio_producer);
localcast_producer_destroy(render_producer);
localcast_runtime_destroy(runtime);
}
#[test]
fn runtime_spine_rejects_nulls() {
let sample = handle(1, 2, 3, 4, 5);

View file

@ -36,6 +36,8 @@ Get-Content .\state\evidence.jsonl -Tail 8
- `LocalcastAudioBlockDescriptor` is the first typed audio payload descriptor:
caller-owned float32 interleaved audio blocks cross the ABI by descriptor
pointer, while the reservoir still owns only timing/retention metadata.
- `LocalcastRenderPacketDescriptor` now gives render packets the same typed
descriptor boundary for caller-owned point buffers and presentation timing.
- Aquarium-Engine commit `4d5aec7` adds the first safe-code C# binding layer for
this native ABI. It is not yet wired into `LocalCastRuntime` as the live
source.
@ -48,6 +50,12 @@ Get-Content .\state\evidence.jsonl -Tail 8
- Aquarium-Engine commit `34694e6` adds the matching safe-code C# binding and
layout tests for `LocalcastAudioBlockDescriptor` and the native audio-block
producer helper.
- Aquarium-Engine commit `9eb40cf` adds the matching safe-code C# binding and
layout tests for `LocalcastRenderPacketDescriptor` and the native
render-packet producer helper.
- Aquarium-Engine commit `cfb48d7` adds `LocalCastNativeRenderDescriptorDecoder`,
which reads render descriptor timing/target metadata from native payload
handles while keeping point-buffer decoding injectable.
- Edge JSON is schema/diagnostic only. Runtime network/process data should remain typed CultNet documents.
- Python live producers and diagnostic CultCache/JSON file adapters are
diagnostics, not production foundations. The OpenGL Spout sink has been

View file

@ -78,3 +78,6 @@
{"ts": "2026-05-19T10:09:53+00:00", "type": "implementation", "status": "ok", "note": "Leap packed-channel decoding and motion-point lowering moved from localcast.diagnostics.visual_producer into localcast.sensor_fusion.leap_packed; tests now import the pure core transform directly."}
{"ts": "2026-05-19T10:13:24+00:00", "type": "implementation", "status": "ok", "note": "RGB dense/reference splat math moved from localcast.diagnostics.visual_producer into localcast.sensor_fusion.rgb_reference; diagnostic capture wrapper now consumes the pure core transform and tests import it directly."}
{"ts": "2026-05-19T10:17:06+00:00", "type": "implementation", "status": "ok", "note": "LiveClapCalibrator split out of the diagnostic visual producer into localcast.diagnostics.clap_calibrator; tests no longer import visual_producer, leaving it as orchestration for the diagnostic command only."}
{"ts": "2026-05-19T11:10:31+00:00", "type": "implementation", "status": "ok", "note": "Native reservoir ABI now includes LocalcastRenderPacketDescriptor and localcast_producer_push_render_packet so render packets carry caller-owned point-buffer and timing descriptors instead of untyped payload integers."}
{"ts": "2026-05-19T11:13:54+00:00", "type": "implementation", "status": "ok", "note": "Aquarium-Engine commit 9eb40cf adds the C# LocalCast render packet descriptor binding and layout tests for LocalcastRenderPacketDescriptor/localcast_producer_push_render_packet."}
{"ts": "2026-05-19T11:21:55+00:00", "type": "implementation", "status": "ok", "note": "Aquarium-Engine commit cfb48d7 adds LocalCastNativeRenderDescriptorDecoder: Aquarium now reads LocalcastRenderPacketDescriptor timing/target metadata from native payload handles while keeping point-buffer decoding as an injected boundary."}

View file

@ -57,6 +57,9 @@ accepted_design:
- `LocalcastAudioBlockDescriptor` is the first typed payload descriptor for
caller-owned float32 interleaved audio blocks; the reservoir stores only the
descriptor pointer as a payload handle and does not own DSP memory.
- `LocalcastRenderPacketDescriptor` gives render packets the same typed
payload boundary for caller-owned point buffers and presentation timing;
Aquarium still owns decoding, upload, and rendering.
- `config/localcast.example.json` defines receiver address, base port, video encode settings, and audio sources.
- `scripts/sender-discover.ps1` lists FFmpeg devices, protocols, and encoders.
- `scripts/sender-start.ps1` launches one FFmpeg process per enabled source.