Skip to content

obs-source: port obs_source_enum_active_sources and obs_source_enum_active_tree to Rust (Fixes #5729) - #5735

Draft
zackees wants to merge 4 commits into
masterfrom
port-5729-enum-active
Draft

zackees wants to merge 4 commits into
masterfrom
port-5729-enum-active

Conversation

@zackees

@zackees zackees commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Fixes #5729.

Ports obs_source_enum_active_sources() and obs_source_enum_active_tree() (with the static enum_source_active_tree_callback()) to obs-source::enum_active, following the #5633 pattern.

Commits:

  1. Extraction (behaviour-neutral): the bodies move verbatim from obs-source.c.h into libobs/obs-source-enum-active.c.h in the live core-source group. data_valid() and struct source_enum_data are file-local in obs-source.c.h, so the new file has its own copies under scoped names, mapped onto the original names with macros that it undefines at the end.
  2. Characterization: new cmocka test_source_enum_active (tests.d + test-graph.json, same host conditions as test_source_active_child). It covers a NULL source (one LOG_DEBUG line), a type without enum_active_sources (does nothing), direct children only, the depth-first post-order tree, a shared child (reported once per edge), and a walk from an inner node.
  3. RED: Tier 1 mirrors in obs-tests-core (rust/obs-source/tests/source/enum_active.rs), plus the dying-source, no-data and transition cases, run against todo!(): 0 passed; 14 failed ... not yet implemented: #5729.
  4. GREEN: a safe core over a Libobs trait, and C ABI shims in ffi/source_enum_active.rs.
    • The context data, type, callback presence and the plugin call go through the new libobs/obs-source-enum-active-fields.c.h (live group, no EXPORT).
    • obs_transition_enum_sources(), obs_source_get_ref() and obs_source_release() go through Calls.
    • The tree callback is a generic extern "C" fn.
    • The extracted file moves to the reference-only group libobs.ported-source-enum-active+. Its exports are listed in rust-exports.d/obs-source-source_enum_active.txt, with a registration test and a README row.

Tiers:

  • Tier 1: 14 cases, green.
  • Tier 2: the new test_source_enum_active, plus the unchanged test_source_transition_slots, test_slideshow_empty, test_slideshow_manual_end and test_scene_item_set_visibility, against hybrid and reference.
  • Tier 3 (enum_active_parity): the original C (renamed oracle_*) against the Rust shims, on noise-filled real struct obs_source nodes. Both sides use the production field adapters, a scripted plugin callback, and recording stand-ins for the get_ref, release and transition calls. It compares every call and reported edge in order (including whether the caller's callback and param were passed), the log lines and every byte. Inputs: a 288-case grid, pinned answers and a 512-case proptest. Four mutants are rejected. Result: 15 passed together with Tier 1.
  • Tier 4 doesn't apply.

The test-only obs_source_enum_active_tree() stand-in in oracle/audio_callback_links.c has been removed, because the Rust export now defines that symbol in the test binaries. The audio_callback and active_child suites still pass (65 tests).

Intentional differences: none. Left out as undefined input: a NULL child reported to the tree walk (the C dereferences it).

Local evidence:

  • Full ./lint passed (333 s).
  • ./push attested client-lint. client-checks could not run because xmllint is missing on this host, so ordinary PR CI applies.
  • Tier 2 (linux-validate) was rerunning on this head when the PR opened. Its result will be added in a comment.

Overlap (git merge-tree):

Draft and unarmed: back pressure was closed (exit 75) at publish time.

🤖 Generated with Claude Code

…tive_tree verbatim (Refs #5729)

Move the two bodies and the static enum_source_active_tree_callback()
unchanged out of obs-source.c.h into obs-source-enum-active.c.h, still
compiled in the live core-source group. obs-source.c.h's data_valid()
and struct source_enum_data are file-local, so the extracted file carries
copies under scoped names mapped onto the originals with macros it
undefines at its end; the bodies stay verbatim. No Rust, no behavior
change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_active_tree (Refs #5729)

New cmocka test test_source_enum_active (tests.d + test-graph.json) on
private sources of a started core, calling the real libobs exports:
NULL source logs one LOG_DEBUG line per function; a type without
enum_active_sources is a silent no-op; enum_active_sources reports direct
children only in plugin order; enum_active_tree walks depth first,
post-order, reporting (edge parent, child, param), not descending into a
child without the callback, and walking a shared child once per edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tier 1 mirrors of test_source_enum_active in the existing obs-tests-core
binary (rust/obs-source/tests/source/enum_active.rs), on a model of what
the core reaches through obs-source::enum_active's Libobs trait: nodes
listing active children, transitions reporting their slots, the
reference calls, and the caller's and the tree walk's sinks. They also
cover the dying-source, data-less and transition arms. They run against
todo!() cores:

  test result: FAILED. 0 passed; 14 failed
  panicked at rust/obs-source/src/enum_active.rs:67:5:
  not yet implemented: #5729

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ctive_tree to Rust (Fixes #5729)

- Safe core obs-source::enum_active::{enumerate, tree_edge} over a
  Libobs trait: NULL source logged with the function's name, no context
  data or (non-transition) no enum_active_sources returns silently;
  then obs_source_get_ref() (a dying source logs the NULL line),
  transition slots first, the type's enum_active_sources, release.
  tree_edge is enum_source_active_tree_callback() up to the caller's
  callback: a transition child's slots, then (with callback and data)
  its own children, through the tree sink; the edge is reported after.
- C ABI shims in ffi/source_enum_active.rs: fields and the plugin call
  through the new libobs/obs-source-enum-active-fields.c.h (live
  core-source group, no EXPORT); obs_transition_enum_sources(),
  obs_source_get_ref() and obs_source_release() through Calls; the tree
  callback is a generic extern "C" fn over the same Calls.
- The extracted file moves to the reference-only group
  libobs.ported-source-enum-active (+ ported-source-sets JSON); both
  names are EXPORT in obs.h, so they go into
  rust-exports.d/obs-source-source_enum_active.txt.
- Oracle: oracle.d/source-enum-active.list and oracle/source_enum_active.c
  (the original C renamed oracle_*, the production field adapters, a
  scripted plugin callback and recording get_ref/release/transition
  stand-ins). The obs_source_enum_active_tree() stand-in in
  oracle/audio_callback_links.c is removed: the Rust export defines it.
- Tier 3 enum_active_parity.rs: every plugin call (with whether it got
  the caller's callback and param), reference, transition enum and
  reported edge in order, the log lines and every byte, over a grid, a
  proptest and pinned answers; four shim mutants rejected.
- obs-build registration test and a rust/README.md row.

  test result: ok. 15 passed; 0 failed (obs-tests-core enum_active)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ci-Attestation: {"at":1795692230,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":84,"stamp":"ff5f97f4eefad89b44bf6750939420f8","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692230,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":84,"stamp":"e3b9427b067c4fa17966e696380cc571","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692230,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":84,"stamp":"9aeb521a002ec1a31fab7522a6c5f9c8","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692230,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":84,"stamp":"1544ec4b6e0e19b9272cd865a3a4bf18","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692144,"gate":"general/all/client-lint","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"74ba567af3d06b7d83237d1978a2e018","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692230,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":84,"stamp":"77c96206fc9cc46e459e01ee80fa9aff","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692145,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"e4bc0f43eab929b994500b421014d9c3","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692145,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"5fef64a7109ce9d3ee0955a140309d2f","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692145,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"9a87fe9fc603c8526f5c4f5c111572d8","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692145,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"799e15d6f9c09d4f1362ae12dacbb6f1","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692144,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"6c6ea1b9fad46cec630feb1aa70006eb","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692145,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"72e1567cbb921723d85c5a335809b126","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692145,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"8df17712065d4bf5162b892170b87dc4","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692145,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"c50fe0a5243e7ce45be66feee5829ce6","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692145,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"b565de30958451fff70f5669e719c8b1","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692145,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"332d1a7ffd6d36da46075dde5c070f51","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692144,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"163a65bf981695f0d935846fad134b3f","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692144,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"b33f96c72c795bb7614ba8d145ff6d6487152ed48fe6ab04ac401b80943edc17","lane":"client-lint","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":317,"stamp":"577fbd0183784e1dc5e970b007eec7c4","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}
Ci-Attestation: {"at":1795692592,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"9b99fde274313fc3b9a22ae1d56415def455383eb6dd3a28d3a98fc10349c0e8","lane":"client-test-x86_64-unknown-linux-gnu","parents":["587bab794da72171aca961947bff6581a65b0d9c"],"secs":361,"stamp":"d2d38917bcfc1f4cc2b76b578f4974c9","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"e8cbea4dd0142b45229389ff871e402fda40050a","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-enum-active+.h.c","libobs/build/ported-source-sets/source-enum-active.json","libobs/cmake/rust-exports.d/obs-source-source_enum_active.txt","libobs/obs-source-enum-active-fields.c.h","libobs/obs-source-enum-active.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_enum_active_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-enum-active.list","rust/obs-c-oracle/oracle/audio_callback_links.c","rust/obs-c-oracle/oracle/source_enum_active.c","rust/obs-source/src/enum_active.rs","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_enum_active.rs","rust/obs-source/src/lib.rs","rust/obs-source/tests/source/enum_active.rs","rust/obs-source/tests/source/enum_active_parity.rs","rust/obs-source/tests/source/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_source_enum_active.c","test/cmocka/tests.d/test_source_enum_active.cmake"],"head":"eb9d29f1ef877d7cf2585bb33c630b80bd865a7c","tools":{"orchestrator-python":"3.13.15 (main, Aug 14 2026, 15:34:59) [Clang 22.1.3 ]","schema-dependencies":"3.13.15 (main, Aug 14 2026, 15:34:59) [Clang 22.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 21503\n   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ISO8859X Regexps Automata RelaxNG Schemas Modules Debug"},"tracked-digest":"23cd197c720122a65e8651063775476e44cdd1ee07236721caf5a4aaecfdce42","tree":"41e0ec99e986d891e09a26d0a61d31876ab95a66"}}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs fix

Development

Successfully merging this pull request may close these issues.

rust: port obs_source_enum_active_sources and obs_source_enum_active_tree to obs-source

1 participant