Repository navigation
Description
Port the protocol-list match of libobs/obs-output.c.h to rust/obs-output as a new module, protocols. It decides which output types can stream a given protocol: obs_enum_output_types_with_protocol() walks the registered service outputs and calls the callback for each one whose ;-separated protocols string holds the protocol. The frontend uses it to pick the stream output for a third-party protocol (GetStreamOutputType(), the auto-configuration wizard) and to check codec support in Settings. If it is wrong, a stream picks the wrong output type or none, so OBS fails to go live or uses an output that cannot speak the protocol.
The unit, about 15 lines: the ;-split loop inside obs_enum_output_types_with_protocol() (master obs-output.c.h 2762-2783, the inner loop 2771-2781). Each segment is compared whole and byte for byte (strlen/strncmp), so "RTMP" does not match "RTMPS" or "rtmp". A protocol listed twice in one output's string calls the callback twice for that output.
These stay C: the output_types loop, the OBS_OUTPUT_SERVICE check and the callback calls; obs_is_output_protocol_registered() and obs_enum_output_protocols() (obs.c.h); and the registration splitter in obs_register_output_s() (obs-module.c.h, strlist_split), which is in another file and group.
Phase and position
Phase 6 (#444), libobs core through opaque seams. It joins rust/obs-output, which holds the delay, interleave and caption text ports. It is part of a large file, so it goes in through function extraction (testing-policy.md, "Extracting a function before porting it"), as the caption text did (#1618, #1620). It is in the core-output+ unity group, which has no other move or port open. Its Rust tests join the crate's existing test binary.
Dependencies and existing tests
- No dependency on libobs internals. The seam is
size_t obs_output_protocol_list_count(const char *protocols, const char *protocol): how many segments of the list equal the protocol (0 for a NULL list). C calls the callback that many times for the output and stops on false. That gives the same calls in the same order as today, because all matches for one output are consecutive. - Today no test calls these lookups. PR 1 adds two (below).
- Input: the protocol comes from the stream service (
services.json, or derived from a custom server URL byrtmp-custom), and the lists come from output plugins. Both are untrusted bytes: any byte but NUL, not necessarily UTF-8. The port compares bytes, neverstr, and must not panic.
Plan
- Characterization and extraction PR (behaviour-neutral, two commits):
test_output_protocols(real libobs, public API only, so it also runs the hybrid libobs). It registers service outputs with"RTMP;RTMP","RTMP;RTMPS","SRT",";RTMP;;","RTMPX","rtmp","HLS;","WHIP; RIST"and"", plus a plain output with a list. It pins the registered protocols and their order, the registered check, the enumerate order, duplicates (two calls), the early stop (also between two matches of one output), whole names and case, unregistered protocols, andobs_output_get_protocols()/obs_get_output_flags().- The move: the loop goes into
libobs/obs-output-protocols.c.has the hidden entry pointobs_output_protocol_list_count()(declared inobs-internal.hwithoutEXPORT). The file joinslibobs.core-outputjust beforeobs-output.c.h, withlibobs.pch.h. test_output_protocol_list_steps, which compiles the moved file (no libobs core) and calls only the entry point: NULL and empty lists, whole segments, case, spaces, duplicates, empty and trailing segments, the empty protocol, high bytes, a 100000-segment list and a 1 MiB segment, and an exhaustive check over short lists against a model.
- NULL fix (separate PR, from master):
obs_is_output_protocol_registered(NULL)andobs_enum_output_types_with_protocol(NULL, ...)crash instrcmp()today. That fix is inobs.c.hand does not touch the moved file, so the two PRs do not depend on each other. Once both are in, the characterization can add the NULL cases. - Port PR (RED, then GREEN):
obs_output::protocols, a safe corefn count_matches(list: &[u8], protocol: &[u8]) -> usize, andsrc/ffi/protocols.rsfor the entry point (a NULL list gives 0). The C file moves to a ported group,libobs.ported-output-protocols, with its.pch.h,source-sets.jsonentry and export fragments (hidden, asobs_output_caption_text_pageis);ci/test_ported_sources.pygets the object.- Tests:
- Tier 1 ports every
test_output_protocol_list_stepsexpectation 1:1. - Tier 3 checks parity against the moved C through
obs-c-oracle(oracle/output_protocols.c): a proptest over byte strings made of;, empty segments, prefixes, case variants and arbitrary non-NUL bytes, and protocols taken from the list, near it, or random. - Tier 2:
test_output_protocol_list_steps_rust, the unchanged.clinked againstlibobs_rust-static, if it links on its own (astest_scene_bounds_place_rustdoes); otherwise the header of its.cmakesays why, as fortest_context_name_helpers.test_output_protocolsruns the hybrid libobs unchanged. - Tier 4 does not apply (no protocol or UI change).
- Tier 1 ports every
- Docs: the
rust/README.mdrows, and thedocs/rust-port/naming.mdrow forrust/obs-output(addobs-output-protocols.c.h).
For the reviewer to decide
- Seam shape. A count, not a callback across the boundary: the Rust core stays pure, and C keeps the output table and the callback. The equivalence holds because the matches of one output are consecutive calls with the same id. The alternative, passing the callback into Rust, buys nothing.
- Behaviours the characterization pins, not endorses (none is changed by the move or the port):
- An output that lists a protocol twice is enumerated twice.
- Nothing is trimmed or case-folded:
"WHIP; RIST"registers" RIST", not"RIST". - The empty protocol matches the empty segments that a
;ends, but not a trailing one. libobs never asks for it, because""is never a registered protocol.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 22, 2026
Claiming: #1829
libobs/obs-output-protocols.c.has a hidden count, withtest_output_protocols(real libobs, 7 cases) andtest_output_protocol_list_steps(9 cases, exhaustive pairs). No behaviour change.rust/obs-output(moduleprotocols) with oracle parity.libobs: Move the output protocol-list match into obs-output-protocols…
rdoupe commentedon Oct 22, 2026
Port is up in #1848. The only intentional difference from C: a NULL protocol counts 0 where C's
strlen()would crash. libobs never passes one, since #1828 returns before the match. The behaviours pinned in #1831 are kept: a duplicate counts twice, and the empty protocol matches only the empty segments a;ends.libobs: Port the output protocol-list match to obs-output (obs-rust#1848