Repository navigation
Description
Unit
Port libobs/obs-output-delay.c.h (211 lines), the stream delay, to a new crate rust/obs-output: obs_output_set_delay, obs_output_get_delay and obs_output_get_active_delay (exported), process_delay, obs_output_delay_start, obs_output_delay_stop and obs_output_cleanup_delay (hidden, declared in obs-internal.h), and the file's static push_packet, pop_packet and process_delay_data.
The file reads about 15 struct obs_output fields: delay_mutex, delay_data (a struct deque of struct delay_data), active_delay_ns, delay_sec, delay_flags, delay_cur_flags, delay_restart_refs, delay_active, delay_capturing, delay_callback, starting, reconnecting, info.flags, context.name and context.signals. It calls obs_output_actual_start / _actual_stop (hidden), obs_output_can_begin_data_capture, obs_output_initialize_encoders, obs_output_begin_data_capture, obs_encoder_packet_create_instance (hidden) / _release, and the starting / stopping signals.
Phase and position
Phase 6 (#444), libobs core through opaque seams. The file is already its own translation unit in libobs/build/libobs.core-output+.h.c, so no function extraction is needed. naming.md has no row for libobs/obs-output*; this adds libobs/obs-output-delay.c.h → rust/obs-output, a crate named after the component, so later obs-output.c units can join it. Its tests are a module of the existing core category binary, obs-tests-core; no new test binary.
Dependencies and existing tests
- No cmocka test covers the delay.
test_output_delay(PR 1) is the characterization.process_delayand the start, stop and cleanup functions are not exported, so it compiles the file into itself with a zeroedstruct obs_output, stubs for theobs-output.ccalls and a test clock. It characterizes the C source only (liketest_wayland_hotkeysfor rust: Port obs-nix-hotkey-state.c to obs-hotkey #1514), so Tier 3 is the proof of the swap. struct obs_outputis private and platform-sized, and Rust should not mirror it. The C users of the delay fields inobs-output.c.hstay C.delay_datais a Cstruct dequethatobs-output.cfrees in destroy. The Rust side keeps it and needs a Rust equivalent of the header-inlineutil/deque.h(push back, peek front, pop front, with the C growth rule andbmallocmemory), with a layout test and parity against oracle wrappers of the inline functions, asdarrayhas.- Layout contracts:
struct delay_data(obs-internal.h),struct encoder_packetandstruct encoder_packet_time(obs-encoder.h),struct deque. process_delayis installed as the encoder callback, and the encoder later removes it by comparing the function pointer, so the Rust symbol must replace the C one exactly (it does underlibobs-with-rust, sinceobs-output.cnames the symbol).
Plan
- Characterization PR:
test/cmocka/test_output_delay.c(20 cases), no change to libobs. It covers set/get delay, packets held for the delay and released oldest first, the start, stop and restart paths, cleanup, and preserve on disconnect. - Accessor PR (behaviour-neutral, like libobs: Lock the hotkey mutex through a hidden accessor #1515): a hidden
obs_output_delay_fields()inobs-output.c.h, declared inobs-internal.h. It returns pointers to the delay fields, plusinfo.flags,context.nameandcontext.signals, in one plain struct.obs-output-delay.c.hreads through it, and a hiddenobs_output_delay_signal()wraps the static-inlinedo_output_signal.test_output_delaygets a one-line stub source in itstests.dfragment for the accessor, astest_wayland_multiseatgothotkey_mutex_stub.c. No test case changes. util/deque.hRust equivalent inobs-util(header-inline unit: layout test, Tier 1, Tier 3 against oracle wrappers). It can go before or alongside 2.- Port PR:
rust/obs-output.- Safe core:
- the pop decision as a pure function of the front entry's time, now,
active_delay_ns, preserve and reconnecting (hold, pop, or extend the delay to the front's age), with the strict>and the wrapping subtraction; - the dispatch of a popped entry (deliver, release, actual start, actual stop with the entry's time);
- the whole-seconds getter;
- start, stop and cleanup, generic over an output trait (lock, queue, flags, C calls), as libobs: Port the Wayland hotkey key state to obs-hotkey #1516 is generic over its lock and store.
- the pop decision as a pure function of the front entry's time, now,
- Shim: the seven symbols and the
repr(C)types. - Tests: Tier 1 ports every
test_output_delayassertion 1:1, plus edge cases. Layout tests. Tier 3 parity of the C file (oracle) against the shim through the same accessor stubs and recorded calls, with a proptest over random packet, start, stop, flag and clock sequences. The C file moves to a ported group. Tier 2 OFF/ON unchanged.
- Safe core:
No intended behaviour changes.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 20, 2026
Claiming: #1546
test_output_delay(20 cases), no change to libobs. Opening it now.obs_output_delay_fields()/obs_output_delay_signal()), after 1 merges.util/deque.hequivalent inobs-util.rust/obs-output, as its own PR.test: Characterize the output stream delay (obs-rust#1547)
test/cmocka: Add util/deque.h characterization test
test/cmocka: Add util/deque.h characterization test (obs-rust#1548)
libobs: Read the output delay fields through a hidden accessor (obs-r…
obs-util: Add a Rust equivalent of util/deque.h (obs-rust#1561)
libobs: Port the output stream delay to obs-output (obs-rust#1567)
test: Run the output stream delay end to end through libobs (obs-rust…