From 36afa76e579a3afaaf6826a76f33baff049a54ed Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 25 Feb 2018 15:49:37 +0100 Subject: [PATCH] Make compiling with CEF optional. --- Makefile | 19 +++++++++++++------ main.cpp | 6 ++++++ mixer.cpp | 6 ++++++ theme.cpp | 16 ++++++++++++++++ theme.h | 6 ++++++ 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index af5937c..0621182 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,15 @@ PKG_MODULES := Qt5Core Qt5Gui Qt5Widgets Qt5OpenGLExtensions Qt5OpenGL Qt5PrintS CXXFLAGS ?= -O2 -g -Wall # Will be overridden by environment. CXXFLAGS += -std=gnu++11 -fPIC $(shell pkg-config --cflags $(PKG_MODULES)) -pthread -DMOVIT_SHADER_DIR=\"$(shell pkg-config --variable=shaderdir movit)\" -Idecklink/ -CEF_DIR=/home/sesse/nmu/cef_binary_3.3282.1734.g8f26fe0_linux64 +# Override CEF_DIR on the command line to build with CEF. +# E.g.: make CEF_DIR=/home/sesse/cef_binary_3.3282.1734.g8f26fe0_linux64 +CEF_DIR= CEF_BUILD_TYPE=Release -CEF_LIBS=$(CEF_DIR)/$(CEF_BUILD_TYPE)/libcef.so $(CEF_DIR)/libcef_dll_wrapper/libcef_dll_wrapper.a -CPPFLAGS += -DHAVE_CEF=1 -I$(CEF_DIR) -I$(CEF_DIR)/include -LDFLAGS += -L$(CEF_DIR)/$(CEF_BUILD_TYPE) -Wl,-rpath $(CEF_DIR)/$(CEF_BUILD_TYPE) +ifneq ($(CEF_DIR),) + CEF_LIBS=$(CEF_DIR)/$(CEF_BUILD_TYPE)/libcef.so $(CEF_DIR)/libcef_dll_wrapper/libcef_dll_wrapper.a + CPPFLAGS += -DHAVE_CEF=1 -I$(CEF_DIR) -I$(CEF_DIR)/include + LDFLAGS += -L$(CEF_DIR)/$(CEF_BUILD_TYPE) -Wl,-rpath $(CEF_DIR)/$(CEF_BUILD_TYPE) +endif ifeq ($(EMBEDDED_BMUSB),yes) CPPFLAGS += -Ibmusb/ @@ -47,8 +51,10 @@ endif # FFmpeg input OBJS += ffmpeg_capture.o -# CEF input -OBJS += nageru_cef_app.o cef_capture.o +ifneq ($(CEF_DIR),) + # CEF input + OBJS += nageru_cef_app.o cef_capture.o +endif # Benchmark program. BM_OBJS = benchmark_audio_mixer.o $(AUDIO_MIXER_OBJS) flags.o metrics.o @@ -88,6 +94,7 @@ midi_mapper.o: midi_mapping.pb.h midi_mapping_dialog.o: ui_midi_mapping.h midi_mapping.pb.h mixer.o: json.pb.h +# CEF wrapper library; typically not built as part of the binary distribution. $(CEF_DIR)/libcef_dll_wrapper/libcef_dll_wrapper.a: $(CEF_DIR)/Makefile cd $(CEF_DIR) && $(MAKE) libcef_dll_wrapper diff --git a/main.cpp b/main.cpp index 65eade9..4287b7e 100644 --- a/main.cpp +++ b/main.cpp @@ -13,20 +13,26 @@ extern "C" { #include #include +#ifdef HAVE_CEF #include #include #include #include +#endif #include "basic_stats.h" +#ifdef HAVE_CEF #include "nageru_cef_app.h" +#endif #include "context.h" #include "flags.h" #include "image_input.h" #include "mainwindow.h" #include "mixer.h" +#ifdef HAVE_CEF CefRefPtr cef_app; +#endif int main(int argc, char *argv[]) { diff --git a/mixer.cpp b/mixer.cpp index 557452d..e1d9ca9 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -33,7 +33,9 @@ #include "basic_stats.h" #include "bmusb/bmusb.h" #include "bmusb/fake_capture.h" +#ifdef HAVE_CEF #include "cef_capture.h" +#endif #include "chroma_subsampler.h" #include "context.h" #include "decklink_capture.h" @@ -428,6 +430,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) } num_video_inputs = video_inputs.size(); +#ifdef HAVE_CEF // Same, for HTML inputs. std::vector html_inputs = theme->get_html_inputs(); for (unsigned html_card_index = 0; html_card_index < html_inputs.size(); ++card_index, ++html_card_index) { @@ -439,6 +442,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) html_inputs[html_card_index]->set_card_index(card_index); } num_html_inputs = html_inputs.size(); +#endif BMUSBCapture::set_card_connected_callback(bind(&Mixer::bm_hotplug_add, this, _1)); BMUSBCapture::start_bm_thread(); @@ -1332,9 +1336,11 @@ void Mixer::render_one_frame(int64_t duration) for (const pair &conn : theme->get_video_signal_connections()) { conn.first->connect_signal_raw(conn.second->get_card_index(), input_state); } +#ifdef HAVE_CEF for (const pair &conn : theme->get_html_signal_connections()) { conn.first->connect_signal_raw(conn.second->get_card_index(), input_state); } +#endif // If HDMI/SDI output is active and the user has requested auto mode, // its mode overrides the existing Y'CbCr setting for the chain. diff --git a/theme.cpp b/theme.cpp index 091495f..485fa43 100644 --- a/theme.cpp +++ b/theme.cpp @@ -28,7 +28,9 @@ #include #include "defs.h" +#ifdef HAVE_CEF #include "cef_capture.h" +#endif #include "ffmpeg_capture.h" #include "flags.h" #include "image_input.h" @@ -233,6 +235,7 @@ int EffectChain_add_video_input(lua_State* L) return ret; } +#ifdef HAVE_CEF int EffectChain_add_html_input(lua_State* L) { assert(lua_gettop(L) == 2); @@ -254,6 +257,7 @@ int EffectChain_add_html_input(lua_State* L) } return ret; } +#endif int EffectChain_add_effect(lua_State* L) { @@ -411,6 +415,7 @@ int VideoInput_get_signal_num(lua_State* L) int HTMLInput_new(lua_State* L) { +#ifdef HAVE_CEF assert(lua_gettop(L) == 1); string url = checkstdstring(L, 1); int ret = wrap_lua_object_nonowned(L, "HTMLInput", url, global_flags.width, global_flags.height); @@ -420,8 +425,14 @@ int HTMLInput_new(lua_State* L) theme->register_html_input(*capture); } return ret; +#else + fprintf(stderr, "This version of Nageru has been compiled without CEF support.\n"); + fprintf(stderr, "HTMLInput is not available.\n"); + exit(1); +#endif } +#ifdef HAVE_CEF int HTMLInput_set_url(lua_State* L) { assert(lua_gettop(L) == 2); @@ -464,6 +475,7 @@ int HTMLInput_get_signal_num(lua_State* L) lua_pushnumber(L, -1 - (*video_input)->get_card_index()); return 1; } +#endif int WhiteBalanceEffect_new(lua_State* L) { @@ -645,7 +657,9 @@ const luaL_Reg EffectChain_funcs[] = { { "__gc", EffectChain_gc }, { "add_live_input", EffectChain_add_live_input }, { "add_video_input", EffectChain_add_video_input }, +#ifdef HAVE_CEF { "add_html_input", EffectChain_add_html_input }, +#endif { "add_effect", EffectChain_add_effect }, { "finalize", EffectChain_finalize }, { NULL, NULL } @@ -675,11 +689,13 @@ const luaL_Reg VideoInput_funcs[] = { const luaL_Reg HTMLInput_funcs[] = { { "new", HTMLInput_new }, +#ifdef HAVE_CEF { "set_url", HTMLInput_set_url }, { "reload", HTMLInput_reload }, { "set_max_fps", HTMLInput_set_max_fps }, { "execute_javascript_async", HTMLInput_execute_javascript_async }, { "get_signal_num", HTMLInput_get_signal_num }, +#endif { NULL, NULL } }; diff --git a/theme.h b/theme.h index c2b93c2..f7897c7 100644 --- a/theme.h +++ b/theme.h @@ -69,6 +69,7 @@ public: return video_inputs; } +#ifdef HAVE_CEF // Should be called as part of HTMLInput.new() only. void register_html_input(CEFCapture *capture) { @@ -79,6 +80,7 @@ public: { return html_inputs; } +#endif void register_video_signal_connection(LiveInputWrapper *live_input, FFmpegCapture *capture) { @@ -90,6 +92,7 @@ public: return video_signal_connections; } +#ifdef HAVE_CEF void register_html_signal_connection(LiveInputWrapper *live_input, CEFCapture *capture) { html_signal_connections.emplace_back(live_input, capture); @@ -99,6 +102,7 @@ public: { return html_signal_connections; } +#endif private: void register_constants(); @@ -116,8 +120,10 @@ private: std::vector video_inputs; std::vector> video_signal_connections; +#ifdef HAVE_CEF std::vector html_inputs; std::vector> html_signal_connections; +#endif friend class LiveInputWrapper; }; -- 2.39.2