Skip to content

Commit 7ebc34e

Browse files
committed
feat: add supervised process recording outputs
1 parent 72fb7d2 commit 7ebc34e

32 files changed

Lines changed: 1454 additions & 246 deletions

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ jobs:
8787
env LD_LIBRARY_PATH=zig-out/lib DYLD_LIBRARY_PATH=zig-out/lib zig-out/rtp-abi-test
8888
cc -std=c11 -Wall -Wextra -Werror -Iinclude tests/socket_output.c -Lzig-out/lib -lzigcamera -o zig-out/socket-output-test
8989
env LD_LIBRARY_PATH=zig-out/lib DYLD_LIBRARY_PATH=zig-out/lib zig-out/socket-output-test
90+
cc -std=c11 -Wall -Wextra -Werror -Iinclude tests/process_output.c -Lzig-out/lib -lzigcamera -o zig-out/process-output-test
91+
env LD_LIBRARY_PATH=zig-out/lib DYLD_LIBRARY_PATH=zig-out/lib zig-out/process-output-test
92+
test -x zig-out/bin/zig-camera-output-host
9093
bun tests/ts/check-sensor-hdr-cli.ts zig-out/bin/zig-camera
9194
bun test tests/ts
9295
bun test tests/ts/processes.test.ts -t 'worker failure and deadline' --rerun-each 10
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Home process output
2+
on:
3+
push:
4+
branches: [main]
5+
paths: ['src/home/byte_tail.zig', 'src/home/process_output*.zig', 'src/process_output*.zig', 'ts/process-output.ts', 'ts/transport-sink.ts', 'ts/elementary-output.ts', 'tests/process_output.c', 'tests/ts/process-output.test.ts', 'tests/fixtures/process-output*.ts', '.github/workflows/home-process-output.yml']
6+
pull_request:
7+
paths: ['src/home/byte_tail.zig', 'src/home/process_output*.zig', 'src/process_output*.zig', 'ts/process-output.ts', 'ts/transport-sink.ts', 'ts/elementary-output.ts', 'tests/process_output.c', 'tests/ts/process-output.test.ts', 'tests/fixtures/process-output*.ts', '.github/workflows/home-process-output.yml']
8+
workflow_dispatch:
9+
permissions:
10+
contents: read
11+
jobs:
12+
output:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15]
17+
zig: ['0.15.2', master]
18+
runs-on: ${{ matrix.os }}
19+
steps:
20+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
21+
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29
22+
with:
23+
version: ${{ matrix.zig }}
24+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
25+
with:
26+
repository: home-lang/home
27+
ref: 6b9c9000460501866cecaa809b5f65bba2254987
28+
path: .home-process-upstream
29+
sparse-checkout: packages/video
30+
persist-credentials: false
31+
- name: Exact upstream tail framing and public exports
32+
shell: bash
33+
run: |
34+
set -euo pipefail
35+
cmp src/home/byte_tail.zig .home-process-upstream/packages/video/src/core/byte_tail.zig
36+
cmp src/home/process_output_wire.zig .home-process-upstream/packages/video/src/core/process_output_wire.zig
37+
sed 's#../core/process_output_wire.zig#process_output_wire.zig#' .home-process-upstream/packages/video/src/io/process_output_host.zig > /tmp/process-output-host.zig
38+
cmp src/home/process_output_host.zig /tmp/process-output-host.zig
39+
for mode in Debug ReleaseSafe; do
40+
zig test -lc -O "$mode" src/home/byte_tail.zig
41+
zig test -lc -O "$mode" src/home/process_output_wire.zig
42+
zig test -lc -O "$mode" --dep video -Mroot=.home-process-upstream/packages/video/tests/process_output.zig -Mvideo=.home-process-upstream/packages/video/src/video.zig
43+
done
44+
- name: Install pinned Bun for native host acceptance
45+
if: matrix.zig == '0.15.2'
46+
shell: bash
47+
run: |
48+
curl -fsSL https://bun.sh/install | bash -s 'bun-v1.4.3'
49+
echo "$HOME/.bun/bin" >> "$GITHUB_PATH"
50+
- name: Native ABI and standalone POSIX supervisor
51+
if: matrix.zig == '0.15.2'
52+
shell: bash
53+
run: |
54+
set -euo pipefail
55+
zig test -lc -Iinclude -O Debug src/process_output.zig
56+
zig test -lc -Iinclude -O ReleaseSafe src/process_output.zig
57+
zig build-exe -lc -O ReleaseSafe src/process_output_host_main.zig -femit-bin=process-output-host
58+
bun .home-process-upstream/packages/video/tests/process_output_host.ts "$PWD/process-output-host"

‎NOTICE‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,3 +710,9 @@ flattened nal_convert import. All are under the MIT license above.
710710
src/home/socket_write.zig is copied verbatim from home-lang/home
711711
packages/video/src/core/socket_write.zig at revision
712712
b32fcc0e9cb086d29ae37f0d463b9cccfd43fcb9, under the MIT license above.
713+
714+
src/home/byte_tail.zig and process_output_wire.zig are copied verbatim from
715+
home-lang/home packages/video/src/core at revision
716+
6b9c9000460501866cecaa809b5f65bba2254987. process_output_host.zig is copied from
717+
packages/video/src/io with only its process_output_wire import flattened. All
718+
are under the MIT license above.

‎README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,8 @@ SDP, cancellation, recovery and circular snapshot integration.
345345
[Raw socket outputs](docs/socket-output.md) send elementary JPEG/AVC/HEVC over
346346
bounded TCP/UDP with joined cancellation and partial-write/deadline handling.
347347
`SocketSink` also carries Home Matroska A/V through `MuxedOutput` without seeking.
348+
349+
[Supervised process outputs](docs/process-output.md) pipe Home media to explicit
350+
Bun/Zig consumer argv with bounded diagnostics, producer backpressure, joined
351+
process-group cancellation and parent-exit handling. `ProcessOutput` sends raw
352+
video; `MuxedOutput(new ProcessSink(...), 'mkv')` carries timestamped Home A/V.

‎build.zig‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ pub fn build(b: *std.Build) void {
7777
.imports = &.{.{ .name = "camera", .module = mod }},
7878
}) });
7979
b.installArtifact(exe);
80+
const output_host = b.addExecutable(.{ .name = "zig-camera-output-host", .root_module = b.createModule(.{
81+
.root_source_file = b.path("src/process_output_host_main.zig"),
82+
.target = target,
83+
.optimize = optimize,
84+
.link_libc = true,
85+
}) });
86+
b.installArtifact(output_host);
8087
const run = b.addRunArtifact(exe);
8188
if (b.args) |args| run.addArgs(args);
8289
b.step("run", "Run the capture CLI").dependOn(&run.step);

‎build.zig.zon‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.{
22
.name = .zig_camera,
3-
.version = "0.103.0",
3+
.version = "0.104.0",
44
.fingerprint = 0x774c3582060c5787,
55
.minimum_zig_version = "0.15.2",
66
.dependencies = .{},

‎docs/home-os-reuse.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,3 +653,14 @@ allocation-free send-progress primitive is therefore implemented in Home video
653653
stdlib and copied verbatim into camera; hosted queues remain in camera's native
654654
mailbox and Bun owns OS sockets. No Home OS source is copied, changed or executed;
655655
no kernel declaration establishes physical networking or Pi capture acceptance.
656+
657+
The 0.104 process-output audit fetches unchanged clean Home OS main at
658+
151269666bc09aa15a271f1c1f4603f681132e65 and inspects CLAUDE.md, ADR-MC3,
659+
kernel/src/ipc/pipe.home and kernel/src/core/process.home. Its finite kernel pipe
660+
and PCB/PGID tables are useful ownership references, not a hosted Bun media stdin
661+
sink, exec handshake or POSIX child-group wait owner. Home basics process I/O and
662+
video pipe wrappers were checked too. The bounded tail/wire and standalone host
663+
are implemented in Home video stdlib, while camera retains native queue ownership
664+
and Bun transport hooks. No OS source is copied, changed or executed. Kernel
665+
process declarations do not supply Pi capture, microphone sync or process-output
666+
performance acceptance evidence.

‎docs/home-reuse.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,3 +1879,29 @@ hosted socket ownership. Neither is copied into the Bun host. Home OS remains
18791879
151269666bc09aa15a271f1c1f4603f681132e65 (clean fetched main): kernel UDP queues and
18801880
the AirPlay RTSP control module do not provide this hosted transport. No OS source
18811881
is copied, changed or executed. See socket-output.md for ownership/transport limits.
1882+
1883+
## Supervised process outputs (0.104)
1884+
1885+
Home main 6b9c9000460501866cecaa809b5f65bba2254987 adds the allocation-free caller-owned
1886+
ByteTail, strict process_output_wire framing and optional standalone POSIX output
1887+
host. Camera copies tail/wire verbatim and adapts only the host's flattened wire
1888+
import. The portable helpers/public exports pass Debug/ReleaseSafe on pinned Zig
1889+
0.15.2 and current 0.18-dev.470; the native ABI host uses 0.15.2. Both Linux CPU
1890+
host executables cross-compile, with native execution in CI. Exact-copy consumer
1891+
checks pin that revision.
1892+
1893+
Inspected packages/basics/src/process.zig, video/src/io/pipe.zig and existing
1894+
camera process-pool supervision. Home basics already drains stdout/stderr
1895+
concurrently but targets a different I/O/compiler API and bounded whole captures.
1896+
Video's pipe wrappers do not provide process-group startup/cancel/exit proof.
1897+
The new shared host therefore owns a standalone fork/exec boundary, private
1898+
control fd, exec confirmation, monotonic grace, unreaped-leader group termination
1899+
and Linux adopted-child joins. The new tail provides bounded binary diagnostics
1900+
without allocating on append or confusing raw bytes with text.
1901+
1902+
Camera reuses its native output mailbox and Home send-progress cursor through a
1903+
shared Bun transport engine for socket/process sinks. No external codec/muxer dependency or
1904+
OS source is introduced. Source argv/env snapshots, stdout/stderr drains, child
1905+
exit and all borrowed bytes remain joined through cancellation. Full parity,
1906+
escaped/hard-killed-supervisor policies and all hardware/performance acceptance
1907+
remain open; see process-output.md.

‎docs/parity-plan.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ manual review before completion. Recheck upstream changes during the final audit
2323
| Preview/UI | SDL/headless preview through the shared native request pump, explicit suspension and joined lifecycle, bounded native RGBA overlays, SDL alpha composition, window/view/aspect controls, independent orthogonal image/overlay transforms and rectangles, main/RGB-BGR-RGBX-BGRX-RGB16-BGR16-I420-YVU-NV-422 lores/background selection with atomic live replacement, isolated display failure and mode restoration | Additional display formats, DRM/KMS and GPU/GUI integrations and their buffer-lifetime rules |
2424
| Still media | Home JPEG/PNG/BMP/TIFF/PPM/GIF, independent main/lores RGB8/RGB16 image objects with checked clone/crop/gray-RGB-RGBA conversion, exact orthogonal transforms, and bounded sync/async PNG/APNG loading with raw animation/metadata ownership, bounded native-precision resizing with capture-time dimensions and encoding/saves, bounded async APNG byte/file encoding and RGB8/RGB16 main/lores capture bursts with joined cancellation/publication, and calibrated Bayer/mono DNG with checked CSI-2 and PiSP COMP1 row decoding; atomic files and owned encoded bytes from main/RGB-BGR-RGBX-BGRX-RGB16-BGR16-I420-YVU-NV-422 lores across capture/CAF/mode jobs; negotiated color metadata and copied RGB ICC and typed/raw capture Exif in JPEG/PNG/TIFF across capture jobs | Remaining image-object transforms, additional external decoded formats and animation compositing, APNG metadata/temporary-mode animation capture conveniences, additional pixel formats/demosaicing, complete Exif/tag/thumbnail semantics and physical metadata acceptance, advanced DNG/decompression behavior and color conversions |
2525
| Encoders/recording | Home MJPEG, AVC, HEVC, AAC, MKV/MP4; named software JPEG/AVC quality tiers and a shared HEVC rate heuristic with exact rational planning, limits admission and session propagation; repeated in-band parameter sets on packet keyframes with immutable first-only opt-out across outputs and sessions; counted public IDR requests with synchronous/async producer ordering, cancellation and per-session accounting; copied AVC profile ceilings, validated codec presets and fixed-QP session policies with Baseline/Main container configuration; mixed tiny/4K HEVC with shared CTU32 and visible conformance crops; copied decoder-level ceilings and VBV/CPB policies with nominal resource/actual-header checks and explicit coordinated resets; copied session color profiles with matching matrix/range conversion and ISO/VUI/nclx across native/Bun outputs, snapshots, restart/reconfiguration and coordinated modes; main/RGB-BGR-RGBX-BGRX-RGB16-BGR16-I420-YVU-NV-422 lores encoder sources, compact producer ownership, shared encoding and session transactions, bounded independent encoders with wait/drop policy and shared PCM retention/catch-up and coordinated all-active encoder mode transactions | Complete upstream quality/rate-control behavior, additional pixel formats/raw input, general gamut/transfer conversion, MJPEG/Matroska color metadata options, independent cadence/resampling and physical shared-audio acceptance, hardware encoder paths where available, timestamps and metadata inputs |
26-
| Output families | File/custom output objects, circular/delayed A/V, PTS, split/rotation/recovery, bounded async I/O; Home AVC/HEVC/AAC RTP framing and bounded Bun UDP sender with signed AAC priming, shared RTCP correlation, actual-header SDP and recorder recovery/circular snapshots; bounded raw TCP/UDP elementary video and Home Matroska TCP A/V with joined prefix/flush/close semantics | Remaining upstream buffering/flush semantics, remaining muxer/network/process-output equivalents through Home/Bun, RTCP feedback/congestion/RTSP/SRTP session behavior, full close/reopen/failure coverage |
26+
| Output families | File/custom output objects, circular/delayed A/V, PTS, split/rotation/recovery, bounded async I/O; Home AVC/HEVC/AAC RTP framing and bounded Bun UDP sender with signed AAC priming, shared RTCP correlation, actual-header SDP and recorder recovery/circular snapshots; bounded raw TCP/UDP elementary video and Home Matroska TCP A/V with joined prefix/flush/close semantics; supervised raw/Home-container process outputs with bounded diagnostics and parent-fd/group joins | Remaining upstream buffering/flush semantics, remaining muxer/network/process-output equivalents through Home/Bun, RTCP feedback/congestion/RTSP/SRTP session behavior, full close/reopen/failure coverage |
2727
| Scheduling/extensibility | Bounded Bun jobs, cancellation, completion callbacks, drains, joined native ownership, exact frame dropping/timestamp waits, scoped pre/post callbacks with main-thread mode-worker handoff and explicit retained acquisition | Complete arbitrary dispatch/wait/cancel/flush semantics and remaining callback/allocator integration behavior |
2828
| Memory/process boundaries | Retained pointer-free descriptor exports with duplicated fds, explicit fd-less staging, full typed metadata and one whole-frame gate; bounded actual SCM_RIGHTS channels, cached shared catalogs, checked receiver-owned maps, explicit ACK primitives, request-owned configuration across source/export/remote/process boundaries, parent-controlled process byte-result publication after matched result/ACK with source retirement before I/O and retained task drains, bounded joined remote asynchronous still encoding/staged saves with owned metadata, remote owned image copies, compact/shaped/physical/raw16 copies, calibrated DNG and processed saves with request-derived Exif/ICC encoding, and opt-in scoped write planes; supervised actual Bun process pools with native moved-export/argument/result admission, matched ACK/result routing, verified-exit cancellation, isolated failures, generations and callback-aware prefix drains; persistent DMA maps, bounded retained requests, scoped read/shared and write/exclusive native mappings; opt-in Bun write contexts with detached views on close | Allocator/persistent-allocation equivalents, remaining remote conveniences, richer value and automatic recovery semantics, remaining IPC/allocator behavior; GPU integration remains unimplemented |
2929
| Camera-specific integrations | Generic typed libcamera controls; bounded pre-open IMX708 sensor HDR helper with exact identity, exclusive manager/layout guards, readback diagnostics and fresh mode catalogs; independent runtime HdrMode with staged control replay | Remaining IMX708 workflows and physical HDR acceptance, IMX500 tensor/network/inference/ROI workflows, Hailo integration and postprocessing equivalents; hardware-backed validation |
@@ -207,3 +207,12 @@ joined lifecycle/deadlines, shared PTS, isolated recovery and async output split
207207
See socket-output.md. Listening/process outputs, broader network protocols and
208208
sessions, remaining buffering/flush behaviors and all other capability families
209209
and physical acceptance remain open. This does not complete full parity.
210+
211+
Version 0.104 adds supervised process video output and Home-container byte sinks,
212+
with shared Home bounded diagnostics/control framing and a standalone Zig host,
213+
exec readiness, joined cancellation, ordinary descendant groups and parent-fd
214+
loss, immutable argv/env, shared socket/process admission, isolated recovery and
215+
async splits. See process-output.md. Additional media containers/protocols,
216+
escaped or hard-killed-supervisor process-tree policy, remaining output semantics
217+
and every other required family and physical acceptance remain open. This does
218+
not complete Picamera2 parity.

0 commit comments

Comments
 (0)