Skip to content

facade: plugins/obs-ffmpeg: move 25 platform conditionals behind a per-platform layer #853

Closed

Description

@zackees

Inventory of platform conditionals in shared-named files of plugins/obs-ffmpeg/ (25 #ifs in 7 files; no existing per-platform C files besides vaapi/mediacodec-specific units).

file lines macro what the branch does
obs-ffmpeg.c 7 _WIN32 INITGUID + dxgi.h include
12 !_WIN32 && !__APPLE__ VAAPI utils include and LIBAVUTIL_VAAPI_AVAILABLE
126 _WIN32 nvenc_device_available() via DXGI adapter enumeration
184 __linux__ get_id_from_sys / sysfs GPU probing for VAAPI
257, 259 _WIN32, __linux__ NVENC availability check per OS (Linux dlopens libnvidia-encode)
326, 377, 426 _WIN32 && !_M_ARM64 AMF amf_load/amf_unload declarations and calls
obs-ffmpeg-mux.c 21 _WIN32 win-version.h include
113 _WIN32 helper exe name obs-ffmpeg-mux(.exe)
318 _WIN32 Windows 10 Defender warning on mux start failure
ffmpeg-mux/ffmpeg-mux.c 17, 1134, 1147, 1195 _WIN32 io.h/windows.h, wmain with wide argv conversion and cleanup, SetErrorMode
658 _MSC_VER disable warning 4996
obs-ffmpeg-srt.h 23, 814, 864 _WIN32 ftime vs gettimeofday style timestamp
485 _WIN32 gai_strerrorA vs gai_strerror
obs-ffmpeg-url.h 31, 35, 95 _WIN32 syslog definitions vs <syslog.h> for SRT headers
obs-amf-test/obs-amf-test.cpp 19 _MSC_VER export AmdPowerXpressRequestHighPerformance

Proposed facade

plugins/obs-ffmpeg/platform.h implemented by platform-windows.c, platform-linux.c, platform-mac.c (empty/no-op):

  • ffmpeg_platform_nvenc_device_available() (merges the 126 and 257/259 branches)
  • ffmpeg_platform_vaapi_available(), ffmpeg_platform_load_hw_backends() / unload_...() (AMF load/unload, 326/377/426)
  • ffmpeg_platform_mux_exe_name(), ffmpeg_platform_mux_start_hint(path) (Defender warning)
  • ffmpeg_platform_wall_clock_seconds() and ffmpeg_platform_gai_strerror() for SRT (or use util/platform.h)
  • ffmpeg-mux/ has its own entry point; put wmain wrapper in ffmpeg-mux/main-windows.c and keep a portable ffmpeg_mux_main(argc, argv).

Likely must stay

  • _MSC_VER pragma-only blocks (ffmpeg-mux.c:658, obs-amf-test.cpp:19 export symbol): compiler/export selection; document as exceptions or move to the test's Windows-only source.
  • obs-ffmpeg-url.h 31/35/95: shim for the bundled SRT headers; move into a platform/ include only if SRT headers can be wrapped.
  • CMake OS_LINUX OR OS_WINDOWS blocks (CMakeLists.txt:6,78, cmake/dependencies.cmake:15,18) 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: #853, one PR per slice, following the #1292/#882 host-interface pattern (conditional-free *-host.h, *-host-{windows,macos,posix} in per-OS unity groups, cmocka RED test, cross-check coverage):

    1. obs-ffmpeg-mux.c.h and its PCH: helper executable name, Defender hint, win-version.h include.
    2. ffmpeg-mux/ helper: wmain wrapper and SetErrorMode into a Windows entry file, plus the _MSC_VER pragma moved to CMake.
    3. obs-ffmpeg.c.h and its PCH: NVENC/VA-API availability, AMF load/unload.
    4. obs-ffmpeg-srt.h / obs-ffmpeg-url.h and the AMF PCH.

    The first PR (RED) goes up today.

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

    @zackees
    MemberAuthor

    Done: all 25 obs-ffmpeg platform conditionals are behind host files, and ci/platform-ifdef-baseline.json has no plugins/obs-ffmpeg entries left. Slices: #2023 (muxer output host), #2042 (ffmpeg-mux helper entry points), #2050 (NVENC device check, AMF load, VA-API define), #2068 (SRT/URL hosts/<os>/obs-ffmpeg-net-host.h, AMF PCH renamed for its Windows group). Each has a Tier 2 test that runs the POSIX hosts on Linux, plus cross check entries. 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