Skip to content

rust: Port the core setup rules in obs.c to obs-core #2878

Closed

Description

@rdoupe

Rust port, round 13 unit 2: the setup decisions in libobs/obs.c.h (the video and audio reset gates, the audio buffering tick rule, the command-line copy, the data path removal, the latest input type, the monitoring device checks and the frame counts), moved to Rust (rust/obs-core, new module core_setup_rules, next to video_plan, context_names and source_load).

Unit

libobs/obs.c.h → libobs/obs-core-setup-rules.c.h → rust/obs-core (core_setup_rules).

Phase and position

Phase 6 (core), the next slice of obs.c.h, after the registration size rules (#2860) in the same unity group (core+).

Scope

Rust takes over these decisions, each asked where the C makes it today, from the value C reads at that point:

  • obs_reset_video: the gates in order: no core (OBS_VIDEO_FAIL), video active, then outputs starting (OBS_VIDEO_CURRENTLY_ACTIVE), then the output size, then the base size (OBS_VIDEO_INVALID_PARAM; the size checks themselves are already Rust). The fps gate stays C;
  • obs_reset_audio2: no core, then an active audio output (only asked when there is one); the buffering tick rule: a max_buffering_ms of 0 gives 45 ticks, any other gives (ms * rate / 1000 + 1023) / 1024 in uint32_t (the product wraps). The log value's divide by the rate stays C;
  • obs_set_cmdline_args: set once (only while the stored argc is 0), the block size: argc + 1 pointers, then each argument's length plus one;
  • obs_remove_data_path: the first equal path is removed;
  • obs_get_latest_input_type_id: a type wins when (int)version is above the best so far (start -1), so the first of equal versions is kept;
  • check_all_aoc_sources: the OBS_SOURCE_DO_NOT_SELF_MONITOR gate;
  • obs_set_audio_monitoring_device: a NULL or empty name or id, then no monitoring, refused; the same id returns true with no reset;
  • obs_get_video_frame_counts: a mix counts when it is the main mix, or an encoder-only mix of the main mix's view, and has a video.

C keeps every lock (monitoring_mutex, mixes_mutex), every call (obs_video_active, outputs_starting, audio_output_active, check_path, find_libobs_data_file, dstr_cmp, strcmp, strlen, obs_audio_monitoring_available, obs_reset_audio_monitoring, obs_enum_sources, video_output_get_*_frames), every allocation, copy and free, the core_video_release signal, the encoder unbind and rebind, the fps gate, every divide by a variable and every log message. Every read and call stays in its original place and under its original condition: a decision made from several reads is split into steps, so C asks after each read and stops where it stops today.

Dependencies and existing tests

  • Depends on the video size checks (already Rust). No fix first.
  • Existing real-libobs coverage: test_obs_core_info_characterization (command line, data paths), test_encoding_lag_rescale (frame counts with a GPU rescale), test_scene_audio_actions (obs_reset_audio2), the test_pulse_monitor_* tests (monitoring device), test_video_reset_fps and many tests that call obs_reset_video.
  • No characterization of the steps themselves yet: test_core_setup_rules_steps lands first, pinning each reset gate in order, the tick rule at 0 ms, 1 ms, an exact multiple of 1024 frames and a product above UINT32_MAX (characterized, not endorsed), the command line set twice and first with argc 0 (characterized, not endorsed), a remove with two equal paths, the latest type with equal versions and a version above INT_MAX (never chosen: characterized, not endorsed), the monitoring device with NULL, empty, the same id and a new id, and the frame-count rule for each kind of mix.

Plan

The standard six commits, one PR:

  1. move to libobs/obs-core-setup-rules.c.h (behaviour-neutral; the export sets stay identical on the C, hybrid and c-ref builds);
  2. characterization test;
  3. Tier 1 RED;
  4. GREEN in libobs.ported-core-setup-rules;
  5. Tier 3 parity (exhaustive over the steps and booleans; proptest over u32 ms and rates, versions, and argument lengths), with a mutation check;
  6. docs.

Notes

No intentional behaviour difference expected for any input libobs can pass. No SIMD, threading or per-OS code. The OBS_VIDEO_* codes and OBS_SOURCE_DO_NOT_SELF_MONITOR are copied into the rules header and _Static_asserted against the core headers in obs.c.h. obs_find_data_file stays C: it has no decision beyond the pointer test and check_path's own answer. The NULL oai return of obs_reset_audio2 (after the free) stays C as the guard of its dereference. R11-U1's functions (the video and audio info getters, the level setter, the object checks) and obs_queue_task are left alone.

Activity

  1. added
    enhancement
    port
    on Oct 29, 2026
  2. rdoupe commented on Oct 29, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2878 (round 13 unit 2).

    1. Move the decisions to libobs/obs-core-setup-rules.c.h (behaviour-neutral).
    2. Characterization test test_core_setup_rules_steps.
    3. Tier 1 RED against todo!() stubs.
    4. GREEN in libobs.ported-core-setup-rules.
    5. Tier 3 parity with a mutation check.
    6. Docs.

    One PR; a draft opens with the RED commit today. #2877 edits three of these functions' lines in obs.c.h (casts only), so whichever lands second rebases.

  3. added
    ready
    on Oct 29, 2026
  4. moved this from In progress to Done in obs-rust Multiviewon Oct 29, 2026
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