Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b83a5c7
Cmake: Cmake ffmpeg library fix for Windows
danrossi Apr 24, 2026
ea1c0a9
- update markdown code blocks
danrossi Apr 25, 2026
9ffc4e3
- Refactor cmake to search for including provided pre-built libraries…
danrossi May 1, 2026
8a2174d
- update latest specfile hashes
danrossi May 1, 2026
a5a16c1
- Enable swift for macOS to configure OBS correctly.
danrossi May 1, 2026
af0d546
- move swift language obs setup to buildspec common
danrossi May 1, 2026
e1ad0af
- revert swift language
danrossi May 1, 2026
44877ff
- add libobs-metal patch
danrossi May 2, 2026
d86e382
- update min xcode requirements to match obs-studio
danrossi May 2, 2026
e54b024
- Use pkg-config to find system libraries for Linux
danrossi May 2, 2026
0d6e7f8
- fix hash for Windows obs source archive
danrossi May 2, 2026
9d45afd
- Set minimum Xcode and SDK required to 26.1 to match the obs-studio …
danrossi May 4, 2026
c34bf51
- fix windows install prefix config
danrossi May 4, 2026
fa05997
- Fix windows commands doc
danrossi May 5, 2026
63cb4ae
- reinstate macos command
danrossi May 5, 2026
02bff6d
Merge branch 'moq-dev:main' into win-build-fix
danrossi May 9, 2026
136cfb8
- Enable a debug console in Windows if the RUST_LOG env var is set t…
danrossi May 13, 2026
9dc4a05
- Add stop signal for connection failures , session and publish errors
danrossi May 13, 2026
1ac1ca3
- change pointer reference within libmoq callback
danrossi May 13, 2026
b0d4fa3
- Revert obs stop signals
danrossi May 14, 2026
b4d6945
Update min XCode requirements to 26.5 to match upstream changes
danrossi Jun 4, 2026
3cb4031
Merge branch 'moq-dev:main' into win-build-fix
danrossi Jun 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,30 @@ add_library(obs-moq MODULE)

if(${BUILD_PLUGIN})
find_package(libobs REQUIRED)
# FFmpeg dependency
include(FindPkgConfig)
pkg_check_modules(FFMPEG REQUIRED libavcodec libavutil libswscale libswresample)
target_include_directories(obs-moq PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_link_directories(obs-moq PRIVATE ${FFMPEG_LIBRARY_DIRS})
target_link_libraries(obs-moq PRIVATE ${FFMPEG_LIBRARIES})

if (CMAKE_HOST_LINUX)
# Use pkg-config to find system libraries for Linux
include(FindPkgConfig)
pkg_check_modules(FFMPEG REQUIRED libavcodec libavutil libswscale libswresample)
target_include_directories(obs-moq PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_link_directories(obs-moq PRIVATE ${FFMPEG_LIBRARY_DIRS})
target_link_libraries(obs-moq PRIVATE ${FFMPEG_LIBRARIES})
else()
# FFmpeg dependency. Use provided pre-built dependancies
find_library(AVCODEC_LIB avcodec)
find_library(AVUTIL_LIB avutil)
find_library(SWSCALE_LIB swscale)
find_library(SWRESAMPLE_LIB swresample)

if (AVCODEC_LIB)
target_link_libraries(obs-moq PRIVATE ${AVCODEC_LIB} ${AVUTIL_LIB} ${SWSCALE_LIB} ${SWRESAMPLE_LIB})
endif()
endif()

# Link required windows system libraries
if(OS_WINDOWS)
target_link_libraries(obs-moq PRIVATE Userenv ntdll)
endif()
else()
find_package(FFmpeg REQUIRED avcodec avutil swscale swresample)
target_link_libraries(obs-moq PRIVATE FFmpeg::avcodec FFmpeg::avutil FFmpeg::swscale FFmpeg::swresample)
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ Prerequisites:
* C++ Compiler (Clang/GCC/MSVC)
* OBS Studio development libraries (libobs)
* [Fork of OBS-Studio](https://github.com/brianmed/obs-studio) just to show MoQ in the UI.
* XCode 26.1 / macOS 15.6

1. Clone the repos:
```bash
git clone https://github.com/moq-dev/obs.git moq-obs
git clone https://github.com/brianmed/obs-studio.git obs-studio
git clone --recurse-submodules https://github.com/brianmed/obs-studio.git obs-studio

# optional: for local moq development
git clone https://github.com/moq-dev/moq.git moq
Expand All @@ -32,9 +33,21 @@ Prerequisites:
```bash
cd obs-studio

# Replace with your platform
# Configure for Windows
cmake -G "Visual Studio 18 2026" -A x64 --preset windows-x64
# Configure for macos
cmake --preset macos
cmake --build --preset macos

# Build for Windows
cmake --build --preset windows-x64

# Build for macOS
cd build_macos
xcodebuild \
-configuration RelWithDebInfo \
-scheme obs-studio \
-parallelizeTargets \
-destination "generic/platform=macOS,name=Any Mac"
```

3. Configure the plugin:
Expand Down
39 changes: 39 additions & 0 deletions WINDOWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## Windows Build Instructions

### Build Setup

```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco install -y git
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System'
choco install visualstudio2026buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
choco install rustup
```

During the rustup installation choose the `nightly` variant.

Locate "Visual Studio Installer". Click "Modify". Choose "Desktop Development with C++". Check C++ ATL For x64

### Build the OBS fork

```powershell
cd obs-studio
cmake -G "Visual Studio 18 2026" -A x64 --preset windows-x64
cmake --build --preset windows-x64
```

### Build the obs-moq plugin and install

```powershell
cd obs
cmake -G "Visual Studio 18 2026" -A x64 --preset windows-x64 -DMOQ_LOCAL="../moq"
cmake --build --preset windows-x64 --target install
```



## Debugging Moq Plugin

```powershell
$env:RUST_LOG="debug"; $env:RUST_BACKTRACE=1; $env:OBS_LOG_LEVEL="debug"; Set-Location "build_x64\rundir\RelWithDebInfo\bin\64bit"; & .\obs64.exe --verbose
```
20 changes: 10 additions & 10 deletions buildspec.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"dependencies": {
"obs-studio": {
"version": "31.1.1",
"version": "32.1.2",
"baseUrl": "https://github.com/obsproject/obs-studio/archive/refs/tags",
"label": "OBS sources",
"hashes": {
"macos": "39751f067bacc13d44b116c5138491b5f1391f91516d3d590d874edd21292291",
"windows-x64": "2c8427c10b55ac6d68008df2e9a3e82f4647aaad18f105e30d4713c2de678ccf"
"macos": "b4a59410cddb46d0e31df1ee13b8ec66f30862d7e980c1a8c4e3b5d16fae6053",
"windows-x64": "21cba22292985cf0da967d5c618999b40eaa32b73d2ab8b06154b5ea1b3d3798"
}
},
"prebuilt": {
"version": "2025-07-11",
"version": "2025-08-23",
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
"label": "Pre-Built obs-deps",
"hashes": {
"macos": "495687e63383d1a287684b6e2e9bfe246bb8f156fe265926afb1a325af1edd2a",
"windows-x64": "c8c642c1070dc31ce9a0f1e4cef5bb992f4bff4882255788b5da12129e85caa7"
"macos": "9403bb43fb0a9bb215739a5659ca274fe884dbbbcd22bd9ca781c961fb041c42",
"windows-x64": "8de229cff6f1981508c0eb646b35e644633a5855787b9f5d3b90ae2aeb87ffc1"
}
},
"qt6": {
"version": "2025-07-11",
"version": "2025-08-23",
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
"label": "Pre-Built Qt6",
"hashes": {
"macos": "d3f5f04b6ea486e032530bdf0187cbda9a54e0a49621a4c8ba984c5023998867",
"windows-x64": "0e76bf0555dd5382838850b748d3dcfab44a1e1058441309ab54e1a65b156d0a"
"macos": "990f11638b80a4509e14e8c315f6e4caa0861e37fcd3113a256fbff835ffca29",
"windows-x64": "c62e82483bc7c0bf199e8ac3220c66a85a6e8a0cd69a05b6d44f873b830e415f"
},
"debugSymbols": {
"windows-x64": "11b7be92cf66a273299b8f3515c07a5cfb61614b59a4e67f7fc5ecba5e2bdf21"
"windows-x64": "ef4954fa18c818103f63415776624fa1e403c3faaa7b0a7b259000cc35b2c9fc"
}
}
},
Expand Down
14 changes: 14 additions & 0 deletions cmake/common/buildspec_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ function(_setup_obs_studio)
set(_cmake_generator "Xcode")
set(_cmake_arch "-DCMAKE_OSX_ARCHITECTURES:STRING='arm64;x86_64'")
set(_cmake_extra "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")

#Patch libobs-metal if required
if (_obs_version VERSION_LESS_EQUAL "32.1.2")

file(READ "${dependencies_dir}/${_obs_destination}/libobs-metal/CMakeLists.txt" CONTENTS)

#check if Swift is not available
if(NOT "${CONTENTS}" MATCHES "enable_language\\(Swift\\)")
string(REGEX REPLACE "cmake_minimum_required\\(VERSION 3.28...3.30\\)" "cmake_minimum_required(VERSION 3.28...3.30)\nenable_language(Swift)" NEW_CONTENTS "${CONTENTS}")
message(STATUS "Patching libobs-metal")
file(WRITE "${dependencies_dir}/${_obs_destination}/libobs-metal/CMakeLists.txt" "${NEW_CONTENTS}")
endif()
Comment on lines +65 to +74
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add if(EXISTS ...) guard before file(READ ...) — fatal error if the path is absent.

file(READ ...) on Line 67 will abort CMake configure with an unhelpful fatal error if ${dependencies_dir}/${_obs_destination}/libobs-metal/CMakeLists.txt does not exist (e.g., partial extraction, unexpected OBS source layout, or obs-studio dependency not yet present). Add an existence check first.

🛠️ Proposed fix
-    `#Patch` libobs-metal if required
-    if (_obs_version VERSION_LESS_EQUAL "32.1.2")
-
-      file(READ "${dependencies_dir}/${_obs_destination}/libobs-metal/CMakeLists.txt" CONTENTS)
-
-      `#check` if Swift is not available
-      if(NOT "${CONTENTS}" MATCHES "enable_language\\(Swift\\)")
-        string(REGEX REPLACE "cmake_minimum_required\\(VERSION 3.28...3.30\\)" "cmake_minimum_required(VERSION 3.28...3.30)\nenable_language(Swift)" NEW_CONTENTS "${CONTENTS}")
-        message(STATUS "Patching libobs-metal")
-        file(WRITE "${dependencies_dir}/${_obs_destination}/libobs-metal/CMakeLists.txt" "${NEW_CONTENTS}")
-      endif()
-
-    endif()
+    # Patch libobs-metal if required
+    if(_obs_version VERSION_LESS_EQUAL "32.1.2")
+      set(_libobs_metal_cmake "${dependencies_dir}/${_obs_destination}/libobs-metal/CMakeLists.txt")
+      if(EXISTS "${_libobs_metal_cmake}")
+        file(READ "${_libobs_metal_cmake}" CONTENTS)
+        # Check if Swift is not already enabled
+        if(NOT "${CONTENTS}" MATCHES "enable_language\\(Swift\\)")
+          string(
+            REGEX REPLACE
+            "cmake_minimum_required\\(VERSION 3\\.28\\.\\.\\. ?3\\.30\\)"
+            "cmake_minimum_required(VERSION 3.28...3.30)\nenable_language(Swift)"
+            NEW_CONTENTS
+            "${CONTENTS}"
+          )
+          if(NOT NEW_CONTENTS STREQUAL CONTENTS)
+            message(STATUS "Patching libobs-metal")
+            file(WRITE "${_libobs_metal_cmake}" "${NEW_CONTENTS}")
+          else()
+            message(WARNING "libobs-metal patch: regex did not match; Swift may not be enabled")
+          endif()
+        endif()
+      else()
+        message(WARNING "libobs-metal/CMakeLists.txt not found at ${_libobs_metal_cmake}; skipping Swift patch")
+      endif()
+    endif()

The proposed fix also escapes the . characters in the version range regex (e.g., 3\\.28) so they match literal dots rather than any character, and adds a guard to warn if the string(REGEX REPLACE) produces no change — which would leave Swift silently un-enabled even though the enable_language(Swift) check triggered.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmake/common/buildspec_common.cmake` around lines 65 - 74, Add an existence
guard before calling file(READ) for
"${dependencies_dir}/${_obs_destination}/libobs-metal/CMakeLists.txt" so CMake
won't fatal-error when the file is missing; keep the surrounding if(_obs_version
VERSION_LESS_EQUAL "32.1.2") block. Update the string(REGEX REPLACE) pattern
used to insert enable_language(Swift) to escape dots in the version tokens
(e.g., use "3\\.28...3\\.30") so it matches literal dots, and after computing
NEW_CONTENTS compare it to CONTENTS and emit a message(WARNING ...) if they are
identical (indicating the replace did nothing) rather than silently proceeding;
leave the message(STATUS "Patching libobs-metal") and file(WRITE ...) logic
unchanged but only run them when the file exists and NEW_CONTENTS differs from
CONTENTS.


endif()
endif()

message(STATUS "Configure ${label} (${arch})")
Expand Down
4 changes: 2 additions & 2 deletions cmake/macos/compilerconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:-fopenmp-simd>")

# Ensure recent enough Xcode and platform SDK
function(check_sdk_requirements)
set(obs_macos_minimum_sdk 15.0) # Keep in sync with Xcode
set(obs_macos_minimum_xcode 16.0) # Keep in sync with SDK
set(obs_macos_minimum_sdk 26.5) # Keep in sync with Xcode
set(obs_macos_minimum_xcode 26.5) # Keep in sync with SDK
execute_process(
COMMAND xcrun --sdk macosx --show-sdk-platform-version
OUTPUT_VARIABLE obs_macos_current_sdk
Expand Down
3 changes: 2 additions & 1 deletion cmake/windows/defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
include(buildspec)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
cmake_path(SET ALLUSERSPROFILE_PATH $ENV{ALLUSERSPROFILE})
set(
CMAKE_INSTALL_PREFIX
"$ENV{ALLUSERSPROFILE}/obs-studio/plugins"
"${ALLUSERSPROFILE_PATH}/obs-studio/plugins"
CACHE STRING
"Default plugin installation directory"
FORCE
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ build preset="":
set -euo pipefail

PRESET=$(just preset "{{preset}}")
cmake --build --preset "$PRESET"
cmake --build --preset "$PRESET" --target install
Comment thread
danrossi marked this conversation as resolved.

# Run a local fork of OBS Studio with the plugin loaded
# TODO support for other platforms
Expand Down
12 changes: 12 additions & 0 deletions src/obs-moq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ extern "C" {
#include "moq.h"
}

#ifdef _WIN64
#include <windows.h>
#include <cstring>
#endif

OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE("obs-moq", "en-US")
MODULE_EXPORT const char *obs_module_description(void)
Expand All @@ -39,6 +44,13 @@ bool obs_module_load(void)
// The second argument is the string length of the first argument.
moq_log_level("info", 4);

// Enable a debug console in Windows if the RUST_LOG env var is set to debug.
#ifdef _WIN64
const char* logLevel = std::getenv("RUST_LOG");
if (logLevel && strcmp(logLevel, "debug") == 0)
AllocConsole();
#endif

register_moq_output();
register_moq_service();
register_moq_source();
Expand Down
Loading