├── data └── locale │ └── en-US.ini ├── .github ├── scripts │ ├── build-linux │ ├── build-macos │ ├── package-linux │ ├── package-macos │ ├── utils.zsh │ │ ├── mkcd │ │ ├── log_error │ │ ├── log_warning │ │ ├── log_debug │ │ ├── log_output │ │ ├── log_status │ │ ├── log_info │ │ ├── read_codesign_user │ │ ├── read_codesign_team │ │ ├── read_codesign_installer │ │ ├── read_codesign │ │ ├── log_group │ │ ├── set_loglevel │ │ ├── check_macos │ │ ├── setup_ccache │ │ ├── read_codesign_pass │ │ ├── setup_linux │ │ └── check_linux │ ├── .Brewfile │ ├── .Wingetfile │ ├── .Aptfile │ ├── utils.pwsh │ │ ├── Ensure-Location.ps1 │ │ ├── Invoke-External.ps1 │ │ ├── Install-BuildDependencies.ps1 │ │ ├── Expand-ArchiveExt.ps1 │ │ └── Logger.ps1 │ ├── Package-Windows.ps1 │ ├── Build-Windows.ps1 │ ├── .package.zsh │ └── .build.zsh ├── workflows │ ├── dispatch.yaml │ ├── check-format.yaml │ ├── pr-pull.yaml │ ├── push.yaml │ └── build-project.yaml └── actions │ ├── run-cmake-format │ └── action.yaml │ ├── run-clang-format │ └── action.yaml │ ├── build-plugin │ └── action.yaml │ ├── package-plugin │ └── action.yaml │ └── setup-macos-codesigning │ └── action.yaml ├── src ├── asset-utils │ ├── asset-loader.h │ ├── asset-render.h │ ├── asset-loader.cpp │ └── asset-render.cpp ├── obs-utils │ ├── obs-utils.h │ └── obs-utils.cpp ├── augmented-filter-data.h ├── augmented-filter.c ├── plugin-support.h ├── augmented-filter.h ├── plugin-main.c ├── plugin-support.c.in └── augmented-filter.cpp ├── cmake ├── windows │ ├── defaults.cmake │ ├── buildspec.cmake │ ├── resources │ │ ├── resource.rc.in │ │ └── installer-Windows.iss.in │ ├── compilerconfig.cmake │ └── helpers.cmake ├── macos │ ├── resources │ │ ├── ccache-launcher-c.in │ │ ├── ccache-launcher-cxx.in │ │ ├── distribution.in │ │ └── create-package.cmake.in │ ├── buildspec.cmake │ ├── defaults.cmake │ ├── compilerconfig.cmake │ ├── helpers.cmake │ └── xcode.cmake ├── common │ ├── ccache.cmake │ ├── buildnumber.cmake │ ├── osconfig.cmake │ ├── helpers_common.cmake │ ├── compiler_common.cmake │ ├── bootstrap.cmake │ └── buildspec_common.cmake ├── linux │ ├── toolchains │ │ ├── x86_64-linux-gcc.cmake │ │ ├── aarch64-linux-gcc.cmake │ │ ├── x86_64-linux-clang.cmake │ │ └── aarch64-linux-clang.cmake │ ├── helpers.cmake │ ├── defaults.cmake │ └── compilerconfig.cmake ├── BuildAssimp.cmake └── FetchOpenCV.cmake ├── .gitignore ├── .cmake-format.json ├── CMakeLists.txt ├── CMakePresets.json ├── .clang-format └── README.md /data/locale/en-US.ini: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/scripts/build-linux: -------------------------------------------------------------------------------- 1 | .build.zsh -------------------------------------------------------------------------------- /.github/scripts/build-macos: -------------------------------------------------------------------------------- 1 | .build.zsh -------------------------------------------------------------------------------- /.github/scripts/package-linux: -------------------------------------------------------------------------------- 1 | .package.zsh -------------------------------------------------------------------------------- /.github/scripts/package-macos: -------------------------------------------------------------------------------- 1 | .package.zsh -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/mkcd: -------------------------------------------------------------------------------- 1 | [[ -n ${1} ]] && mkdir -p ${1} && builtin cd ${1} 2 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/log_error: -------------------------------------------------------------------------------- 1 | local icon=' ✖︎ ' 2 | 3 | print -u2 -PR "${CI:+::error::}%F{1} ${icon} %f ${@}" 4 | -------------------------------------------------------------------------------- /.github/scripts/.Brewfile: -------------------------------------------------------------------------------- 1 | brew "ccache" 2 | brew "coreutils" 3 | brew "cmake" 4 | brew "git" 5 | brew "jq" 6 | brew "xcbeautify" 7 | -------------------------------------------------------------------------------- /.github/scripts/.Wingetfile: -------------------------------------------------------------------------------- 1 | package 'cmake', path: 'Cmake\bin', bin: 'cmake' 2 | package 'innosetup', path: 'Inno Setup 6', bin: 'iscc' 3 | -------------------------------------------------------------------------------- /.github/scripts/.Aptfile: -------------------------------------------------------------------------------- 1 | package 'cmake' 2 | package 'ccache' 3 | package 'git' 4 | package 'jq' 5 | package 'ninja-build', bin: 'ninja' 6 | package 'pkg-config' 7 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/log_warning: -------------------------------------------------------------------------------- 1 | if (( _loglevel > 0 )) { 2 | local icon=' =>' 3 | 4 | print -PR "${CI:+::warning::}%F{3} ${(r:5:)icon} ${@}%f" 5 | } 6 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/log_debug: -------------------------------------------------------------------------------- 1 | if (( ! ${+_loglevel} )) typeset -g _loglevel=1 2 | 3 | if (( _loglevel > 2 )) print -PR -e -- "${CI:+::debug::}%F{220}DEBUG: ${@}%f" 4 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/log_output: -------------------------------------------------------------------------------- 1 | if (( ! ${+_loglevel} )) typeset -g _loglevel=1 2 | 3 | if (( _loglevel > 0 )) { 4 | local icon='' 5 | 6 | print -PR " ${(r:5:)icon} ${@}" 7 | } 8 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/log_status: -------------------------------------------------------------------------------- 1 | if (( ! ${+_loglevel} )) typeset -g _loglevel=1 2 | 3 | if (( _loglevel > 0 )) { 4 | local icon=' >' 5 | 6 | print -PR "%F{2} ${(r:5:)icon}%f ${@}" 7 | } 8 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/log_info: -------------------------------------------------------------------------------- 1 | if (( ! ${+_loglevel} )) typeset -g _loglevel=1 2 | 3 | if (( _loglevel > 0 )) { 4 | local icon=' =>' 5 | 6 | print -PR "%F{4} ${(r:5:)icon}%f %B${@}%b" 7 | } 8 | -------------------------------------------------------------------------------- /src/asset-utils/asset-loader.h: -------------------------------------------------------------------------------- 1 | #ifndef ASSET_LOADER_H 2 | #define ASSET_LOADER_H 3 | 4 | #include 5 | 6 | const aiScene *load_asset(const char *path); 7 | 8 | #endif /* ASSET_LOADER_H */ 9 | -------------------------------------------------------------------------------- /cmake/windows/defaults.cmake: -------------------------------------------------------------------------------- 1 | # CMake Windows defaults module 2 | 3 | include_guard(GLOBAL) 4 | 5 | # Enable find_package targets to become globally available targets 6 | set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) 7 | 8 | include(buildspec) 9 | -------------------------------------------------------------------------------- /src/asset-utils/asset-render.h: -------------------------------------------------------------------------------- 1 | #ifndef ASSET_RENDER_H 2 | #define ASSET_RENDER_H 3 | 4 | #include "augmented-filter-data.h" 5 | 6 | bool render_asset_3d(augmented_filter_data *afd, const aiScene *scene); 7 | 8 | #endif /* ASSET_RENDER_H */ 9 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/read_codesign_user: -------------------------------------------------------------------------------- 1 | autoload -Uz log_info 2 | 3 | if (( ! ${+CODESIGN_IDENT_USER} )) { 4 | typeset -g CODESIGN_IDENT_USER 5 | log_info 'Setting up Apple ID for notarization...' 6 | read CODESIGN_IDENT_USER'?Apple ID: ' 7 | } 8 | -------------------------------------------------------------------------------- /src/obs-utils/obs-utils.h: -------------------------------------------------------------------------------- 1 | #ifndef OBS_UTILS_H 2 | #define OBS_UTILS_H 3 | 4 | #include "augmented-filter-data.h" 5 | 6 | bool getRGBAFromStageSurface(augmented_filter_data *tf, uint32_t &width, 7 | uint32_t &height); 8 | 9 | #endif /* OBS_UTILS_H */ 10 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/read_codesign_team: -------------------------------------------------------------------------------- 1 | autoload -Uz log_info 2 | 3 | if (( ! ${+CODESIGN_TEAM} )) { 4 | typeset -g CODESIGN_TEAM 5 | log_info 'Setting up Apple Developer Team ID for codesigning...' 6 | read CODESIGN_TEAM'?Apple Developer Team ID (leave empty to use Apple Developer ID instead): ' 7 | } 8 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/read_codesign_installer: -------------------------------------------------------------------------------- 1 | autoload -Uz log_info 2 | 3 | if (( ! ${+CODESIGN_IDENT_INSTALLER} )) { 4 | typeset -g CODESIGN_IDENT_INSTALLER 5 | log_info 'Setting up Apple Developer Installer ID for installer package codesigning...' 6 | read CODESIGN_IDENT_INSTALLER'?Apple Developer Installer ID: ' 7 | } 8 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/read_codesign: -------------------------------------------------------------------------------- 1 | autoload -Uz log_info 2 | 3 | if (( ! ${+CODESIGN_IDENT} )) { 4 | typeset -g CODESIGN_IDENT 5 | log_info 'Setting up Apple Developer ID for application codesigning...' 6 | read CODESIGN_IDENT'?Apple Developer Application ID: ' 7 | } 8 | 9 | typeset -g CODESIGN_TEAM=$(print "${CODESIGN_IDENT}" | /usr/bin/sed -En 's/.+\((.+)\)/\1/p') 10 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/log_group: -------------------------------------------------------------------------------- 1 | autoload -Uz log_info 2 | 3 | if (( ! ${+_log_group} )) typeset -g _log_group=0 4 | 5 | if (( ${+CI} )) { 6 | if (( _log_group )) { 7 | print "::endgroup::" 8 | typeset -g _log_group=0 9 | } 10 | if (( # )) { 11 | print "::group::${@}" 12 | typeset -g _log_group=1 13 | } 14 | } else { 15 | if (( # )) log_info ${@} 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Exclude everything 2 | /* 3 | 4 | # Except for default project files 5 | !/.github 6 | !/build-aux 7 | !/cmake 8 | !/data 9 | !/src 10 | !.clang-format 11 | !.cmake-format.json 12 | !.gitignore 13 | !buildspec.json 14 | !CMakeLists.txt 15 | !CMakePresets.json 16 | !LICENSE 17 | !README.md 18 | 19 | # Exclude lock files 20 | *.lock.json 21 | 22 | # Exclude macOS legacy resource forks 23 | .DS_Store 24 | 25 | # Exclude CMake build number cache 26 | /cmake/.CMakeBuildNumber 27 | -------------------------------------------------------------------------------- /.github/workflows/dispatch.yaml: -------------------------------------------------------------------------------- 1 | name: Dispatch 2 | run-name: Dispatched Repository Actions - ${{ inputs.job }} ⌛️ 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | job: 7 | description: Dispatch job to run 8 | required: true 9 | type: choice 10 | options: 11 | - build 12 | permissions: 13 | contents: write 14 | jobs: 15 | check-and-build: 16 | if: inputs.job == 'build' 17 | uses: ./.github/workflows/build-project.yaml 18 | secrets: inherit 19 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/set_loglevel: -------------------------------------------------------------------------------- 1 | autoload -Uz log_debug log_error 2 | 3 | local -r _usage="Usage: %B${0}%b 4 | 5 | Set log level, following levels are supported: 0 (quiet), 1 (normal), 2 (verbose), 3 (debug)" 6 | 7 | if (( ! # )); then 8 | log_error 'Called without arguments.' 9 | log_output ${_usage} 10 | return 2 11 | elif (( ${1} >= 4 )); then 12 | log_error 'Called with loglevel > 3.' 13 | log_output ${_usage} 14 | fi 15 | 16 | typeset -g -i -r _loglevel=${1} 17 | log_debug "Log level set to '${1}'" 18 | -------------------------------------------------------------------------------- /cmake/macos/resources/ccache-launcher-c.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ "$1" == "${CMAKE_C_COMPILER}" ]] ; then 4 | shift 5 | fi 6 | 7 | export CCACHE_CPP2=true 8 | export CCACHE_DEPEND=true 9 | export CCACHE_DIRECT=true 10 | export CCACHE_FILECLONE=true 11 | export CCACHE_INODECACHE=true 12 | export CCACHE_NOCOMPILERCHECK='content' 13 | export CCACHE_SLOPPINESS='include_file_mtime,include_file_ctime,clang_index_store,system_headers' 14 | if [[ "${CI}" ]]; then 15 | export CCACHE_NOHASHDIR=true 16 | fi 17 | exec "${CMAKE_C_COMPILER_LAUNCHER}" "${CMAKE_C_COMPILER}" "$@" 18 | -------------------------------------------------------------------------------- /cmake/macos/resources/ccache-launcher-cxx.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ "$1" == "${CMAKE_CXX_COMPILER}" ]] ; then 4 | shift 5 | fi 6 | 7 | export CCACHE_CPP2=true 8 | export CCACHE_NODEPEND=true 9 | export CCACHE_DIRECT=true 10 | export CCACHE_FILECLONE=true 11 | export CCACHE_INODECACHE=true 12 | export CCACHE_NOCOMPILERCHECK='content' 13 | export CCACHE_SLOPPINESS='include_file_mtime,include_file_ctime,clang_index_store,system_headers' 14 | if [[ "${CI}" ]]; then 15 | export CCACHE_NOHASHDIR=true 16 | fi 17 | exec "${CMAKE_CXX_COMPILER_LAUNCHER}" "${CMAKE_CXX_COMPILER}" "$@" 18 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/check_macos: -------------------------------------------------------------------------------- 1 | autoload -Uz is-at-least log_group log_info log_error log_status read_codesign 2 | 3 | local macos_version=$(sw_vers -productVersion) 4 | 5 | log_group 'Install macOS build requirements' 6 | log_info 'Checking macOS version...' 7 | if ! is-at-least 11.0 ${macos_version}; then 8 | log_error "Minimum required macOS version is 11.0, but running on macOS ${macos_version}" 9 | return 2 10 | else 11 | log_status "macOS ${macos_version} is recent" 12 | fi 13 | 14 | log_info 'Checking for Homebrew...' 15 | if (( ! ${+commands[brew]} )) { 16 | log_error 'No Homebrew command found. Please install Homebrew (https://brew.sh)' 17 | return 2 18 | } 19 | 20 | brew bundle --file ${SCRIPT_HOME}/.Brewfile 21 | rehash 22 | log_group 23 | -------------------------------------------------------------------------------- /.github/workflows/check-format.yaml: -------------------------------------------------------------------------------- 1 | name: Check Code Formatting 🛠️ 2 | on: 3 | workflow_call: 4 | jobs: 5 | clang-format: 6 | runs-on: ubuntu-22.04 7 | steps: 8 | - uses: actions/checkout@v4 9 | with: 10 | fetch-depth: 0 11 | - name: clang-format check 🐉 12 | id: clang-format 13 | uses: ./.github/actions/run-clang-format 14 | with: 15 | failCondition: error 16 | 17 | cmake-format: 18 | runs-on: ubuntu-22.04 19 | steps: 20 | - uses: actions/checkout@v4 21 | with: 22 | fetch-depth: 0 23 | - name: cmake-format check 🎛️ 24 | id: cmake-format 25 | uses: ./.github/actions/run-cmake-format 26 | with: 27 | failCondition: error 28 | -------------------------------------------------------------------------------- /.cmake-format.json: -------------------------------------------------------------------------------- 1 | { 2 | "format": { 3 | "line_width": 120, 4 | "tab_size": 2, 5 | "enable_sort": true, 6 | "autosort": true 7 | }, 8 | "additional_commands": { 9 | "set_target_properties_obs": { 10 | "pargs": 1, 11 | "flags": [], 12 | "kwargs": { 13 | "PROPERTIES": { 14 | "kwargs": { 15 | "PREFIX": 1, 16 | "OUTPUT_NAME": 1, 17 | "FOLDER": 1, 18 | "VERSION": 1, 19 | "SOVERSION": 1, 20 | "AUTOMOC": 1, 21 | "AUTOUIC": 1, 22 | "AUTORCC": 1, 23 | "AUTOUIC_SEARCH_PATHS": 1, 24 | "BUILD_RPATH": 1, 25 | "INSTALL_RPATH": 1 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cmake/common/ccache.cmake: -------------------------------------------------------------------------------- 1 | # CMake ccache module 2 | 3 | include_guard(GLOBAL) 4 | 5 | if(NOT DEFINED CCACHE_PROGRAM) 6 | message(DEBUG "Trying to find ccache on build host...") 7 | find_program(CCACHE_PROGRAM "ccache") 8 | mark_as_advanced(CCACHE_PROGRAM) 9 | endif() 10 | 11 | if(CCACHE_PROGRAM) 12 | message(DEBUG "Ccache found as ${CCACHE_PROGRAM}...") 13 | option(ENABLE_CCACHE "Enable compiler acceleration with ccache" ON) 14 | 15 | if(ENABLE_CCACHE) 16 | set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") 17 | set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") 18 | set(CMAKE_OBJC_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") 19 | set(CMAKE_OBJCXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") 20 | set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") 21 | endif() 22 | endif() 23 | -------------------------------------------------------------------------------- /cmake/linux/toolchains/x86_64-linux-gcc.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 3 | set(CMAKE_CROSSCOMPILING TRUE) 4 | 5 | set(CMAKE_C_COMPILER /usr/bin/x86_64-linux-gnu-gcc) 6 | set(CMAKE_CXX_COMPILER /usr/bin/x86_64-linux-gnu-g++) 7 | 8 | set(CMAKE_FIND_ROOT_PATH /usr/x86_64-linux-gnu) 9 | 10 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 11 | 12 | set(PKG_CONFIG_EXECUTABLE 13 | /usr/bin/x86_64-linux-gnu-pkg-config 14 | CACHE FILEPATH "pkg-config executable") 15 | 16 | set(CPACK_READELF_EXECUTABLE /usr/bin/x86_64-linux-gnu-readelf) 17 | set(CPACK_OBJCOPY_EXECUTABLE /usr/bin/x86_64-linux-gnu-objcopy) 18 | set(CPACK_OBJDUMP_EXECUTABLE /usr/bin/x86_64-linux-gnu-objdump) 19 | set(CPACK_PACKAGE_ARCHITECTURE x86_64) 20 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE x86_64) 21 | -------------------------------------------------------------------------------- /src/augmented-filter-data.h: -------------------------------------------------------------------------------- 1 | #ifndef FILTERDATA_H 2 | #define FILTERDATA_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | /** 14 | * @brief The filter_data struct 15 | * 16 | * This struct is used to store the base data needed for ORT filters. 17 | * 18 | */ 19 | struct augmented_filter_data { 20 | obs_source_t *source; 21 | gs_texrender_t *texrender; 22 | gs_stagesurf_t *stagesurface; 23 | 24 | const aiScene *asset; 25 | 26 | cv::Mat inputBGRA; 27 | cv::Mat outputPreviewBGRA; 28 | cv::Mat outputMask; 29 | 30 | bool isDisabled; 31 | bool preview; 32 | 33 | std::mutex inputBGRALock; 34 | std::mutex outputLock; 35 | std::mutex modelMutex; 36 | }; 37 | 38 | #endif /* FILTERDATA_H */ 39 | -------------------------------------------------------------------------------- /cmake/linux/toolchains/aarch64-linux-gcc.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR aarch64) 3 | set(CMAKE_CROSSCOMPILING TRUE) 4 | 5 | set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc) 6 | set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++) 7 | 8 | set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) 9 | 10 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 11 | 12 | set(PKG_CONFIG_EXECUTABLE 13 | /usr/bin/aarch64-linux-gnu-pkg-config 14 | CACHE FILEPATH "pkg-config executable") 15 | 16 | set(CPACK_READELF_EXECUTABLE /usr/bin/aarch64-linux-gnu-readelf) 17 | set(CPACK_OBJCOPY_EXECUTABLE /usr/bin/aarch64-linux-gnu-objcopy) 18 | set(CPACK_OBJDUMP_EXECUTABLE /usr/bin/aarch64-linux-gnu-objdump) 19 | set(CPACK_PACKAGE_ARCHITECTURE arm64) 20 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE arm64) 21 | -------------------------------------------------------------------------------- /src/augmented-filter.c: -------------------------------------------------------------------------------- 1 | #include "augmented-filter.h" 2 | 3 | struct obs_source_info augmented_filter_info = { 4 | .id = "augmented_filter", 5 | .type = OBS_SOURCE_TYPE_FILTER, 6 | .output_flags = OBS_SOURCE_VIDEO, 7 | .get_name = augmented_filter_name, 8 | .create = augmented_filter_create, 9 | .destroy = augmented_filter_destroy, 10 | .get_defaults = augmented_filter_defaults, 11 | .get_properties = augmented_filter_properties, 12 | .update = augmented_filter_update, 13 | .activate = augmented_filter_activate, 14 | .deactivate = augmented_filter_deactivate, 15 | .filter_remove = augmented_filter_remove, 16 | .show = augmented_filter_show, 17 | .hide = augmented_filter_hide, 18 | .video_tick = augmented_filter_video_tick, 19 | .video_render = augmented_filter_video_render, 20 | }; 21 | -------------------------------------------------------------------------------- /.github/workflows/pr-pull.yaml: -------------------------------------------------------------------------------- 1 | name: Pull Request 2 | run-name: ${{ github.event.pull_request.title }} pull request run 🚀 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | paths-ignore: 7 | - '**.md' 8 | branches: [master, main] 9 | types: [ opened, synchronize, reopened ] 10 | permissions: 11 | contents: read 12 | concurrency: 13 | group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' 14 | cancel-in-progress: true 15 | jobs: 16 | check-format: 17 | name: Check Formatting 🔍 18 | uses: ./.github/workflows/check-format.yaml 19 | permissions: 20 | contents: read 21 | 22 | build-project: 23 | name: Build Project 🧱 24 | uses: ./.github/workflows/build-project.yaml 25 | secrets: inherit 26 | permissions: 27 | contents: read 28 | -------------------------------------------------------------------------------- /.github/scripts/utils.pwsh/Ensure-Location.ps1: -------------------------------------------------------------------------------- 1 | function Ensure-Location { 2 | <# 3 | .SYNOPSIS 4 | Ensures current location to be set to specified directory. 5 | .DESCRIPTION 6 | If specified directory exists, switch to it. Otherwise create it, 7 | then switch. 8 | .EXAMPLE 9 | Ensure-Location "My-Directory" 10 | Ensure-Location -Path "Path-To-My-Directory" 11 | #> 12 | 13 | param( 14 | [Parameter(Mandatory)] 15 | [string] $Path 16 | ) 17 | 18 | if ( ! ( Test-Path $Path ) ) { 19 | $_Params = @{ 20 | ItemType = "Directory" 21 | Path = ${Path} 22 | ErrorAction = "SilentlyContinue" 23 | } 24 | 25 | New-Item @_Params | Set-Location 26 | } else { 27 | Set-Location -Path ${Path} 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cmake/windows/buildspec.cmake: -------------------------------------------------------------------------------- 1 | # CMake Windows build dependencies module 2 | 3 | include_guard(GLOBAL) 4 | 5 | include(buildspec_common) 6 | 7 | # _check_dependencies_windows: Set up Windows slice for _check_dependencies 8 | function(_check_dependencies_windows) 9 | set(arch ${CMAKE_GENERATOR_PLATFORM}) 10 | set(platform windows-${arch}) 11 | 12 | set(dependencies_dir "${CMAKE_CURRENT_SOURCE_DIR}/.deps") 13 | set(prebuilt_filename "windows-deps-VERSION-ARCH-REVISION.zip") 14 | set(prebuilt_destination "obs-deps-VERSION-ARCH") 15 | set(qt6_filename "windows-deps-qt6-VERSION-ARCH-REVISION.zip") 16 | set(qt6_destination "obs-deps-qt6-VERSION-ARCH") 17 | set(obs-studio_filename "VERSION.zip") 18 | set(obs-studio_destination "obs-studio-VERSION") 19 | set(dependencies_list prebuilt qt6 obs-studio) 20 | 21 | _check_dependencies() 22 | endfunction() 23 | 24 | _check_dependencies_windows() 25 | -------------------------------------------------------------------------------- /cmake/common/buildnumber.cmake: -------------------------------------------------------------------------------- 1 | # CMake build number module 2 | 3 | include_guard(GLOBAL) 4 | 5 | # Define build number cache file 6 | set(_BUILD_NUMBER_CACHE 7 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/.CMakeBuildNumber" 8 | CACHE INTERNAL "OBS build number cache file") 9 | 10 | # Read build number from cache file or manual override 11 | if(NOT DEFINED PLUGIN_BUILD_NUMBER AND EXISTS "${_BUILD_NUMBER_CACHE}") 12 | file(READ "${_BUILD_NUMBER_CACHE}" PLUGIN_BUILD_NUMBER) 13 | math(EXPR PLUGIN_BUILD_NUMBER "${PLUGIN_BUILD_NUMBER}+1") 14 | elseif(NOT DEFINED PLUGIN_BUILD_NUMBER) 15 | if($ENV{CI}) 16 | if($ENV{GITHUB_RUN_ID}) 17 | set(PLUGIN_BUILD_NUMBER "$ENV{GITHUB_RUN_ID}") 18 | elseif($ENV{GITLAB_RUN_ID}) 19 | set(PLUGIN_BUILD_NUMBER "$ENV{GITLAB_RUN_ID}") 20 | else() 21 | set(PLUGIN_BUILD_NUMBER "1") 22 | endif() 23 | else() 24 | set(PLUGIN_BUILD_NUMBER "1") 25 | endif() 26 | endif() 27 | file(WRITE "${_BUILD_NUMBER_CACHE}" "${PLUGIN_BUILD_NUMBER}") 28 | -------------------------------------------------------------------------------- /cmake/common/osconfig.cmake: -------------------------------------------------------------------------------- 1 | # CMake operating system bootstrap module 2 | 3 | include_guard(GLOBAL) 4 | 5 | # Set minimum CMake version specific to host operating system, add OS-specific module directory to default search paths, 6 | # and set helper variables for OS detection in other CMake list files. 7 | if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") 8 | set(CMAKE_C_EXTENSIONS FALSE) 9 | set(CMAKE_CXX_EXTENSIONS FALSE) 10 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/windows") 11 | set(OS_WINDOWS TRUE) 12 | elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") 13 | set(CMAKE_C_EXTENSIONS FALSE) 14 | set(CMAKE_CXX_EXTENSIONS FALSE) 15 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos") 16 | set(OS_MACOS TRUE) 17 | elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD") 18 | set(CMAKE_CXX_EXTENSIONS FALSE) 19 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux") 20 | string(TOUPPER "${CMAKE_HOST_SYSTEM_NAME}" _SYSTEM_NAME_U) 21 | set(OS_${_SYSTEM_NAME_U} TRUE) 22 | endif() 23 | -------------------------------------------------------------------------------- /cmake/windows/resources/resource.rc.in: -------------------------------------------------------------------------------- 1 | 1 VERSIONINFO 2 | FILEVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0 3 | PRODUCTVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0 4 | FILEFLAGSMASK 0x0L 5 | #ifdef _DEBUG 6 | FILEFLAGS 0x1L 7 | #else 8 | FILEFLAGS 0x0L 9 | #endif 10 | FILEOS 0x0L 11 | FILETYPE 0x2L 12 | FILESUBTYPE 0x0L 13 | BEGIN 14 | BLOCK "StringFileInfo" 15 | BEGIN 16 | BLOCK "040904b0" 17 | BEGIN 18 | VALUE "CompanyName", "${PLUGIN_AUTHOR}" 19 | VALUE "FileDescription", "${PROJECT_NAME}" 20 | VALUE "FileVersion", "${PROJECT_VERSION}" 21 | VALUE "InternalName", "${PROJECT_NAME}" 22 | VALUE "LegalCopyright", "(C) ${CURRENT_YEAR} ${PLUGIN_AUTHOR}" 23 | VALUE "OriginalFilename", "${PROJECT_NAME}" 24 | VALUE "ProductName", "${PROJECT_NAME}" 25 | VALUE "ProductVersion", "${PROJECT_VERSION}" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x409, 1200 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /src/plugin-support.h: -------------------------------------------------------------------------------- 1 | /* 2 | OBS Augmented Filter Plugin 3 | Copyright (C) 2024 Roy Shilkrot roy.shil@gmail.com 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program. If not, see 17 | */ 18 | 19 | #pragma once 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | extern const char *PLUGIN_NAME; 31 | extern const char *PLUGIN_VERSION; 32 | 33 | void obs_log(int log_level, const char *format, ...); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /.github/scripts/utils.pwsh/Invoke-External.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-External { 2 | <# 3 | .SYNOPSIS 4 | Invokes a non-PowerShell command. 5 | .DESCRIPTION 6 | Runs a non-PowerShell command, and captures its return code. 7 | Throws an exception if the command returns non-zero. 8 | .EXAMPLE 9 | Invoke-External 7z x $MyArchive 10 | #> 11 | 12 | if ( $args.Count -eq 0 ) { 13 | throw 'Invoke-External called without arguments.' 14 | } 15 | 16 | if ( ! ( Test-Path function:Log-Information ) ) { 17 | . $PSScriptRoot/Logger.ps1 18 | } 19 | 20 | $Command = $args[0] 21 | $CommandArgs = @() 22 | 23 | if ( $args.Count -gt 1) { 24 | $CommandArgs = $args[1..($args.Count - 1)] 25 | } 26 | 27 | $_EAP = $ErrorActionPreference 28 | $ErrorActionPreference = "Continue" 29 | 30 | Log-Debug "Invoke-External: ${Command} ${CommandArgs}" 31 | 32 | & $command $commandArgs 33 | $Result = $LASTEXITCODE 34 | 35 | $ErrorActionPreference = $_EAP 36 | 37 | if ( $Result -ne 0 ) { 38 | throw "${Command} ${CommandArgs} exited with non-zero code ${Result}." 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/setup_ccache: -------------------------------------------------------------------------------- 1 | autoload -Uz log_debug log_warning 2 | 3 | if (( ! ${+project_root} )) { 4 | log_error "'project_root' not set. Please set before running ${0}." 5 | return 2 6 | } 7 | 8 | if (( ${+commands[ccache]} )) { 9 | log_debug "Found ccache at ${commands[ccache]}" 10 | 11 | typeset -gx CCACHE_CONFIGPATH="${project_root}/.ccache.conf" 12 | 13 | ccache --set-config=run_second_cpp=true 14 | ccache --set-config=direct_mode=true 15 | ccache --set-config=inode_cache=true 16 | ccache --set-config=compiler_check=content 17 | ccache --set-config=file_clone=true 18 | 19 | local -a sloppiness=( 20 | include_file_mtime 21 | include_file_ctime 22 | file_stat_matches 23 | system_headers 24 | ) 25 | 26 | if [[ ${host_os} == macos ]] { 27 | sloppiness+=( 28 | modules 29 | clang_index_store 30 | ) 31 | 32 | ccache --set-config=sloppiness=${(j:,:)sloppiness} 33 | } 34 | 35 | if (( ${+CI} )) { 36 | ccache --set-config=cache_dir="${GITHUB_WORKSPACE:-${HOME}}/.ccache" 37 | ccache --set-config=max_size="${CCACHE_SIZE:-1G}" 38 | ccache -z > /dev/null 39 | } 40 | } else { 41 | log_warning "No ccache found on the system" 42 | } 43 | -------------------------------------------------------------------------------- /src/augmented-filter.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #define MT_ obs_module_text 8 | 9 | void augmented_filter_activate(void *data); 10 | void *augmented_filter_create(obs_data_t *settings, obs_source_t *filter); 11 | void augmented_filter_update(void *data, obs_data_t *s); 12 | void augmented_filter_destroy(void *data); 13 | const char *augmented_filter_name(void *unused); 14 | void augmented_filter_deactivate(void *data); 15 | void augmented_filter_defaults(obs_data_t *s); 16 | obs_properties_t *augmented_filter_properties(void *data); 17 | void augmented_filter_remove(void *data, obs_source_t *source); 18 | void augmented_filter_show(void *data); 19 | void augmented_filter_hide(void *data); 20 | void augmented_filter_video_tick(void *data, float seconds); 21 | void augmented_filter_video_render(void *data, gs_effect_t *_effect); 22 | 23 | const char *const PLUGIN_INFO_TEMPLATE = 24 | "Augmented (%1) by " 25 | "OCC AI ❤️ " 26 | "Support & Follow"; 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /cmake/macos/buildspec.cmake: -------------------------------------------------------------------------------- 1 | # CMake macOS build dependencies module 2 | 3 | include_guard(GLOBAL) 4 | 5 | include(buildspec_common) 6 | 7 | # _check_dependencies_macos: Set up macOS slice for _check_dependencies 8 | function(_check_dependencies_macos) 9 | set(arch universal) 10 | set(platform macos) 11 | 12 | file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec) 13 | 14 | set(dependencies_dir "${CMAKE_CURRENT_SOURCE_DIR}/.deps") 15 | set(prebuilt_filename "macos-deps-VERSION-ARCH_REVISION.tar.xz") 16 | set(prebuilt_destination "obs-deps-VERSION-ARCH") 17 | set(qt6_filename "macos-deps-qt6-VERSION-ARCH-REVISION.tar.xz") 18 | set(qt6_destination "obs-deps-qt6-VERSION-ARCH") 19 | set(obs-studio_filename "VERSION.tar.gz") 20 | set(obs-studio_destination "obs-studio-VERSION") 21 | set(dependencies_list prebuilt qt6 obs-studio) 22 | 23 | _check_dependencies() 24 | 25 | execute_process(COMMAND "xattr" -r -d com.apple.quarantine "${dependencies_dir}" 26 | RESULT_VARIABLE result COMMAND_ERROR_IS_FATAL ANY) 27 | 28 | list(APPEND CMAKE_FRAMEWORK_PATH "${dependencies_dir}/Frameworks") 29 | set(CMAKE_FRAMEWORK_PATH 30 | ${CMAKE_FRAMEWORK_PATH} 31 | PARENT_SCOPE) 32 | endfunction() 33 | 34 | _check_dependencies_macos() 35 | -------------------------------------------------------------------------------- /src/plugin-main.c: -------------------------------------------------------------------------------- 1 | /* 2 | OBS Augmented Filter Plugin 3 | Copyright (C) 2024 Roy Shilkrot roy.shil@gmail.com 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program. If not, see 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | OBS_DECLARE_MODULE() 23 | OBS_MODULE_USE_DEFAULT_LOCALE(PLUGIN_NAME, "en-US") 24 | 25 | extern struct obs_source_info augmented_filter_info; 26 | 27 | bool obs_module_load(void) 28 | { 29 | obs_log(LOG_INFO, "plugin loaded successfully (version %s)", 30 | PLUGIN_VERSION); 31 | obs_register_source(&augmented_filter_info); 32 | return true; 33 | } 34 | 35 | void obs_module_unload(void) 36 | { 37 | obs_log(LOG_INFO, "plugin unloaded"); 38 | } 39 | -------------------------------------------------------------------------------- /src/plugin-support.c.in: -------------------------------------------------------------------------------- 1 | /* 2 | OBS Augmented Filter Plugin 3 | Copyright (C) 2024 Roy Shilkrot roy.shil@gmail.com 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program. If not, see 17 | */ 18 | 19 | #include 20 | 21 | const char *PLUGIN_NAME = "@CMAKE_PROJECT_NAME@"; 22 | const char *PLUGIN_VERSION = "@CMAKE_PROJECT_VERSION@"; 23 | 24 | extern void blogva(int log_level, const char *format, va_list args); 25 | 26 | void obs_log(int log_level, const char *format, ...) 27 | { 28 | size_t length = 4 + strlen(PLUGIN_NAME) + strlen(format); 29 | 30 | char *template = malloc(length + 1); 31 | 32 | snprintf(template, length, "[%s] %s", PLUGIN_NAME, format); 33 | 34 | va_list(args); 35 | 36 | va_start(args, format); 37 | blogva(log_level, template, args); 38 | va_end(args); 39 | 40 | free(template); 41 | } 42 | -------------------------------------------------------------------------------- /cmake/macos/resources/distribution.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | @CMAKE_PROJECT_NAME@ 10 | 11 | 12 | 13 | 14 | 15 | 16 | #@CMAKE_PROJECT_NAME@.pkg 17 | 18 | 33 | 34 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/read_codesign_pass: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Apple Developer credentials necessary: 3 | # 4 | # + Signing for distribution and notarization require an active Apple 5 | # Developer membership 6 | # + An Apple Development identity is needed for code signing 7 | # (i.e. 'Apple Development: YOUR APPLE ID (PROVIDER)') 8 | # + Your Apple developer ID is needed for notarization 9 | # + An app-specific password is necessary for notarization from CLI 10 | # + This password will be stored in your macOS keychain under the identifier 11 | # 'OBS-Codesign-Password'with access Apple's 'altool' only. 12 | ############################################################################## 13 | 14 | autoload -Uz read_codesign read_codesign_user log_info log_warning 15 | 16 | if (( ! ${+CODESIGN_IDENT} )) { 17 | read_codesign 18 | } 19 | 20 | if (( ! ${+CODESIGN_IDENT_USER} )) { 21 | read_codesign_user 22 | } 23 | 24 | log_info 'Setting up password for notarization keychain...' 25 | if (( ! ${+CODESIGN_IDENT_PASS} )) { 26 | read -s CODESIGN_IDENT_PASS'?Apple Developer ID password: ' 27 | } 28 | 29 | print '' 30 | log_info 'Setting up notarization keychain...' 31 | log_warning " 32 | + Your Apple ID and an app-specific password is necessary for notarization from CLI 33 | + This password will be stored in your macOS keychain under the identifier 34 | 'OBS-Codesign-Password' with access Apple's 'altool' only. 35 | 36 | " 37 | xcrun notarytool store-credentials 'OBS-Codesign-Password' --apple-id "${CODESIGN_IDENT_USER}" --team-id "${CODESIGN_TEAM}" --password "${CODESIGN_IDENT_PASS}" 38 | 39 | -------------------------------------------------------------------------------- /src/asset-utils/asset-loader.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include "plugin-support.h" 9 | 10 | const aiScene *load_asset(const char *path) 11 | { 12 | // Load asset from path using Assimp 13 | const aiScene *scene = 14 | aiImportFile(path, aiProcessPreset_TargetRealtime_MaxQuality); 15 | 16 | if (!scene) { 17 | obs_log(LOG_ERROR, "Failed to load asset: %s\n", 18 | aiGetErrorString()); 19 | return nullptr; 20 | } 21 | 22 | // print asset info 23 | obs_log(LOG_INFO, "Asset: %s", scene->mName.C_Str()); 24 | obs_log(LOG_INFO, "Number of meshes: %d", scene->mNumMeshes); 25 | obs_log(LOG_INFO, "Number of materials: %d", scene->mNumMaterials); 26 | obs_log(LOG_INFO, "Number of textures: %d", scene->mNumTextures); 27 | 28 | // print mesh info 29 | for (unsigned int i = 0; i < scene->mNumMeshes; i++) { 30 | aiMesh *mesh = scene->mMeshes[i]; 31 | obs_log(LOG_INFO, "Mesh %d: %s", i, mesh->mName.C_Str()); 32 | obs_log(LOG_INFO, "Number of vertices: %d", mesh->mNumVertices); 33 | obs_log(LOG_INFO, "Number of faces: %d", mesh->mNumFaces); 34 | } 35 | 36 | // print material info 37 | for (unsigned int i = 0; i < scene->mNumMaterials; i++) { 38 | aiMaterial *material = scene->mMaterials[i]; 39 | obs_log(LOG_INFO, "Material %d: %s", i, 40 | material->GetName().C_Str()); 41 | } 42 | 43 | // print texture info 44 | for (unsigned int i = 0; i < scene->mNumTextures; i++) { 45 | aiTexture *texture = scene->mTextures[i]; 46 | obs_log(LOG_INFO, "Texture %d: %s", i, 47 | texture->mFilename.C_Str()); 48 | } 49 | 50 | return scene; 51 | } 52 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/setup_linux: -------------------------------------------------------------------------------- 1 | autoload -Uz log_error log_status log_info mkcd 2 | 3 | if (( ! ${+project_root} )) { 4 | log_error "'project_root' not set. Please set before running ${0}." 5 | return 2 6 | } 7 | 8 | if (( ! ${+target} )) { 9 | log_error "'target' not set. Please set before running ${0}." 10 | return 2 11 | } 12 | 13 | pushd ${project_root} 14 | 15 | typeset -g QT_VERSION 16 | 17 | local -a apt_args=( 18 | ${CI:+-y} 19 | --no-install-recommends 20 | ) 21 | if (( _loglevel == 0 )) apt_args+=(--quiet) 22 | 23 | if (( ! (${skips[(Ie)all]} + ${skips[(Ie)deps]}) )) { 24 | log_group 'Installing obs-studio build dependencies...' 25 | 26 | local suffix 27 | if [[ ${CPUTYPE} != "${target##*-}" ]] { 28 | local -A arch_mappings=( 29 | aarch64 arm64 30 | x86_64 amd64 31 | ) 32 | 33 | suffix=":${arch_mappings[${target##*-}]}" 34 | 35 | sudo apt-get install ${apt_args} gcc-${${target##*-}//_/-}-linux-gnu g++-${${target##*-}//_/-}-linux-gnu 36 | } 37 | 38 | sudo add-apt-repository --yes ppa:obsproject/obs-studio 39 | sudo apt update 40 | 41 | sudo apt-get install ${apt_args} \ 42 | build-essential \ 43 | libgles2-mesa-dev \ 44 | obs-studio 45 | 46 | local -a _qt_packages=() 47 | 48 | if (( QT_VERSION == 5 )) { 49 | _qt_packages+=( 50 | qtbase5-dev${suffix} 51 | libqt5svg5-dev${suffix} 52 | qtbase5-private-dev${suffix} 53 | libqt5x11extras5-dev${suffix} 54 | ) 55 | } else { 56 | _qt_packages+=( 57 | qt6-base-dev${suffix} 58 | libqt6svg6-dev${suffix} 59 | qt6-base-private-dev${suffix} 60 | ) 61 | } 62 | 63 | sudo apt-get install ${apt_args} ${_qt_packages} 64 | log_group 65 | } 66 | -------------------------------------------------------------------------------- /cmake/macos/defaults.cmake: -------------------------------------------------------------------------------- 1 | # CMake macOS defaults module 2 | 3 | include_guard(GLOBAL) 4 | 5 | # Set empty codesigning team if not specified as cache variable 6 | if(NOT CODESIGN_TEAM) 7 | set(CODESIGN_TEAM 8 | "" 9 | CACHE STRING "OBS code signing team for macOS" FORCE) 10 | 11 | # Set ad-hoc codesigning identity if not specified as cache variable 12 | if(NOT CODESIGN_IDENTITY) 13 | set(CODESIGN_IDENTITY 14 | "-" 15 | CACHE STRING "OBS code signing identity for macOS" FORCE) 16 | endif() 17 | endif() 18 | 19 | if(XCODE) 20 | include(xcode) 21 | endif() 22 | 23 | include(buildspec) 24 | 25 | # Set default deployment target to 11.0 if not set and enable selection in GUI up to 13.0 26 | if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) 27 | set(CMAKE_OSX_DEPLOYMENT_TARGET 28 | 11.0 29 | CACHE STRING "Minimum macOS version to target for deployment (at runtime). Newer APIs will be weak-linked." FORCE) 30 | endif() 31 | set_property(CACHE CMAKE_OSX_DEPLOYMENT_TARGET PROPERTY STRINGS 13.0 12.0 11.0) 32 | 33 | # Use Applications directory as default install destination 34 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 35 | set(CMAKE_INSTALL_PREFIX 36 | "$ENV{HOME}/Library/Application Support/obs-studio/plugins" 37 | CACHE STRING "Directory to install OBS after building" FORCE) 38 | endif() 39 | 40 | # Enable find_package targets to become globally available targets 41 | set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) 42 | # Enable RPATH support for generated binaries 43 | set(CMAKE_MACOSX_RPATH TRUE) 44 | # Use RPATHs from build tree _in_ the build tree 45 | set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 46 | # Do not add default linker search paths to RPATH 47 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) 48 | # Use common bundle-relative RPATH for installed targets 49 | set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks") 50 | -------------------------------------------------------------------------------- /.github/scripts/utils.zsh/check_linux: -------------------------------------------------------------------------------- 1 | autoload -Uz log_info log_status log_error log_debug log_warning log_group 2 | 3 | log_group 'Check Linux build requirements' 4 | log_debug 'Checking Linux distribution name and version...' 5 | 6 | # Check for Ubuntu version 22.10 or later, which have srt and librist available via apt-get 7 | typeset -g -i UBUNTU_2210_OR_LATER=0 8 | if [[ -f /etc/os_release ]] { 9 | local dist_name 10 | local dist_version 11 | read -r dist_name dist_version <<< "$(source /etc/os_release; print "${NAME} ${VERSION_ID}")" 12 | 13 | autoload -Uz is-at-least 14 | if [[ ${dist_name} == Ubuntu ]] && is-at-least 22.10 ${dist_version}; then 15 | typeset -g -i UBUNTU_2210_OR_LATER=1 16 | fi 17 | } 18 | 19 | log_debug 'Checking for apt-get...' 20 | if (( ! ${+commands[apt-get]} )) { 21 | log_error 'No apt-get command found. Please install apt' 22 | return 2 23 | } else { 24 | log_debug "Apt-get located at ${commands[apt-get]}" 25 | } 26 | 27 | local -a dependencies=("${(fA)$(<${SCRIPT_HOME}/.Aptfile)}") 28 | local -a install_list 29 | local binary 30 | 31 | sudo apt-get update -qq 32 | 33 | for dependency (${dependencies}) { 34 | local -a tokens=(${=dependency//(,|:|\')/}) 35 | 36 | if [[ ! ${tokens[1]} == 'package' ]] continue 37 | 38 | if [[ ${#tokens} -gt 2 && ${tokens[3]} == 'bin' ]] { 39 | binary=${tokens[4]} 40 | } else { 41 | binary=${tokens[2]} 42 | } 43 | 44 | if (( ! ${+commands[${binary}]} )) install_list+=(${tokens[2]}) 45 | } 46 | 47 | log_debug "List of dependencies to install: ${install_list}" 48 | if (( ${#install_list} )) { 49 | if (( ! ${+CI} )) log_warning 'Dependency installation via apt may require elevated privileges' 50 | 51 | local -a apt_args=( 52 | ${CI:+-y} 53 | --no-install-recommends 54 | ) 55 | if (( _loglevel == 0 )) apt_args+=(--quiet) 56 | 57 | sudo apt-get ${apt_args} install ${install_list} 58 | } 59 | 60 | rehash 61 | log_group 62 | -------------------------------------------------------------------------------- /cmake/linux/toolchains/x86_64-linux-clang.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 3 | set(CMAKE_CROSSCOMPILING TRUE) 4 | 5 | set(CMAKE_C_COMPILER /usr/bin/clang) 6 | set(CMAKE_CXX_COMPILER /usr/bin/clang++) 7 | 8 | set(CMAKE_C_COMPILER_TARGET x86_64-linux-gnu) 9 | set(CMAKE_CXX_COMPILER_TARGET x86_64-linux-gnu) 10 | 11 | set(CMAKE_FIND_ROOT_PATH /usr/x86_64-linux-gnu) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 13 | set(PKG_CONFIG_EXECUTABLE 14 | /usr/bin/x86_64-linux-gnu-pkg-config 15 | CACHE FILEPATH "pkg-config executable") 16 | 17 | execute_process( 18 | COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-ranlib 19 | OUTPUT_VARIABLE CMAKE_RANLIB 20 | OUTPUT_STRIP_TRAILING_WHITESPACE) 21 | 22 | execute_process( 23 | COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-ar 24 | OUTPUT_VARIABLE CMAKE_LLVM_AR 25 | OUTPUT_STRIP_TRAILING_WHITESPACE) 26 | 27 | execute_process( 28 | COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-readelf 29 | OUTPUT_VARIABLE READELF 30 | OUTPUT_STRIP_TRAILING_WHITESPACE) 31 | 32 | execute_process( 33 | COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-objcopy 34 | OUTPUT_VARIABLE CMAKE_LLVM_OBJCOPY 35 | OUTPUT_STRIP_TRAILING_WHITESPACE) 36 | 37 | execute_process( 38 | COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-objdump 39 | OUTPUT_VARIABLE CMAKE_LLVM_OBJDUMP 40 | OUTPUT_STRIP_TRAILING_WHITESPACE) 41 | 42 | set(CMAKE_AR 43 | "${CMAKE_LLVM_AR}" 44 | CACHE INTERNAL "${CMAKE_SYSTEM_NAME} ar" FORCE) 45 | set(CMAKE_OBJCOPY 46 | "${CMAKE_LLVM_OBJCOPY}" 47 | CACHE INTERNAL "${CMAKE_SYSTEM_NAME} objcopy" FORCE) 48 | set(CMAKE_OBJDUMP 49 | "${CMAKE_LLVM_OBJDUMP}" 50 | CACHE INTERNAL "${CMAKE_SYSTEM_NAME} objdump" FORCE) 51 | 52 | set(CPACK_READELF_EXECUTABLE "${READELF}") 53 | set(CPACK_OBJCOPY_EXECUTABLE "${CMAKE_LLVM_OBJCOPY}") 54 | set(CPACK_OBJDUMP_EXECUTABLE "${CMAKE_LLVM_OBJDUMP}") 55 | set(CPACK_PACKAGE_ARCHITECTURE x86_64) 56 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE x86_64) 57 | -------------------------------------------------------------------------------- /cmake/linux/toolchains/aarch64-linux-clang.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR aarch64) 3 | set(CMAKE_CROSSCOMPILING TRUE) 4 | 5 | set(CMAKE_C_COMPILER /usr/bin/clang) 6 | set(CMAKE_CXX_COMPILER /usr/bin/clang++) 7 | 8 | set(CMAKE_C_COMPILER_TARGET aarch64-linux-gnu) 9 | set(CMAKE_CXX_COMPILER_TARGET aarch64-linux-gnu) 10 | 11 | set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 13 | set(PKG_CONFIG_EXECUTABLE 14 | /usr/bin/aarch64-linux-gnu-pkg-config 15 | CACHE FILEPATH "pkg-config executable") 16 | 17 | execute_process( 18 | COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-ranlib 19 | OUTPUT_VARIABLE CMAKE_RANLIB 20 | OUTPUT_STRIP_TRAILING_WHITESPACE) 21 | 22 | execute_process( 23 | COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-ar 24 | OUTPUT_VARIABLE CMAKE_LLVM_AR 25 | OUTPUT_STRIP_TRAILING_WHITESPACE) 26 | 27 | execute_process( 28 | COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-readelf 29 | OUTPUT_VARIABLE READELF 30 | OUTPUT_STRIP_TRAILING_WHITESPACE) 31 | 32 | execute_process( 33 | COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-objcopy 34 | OUTPUT_VARIABLE CMAKE_LLVM_OBJCOPY 35 | OUTPUT_STRIP_TRAILING_WHITESPACE) 36 | 37 | execute_process( 38 | COMMAND ${CMAKE_C_COMPILER} -print-prog-name=llvm-objdump 39 | OUTPUT_VARIABLE CMAKE_LLVM_OBJDUMP 40 | OUTPUT_STRIP_TRAILING_WHITESPACE) 41 | 42 | set(CMAKE_AR 43 | "${CMAKE_LLVM_AR}" 44 | CACHE INTERNAL "${CMAKE_SYSTEM_NAME} ar" FORCE) 45 | set(CMAKE_OBJCOPY 46 | "${CMAKE_LLVM_OBJCOPY}" 47 | CACHE INTERNAL "${CMAKE_SYSTEM_NAME} objcopy" FORCE) 48 | set(CMAKE_OBJDUMP 49 | "${CMAKE_LLVM_OBJDUMP}" 50 | CACHE INTERNAL "${CMAKE_SYSTEM_NAME} objdump" FORCE) 51 | 52 | set(CPACK_READELF_EXECUTABLE "${READELF}") 53 | set(CPACK_OBJCOPY_EXECUTABLE "${CMAKE_LLVM_OBJCOPY}") 54 | set(CPACK_OBJDUMP_EXECUTABLE "${CMAKE_LLVM_OBJDUMP}") 55 | set(CPACK_PACKAGE_ARCHITECTURE arm64) 56 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE arm64) 57 | -------------------------------------------------------------------------------- /cmake/common/helpers_common.cmake: -------------------------------------------------------------------------------- 1 | # CMake common helper functions module 2 | 3 | # cmake-format: off 4 | # cmake-lint: disable=C0103 5 | # cmake-format: on 6 | 7 | include_guard(GLOBAL) 8 | 9 | # check_uuid: Helper function to check for valid UUID 10 | function(check_uuid uuid_string return_value) 11 | set(valid_uuid TRUE) 12 | set(uuid_token_lengths 8 4 4 4 12) 13 | set(token_num 0) 14 | 15 | string(REPLACE "-" ";" uuid_tokens ${uuid_string}) 16 | list(LENGTH uuid_tokens uuid_num_tokens) 17 | 18 | if(uuid_num_tokens EQUAL 5) 19 | message(DEBUG "UUID ${uuid_string} is valid with 5 tokens.") 20 | foreach(uuid_token IN LISTS uuid_tokens) 21 | list(GET uuid_token_lengths ${token_num} uuid_target_length) 22 | string(LENGTH "${uuid_token}" uuid_actual_length) 23 | if(uuid_actual_length EQUAL uuid_target_length) 24 | string(REGEX MATCH "[0-9a-fA-F]+" uuid_hex_match ${uuid_token}) 25 | if(NOT uuid_hex_match STREQUAL uuid_token) 26 | set(valid_uuid FALSE) 27 | break() 28 | endif() 29 | else() 30 | set(valid_uuid FALSE) 31 | break() 32 | endif() 33 | math(EXPR token_num "${token_num}+1") 34 | endforeach() 35 | else() 36 | set(valid_uuid FALSE) 37 | endif() 38 | message(DEBUG "UUID ${uuid_string} valid: ${valid_uuid}") 39 | set(${return_value} 40 | ${valid_uuid} 41 | PARENT_SCOPE) 42 | endfunction() 43 | 44 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-support.c.in") 45 | configure_file(src/plugin-support.c.in plugin-support.c @ONLY) 46 | add_library(plugin-support STATIC) 47 | target_sources( 48 | plugin-support 49 | PRIVATE plugin-support.c 50 | PUBLIC src/plugin-support.h) 51 | target_include_directories(plugin-support PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src") 52 | if(OS_LINUX 53 | OR OS_FREEBSD 54 | OR OS_OPENBSD) 55 | # add fPIC on Linux to prevent shared object errors 56 | set_property(TARGET plugin-support PROPERTY POSITION_INDEPENDENT_CODE ON) 57 | endif() 58 | endif() 59 | -------------------------------------------------------------------------------- /cmake/BuildAssimp.cmake: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | set(ASSIMP_VERSION 5.4.1) 4 | set(ASSIMP_URL https://github.com/assimp/assimp/archive/refs/tags/v${ASSIMP_VERSION}.tar.gz) 5 | if(WIN32) 6 | set(ASSIMP_SHARE_LIB_NAME assimp-vc143-mt) 7 | else() 8 | set(ASSIMP_SHARE_LIB_NAME assimp) 9 | endif() 10 | 11 | ExternalProject_Add( 12 | assimp-build 13 | URL ${ASSIMP_URL} DOWNLOAD_EXTRACT_TIMESTAMP TRUE 14 | CMAKE_GENERATOR ${CMAKE_GENERATOR} 15 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= 16 | -DBUILD_SHARED_LIBS=ON 17 | -DASSIMP_BUILD_ASSIMP_TOOLS=OFF 18 | -DASSIMP_BUILD_TESTS=OFF 19 | -DASSIMP_BUILD_SAMPLES=OFF 20 | -DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=ON 21 | -DASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT=OFF 22 | -DASSIMP_INSTALL_PDB=OFF 23 | -DASSIMP_NO_EXPORT=ON) 24 | 25 | ExternalProject_Get_Property(assimp-build INSTALL_DIR) 26 | 27 | add_library(assimp::assimp SHARED IMPORTED) 28 | add_dependencies(assimp::assimp assimp-build) 29 | set_target_properties( 30 | assimp::assimp 31 | PROPERTIES IMPORTED_LOCATION 32 | ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}${ASSIMP_SHARE_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) 33 | if(WIN32) 34 | set_target_properties( 35 | assimp::assimp 36 | PROPERTIES IMPORTED_IMPLIB 37 | ${INSTALL_DIR}/lib/${CMAKE_IMPORT_LIBRARY_PREFIX}${ASSIMP_SHARE_LIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}) 38 | endif() 39 | target_include_directories(assimp::assimp INTERFACE ${INSTALL_DIR}/include) 40 | 41 | add_library(assimp INTERFACE) 42 | add_dependencies(assimp assimp-build) 43 | target_link_libraries(assimp INTERFACE assimp::assimp) 44 | target_include_directories(assimp INTERFACE ${INSTALL_DIR}/include) 45 | 46 | if(WIN32) 47 | # install the DLL to the plugin output directory 48 | install(FILES ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}${ASSIMP_SHARE_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} 49 | DESTINATION ${CMAKE_SOURCE_DIR}/release/${CMAKE_BUILD_TYPE}/obs-plugins/64bit) 50 | endif() 51 | -------------------------------------------------------------------------------- /cmake/windows/compilerconfig.cmake: -------------------------------------------------------------------------------- 1 | # CMake Windows compiler configuration module 2 | 3 | include_guard(GLOBAL) 4 | 5 | include(compiler_common) 6 | 7 | # CMake 3.24 introduces a bug mistakenly interpreting MSVC as supporting the '-pthread' compiler flag 8 | if(CMAKE_VERSION VERSION_EQUAL 3.24.0) 9 | set(THREADS_HAVE_PTHREAD_ARG FALSE) 10 | endif() 11 | 12 | # CMake 3.25 changed the way symbol generation is handled on Windows 13 | if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.25.0) 14 | if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") 15 | set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT ProgramDatabase) 16 | else() 17 | set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) 18 | endif() 19 | endif() 20 | 21 | message(DEBUG "Current Windows API version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") 22 | if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM) 23 | message(DEBUG "Maximum Windows API version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM}") 24 | endif() 25 | 26 | if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.20348) 27 | message(FATAL_ERROR "OBS requires Windows 10 SDK version 10.0.20348.0 or more recent.\n" 28 | "Please download and install the most recent Windows platform SDK.") 29 | endif() 30 | 31 | add_compile_options( 32 | /W3 33 | /utf-8 34 | "$<$:/MP>" 35 | "$<$:/MP>" 36 | "$<$:${_obs_clang_c_options}>" 37 | "$<$:${_obs_clang_cxx_options}>" 38 | $<$>:/Gy>) 39 | 40 | add_compile_definitions(UNICODE _UNICODE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS $<$:DEBUG> 41 | $<$:_DEBUG>) 42 | 43 | # cmake-format: off 44 | add_link_options($<$>:/OPT:REF> 45 | $<$>:/OPT:ICF> 46 | $<$>:/INCREMENTAL:NO> 47 | /DEBUG 48 | /Brepro) 49 | # cmake-format: on 50 | 51 | if(CMAKE_COMPILE_WARNING_AS_ERROR) 52 | add_link_options(/WX) 53 | endif() 54 | -------------------------------------------------------------------------------- /cmake/macos/resources/create-package.cmake.in: -------------------------------------------------------------------------------- 1 | make_directory("$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins") 2 | 3 | if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin") 4 | file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins" 5 | TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin" USE_SOURCE_PERMISSIONS) 6 | 7 | if(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$" OR CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$") 8 | if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM") 9 | file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins" TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM" USE_SOURCE_PERMISSIONS) 10 | endif() 11 | endif() 12 | endif() 13 | 14 | make_directory("$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp") 15 | 16 | execute_process( 17 | COMMAND /usr/bin/pkgbuild 18 | --identifier '@MACOS_BUNDLEID@' 19 | --version '@CMAKE_PROJECT_VERSION@' 20 | --root "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package" 21 | "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp/@CMAKE_PROJECT_NAME@.pkg" 22 | COMMAND_ERROR_IS_FATAL ANY 23 | ) 24 | 25 | execute_process( 26 | COMMAND /usr/bin/productbuild 27 | --distribution "@CMAKE_CURRENT_BINARY_DIR@/distribution" 28 | --package-path "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp" 29 | "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.pkg" 30 | COMMAND_ERROR_IS_FATAL ANY) 31 | 32 | if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.pkg") 33 | file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp") 34 | file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package") 35 | endif() 36 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16...3.26) 2 | 3 | include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/bootstrap.cmake" NO_POLICY_SCOPE) 4 | 5 | project(${_name} VERSION ${_version}) 6 | 7 | option(ENABLE_FRONTEND_API "Use obs-frontend-api for UI functionality" OFF) 8 | option(ENABLE_QT "Use Qt functionality" OFF) 9 | 10 | include(compilerconfig) 11 | include(defaults) 12 | include(helpers) 13 | 14 | add_library(${CMAKE_PROJECT_NAME} MODULE) 15 | 16 | find_package(libobs REQUIRED) 17 | target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs) 18 | 19 | if(ENABLE_FRONTEND_API) 20 | find_package(obs-frontend-api REQUIRED) 21 | target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::obs-frontend-api) 22 | endif() 23 | 24 | if(ENABLE_QT) 25 | find_package(Qt6 COMPONENTS Widgets Core) 26 | target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets) 27 | target_compile_options( 28 | ${CMAKE_PROJECT_NAME} PRIVATE $<$:-Wno-quoted-include-in-framework-header 29 | -Wno-comma>) 30 | set_target_properties( 31 | ${CMAKE_PROJECT_NAME} 32 | PROPERTIES AUTOMOC ON 33 | AUTOUIC ON 34 | AUTORCC ON) 35 | endif() 36 | 37 | include(cmake/BuildAssimp.cmake) 38 | target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE assimp) 39 | 40 | set(USE_SYSTEM_OPENCV 41 | OFF 42 | CACHE STRING "Use system OpenCV") 43 | if(USE_SYSTEM_OPENCV) 44 | if(OS_LINUX) 45 | find_package(OpenCV REQUIRED COMPONENTS core imgproc) 46 | target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE "${OpenCV_LIBRARIES}") 47 | target_include_directories(${CMAKE_PROJECT_NAME} SYSTEM PUBLIC "${OpenCV_INCLUDE_DIRS}") 48 | else() 49 | message(FATAL_ERROR "System OpenCV is only supported on Linux!") 50 | endif() 51 | else() 52 | include(cmake/FetchOpenCV.cmake) 53 | target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OpenCV) 54 | endif() 55 | 56 | target_sources( 57 | ${CMAKE_PROJECT_NAME} 58 | PRIVATE src/plugin-main.c src/augmented-filter.c src/augmented-filter.cpp src/asset-utils/asset-loader.cpp 59 | src/asset-utils/asset-render.cpp src/obs-utils/obs-utils.cpp) 60 | 61 | set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name}) 62 | -------------------------------------------------------------------------------- /.github/actions/run-cmake-format/action.yaml: -------------------------------------------------------------------------------- 1 | name: Run cmake-format 2 | description: Runs cmake-format and checks for any changes introduced by it 3 | inputs: 4 | failCondition: 5 | description: Controls whether failed checks also fail the workflow run 6 | required: false 7 | default: 'never' 8 | workingDirectory: 9 | description: Working directory for checks 10 | required: false 11 | default: ${{ github.workspace }} 12 | runs: 13 | using: composite 14 | steps: 15 | - name: Check Runner Operating System 🏃‍♂️ 16 | if: runner.os == 'Windows' 17 | shell: bash 18 | run: | 19 | : Check Runner Operating System 🏃‍♂️ 20 | echo "::notice::run-cmake-format action requires a macOS-based or Linux-based runner." 21 | exit 2 22 | 23 | - name: Install Dependencies 🛍️ 24 | if: runner.os == 'Linux' 25 | shell: bash 26 | run: | 27 | : Install Dependencies 🛍️ 28 | echo ::group::Install Dependencies 29 | eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 30 | echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH 31 | brew install --quiet zsh 32 | echo ::endgroup:: 33 | 34 | - name: Run cmake-format 🎛️ 35 | id: result 36 | shell: zsh --no-rcs --errexit --pipefail {0} 37 | working-directory: ${{ github.workspace }} 38 | env: 39 | GITHUB_EVENT_FORCED: ${{ github.event.forced }} 40 | GITHUB_REF_BEFORE: ${{ github.event.before }} 41 | run: | 42 | : Run cmake-format 🎛️ 43 | if (( ${+RUNNER_DEBUG} )) setopt XTRACE 44 | 45 | local -a changes=($(git diff --name-only HEAD~1 HEAD)) 46 | case ${GITHUB_EVENT_NAME} { 47 | pull_request) changes=($(git diff --name-only origin/${GITHUB_BASE_REF} HEAD)) ;; 48 | push) if [[ ${GITHUB_EVENT_FORCED} != true ]] changes=($(git diff --name-only ${GITHUB_REF_BEFORE} HEAD)) ;; 49 | *) ;; 50 | } 51 | 52 | if (( ${changes[(I)*.cmake|*CMakeLists.txt]} )) { 53 | echo ::group::Install cmakelang 54 | pip3 install cmakelang 55 | echo ::endgroup:: 56 | echo ::group::Run cmake-format 57 | ./build-aux/run-cmake-format --fail-${{ inputs.failCondition }} --check 58 | echo ::endgroup:: 59 | } 60 | -------------------------------------------------------------------------------- /cmake/macos/compilerconfig.cmake: -------------------------------------------------------------------------------- 1 | # CMake macOS compiler configuration module 2 | 3 | include_guard(GLOBAL) 4 | 5 | include(ccache) 6 | include(compiler_common) 7 | 8 | add_compile_options(-fopenmp-simd) 9 | 10 | if(XCODE) 11 | # Use Xcode's standard architecture selection 12 | set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)") 13 | # Enable dSYM generation for Release builds 14 | string(APPEND CMAKE_C_FLAGS_RELEASE " -g") 15 | string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g") 16 | else() 17 | option(ENABLE_COMPILER_TRACE "Enable clang time-trace (requires Ninja)" OFF) 18 | mark_as_advanced(ENABLE_COMPILER_TRACE) 19 | 20 | # clang options for ObjC 21 | set(_obs_clang_objc_options 22 | # cmake-format: sortable 23 | -Werror=block-capture-autoreleasing -Wno-selector -Wno-strict-selector-match -Wnon-virtual-dtor -Wprotocol 24 | -Wundeclared-selector) 25 | 26 | # clang options for ObjC++ 27 | set(_obs_clang_objcxx_options 28 | # cmake-format: sortable 29 | ${_obs_clang_objc_options} -Warc-repeated-use-of-weak -Wno-arc-maybe-repeated-use-of-weak) 30 | 31 | add_compile_options( 32 | "$<$:${_obs_clang_c_options}>" "$<$:${_obs_clang_cxx_options}>" 33 | "$<$:${_obs_clang_objc_options}>" 34 | "$<$:${_obs_clang_objcxx_options}>") 35 | 36 | # Enable stripping of dead symbols when not building for Debug configuration 37 | set(_release_configs RelWithDebInfo Release MinSizeRel) 38 | if(CMAKE_BUILD_TYPE IN_LIST _release_configs) 39 | add_link_options(LINKER:-dead_strip) 40 | endif() 41 | 42 | # Enable color diagnostics for AppleClang 43 | set(CMAKE_COLOR_DIAGNOSTICS ON) 44 | # Set universal architectures via CMake flag for non-Xcode generators 45 | set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64") 46 | 47 | # Enable compiler and build tracing (requires Ninja generator) 48 | if(ENABLE_COMPILER_TRACE AND CMAKE_GENERATOR STREQUAL "Ninja") 49 | add_compile_options($<$:-ftime-trace> $<$:-ftime-trace>) 50 | else() 51 | set(ENABLE_COMPILER_TRACE 52 | OFF 53 | CACHE STRING "Enable clang time-trace (requires Ninja)" FORCE) 54 | endif() 55 | endif() 56 | 57 | add_compile_definitions($<$:DEBUG> $<$:_DEBUG> SIMDE_ENABLE_OPENMP) 58 | -------------------------------------------------------------------------------- /src/obs-utils/obs-utils.cpp: -------------------------------------------------------------------------------- 1 | #include "obs-utils.h" 2 | #include "plugin-support.h" 3 | 4 | #include 5 | 6 | /** 7 | * @brief Get RGBA from the stage surface 8 | * 9 | * @param tf The filter data 10 | * @param width The width of the stage surface (output) 11 | * @param height The height of the stage surface (output) 12 | * @return true if successful 13 | * @return false if unsuccessful 14 | */ 15 | bool getRGBAFromStageSurface(augmented_filter_data *tf, uint32_t &width, 16 | uint32_t &height) 17 | { 18 | 19 | if (!obs_source_enabled(tf->source)) { 20 | return false; 21 | } 22 | 23 | obs_source_t *target = obs_filter_get_target(tf->source); 24 | if (!target) { 25 | return false; 26 | } 27 | width = obs_source_get_base_width(target); 28 | height = obs_source_get_base_height(target); 29 | if (width == 0 || height == 0) { 30 | return false; 31 | } 32 | gs_texrender_reset(tf->texrender); 33 | if (!gs_texrender_begin(tf->texrender, width, height)) { 34 | return false; 35 | } 36 | struct vec4 background; 37 | vec4_zero(&background); 38 | gs_clear(GS_CLEAR_COLOR, &background, 0.0f, 0); 39 | gs_ortho(0.0f, static_cast(width), 0.0f, 40 | static_cast(height), -100.0f, 100.0f); 41 | gs_blend_state_push(); 42 | gs_blend_function(GS_BLEND_ONE, GS_BLEND_ZERO); 43 | obs_source_video_render(target); 44 | gs_blend_state_pop(); 45 | gs_texrender_end(tf->texrender); 46 | 47 | if (tf->stagesurface) { 48 | uint32_t stagesurf_width = 49 | gs_stagesurface_get_width(tf->stagesurface); 50 | uint32_t stagesurf_height = 51 | gs_stagesurface_get_height(tf->stagesurface); 52 | if (stagesurf_width != width || stagesurf_height != height) { 53 | gs_stagesurface_destroy(tf->stagesurface); 54 | tf->stagesurface = nullptr; 55 | } 56 | } 57 | if (!tf->stagesurface) { 58 | tf->stagesurface = 59 | gs_stagesurface_create(width, height, GS_BGRA); 60 | } 61 | gs_stage_texture(tf->stagesurface, 62 | gs_texrender_get_texture(tf->texrender)); 63 | uint8_t *video_data; 64 | uint32_t linesize; 65 | if (!gs_stagesurface_map(tf->stagesurface, &video_data, &linesize)) { 66 | return false; 67 | } 68 | { 69 | std::lock_guard lock(tf->inputBGRALock); 70 | tf->inputBGRA = 71 | cv::Mat(height, width, CV_8UC4, video_data, linesize); 72 | } 73 | gs_stagesurface_unmap(tf->stagesurface); 74 | return true; 75 | } 76 | -------------------------------------------------------------------------------- /.github/actions/run-clang-format/action.yaml: -------------------------------------------------------------------------------- 1 | name: Run clang-format 2 | description: Runs clang-format and checks for any changes introduced by it 3 | inputs: 4 | failCondition: 5 | description: Controls whether failed checks also fail the workflow run 6 | required: false 7 | default: 'never' 8 | workingDirectory: 9 | description: Working directory for checks 10 | required: false 11 | default: ${{ github.workspace }} 12 | runs: 13 | using: composite 14 | steps: 15 | - name: Check Runner Operating System 🏃‍♂️ 16 | if: runner.os == 'Windows' 17 | shell: bash 18 | run: | 19 | : Check Runner Operating System 🏃‍♂️ 20 | echo "::notice::run-clang-format action requires a macOS-based or Linux-based runner." 21 | exit 2 22 | 23 | - name: Install Dependencies 🛍️ 24 | if: runner.os == 'Linux' 25 | shell: bash 26 | run: | 27 | : Install Dependencies 🛍️ 28 | echo ::group::Install Dependencies 29 | eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 30 | echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH 31 | echo "/home/linuxbrew/.linuxbrew/opt/clang-format@17/bin" >> $GITHUB_PATH 32 | brew install --quiet zsh 33 | echo ::endgroup:: 34 | 35 | - name: Run clang-format 🐉 36 | id: result 37 | shell: zsh --no-rcs --errexit --pipefail {0} 38 | working-directory: ${{ inputs.workingDirectory }} 39 | env: 40 | GITHUB_EVENT_FORCED: ${{ github.event.forced }} 41 | GITHUB_REF_BEFORE: ${{ github.event.before }} 42 | run: | 43 | : Run clang-format 🐉 44 | if (( ${+RUNNER_DEBUG} )) setopt XTRACE 45 | 46 | local -a changes=($(git diff --name-only HEAD~1 HEAD)) 47 | case ${GITHUB_EVENT_NAME} { 48 | pull_request) changes=($(git diff --name-only origin/${GITHUB_BASE_REF} HEAD)) ;; 49 | push) if [[ ${GITHUB_EVENT_FORCED} != true ]] changes=($(git diff --name-only ${GITHUB_REF_BEFORE} HEAD)) ;; 50 | *) ;; 51 | } 52 | 53 | if (( ${changes[(I)(*.c|*.h|*.cpp|*.hpp|*.m|*.mm)]} )) { 54 | echo ::group::Install clang-format-17 55 | brew install --quiet obsproject/tools/clang-format@17 56 | echo ::endgroup:: 57 | 58 | echo ::group::Run clang-format-17 59 | ./build-aux/run-clang-format --fail-${{ inputs.failCondition }} --check 60 | echo ::endgroup:: 61 | } 62 | -------------------------------------------------------------------------------- /cmake/common/compiler_common.cmake: -------------------------------------------------------------------------------- 1 | # CMake common compiler options module 2 | 3 | include_guard(GLOBAL) 4 | 5 | # Set C and C++ language standards to C17 and C++17 6 | if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21) 7 | set(CMAKE_C_STANDARD 17) 8 | else() 9 | set(CMAKE_C_STANDARD 11) 10 | endif() 11 | set(CMAKE_C_STANDARD_REQUIRED TRUE) 12 | set(CMAKE_CXX_STANDARD 17) 13 | set(CMAKE_CXX_STANDARD_REQUIRED TRUE) 14 | 15 | # Set symbols to be hidden by default for C and C++ 16 | set(CMAKE_C_VISIBILITY_PRESET hidden) 17 | set(CMAKE_CXX_VISIBILITY_PRESET hidden) 18 | set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE) 19 | 20 | # clang options for C 21 | set(_obs_clang_c_options 22 | # cmake-format: sortable 23 | -fno-strict-aliasing 24 | -Wbool-conversion 25 | -Wcomma 26 | -Wconstant-conversion 27 | -Wdeprecated-declarations 28 | -Wempty-body 29 | -Wenum-conversion 30 | -Werror=return-type 31 | -Wextra 32 | -Wformat 33 | -Wformat-security 34 | -Wfour-char-constants 35 | -Winfinite-recursion 36 | -Wint-conversion 37 | -Wnewline-eof 38 | -Wno-conversion 39 | -Wno-float-conversion 40 | -Wno-implicit-fallthrough 41 | -Wno-missing-braces 42 | -Wno-missing-field-initializers 43 | -Wno-missing-prototypes 44 | -Wno-semicolon-before-method-body 45 | -Wno-shadow 46 | -Wno-sign-conversion 47 | -Wno-strict-prototypes 48 | -Wno-trigraphs 49 | -Wno-unknown-pragmas 50 | -Wno-unused-function 51 | -Wno-unused-label 52 | -Wnon-literal-null-conversion 53 | -Wobjc-literal-conversion 54 | -Wparentheses 55 | -Wpointer-sign 56 | -Wquoted-include-in-framework-header 57 | -Wshadow 58 | -Wshorten-64-to-32 59 | -Wuninitialized 60 | -Wunreachable-code 61 | -Wunused-parameter 62 | -Wunused-value 63 | -Wunused-variable 64 | -Wvla) 65 | 66 | # clang options for C++ 67 | set(_obs_clang_cxx_options 68 | # cmake-format: sortable 69 | ${_obs_clang_c_options} 70 | -Wconversion 71 | -Wdeprecated-implementations 72 | -Wduplicate-method-match 73 | -Wfloat-conversion 74 | -Wfour-char-constants 75 | -Wimplicit-retain-self 76 | -Winvalid-offsetof 77 | -Wmove 78 | -Wno-c++11-extensions 79 | -Wno-exit-time-destructors 80 | -Wno-implicit-atomic-properties 81 | -Wno-objc-interface-ivars 82 | -Wno-overloaded-virtual 83 | -Wrange-loop-analysis) 84 | 85 | if(NOT DEFINED CMAKE_COMPILE_WARNING_AS_ERROR) 86 | set(CMAKE_COMPILE_WARNING_AS_ERROR ON) 87 | endif() 88 | -------------------------------------------------------------------------------- /cmake/windows/resources/installer-Windows.iss.in: -------------------------------------------------------------------------------- 1 | #define MyAppName "@CMAKE_PROJECT_NAME@" 2 | #define MyAppVersion "@CMAKE_PROJECT_VERSION@" 3 | #define MyAppPublisher "@PLUGIN_AUTHOR@" 4 | #define MyAppURL "@PLUGIN_WEBSITE@" 5 | 6 | [Setup] 7 | ; NOTE: The value of AppId uniquely identifies this application. 8 | ; Do not use the same AppId value in installers for other applications. 9 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 10 | AppId={{@UUID_APP@} 11 | AppName={#MyAppName} 12 | AppVersion={#MyAppVersion} 13 | AppPublisher={#MyAppPublisher} 14 | AppPublisherURL={#MyAppURL} 15 | AppSupportURL={#MyAppURL} 16 | AppUpdatesURL={#MyAppURL} 17 | DefaultDirName={code:GetDirName} 18 | DefaultGroupName={#MyAppName} 19 | OutputBaseFilename={#MyAppName}-{#MyAppVersion}-Windows-Installer 20 | Compression=lzma 21 | SolidCompression=yes 22 | DirExistsWarning=no 23 | 24 | [Languages] 25 | Name: "english"; MessagesFile: "compiler:Default.isl" 26 | 27 | [Files] 28 | Source: "..\release\Package\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs 29 | Source: "..\LICENSE"; Flags: dontcopy 30 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 31 | 32 | [Icons] 33 | Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}" 34 | Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" 35 | 36 | [Code] 37 | procedure InitializeWizard(); 38 | var 39 | GPLText: AnsiString; 40 | Page: TOutputMsgMemoWizardPage; 41 | begin 42 | ExtractTemporaryFile('LICENSE'); 43 | LoadStringFromFile(ExpandConstant('{tmp}\LICENSE'), GPLText); 44 | Page := CreateOutputMsgMemoPage(wpWelcome, 45 | 'License Information', 'Please review the license terms before installing {#MyAppName}', 46 | 'Press Page Down to see the rest of the agreement. Once you are aware of your rights, click Next to continue.', 47 | String(GPLText) 48 | ); 49 | end; 50 | 51 | // credit where it's due : 52 | // following function come from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45 53 | function GetDirName(Value: string): string; 54 | var 55 | InstallPath: string; 56 | begin 57 | // initialize default path, which will be returned when the following registry 58 | // key queries fail due to missing keys or for some different reason 59 | Result := '{autopf}\obs-studio'; 60 | // query the first registry value; if this succeeds, return the obtained value 61 | if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then 62 | Result := InstallPath 63 | end; 64 | 65 | -------------------------------------------------------------------------------- /src/augmented-filter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "augmented-filter.h" 5 | #include "augmented-filter-data.h" 6 | #include "plugin-support.h" 7 | #include "asset-utils/asset-loader.h" 8 | #include "asset-utils/asset-render.h" 9 | 10 | void augmented_filter_activate(void *data) {} 11 | 12 | void *augmented_filter_create(obs_data_t *settings, obs_source_t *filter) 13 | { 14 | obs_log(LOG_INFO, "Augmented filter created"); 15 | void *data = bmalloc(sizeof(struct augmented_filter_data)); 16 | struct augmented_filter_data *afd = new (data) augmented_filter_data(); 17 | 18 | afd->source = filter; 19 | afd->texrender = gs_texrender_create(GS_BGRA, GS_ZS_NONE); 20 | 21 | // get file path of the built in asset 22 | const char *assetPath = obs_module_file("assets/crown.dae"); 23 | afd->asset = load_asset(assetPath); 24 | 25 | return afd; 26 | } 27 | 28 | void augmented_filter_update(void *data, obs_data_t *s) {} 29 | 30 | void augmented_filter_destroy(void *data) 31 | { 32 | obs_log(LOG_INFO, "Augmented filter destroyed"); 33 | 34 | struct augmented_filter_data *afd = 35 | reinterpret_cast(data); 36 | 37 | if (afd) { 38 | afd->isDisabled = true; 39 | 40 | if (afd->asset) { 41 | aiReleaseImport(afd->asset); 42 | } 43 | 44 | obs_enter_graphics(); 45 | gs_texrender_destroy(afd->texrender); 46 | if (afd->stagesurface) { 47 | gs_stagesurface_destroy(afd->stagesurface); 48 | } 49 | obs_leave_graphics(); 50 | afd->~augmented_filter_data(); 51 | bfree(afd); 52 | } 53 | } 54 | 55 | const char *augmented_filter_name(void *unused) 56 | { 57 | return "Augmented Filter"; 58 | } 59 | 60 | void augmented_filter_deactivate(void *data) {} 61 | 62 | void augmented_filter_defaults(obs_data_t *s) {} 63 | 64 | obs_properties_t *augmented_filter_properties(void *data) 65 | { 66 | obs_properties_t *props = obs_properties_create(); 67 | 68 | return props; 69 | } 70 | 71 | void augmented_filter_remove(void *data, obs_source_t *source) {} 72 | 73 | void augmented_filter_show(void *data) {} 74 | 75 | void augmented_filter_hide(void *data) {} 76 | 77 | void augmented_filter_video_tick(void *data, float seconds) {} 78 | 79 | void augmented_filter_video_render(void *data, gs_effect_t *_effect) 80 | { 81 | struct augmented_filter_data *afd = 82 | reinterpret_cast(data); 83 | 84 | if (afd->isDisabled) { 85 | return; 86 | } 87 | 88 | if (!afd->asset) { 89 | return; 90 | } 91 | 92 | render_asset_3d(afd, afd->asset); 93 | } 94 | -------------------------------------------------------------------------------- /.github/scripts/utils.pwsh/Install-BuildDependencies.ps1: -------------------------------------------------------------------------------- 1 | function Install-BuildDependencies { 2 | <# 3 | .SYNOPSIS 4 | Installs required build dependencies. 5 | .DESCRIPTION 6 | Additional packages might be needed for successful builds. This module contains additional 7 | dependencies available for installation via winget and, if possible, adds their locations 8 | to the environment path for future invocation. 9 | .EXAMPLE 10 | Install-BuildDependencies 11 | #> 12 | 13 | param( 14 | [string] $WingetFile = "$PSScriptRoot/.Wingetfile" 15 | ) 16 | 17 | if ( ! ( Test-Path function:Log-Warning ) ) { 18 | . $PSScriptRoot/Logger.ps1 19 | } 20 | 21 | $Prefixes = @{ 22 | 'x64' = ${Env:ProgramFiles} 23 | 'x86' = ${Env:ProgramFiles(x86)} 24 | 'arm64' = ${Env:ProgramFiles(arm)} 25 | } 26 | 27 | $Paths = $Env:Path -split [System.IO.Path]::PathSeparator 28 | 29 | $WingetOptions = @('install', '--accept-package-agreements', '--accept-source-agreements') 30 | 31 | if ( $script:Quiet ) { 32 | $WingetOptions += '--silent' 33 | } 34 | 35 | Log-Group 'Check Windows build requirements' 36 | Get-Content $WingetFile | ForEach-Object { 37 | $_, $Package, $_, $Path, $_, $Binary, $_, $Version = $_ -replace ',','' -split " +(?=(?:[^\']*\'[^\']*\')*[^\']*$)" -replace "'",'' 38 | 39 | $Prefixes.GetEnumerator() | ForEach-Object { 40 | $Prefix = $_.value 41 | $FullPath = "${Prefix}\${Path}" 42 | if ( ( Test-Path $FullPath ) -and ! ( $Paths -contains $FullPath ) ) { 43 | $Paths = @($FullPath) + $Paths 44 | $Env:Path = $Paths -join [System.IO.Path]::PathSeparator 45 | } 46 | } 47 | 48 | Log-Debug "Checking for command ${Binary}" 49 | $Found = Get-Command -ErrorAction SilentlyContinue $Binary 50 | 51 | if ( $Found ) { 52 | Log-Status "Found dependency ${Binary} as $($Found.Source)" 53 | } else { 54 | Log-Status "Installing package ${Package} $(if ( $Version -ne $null ) { "Version: ${Version}" } )" 55 | 56 | if ( $Version -ne $null ) { 57 | $WingetOptions += @('--version', ${Version}) 58 | } 59 | 60 | try { 61 | $Params = $WingetOptions + $Package 62 | 63 | winget @Params 64 | } catch { 65 | throw "Error while installing winget package ${Package}: $_" 66 | } 67 | } 68 | } 69 | Log-Group 70 | } 71 | -------------------------------------------------------------------------------- /.github/scripts/utils.pwsh/Expand-ArchiveExt.ps1: -------------------------------------------------------------------------------- 1 | function Expand-ArchiveExt { 2 | <# 3 | .SYNOPSIS 4 | Expands archive files. 5 | .DESCRIPTION 6 | Allows extraction of zip, 7z, gz, and xz archives. 7 | Requires tar and 7-zip to be available on the system. 8 | Archives ending with .zip but created using LZMA compression are 9 | expanded using 7-zip as a fallback. 10 | .EXAMPLE 11 | Expand-ArchiveExt -Path 12 | Expand-ArchiveExt -Path -DestinationPath 13 | #> 14 | 15 | param( 16 | [Parameter(Mandatory)] 17 | [string] $Path, 18 | [string] $DestinationPath = [System.IO.Path]::GetFileNameWithoutExtension($Path), 19 | [switch] $Force 20 | ) 21 | 22 | switch ( [System.IO.Path]::GetExtension($Path) ) { 23 | .zip { 24 | try { 25 | Expand-Archive -Path $Path -DestinationPath $DestinationPath -Force:$Force 26 | } catch { 27 | if ( Get-Command 7z ) { 28 | Invoke-External 7z x -y $Path "-o${DestinationPath}" 29 | } else { 30 | throw "Fallback utility 7-zip not found. Please install 7-zip first." 31 | } 32 | } 33 | break 34 | } 35 | { ( $_ -eq ".7z" ) -or ( $_ -eq ".exe" ) } { 36 | if ( Get-Command 7z ) { 37 | Invoke-External 7z x -y $Path "-o${DestinationPath}" 38 | } else { 39 | throw "Extraction utility 7-zip not found. Please install 7-zip first." 40 | } 41 | break 42 | } 43 | .gz { 44 | try { 45 | Invoke-External tar -x -o $DestinationPath -f $Path 46 | } catch { 47 | if ( Get-Command 7z ) { 48 | Invoke-External 7z x -y $Path "-o${DestinationPath}" 49 | } else { 50 | throw "Fallback utility 7-zip not found. Please install 7-zip first." 51 | } 52 | } 53 | break 54 | } 55 | .xz { 56 | try { 57 | Invoke-External tar -x -o $DestinationPath -f $Path 58 | } catch { 59 | if ( Get-Command 7z ) { 60 | Invoke-External 7z x -y $Path "-o${DestinationPath}" 61 | } else { 62 | throw "Fallback utility 7-zip not found. Please install 7-zip first." 63 | } 64 | } 65 | } 66 | default { 67 | throw "Unsupported archive extension provided." 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cmake/common/bootstrap.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16...3.26) 2 | 3 | include_guard(GLOBAL) 4 | 5 | # Enable automatic PUSH and POP of policies to parent scope 6 | if(POLICY CMP0011) 7 | cmake_policy(SET CMP0011 NEW) 8 | endif() 9 | 10 | # Enable distinction between Clang and AppleClang 11 | if(POLICY CMP0025) 12 | cmake_policy(SET CMP0025 NEW) 13 | endif() 14 | 15 | # Enable strict checking of "break()" usage 16 | if(POLICY CMP0055) 17 | cmake_policy(SET CMP0055 NEW) 18 | endif() 19 | 20 | # Honor visibility presets for all target types (executable, shared, module, static) 21 | if(POLICY CMP0063) 22 | cmake_policy(SET CMP0063 NEW) 23 | endif() 24 | 25 | # Disable export function calls to populate package registry by default 26 | if(POLICY CMP0090) 27 | cmake_policy(SET CMP0090 NEW) 28 | endif() 29 | 30 | # Prohibit in-source builds 31 | if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") 32 | message(FATAL_ERROR "In-source builds are not supported. " 33 | "Specify a build directory via 'cmake -S -B ' instead.") 34 | file(REMOVE_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeCache.txt" "${CMAKE_CURRENT_SOURCE_DIR}/CMakeFiles") 35 | endif() 36 | 37 | # Use folders for source file organization with IDE generators (Visual Studio/Xcode) 38 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 39 | 40 | # Add common module directories to default search path 41 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common") 42 | 43 | file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec) 44 | 45 | # cmake-format: off 46 | string(JSON _name GET ${buildspec} name) 47 | string(JSON _website GET ${buildspec} website) 48 | string(JSON _author GET ${buildspec} author) 49 | string(JSON _email GET ${buildspec} email) 50 | string(JSON _version GET ${buildspec} version) 51 | string(JSON _bundleId GET ${buildspec} platformConfig macos bundleId) 52 | string(JSON _windowsAppUUID GET ${buildspec} uuids windowsApp) 53 | # cmake-format: on 54 | 55 | set(PLUGIN_AUTHOR ${_author}) 56 | set(PLUGIN_WEBSITE ${_website}) 57 | set(PLUGIN_EMAIL ${_email}) 58 | set(PLUGIN_VERSION ${_version}) 59 | set(MACOS_BUNDLEID ${_bundleId}) 60 | 61 | include(buildnumber) 62 | include(osconfig) 63 | 64 | # Allow selection of common build types via UI 65 | if(NOT CMAKE_BUILD_TYPE) 66 | set(CMAKE_BUILD_TYPE 67 | "RelWithDebInfo" 68 | CACHE STRING "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE) 69 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel) 70 | endif() 71 | 72 | # Disable exports automatically going into the CMake package registry 73 | set(CMAKE_EXPORT_PACKAGE_REGISTRY FALSE) 74 | # Enable default inclusion of targets' source and binary directory 75 | set(CMAKE_INCLUDE_CURRENT_DIR TRUE) 76 | -------------------------------------------------------------------------------- /cmake/linux/helpers.cmake: -------------------------------------------------------------------------------- 1 | # CMake Linux helper functions module 2 | 3 | include_guard(GLOBAL) 4 | 5 | include(helpers_common) 6 | 7 | # set_target_properties_plugin: Set target properties for use in obs-studio 8 | function(set_target_properties_plugin target) 9 | set(options "") 10 | set(oneValueArgs "") 11 | set(multiValueArgs PROPERTIES) 12 | cmake_parse_arguments(PARSE_ARGV 0 _STPO "${options}" "${oneValueArgs}" "${multiValueArgs}") 13 | 14 | message(DEBUG "Setting additional properties for target ${target}...") 15 | 16 | while(_STPO_PROPERTIES) 17 | list(POP_FRONT _STPO_PROPERTIES key value) 18 | set_property(TARGET ${target} PROPERTY ${key} "${value}") 19 | endwhile() 20 | 21 | set_target_properties( 22 | ${target} 23 | PROPERTIES VERSION 0 24 | SOVERSION ${PLUGIN_VERSION} 25 | PREFIX "") 26 | 27 | install( 28 | TARGETS ${target} 29 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 30 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/obs-plugins) 31 | 32 | if(TARGET plugin-support) 33 | target_link_libraries(${target} PRIVATE plugin-support) 34 | endif() 35 | 36 | target_install_resources(${target}) 37 | 38 | get_target_property(target_sources ${target} SOURCES) 39 | set(target_ui_files ${target_sources}) 40 | list(FILTER target_ui_files INCLUDE REGEX ".+\\.(ui|qrc)") 41 | source_group( 42 | TREE "${CMAKE_CURRENT_SOURCE_DIR}" 43 | PREFIX "UI Files" 44 | FILES ${target_ui_files}) 45 | endfunction() 46 | 47 | # Helper function to add resources into bundle 48 | function(target_install_resources target) 49 | message(DEBUG "Installing resources for target ${target}...") 50 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/data") 51 | file(GLOB_RECURSE data_files "${CMAKE_CURRENT_SOURCE_DIR}/data/*") 52 | foreach(data_file IN LISTS data_files) 53 | cmake_path(RELATIVE_PATH data_file BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" OUTPUT_VARIABLE 54 | relative_path) 55 | cmake_path(GET relative_path PARENT_PATH relative_path) 56 | target_sources(${target} PRIVATE "${data_file}") 57 | source_group("Resources/${relative_path}" FILES "${data_file}") 58 | endforeach() 59 | 60 | install( 61 | DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" 62 | DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/obs/obs-plugins/${target} 63 | USE_SOURCE_PERMISSIONS) 64 | endif() 65 | endfunction() 66 | 67 | # Helper function to add a specific resource to a bundle 68 | function(target_add_resource target resource) 69 | message(DEBUG "Add resource '${resource}' to target ${target} at destination '${target_destination}'...") 70 | 71 | install(FILES "${resource}" DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/obs/obs-plugins/${target}) 72 | 73 | source_group("Resources" FILES "${resource}") 74 | endfunction() 75 | -------------------------------------------------------------------------------- /cmake/linux/defaults.cmake: -------------------------------------------------------------------------------- 1 | # CMake Linux defaults module 2 | 3 | # cmake-format: off 4 | # cmake-lint: disable=C0103 5 | # cmake-lint: disable=C0111 6 | # cmake-format: on 7 | 8 | include_guard(GLOBAL) 9 | 10 | include(GNUInstallDirs) 11 | 12 | # Enable find_package targets to become globally available targets 13 | set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) 14 | 15 | set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") 16 | set(CPACK_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}") 17 | set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_C_LIBRARY_ARCHITECTURE}") 18 | 19 | set(CPACK_GENERATOR "DEB") 20 | set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) 21 | set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${PLUGIN_EMAIL}") 22 | set(CPACK_SET_DESTDIR ON) 23 | 24 | if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.25.0 OR NOT CMAKE_CROSSCOMPILING) 25 | set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) 26 | endif() 27 | 28 | set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/release") 29 | 30 | set(CPACK_SOURCE_GENERATOR "TXZ") 31 | set(CPACK_SOURCE_IGNORE_FILES 32 | # cmake-format: sortable 33 | ".*~$" 34 | \\.git/ 35 | \\.github/ 36 | \\.gitignore 37 | build_.* 38 | cmake/\\.CMakeBuildNumber 39 | release/) 40 | 41 | set(CPACK_VERBATIM_VARIABLES YES) 42 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-source") 43 | set(CPACK_ARCHIVE_THREADS 0) 44 | 45 | include(CPack) 46 | 47 | find_package(libobs QUIET) 48 | 49 | if(NOT TARGET OBS::libobs) 50 | find_package(LibObs REQUIRED) 51 | add_library(OBS::libobs ALIAS libobs) 52 | 53 | if(ENABLE_FRONTEND_API) 54 | find_path( 55 | obs-frontend-api_INCLUDE_DIR 56 | NAMES obs-frontend-api.h 57 | PATHS /usr/include /usr/local/include 58 | PATH_SUFFIXES obs) 59 | 60 | find_library( 61 | obs-frontend-api_LIBRARY 62 | NAMES obs-frontend-api 63 | PATHS /usr/lib /usr/local/lib) 64 | 65 | if(obs-frontend-api_LIBRARY) 66 | if(NOT TARGET OBS::obs-frontend-api) 67 | if(IS_ABSOLUTE "${obs-frontend-api_LIBRARY}") 68 | add_library(OBS::obs-frontend-api UNKNOWN IMPORTED) 69 | set_property(TARGET OBS::obs-frontend-api PROPERTY IMPORTED_LOCATION "${obs-frontend-api_LIBRARY}") 70 | else() 71 | add_library(OBS::obs-frontend-api INTERFACE IMPORTED) 72 | set_property(TARGET OBS::obs-frontend-api PROPERTY IMPORTED_LIBNAME "${obs-frontend-api_LIBRARY}") 73 | endif() 74 | 75 | set_target_properties(OBS::obs-frontend-api PROPERTIES INTERFACE_INCLUDE_DIRECTORIES 76 | "${obs-frontend-api_INCLUDE_DIR}") 77 | endif() 78 | endif() 79 | endif() 80 | 81 | macro(find_package) 82 | if(NOT "${ARGV0}" STREQUAL libobs AND NOT "${ARGV0}" STREQUAL obs-frontend-api) 83 | _find_package(${ARGV}) 84 | endif() 85 | endmacro() 86 | endif() 87 | -------------------------------------------------------------------------------- /cmake/linux/compilerconfig.cmake: -------------------------------------------------------------------------------- 1 | # CMake Linux compiler configuration module 2 | 3 | include_guard(GLOBAL) 4 | 5 | include(ccache) 6 | include(compiler_common) 7 | 8 | option(ENABLE_COMPILER_TRACE "Enable Clang time-trace (required Clang and Ninja)" OFF) 9 | mark_as_advanced(ENABLE_COMPILER_TRACE) 10 | 11 | # gcc options for C 12 | set(_obs_gcc_c_options 13 | # cmake-format: sortable 14 | -fno-strict-aliasing 15 | -fopenmp-simd 16 | -Wdeprecated-declarations 17 | -Wempty-body 18 | -Wenum-conversion 19 | -Werror=return-type 20 | -Wextra 21 | -Wformat 22 | -Wformat-security 23 | -Wno-conversion 24 | -Wno-float-conversion 25 | -Wno-implicit-fallthrough 26 | -Wno-missing-braces 27 | -Wno-missing-field-initializers 28 | -Wno-shadow 29 | -Wno-sign-conversion 30 | -Wno-trigraphs 31 | -Wno-unknown-pragmas 32 | -Wno-unused-function 33 | -Wno-unused-label 34 | -Wparentheses 35 | -Wshadow 36 | -Wuninitialized 37 | -Wunreachable-code 38 | -Wunused-parameter 39 | -Wunused-value 40 | -Wunused-variable 41 | -Wvla) 42 | 43 | # gcc options for C++ 44 | set(_obs_gcc_cxx_options 45 | # cmake-format: sortable 46 | ${_obs_gcc_c_options} -Wconversion -Wfloat-conversion -Winvalid-offsetof -Wno-overloaded-virtual) 47 | 48 | add_compile_options( 49 | -fopenmp-simd 50 | "$<$:${_obs_gcc_c_options}>" 51 | "$<$:-Wint-conversion;-Wno-missing-prototypes;-Wno-strict-prototypes;-Wpointer-sign>" 52 | "$<$:${_obs_gcc_cxx_options}>" 53 | "$<$:${_obs_clang_c_options}>" 54 | "$<$:${_obs_clang_cxx_options}>") 55 | 56 | # Add support for color diagnostics and CMake switch for warnings as errors to CMake < 3.24 57 | if(CMAKE_VERSION VERSION_LESS 3.24.0) 58 | add_compile_options($<$:-fcolor-diagnostics> $<$:-fcolor-diagnostics>) 59 | if(CMAKE_COMPILE_WARNING_AS_ERROR) 60 | add_compile_options(-Werror) 61 | endif() 62 | else() 63 | set(CMAKE_COLOR_DIAGNOSTICS ON) 64 | endif() 65 | 66 | if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) 67 | # Disable false-positive warning in GCC 12.1.0 and later 68 | add_compile_options(-Wno-error=maybe-uninitialized) 69 | 70 | # Add warning for infinite recursion (added in GCC 12) 71 | if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0.0) 72 | add_compile_options(-Winfinite-recursion) 73 | endif() 74 | endif() 75 | 76 | # Enable compiler and build tracing (requires Ninja generator) 77 | if(ENABLE_COMPILER_TRACE AND CMAKE_GENERATOR STREQUAL "Ninja") 78 | add_compile_options($<$:-ftime-trace> $<$:-ftime-trace>) 79 | else() 80 | set(ENABLE_COMPILER_TRACE 81 | OFF 82 | CACHE STRING "Enable Clang time-trace (required Clang and Ninja)" FORCE) 83 | endif() 84 | 85 | add_compile_definitions($<$:DEBUG> $<$:_DEBUG> SIMDE_ENABLE_OPENMP) 86 | -------------------------------------------------------------------------------- /src/asset-utils/asset-render.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "asset-render.h" 3 | #include "augmented-filter-data.h" 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | bool render_asset_3d(augmented_filter_data *afd, const aiScene *scene) 11 | { 12 | obs_source_t *target = obs_filter_get_target(afd->source); 13 | if (!target) { 14 | return false; 15 | } 16 | uint32_t width = obs_source_get_base_width(target); 17 | uint32_t height = obs_source_get_base_height(target); 18 | if (width == 0 || height == 0) { 19 | return false; 20 | } 21 | gs_texrender_reset(afd->texrender); 22 | gs_viewport_push(); 23 | gs_matrix_push(); 24 | gs_blend_state_push(); 25 | gs_blend_function(GS_BLEND_ONE, GS_BLEND_ZERO); 26 | if (!gs_texrender_begin(afd->texrender, width, height)) { 27 | return false; 28 | } 29 | struct vec4 background; 30 | vec4_zero(&background); 31 | gs_clear(GS_CLEAR_COLOR, &background, 0.0f, 0); 32 | 33 | gs_perspective(120.0f, (float)width / (float)height, 34 | 1.0f / (float)(1 << 22), (float)(1 << 22)); 35 | 36 | gs_vb_data *vb = gs_vbdata_create(); 37 | vb->points = 38 | (vec3 *)bmalloc(sizeof(vec3) * scene->mMeshes[0]->mNumVertices); 39 | vb->colors = (uint32_t *)bmalloc(sizeof(uint32_t) * 40 | scene->mMeshes[0]->mNumVertices); 41 | vb->num = scene->mMeshes[0]->mNumVertices; 42 | for (unsigned int i = 0; i < scene->mMeshes[0]->mNumVertices; i++) { 43 | vb->points[i].x = scene->mMeshes[0]->mVertices[i].x; 44 | vb->points[i].y = scene->mMeshes[0]->mVertices[i].y; 45 | vb->points[i].z = scene->mMeshes[0]->mVertices[i].z; 46 | vb->colors[i] = 0xFFFFFFFF; 47 | } 48 | gs_vertbuffer_t *vbo = gs_vertexbuffer_create(vb, GS_DYNAMIC); 49 | gs_vertexbuffer_flush(vbo); 50 | gs_load_vertexbuffer(vbo); 51 | gs_load_indexbuffer(NULL); 52 | 53 | gs_draw(GS_TRIS, 0, 0); 54 | 55 | gs_vertexbuffer_destroy(vbo); 56 | 57 | gs_matrix_identity(); 58 | 59 | gs_texrender_end(afd->texrender); 60 | gs_blend_state_pop(); 61 | gs_matrix_pop(); 62 | gs_viewport_pop(); 63 | 64 | return true; 65 | } 66 | 67 | /* 68 | void effect_3d_draw_frame(struct effect_3d *context, uint32_t w, uint32_t h) 69 | { 70 | const enum gs_color_space current_space = gs_get_color_space(); 71 | float multiplier; 72 | const char *technique = get_tech_name_and_multiplier( 73 | current_space, context->space, &multiplier); 74 | 75 | gs_effect_t *effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); 76 | gs_texture_t *tex = gs_texrender_get_texture(context->render); 77 | if (!tex) 78 | return; 79 | 80 | gs_blend_state_push(); 81 | gs_blend_function(GS_BLEND_ONE, GS_BLEND_INVSRCALPHA); 82 | 83 | const bool previous = gs_framebuffer_srgb_enabled(); 84 | gs_enable_framebuffer_srgb(true); 85 | 86 | gs_effect_set_texture_srgb(gs_effect_get_param_by_name(effect, "image"), 87 | tex); 88 | gs_effect_set_float(gs_effect_get_param_by_name(effect, "multiplier"), 89 | multiplier); 90 | 91 | while (gs_effect_loop(effect, technique)) 92 | gs_draw_sprite(tex, 0, w, h); 93 | 94 | gs_enable_framebuffer_srgb(previous); 95 | gs_blend_state_pop(); 96 | } 97 | */ -------------------------------------------------------------------------------- /.github/scripts/Package-Windows.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | param( 3 | [ValidateSet('x64')] 4 | [string] $Target = 'x64', 5 | [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')] 6 | [string] $Configuration = 'RelWithDebInfo', 7 | [switch] $BuildInstaller, 8 | [switch] $SkipDeps 9 | ) 10 | 11 | $ErrorActionPreference = 'Stop' 12 | 13 | if ( $DebugPreference -eq 'Continue' ) { 14 | $VerbosePreference = 'Continue' 15 | $InformationPreference = 'Continue' 16 | } 17 | 18 | if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) { 19 | throw "Packaging script requires a 64-bit system to build and run." 20 | } 21 | 22 | 23 | if ( $PSVersionTable.PSVersion -lt '7.0.0' ) { 24 | Write-Warning 'The packaging script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6' 25 | exit 2 26 | } 27 | 28 | function Package { 29 | trap { 30 | Pop-Location -Stack BuildTemp -ErrorAction 'SilentlyContinue' 31 | Write-Error $_ 32 | Log-Group 33 | exit 2 34 | } 35 | 36 | $ScriptHome = $PSScriptRoot 37 | $ProjectRoot = Resolve-Path -Path "$PSScriptRoot/../.." 38 | $BuildSpecFile = "${ProjectRoot}/buildspec.json" 39 | 40 | $UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse 41 | 42 | foreach( $Utility in $UtilityFunctions ) { 43 | Write-Debug "Loading $($Utility.FullName)" 44 | . $Utility.FullName 45 | } 46 | 47 | $BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json 48 | $ProductName = $BuildSpec.name 49 | $ProductVersion = $BuildSpec.version 50 | 51 | $OutputName = "${ProductName}-${ProductVersion}-windows-${Target}" 52 | 53 | if ( ! $SkipDeps ) { 54 | Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile" 55 | } 56 | 57 | $RemoveArgs = @{ 58 | ErrorAction = 'SilentlyContinue' 59 | Path = @( 60 | "${ProjectRoot}/release/${ProductName}-*-windows-*.zip" 61 | "${ProjectRoot}/release/${ProductName}-*-windows-*.exe" 62 | ) 63 | } 64 | 65 | Remove-Item @RemoveArgs 66 | 67 | Log-Group "Archiving ${ProductName}..." 68 | $CompressArgs = @{ 69 | Path = (Get-ChildItem -Path "${ProjectRoot}/release/${Configuration}" -Exclude "${OutputName}*.*") 70 | CompressionLevel = 'Optimal' 71 | DestinationPath = "${ProjectRoot}/release/${OutputName}.zip" 72 | Verbose = ($Env:CI -ne $null) 73 | } 74 | Compress-Archive -Force @CompressArgs 75 | Log-Group 76 | 77 | if ( ( $BuildInstaller ) ) { 78 | Log-Group "Packaging ${ProductName}..." 79 | 80 | $IsccFile = "${ProjectRoot}/build_${Target}/installer-Windows.generated.iss" 81 | if ( ! ( Test-Path -Path $IsccFile ) ) { 82 | throw 'InnoSetup install script not found. Run the build script or the CMake build and install procedures first.' 83 | } 84 | 85 | Log-Information 'Creating InnoSetup installer...' 86 | Push-Location -Stack BuildTemp 87 | Ensure-Location -Path "${ProjectRoot}/release" 88 | Copy-Item -Path ${Configuration} -Destination Package -Recurse 89 | Invoke-External iscc ${IsccFile} /O"${ProjectRoot}/release" /F"${OutputName}-Installer" 90 | Remove-Item -Path Package -Recurse 91 | Pop-Location -Stack BuildTemp 92 | 93 | Log-Group 94 | } 95 | } 96 | 97 | Package 98 | -------------------------------------------------------------------------------- /.github/scripts/Build-Windows.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | param( 3 | [ValidateSet('x64')] 4 | [string] $Target = 'x64', 5 | [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')] 6 | [string] $Configuration = 'RelWithDebInfo', 7 | [switch] $SkipAll, 8 | [switch] $SkipBuild, 9 | [switch] $SkipDeps 10 | ) 11 | 12 | $ErrorActionPreference = 'Stop' 13 | 14 | if ( $DebugPreference -eq 'Continue' ) { 15 | $VerbosePreference = 'Continue' 16 | $InformationPreference = 'Continue' 17 | } 18 | 19 | if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) { 20 | throw "A 64-bit system is required to build the project." 21 | } 22 | 23 | if ( $PSVersionTable.PSVersion -lt '7.0.0' ) { 24 | Write-Warning 'The obs-deps PowerShell build script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6' 25 | exit 2 26 | } 27 | 28 | function Build { 29 | trap { 30 | Pop-Location -Stack BuildTemp -ErrorAction 'SilentlyContinue' 31 | Write-Error $_ 32 | Log-Group 33 | exit 2 34 | } 35 | 36 | $ScriptHome = $PSScriptRoot 37 | $ProjectRoot = Resolve-Path -Path "$PSScriptRoot/../.." 38 | $BuildSpecFile = "${ProjectRoot}/buildspec.json" 39 | 40 | $UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse 41 | 42 | foreach($Utility in $UtilityFunctions) { 43 | Write-Debug "Loading $($Utility.FullName)" 44 | . $Utility.FullName 45 | } 46 | 47 | $BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json 48 | $ProductName = $BuildSpec.name 49 | $ProductVersion = $BuildSpec.version 50 | 51 | if ( ! $SkipDeps ) { 52 | Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile" 53 | } 54 | 55 | Push-Location -Stack BuildTemp 56 | if ( ! ( ( $SkipAll ) -or ( $SkipBuild ) ) ) { 57 | Ensure-Location $ProjectRoot 58 | 59 | $CmakeArgs = @() 60 | $CmakeBuildArgs = @() 61 | $CmakeInstallArgs = @() 62 | 63 | if ( $VerbosePreference -eq 'Continue' ) { 64 | $CmakeBuildArgs += ('--verbose') 65 | $CmakeInstallArgs += ('--verbose') 66 | } 67 | 68 | if ( $DebugPreference -eq 'Continue' ) { 69 | $CmakeArgs += ('--debug-output') 70 | } 71 | 72 | $Preset = "windows-$(if ( $Env:CI -ne $null ) { 'ci-' })${Target}" 73 | 74 | $CmakeArgs += @( 75 | '--preset', $Preset 76 | ) 77 | 78 | $CmakeBuildArgs += @( 79 | '--build' 80 | '--preset', $Preset 81 | '--config', $Configuration 82 | '--parallel' 83 | '--', '/consoleLoggerParameters:Summary', '/noLogo' 84 | ) 85 | 86 | $CmakeInstallArgs += @( 87 | '--install', "build_${Target}" 88 | '--prefix', "${ProjectRoot}/release/${Configuration}" 89 | '--config', $Configuration 90 | ) 91 | 92 | Log-Group "Configuring ${ProductName}..." 93 | Invoke-External cmake @CmakeArgs 94 | 95 | Log-Group "Building ${ProductName}..." 96 | Invoke-External cmake @CmakeBuildArgs 97 | } 98 | Log-Group "Install ${ProductName}..." 99 | Invoke-External cmake @CmakeInstallArgs 100 | 101 | Pop-Location -Stack BuildTemp 102 | Log-Group 103 | } 104 | 105 | Build 106 | -------------------------------------------------------------------------------- /cmake/FetchOpenCV.cmake: -------------------------------------------------------------------------------- 1 | include(FetchContent) 2 | 3 | set(CUSTOM_OPENCV_URL 4 | "" 5 | CACHE STRING "URL of a downloaded OpenCV static library tarball") 6 | 7 | set(CUSTOM_OPENCV_HASH 8 | "" 9 | CACHE STRING "Hash of a downloaded OpenCV staitc library tarball") 10 | 11 | if(CUSTOM_OPENCV_URL STREQUAL "") 12 | set(USE_PREDEFINED_OPENCV ON) 13 | else() 14 | if(CUSTOM_OPENCV_HASH STREQUAL "") 15 | message(FATAL_ERROR "Both of CUSTOM_OPENCV_URL and CUSTOM_OPENCV_HASH must be present!") 16 | else() 17 | set(USE_PREDEFINED_OPENCV OFF) 18 | endif() 19 | endif() 20 | 21 | if(USE_PREDEFINED_OPENCV) 22 | set(OpenCV_VERSION "v4.9.0-1") 23 | set(OpenCV_BASEURL "https://github.com/obs-ai/obs-backgroundremoval-dep-opencv/releases/download/${OpenCV_VERSION}") 24 | 25 | if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo) 26 | set(OpenCV_BUILD_TYPE Release) 27 | else() 28 | set(OpenCV_BUILD_TYPE Debug) 29 | endif() 30 | 31 | if(APPLE) 32 | if(OpenCV_BUILD_TYPE STREQUAL Debug) 33 | set(OpenCV_URL "${OpenCV_BASEURL}/opencv-macos-${OpenCV_VERSION}-Debug.tar.gz") 34 | set(OpenCV_HASH SHA256=BE85C8224F71C52162955BEE4EC9FFBE41CBED636D7989843CA75AD42657B121) 35 | else() 36 | set(OpenCV_URL "${OpenCV_BASEURL}/opencv-macos-${OpenCV_VERSION}-Release.tar.gz") 37 | set(OpenCV_HASH SHA256=5DB4FCFBD8C7CDBA136657B4D149821A670DF9A7C71120F5A4D34FA35A58D07B) 38 | endif() 39 | elseif(MSVC) 40 | if(OpenCV_BUILD_TYPE STREQUAL Debug) 41 | set(OpenCV_URL "${OpenCV_BASEURL}/opencv-windows-${OpenCV_VERSION}-Debug.zip") 42 | set(OpenCV_HASH SHA256=0A1BBC898DCE5F193427586DA84D7A34BBB783127957633236344E9CCD61B9CE) 43 | else() 44 | set(OpenCV_URL "${OpenCV_BASEURL}/opencv-windows-${OpenCV_VERSION}-Release.zip") 45 | set(OpenCV_HASH SHA256=56A5E042F490B8390B1C1819B2B48C858F10CD64E613BABBF11925A57269C3FA) 46 | endif() 47 | else() 48 | if(OpenCV_BUILD_TYPE STREQUAL Debug) 49 | set(OpenCV_URL "${OpenCV_BASEURL}/opencv-linux-${OpenCV_VERSION}-Debug.tar.gz") 50 | set(OpenCV_HASH SHA256=840A7D80B661CFF7B7300272A2A2992D539672ECECA01836B85F68BD8CAF07F5) 51 | else() 52 | set(OpenCV_URL "${OpenCV_BASEURL}/opencv-linux-${OpenCV_VERSION}-Release.tar.gz") 53 | set(OpenCV_HASH SHA256=73652C2155B477B5FD95FCD8EA7CE35D313543ECE17BDFA3A2B217A0239D74C6) 54 | endif() 55 | endif() 56 | else() 57 | set(OpenCV_URL "${CUSTOM_OPENCV_URL}") 58 | set(OpenCV_HASH "${CUSTOM_OPENCV_HASH}") 59 | endif() 60 | 61 | FetchContent_Declare( 62 | opencv 63 | URL ${OpenCV_URL} 64 | URL_HASH ${OpenCV_HASH}) 65 | FetchContent_MakeAvailable(opencv) 66 | 67 | add_library(OpenCV INTERFACE) 68 | if(MSVC) 69 | target_link_libraries( 70 | OpenCV 71 | INTERFACE ${opencv_SOURCE_DIR}/x64/vc17/staticlib/opencv_imgproc490.lib 72 | ${opencv_SOURCE_DIR}/x64/vc17/staticlib/opencv_core490.lib 73 | ${opencv_SOURCE_DIR}/x64/vc17/staticlib/opencv_video490.lib 74 | ${opencv_SOURCE_DIR}/x64/vc17/staticlib/zlib.lib) 75 | target_include_directories(OpenCV SYSTEM INTERFACE ${opencv_SOURCE_DIR}/include) 76 | else() 77 | target_link_libraries( 78 | OpenCV INTERFACE ${opencv_SOURCE_DIR}/lib/libopencv_imgproc.a ${opencv_SOURCE_DIR}/lib/libopencv_core.a 79 | ${opencv_SOURCE_DIR}/lib/libopencv_video.a ${opencv_SOURCE_DIR}/lib/opencv4/3rdparty/libzlib.a) 80 | target_include_directories(OpenCV SYSTEM INTERFACE ${opencv_SOURCE_DIR}/include/opencv4) 81 | endif() 82 | -------------------------------------------------------------------------------- /.github/actions/build-plugin/action.yaml: -------------------------------------------------------------------------------- 1 | name: 'Set up and build plugin' 2 | description: 'Builds the plugin for specified architecture and build config' 3 | inputs: 4 | target: 5 | description: 'Target architecture for dependencies' 6 | required: true 7 | config: 8 | description: 'Build configuration' 9 | required: false 10 | default: 'RelWithDebInfo' 11 | codesign: 12 | description: 'Enable codesigning (macOS only)' 13 | required: false 14 | default: 'false' 15 | codesignIdent: 16 | description: 'Developer ID for application codesigning (macOS only)' 17 | required: false 18 | default: '-' 19 | workingDirectory: 20 | description: 'Working directory for packaging' 21 | required: false 22 | default: ${{ github.workspace }} 23 | runs: 24 | using: composite 25 | steps: 26 | - name: Run macOS Build 27 | if: runner.os == 'macOS' 28 | shell: zsh --no-rcs --errexit --pipefail {0} 29 | working-directory: ${{ inputs.workingDirectory }} 30 | env: 31 | CODESIGN_IDENT: ${{ inputs.codesignIdent }} 32 | CODESIGN_TEAM: ${{ inputs.codesignTeam }} 33 | run: | 34 | : Run macOS Build 35 | 36 | local -a build_args=(--config ${{ inputs.config }}) 37 | if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) 38 | 39 | if [[ '${{ inputs.codesign }}' == 'true' ]] build_args+=(--codesign) 40 | 41 | .github/scripts/build-macos ${build_args} 42 | 43 | - name: Install Dependencies 🛍️ 44 | if: runner.os == 'Linux' 45 | shell: bash 46 | run: | 47 | : Install Dependencies 🛍️ 48 | echo ::group::Install Dependencies 49 | eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 50 | echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH 51 | brew install --quiet zsh 52 | echo ::endgroup:: 53 | 54 | - name: Run Ubuntu Build 55 | if: runner.os == 'Linux' 56 | shell: zsh --no-rcs --errexit --pipefail {0} 57 | working-directory: ${{ inputs.workingDirectory }} 58 | run: | 59 | : Run Ubuntu Build 60 | 61 | local -a build_args=( 62 | --target linux-${{ inputs.target }} 63 | --config ${{ inputs.config }} 64 | ) 65 | if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) 66 | 67 | .github/scripts/build-linux ${build_args} 68 | 69 | - name: Run Windows Build 70 | if: runner.os == 'Windows' 71 | shell: pwsh 72 | run: | 73 | # Run Windows Build 74 | if ( $Env:RUNNER_DEBUG -ne $null ) { 75 | Set-PSDebug -Trace 1 76 | } 77 | 78 | $BuildArgs = @{ 79 | Target = '${{ inputs.target }}' 80 | Configuration = '${{ inputs.config }}' 81 | } 82 | 83 | .github/scripts/Build-Windows.ps1 @BuildArgs 84 | 85 | - name: Create Summary 📊 86 | if: contains(fromJSON('["Linux", "macOS"]'),runner.os) 87 | shell: zsh --no-rcs --errexit --pipefail {0} 88 | env: 89 | CCACHE_CONFIGPATH: ${{ inputs.workingDirectory }}/.ccache.conf 90 | run: | 91 | : Create Summary 📊 92 | 93 | local -a ccache_data 94 | if (( ${+RUNNER_DEBUG} )) { 95 | setopt XTRACE 96 | ccache_data=("${(fA)$(ccache -s -vv)}") 97 | } else { 98 | ccache_data=("${(fA)$(ccache -s)}") 99 | } 100 | 101 | print '### ${{ runner.os }} Ccache Stats (${{ inputs.target }})' >> $GITHUB_STEP_SUMMARY 102 | print '```' >> $GITHUB_STEP_SUMMARY 103 | for line (${ccache_data}) { 104 | print ${line} >> $GITHUB_STEP_SUMMARY 105 | } 106 | print '```' >> $GITHUB_STEP_SUMMARY 107 | -------------------------------------------------------------------------------- /.github/scripts/utils.pwsh/Logger.ps1: -------------------------------------------------------------------------------- 1 | function Log-Debug { 2 | [CmdletBinding()] 3 | param( 4 | [Parameter(Mandatory,ValueFromPipeline)] 5 | [ValidateNotNullOrEmpty()] 6 | [string[]] $Message 7 | ) 8 | 9 | Process { 10 | foreach($m in $Message) { 11 | Write-Debug "$(if ( $env:CI -ne $null ) { '::debug::' })$m" 12 | } 13 | } 14 | } 15 | 16 | function Log-Verbose { 17 | [CmdletBinding()] 18 | param( 19 | [Parameter(Mandatory,ValueFromPipeline)] 20 | [ValidateNotNullOrEmpty()] 21 | [string[]] $Message 22 | ) 23 | 24 | Process { 25 | foreach($m in $Message) { 26 | Write-Verbose $m 27 | } 28 | } 29 | } 30 | 31 | function Log-Warning { 32 | [CmdletBinding()] 33 | param( 34 | [Parameter(Mandatory,ValueFromPipeline)] 35 | [ValidateNotNullOrEmpty()] 36 | [string[]] $Message 37 | ) 38 | 39 | Process { 40 | foreach($m in $Message) { 41 | Write-Warning "$(if ( $env:CI -ne $null ) { '::warning::' })$m" 42 | } 43 | } 44 | } 45 | 46 | function Log-Error { 47 | [CmdletBinding()] 48 | param( 49 | [Parameter(Mandatory,ValueFromPipeline)] 50 | [ValidateNotNullOrEmpty()] 51 | [string[]] $Message 52 | ) 53 | 54 | Process { 55 | foreach($m in $Message) { 56 | Write-Error "$(if ( $env:CI -ne $null ) { '::error::' })$m" 57 | } 58 | } 59 | } 60 | 61 | function Log-Information { 62 | [CmdletBinding()] 63 | param( 64 | [Parameter(Mandatory,ValueFromPipeline)] 65 | [ValidateNotNullOrEmpty()] 66 | [string[]] $Message 67 | ) 68 | 69 | Process { 70 | if ( ! ( $script:Quiet ) ) { 71 | $StageName = $( if ( $script:StageName -ne $null ) { $script:StageName } else { '' }) 72 | $Icon = ' =>' 73 | 74 | foreach($m in $Message) { 75 | Write-Host -NoNewLine -ForegroundColor Blue " ${StageName} $($Icon.PadRight(5)) " 76 | Write-Host "${m}" 77 | } 78 | } 79 | } 80 | } 81 | 82 | function Log-Group { 83 | [CmdletBinding()] 84 | param( 85 | [Parameter(ValueFromPipeline)] 86 | [string[]] $Message 87 | ) 88 | 89 | Process { 90 | if ( $Env:CI -ne $null ) { 91 | if ( $script:LogGroup ) { 92 | Write-Output '::endgroup::' 93 | $script:LogGroup = $false 94 | } 95 | 96 | if ( $Message.count -ge 1 ) { 97 | Write-Output "::group::$($Message -join ' ')" 98 | $script:LogGroup = $true 99 | } 100 | } else { 101 | if ( $Message.count -ge 1 ) { 102 | Log-Information $Message 103 | } 104 | } 105 | } 106 | } 107 | 108 | function Log-Status { 109 | [CmdletBinding()] 110 | param( 111 | [Parameter(Mandatory,ValueFromPipeline)] 112 | [ValidateNotNullOrEmpty()] 113 | [string[]] $Message 114 | ) 115 | 116 | Process { 117 | if ( ! ( $script:Quiet ) ) { 118 | $StageName = $( if ( $StageName -ne $null ) { $StageName } else { '' }) 119 | $Icon = ' >' 120 | 121 | foreach($m in $Message) { 122 | Write-Host -NoNewLine -ForegroundColor Green " ${StageName} $($Icon.PadRight(5)) " 123 | Write-Host "${m}" 124 | } 125 | } 126 | } 127 | } 128 | 129 | function Log-Output { 130 | [CmdletBinding()] 131 | param( 132 | [Parameter(Mandatory,ValueFromPipeline)] 133 | [ValidateNotNullOrEmpty()] 134 | [string[]] $Message 135 | ) 136 | 137 | Process { 138 | if ( ! ( $script:Quiet ) ) { 139 | $StageName = $( if ( $script:StageName -ne $null ) { $script:StageName } else { '' }) 140 | $Icon = '' 141 | 142 | foreach($m in $Message) { 143 | Write-Output " ${StageName} $($Icon.PadRight(5)) ${m}" 144 | } 145 | } 146 | } 147 | } 148 | 149 | $Columns = (Get-Host).UI.RawUI.WindowSize.Width - 5 150 | -------------------------------------------------------------------------------- /cmake/macos/helpers.cmake: -------------------------------------------------------------------------------- 1 | # CMake macOS helper functions module 2 | 3 | # cmake-format: off 4 | # cmake-lint: disable=C0103 5 | # cmake-lint: disable=C0307 6 | # cmake-format: on 7 | 8 | include_guard(GLOBAL) 9 | 10 | include(helpers_common) 11 | 12 | # set_target_properties_obs: Set target properties for use in obs-studio 13 | function(set_target_properties_plugin target) 14 | set(options "") 15 | set(oneValueArgs "") 16 | set(multiValueArgs PROPERTIES) 17 | cmake_parse_arguments(PARSE_ARGV 0 _STPO "${options}" "${oneValueArgs}" "${multiValueArgs}") 18 | 19 | message(DEBUG "Setting additional properties for target ${target}...") 20 | 21 | while(_STPO_PROPERTIES) 22 | list(POP_FRONT _STPO_PROPERTIES key value) 23 | set_property(TARGET ${target} PROPERTY ${key} "${value}") 24 | endwhile() 25 | 26 | string(TIMESTAMP CURRENT_YEAR "%Y") 27 | set_target_properties( 28 | ${target} 29 | PROPERTIES BUNDLE TRUE 30 | BUNDLE_EXTENSION plugin 31 | XCODE_ATTRIBUTE_PRODUCT_NAME ${target} 32 | XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER ${MACOS_BUNDLEID} 33 | XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION ${PLUGIN_BUILD_NUMBER} 34 | XCODE_ATTRIBUTE_MARKETING_VERSION ${PLUGIN_VERSION} 35 | XCODE_ATTRIBUTE_GENERATE_INFOPLIST_FILE YES 36 | XCODE_ATTRIBUTE_INFOPLIST_FILE "" 37 | XCODE_ATTRIBUTE_INFOPLIST_KEY_CFBundleDisplayName ${target} 38 | XCODE_ATTRIBUTE_INFOPLIST_KEY_NSHumanReadableCopyright "(c) ${CURRENT_YEAR} ${PLUGIN_AUTHOR}" 39 | XCODE_ATTRIBUTE_INSTALL_PATH "$(USER_LIBRARY_DIR)/Application Support/obs-studio/plugins") 40 | 41 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist") 42 | set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS 43 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist") 44 | endif() 45 | 46 | if(TARGET plugin-support) 47 | target_link_libraries(${target} PRIVATE plugin-support) 48 | endif() 49 | 50 | target_install_resources(${target}) 51 | 52 | get_target_property(target_sources ${target} SOURCES) 53 | set(target_ui_files ${target_sources}) 54 | list(FILTER target_ui_files INCLUDE REGEX ".+\\.(ui|qrc)") 55 | source_group( 56 | TREE "${CMAKE_CURRENT_SOURCE_DIR}" 57 | PREFIX "UI Files" 58 | FILES ${target_ui_files}) 59 | 60 | install(TARGETS ${target} LIBRARY DESTINATION .) 61 | install( 62 | FILES "$.dsym" 63 | CONFIGURATIONS Release 64 | DESTINATION . 65 | OPTIONAL) 66 | 67 | configure_file(cmake/macos/resources/distribution.in "${CMAKE_CURRENT_BINARY_DIR}/distribution" @ONLY) 68 | configure_file(cmake/macos/resources/create-package.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake" @ONLY) 69 | install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake") 70 | endfunction() 71 | 72 | # target_install_resources: Helper function to add resources into bundle 73 | function(target_install_resources target) 74 | message(DEBUG "Installing resources for target ${target}...") 75 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/data") 76 | file(GLOB_RECURSE data_files "${CMAKE_CURRENT_SOURCE_DIR}/data/*") 77 | foreach(data_file IN LISTS data_files) 78 | cmake_path(RELATIVE_PATH data_file BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" OUTPUT_VARIABLE 79 | relative_path) 80 | cmake_path(GET relative_path PARENT_PATH relative_path) 81 | target_sources(${target} PRIVATE "${data_file}") 82 | set_property(SOURCE "${data_file}" PROPERTY MACOSX_PACKAGE_LOCATION "Resources/${relative_path}") 83 | source_group("Resources/${relative_path}" FILES "${data_file}") 84 | endforeach() 85 | endif() 86 | endfunction() 87 | 88 | # target_add_resource: Helper function to add a specific resource to a bundle 89 | function(target_add_resource target resource) 90 | message(DEBUG "Add resource ${resource} to target ${target} at destination ${destination}...") 91 | target_sources(${target} PRIVATE "${resource}") 92 | set_property(SOURCE "${resource}" PROPERTY MACOSX_PACKAGE_LOCATION Resources) 93 | source_group("Resources" FILES "${resource}") 94 | endfunction() 95 | -------------------------------------------------------------------------------- /.github/actions/package-plugin/action.yaml: -------------------------------------------------------------------------------- 1 | name: 'Package plugin' 2 | description: 'Packages the plugin for specified architecture and build config.' 3 | inputs: 4 | target: 5 | description: 'Build target for dependencies' 6 | required: true 7 | config: 8 | description: 'Build configuration' 9 | required: false 10 | default: 'RelWithDebInfo' 11 | codesign: 12 | description: 'Enable codesigning (macOS only)' 13 | required: false 14 | default: 'false' 15 | notarize: 16 | description: 'Enable notarization (macOS only)' 17 | required: false 18 | default: 'false' 19 | codesignIdent: 20 | description: 'Developer ID for application codesigning (macOS only)' 21 | required: false 22 | default: '-' 23 | installerIdent: 24 | description: 'Developer ID for installer package codesigning (macOS only)' 25 | required: false 26 | default: '' 27 | codesignTeam: 28 | description: 'Developer team for codesigning (macOS only)' 29 | required: false 30 | default: '' 31 | codesignUser: 32 | description: 'Apple ID username for notarization (macOS only)' 33 | required: false 34 | default: '' 35 | codesignPass: 36 | description: 'Apple ID password for notarization (macOS only)' 37 | required: false 38 | default: '' 39 | package: 40 | description: 'Create Windows or macOS installation package' 41 | required: false 42 | default: 'false' 43 | workingDirectory: 44 | description: 'Working directory for packaging' 45 | required: false 46 | default: ${{ github.workspace }} 47 | runs: 48 | using: composite 49 | steps: 50 | - name: Run macOS Packaging 51 | if: runner.os == 'macOS' 52 | shell: zsh --no-rcs --errexit --pipefail {0} 53 | working-directory: ${{ inputs.workingDirectory }} 54 | env: 55 | CODESIGN_IDENT: ${{ inputs.codesignIdent }} 56 | CODESIGN_IDENT_INSTALLER: ${{ inputs.installerIdent }} 57 | CODESIGN_TEAM: ${{ inputs.codesignTeam }} 58 | CODESIGN_IDENT_USER: ${{ inputs.codesignUser }} 59 | CODESIGN_IDENT_PASS: ${{ inputs.codesignPass }} 60 | run: | 61 | : Run macOS Packaging 62 | 63 | local -a package_args=(--config ${{ inputs.config }}) 64 | if (( ${+RUNNER_DEBUG} )) package_args+=(--debug) 65 | 66 | if [[ '${{ inputs.codesign }}' == 'true' ]] package_args+=(--codesign) 67 | if [[ '${{ inputs.notarize }}' == 'true' ]] package_args+=(--notarize) 68 | if [[ '${{ inputs.package }}' == 'true' ]] package_args+=(--package) 69 | 70 | .github/scripts/package-macos ${package_args} 71 | 72 | - name: Install Dependencies 🛍️ 73 | if: runner.os == 'Linux' 74 | shell: bash 75 | run: | 76 | : Install Dependencies 🛍️ 77 | echo ::group::Install Dependencies 78 | eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 79 | echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH 80 | brew install --quiet zsh 81 | echo ::endgroup:: 82 | 83 | - name: Run Ubuntu Packaging 84 | if: runner.os == 'Linux' 85 | shell: zsh --no-rcs --errexit --pipefail {0} 86 | working-directory: ${{ inputs.workingDirectory }} 87 | run: | 88 | : Run Ubuntu Packaging 89 | package_args=( 90 | --target linux-${{ inputs.target }} 91 | --config ${{ inputs.config }} 92 | ) 93 | if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) 94 | 95 | if [[ '${{ inputs.package }}' == 'true' ]] package_args+=(--package) 96 | 97 | .github/scripts/package-linux ${package_args} 98 | 99 | - name: Run Windows Packaging 100 | if: runner.os == 'Windows' 101 | shell: pwsh 102 | run: | 103 | # Run Windows Packaging 104 | if ( $Env:RUNNER_DEBUG -ne $null ) { 105 | Set-PSDebug -Trace 1 106 | } 107 | 108 | $PackageArgs = @{ 109 | Target = '${{ inputs.target }}' 110 | Configuration = '${{ inputs.config }}' 111 | } 112 | 113 | if ( '${{ inputs.package }}' -eq 'true' ) { 114 | $PackageArgs += @{BuildInstaller = $true} 115 | } 116 | 117 | .github/scripts/Package-Windows.ps1 @PackageArgs 118 | -------------------------------------------------------------------------------- /.github/workflows/push.yaml: -------------------------------------------------------------------------------- 1 | name: Push to master 2 | run-name: ${{ github.ref_name }} push run 🚀 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | - 'release/**' 9 | tags: 10 | - '*' 11 | permissions: 12 | contents: write 13 | concurrency: 14 | group: '${{ github.workflow }} @ ${{ github.ref }}' 15 | cancel-in-progress: ${{ github.ref_type == 'tag' }} 16 | jobs: 17 | check-format: 18 | name: Check Formatting 🔍 19 | if: github.ref_name == 'master' 20 | uses: ./.github/workflows/check-format.yaml 21 | permissions: 22 | contents: read 23 | 24 | build-project: 25 | name: Build Project 🧱 26 | uses: ./.github/workflows/build-project.yaml 27 | secrets: inherit 28 | permissions: 29 | contents: read 30 | 31 | create-release: 32 | name: Create Release 🛫 33 | if: github.ref_type == 'tag' 34 | runs-on: ubuntu-22.04 35 | needs: build-project 36 | defaults: 37 | run: 38 | shell: bash 39 | steps: 40 | - name: Check Release Tag ☑️ 41 | id: check 42 | run: | 43 | : Check Release Tag ☑️ 44 | if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi 45 | shopt -s extglob 46 | 47 | case "${GITHUB_REF_NAME}" in 48 | +([0-9]).+([0-9]).+([0-9]) ) 49 | echo 'validTag=true' >> $GITHUB_OUTPUT 50 | echo 'prerelease=false' >> $GITHUB_OUTPUT 51 | echo "version=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT 52 | ;; 53 | +([0-9]).+([0-9]).+([0-9])-@(beta|rc)*([0-9]) ) 54 | echo 'validTag=true' >> $GITHUB_OUTPUT 55 | echo 'prerelease=true' >> $GITHUB_OUTPUT 56 | echo "version=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT 57 | ;; 58 | *) echo 'validTag=false' >> $GITHUB_OUTPUT ;; 59 | esac 60 | 61 | - name: Download Build Artifacts 📥 62 | uses: actions/download-artifact@v4 63 | if: fromJSON(steps.check.outputs.validTag) 64 | id: download 65 | 66 | - name: Rename Files 🏷️ 67 | if: fromJSON(steps.check.outputs.validTag) 68 | run: | 69 | : Rename Files 🏷️ 70 | if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi 71 | shopt -s extglob 72 | shopt -s nullglob 73 | 74 | root_dir="$(pwd)" 75 | commit_hash="${GITHUB_SHA:0:9}" 76 | 77 | variants=( 78 | 'windows-x64;zip|exe' 79 | 'macos-universal;tar.xz|pkg' 80 | 'ubuntu-22.04-x86_64;tar.xz|deb|ddeb' 81 | 'sources;tar.xz' 82 | ) 83 | 84 | for variant_data in "${variants[@]}"; do 85 | IFS=';' read -r variant suffix <<< "${variant_data}" 86 | 87 | candidates=(*-${variant}-${commit_hash}/@(*|*-dbgsym).@(${suffix})) 88 | 89 | for candidate in "${candidates[@]}"; do 90 | mv "${candidate}" "${root_dir}" 91 | done 92 | done 93 | 94 | - name: Generate Checksums 🪪 95 | if: fromJSON(steps.check.outputs.validTag) 96 | run: | 97 | : Generate Checksums 🪪 98 | if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi 99 | shopt -s extglob 100 | 101 | echo "### Checksums" > ${{ github.workspace }}/CHECKSUMS.txt 102 | for file in ${{ github.workspace }}/@(*.exe|*.deb|*.ddeb|*.pkg|*.tar.xz|*.zip); do 103 | echo " ${file##*/}: $(sha256sum "${file}" | cut -d " " -f 1)" >> ${{ github.workspace }}/CHECKSUMS.txt 104 | done 105 | 106 | - name: Create Release 🛫 107 | if: fromJSON(steps.check.outputs.validTag) 108 | id: create_release 109 | uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 110 | with: 111 | draft: true 112 | prerelease: ${{ fromJSON(steps.check.outputs.prerelease) }} 113 | tag_name: ${{ steps.check.outputs.version }} 114 | name: ${{ needs.build-project.outputs.pluginName }} ${{ steps.check.outputs.version }} 115 | body_path: ${{ github.workspace }}/CHECKSUMS.txt 116 | files: | 117 | ${{ github.workspace }}/*.exe 118 | ${{ github.workspace }}/*.zip 119 | ${{ github.workspace }}/*.pkg 120 | ${{ github.workspace }}/*.deb 121 | ${{ github.workspace }}/*.ddeb 122 | ${{ github.workspace }}/*.tar.xz 123 | -------------------------------------------------------------------------------- /cmake/windows/helpers.cmake: -------------------------------------------------------------------------------- 1 | # CMake Windows helper functions module 2 | 3 | # cmake-format: off 4 | # cmake-lint: disable=C0103 5 | # cmake-format: on 6 | 7 | include_guard(GLOBAL) 8 | 9 | include(helpers_common) 10 | 11 | # set_target_properties_plugin: Set target properties for use in obs-studio 12 | function(set_target_properties_plugin target) 13 | set(options "") 14 | set(oneValueArgs "") 15 | set(multiValueArgs PROPERTIES) 16 | cmake_parse_arguments(PARSE_ARGV 0 _STPO "${options}" "${oneValueArgs}" "${multiValueArgs}") 17 | 18 | message(DEBUG "Setting additional properties for target ${target}...") 19 | 20 | while(_STPO_PROPERTIES) 21 | list(POP_FRONT _STPO_PROPERTIES key value) 22 | set_property(TARGET ${target} PROPERTY ${key} "${value}") 23 | endwhile() 24 | 25 | string(TIMESTAMP CURRENT_YEAR "%Y") 26 | 27 | set_target_properties(${target} PROPERTIES VERSION 0 SOVERSION ${PLUGIN_VERSION}) 28 | 29 | install( 30 | TARGETS ${target} 31 | RUNTIME DESTINATION bin/64bit 32 | LIBRARY DESTINATION obs-plugins/64bit) 33 | 34 | install( 35 | FILES "$" 36 | CONFIGURATIONS RelWithDebInfo Debug Release 37 | DESTINATION obs-plugins/64bit 38 | OPTIONAL) 39 | 40 | if(OBS_BUILD_DIR) 41 | add_custom_command( 42 | TARGET ${target} 43 | POST_BUILD 44 | COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_BUILD_DIR}/obs-plugins/64bit" 45 | COMMAND 46 | "${CMAKE_COMMAND}" -E copy_if_different "$" 47 | "$<$:$>" "${OBS_BUILD_DIR}/obs-plugins/64bit" 48 | COMMENT "Copy ${target} to obs-studio directory ${OBS_BUILD_DIR}" 49 | VERBATIM) 50 | endif() 51 | 52 | if(TARGET plugin-support) 53 | target_link_libraries(${target} PRIVATE plugin-support) 54 | endif() 55 | 56 | target_install_resources(${target}) 57 | 58 | get_target_property(target_sources ${target} SOURCES) 59 | set(target_ui_files ${target_sources}) 60 | list(FILTER target_ui_files INCLUDE REGEX ".+\\.(ui|qrc)") 61 | source_group( 62 | TREE "${CMAKE_CURRENT_SOURCE_DIR}" 63 | PREFIX "UI Files" 64 | FILES ${target_ui_files}) 65 | 66 | set(valid_uuid FALSE) 67 | check_uuid(${_windowsAppUUID} valid_uuid) 68 | if(NOT valid_uuid) 69 | message(FATAL_ERROR "Specified Windows package UUID is not a valid UUID value: ${_windowsAppUUID}") 70 | else() 71 | set(UUID_APP ${_windowsAppUUID}) 72 | endif() 73 | 74 | configure_file(cmake/windows/resources/installer-Windows.iss.in 75 | "${CMAKE_CURRENT_BINARY_DIR}/installer-Windows.generated.iss") 76 | 77 | configure_file(cmake/windows/resources/resource.rc.in "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.rc") 78 | target_sources(${CMAKE_PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.rc") 79 | endfunction() 80 | 81 | # Helper function to add resources into bundle 82 | function(target_install_resources target) 83 | message(DEBUG "Installing resources for target ${target}...") 84 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/data") 85 | file(GLOB_RECURSE data_files "${CMAKE_CURRENT_SOURCE_DIR}/data/*") 86 | foreach(data_file IN LISTS data_files) 87 | cmake_path(RELATIVE_PATH data_file BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" OUTPUT_VARIABLE 88 | relative_path) 89 | cmake_path(GET relative_path PARENT_PATH relative_path) 90 | target_sources(${target} PRIVATE "${data_file}") 91 | source_group("Resources/${relative_path}" FILES "${data_file}") 92 | endforeach() 93 | 94 | install( 95 | DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" 96 | DESTINATION data/obs-plugins/${target} 97 | USE_SOURCE_PERMISSIONS) 98 | 99 | if(OBS_BUILD_DIR) 100 | add_custom_command( 101 | TARGET ${target} 102 | POST_BUILD 103 | COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_BUILD_DIR}/data/obs-plugins/${target}" 104 | COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/data" 105 | "${OBS_BUILD_DIR}/data/obs-plugins/${target}" 106 | COMMENT "Copy ${target} resources to data directory" 107 | VERBATIM) 108 | endif() 109 | endif() 110 | endfunction() 111 | 112 | # Helper function to add a specific resource to a bundle 113 | function(target_add_resource target resource) 114 | message(DEBUG "Add resource '${resource}' to target ${target} at destination '${target_destination}'...") 115 | 116 | install( 117 | FILES "${resource}" 118 | DESTINATION data/obs-plugins/${target} 119 | COMPONENT Runtime) 120 | 121 | if(OBS_BUILD_DIR) 122 | add_custom_command( 123 | TARGET ${target} 124 | POST_BUILD 125 | COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_BUILD_DIR}/data/obs-plugins/${target}" 126 | COMMAND "${CMAKE_COMMAND}" -E copy "${resource}" "${OBS_BUILD_DIR}/data/obs-plugins/${target}" 127 | COMMENT "Copy ${target} resource ${resource} to library directory" 128 | VERBATIM) 129 | endif() 130 | source_group("Resources" FILES "${resource}") 131 | endfunction() 132 | -------------------------------------------------------------------------------- /CMakePresets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "cmakeMinimumRequired": { 4 | "major": 3, 5 | "minor": 22, 6 | "patch": 0 7 | }, 8 | "configurePresets": [ 9 | { 10 | "name": "template", 11 | "hidden": true, 12 | "cacheVariables": { 13 | "ENABLE_FRONTEND_API": false, 14 | "ENABLE_QT": false 15 | } 16 | }, 17 | { 18 | "name": "macos", 19 | "displayName": "macOS Universal", 20 | "description": "Build for macOS 11.0+ (Universal binary)", 21 | "inherits": ["template"], 22 | "binaryDir": "${sourceDir}/build_macos", 23 | "condition": { 24 | "type": "equals", 25 | "lhs": "${hostSystemName}", 26 | "rhs": "Darwin" 27 | }, 28 | "generator": "Xcode", 29 | "warnings": {"dev": true, "deprecated": true}, 30 | "cacheVariables": { 31 | "CMAKE_OSX_DEPLOYMENT_TARGET": "11.0", 32 | "CODESIGN_IDENTITY": "$penv{CODESIGN_IDENT}", 33 | "CODESIGN_TEAM": "$penv{CODESIGN_TEAM}" 34 | } 35 | }, 36 | { 37 | "name": "macos-ci", 38 | "inherits": ["macos"], 39 | "displayName": "macOS Universal CI build", 40 | "description": "Build for macOS 11.0+ (Universal binary) for CI", 41 | "generator": "Xcode", 42 | "cacheVariables": { 43 | "CMAKE_COMPILE_WARNING_AS_ERROR": true 44 | } 45 | }, 46 | { 47 | "name": "windows-x64", 48 | "displayName": "Windows x64", 49 | "description": "Build for Windows x64", 50 | "inherits": ["template"], 51 | "binaryDir": "${sourceDir}/build_x64", 52 | "condition": { 53 | "type": "equals", 54 | "lhs": "${hostSystemName}", 55 | "rhs": "Windows" 56 | }, 57 | "generator": "Visual Studio 17 2022", 58 | "architecture": "x64", 59 | "warnings": {"dev": true, "deprecated": true}, 60 | "cacheVariables": { 61 | "CMAKE_SYSTEM_VERSION": "10.0.18363.657" 62 | } 63 | }, 64 | { 65 | "name": "windows-ci-x64", 66 | "inherits": ["windows-x64"], 67 | "displayName": "Windows x64 CI build", 68 | "description": "Build for Windows x64 on CI", 69 | "cacheVariables": { 70 | "CMAKE_COMPILE_WARNING_AS_ERROR": true 71 | } 72 | }, 73 | { 74 | "name": "linux-x86_64", 75 | "displayName": "Linux x86_64", 76 | "description": "Build for Linux x86_64", 77 | "inherits": ["template"], 78 | "binaryDir": "${sourceDir}/build_x86_64", 79 | "condition": { 80 | "type": "equals", 81 | "lhs": "${hostSystemName}", 82 | "rhs": "Linux" 83 | }, 84 | "generator": "Ninja", 85 | "warnings": {"dev": true, "deprecated": true}, 86 | "cacheVariables": { 87 | "CMAKE_BUILD_TYPE": "RelWithDebInfo" 88 | } 89 | }, 90 | { 91 | "name": "linux-ci-x86_64", 92 | "inherits": ["linux-x86_64"], 93 | "displayName": "Linux x86_64 CI build", 94 | "description": "Build for Linux x86_64 on CI", 95 | "cacheVariables": { 96 | "CMAKE_BUILD_TYPE": "RelWithDebInfo", 97 | "CMAKE_COMPILE_WARNING_AS_ERROR": true 98 | } 99 | }, 100 | { 101 | "name": "linux-aarch64", 102 | "displayName": "Linux aarch64", 103 | "description": "Build for Linux aarch64", 104 | "inherits": ["template"], 105 | "binaryDir": "${sourceDir}/build_aarch64", 106 | "condition": { 107 | "type": "equals", 108 | "lhs": "${hostSystemName}", 109 | "rhs": "Linux" 110 | }, 111 | "generator": "Ninja", 112 | "warnings": {"dev": true, "deprecated": true}, 113 | "cacheVariables": { 114 | "CMAKE_BUILD_TYPE": "RelWithDebInfo" 115 | } 116 | }, 117 | { 118 | "name": "linux-ci-aarch64", 119 | "inherits": ["linux-aarch64"], 120 | "displayName": "Linux aarch64 CI build", 121 | "description": "Build for Linux aarch64 on CI", 122 | "cacheVariables": { 123 | "CMAKE_BUILD_TYPE": "RelWithDebInfo", 124 | "CMAKE_COMPILE_WARNING_AS_ERROR": true 125 | } 126 | } 127 | ], 128 | "buildPresets": [ 129 | { 130 | "name": "macos", 131 | "configurePreset": "macos", 132 | "displayName": "macOS Universal", 133 | "description": "macOS build for Universal architectures", 134 | "configuration": "Release" 135 | }, 136 | { 137 | "name": "macos-ci", 138 | "configurePreset": "macos-ci", 139 | "displayName": "macOS Universal CI", 140 | "description": "macOS CI build for Universal architectures", 141 | "configuration": "RelWithDebInfo" 142 | }, 143 | { 144 | "name": "windows-x64", 145 | "configurePreset": "windows-x64", 146 | "displayName": "Windows x64", 147 | "description": "Windows build for x64", 148 | "configuration": "RelWithDebInfo" 149 | }, 150 | { 151 | "name": "windows-ci-x64", 152 | "configurePreset": "windows-ci-x64", 153 | "displayName": "Windows x64 CI", 154 | "description": "Windows CI build for x64 (RelWithDebInfo configuration)", 155 | "configuration": "RelWithDebInfo" 156 | }, 157 | { 158 | "name": "linux-x86_64", 159 | "configurePreset": "linux-x86_64", 160 | "displayName": "Linux x86_64", 161 | "description": "Linux build for x86_64", 162 | "configuration": "RelWithDebInfo" 163 | }, 164 | { 165 | "name": "linux-ci-x86_64", 166 | "configurePreset": "linux-ci-x86_64", 167 | "displayName": "Linux x86_64 CI", 168 | "description": "Linux CI build for x86_64", 169 | "configuration": "RelWithDebInfo" 170 | }, 171 | { 172 | "name": "linux-aarch64", 173 | "configurePreset": "linux-aarch64", 174 | "displayName": "Linux aarch64", 175 | "description": "Linux build for aarch64", 176 | "configuration": "RelWithDebInfo" 177 | }, 178 | { 179 | "name": "linux-ci-aarch64", 180 | "configurePreset": "linux-ci-aarch64", 181 | "displayName": "Linux aarch64 CI", 182 | "description": "Linux CI build for aarch64", 183 | "configuration": "RelWithDebInfo" 184 | } 185 | ] 186 | } 187 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # please use clang-format version 16 or later 2 | 3 | Standard: c++17 4 | AccessModifierOffset: -8 5 | AlignAfterOpenBracket: Align 6 | AlignConsecutiveAssignments: false 7 | AlignConsecutiveDeclarations: false 8 | AlignEscapedNewlines: Left 9 | AlignOperands: true 10 | AlignTrailingComments: true 11 | AllowAllArgumentsOnNextLine: false 12 | AllowAllConstructorInitializersOnNextLine: false 13 | AllowAllParametersOfDeclarationOnNextLine: false 14 | AllowShortBlocksOnASingleLine: false 15 | AllowShortCaseLabelsOnASingleLine: false 16 | AllowShortFunctionsOnASingleLine: Inline 17 | AllowShortIfStatementsOnASingleLine: false 18 | AllowShortLambdasOnASingleLine: Inline 19 | AllowShortLoopsOnASingleLine: false 20 | AlwaysBreakAfterDefinitionReturnType: None 21 | AlwaysBreakAfterReturnType: None 22 | AlwaysBreakBeforeMultilineStrings: false 23 | AlwaysBreakTemplateDeclarations: false 24 | BinPackArguments: true 25 | BinPackParameters: true 26 | BraceWrapping: 27 | AfterClass: false 28 | AfterControlStatement: false 29 | AfterEnum: false 30 | AfterFunction: true 31 | AfterNamespace: false 32 | AfterObjCDeclaration: false 33 | AfterStruct: false 34 | AfterUnion: false 35 | AfterExternBlock: false 36 | BeforeCatch: false 37 | BeforeElse: false 38 | IndentBraces: false 39 | SplitEmptyFunction: true 40 | SplitEmptyRecord: true 41 | SplitEmptyNamespace: true 42 | BreakBeforeBinaryOperators: None 43 | BreakBeforeBraces: Custom 44 | BreakBeforeTernaryOperators: true 45 | BreakConstructorInitializers: BeforeColon 46 | BreakStringLiterals: false # apparently unpredictable 47 | ColumnLimit: 80 48 | CompactNamespaces: false 49 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 50 | ConstructorInitializerIndentWidth: 8 51 | ContinuationIndentWidth: 8 52 | Cpp11BracedListStyle: true 53 | DerivePointerAlignment: false 54 | DisableFormat: false 55 | FixNamespaceComments: true 56 | ForEachMacros: 57 | - 'json_object_foreach' 58 | - 'json_object_foreach_safe' 59 | - 'json_array_foreach' 60 | - 'HASH_ITER' 61 | IncludeBlocks: Preserve 62 | IndentCaseLabels: false 63 | IndentPPDirectives: None 64 | IndentWidth: 8 65 | IndentWrappedFunctionNames: false 66 | KeepEmptyLinesAtTheStartOfBlocks: true 67 | MaxEmptyLinesToKeep: 1 68 | NamespaceIndentation: None 69 | ObjCBinPackProtocolList: Auto 70 | ObjCBlockIndentWidth: 8 71 | ObjCSpaceAfterProperty: true 72 | ObjCSpaceBeforeProtocolList: true 73 | 74 | PenaltyBreakAssignment: 10 75 | PenaltyBreakBeforeFirstCallParameter: 30 76 | PenaltyBreakComment: 10 77 | PenaltyBreakFirstLessLess: 0 78 | PenaltyBreakString: 10 79 | PenaltyExcessCharacter: 100 80 | PenaltyReturnTypeOnItsOwnLine: 60 81 | 82 | PointerAlignment: Right 83 | ReflowComments: false 84 | SortIncludes: false 85 | SortUsingDeclarations: false 86 | SpaceAfterCStyleCast: false 87 | SpaceAfterLogicalNot: false 88 | SpaceAfterTemplateKeyword: false 89 | SpaceBeforeAssignmentOperators: true 90 | SpaceBeforeCtorInitializerColon: true 91 | SpaceBeforeInheritanceColon: true 92 | SpaceBeforeParens: ControlStatements 93 | SpaceBeforeRangeBasedForLoopColon: true 94 | SpaceInEmptyParentheses: false 95 | SpacesBeforeTrailingComments: 1 96 | SpacesInAngles: false 97 | SpacesInCStyleCastParentheses: false 98 | SpacesInContainerLiterals: false 99 | SpacesInParentheses: false 100 | SpacesInSquareBrackets: false 101 | StatementMacros: 102 | - 'Q_OBJECT' 103 | TabWidth: 8 104 | TypenameMacros: 105 | - 'DARRAY' 106 | UseTab: ForContinuationAndIndentation 107 | --- 108 | Language: ObjC 109 | AccessModifierOffset: 2 110 | AlignArrayOfStructures: Right 111 | AlignConsecutiveAssignments: None 112 | AlignConsecutiveBitFields: None 113 | AlignConsecutiveDeclarations: None 114 | AlignConsecutiveMacros: 115 | Enabled: true 116 | AcrossEmptyLines: false 117 | AcrossComments: true 118 | AllowShortBlocksOnASingleLine: Never 119 | AllowShortEnumsOnASingleLine: false 120 | AllowShortFunctionsOnASingleLine: Empty 121 | AllowShortIfStatementsOnASingleLine: Never 122 | AllowShortLambdasOnASingleLine: None 123 | AttributeMacros: ['__unused', '__autoreleasing', '_Nonnull', '__bridge'] 124 | BitFieldColonSpacing: Both 125 | #BreakBeforeBraces: Webkit 126 | BreakBeforeBraces: Custom 127 | BraceWrapping: 128 | AfterCaseLabel: false 129 | AfterClass: true 130 | AfterControlStatement: Never 131 | AfterEnum: false 132 | AfterFunction: true 133 | AfterNamespace: false 134 | AfterObjCDeclaration: false 135 | AfterStruct: false 136 | AfterUnion: false 137 | AfterExternBlock: false 138 | BeforeCatch: false 139 | BeforeElse: false 140 | BeforeLambdaBody: false 141 | BeforeWhile: false 142 | IndentBraces: false 143 | SplitEmptyFunction: false 144 | SplitEmptyRecord: false 145 | SplitEmptyNamespace: true 146 | BreakAfterAttributes: Never 147 | BreakArrays: false 148 | BreakBeforeConceptDeclarations: Allowed 149 | BreakBeforeInlineASMColon: OnlyMultiline 150 | BreakConstructorInitializers: AfterColon 151 | BreakInheritanceList: AfterComma 152 | ColumnLimit: 120 153 | ConstructorInitializerIndentWidth: 4 154 | ContinuationIndentWidth: 4 155 | EmptyLineAfterAccessModifier: Never 156 | EmptyLineBeforeAccessModifier: LogicalBlock 157 | ExperimentalAutoDetectBinPacking: false 158 | FixNamespaceComments: true 159 | IndentAccessModifiers: false 160 | IndentCaseBlocks: false 161 | IndentCaseLabels: true 162 | IndentExternBlock: Indent 163 | IndentGotoLabels: false 164 | IndentRequiresClause: true 165 | IndentWidth: 4 166 | IndentWrappedFunctionNames: true 167 | InsertBraces: false 168 | InsertNewlineAtEOF: true 169 | KeepEmptyLinesAtTheStartOfBlocks: false 170 | LambdaBodyIndentation: Signature 171 | NamespaceIndentation: All 172 | ObjCBinPackProtocolList: Auto 173 | ObjCBlockIndentWidth: 4 174 | ObjCBreakBeforeNestedBlockParam: false 175 | ObjCSpaceAfterProperty: true 176 | ObjCSpaceBeforeProtocolList: true 177 | PPIndentWidth: -1 178 | PackConstructorInitializers: NextLine 179 | QualifierAlignment: Leave 180 | ReferenceAlignment: Right 181 | RemoveSemicolon: false 182 | RequiresClausePosition: WithPreceding 183 | RequiresExpressionIndentation: OuterScope 184 | SeparateDefinitionBlocks: Always 185 | ShortNamespaceLines: 1 186 | SortIncludes: false 187 | #SortUsingDeclarations: LexicographicNumeric 188 | SortUsingDeclarations: true 189 | SpaceAfterCStyleCast: true 190 | SpaceAfterLogicalNot: false 191 | SpaceAroundPointerQualifiers: Default 192 | SpaceBeforeCaseColon: false 193 | SpaceBeforeCpp11BracedList: true 194 | SpaceBeforeCtorInitializerColon: true 195 | SpaceBeforeInheritanceColon: true 196 | SpaceBeforeParens: ControlStatements 197 | SpaceBeforeRangeBasedForLoopColon: true 198 | SpaceBeforeSquareBrackets: false 199 | SpaceInEmptyBlock: false 200 | SpaceInEmptyParentheses: false 201 | SpacesBeforeTrailingComments: 2 202 | SpacesInConditionalStatement: false 203 | SpacesInLineCommentPrefix: 204 | Minimum: 1 205 | Maximum: -1 206 | Standard: c++17 207 | TabWidth: 4 208 | UseTab: Never 209 | -------------------------------------------------------------------------------- /.github/actions/setup-macos-codesigning/action.yaml: -------------------------------------------------------------------------------- 1 | name: Set up macOS codesigning 2 | description: Sets up code signing certificates, provisioning profiles, and notarization information 3 | inputs: 4 | codesignIdentity: 5 | description: Codesigning identity 6 | required: true 7 | installerIdentity: 8 | description: Codesigning identity for package installer 9 | required: false 10 | codesignCertificate: 11 | description: PKCS12 certificate in base64 format 12 | required: true 13 | certificatePassword: 14 | description: Password required to install PKCS12 certificate 15 | required: true 16 | keychainPassword: 17 | description: Password to use for temporary keychain 18 | required: false 19 | notarizationUser: 20 | description: Apple ID to use for notarization 21 | required: false 22 | notarizationPassword: 23 | description: Application password for notarization 24 | provisioningProfile: 25 | description: Provisioning profile in base64 format 26 | required: false 27 | outputs: 28 | haveCodesignIdent: 29 | description: True if necessary codesigning credentials were found 30 | value: ${{ steps.codesign.outputs.haveCodesignIdent }} 31 | haveProvisioningProfile: 32 | description: True if necessary provisioning profile credentials were found 33 | value: ${{ steps.provisioning.outputs.haveProvisioningProfile }} 34 | haveNotarizationUser: 35 | description: True if necessary notarization credentials were found 36 | value: ${{ steps.notarization.outputs.haveNotarizationUser }} 37 | codesignIdent: 38 | description: Codesigning identity 39 | value: ${{ steps.codesign.outputs.codesignIdent }} 40 | installerIdent: 41 | description: Codesigning identity for package installer 42 | value: ${{ steps.codesign.outputs.installerIdent }} 43 | codesignTeam: 44 | description: Codesigning team 45 | value: ${{ steps.codesign.outputs.codesignTeam }} 46 | runs: 47 | using: composite 48 | steps: 49 | - name: Check Runner Operating System 🏃‍♂️ 50 | if: runner.os != 'macOS' 51 | shell: bash 52 | run: | 53 | : Check Runner Operating System 🏃‍♂️ 54 | echo "setup-macos-codesigning action requires a macOS-based runner." 55 | exit 2 56 | 57 | - name: macOS Codesigning ✍️ 58 | shell: zsh --no-rcs --errexit --pipefail {0} 59 | id: codesign 60 | env: 61 | MACOS_SIGNING_IDENTITY: ${{ inputs.codesignIdentity }} 62 | MACOS_SIGNING_IDENTITY_INSTALLER: ${{ inputs.installerIdentity}} 63 | MACOS_SIGNING_CERT: ${{ inputs.codesignCertificate }} 64 | MAOCS_SIGNING_CERT_PASSWORD: ${{ inputs.certificatePassword }} 65 | MACOS_KEYCHAIN_PASSWORD: ${{ inputs.keychainPassword }} 66 | run: | 67 | : macOS Codesigning ✍️ 68 | if (( ${+RUNNER_DEBUG} )) setopt XTRACE 69 | 70 | if [[ ${MACOS_SIGNING_IDENTITY} && ${MACOS_SIGNING_IDENTITY_INSTALLER} && ${MACOS_SIGNING_CERT} ]] { 71 | print 'haveCodesignIdent=true' >> $GITHUB_OUTPUT 72 | 73 | local -r certificate_path="${RUNNER_TEMP}/build_certificate.p12" 74 | local -r keychain_path="${RUNNER_TEMP}/app-signing.keychain-db" 75 | 76 | print -n "${MACOS_SIGNING_CERT}" | base64 --decode --output="${certificate_path}" 77 | 78 | : "${MACOS_KEYCHAIN_PASSWORD:="$(print ${RANDOM} | shasum | head -c 32)"}" 79 | 80 | print '::group::Keychain setup' 81 | security create-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" ${keychain_path} 82 | security set-keychain-settings -lut 21600 ${keychain_path} 83 | security unlock-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" ${keychain_path} 84 | 85 | security import "${certificate_path}" -P "${MAOCS_SIGNING_CERT_PASSWORD}" -A \ 86 | -t cert -f pkcs12 -k ${keychain_path} \ 87 | -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/xcrun 88 | 89 | security set-key-partition-list -S 'apple-tool:,apple:' -k "${MACOS_KEYCHAIN_PASSWORD}" \ 90 | ${keychain_path} &> /dev/null 91 | 92 | security list-keychain -d user -s ${keychain_path} 'login-keychain' 93 | print '::endgroup::' 94 | 95 | local -r team_id="${${MACOS_SIGNING_IDENTITY##* }//(\(|\))/}" 96 | 97 | print "codesignIdent=${MACOS_SIGNING_IDENTITY}" >> $GITHUB_OUTPUT 98 | print "installerIdent=${MACOS_SIGNING_IDENTITY_INSTALLER}" >> $GITHUB_OUTPUT 99 | print "MACOS_KEYCHAIN_PASSWORD=${MACOS_KEYCHAIN_PASSWORD}" >> $GITHUB_ENV 100 | print "codesignTeam=${team_id}" >> $GITHUB_OUTPUT 101 | } else { 102 | print 'haveCodesignIdent=false' >> $GITHUB_OUTPUT 103 | } 104 | 105 | - name: Provisioning Profile 👤 106 | shell: zsh --no-rcs --errexit --pipefail {0} 107 | id: provisioning 108 | if: ${{ fromJSON(steps.codesign.outputs.haveCodesignIdent) }} 109 | env: 110 | MACOS_SIGNING_PROVISIONING_PROFILE: ${{ inputs.provisioningProfile }} 111 | run: | 112 | : Provisioning Profile 👤 113 | if (( ${+RUNNER_DEBUG} )) setopt XTRACE 114 | 115 | if [[ ${MACOS_SIGNING_PROVISIONING_PROFILE} ]] { 116 | print 'haveProvisioningProfile=true' >> $GITHUB_OUTPUT 117 | 118 | local -r profile_path="${RUNNER_TEMP}/build_profile.provisionprofile" 119 | print -n "${MACOS_SIGNING_PROVISIONING_PROFILE}" \ 120 | | base64 --decode --output ${profile_path} 121 | 122 | print '::group::Provisioning Profile Setup' 123 | mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles 124 | security cms -D -i ${profile_path} -o ${RUNNER_TEMP}/build_profile.plist 125 | local -r uuid="$(plutil -extract UUID raw ${RUNNER_TEMP}/build_profile.plist)" 126 | local -r team_id="$(plutil -extract TeamIdentifier.0 raw -expect string ${RUNNER_TEMP}/build_profile.plist)" 127 | 128 | if [[ ${team_id} != '${{ steps.codesign.codesignTeam }}' ]] { 129 | print '::notice::Code Signing team in provisioning profile does not match certificate.' 130 | } 131 | 132 | cp ${profile_path} ~/Library/MobileDevice/Provisioning\ Profiles/${uuid}.provisionprofile 133 | print "provisioningProfileUUID=${uuid}" >> $GITHUB_OUTPUT 134 | print '::endgroup::' 135 | } else { 136 | print 'haveProvisioningProfile=false' >> $GITHUB_OUTPUT 137 | } 138 | 139 | - name: Notarization 🧑‍💼 140 | shell: zsh --no-rcs --errexit --pipefail {0} 141 | id: notarization 142 | if: ${{ fromJSON(steps.codesign.outputs.haveCodesignIdent) }} 143 | env: 144 | MACOS_NOTARIZATION_USERNAME: ${{ inputs.notarizationUser }} 145 | MACOS_NOTARIZATION_PASSWORD: ${{ inputs.notarizationPassword }} 146 | run: | 147 | : Notarization 🧑‍💼 148 | if (( ${+RUNNER_DEBUG} )) setopt XTRACE 149 | 150 | if [[ ${MACOS_NOTARIZATION_USERNAME} && ${MACOS_NOTARIZATION_PASSWORD} ]] { 151 | print 'haveNotarizationUser=true' >> $GITHUB_OUTPUT 152 | } else { 153 | print 'haveNotarizationUser=false' >> $GITHUB_OUTPUT 154 | } 155 | -------------------------------------------------------------------------------- /cmake/common/buildspec_common.cmake: -------------------------------------------------------------------------------- 1 | # Common build dependencies module 2 | 3 | # cmake-format: off 4 | # cmake-lint: disable=C0103 5 | # cmake-lint: disable=E1126 6 | # cmake-lint: disable=R0912 7 | # cmake-lint: disable=R0915 8 | # cmake-format: on 9 | 10 | include_guard(GLOBAL) 11 | 12 | # _check_deps_version: Checks for obs-deps VERSION file in prefix paths 13 | function(_check_deps_version version) 14 | # cmake-format: off 15 | set(found FALSE PARENT_SCOPE) 16 | # cmake-format: on 17 | 18 | foreach(path IN LISTS CMAKE_PREFIX_PATH) 19 | if(EXISTS "${path}/share/obs-deps/VERSION") 20 | if(dependency STREQUAL qt6 AND NOT EXISTS "${path}/lib/cmake/Qt6/Qt6Config.cmake") 21 | # cmake-format: off 22 | set(found FALSE PARENT_SCOPE) 23 | # cmake-format: on 24 | continue() 25 | endif() 26 | 27 | file(READ "${path}/share/obs-deps/VERSION" _check_version) 28 | string(REPLACE "\n" "" _check_version "${_check_version}") 29 | string(REPLACE "-" "." _check_version "${_check_version}") 30 | string(REPLACE "-" "." version "${version}") 31 | 32 | if(_check_version VERSION_EQUAL version) 33 | # cmake-format: off 34 | set(found TRUE PARENT_SCOPE) 35 | # cmake-format: on 36 | break() 37 | elseif(_check_version VERSION_LESS version) 38 | message(AUTHOR_WARNING "Older ${label} version detected in ${path}: \n" 39 | "Found ${_check_version}, require ${version}") 40 | list(REMOVE_ITEM CMAKE_PREFIX_PATH "${path}") 41 | list(APPEND CMAKE_PREFIX_PATH "${path}") 42 | # cmake-format: off 43 | set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE) 44 | # cmake-format: on 45 | continue() 46 | else() 47 | message(AUTHOR_WARNING "Newer ${label} version detected in ${path}: \n" 48 | "Found ${_check_version}, require ${version}") 49 | # cmake-format: off 50 | set(found TRUE PARENT_SCOPE) 51 | # cmake-format: on 52 | break() 53 | endif() 54 | endif() 55 | endforeach() 56 | endfunction() 57 | 58 | # _setup_obs_studio: Create obs-studio build project, then build libobs and obs-frontend-api 59 | function(_setup_obs_studio) 60 | if(NOT libobs_DIR) 61 | set(_is_fresh --fresh) 62 | endif() 63 | 64 | if(OS_WINDOWS) 65 | set(_cmake_generator "${CMAKE_GENERATOR}") 66 | set(_cmake_arch "-A ${arch}") 67 | set(_cmake_extra "-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION} -DCMAKE_ENABLE_SCRIPTING=OFF") 68 | set(_cmake_version "2.0.0") 69 | elseif(OS_MACOS) 70 | set(_cmake_generator "Xcode") 71 | set(_cmake_arch "-DCMAKE_OSX_ARCHITECTURES:STRING='arm64;x86_64'") 72 | set(_cmake_extra "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}") 73 | set(_cmake_version "3.0.0") 74 | endif() 75 | 76 | message(STATUS "Configure ${label} (${arch})") 77 | execute_process( 78 | COMMAND 79 | "${CMAKE_COMMAND}" -S "${dependencies_dir}/${_obs_destination}" -B 80 | "${dependencies_dir}/${_obs_destination}/build_${arch}" -G ${_cmake_generator} "${_cmake_arch}" 81 | -DOBS_CMAKE_VERSION:STRING=${_cmake_version} -DENABLE_PLUGINS:BOOL=OFF -DENABLE_UI:BOOL=OFF 82 | -DOBS_VERSION_OVERRIDE:STRING=${_obs_version} "-DCMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'" ${_is_fresh} 83 | ${_cmake_extra} 84 | RESULT_VARIABLE _process_result COMMAND_ERROR_IS_FATAL ANY 85 | OUTPUT_QUIET) 86 | message(STATUS "Configure ${label} (${arch}) - done") 87 | 88 | message(STATUS "Build ${label} (${arch})") 89 | execute_process( 90 | COMMAND "${CMAKE_COMMAND}" --build build_${arch} --target obs-frontend-api --config Debug --parallel 91 | WORKING_DIRECTORY "${dependencies_dir}/${_obs_destination}" 92 | RESULT_VARIABLE _process_result COMMAND_ERROR_IS_FATAL ANY 93 | OUTPUT_QUIET) 94 | message(STATUS "Build ${label} (${arch}) - done") 95 | 96 | message(STATUS "Install ${label} (${arch})") 97 | if(OS_WINDOWS) 98 | set(_cmake_extra "--component obs_libraries") 99 | else() 100 | set(_cmake_extra "") 101 | endif() 102 | execute_process( 103 | COMMAND "${CMAKE_COMMAND}" --install build_${arch} --component Development --config Debug --prefix 104 | "${dependencies_dir}" ${_cmake_extra} 105 | WORKING_DIRECTORY "${dependencies_dir}/${_obs_destination}" 106 | RESULT_VARIABLE _process_result COMMAND_ERROR_IS_FATAL ANY 107 | OUTPUT_QUIET) 108 | message(STATUS "Install ${label} (${arch}) - done") 109 | endfunction() 110 | 111 | # _check_dependencies: Fetch and extract pre-built OBS build dependencies 112 | function(_check_dependencies) 113 | if(NOT buildspec) 114 | file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec) 115 | endif() 116 | 117 | # cmake-format: off 118 | string(JSON dependency_data GET ${buildspec} dependencies) 119 | # cmake-format: on 120 | 121 | foreach(dependency IN LISTS dependencies_list) 122 | # cmake-format: off 123 | string(JSON data GET ${dependency_data} ${dependency}) 124 | string(JSON version GET ${data} version) 125 | string(JSON hash GET ${data} hashes ${platform}) 126 | string(JSON url GET ${data} baseUrl) 127 | string(JSON label GET ${data} label) 128 | string(JSON revision ERROR_VARIABLE error GET ${data} revision ${platform}) 129 | # cmake-format: on 130 | 131 | message(STATUS "Setting up ${label} (${arch})") 132 | 133 | set(file "${${dependency}_filename}") 134 | set(destination "${${dependency}_destination}") 135 | string(REPLACE "VERSION" "${version}" file "${file}") 136 | string(REPLACE "VERSION" "${version}" destination "${destination}") 137 | string(REPLACE "ARCH" "${arch}" file "${file}") 138 | string(REPLACE "ARCH" "${arch}" destination "${destination}") 139 | if(revision) 140 | string(REPLACE "_REVISION" "_v${revision}" file "${file}") 141 | string(REPLACE "-REVISION" "-v${revision}" file "${file}") 142 | else() 143 | string(REPLACE "_REVISION" "" file "${file}") 144 | string(REPLACE "-REVISION" "" file "${file}") 145 | endif() 146 | 147 | set(skip FALSE) 148 | if(dependency STREQUAL prebuilt OR dependency STREQUAL qt6) 149 | _check_deps_version(${version}) 150 | 151 | if(found) 152 | set(skip TRUE) 153 | endif() 154 | endif() 155 | 156 | if(skip) 157 | message(STATUS "Setting up ${label} (${arch}) - skipped") 158 | continue() 159 | endif() 160 | 161 | if(dependency STREQUAL obs-studio) 162 | set(url ${url}/${file}) 163 | else() 164 | set(url ${url}/${version}/${file}) 165 | endif() 166 | 167 | if(NOT EXISTS "${dependencies_dir}/${file}") 168 | message(STATUS "Downloading ${url}") 169 | file( 170 | DOWNLOAD "${url}" "${dependencies_dir}/${file}" 171 | STATUS download_status 172 | EXPECTED_HASH SHA256=${hash}) 173 | 174 | list(GET download_status 0 error_code) 175 | list(GET download_status 1 error_message) 176 | if(error_code GREATER 0) 177 | message(STATUS "Downloading ${url} - Failure") 178 | message(FATAL_ERROR "Unable to download ${url}, failed with error: ${error_message}") 179 | file(REMOVE "${dependencies_dir}/${file}") 180 | else() 181 | message(STATUS "Downloading ${url} - done") 182 | endif() 183 | endif() 184 | 185 | if(NOT EXISTS "${dependencies_dir}/${destination}") 186 | file(MAKE_DIRECTORY "${dependencies_dir}/${destination}") 187 | if(dependency STREQUAL obs-studio) 188 | file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}") 189 | else() 190 | file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}/${destination}") 191 | endif() 192 | endif() 193 | 194 | if(dependency STREQUAL prebuilt) 195 | list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}") 196 | elseif(dependency STREQUAL qt6) 197 | list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}") 198 | elseif(dependency STREQUAL obs-studio) 199 | set(_obs_version ${version}) 200 | set(_obs_destination "${destination}") 201 | list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}") 202 | 203 | endif() 204 | 205 | message(STATUS "Setting up ${label} (${arch}) - done") 206 | endforeach() 207 | 208 | list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH) 209 | 210 | # cmake-format: off 211 | set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE PATH "CMake prefix search path" FORCE) 212 | # cmake-format: on 213 | 214 | _setup_obs_studio() 215 | endfunction() 216 | -------------------------------------------------------------------------------- /cmake/macos/xcode.cmake: -------------------------------------------------------------------------------- 1 | # CMake macOS Xcode module 2 | 3 | include_guard(GLOBAL) 4 | 5 | # Use a compiler wrapper to enable ccache in Xcode projects 6 | if(ENABLE_CCACHE AND CCACHE_PROGRAM) 7 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/resources/ccache-launcher-c.in" ccache-launcher-c) 8 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/resources/ccache-launcher-cxx.in" ccache-launcher-cxx) 9 | 10 | execute_process(COMMAND chmod a+rx "${CMAKE_CURRENT_BINARY_DIR}/ccache-launcher-c" 11 | "${CMAKE_CURRENT_BINARY_DIR}/ccache-launcher-cxx") 12 | set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_CURRENT_BINARY_DIR}/ccache-launcher-c") 13 | set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_CURRENT_BINARY_DIR}/ccache-launcher-cxx") 14 | set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_C_COMPILER}") 15 | set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_CXX_COMPILER}") 16 | endif() 17 | 18 | # Set project variables 19 | set(CMAKE_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION ${PLUGIN_BUILD_NUMBER}) 20 | set(CMAKE_XCODE_ATTRIBUTE_DYLIB_COMPATIBILITY_VERSION 1.0.0) 21 | set(CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION ${PLUGIN_VERSION}) 22 | 23 | # Set deployment target 24 | set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET}) 25 | 26 | if(NOT CODESIGN_TEAM) 27 | # Switch to manual codesigning if no codesigning team is provided 28 | set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE Manual) 29 | set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${CODESIGN_IDENTITY}") 30 | else() 31 | if(CODESIGN_IDENTITY AND NOT CODESIGN_IDENTITY STREQUAL "-") 32 | # Switch to manual codesigning if a non-adhoc codesigning identity is provided 33 | set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE Manual) 34 | set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${CODESIGN_IDENTITY}") 35 | else() 36 | # Switch to automatic codesigning via valid team ID 37 | set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE Automatic) 38 | set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Apple Development") 39 | endif() 40 | set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "${CODESIGN_TEAM}") 41 | endif() 42 | 43 | # Only create a single Xcode project file 44 | set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY TRUE) 45 | # Add all libraries to project link phase (lets Xcode handle linking) 46 | set(CMAKE_XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION) 47 | 48 | # Enable codesigning with secure timestamp when not in Debug configuration (required for Notarization) 49 | set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS[variant=Release] "--timestamp") 50 | set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS[variant=RelWithDebInfo] "--timestamp") 51 | set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS[variant=MinSizeRel] "--timestamp") 52 | 53 | # Enable codesigning with hardened runtime option when not in Debug configuration (required for Notarization) 54 | set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME[variant=Release] YES) 55 | set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME[variant=RelWithDebInfo] YES) 56 | set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME[variant=MinSizeRel] YES) 57 | 58 | # Disable injection of Xcode's base entitlements used for debugging when not in Debug configuration (required for 59 | # Notarization) 60 | set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS[variant=Release] NO) 61 | set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS[variant=RelWithDebInfo] NO) 62 | set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS[variant=MinSizeRel] NO) 63 | 64 | # Use Swift version 5.0 by default 65 | set(CMAKE_XCODE_ATTRIBUTE_SWIFT_VERSION 5.0) 66 | 67 | # Use DWARF with separate dSYM files when in Release or MinSizeRel configuration. 68 | # 69 | # * Currently overruled by CMake's Xcode generator, requires adding '-g' flag to raw compiler command line for desired 70 | # output configuration. Report to KitWare. 71 | # 72 | set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Debug] dwarf) 73 | set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=RelWithDebInfo] dwarf) 74 | set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Release] dwarf-with-dsym) 75 | set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=MinSizeRel] dwarf-with-dsym) 76 | 77 | # Make all symbols hidden by default (currently overriden by CMake's compiler flags) 78 | set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES) 79 | set(CMAKE_XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN YES) 80 | 81 | # Strip unused code 82 | set(CMAKE_XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING YES) 83 | 84 | # Display mangled names in Debug configuration 85 | set(CMAKE_XCODE_ATTRIBUTE_LINKER_DISPLAYS_MANGLED_NAMES[variant=Debug] YES) 86 | 87 | # Build active architecture only in Debug configuration 88 | set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] YES) 89 | 90 | # Enable testability in Debug configuration 91 | set(CMAKE_XCODE_ATTRIBUTE_ENABLE_TESTABILITY[variant=Debug] YES) 92 | 93 | # Enable using ARC in ObjC by default 94 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES) 95 | # Enable weak references in manual retain release 96 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_WEAK YES) 97 | # Disable strict aliasing 98 | set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO) 99 | 100 | # Set C++ language default to c17 101 | # 102 | # * CMake explicitly sets the version via compiler flag when transitive dependencies require specific compiler feature 103 | # set, resulting in the flag being added twice. Report to KitWare as a feature request for Xcode generator 104 | # * See also: https://gitlab.kitware.com/cmake/cmake/-/issues/17183 105 | # 106 | # set(CMAKE_XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD c17) 107 | # 108 | # Set C++ language default to c++17 109 | # 110 | # * See above. Report to KitWare as a feature request for Xcode generator 111 | # 112 | # set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD c++17) 113 | 114 | # Enable support for module imports in ObjC 115 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES YES) 116 | # Enable automatic linking of imported modules in ObjC 117 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_MODULES_AUTOLINK YES) 118 | # Enable strict msg_send rules for ObjC 119 | set(CMAKE_XCODE_ATTRIBUTE_ENABLE_STRICT_OBJC_MSGSEND YES) 120 | 121 | # Set default warnings for ObjC and C++ 122 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING YES_ERROR) 123 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION YES) 124 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS YES) 125 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_COMMA YES) 126 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION YES) 127 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY YES) 128 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION YES) 129 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INFINITE_RECURSION YES) 130 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION YES) 131 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_NON_LITERAL_NULL_CONVERSION YES) 132 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF YES) 133 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_OBJC_LITERAL_CONVERSION YES) 134 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK YES) 135 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER YES) 136 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_RANGE_LOOP_ANALYSIS YES) 137 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_STRICT_PROTOTYPES NO) 138 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION NO) 139 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_SUSPICIOUS_MOVE YES) 140 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_UNREACHABLE_CODE YES) 141 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN__DUPLICATE_METHOD_MATCH YES) 142 | 143 | # Set default warnings for C and C++ 144 | set(CMAKE_XCODE_ATTRIBUTE_GCC_NO_COMMON_BLOCKS YES) 145 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION YES) 146 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS NO) 147 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE YES) 148 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE YES_ERROR) 149 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_CHECK_SWITCH_STATEMENTS YES) 150 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_FOUR_CHARACTER_CONSTANTS YES) 151 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SHADOW NO) 152 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE YES) 153 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_TYPECHECK_CALLS_TO_PRINTF YES) 154 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNDECLARED_SELECTOR YES) 155 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS YES) 156 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION NO) 157 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_PARAMETER YES) 158 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VALUE YES) 159 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE YES) 160 | 161 | # Add additional warning compiler flags 162 | set(CMAKE_XCODE_ATTRIBUTE_WARNING_CFLAGS "-Wvla -Wformat-security") 163 | 164 | if(CMAKE_COMPILE_WARNING_AS_ERROR) 165 | set(CMAKE_XCODE_ATTRIBUTE_GCC_TREAT_WARNINGS_AS_ERRORS YES) 166 | endif() 167 | 168 | # Enable color diagnostics 169 | set(CMAKE_COLOR_DIAGNOSTICS TRUE) 170 | 171 | # Disable usage of RPATH in build or install configurations 172 | set(CMAKE_SKIP_RPATH TRUE) 173 | # Have Xcode set default RPATH entries 174 | set(CMAKE_XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks") 175 | -------------------------------------------------------------------------------- /.github/scripts/.package.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | builtin emulate -L zsh 4 | setopt EXTENDED_GLOB 5 | setopt PUSHD_SILENT 6 | setopt ERR_EXIT 7 | setopt ERR_RETURN 8 | setopt NO_UNSET 9 | setopt PIPE_FAIL 10 | setopt NO_AUTO_PUSHD 11 | setopt NO_PUSHD_IGNORE_DUPS 12 | setopt FUNCTION_ARGZERO 13 | 14 | ## Enable for script debugging 15 | # setopt WARN_CREATE_GLOBAL 16 | # setopt WARN_NESTED_VAR 17 | # setopt XTRACE 18 | 19 | autoload -Uz is-at-least && if ! is-at-least 5.2; then 20 | print -u2 -PR "${CI:+::error::}%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue." 21 | exit 1 22 | fi 23 | 24 | TRAPEXIT() { 25 | local return_value=$? 26 | 27 | if (( ${+CI} )) { 28 | unset NSUnbufferedIO 29 | } 30 | 31 | return ${return_value} 32 | } 33 | 34 | TRAPZERR() { 35 | if (( ${_loglevel:-3} > 2 )) { 36 | print -u2 -PR "${CI:+::error::}%F{1} ✖︎ script execution error%f" 37 | print -PR -e " 38 | Callstack: 39 | ${(j:\n :)funcfiletrace} 40 | " 41 | } 42 | 43 | exit 2 44 | } 45 | 46 | package() { 47 | if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h} 48 | local host_os=${${(s:-:)ZSH_ARGZERO:t:r}[2]} 49 | local project_root=${SCRIPT_HOME:A:h:h} 50 | local buildspec_file=${project_root}/buildspec.json 51 | 52 | fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath}) 53 | autoload -Uz set_loglevel log_info log_group log_error log_output check_${host_os} 54 | 55 | if [[ ! -r ${buildspec_file} ]] { 56 | log_error \ 57 | 'No buildspec.json found. Please create a build specification for your project.' 58 | return 2 59 | } 60 | 61 | local -i verbosity=1 62 | local -r _version='2.0.0' 63 | local -r -a _valid_targets=( 64 | macos-universal 65 | linux-x86_64 66 | ) 67 | local target 68 | local config='RelWithDebInfo' 69 | local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel) 70 | local -i codesign=0 71 | local -i notarize=0 72 | local -i package=0 73 | local -i skip_deps=0 74 | 75 | if [[ ${host_os} == macos ]] { 76 | local -r _usage_host=" 77 | %F{yellow} Additional options for macOS builds%f 78 | ----------------------------------------------------------------------------- 79 | %B-s | --codesign%b Enable codesigning (macOS only) 80 | %B-n | --notarize%b Enable notarization (macOS only) 81 | %B-p | --package%b Create package installer (macOS only)" 82 | } 83 | 84 | local -r _usage=" 85 | Usage: %B${functrace[1]%:*}%b