Skip to content

rust: Port the source type lookup to obs-source #4606

Closed

Description

@rdoupe

Unit

libobs/obs-source-info-lookup.c.h (get_source_info, declared in obs-internal.h, hidden) to rust/obs-source, new module info_lookup.

Phase and position

Phase 6, libobs core: obs-source. The extraction to obs-source-info-lookup.c.h is on master; this finishes the file. Its caller obs_source_get_icon_type is already Rust (#4231) and calls back into this C lookup.

Dependencies and existing tests

  • No dependencies: the file is extracted and still compiled in libobs.core-source+.h.c.
  • No characterization test pins the lookup directly. Commit 1 adds test/cmocka/test_source_info_lookup.c: after obs_startup and two registered test source types, it goes through the public calls that use the lookup (obs_get_source_output_flags, obs_source_get_display_name, obs_is_source_configurable, obs_get_source_defaults) and pins that a registered ID finds its type, that an unknown ID, an empty ID and an ID that differs only in case find nothing, and that IDs are compared as whole strings.
  • Existing parity tests nearby: source_icon_type, type_id_getters.

Notes

  • The returned pointer points into the core's source_types array and callers keep it, so the Rust returns the C address, never a copy. A small live adapter (obs-source-info-lookup-fields.c.h) gives the array's address, its count, element size and each entry's id; Rust never reads struct obs_source_info's layout.
  • The compare stays bytewise, like strcmp, and the first match wins.
  • One intentional difference: the C calls strcmp(info->id, id) without checking id, so a NULL ID crashes as soon as any source type is registered. It reaches the lookup through obs_get_source_defaults, obs_is_source_configurable, obs_get_source_output_flags, obs_source_get_display_name, obs_source_get_icon_type and the properties call. The port returns NULL for a NULL ID, which every caller already treats as "not found". The rest of this API forgives NULL. The Tier 3 parity test lists it.
  • No threading: the registry is filled at module load and only read here.
  • Tier 4 does not apply.

Activity

  1. added
    enhancement
    port
    on Nov 10, 2026
  2. rdoupe commented on Nov 10, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: the source type lookup port (get_source_info), with its NULL-ID fix as the one intentional difference.

    1. Characterization: test/cmocka/test_source_info_lookup.c through the public calls that use the lookup.
    2. RED: Tier 1 tests in obs-source against todo!() stubs, plus the NULL ID.
    3. GREEN: the safe core and the C shim over a small fields adapter, returning the C address; its own ported unity group and hidden-symbol fragment.
    4. Tier 3 differential test against the original C over random registries and IDs, with mutation.
    5. Docs: rust/README.md, naming.md, crate docs.

    Draft PR at RED within a few hours.

  3. added
    ready
    on Nov 10, 2026
  4. rdoupe commented on Nov 10, 2026

    @rdoupe
    CollaboratorAuthor

    Progress: GREEN, Tier 3 and docs are committed on the branch of #4608 (local gates pass); they go up after review.

    Intentional differences, as listed in the parity test:

    1. A NULL asked ID finds nothing. The C passed it to strcmp, so every caller crashed on it once a type was registered. With the port, obs_source_create_private(NULL, ...) takes the unknown-ID path ("Source ID '(null)' not found") instead of crashing.
    2. A registered NULL ID matches nothing, where the C would also have passed it to strcmp.
  5. 27 remaining items

  6. rdoupe commented on Nov 14, 2026

    @rdoupe
    CollaboratorAuthor

    Blocked: waiting on the merge queue. #4608 is green and mergeable, and goes in once the queue has room.

  7. added
    claim-blocked
    on Nov 14, 2026
  8. removed
    claim-blocked
    on Nov 14, 2026
  9. moved this from In review to In merge queue in obs-rust Multiviewon Nov 14, 2026
  10. rdoupe commented on Nov 14, 2026

    @rdoupe
    CollaboratorAuthor

    Closed by #4608, merged through the merge queue as 932a68c: the source type lookup (get_source_info) now lives in rust/obs-source (module info_lookup), with the C address returned unchanged and one intentional difference: a NULL ID finds nothing instead of crashing in strcmp. The master push run for the merge commit is green (run 43623588540).

    Left: nothing for this unit. No follow-up issue is needed; the next source metadata unit that builds on this lookup is already filed as #4719 (port obs-source-type-info.c.h).

  11. moved this from In merge queue to Done in obs-rust Multiviewon Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementportready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions