Skip to content

rust: Port the window setting's string codec #3380

Closed

Description

@rdoupe

Unit

Port the string codec of the window setting in libobs/util/windows/window-helpers.c.h to rust/obs-util, in the existing window_match module. Window capture and game capture save the chosen window as one string, title:class:exe, each part escaped (# as #22, then : as #3A), and split it back when the source loads:

  • encode_dstr (7-11): replace-all # with #22, then : with #3A;
  • decode_str (13-20): a copy, then #3A back to :, then #22 back to #;
  • ms_build_window_strings (22-43, EXPORT in window-helpers.h): all three outputs NULL first, a NULL string returns at once, strlist_split(str, ':', true) keeps empty fields, fields 0, 1 and 2 decode as the title, class and exe, later fields are ignored, and with fewer than three fields all three stay NULL.

The core moves into libobs/util/windows/window-match.c.h (the ported-window-match+ group) as three hidden functions over bytes and lengths: ms_window_match_encode (snprintf-style, returns the length needed), ms_window_match_decode (in place, returns the new length) and ms_window_match_split (the first three fields' offsets and lengths, false with fewer than three).

These stay in C: every bmalloc, bstrndup, bfree and dstr_* call, add_window's description and join, insert_preserved_val and ms_check_window_property_setting with their obs_property_list_* calls.

Phase and position

Phase 6, Windows host code, the second unit beside the window match decisions (#3154, merged in #3156). Tracking: #4.

Dependencies and existing tests

  • Builds on the landed window_match module and its ported-window-match+ group; no open PR touches window-helpers.c.h, window-match.* or the module.
  • Real libobs: no test reaches the codec; window-helpers.c.h builds only on Windows.
  • Characterization: test_window_match_steps covers the decisions only; the codec's cases are added to it first. The moved code includes no Windows header, so it runs on every OS.

Notes

One PR, separate commits: the behaviour-neutral move, characterization ("", ":", "::", "a:b:c", "a:b:c:d", "a:b", "#", "#22", "#3A", "#223A", "##3A22", "#2222", lower-case "x#3a", NULL, and round trips), RED, GREEN, Tier 3 (random byte strings rich in #, :, 2, 3, A, and the round-trip property), docs.

No intentional difference is expected. dstr_replace replaces non-overlapping matches scanning forward and never rescans its own output ("#2222" decodes to "#22"); the Rust works the same way, on bytes rather than UTF-8. ms_build_window_strings stays EXPORT and its NULL outputs ("no saved window") stay exactly as they are.

Activity

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

    @rdoupe
    CollaboratorAuthor

    Claiming: the window setting's string codec port.

    Plan, one PR:

    1. Move the codec's core out of encode_dstr, decode_str and ms_build_window_strings into libobs/util/windows/window-match.c.h as three hidden functions (ms_window_match_encode, ms_window_match_decode, ms_window_match_split); every allocation, free and dstr_* call stays in window-helpers.c.h.
    2. Characterize them in test_window_match_steps (cmocka, every OS).
    3. RED: obs_util::window_match Tier 1 against todo!().
    4. GREEN: the safe core and the shims in src/ffi/window_match.rs, hidden.
    5. Tier 3: oracle and parity tests over #/:-rich byte strings, the round trip, and a mutation check.
    6. Docs.

    Draft PR expected today.

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

    @rdoupe
    CollaboratorAuthor

    Fixed by PR #3386 (merged through the merge queue as b447b30): the window setting's string codec (encode_dstr, decode_str and the split in ms_build_window_strings) now has its core in obs_util::window_match, with the moved C in window-match.c.h, the Rust shims behind it, and Tier 1, Tier 2 and Tier 3 coverage. No intentional difference from the C.

    What's left: nothing of this unit. The allocations and frees, the dstr_* calls, add_window's description and join, and insert_preserved_val / ms_check_window_property_setting with their property-list calls stay in C by design.

    Follow-up issue: none needed; nothing was carried over.

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