Skip to content

obs-core: port the raw video callback entry points to Rust (Fixes #5514) - #5516

Merged
rdoupe merged 2 commits into
masterfrom
port/raw-video-callbacks
Nov 23, 2026
Merged

rdoupe merged 2 commits into
masterfrom
port/raw-video-callbacks

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #5514

Rebased onto master after #5509 (the extraction of libobs/obs-raw-video-callbacks.c.h and test_raw_video_callbacks) merged.

What and why

obs_add_raw_video_callback, obs_add_raw_video_callback2 and obs_remove_raw_video_callback (libobs/obs-raw-video-callbacks.c.h, extracted and characterized by #5509) move to Rust in obs-core, the video counterpart of the raw audio pair (#5003, #5512). The safe core (raw_video_callbacks::{add, add2, remove}) makes add the divisor-1 form of add2; it reads the main canvas's mix video once and, with no main canvas or no mix, the add logs its LOG_WARNING (obs_add_raw_video_callback2: video is not set up yet, the raw video callback was not added, word for word, also through the divisor-1 form) and keeps nothing, while the removal does nothing. Otherwise exactly one call to libobs' hidden start_raw_video / stop_raw_video (they stay C in obs.c.h, also used by outputs and encoders) on the mix's video_t, with the conversion pointer, divisor, callback and param unchanged. No validation, locking or fallback is added: the divisor/NULL/duplicate checks, the locking and the raw_active count stay in start_raw_video / video-io.

The main canvas and mix are read through the existing private obs_get_video_fields() adapter (the one the Rust obs_get_video uses: canvas, canvas->mix, mix->video), so no new libobs seam is added; a mix whose video is NULL is passed on as the C does. The C file moves to its own ported unity group (libobs.ported-raw-video-callbacks+), so the C reference keeps compiling it and hybrid libobs links the Rust; the three symbols are in rust-exports.d/obs-core-raw_video_callbacks.txt. For the Windows/macOS test links, rust/obs-c-oracle/oracle/raw_video_callbacks_links.c gives obs-tests-core stand-ins for start_raw_video / stop_raw_video (the shim names them; obs_get_video_fields and blog already have definitions there). No intentional differences from the C.

Tiers: Tier 1 mirrors all seven test_raw_video_callbacks cases, plus the before-first-reset calls of test_main_mix_before_video (no canvas, and a canvas with no mix), in the Core state binary, over a synchronous model of the canvas, its mix and video-io's connect2/disconnect2 rules (no threads or waits). Tier 2 is the unchanged test_raw_video_callbacks, test_main_mix_before_video and test_video_active against both libraries. Tier 3 runs the original C (compiled against a real-header core and the real obs_get_video() field adapter) and the Rust bridge against one recorder for start_raw_video, stop_raw_video and the warning, comparing call counts, the video, conversion, divisor, callback and param identities, the warning level and text, and that neither the core/canvas/mixes nor the conversions are written, over five main-canvas states (no canvas, no mix, mix with NULL video, two mixes) x add/add2/remove x divisors 0, 1, 2, 3, u32::MAX x three conversions x four callbacks x four params, plus 256 proptest cases over any u32 divisor and 1..3 repeats; it also checks the real-header layouts of struct video_scale_info, the callback type and the field adapter. Tier 4 does not apply. No existing C test or public header changes.

Evidence

  • RED, 625f156 (rebased from b11e440; todo!() core): soldr cargo test -p obs-data --test obs-tests-core -- raw_video_callbacks → 0 passed, 9 failed (not yet implemented: obs_add_raw_video_callback / ..._callback2; the parity child aborts on the todo!() inside the extern "C" bridge).
  • GREEN, same command on the head: 9 passed (8 Tier 1 + the original-C Tier 3 parity case).
  • Mutation: forwarding divisor 1 always from add2 fails raw_video_callbacks_parity::original_c_arguments_calls_and_warning and four Tier 1 cases (5 failed, 4 passed).
  • Tier 2 (OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 5 --tests '^test_(raw_video_callbacks|main_mix_before_video|video_active)$'): full suite 1090/1090 on the C reference and 1090/1090 on hybrid libobs; the three tests 5/5 repeats on each; exported symbols identical (1769).
  • ./lint: ok.

Test cost: eight Tier 1 tests in microseconds, no threads; the parity test runs in one child process (~10 ms), no threads of its own.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner November 23, 2026 14:27
@rdoupe
rdoupe changed the base branch from master to test/raw-video-callbacks November 23, 2026 14:27
Base automatically changed from test/raw-video-callbacks to master November 23, 2026 14:59
@rdoupe
rdoupe force-pushed the port/raw-video-callbacks branch from d3acdab to 80a3194 Compare November 23, 2026 15:16
@rdoupe rdoupe closed this Nov 23, 2026
@rdoupe rdoupe reopened this Nov 23, 2026
@rdoupe
rdoupe enabled auto-merge November 23, 2026 16:05
rdoupe and others added 2 commits November 23, 2026 11:25
…() stub (Refs #5514)

RED: the obs-core core is todo!(), so all eight Tier 1 cases (one per
test_raw_video_callbacks case, plus the before-first-reset calls of
test_main_mix_before_video) and the Tier 3 parity test fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
obs_add_raw_video_callback, obs_add_raw_video_callback2 and
obs_remove_raw_video_callback move to obs-core. The main canvas's mix is
read once through the existing obs_get_video() field adapter; with no
canvas or no mix the add logs its LOG_WARNING and keeps nothing and the
removal does nothing; otherwise exactly one start_raw_video /
stop_raw_video (still C) on the mix's video with the arguments
unchanged. The C moves to its own ported unity group, so the C
reference keeps compiling it and hybrid libobs links the Rust.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Ci-Attestation: {"at":1795451559,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":92,"stamp":"f59e3bec81e3c500733d6b608d83037c","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451559,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":92,"stamp":"0c3155738420ba1f7b8ddd1d1878ccb7","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451559,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":92,"stamp":"b2baabfa1622849e4e5b25d17b585bb7","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451559,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":92,"stamp":"acbaa74fa63c13757aa6ca8b59c7281c","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"general/all/client-lint","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"4681c145455fcc1d9ee6bdfc5489ba1c","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451559,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":92,"stamp":"bfb34953665c3cee46bc868d21c62b3a","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"c9f60dbcc3d589ae865d5e55d6a547bc","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"212f2888f9bcfc838cafb25749e4f734","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"1e5efe03e0a2d40fc7970a59e3dc739b","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"dcdd1725ab6dbbefea02c8a56557d825","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"1c591cacc032d7e9d6ddd99e121dd1ba","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"4589ec4509ff1467694292bf67c18ca7","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"23cb5111487863cfbad698da2b49dfea","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"d5cfc6a5c6186724e0273e128738fe62","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"43b8c48a1059a6c76485d50a9b92a11d","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"7bafcdfe497489b9811632295ad32760","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"5222b89f6ea038cf1cf7f57f23d8f827","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451466,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"ae878c8a1b304ea1a71a8acd18af046fc569c9289cb81723fc5613f712ad4d33","lane":"client-lint","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":50,"stamp":"7645a9ee1e72a24850ee2ff8b7956227","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}
Ci-Attestation: {"at":1795451769,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"8811839e47d0b0618d27e0351586e5925854dc6e9b8381298481ec25b270f1a9","lane":"client-test-x86_64-unknown-linux-gnu","parents":["a4314f740ecadb5409faf3a4539c4e6f6172dbec"],"secs":209,"stamp":"6b19e6c27a62b7999c57dadee62d74b0","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"f97bee2b3dad98db4d5d88adf49cee22d8bd6a64","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core+.h.c","libobs/build/libobs.ported-raw-video-callbacks+.h.c","libobs/build/ported-source-sets/raw-video-callbacks.json","libobs/cmake/rust-exports.d/obs-core-raw_video_callbacks.txt","rust/README.md","rust/obs-c-oracle/oracle/raw_video_callbacks.c","rust/obs-c-oracle/oracle/raw_video_callbacks_links.c","rust/obs-core/src/ffi/mod.rs","rust/obs-core/src/ffi/raw_video_callbacks.rs","rust/obs-core/src/lib.rs","rust/obs-core/src/raw_video_callbacks.rs","rust/obs-core/tests/obs_core/main.rs","rust/obs-core/tests/obs_core/raw_video_callbacks.rs","rust/obs-core/tests/obs_core/raw_video_callbacks_parity.rs"],"head":"0fb4c2299a88e7bf6d8e4016323f213379587bd3","tools":{"orchestrator-python":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]","schema-dependencies":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504-GITv2.15.4\n   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Regexps Automata RelaxNG Schemas Schematron Modules Debug Zlib"},"tracked-digest":"cd28e628302aecedc86e14468f7507282eb89f0085fb4587c0e2c9c4ac23ba44","tree":"70e1748876a60d32aeff5fd37d589366c32b9a34"}}
@rdoupe
rdoupe force-pushed the port/raw-video-callbacks branch from 80a3194 to ceaaf67 Compare November 23, 2026 16:36
@rdoupe
rdoupe added this pull request to the merge queue Nov 23, 2026
Merged via the queue into master with commit aa1ca3d Nov 23, 2026
44 checks passed
@rdoupe
rdoupe deleted the port/raw-video-callbacks branch November 23, 2026 17:32
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.

rust: Port libobs/obs-raw-video-callbacks.c.h to obs-core

1 participant