Skip to content

rust: port get_new_filter_name and filter_compatible to obs-source #5978

Done

Description

@rdoupe

get_new_filter_name() and filter_compatible() in libobs/obs-source.c.h (~314-332 and ~769-772 on master, 914f81f) are still C. Both are internal (obs-internal.h, no EXPORT) and called from already-ported code: the copy-filters fields adapter (obs-source-copy-filters-fields.c.h), obs-source-copy-filters.c.h, and obs_source_filter_add (obs-source-filter-add.c.h). Every decision in them is already Rust: obs_source_duplicate_filter_number() (obs-source source_duplicate) and obs_source_filter_chain_compatible() (obs-source source_filter_chain). What is left is the field reads, the by-name lookup calls and the dstr building.

Behavior the port keeps, call for call:

  • get_new_filter_name(dst, name): try name first, then "<name> N" with N from obs_source_duplicate_filter_number(++inc), asking obs_source_get_filter_by_name(dst, candidate) each time and releasing every hit; return a bmalloc'd string the caller frees with bfree (the C returns dstr.array).
  • filter_compatible(source, filter): obs_source_filter_chain_compatible(source->info.output_flags, filter->info.output_flags), one read of each.

The by-name lookup itself (obs_source_get_filter_by_name) stays C and is not part of this unit.

Plan, one PR into obs-source (the shape of #5977):

  1. Extract both verbatim into their own live core-source file, callers unchanged. No behavior change.
  2. Tier 1 RED in obs-source's existing category binary against a todo!() core over a trait for the field reads, the lookup/release calls and the allocation.
  3. GREEN: safe core in obs-source, the two symbols as hidden C ABI exports in ffi/, a one-access field adapter, the extracted file moved to a reference-only ported group.
  4. Tier 3 parity against the original C in obs-c-oracle: free name, one and several taken names, a name ending in a number, compatible and incompatible flag pairs, comparing the returned name and the recorded lookup/release calls.
  5. Tier 2: test_source_copy_filters, test_source_duplicate and test_source_duplicate_steps against the hybrid libobs and the C reference.

No public header, C test or obs-websocket change.

Activity

  1. added
    port
    on Nov 30, 2026
  2. rdoupe commented on Nov 30, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #5978 port of get_new_filter_name and filter_compatible (extract, Tier 1 RED, GREEN, Tier 3 parity, Tier 2), alone, first PR within the next couple of hours.

    1. Extract both verbatim into a live core-source file.
    2. Tier 1 RED against a todo!() core.
    3. GREEN: safe core, hidden ffi exports, field adapter, extracted file to a reference-only ported group.
    4. Tier 3 parity against the original C.
    5. Tier 2: copy-filters and duplicate cmocka cases against hybrid libobs and the C reference.
  3. rdoupe commented on Nov 30, 2026

    @rdoupe
    CollaboratorAuthor

    /ready

  4. added
    ready
    on Nov 30, 2026
  5. added a commit that references this issue on Dec 4, 2026
    0e58a1a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

portready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions