Repository navigation
libobs: Port the source registration rules to obs-core - #1929
Merged
Merged
Conversation
rdoupe
force-pushed
the
port/obs-module-slice4
branch
from
October 23, 2026 12:07
9ef1b3c to
d41def1
Compare
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 23, 2026
rdoupe
force-pushed
the
port/obs-module-slice4
branch
from
October 23, 2026 12:48
d41def1 to
2c95bd4
Compare
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 23, 2026
rdoupe
force-pushed
the
port/obs-module-slice4
branch
2 times, most recently
from
October 23, 2026 14:12
9889131 to
576e0cf
Compare
zackees
enabled auto-merge
October 23, 2026 14:13
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 23, 2026
rdoupe
force-pushed
the
port/obs-module-slice4
branch
from
October 23, 2026 14:55
576e0cf to
fc720ab
Compare
zackees
enabled auto-merge
October 23, 2026 15:12
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 23, 2026
Adds test_source_registration, a characterization of obs_register_source_s() ahead of the port of its rules to obs-core (slice 4 of obs-module.c.h, obs-rust#1876). Public API only: obs_register_source_s() with crafted obs_source_info structures and sizes, observed through obs_enum_source_types(), the input, filter and transition lists, obs_enum_input_types2(), obs_get_source_output_flags(), obs_source_get_display_name(), free_type_data and the log handler (every message and its level, in order). Covered: - the list each type goes in (input, filter, transition; a scene in none; any other type rejected); - a duplicate id and version, and another version of the same id; - the size limit, and sizes that cut the structure before get_name, get_width, get_height, audio_render, free_type_data, the flags, the type and the version; - the flag rules: an audio-only filter made async, a transition made composite, video and custom draw, with its get_width/get_height warnings; - the composite checks (audio before async) and the required callbacks (get_name, get_width, get_height, audio_render) and their order; - the versioned id, with the version printed as an int; - which check wins when several fail, and when the type data is freed. Registered in test-graph.json like test_service_settings, under xvfb-run where a display is needed. 10 of 10 on the C backend libobs. Refs obs-rust#1876
…es.c Moves the pure decisions of obs_register_source_s() from obs-module.c.h to libobs/obs-module-source-rules.c.h, ahead of their port to obs-core (obs-rust#1876). Behaviour-neutral: no public function, header or signature changes. Five hidden entry points, declared in obs-internal.h without EXPORT: - obs_module_source_rules_list_of(): the list of a type (input, filter, transition; none for a scene; unknown for anything else); - obs_module_source_rules_size_supported(): size is not above the structure libobs knows; - obs_module_source_rules_output_flags(): an audio-only filter made async, a transition made composite, video and custom draw; - obs_module_source_rules_check(): the first composite or required callback rule broken, in the C's order. It takes the caller's type and flags for the get_width/get_height rule and the normalized flags for the composite rules, as the C reads them, and a bit for each callback HAS_VAL() finds inside the size; - obs_module_source_rules_versioned_id(): "<id>_v<N>" through dstr_printf() with (int)version, or bstrdup(id) for version 0. obs_register_source_s() keeps the duplicate lookup, the module's source list, the memcpy, the HAS_VAL() size checks, the transition get_width/ get_height warnings, the da_push_back() calls, every log message (the same text, level and order, picked from the returned code) and HANDLE_ERROR. The file joins libobs.core for now, as the earlier slices did before their ports. test_source_registration: 10 of 10 on the C backend libobs, as before the move. Refs obs-rust#1876
The safe core of libobs/obs-module-source-rules.c.h (obs-rust#1876) as todo!() stubs in rust/obs-core (module_source_rules), and its Tier 1 tests: - list_of(), size_supported(), output_flags(), check() and versioned_id(), on u32 types and flags, a Callbacks set for the callbacks HAS_VAL() finds, and the id as bytes (None for NULL); - the ten cases of test_source_registration one to one, in the same order, with the same ids, sizes and messages, through a model of obs_register_source_s() built on the core (the list, the duplicate lookup, the size, the copy cut at the size, the flags, the callbacks inside the size, the check, the versioned id, the log and the freed type data); - the edges of each function, and five 2048-case proptests: unknown past the scene type, normalization only adding its bits, the first rule broken in the C's order, the size limit, and the id with the version printed as an int. 21 tests; 20 fail on todo!() (Callbacks::from_bits is not a stub). Refs obs-rust#1876
Ports libobs/obs-module-source-rules.c.h to the module_source_rules module of rust/obs-core. Every obs_register_source_s() (every source type libobs and its modules register) takes its list, size, flag, composite and required callback decisions and its versioned id from it. The hybrid libobs drops the C file and links the Rust shims; obs-module.c.h keeps the duplicate lookup, the module's source list, the copy, the HAS_VAL() size checks, the type lists, the logging and HANDLE_ERROR. Safe core (src/module_source_rules.rs), on u32 types and flags: - list_of(): input, filter, transition, none for a scene, unknown for anything else; - size_supported(): size <= supported; - output_flags(): a filter without video gets ASYNC, a transition COMPOSITE | VIDEO | CUSTOM_DRAW; every other bit is kept; - check(): the first rule broken, in the C's order (composite audio, composite async, get_name, get_width, get_height, audio_render), with the caller's type and flags for the get_width/get_height rule and the normalized flags for the composite rules; - versioned_id(): the id, "_v" and the version as an i32, or a copy of the id for version 0 (None for NULL; "(null)" with a version, as the C's "%s" prints it). Nothing panics, indexes or overflows; the module denies clippy's indexing, arithmetic, unwrap and panic lints. Kept as the C has it, characterized and not endorsed (obs-rust#1876): the two reads of the flags, which can differ only for a structure cut before its type or flags end, and such a source always fails; the version printed as an int. No intentional differences. Shim (src/ffi/module_source_rules.rs): the five C signatures, the enums as u32 (32-bit on every target), the callbacks as the C's OBS_MODULE_SOURCE_RULES_HAS_* bits and the versioned id bmalloc'd. C side: the file leaves libobs.core for its own group, libobs.ported-module-source-rules (LIBOBS_PORTED_SOURCES), whose PCH is obs-internal.h, so the C reference and the C backend keep compiling it. The functions are declared in obs-internal.h without EXPORT, so the shims are hidden: rust-hidden.txt, rust-exports.map and rust-unexports-macos.txt. libobs-rust already re-exports obs-core's ffi. ci/test_ported_sources.py expects the object in the ported inventory on Linux, Windows and macOS. Results: Tier 1 21 of 21. test_source_registration (10 of 10, under a private Xvfb) passes against the C-backend libobs, the hybrid libobs (the five symbols are the Rust shims, local, and no obs-module-source-rules object is linked) and libobs-c-reference (which still compiles the C). With the todo!() core the hybrid run aborts in obs_startup() (exit 134, "not yet implemented"). Refs obs-rust#1876
…ginal C Adds oracle/module_source_rules.c, the unmodified libobs/obs-module-source-rules.c.h with its five entry points renamed to oracle_*, its dstr_printf the dstr oracle's (the original util/dstr-libc.c), and module_source_rules_parity in obs-tests-core (12 tests). Compared, as the C enum codes are returned: - list_of over 13 types around the enum and both ends of u32; - size_supported around sizeof(struct obs_source_info) and both ends of size_t; - output_flags and check exhaustively: 13 types x every subset of the five flags the rules read, for the caller's and the normalized flags, x all 16 callback sets (and high flag bits for output_flags); - versioned_id over 8 ids (NULL, empty, '%' sequences, bytes outside ASCII) x 11 versions around both ends of int; - the whole decision of obs_register_source_s(): each side's five functions in the C's order, the copy cut at the size, for 5 types x 32 flag sets x 3 callback sets x 28 sizes around every field end the registration reads; - six 2048-case proptests: any type, size, flags, callback bits, id and version, and the registration over type, flags, size, callback mask and version. Refs obs-rust#1876
…ration rules - rust/README.md: obs-module-source-rules.c.h in the obs-core crate row, and its row in the port table (what moved, what stays C, the characterized cases, no intentional differences, Tier 2 and Tier 3); - docs/rust-port/naming.md, the obs-core Cargo.toml description and the lib.rs docs: the new unit; - port_comparison: module_source_rules/list_of, size_supported, output_flags, check and versioned_id (unversioned and versioned), in their own file. Refs obs-rust#1876
rdoupe
force-pushed
the
port/obs-module-slice4
branch
from
October 23, 2026 15:38
fc720ab to
f060068
Compare
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 23, 2026
6 of 7 tasks
This was referenced Oct 23, 2026
Closed
This was referenced Oct 23, 2026
This was referenced Oct 23, 2026
Closed
MCPVOT
pushed a commit
to MCPVOT/obs-studio
that referenced
this pull request
Oct 30, 2026
…-rust#1997) (obs-rust#2554) * test: require the port_comparison units to be discovered, not listed (obs-rust#1997) RED: the ci test demanded the hand-kept `#[path] mod` lines and the `modules![...]` call in `port_comparison.rs` stay sorted. It now fails if either list exists and requires the two generated includes instead. `uv run -m unittest discover -s ci -p test_sorted_shared_lists.py`: test_port_comparison_units_are_discovered FAILs, assertNotRegex matched `#[path = "port_comparison/audio.rs"]`. * build: Generate the port_comparison unit list from the directory (obs-rust#1997) GREEN: build.rs enumerates benches/port_comparison/*.rs and writes the #[path] module lines and the run_units() call list into OUT_DIR, so a port adds its own file and edits nothing shared. That was the last hand-kept list every port appended to; two ports on one file collided in the merge queue (obs-rust#1922 vs obs-rust#1928, obs-rust#1929 vs obs-rust#1922). The file stem is the module name, so core.rs becomes core_units.rs (a `mod core` at the crate root would make the units' `use core::ffi` paths ambiguous). Absolute #[path] rather than `mod x { include!() }` because the units open with //! inner docs, which include! cannot carry. Verified: `soldr cargo check -p obs-c-oracle --benches` is clean, and a throwaway zzz_probe.rs appeared in the generated run_units() and compiled with no edit to a shared file. ci/test_sorted_shared_lists.py passes.
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.
Refs #1876 (slice 4 of
obs-module.c.h; more slices may follow). Unit 9 of #1846.What and why
The fourth slice of
libobs/obs-module.c.hmoves torust/obs-core: the pure decisions ofobs_register_source_s(). Those are the list a source type goes in, the size limit, the output flag rules, the composite and required callback checks, and the versioned id.Feasibility. No seam is needed.
obs_register_source_s()passes the type, the flags, the size, the version and a bit for each callback thatHAS_VAL()finds, and it gets back a list or an error code. The duplicate lookup (get_source_info2()), the module's source list (loadingModule), thememcpy, the size-awareHAS_VAL()checks, the transitionget_width/get_heightwarnings, theda_push_back()calls, every log message andHANDLE_ERRORstay C. C logs from the returned code, with the same text, level and order as before.No exported function moves, so there is no
rust-exports.dfragment, and the 1766 exported symbols are unchanged. The unit is its own file,obs-module-source-rules.c.h(Rustobs_core::module_source_rules). The hybrid build drops a ported file's C, so the new functions can't go into one of the earlier slices' files. Still inobs-module.c.h: the decision chain ofload_all_callback()and the output, encoder and service registration (later slices). Overlap: #1926 (slice 3) is open and touches the same README rows, lists and lib.rs docs, but notobs_register_source_s(). This branch is based onmaster, and the shared rows will be rebased after #1926 lands.Commits:
test: Characterize the source registration rules: a new cross-platform test,test_source_registration, registered intest-graph.jsonliketest_service_settings(underxvfb-runwhere a display is needed). It uses the public API only.obs_register_source_s()gets craftedobs_source_infostructures and sizes, and the result is read back throughobs_enum_source_types(), the input, filter and transition lists,obs_enum_input_types2(),obs_get_source_output_flags(),obs_source_get_display_name(),free_type_dataand the log handler (every message and its level, in order). Covered:get_name,get_width,get_height,audio_render,free_type_data, the flags, the type and the version;get_width/get_heightwarnings;int;libobs: Move the source registration rules into obs-module-source-rules.c: a behaviour-neutral extraction that changes no public function, header or signature. It adds five hidden entry points:obs_module_source_rules_list_of,_size_supported,_output_flags,_checkand_versioned_id.port_comparison.The two reads of the flags. The C reads the caller's structure for the list and for the
get_width/get_heightrule (info->type,info->output_flags). It reads its copy, cut at the caller's size, for the flag rules and the composite rules (data.type,data.output_flags)._check()takes both, as the C has them.get_width/get_heightrule skips both. So the two reads can differ only when the size cuts the copy before its type or flags end.get_name, so it always fails. The two reads change which message is logged, never whether a source is registered.test_short_sizepins the cases where the message changes. A mutant that makes theget_width/get_heightrule read the normalized flags passestest_source_registration10/10 on the hybridlibobs. Tier 1 and Tier 3 catch it.This is not a bug that changes behaviour, so it is kept as it is.
Safe core (
rust/obs-core/src/module_source_rules.rs):list_of,size_supported,output_flags,check(withCallbacks) andversioned_id.u32, so a value outside the enum is kept as its bits. Flag bits that the rules don't name are kept.Optionfor NULL. With a version, a NULL id prints as(null), as the C's"%s"prints it. libobs never gets there: a NULL id crashes in the duplicate lookup first.Shim (
src/ffi/module_source_rules.rs): the five C signatures.u32: 32-bit on every target (unsigned intwith GCC and Clang,intwith MSVC).OBS_MODULE_SOURCE_RULES_HAS_*bits.bmalloc'd, and the caller owns it.libobs/obs-module-source-rules.c.hmoves tolibobs.ported-module-source-rules(PCHobs-internal.h). The five symbols are hidden throughrust-hidden.txt,rust-exports.mapandrust-unexports-macos.txt.Kept, characterized, not endorsed:
int:2147483648gives_v-2147483648, andUINT32_MAXgives_v-1.obs-module.c.h(still C): the duplicate lookup reads the caller's version even when the size cuts it off. Such a type is then registered unversioned (its copy has version 0), and a later registration of the same id with version 0 is a duplicate.type_dataandfree_type_data.get_name.Intentional differences: none.
RED → GREEN
Characterization: e089bc4.
test_source_registrationgives 10/10 on the C backendlibobs. At the extraction (6201153) it is 10/10 on the C backendlibobs, the hybridlibobsandlibobs-c-reference.RED commit: 65f18ab
libobs: Add Tier 1 tests for the source registration rules port.obs_core::module_source_ruleshas 21 tests:obs_register_source_s()built on the core;20 of them fail on
todo!();Callbacks::from_bitsis not a stub. With thetodo!()core linked into the swapped hybridlibobs,test_source_registrationaborts inobs_startup()(exit 134, "not yet implemented" inmodule_source_rules.rs).GREEN: b8992f1
libobs: Port the source registration rules to obs-core. Tier 1 21/21. Tier 2:test_source_registration10/10 against the hybridlibobsandlibobs-c-reference.libobs, the fiveobs_module_source_rules_*symbols are the Rust shims (local), and noobs-module-source-rulesobject is linked.libobs-c-referenceand the C backend still compile the C.Tier 3: 71fab4c (
module_source_rules_parity.rs, 12 tests). The oracle is the unmodified C file with its entry points renamed. Itsdstr_printfis the originalutil/dstr-libc.c, through the dstr oracle. Compared, as the C enum codes are returned:list_ofover 13 types around the enum and both ends ofu32;size_supportedaroundsizeof(struct obs_source_info)and both ends ofsize_t;output_flagsandcheckexhaustively: 13 types × every subset of the five flags the rules read, for both the caller's and the normalized flags, × all 16 callback sets;versioned_idover 8 ids (NULL, empty,%sequences, bytes outside ASCII) × 11 versions around both ends ofint;obs_register_source_s(): each side's five functions in the C's order, with the copy cut at the size, for 5 types × 32 flag sets × 3 callback sets × 28 sizes around every field end the registration reads;Mutation check: 22 mutants of the safe core, each reverted (not committed). Each cell is the number of failing tests:
<for<=get_width/get_heightrule reads the normalized flagsget_width/get_heightget_width/get_heightget_width/get_heightget_heightnot requiredget_namechecked after the size ruleaudio_renderalways requiredaudio_rendernever requiredget_widthandget_heightbits swapped-vfor_vTwo mutants were also run through Tier 2 against the hybrid
libobs:"composite rules read the caller's flags":
test_source_registration7/10.test_short_size,test_transition_flagsandtest_compositefail."
get_width/get_heightrule reads the normalized flags": 10/10. It changes no registration (see "The two reads of the flags").Rebased several times as other ports landed: onto
452bd9661(libobs: Port the module locale files to obs-core #1926),739a3c0f2(obs-media-io: Port media-io/media-remux.c.h #1928, test: fix the source_profiler_parity race (#1930) #1931),ed71dc387(obs-scene: Port the group content extent #1922),dc5b192c9(test: characterize obs-view before the Rust port (#1933) #1934),b4a58944c(obs-core: port obs-view to Rust (#1933) #1935) andf53d2fdbc(obs-source: Port the source audio timestamp placement #1936). The conflicts were only in shared lists and rows: the obs-corerust/README.mdrow,naming.md, the obs-coreCargo.tomldescription, thelib.rsdocs, the port_comparison bench list andtest/cmocka/build/test-graph.json. After the latest rebase,ci/test_build_groups.py,ci/test_ported_sources.py, the native build-graph tests,obs_core::module*in obs-tests-core (obs_core::271/271 after the latest) and the lint lane were re-run and pass.Local runs used two build trees (
OBS_LIBOBS_BACKEND=C, andHYBRIDwithOBS_BUILD_C_REFERENCE=ON), headless, with a private Xvfb (-noreset), a private D-Bus and a fresh HOME, at 251192c90. The pre-rebase head, 9ef1b3c, differed from it only by rustfmt line wrapping in the two Rust test files:test_source_registrationtest_core_module_loadlibobslibobslibobs-c-referencesoldr cargo test -p obs-data --test obs-tests-core: 989/989 (one earlier run had 988/989:obs_core::source_profiler_parity::parity_random_sequences, which fails intermittently onmastertoo and is not touched here) (obs_core::module_source_rules*33/33).soldr cargo test -p obs-core: passed.ci/local_gate.py --lane lintand--lane cross: passed.ci/test_build_groups.py,ci/test_ported_sources.pyandci/test_oracle_standins.py: passed.port_comparison:soldr cargo bench -p obs-c-oracle --bench port_comparison -- module_source_rules, 3 passes pinned to one CPU, Linux x86_64, rustc 1.98.1. Each call runs once per registered source type, at startup and when a module loads.checkconverts the callback bits toCallbacksand maps the result to the C code.Vec, thenbmalloc); the C copies it once.vsnprintf.Windows/macOS: the cross lane compiles and links the shims, but they were not run locally.
test_source_registrationis a cross-platform test, but no native Windows or macOS run built it locally. On Windows and macOS, PR CI's Rust lanes run Tier 1 and Tier 3, and the merge queue's Tier 2 runs the C test. The oracle prints a NULL id with the C library's"%s"(glibc here, the UCRT on Windows, libc on macOS). All three print(null), as the core does.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag changes)