Skip to content

Commit

Permalink
Add procedure handler based API
Browse files Browse the repository at this point in the history
  • Loading branch information
tytan652 committed Jan 27, 2024
1 parent 1e68bac commit 18009b4
Show file tree
Hide file tree
Showing 10 changed files with 988 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ legacy_check()

option(ENABLE_BROWSER "Enable browser source plugin (required Chromium Embedded Framework)" OFF)

include(cmake/obs-browser-api.cmake)

if(NOT ENABLE_BROWSER)
target_disable(obs-browser)
target_disable_feature(obs-browser "Browser sources are not enabled by default (set CEF_ROOT_DIR and ENABLE_BROWSER)")
Expand Down Expand Up @@ -38,6 +40,8 @@ target_sources(
deps/signal-restore.hpp
deps/wide-string.cpp
deps/wide-string.hpp
obs-browser-api-impl.cpp
obs-browser-api-impl.hpp
obs-browser-plugin.cpp
obs-browser-source-audio.cpp
obs-browser-source.cpp
Expand All @@ -46,7 +50,7 @@ target_sources(
target_include_directories(obs-browser PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/deps")

target_compile_features(obs-browser PRIVATE cxx_std_17)
target_link_libraries(obs-browser PRIVATE OBS::libobs OBS::frontend-api nlohmann_json::nlohmann_json)
target_link_libraries(obs-browser PRIVATE OBS::libobs OBS::frontend-api OBS::browser-api nlohmann_json::nlohmann_json)

if(OS_WINDOWS)
include(cmake/os-windows.cmake)
Expand Down
4 changes: 2 additions & 2 deletions cmake/feature-panels.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ target_compile_definitions(browser-panels INTERFACE BROWSER_AVAILABLE)
target_sources(
obs-browser
PRIVATE # cmake-format: sortable
panel/browser-panel-client.cpp panel/browser-panel-client.hpp panel/browser-panel-internal.hpp
panel/browser-panel.cpp)
obs-browser-api-impl-panel.cpp panel/browser-panel-client.cpp panel/browser-panel-client.hpp
panel/browser-panel-internal.hpp panel/browser-panel.cpp)

target_link_libraries(obs-browser PRIVATE OBS::browser-panels Qt::Widgets)

Expand Down
25 changes: 22 additions & 3 deletions cmake/legacy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ project(obs-browser)
option(ENABLE_BROWSER "Enable building OBS with browser source plugin (required Chromium Embedded Framework)"
${OS_LINUX})

find_package(Qt6 REQUIRED Widgets)

add_library(obs-browser-api INTERFACE)
add_library(OBS::browser-api ALIAS obs-browser-api)

target_sources(obs-browser-api PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/obs-browser-api.hpp>
$<INSTALL_INTERFACE:${OBS_INCLUDE_DESTINATION}/obs-browser-api.hpp>)

target_link_libraries(obs-browser-api INTERFACE OBS::libobs Qt::Widgets)

target_include_directories(obs-browser-api INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib>
$<INSTALL_INTERFACE:${OBS_INCLUDE_DESTINATION}>)

set_target_properties(obs-browser-api PROPERTIES PUBLIC_HEADER lib/obs-browser-api.hpp)

export_target(obs-browser-api)

if(NOT ENABLE_BROWSER OR NOT ENABLE_UI)
message(STATUS "OBS: DISABLED obs-browser")
message(
Expand Down Expand Up @@ -54,6 +71,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/browser-config.h.in ${CMAKE_BINARY_DI
target_sources(
obs-browser
PRIVATE obs-browser-plugin.cpp
obs-browser-api-impl.cpp
obs-browser-api-impl.hpp
obs-browser-source.cpp
obs-browser-source.hpp
obs-browser-source-audio.cpp
Expand All @@ -76,13 +95,11 @@ target_sources(

target_include_directories(obs-browser PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deps ${CMAKE_BINARY_DIR}/config)

target_link_libraries(obs-browser PRIVATE OBS::libobs OBS::frontend-api nlohmann_json::nlohmann_json)
target_link_libraries(obs-browser PRIVATE OBS::libobs OBS::frontend-api OBS::browser-api nlohmann_json::nlohmann_json)

target_compile_features(obs-browser PRIVATE cxx_std_17)

if(ENABLE_BROWSER_PANELS OR ENABLE_BROWSER_QT_LOOP)
find_qt(COMPONENTS Widgets)

set_target_properties(
obs-browser
PROPERTIES AUTOMOC ON
Expand Down Expand Up @@ -251,6 +268,8 @@ if(ENABLE_BROWSER_PANELS)

target_compile_definitions(obs-browser-panels INTERFACE BROWSER_AVAILABLE)

target_sources(obs-browser PRIVATE obs-browser-api-impl-panel.cpp obs-browser-api-impl.cpp)

if(ENABLE_BROWSER_QT_LOOP)
target_compile_definitions(obs-browser-panels INTERFACE ENABLE_BROWSER_QT_LOOP)
endif()
Expand Down
16 changes: 16 additions & 0 deletions cmake/obs-browser-api.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
find_package(Qt6 REQUIRED Widgets)

add_library(obs-browser-api INTERFACE)
add_library(OBS::browser-api ALIAS obs-browser-api)

target_sources(obs-browser-api PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/obs-browser-api.hpp>
$<INSTALL_INTERFACE:${OBS_INCLUDE_DESTINATION}/obs-browser-api.hpp>)

target_link_libraries(obs-browser-api INTERFACE OBS::libobs Qt::Widgets)

target_include_directories(obs-browser-api INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/lib"
"$<INSTALL_INTERFACE:${OBS_INCLUDE_DESTINATION}>")

set_target_properties(obs-browser-api PROPERTIES PREFIX "" PUBLIC_HEADER lib/obs-browser-api.hpp)

target_export(obs-browser-api)
9 changes: 9 additions & 0 deletions cmake/obs-browser-apiConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

find_dependency(libobs REQUIRED)
find_package(Qt6 REQUIRED Widgets)

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components("@PROJECT_NAME@")
Loading

0 comments on commit 18009b4

Please sign in to comment.