Skip to content

rust: Port the obs-service capability and connect-info getters to obs-output (#1846 unit 8, slice 1) #1899

Closed

Description

@zackees

Unit

#1846 unit 8, first slice: the service capability and connect-info getters in libobs/obs-service.c.h (lines 372–466, about 95 lines) → rust/obs-output.

  • obs_service_get_supported_resolutions
  • obs_service_get_max_fps
  • obs_service_get_max_bitrate
  • obs_service_get_supported_video_codecs
  • obs_service_get_supported_audio_codecs
  • obs_service_get_protocol
  • obs_service_get_preferred_output_type
  • obs_service_get_connect_info
  • obs_service_can_try_to_connect

Create, destroy, update, the reference counts and activate/deactivate stay C in this slice. They use obs_context_data (signals, hotkeys, the object list), which belongs to the #444 seam.

Why a slice, not the whole file

#1846 calls obs-service.c.h "public API only", but the getters read the private struct obs_service (service->info.<callback>, service->context.data). So the Rust needs a small exported-to-Rust C accessor: obs_service_info_ptr(service) plus the context data pointer, kept in C next to the struct layout. Rust then does the null checks, out-parameter zeroing and callback dispatch against struct obs_service_info, the public plugin ABI in obs-service.h, mirrored #[repr(C)].

Behavior to keep (characterized, not endorsed where marked)

  • A null service logs through obs_service_valid and returns NULL / false / nothing, for every getter that checks.
  • obs_service_get_supported_video_codecs and ..._audio_codecs do not check for a null service and dereference it (characterized, not endorsed; Tier 2 does not call them with NULL).
  • obs_service_get_protocol calls get_protocol without a NULL check (registration requires it).
  • get_max_bitrate zeroes both out-parameters before validating the service; get_max_fps and get_supported_resolutions validate first, then zero.
  • can_try_to_connect returns true when the plugin has no callback.

Plan

  1. Characterization: test/cmocka/test_service_getters.c registers a fake obs_service_info with each callback present and absent, and pins every row above through OBS::libobs. It lands first, against the C.
  2. RED: the Rust module obs-output/src/service.rs with todo!() stubs, plus Tier 1 tests.
  3. GREEN: the port, the C accessor, and moving the getters into a ported-* group in libobs/build/source-sets.json. Tier 3 differential against the C oracle in rust/obs-c-oracle/legacy/. Record port_comparison.

The next slice (create/destroy/refs) is filed here when this one lands.

Activity

  1. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Claiming: #1846 unit 8, slice 1, the service getters. 1. Characterization cmocka test against the C (its own PR, first). 2. RED: Rust stubs plus Tier 1 tests. 3. GREEN: the port, the C accessor and the source-sets move, with Tier 3. The first PR is expected today.

  2. added
    claimed
    on Oct 23, 2026
  3. 4 remaining items

  4. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Done: Tier 2 characterization #1901, port #1904 (merged). Next slices: #1913, #1920.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions