]> git.sesse.net Git - nageru/commitdiff
Make compiling with CEF optional.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Feb 2018 14:49:37 +0000 (15:49 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 26 Feb 2018 17:06:16 +0000 (18:06 +0100)
Makefile
main.cpp
mixer.cpp
theme.cpp
theme.h

index af5937c60ceac7f95e38fc29a3902341fd3a93dd..0621182b01071792695506c562b62031d8af5d53 100644 (file)
--- 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
 
index 65eade924ecc15e559c655e9fa47a9864ac65bdb..4287b7e56f8d4faf321f28221d432492ac54c1bd 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -13,20 +13,26 @@ extern "C" {
 #include <QSurfaceFormat>
 #include <string>
 
+#ifdef HAVE_CEF
 #include <cef_app.h>
 #include <cef_browser.h>
 #include <cef_client.h>
 #include <cef_version.h>
+#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<NageruCefApp> cef_app;
+#endif
 
 int main(int argc, char *argv[])
 {
index 557452db91cb9e7176b7df51ebecedb7c286c355..e1d9ca9c49466a18c64fbd08c9e71069a3473dc6 100644 (file)
--- 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<CEFCapture *> 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<LiveInputWrapper *, FFmpegCapture *> &conn : theme->get_video_signal_connections()) {
                conn.first->connect_signal_raw(conn.second->get_card_index(), input_state);
        }
+#ifdef HAVE_CEF
        for (const pair<LiveInputWrapper *, CEFCapture *> &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.
index 091495f9cae0e78836a7b6c7f3f42480ffbadb0d..485fa433de9f043345c87db7820a7024792bb62e 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -28,7 +28,9 @@
 #include <utility>
 
 #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<CEFCapture>(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 c2b93c2301b98d2b092bb9bae03b6c240e826503..f7897c77f9bf6b16ae3e5927af9b4c212ae21cc4 100644 (file)
--- 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<FFmpegCapture *> video_inputs;
        std::vector<std::pair<LiveInputWrapper *, FFmpegCapture *>> video_signal_connections;
+#ifdef HAVE_CEF
        std::vector<CEFCapture *> html_inputs;
        std::vector<std::pair<LiveInputWrapper *, CEFCapture *>> html_signal_connections;
+#endif
 
        friend class LiveInputWrapper;
 };