Skip to content

facade: plugins/obs-outputs: move 34 platform conditionals behind a per-platform layer #851

Closed

Description

@zackees

Inventory of platform conditionals in shared-named files of plugins/obs-outputs/ (34 #ifs in 8 files; excludes vendored librtmp/). Existing per-platform files: rtmp-windows.c, net-if.c calls netif_get_addrs_win32/_nix.

file lines macro what the branch does
rtmp-stream.c 27 _WIN32 include win-version.h
256 _WIN32 last socket error: WSAGetLastError() vs errno
278 _WIN32+test macro framedrop test shortcut code (dev-only)
347 _WIN32 socket_queue_data callback (new socket loop)
388 _WIN32 ioctlsocket(FIONREAD) vs ioctl(FIONREAD)
506 _WIN32 map WSA error codes to user messages
576 __linux__ append root-certificate hint to error text
619, 639, 710 _WIN32 log_sndbuf_size() definition (+socklen_t typedef) and its two call sites
996 _WIN32 set socket non-blocking: ioctlsocket(FIONBIO) vs fcntl
1063 _WIN32 new socket loop: unsupported-platform error on non-Windows
1095, 1215 _WIN32 win32_log_interface_type() and its call
1486, 1956, 1993 _WIN32 new-socket-loop / low-latency settings read, defaults, UI properties
rtmp-stream.h 12, 146 _WIN32 Iphlpapi.h vs sys/ioctl.h; socket_thread_windows prototype
net-if.c 52 _WIN32 inet_ntop path vs Windows address formatting
115 _WIN32 WSAStringToAddressA vs inet_pton
136 _WIN32 is_loopback(struct ifaddrs*) helper (nix only)
260 _WIN32 dispatch to netif_get_addrs_win32 / _nix
net-if.h 22, 29, 31, 47 _WIN32 __linux__ __FreeBSD__ socket/ifaddrs headers, _GNU_SOURCE fiddling
obs-outputs.c 3, 21, 54, 59, 73 _WIN32 WSAStartup/cleanup and mbedTLS threading shims (mbed_mutex_*)
mp4-mux-internal.h 201 _WIN32 min() fallback helper for non-Windows
utils.h 13 _MSC_VER clz32 MSVC intrinsic variant

Proposed facade

New plugins/obs-outputs/platform.h (shared API) with platform-windows.c (extend existing rtmp-windows.c) and platform-nix.c:

  • rtmp_socket_last_error(), rtmp_socket_set_nonblocking(sock), rtmp_socket_bytes_available(sock, &n), rtmp_socket_error_message(code)
  • rtmp_net_startup() / rtmp_net_shutdown() (WSAStartup + mbedTLS threading on Windows, no-op elsewhere)
  • rtmp_log_socket_details(stream) (sndbuf size, interface type)
  • netif_parse_address() / netif_format_address(); netif_get_addrs() already has per-platform backends, so call it through the facade and drop the dispatch #if
  • rtmp_stream_platform_defaults(defaults), rtmp_stream_platform_properties(props), rtmp_stream_platform_update(stream, settings) for the Windows-only new-socket-loop / low-latency options
  • move socket_queue_data and socket_thread_windows into rtmp-windows.c

Likely must stay

  • net-if.h 22/29/31/47: header selection and _GNU_SOURCE workaround; move into platform.h per OS if possible, else keep as documented exception.
  • utils.h 13 (_MSC_VER intrinsic) and mp4-mux-internal.h 201 (min fallback): compiler/libc feature selection; replace with util/ helpers or feature checks instead of an OS facade.
  • rtmp-stream.c 576 (__linux__ hint text): can become a facade string getter, low value.
  • CMake OS_WINDOWS block (CMakeLists.txt:111) and /IGNORE:4098 link options (108): the intended per-platform source selection mechanism, stay.

Test approach

Behaviour-preserving moves. Verify with: the plugin's native builds on each platform (ci-full label, since these are outside the quick gate), the existing cmocka tests where the moved function is testable, and ./lint. Where a facade function is pure (path/name/constant selection) add a small unit test per platform implementation. The #847 ratchet lint baseline must go down by the count moved.

Part of #847.

Activity

  1. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Claiming: #851 (obs-outputs platform facade), same pattern as the #853 slices (#2023/#2042/#2050/#2068): conditional-free *-host.h interfaces, *-host-<os>.c.h or hosts/<os>/ implementations with their own unity groups/PCHs, a Tier 2 test per slice that runs the POSIX hosts on Linux, cross check for Windows/macOS, baseline entries removed.

    1. net-if.c.h/net-if.h (interface enumeration, 13).
    2. rtmp-stream.c.h/.h + obs-outputs-rtmp.pch.h (socket send/low-latency/Windows send thread, 19).
    3. obs-outputs.c.h, obs-outputs.pch.h, mp4-mux-internal.h, utils.h (8).

    First PR (slice 1) within a day.

  2. added
    claimed
    on Oct 24, 2026
  3. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Done: all obs-outputs platform conditionals are behind host files, and ci/platform-ifdef-baseline.json has no plugins/obs-outputs entries left. Slices: #2076 (net-if host and hosts/<os>/net-if-os.h), #2092 (RTMP output host: socket errors/ioctls, root-cert hint, Windows send thread), #2096 (module host: Winsock/mbedtls threading; portable bit helpers; min_size). Each has a Tier 2 test running the POSIX host on Linux, and the host groups are in the cross check (obs-outputs had no entry before). Nothing left.

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