Repository navigation
obs-source: port the six async-frame entry wrappers to Rust (Fixes #5760) - #5761
Merged
Merged
Conversation
Moves obs_source_output_video(), obs_source_output_video2(), obs_source_preload_video(), obs_source_preload_video2(), obs_source_set_video_frame() and obs_source_set_video_frame2() unchanged into libobs/obs-source-frame-wrappers.c.h in the live core-source group. The three workers they call (obs_source_output_video_internal(), obs_source_preload_video_internal() and obs_source_set_video_frame_internal()) stay in obs-source.c.h; they lose their `static` and obs-internal.h declares them, because the new file comes before obs-source.c.h in the unity group. Hidden visibility keeps them out of the exported symbols. No behavior change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds test_source_frame_wrappers (cmocka, a private async source, 7 cases) against hybrid libobs and the C reference. The workers are hidden in libobs, so each case checks what the worker left: a source being destroyed returns before the NULL check (output with a NULL frame would clear the clocks); a NULL frame clears the queue, the cache and both clocks through output and changes nothing through preload or set; the obs_source_frame variants copy the whole frame with full_range replaced (YUV keeps it, BGRA becomes full range); the obs_source_frame2 variants take full_range from the range and max_luminance 0; the caller's frame is never written. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds obs_source::frame_wrappers with todo!() bodies and its Tier 1 tests over a recording model of destroying() and the three C workers: a source being destroyed returns first, NULL frames go to the worker (and the two set_video_frame entries to the preload worker), the obs_source_frame entries copy the whole frame with full_range replaced, the obs_source_frame2 entries build a zeroed frame with full_range from the range and max_luminance 0, and the worker never gets the caller's frame. soldr cargo test -p obs-data --test obs-tests-core frame_wrappers:: fails 7 of 7 (not yet implemented). Co-Authored-By: Claude Opus 5.5 <[email protected]>
) Implements obs_source::frame_wrappers and the six exports obs_source_output_video(), obs_source_output_video2(), obs_source_preload_video(), obs_source_preload_video2(), obs_source_set_video_frame() and obs_source_set_video_frame2(). A source being destroyed returns first; a NULL frame goes to the worker as NULL (the set_video_frame pair to the preload worker, as upstream); an obs_source_frame is copied whole with full_range replaced, an obs_source_frame2 builds a zeroed frame with full_range from the range and max_luminance 0; the worker gets the local copy. destroying() and the three workers stay C behind the new adapter file obs-source-frame-wrappers-fields.c.h (declared in obs-internal.h). The extracted C moves to the reference-only group libobs.ported-source-frame-wrappers. Tier 3 (frame_wrappers_parity, oracle/source_frame_wrappers.c) runs the original C and the Rust exports on a real private source over the same adapters, with destroying() and the workers recorded, and compares which worker runs, its source, whether its frame is NULL, the caller's or a copy, and every field of the copy as bits; it checks both frame layouts, pins the characterized answers, rejects four export mutants and runs a proptest over random frames. Co-Authored-By: Claude Opus 5.5 <[email protected]> Ci-Attestation: {"at":1795670503,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":95,"stamp":"4e34e2a414dbceba8d6e8bd4b87788a7","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670503,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":95,"stamp":"260e43117b4a68a6d5112c17daec2dbc","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670503,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":95,"stamp":"be03472440c96f1204c081575153ce0e","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670503,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":95,"stamp":"3673672118e5936ebedf44f63fe605bc","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"general/all/client-lint","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"fa5ed3c4be251ce075a0a03ba673f902","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670503,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":95,"stamp":"5a8a40452f521dfe9e3dc3a62bee3b56","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"6e5248184b6c1d0ac3a651d2a203deee","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"178ace8eaa8f8dfb2b1fa12719f8c3b4","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"d1d186387aea35399f4ce4c13cb6768b","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"0ed2ad987400b27996922f00771d1228","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"1b7d06315bfae9842ff43d3669fdd5a2","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"67aeca80cb969b30e2fb0a265a5e398e","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"e28e4ff9974fae28ae35bc1eb5239688","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"6b16fc3de6d1ad5d51578896da88771c","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"a39b14e5757427809d267aca9599bfa1","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"834ba0ad6ad7acfbbd36cbaa740139e3","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"fed15245258a2eb00c7bac1bce847f0d","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670408,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"9b5242b962333cd36a9f0ef30f036840080e88a41339fb7be39021134f1e8137","lane":"client-lint","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":102,"stamp":"85da17a0ed48ed66dc40eb87517a051d","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Ci-Attestation: {"at":1795670777,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"869494226a1582afa13b3a379b2d1bff497456686507da184c07958ae32306ac","lane":"client-test-x86_64-unknown-linux-gnu","parents":["bd63b0fc7726716aae7d3eecbe7263f2d23a6f1b"],"secs":273,"stamp":"2d8b4d9b4d599ff73394234dd5d655b4","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad","v":1,"via":"run"} Client-Checks: {"checks":{"base":"1a371e8bc576a915376715bf91ad39d30518b860","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-frame-wrappers+.h.c","libobs/build/ported-source-sets/source-frame-wrappers.json","libobs/cmake/rust-exports.d/obs-source-source_frame_wrappers.txt","libobs/obs-internal.h","libobs/obs-source-frame-wrappers-fields.c.h","libobs/obs-source-frame-wrappers.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_frame_wrappers_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-frame-wrappers.list","rust/obs-c-oracle/oracle/source_frame_wrappers.c","rust/obs-source/Cargo.toml","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_frame_wrappers.rs","rust/obs-source/src/frame_wrappers.rs","rust/obs-source/src/lib.rs","rust/obs-source/tests/source/frame_wrappers.rs","rust/obs-source/tests/source/frame_wrappers_parity.rs","rust/obs-source/tests/source/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_source_frame_wrappers.c","test/cmocka/tests.d/test_source_frame_wrappers.cmake"],"head":"cd9654438ddcbf277abb781c4014d5d195273b89","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":"185d47a2f39fe6e2176c6ee779b6158d68108c070aa1b62dba872941505436d5","tree":"cac94551ccd2eb9ffd9085a2296126762b9a08ad"}}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5760.
Ports the six exported async-frame entry points
obs_source_output_video(),obs_source_output_video2(),obs_source_preload_video(),obs_source_preload_video2(),obs_source_set_video_frame()andobs_source_set_video_frame2()fromlibobs/obs-source.c.htoobs-source. Each is the same thin wrapper (adestroying()check, a NULL shortcut, then a frame built from the caller's) in front of a C worker.Commits
libobs: extract ... verbatimmoves the six functions unchanged intolibobs/obs-source-frame-wrappers.c.h, a member of the live core-source group. The new file sorts beforeobs-source.c.hin the unity group, so the three workers they call (obs_source_output_video_internal(),_preload_video_internal(),_set_video_frame_internal()) lose theirstaticandobs-internal.hdeclares them; hidden visibility keeps them out of the exports. No behavior change.test: characterize ...addstest_source_frame_wrappers(cmocka, a private async source afterobs_startup(), 7 cases) against hybrid libobs and the C reference. The workers are hidden in libobs, so each case checks what the worker left: a source being destroyed returns before the NULL check (output with a NULL frame would otherwise clear the clocks); a NULL frame clears the queue, the cache and both clocks through output and changes nothing through preload or set; theobs_source_frameentries queue or preload the whole frame withfull_rangereplaced (BGRA becomes full range, I420 keeps it,max_luminance1000 kept); theobs_source_frame2entries takefull_rangefrom the range (default resolves per format) and writemax_luminance0 over a frame that had 1000; the set pair also fills the async texture description and clearsasync_textures_stale; the caller's frame is byte-for-byte unchanged. Theset_video_frame(NULL)quirk (it calls the preload worker) leaves no state that tells the two workers apart, so Tier 1 and Tier 3 pin it.test: REDadds Tier 1 (obs_source::frame_wrappersover a recording model ofdestroying()and the three workers: which worker each entry calls, the order, and the exact frame each worker gets, field by field as bits) againsttodo!()cores.obs-source: portimplements the core and the six exports.destroying()and the three workers stay C behind the new adapter fileobs-source-frame-wrappers-fields.c.h(declared inobs-internal.h). The extracted C moves to the reference-only grouplibobs.ported-source-frame-wrappers.Contract
obs_source_set_video_frame()/_set_video_frame2()hand it to the preload worker (upstream quirk, characterized, not endorsed).obs_source_frameentries copy the caller's whole struct and replace onlyfull_rangewithobs_source_frame_copy_full_range(format, full_range).obs_source_frame2entries build a zeroed frame of allMAX_AV_PLANESdata/linesize pairs, width, height, timestamp, format, flip, flags, trc,color_matrix,color_range_min/_max, withfull_range = obs_source_frame_copy_full_range2(format, range)andmax_luminance = 0.Tier 3 (
frame_wrappers_parity,oracle/source_frame_wrappers.c) runs the original C and the Rust exports on a real private source over the same production adapters, withdestroying()(reading the real field) and the three workers routed through recorders, and compares for every call: which worker runs, its source, whether its frame pointer is NULL, the caller's or a copy, and every field of the copy as bits (NaN, infinities and denormals included). It checks the Rust mirrors of both frame structs against the C layouts (sizes and every offset), pins the characterized answers, rejects four export mutants (set NULL to the set worker, the caller's frame passed through, the NULL check beforedestroying(), theobs_source_framerange rule onframe2), and runs a proptest over random frames, ranges, formats and destroying values.No intentional differences. No public-header, existing-C-test, WebSocket or workflow edits. Tier 4 does not apply.
Test cost: new Rust tests are each under 0.1 s in debug, with or without
OBS_PARITY_CASES=reduced; the proptest peaks at 12.9 MB over 25 runs; no threads of their own (the three recorder tests run in one isolated child process each, as the shared recorder needs).Evidence
RED (commit 3, cores
todo!()):GREEN (commit 4, after rebasing onto the cea708 port #5752):
Mutation checks on the safe core (each reverted): set_video_frame NULL to the set worker;
full_rangenot replaced; NULL check beforedestroying();frame2max_luminancenot zero. Each fails Tier 1 and all three recorder-based Tier 3 tests; an equivalent rewrite (control) passes 11/11.Tier 2 (
OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 3 --tests 'test_source_frame_wrappers|test_async_overflow_clock|test_media_restart_stale_frame|test_source_deinterlace|test_deinterlace_mode_load|test_async_audio_own_clock'):[ PASSED ] 7 test(s).for both hybrid (libobs/libobs.so.30) and the C reference (libobs-c-reference/libobs.so.30), on the characterization commit and again on GREEN after the rebase.🤖 Generated with Claude Code