Skip to content

obs-core: swap obs_get_video to Rust (Refs #5354) - #5421

Merged
zackees merged 2 commits into
masterfrom
port/get-video-rust
Nov 22, 2026
Merged

zackees merged 2 commits into
masterfrom
port/get-video-rust

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Swaps obs_get_video to Rust in obs-core. Public C API and ABI are unchanged.

Refs #5354. Builds on the extraction PR (#5419), now merged; this is rebased onto master.

What changes

  • libobs/obs-get-video-fields.c.h (core group, and a shared Rust-static support member through test/cmocka/get-video-link-support.c) holds the private adapters. They return the current main-canvas field and do one borrowed read each of canvas->mix and mix->video. Struct layouts stay in C.
  • The safe core obs_core::get_video answers NULL when there is no main canvas, no mix (before the first video reset) or no video. Otherwise it returns the video by identity. It takes no reference or lock and writes nothing. obs_core::ffi::get_video is the thin C ABI shim, exported through rust-exports.d/obs-core-get_video.txt.
  • The original C moves to libobs.ported-get-video (C reference only). The unchanged test_get_video runs against both libraries.

Evidence

  • RED (a5bef350f): safe Tier 1 mirrors of every test_get_video.c case, plus the NULL main canvas that test cannot reach (the core global is hidden from test executables) and a missing mix that never reads a video. All run against a todo!() core.
    soldr cargo test -p obs-data --test obs-tests-core -- get_video: all 5 obs_core::get_video tests failed.
  • GREEN (3d17006e9): the same command gives 9 passed, 0 failed (5 Tier 1 tests and 4 Tier 3 tests).
  • Tier 3 (get_video_parity, rust/obs-c-oracle/oracle/get_video.c): the original C and the shim run on real-layout core, canvas and mix fixtures. The states covered are: no main canvas; either canvas with no mix or either mix; and that mix with no video or either token. The other canvas and mix always hold a video, so reading the wrong one shows up. The state switches between reads, in both orders and through a proptest over sequences. Each check compares the answer, the unchanged fixture bytes, the real adapter layout, and the original's answers against the characterized ones.
  • Mutation: when the shim returns the mix pointer as the video, get_video_parity gives 2 passed and 2 failed. When the safe core always answers None, 3 of the get_video tests fail.
  • Tier 2: OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 10 --tests '^test_get_video$' gave [OFF] (C reference) 1074/1074 and [ON] (hybrid libobs) 1074/1074, with test_get_video passing 10 repeats against each. The exported-symbol comparison between C and Rust passed.
  • After the rebase onto master (1d9ab9704): the same Tier 1/3 command gives 10 passed, 0 failed, and ./lint passed.

Not run locally: native Windows/macOS. Tier 4 does not apply to this getter.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner November 21, 2026 22:07
@rdoupe
rdoupe changed the base branch from master to test/get-video-extract November 21, 2026 22:07
@rdoupe
rdoupe marked this pull request as draft November 21, 2026 22:07
@obs-rust-project-manager obs-rust-project-manager Bot moved this to In progress in obs-rust Multiview Nov 21, 2026
Base automatically changed from test/get-video-extract to master November 22, 2026 01:03
rdoupe and others added 2 commits November 21, 2026 20:51
Safe Rust mirrors of every case of the unchanged test_get_video.c (no mix
answers NULL with references unchanged; a mix's video by identity, following
a change and answering NULL for an unset video; an auxiliary canvas's mix is
never the answer), plus the NULL main canvas the C test cannot reach and a
missing mix that never reads a video, against a todo!() core.

    soldr cargo test -p obs-data --test obs-tests-core -- get_video
    obs_core::get_video: 0 passed; 5 failed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
obs_get_video now comes from obs-core in hybrid libobs. Private C adapters
(obs-get-video-fields.c.h, in the core group and a shared Rust-static
support member) give the current main-canvas field and one borrowed read
each of the canvas's mix and the mix's video. The safe core answers NULL for
no main canvas, no mix or no video, else the video by identity, with no
reference, lock or write. The original moves to libobs.ported-get-video for
the C reference; the unchanged test_get_video runs both libraries.

Tier 3 runs the original and the shim on real-layout core, canvas and mix
fixtures over every state (no main canvas, either canvas with no mix or
either mix, that mix with no video or either token), switched between
reads, checking the answer, unchanged fixture bytes and the adapter layout.

    soldr cargo test -p obs-data --test obs-tests-core -- get_video
    obs_core::get_video*: 9 passed; 0 failed

Mutation (shim returning the mix pointer as the video): get_video_parity
2 passed; 2 failed. Safe core always None: 3 of the get_video tests fail.

    OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 10 --tests '^test_get_video$'
    [OFF] 1074/1074, [ON] 1074/1074, test_get_video 10 repeats each

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

Ci-Attestation: {"at":1795312674,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":64,"stamp":"0048a7c8281744bb2cf18412e1f26c8d","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312674,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":64,"stamp":"b2217d337a0c52e42ad3ea24e9dd31d5","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312674,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":64,"stamp":"3baa9a737542af1a4b5699fbdfb18430","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312674,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":64,"stamp":"3d55ba635f66ad41cf5ed671e53f9348","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"general/all/client-lint","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"d05517906114c2446f97459f49a204e3","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312674,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":64,"stamp":"cd57a5a5a6b88c0e7ed39ae340b1b7a9","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"2d729eeec56c19f56635070bbced5e9e","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"4316bcd67869e63b0a660b1748c07cf3","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"9da652bdc8db8e5f31b94db9eeab252e","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"1784fefca3cbdc27fbeaeeff6cd54b83","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"ec70f7f9e9b0fd5dcedd929ee573e232","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"3e2ed3a9fb4d95b0bb54e8d3bafa4d80","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"97cbf05af582b0b5b250583832e0708b","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"f10d12ed076ed18cb79b848a1693249e","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"a8af7ccf5b43645fee25bdb8c5f2f55c","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"812f10527e6f109745f58f20ae78cc99","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"b3e8dac4e356aa3187ebec1b535ac68a","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312609,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"f83b6c4042e72d0005abc87026e5f20cd172097e9c7a0a451fe30154477eb29e","lane":"client-lint","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":99,"stamp":"85af209bb18112ad5fe1a2f0c7faf74e","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}
Ci-Attestation: {"at":1795312864,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"6f8be9a76e5b49b717878b6b5ec30710caebe9288af7c583701a54ac4881e025","lane":"client-test-x86_64-unknown-linux-gnu","parents":["a5bef350f58f8333740deaf4411e35bffdb9c231"],"secs":189,"stamp":"bdff2c387b27e0af755e559161c12b38","tree":"51de33862e630a5b895ba7e4267bd653dc797237","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"1d9ab9704a899c04b9cd412283bda12491b55e77","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core+.h.c","libobs/build/libobs.ported-get-video+.h.c","libobs/build/ported-source-sets/get-video.json","libobs/cmake/rust-exports.d/obs-core-get_video.txt","libobs/obs-get-video-fields.c.h","rust/README.md","rust/obs-c-oracle/oracle/get_video.c","rust/obs-core/src/ffi/get_video.rs","rust/obs-core/src/ffi/mod.rs","rust/obs-core/src/get_video.rs","rust/obs-core/src/lib.rs","rust/obs-core/tests/obs_core/get_video.rs","rust/obs-core/tests/obs_core/get_video_parity.rs","rust/obs-core/tests/obs_core/main.rs","test/cmocka/build/rust-static-support.json","test/cmocka/get-video-link-support.c"],"head":"d4c6ea18beb7db2077e68b8abb11c6d1fb3fba05","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":"e6cc6681c175c899db8cd0df4d9d145a5aaf0e90529ca24f121173ad4a05b1ee","tree":"51de33862e630a5b895ba7e4267bd653dc797237"}}
@rdoupe
rdoupe force-pushed the port/get-video-rust branch from 5f6bd53 to 3d17006 Compare November 22, 2026 02:01
@rdoupe
rdoupe marked this pull request as ready for review November 22, 2026 02:05

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator review: approved.

  • Correctness: canvas.and_then(mix).and_then(video) is exactly the original canvas && canvas->mix ? canvas->mix->video : NULL: three borrowed reads, no reference, no lock, no write. The struct layouts stay in C behind the obs-get-video-fields adapter.
  • RED → GREEN: a5bef350f (todo! core, 5 Tier 1 tests fail), then 3d17006e9.
  • Tier 2: the unchanged test_get_video runs against both libraries.
  • Tier 3: get_video_parity runs the original C in the oracle against the shim on real-layout fixtures. The decoys catch a wrong canvas or mix read.
  • Ledger: this is an internal port with no user-visible change, so it needs no features line. The rust/README.md row is present.

Nit: the PR adds Rust tests, so the body should carry a Test cost: line (count, runtime, peak RSS, threads; obs-worker §4). Please add it; it doesn't hold the merge.

@zackees
zackees added this pull request to the merge queue Nov 22, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In progress to In merge queue in obs-rust Multiview Nov 22, 2026
Merged via the queue into master with commit ec9208d Nov 22, 2026
46 checks passed
@zackees
zackees deleted the port/get-video-rust branch November 22, 2026 03:04
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In merge queue to Done in obs-rust Multiview Nov 22, 2026
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