Skip to content

obs-output: port the obs-service getters to Rust (#1899) - #1904

Merged
zackees merged 4 commits into
masterfrom
port/1899-service-getters
Oct 23, 2026
Merged

zackees merged 4 commits into
masterfrom
port/1899-service-getters

Conversation

@zackees

@zackees zackees commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Refs #1899 (#1846 unit 8, slice 1). Stacked on #1901, the characterization (queued); its commits show here until it merges.

Commits

  • RED 26da896: obs-output/src/service.rs with todo!() stubs, plus Tier 1 tests/output/service.rs, which mirrors every case of test_service_getters.c. All 8 fail.
  • The safe core: Tier 1 passes. It keeps the C's check-and-zero order, including the characterized max_bitrate zero-before-check, and the C's obs_ptr_valid function and parameter names (obs_service_get_info for connect info).
  • GREEN 58f0139: the swap.
    • The nine exported getters move from obs-service.c.h to obs-service-getters.c.h, in a new group libobs.ported-service-getters (LIBOBS_PORTED_SOURCES). The hybrid libobs replaces the group with the shims in obs-output::ffi::service, which are exported through rust-exports.d/obs-output-service.txt. The C reference keeps the C.
    • struct obs_service stays private to C. Two hidden accessors next to it, obs_service_get_info_table() and obs_service_get_plugin_data() (declared in obs-internal.h), give the C file and the shims the plugin's callback table and data.
    • ObsServiceInfo mirrors the public struct obs_service_info.
  • Tier 3 service_parity.rs, against rust/obs-c-oracle/oracle/service_getters.c, which compiles the unmodified obs-service-getters.c.h with oracle_* names.
    • The C and the shims run on the same struct obs_service over all 256 optional-callback tables, with NULL and sentinel out-parameters. Both sides must agree on return values, out-parameters and the plugin call trace (data pointer and arguments).
    • The mirror's size, alignment and 27 field offsets equal the C's.
    • Mutation check (not committed): a can_try_to_connect default of false, and a video bitrate that isn't zeroed, both fail Tier 3.
  • port_comparison (cargo bench -p obs-c-oracle --bench port_comparison -- service/, criterion median, this host):
getter Rust C
get_protocol 3.57 ns 3.86 ns
get_connect_info 4.17 ns 5.14 ns
can_try_to_connect (no callback) 3.82 ns 2.60 ns
get_max_bitrate 8.97 ns 10.45 ns

The getters are a few nanoseconds either way. The callers (stream start, settings) call them a handful of times.

Tiers

  • Tier 1: 8 tests. Tier 3: 2 tests. All pass locally (soldr cargo test -p obs-data --test obs-tests-core output::service). ./lint is clean.
  • Tier 2: test_service_getters (test: characterize the obs-service getters before the Rust port (#1899) #1901) through the hybrid and reference libobs, which PR CI runs. My local Tier 2 lane can't see new files in this clone's bind mount, which is an environment issue, not the change.
  • Tier 4: none, as there is no protocol surface.

Create, destroy, references and activation stay in C. That next slice gets filed on #1846 when this lands.

@zackees
zackees force-pushed the port/1899-service-getters branch from 1b7eab0 to 92a5c99 Compare October 23, 2026 06:08
@zackees
zackees marked this pull request as ready for review October 23, 2026 06:34
@zackees
zackees force-pushed the port/1899-service-getters branch from e30abd2 to 8482924 Compare October 23, 2026 06:39
@zackees
zackees force-pushed the port/1899-service-getters branch from 8482924 to 09bc1fd Compare October 23, 2026 07:00
@zackees
zackees force-pushed the port/1899-service-getters branch from 09bc1fd to b7f0815 Compare October 23, 2026 07:27
@zackees
zackees added this pull request to the merge queue Oct 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 23, 2026
The nine exported getters move from obs-service.c.h to
obs-service-getters.c.h in their own unity group,
libobs.ported-service-getters, which the hybrid libobs replaces with the
Rust shims in obs-output's ffi::service (rust-exports.d). struct
obs_service stays C: the hidden obs_service_get_info_table() and
obs_service_get_plugin_data() beside it give the C file and the shims the
plugin's callback table and data. The shims mirror struct obs_service_info.

Tier 3 (service_parity): the C oracle and the shims run on the same
service over all 256 optional-callback tables with NULL and sentinel
out-parameters, comparing returns, out-parameters and the plugin call
trace; the mirror's size, alignment and 27 field offsets match the C.
Mutants (can_try default false; video bitrate not zeroed) fail it.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant