Skip to content

rust: Port libobs/obs-video-level-queries.c.h to obs-core #5187

Open

Description

@zackees

Unit

Port the entire extracted libobs/obs-video-level-queries.c.h to obs-core, preserving obs_get_video_sdr_white_level and obs_get_video_hdr_nominal_peak_level. This is the separate Rust swap following the C-only characterization/extraction prerequisite #5168; wait for that prerequisite to merge and be verified before implementation.

Phase and position

Phase 6 core query boundary, following the already ported level-setting admission rules. Preserve the two query bodies' behavior without changing obs_set_video_levels, its validation policy, graphics backends or any other core query.

Dependencies and existing tests

Blocked by #5168. Its test/cmocka/test_video_level_queries.c pins NULL-core defaults before and after synthetic live-core use, graphics-absent defaults despite stored fields, exact asymmetric stored float routing with graphics present, signed zeros, negative values, infinities, quiet NaN payloads, smallest normal and largest finite values, and unchanged core state/global pointer after each query. Float assertions require exact binary32 bits, with no approximate comparison. The test uses actual private core/graphics types without allocating resources, starting a backend or creating threads.

Relink that unchanged C-source fixture to the Rust replacement and real private adapters in its canonical graph registration; do not leave it exercising only the retained C oracle. Preserve its tests.d pointer, availability and sorted graph registration. Retain unchanged actual-library coverage in test_no_core_getters and test_video_levels_range against both implementations.

Notes and required evidence

Reject a NULL core before taking its video address or calling a C field adapter. Without a core or graphics return exactly 300.0f (0x43960000) and 1000.0f (0x447a0000). Otherwise return each corresponding stored field's exact bits, without validation, clamping, arithmetic, writes or allocation. Keep the owner opaque and private field access behind real C adapters; do not guess private Rust layouts or change public headers. Use a real graphics_t fixture object, not an underaligned char cast; MSVC has no max_align_t.

Commit safe-core Tier 1 assertion mirrors against failing stubs before GREEN. Add modules to the existing owning obs-core suite in the Core state category (soldr cargo test -p obs-data --test obs-tests-core), never a new test binary. Keep Tier 2 C tests and public headers unchanged; check exact public symbol parity and any necessary real-header size/alignment/all-field offsets. Tier 3 must compare the safe core and thin ABI shim against the original extracted C oracle with bounded random bit patterns and fixed edge cases, excluding only genuinely undefined input domains, and demonstrate a mutation failure. Tier 4 is inapplicable to this non-protocol query; preserve the unchanged C++ OBS WebSocket compatibility plugin.

Any real C adapter must be linked into every affected standalone Rust-static consumer using tests.d link-support fragments that compile the actual adapter source, never aborting stubs or placeholder globals. Adapters that reference graphics/runtime symbols can break unrelated static links. Before publishing, run ci/windows_link_check.py and a focused Linux Tier 2 build of at least two unrelated *_rust cmocka targets, using the release archive where archive-member selection matters. Type platform-width helpers and generated ranges directly as c_long/c_ulong: these are 32 bits on Windows and 64 bits on Linux/macOS, and .into() can fail Windows clippy as a useless conversion.

Run the entire native_build:: module and repository lint. Keep all source/module inventories and unity membership consistent and sorted. No existing C test, public-header, CI, workflow or WebSocket plugin changes. Rust through soldr, Python through uv, publication through ./push; use Refs and confirm empty closing references.

Refs #5168
Refs #2566
Refs #2209

Activity

  1. added
    portPort a C unit to Rust (four-tier policy)
    readyMeets the definition of Ready; claimable
    P2Normal priority
    on Nov 19, 2026
  2. rdoupe commented on Nov 19, 2026

    @rdoupe
    Collaborator

    Claiming: #5187 (swap obs_get_video_sdr_white_level and obs_get_video_hdr_nominal_peak_level to safe Rust in obs-core).

    Plan, one PR:

    1. RED: mirror test_video_level_queries.c as Tier 1 tests in the Core state binary against failing stubs.
    2. GREEN: safe core + thin FFI exports, private C field adapters (real sources, tests.d link-support), relink the unchanged C fixture to the Rust replacement, Tier 3 differential against the extracted C oracle with a mutation check.
  3. rdoupe commented on Nov 19, 2026

    @rdoupe
    Collaborator

    PR is up: #5196 (RED fc7b390, GREEN 1303511a4; Tier 1/2/3 evidence in the body). Auto-merge is armed, so it queues once PR CI is green.

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

Metadata

Metadata

Assignees

Labels

P2Normal priorityportPort a C unit to Rust (four-tier policy)readyMeets the definition of Ready; claimablesize:SHours

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions