Skip to content

test: Run the output interleaver end to end through libobs - #1606

Merged
zackees merged 1 commit into
obs-rust:masterfrom
rdoupe:test/output-interleave-e2e
Oct 21, 2026
Merged

zackees merged 1 commit into
obs-rust:masterfrom
rdoupe:test/output-interleave-e2e

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Refs #1594 (follow-up to #1603: an end-to-end test of the ported interleaver)

What and why

#1603's deliberate-break check showed that the tests run through the libobs that ships catch only the interleaver's catch-up limit (test_output_interleave_restart). test_output_interleave compiles obs-output-interleave.c.h into itself, so it characterizes the C source only. With the premature prune made non-strict (>=) or the video-before-audio insertion rule removed in the Rust core, every real-libobs test still passed against libobs-with-rust; only Tier 3 caught them. This PR adds test/cmocka/test_output_interleave_e2e.c, which drives a real encoded output with one video and two audio tracks through real libobs. It is test-only: no change to libobs, to Rust code or to an existing test.

  • How it runs. obs_startup() with real core video, then a video encoder, two audio encoders and an encoded multi-track output (OBS_OUTPUT_AV | OBS_OUTPUT_ENCODED | OBS_OUTPUT_MULTI_TRACK), all registered in the test. The media is fed by hand, as in test_output_interleave_restart: each step submits one audio block (one packet from each audio encoder, with a dts the test picks) and then one video frame (a keyframe every third frame, the frame number in the payload), and waits until the encoders and the output have handled it. Audio encoders paired with the video start at the video's start time, so an audio packet's dts sets its place relative to the first video frame. The output's encoded_packet() records what it receives.
  • Timing. Nothing depends on the wall clock, so the checks are orderings and lower bounds plus the start values the interleaver sets (dts 0, the first frame number). The test takes about 1.7 s.
  • Registration. A tests.d/test_output_interleave_e2e.cmake fragment like test_output_interleave_restart's: Linux with libobs-opengl, skip code 77 without a display (CI runs ctest under xvfb-run).
  • The 4 cases. Every capture checks that the first packet is a video keyframe at dts 0, no earlier video frame is sent, each audio track's first packet comes after it at a dts from 0 to one frame, the dts never decrease across the tracks, video comes before audio at an equal dts, and every track delivers packets.
    • starts_on_keyframe_and_interleaves: audio and video start together. The output starts at frame 0. Each audio packet is queued before the video frame of the same dts, so the insertion order shows.
    • audio_one_frame_late_keeps_keyframe: the first audio is exactly one frame (20 ms) after the first keyframe. That is not premature (the prune is strict): the output starts at frame 0 and the audio is offset to 0 as well.
    • late_audio_starts_at_next_keyframe: the first audio is two frames after the first keyframe. As test_output_interleave characterizes (not endorsed), the keyframe is dropped and the output starts at the next keyframe, frame 3, with every track at 0.
    • stop_and_restart: a capture, then obs_output_stop() until the output deactivates. Media submitted after that reaches nothing. The same output then starts again with late audio and starts at frame 3 at dts 0: the start rules and the offsets apply to the new capture, not the old one.

RED → GREEN

  • No RED commit: the test covers existing behaviour and passes on master in both libraries. 69a7df5 test: Run the output interleaver end to end through libobs.
  • Runs (headless: private Xvfb, private D-Bus, fresh HOME), 5 runs of the test in each build tree against each library:
Lane libobs libobs-with-rust
C (ENABLE_RUST_LIBOBS=OFF) 5/5, 1.65-1.74 s 5/5, 1.66-1.76 s
Rust (ENABLE_RUST_LIBOBS=ON) 5/5, 1.65-1.75 s 5/5, 1.66-1.76 s

Since #1603 merged, the libobs-with-rust column runs the Rust interleaver.

  • The swap is now visible end to end. On libobs: Port the output interleaver to obs-output #1603's head (its rust/, libobs/ and test/ are identical to master's since it merged), each mutant of the Rust core (rust/obs-output/src/interleave.rs) was rebuilt into libobs-with-rust and the test was run against it (mode ON). Both mutants fail it, while test_output_interleave_restart still passes:
    • diff >= duration_usec for the strict > in premature_prune: audio_one_frame_late_keeps_keyframe fails (the output starts at frame 3, not 0); the other 3 cases pass. 2/2 runs.
    • The video-before-audio rule removed from insert_position: all 4 cases fail. Three see audio before video at an equal dts; late_audio_starts_at_next_keyframe sees audio as the first packet. 2/2 runs.
    • The clean port passes 5/5 in each of the two mutant runs (1.66-1.77 s). Restored after the mutants, it passes again, and so does its C libobs.
  • Full cmocka suite, both build trees, each against both libraries:
Lane libobs libobs-with-rust Exported symbols
C (ENABLE_RUST_LIBOBS=OFF) 349/349 349/349 IDENTICAL (1766)
Rust (ENABLE_RUST_LIBOBS=ON) 349/349 349/349 IDENTICAL (1766)

No test was skipped or failed to run. test_output_interleave_e2e takes 1.65-1.68 s inside the parallel suite.

  • uv run ci/local_gate.py --lane lint: passed. clang-format and gersemi are clean on the new files.
  • Real app: not applicable (test only).

Windows/macOS: not built there. Like test_output_interleave_restart, the test is registered on Linux only (it loads libobs-opengl for core video). It uses only public libobs API (obs.h, media-io/video-frame.h, util/threading.h).

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (test only; it passes on master)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): not applicable
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): not applicable (no port here)

obs-rust#1603 ports obs-output-interleave.c.h to rust/obs-output, and its
deliberate-break check showed that the tests run through a real libobs
catch only the catch-up limit (test_output_interleave_restart).
test_output_interleave compiles the C file into itself, so with the
premature prune made non-strict (>=) or the video-before-audio insertion
rule removed in the Rust core, every real-libobs test still passed
against libobs-with-rust; only Tier 3 caught them.

test_output_interleave_e2e drives an encoded output with one video and
two audio tracks, all registered in the test, through obs_startup() and
real core video, and feeds the media by hand as the restart test does,
so nothing depends on the wall clock. It checks what the output's
encoded_packet callback receives: the first packet is a video keyframe
at dts 0 and each audio track starts after it, near 0; the dts never
decrease across the tracks, with video before audio at an equal dts;
audio exactly one frame after the first keyframe keeps it, and audio two
frames after drops it, so the output starts at the next keyframe (as
test_output_interleave characterizes); and the same output, stopped,
receives nothing and starts afresh the same way. About 2 s.

Refs obs-rust#1594
@rdoupe
rdoupe requested a review from zackees as a code owner October 21, 2026 06:30
@zackees
zackees added this pull request to the merge queue Oct 21, 2026
Merged via the queue into obs-rust:master with commit 7764b79 Oct 21, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants