diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a991b0b6..aca109f88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,17 @@ if(NOT CEF_FOUND) return() endif() -option(EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED "Enable shared texture support for the browser plugin (Win32)" ON) -option(BROWSER_PANEL_SUPPORT_ENABLED "Enables Qt web browser panel support" ON) +option(EXPERIMENTAL_SHARED_TEXTURE_SUPPORT "Enable shared texture support for the browser plugin (Win32)" ON) +option(BROWSER_PANEL_SUPPORT "Enables Qt web browser panel support" ON) +option(BROWSER_FRONTEND_API_SUPPORT "Enables integration with obs-frontend-api library" ON) + +if (EXPERIMENTAL_SHARED_TEXTURE_SUPPORT) + set(EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED) +endif() + +if (BROWSER_FRONTEND_API_SUPPORT) + set(BROWSER_FRONTEND_API_SUPPORT_ENABLED) +endif() configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/browser-config.h.in" @@ -84,7 +93,7 @@ set(obs-browser_HEADERS # only allow browser panels on win32 for now -- other operating systems # need more testing -if(WIN32 AND BROWSER_PANEL_SUPPORT_ENABLED) +if(WIN32 AND BROWSER_PANEL_SUPPORT AND BROWSER_FRONTEND_API_SUPPORT) if(DEFINED QTDIR${_lib_suffix}) list(APPEND CMAKE_PREFIX_PATH "${QTDIR${_lib_suffix}}") elseif(DEFINED QTDIR) diff --git a/browser-client.cpp b/browser-client.cpp index 5d6691e33..5577e2874 100644 --- a/browser-client.cpp +++ b/browser-client.cpp @@ -20,7 +20,10 @@ #include "obs-browser-source.hpp" #include "base64/base64.hpp" #include "json11/json11.hpp" + +#if BROWSER_FRONTEND_API_SUPPORT_ENABLED #include +#endif using namespace json11; @@ -106,14 +109,18 @@ bool BrowserClient::OnProcessMessageReceived( {"height", (int)obs_source_get_height(bs->source)} }; - } else if (name == "getStatus") { + } +#if BROWSER_FRONTEND_API_SUPPORT_ENABLED + else if (name == "getStatus") { json = Json::object { {"recording", obs_frontend_recording_active()}, {"streaming", obs_frontend_streaming_active()}, {"replaybuffer", obs_frontend_replay_buffer_active()} }; - } else { + } +#endif + else { return false; } diff --git a/browser-config.h.in b/browser-config.h.in index ef4e7ed59..5970763a3 100644 --- a/browser-config.h.in +++ b/browser-config.h.in @@ -1,24 +1,7 @@ #pragma once -#ifndef ON -#define ON true -#endif - -#ifndef OFF -#define OFF false -#endif - -#ifndef TRUE -#define TRUE true -#endif - -#ifndef FALSE -#define FALSE false -#endif - #ifdef _WIN32 -#define EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED \ - @EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED@ -#else -#define EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED false +#cmakedefine01 EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED #endif + +#cmakedefine01 BROWSER_FRONTEND_API_SUPPORT_ENABLED \ No newline at end of file diff --git a/obs-browser-plugin.cpp b/obs-browser-plugin.cpp index 7cefea434..5cd5c0dcf 100644 --- a/obs-browser-plugin.cpp +++ b/obs-browser-plugin.cpp @@ -16,7 +16,6 @@ along with this program. If not, see . ******************************************************************************/ -#include #include #include #include @@ -40,6 +39,10 @@ #include #endif +#if BROWSER_FRONTEND_API_SUPPORT_ENABLED +#include +#endif + OBS_DECLARE_MODULE() OBS_MODULE_USE_DEFAULT_LOCALE("obs-browser", "en-US") @@ -315,6 +318,7 @@ void RegisterBrowserSource() extern void DispatchJSEvent(const char *eventName, const char *jsonString); +#if BROWSER_FRONTEND_API_SUPPORT_ENABLED static void handle_obs_frontend_event(enum obs_frontend_event event, void *) { switch (event) { @@ -363,6 +367,7 @@ static void handle_obs_frontend_event(enum obs_frontend_event event, void *) default:; } } +#endif #ifdef _WIN32 static inline void EnumAdapterCount() @@ -401,7 +406,11 @@ bool obs_module_load(void) EnumAdapterCount(); #endif RegisterBrowserSource(); + +#if BROWSER_FRONTEND_API_SUPPORT_ENABLED obs_frontend_add_event_callback(handle_obs_frontend_event, nullptr); +#endif + #if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED obs_data_t *private_data = obs_get_private_data();