mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
a8d27ede9e
A new `executionType` field has been added to the `RequestBatch` Op Types added: - `OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_SERIAL_REALTIME`(default) - `OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_SERIAL_FRAME` - `OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_PARALLEL` `OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_SERIAL_REALTIME`: - Same as how request batches have always worked. - Requests are processed in-order - Requests are processed as soon as possible by one worker thread - The `Sleep` request blocks execution for a specified amount of real world time `OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_SERIAL_FRAME`: - New! - Requests are processed in-order - Requests are processed on the graphics thread. BE VERY CAREFUL NOT TO OVERLOAD THE GRAPHICS THREAD WITH LARGE REQUESTS. A general rule of thumb is for your request batches to take a maximum of 2ms per frame of processing. - Requests processing starts right before the next frame is composited. This functionality is perfect for things like `SetSceneItemTransform` - The `Sleep` request will halt processing of the request batch for a specified number of frames (ticks) - To be clear: If you do not have any sleep requests, all requests in the batch will be processed in the span of a single frame - For developers: The execution of requests gets profiled by the OBS profiler under the `obs-websocket-request-batch-frame-tick` name. This value (shown in the OBS log after OBS shutdown) represents the amount of time that the graphics thread spent actively processing requests per frame. This tool can be used to determine the amount of load that your request batches are placing on the graphics thread. `OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_PARALLEL`: - New! - Requests are processed asynchronously at the soonest possible time. - Requests are processed by the core obs-websocket thread pool, where the number of workers == the number of threads on your machine. - If you have 12 threads on your machine, obs-websocket will be able to process 12 requests at any given moment. - The `results` array is populated by order of request completion. Consider the order to be random. - The `Sleep` request will return an error if attempted to be used in this mode. - Note: This feature is experimental and can increase the chances of causing race conditions (crashes). While the implementation is fully thread-safe, OBS itself is not. Usage of this is only recommended if you are processing very large batches and need the performance benefit. - Example use case: Performing `SaveSourceScreenshot` on 8 sources at once.
305 lines
8.9 KiB
CMake
305 lines
8.9 KiB
CMake
cmake_minimum_required(VERSION 3.16...3.20)
|
|
|
|
# Version variables
|
|
project(obs-websocket VERSION 5.0.0)
|
|
set(OBS_WEBSOCKET_RPC_VERSION 1)
|
|
|
|
|
|
# Set correct version string
|
|
if(DEFINED OBS_WEBSOCKET_VERSION_SUFFIX AND NOT OBS_WEBSOCKET_VERSION_SUFFIX STREQUAL "")
|
|
set(OBS_WEBSOCKET_VERSION "${CMAKE_PROJECT_VERSION}${OBS_WEBSOCKET_VERSION_SUFFIX}")
|
|
message(WARNING "-----------------------------------\nVersion Suffix provided. OBS_WEBSOCKET_VERSION is now ${OBS_WEBSOCKET_VERSION}\n-----------------------------------")
|
|
else()
|
|
set(OBS_WEBSOCKET_VERSION "${CMAKE_PROJECT_VERSION}")
|
|
endif()
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
# Prohibit in-source builds
|
|
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" _LOC_PATH)
|
|
if(EXISTS "${LOC_PATH}")
|
|
message(FATAL_ERROR "obs-websocket: You cannot build in a source directory (or any directory with "
|
|
"CMakeLists.txt file). Please make a build subdirectory. Feel free to "
|
|
"remove CMakeCache.txt and CMakeFiles.")
|
|
endif()
|
|
unset(_LOC_PATH)
|
|
|
|
|
|
# Allow selection of common build types via UI
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
|
"OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
|
|
endif()
|
|
|
|
|
|
# Qt build stuff
|
|
set(CMAKE_PREFIX_PATH "${QTDIR}")
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
set(CMAKE_AUTOMOC ON)
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
set(CMAKE_AUTORCC ON) # For resources.qrc
|
|
|
|
# Tell websocketpp not to use system boost
|
|
add_definitions(-DASIO_STANDALONE)
|
|
|
|
|
|
# Arm build fixes
|
|
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
|
set(CMAKE_CXX_FLAGS "-mfpu=neon")
|
|
endif()
|
|
|
|
|
|
# Find libobs
|
|
if (WIN32 OR APPLE)
|
|
include(cmake/FindLibObs.cmake)
|
|
endif()
|
|
find_package(LibObs REQUIRED)
|
|
|
|
|
|
# Find Qt5
|
|
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Svg Network)
|
|
|
|
|
|
# Find nlohmann
|
|
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
|
add_subdirectory(deps/json)
|
|
|
|
|
|
# Configure files
|
|
configure_file(
|
|
src/plugin-macros.h.in
|
|
../src/plugin-macros.generated.h
|
|
)
|
|
configure_file(
|
|
installer/installer-windows.iss.in
|
|
../installer/installer-windows.generated.iss
|
|
)
|
|
|
|
|
|
# Inlude sources
|
|
set(obs-websocket_SOURCES
|
|
src/obs-websocket.cpp
|
|
src/Config.cpp
|
|
src/WebSocketServer.cpp
|
|
src/WebSocketServer_Protocol.cpp
|
|
src/WebSocketServer_RequestBatchProcessing.cpp
|
|
src/WebSocketSession.cpp
|
|
src/eventhandler/EventHandler.cpp
|
|
src/eventhandler/EventHandler_General.cpp
|
|
src/eventhandler/EventHandler_Config.cpp
|
|
src/eventhandler/EventHandler_Scenes.cpp
|
|
src/eventhandler/EventHandler_Inputs.cpp
|
|
src/eventhandler/EventHandler_Transitions.cpp
|
|
src/eventhandler/EventHandler_Filters.cpp
|
|
src/eventhandler/EventHandler_Outputs.cpp
|
|
src/eventhandler/EventHandler_SceneItems.cpp
|
|
src/eventhandler/EventHandler_MediaInputs.cpp
|
|
src/requesthandler/RequestHandler.cpp
|
|
src/requesthandler/RequestHandler_General.cpp
|
|
src/requesthandler/RequestHandler_Config.cpp
|
|
src/requesthandler/RequestHandler_Sources.cpp
|
|
src/requesthandler/RequestHandler_Scenes.cpp
|
|
src/requesthandler/RequestHandler_Inputs.cpp
|
|
src/requesthandler/RequestHandler_SceneItems.cpp
|
|
src/requesthandler/RequestHandler_Stream.cpp
|
|
src/requesthandler/rpc/Request.cpp
|
|
src/requesthandler/rpc/RequestResult.cpp
|
|
src/forms/SettingsDialog.cpp
|
|
src/forms/ConnectInfo.cpp
|
|
src/forms/resources.qrc
|
|
src/utils/Crypto.cpp
|
|
src/utils/Json.cpp
|
|
src/utils/Obs.cpp
|
|
src/utils/Platform.cpp
|
|
src/utils/Compat.cpp
|
|
deps/qr/cpp/QrCode.cpp)
|
|
|
|
set(obs-websocket_HEADERS
|
|
src/obs-websocket.h
|
|
src/Config.h
|
|
src/WebSocketServer.h
|
|
src/WebSocketSession.h
|
|
src/eventhandler/EventHandler.h
|
|
src/eventhandler/types/EventSubscription.h
|
|
src/requesthandler/RequestHandler.h
|
|
src/requesthandler/rpc/Request.h
|
|
src/requesthandler/rpc/RequestResult.h
|
|
src/requesthandler/rpc/RequestStatus.h
|
|
src/forms/SettingsDialog.h
|
|
src/forms/ConnectInfo.h
|
|
src/utils/Crypto.h
|
|
src/utils/Json.h
|
|
src/utils/Obs.h
|
|
src/utils/Platform.h
|
|
src/utils/Compat.h
|
|
src/utils/Utils.h
|
|
deps/qr/cpp/QrCode.hpp)
|
|
|
|
|
|
# Platform-independent build settings
|
|
add_library(obs-websocket MODULE
|
|
${obs-websocket_SOURCES}
|
|
${obs-websocket_HEADERS})
|
|
|
|
include_directories(
|
|
"${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api"
|
|
${Qt5Core_INCLUDES}
|
|
${Qt5Widgets_INCLUDES}
|
|
${Qt5Svg_INCLUDES}
|
|
${Qt5Network_INCLUDES}
|
|
"${CMAKE_SOURCE_DIR}/deps/asio/asio/include"
|
|
"${CMAKE_SOURCE_DIR}/deps/websocketpp")
|
|
|
|
target_link_libraries(obs-websocket
|
|
libobs
|
|
Qt5::Core
|
|
Qt5::Widgets
|
|
Qt5::Svg
|
|
Qt5::Network
|
|
nlohmann_json::nlohmann_json)
|
|
|
|
|
|
# Windows-specific build settings and tasks
|
|
if(WIN32)
|
|
if(NOT DEFINED OBS_FRONTEND_LIB)
|
|
set(OBS_FRONTEND_LIB "OBS_FRONTEND_LIB-NOTFOUND" CACHE FILEPATH "OBS frontend library")
|
|
message(FATAL_ERROR "Could not find OBS Frontend API's library!")
|
|
endif()
|
|
|
|
if(MSVC)
|
|
# Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL)
|
|
add_definitions(/MP /d2FH4-)
|
|
endif()
|
|
|
|
add_definitions(-D_WEBSOCKETPP_CPP11_STL_)
|
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
set(ARCH_NAME "64bit")
|
|
set(OBS_BUILDDIR_ARCH "build64")
|
|
else()
|
|
set(ARCH_NAME "32bit")
|
|
set(OBS_BUILDDIR_ARCH "build32")
|
|
endif()
|
|
|
|
include_directories(
|
|
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/UI"
|
|
)
|
|
|
|
target_link_libraries(obs-websocket
|
|
"${OBS_FRONTEND_LIB}")
|
|
|
|
# Release package helper
|
|
# The "release" folder has a structure similar OBS' one on Windows
|
|
set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release")
|
|
|
|
add_custom_command(TARGET obs-websocket POST_BUILD
|
|
# If config is Release or RelWithDebInfo, package release files
|
|
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
|
"${CMAKE_COMMAND}" -E make_directory
|
|
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
|
|
)
|
|
|
|
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
|
"${CMAKE_COMMAND}" -E copy_directory
|
|
"${PROJECT_SOURCE_DIR}/data"
|
|
"${RELEASE_DIR}/data/obs-plugins/obs-websocket"
|
|
)
|
|
|
|
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
|
"${CMAKE_COMMAND}" -E copy
|
|
"$<TARGET_FILE:obs-websocket>"
|
|
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
|
|
)
|
|
|
|
# In Release or RelWithDebInfo mode, copy Qt image format plugins
|
|
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
|
"${CMAKE_COMMAND}" -E make_directory
|
|
"${RELEASE_DIR}/bin/${ARCH_NAME}/imageformats"
|
|
)
|
|
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
|
"${CMAKE_COMMAND}" -E copy
|
|
"${QTDIR}/plugins/imageformats/qicns.dll"
|
|
"${QTDIR}/plugins/imageformats/qico.dll"
|
|
"${QTDIR}/plugins/imageformats/qjpeg.dll"
|
|
"${QTDIR}/plugins/imageformats/qtiff.dll"
|
|
"${QTDIR}/plugins/imageformats/qwbmp.dll"
|
|
"${QTDIR}/plugins/imageformats/qwebp.dll"
|
|
"${RELEASE_DIR}/bin/${ARCH_NAME}/imageformats"
|
|
)
|
|
|
|
# If config is RelWithDebInfo, package PDB file for target
|
|
COMMAND if $<CONFIG:RelWithDebInfo>==1 (
|
|
"${CMAKE_COMMAND}" -E copy
|
|
"$<TARGET_PDB_FILE:obs-websocket>"
|
|
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
|
|
)
|
|
|
|
# In the Debug configuration, copy to obs-studio dev environment for immediate testing
|
|
COMMAND if $<CONFIG:Debug>==1 (
|
|
"${CMAKE_COMMAND}" -E copy
|
|
"$<TARGET_FILE:obs-websocket>"
|
|
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/obs-plugins/${ARCH_NAME}"
|
|
)
|
|
|
|
COMMAND if $<CONFIG:Debug>==1 (
|
|
"${CMAKE_COMMAND}" -E copy
|
|
"$<TARGET_PDB_FILE:obs-websocket>"
|
|
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/obs-plugins/${ARCH_NAME}"
|
|
)
|
|
|
|
COMMAND if $<CONFIG:Debug>==1 (
|
|
"${CMAKE_COMMAND}" -E make_directory
|
|
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-websocket"
|
|
)
|
|
|
|
COMMAND if $<CONFIG:Debug>==1 (
|
|
"${CMAKE_COMMAND}" -E copy_directory
|
|
"${PROJECT_SOURCE_DIR}/data"
|
|
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-websocket"
|
|
)
|
|
)
|
|
endif()
|
|
|
|
|
|
# Linux-specific build settings and tasks
|
|
if(UNIX AND NOT APPLE)
|
|
include(GNUInstallDirs)
|
|
|
|
set_target_properties(obs-websocket PROPERTIES PREFIX "")
|
|
target_link_libraries(obs-websocket obs-frontend-api)
|
|
|
|
# Manually set permissions for locales
|
|
file(GLOB locale_files data/locale/*.ini)
|
|
set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
|
|
OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
|
|
|
# Manually set file permissions for binary
|
|
install(TARGETS obs-websocket LIBRARY
|
|
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/obs-plugins"
|
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
|
|
|
|
# OBS on Ubuntu installs into a different directory than most linux distros
|
|
if(${USE_UBUNTU_FIX})
|
|
install(TARGETS obs-websocket LIBRARY
|
|
DESTINATION "/usr/lib/obs-plugins"
|
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
|
|
endif()
|
|
|
|
install(FILES ${locale_files}
|
|
DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/obs/obs-plugins/obs-websocket/locale")
|
|
endif()
|
|
|
|
# MacOS-specific build settings and tasks
|
|
if(APPLE)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fvisibility=default")
|
|
|
|
set(CMAKE_SKIP_RPATH TRUE)
|
|
set_target_properties(obs-websocket PROPERTIES PREFIX "")
|
|
target_link_libraries(obs-websocket "${OBS_FRONTEND_LIB}")
|
|
endif()
|