Skip to content

Commit

Permalink
Merge pull request #138 from Stivius/master
Browse files Browse the repository at this point in the history
1.8 R4 fixes
  • Loading branch information
alexharrington authored Nov 1, 2019
2 parents c77bc19 + 3ce446f commit 9540592
Show file tree
Hide file tree
Showing 52 changed files with 475 additions and 410 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ xibo-*.snap*
snap
gcov
build*
prime
stage
parts
WORK
pch.py
*.json
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules")

find_package(PkgConfig REQUIRED)
find_package(Boost 1.69 REQUIRED filesystem system date_time thread)
find_package(Boost 1.70 EXACT REQUIRED filesystem system date_time thread)

# modules
include(FindSonameLib)
Expand Down
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
libgtkmm-3.0-dev \
libgstreamer1.0-dev \
libgstreamermm-1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev \
gstreamer1.0-libav \
Expand Down Expand Up @@ -47,7 +46,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 90

ENV BOOST_MAJOR=1 BOOST_MINOR=69
ENV BOOST_MAJOR=1 BOOST_MINOR=70
ENV BOOST=${BOOST_MAJOR}_${BOOST_MINOR}_0
RUN curl -o /root/boost.tar.gz -SL https://dl.bintray.com/boostorg/release/${BOOST_MAJOR}.${BOOST_MINOR}.0/source/boost_${BOOST}.tar.gz && \
cd /root && \
Expand Down Expand Up @@ -140,6 +139,7 @@ RUN curl -o /root/cryptopp.tar.gz -SL https://github.com/weidai11/cryptopp/archi

RUN mkdir -p /app

VOLUME /build
ADD . /app

RUN cd /app && \
Expand All @@ -148,6 +148,4 @@ RUN cd /app && \
make -j4 && \
make install

RUN cp -r /app/_build/. /app/build

CMD []
ENTRYPOINT cp -r /app/_build/. /build
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@

### Building manually

NOTE: these libraries can require additional installations if you haven't such
NOTE: These libraries can require additional installations if you haven't such. We have tested only with listed libraries versions, however, it can be possible to build with newer or older versions as well.
- `cmake>=3.14` cross-platform software for managing the build process
- `gtk>=3.18` and `gtkmm>=3.18` GUI library and C++ bindings
- `gtk>=3.22` and `gtkmm>=3.22` GUI library and C++ bindings
- `glib>=2.56` and `glibmm>=2.56` low-level system library written in C and C++ bindings
- `gstreamer>=1.8`, `gstreamer-base-plugins>=1.8` multimedia framerwork with base plugins
- `gstreamer1.0-libav` needed for running video content
- `cryptopp>=8.1` for crypto utils (RSA, RC4 etc.)
- `zeromq>=4.3` distributed messaging
- `gstreamer, gstreamer-base-plugins, gstreamer-good-plugins, gstreamer-bad-plugins>=1.14` multimedia framerwork for audio/video playback with plugins
- `gstreamer1.0-libav`, `gstreamer1.0-gtk3`, `gstreamer1.0-gl`, `gstreamer1.0-vaapi`, `gstreamer1.0-alsa`, `gstreamer1.0-pulseaudio` needed for running/accelerating video content
- `cryptopp=8.1` for crypto utils (RSA, RC4 etc.)
- `cryptopp-pem`that is compatiable with `cryptopp` version needed for PEM key format
- `zeromq=4.3` distributed messaging
- `spdlog=1.4.1` logging library
- `gtest=1.8.1` for tests
- `webkitgtk>=2.4.10` web content rendering
- `Boost.System>=1.69`, `Boost.Date_Time>=1.69` and `Boost.Thread>=1.69`
- `Boost.System, Boost.Filesystem, Boost.Date_Time, Boost.Thread=1.70`

### Building with Docker (only for Ubuntu 16.04)
### Building with Docker (only for Ubuntu 18.04)
- Install Docker
- Clone this repository
- Run `sudo docker build -t xibo-linux .` in the root of the repository
Expand Down
16 changes: 3 additions & 13 deletions config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,12 @@ namespace ProjectResources
const std::string PlayerBin = "player";
inline std::string playerBinary()
{
auto path = buildDirectory() / PlayerBin;
#ifdef SNAP_ENABLED
return "desktop-launch " + path.string();
#else
return path.string();
#endif
return (buildDirectory() / PlayerBin).string();
}

const std::string OptionsBin = "options";
inline std::string optionsBinary()
{
auto path = buildDirectory() / "options";
#ifdef SNAP_ENABLED
return "desktop-launch " + path.string();
#else
return path.string();
#endif
return (buildDirectory() / OptionsBin).string();
}

}
7 changes: 4 additions & 3 deletions player/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
project(player)

pkg_check_modules(GStreamer REQUIRED gstreamermm-1.0>=1.10.0 gstreamer-pbutils-1.0 gstreamer-video-1.0>=1.14.0 gstreamer-plugins-base-1.0>=1.14.0)
pkg_check_modules(GStreamer REQUIRED gstreamer-pbutils-1.0 gstreamer-video-1.0>=1.14.0 gstreamer-plugins-base-1.0>=1.14.0)
pkg_check_modules(WebKit REQUIRED webkitgtk-3.0>=2.4.10)
pkg_check_modules(Gtkmm REQUIRED gtkmm-3.0>=3.18.0)
pkg_check_modules(Gtkmm REQUIRED gtkmm-3.0>=3.22.0)
pkg_check_modules(Glibmm REQUIRED glibmm-2.4>=2.56.0)
pkg_check_modules(Spdlog REQUIRED spdlog>=1.4.1)

Expand All @@ -13,7 +13,8 @@ add_compile_definitions(BOOST_THREAD_PROVIDES_FUTURE BOOST_THREAD_PROVIDES_FUTUR
file(GLOB MAIN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.*pp)
file(GLOB_RECURSE CONTROL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/control/*.*pp)
file(GLOB OTHER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/screenshot/*.*pp
${CMAKE_CURRENT_SOURCE_DIR}/managers/*.*pp)
${CMAKE_CURRENT_SOURCE_DIR}/managers/*.*pp
${CMAKE_CURRENT_SOURCE_DIR}/stat/*.*pp)

add_subdirectory(schedule)
add_subdirectory(options)
Expand Down
13 changes: 11 additions & 2 deletions player/MainLoop.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#include "MainLoop.hpp"

#include "common/logger/Logging.hpp"
#include "control/widgets/gtk/WindowGtk.hpp"

#include <glibmm/main.h>
static std::thread::id g_uiThreadId;

MainLoop::MainLoop(const std::string& name) : parentApp_(Gtk::Application::create(name)) {}
MainLoop::MainLoop(const std::string& name) : parentApp_(Gtk::Application::create(name))
{
g_uiThreadId = std::this_thread::get_id();
}

std::thread::id MainLoop::uiThreadId()
{
return g_uiThreadId;
}

int MainLoop::run(WindowGtk& adaptor)
{
Expand Down
15 changes: 15 additions & 0 deletions player/MainLoop.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include <glibmm/main.h>
#include <gtkmm/application.h>
#include <thread>

class WindowGtk;

Expand All @@ -12,6 +14,17 @@ class MainLoop
public:
MainLoop(const std::string& name);

template <typename Callback>
static void pushToUiThread(Callback callback)
{
Glib::MainContext::get_default()->invoke([callback = std::move(callback)] {
callback();
return false;
});
}

static std::thread::id uiThreadId();

int run(WindowGtk& adaptor);
void quit();

Expand All @@ -23,3 +36,5 @@ class MainLoop
sigc::connection idleConnection_;
ShutdownAction shutdownAction_;
};

#define CHECK_UI_THREAD() assert(MainLoop::uiThreadId() == std::this_thread::get_id())
47 changes: 28 additions & 19 deletions player/XiboApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include "control/media/MediaParsersRepo.hpp"

#include "managers/CollectionInterval.hpp"
#include "managers/StatsRecorder.hpp"
#include "managers/XmrManager.hpp"
#include "schedule/Scheduler.hpp"
#include "screenshot/ScreeShoterFactory.hpp"
#include "screenshot/ScreenShotInterval.hpp"
#include "stat/StatsRecorder.hpp"

#include "networking/HttpClient.hpp"
#include "networking/WebServer.hpp"
Expand All @@ -29,9 +29,7 @@
#include "common/settings/PlayerSettings.hpp"
#include "common/system/System.hpp"

#include <boost/date_time/time_clock.hpp>
#include <glibmm/main.h>
#include <gstreamermm/init.h>
#include <gst/gst.h>

static std::unique_ptr<XiboApp> g_app;

Expand All @@ -42,9 +40,8 @@ XiboApp& xiboApp()

XiboApp& XiboApp::create(const std::string& name)
{
auto logger = Log::create();

Gst::init();
Log::create();
gst_init(nullptr, nullptr);
Resources::setDirectory(ProjectResources::defaultResourcesDir());

g_app = std::unique_ptr<XiboApp>(new XiboApp(name));
Expand Down Expand Up @@ -94,12 +91,16 @@ XiboApp::XiboApp(const std::string& name) :
void XiboApp::setupXmrManager()
{
xmrManager_->collectionInterval().connect([this]() {
CHECK_UI_THREAD();

Log::info("[XMR] Start unscheduled collection");

collectionInterval_->collect([this](const PlayerError& error) { onCollectionFinished(error); });
});

xmrManager_->screenshot().connect([this]() {
CHECK_UI_THREAD();

Log::info("[XMR] Taking unscheduled screenshot");

screenShoter_->takeBase64([this](const std::string& screenshot) {
Expand All @@ -119,14 +120,6 @@ void XiboApp::setupXmrManager()
});
}

XiboApp::~XiboApp()
{
if (Gst::is_initialized())
{
Gst::deinit();
}
}

FileCache& XiboApp::fileManager()
{
return *fileCache_;
Expand All @@ -148,6 +141,8 @@ int XiboApp::run()
setupLayoutManager();

mainWindow_->statusScreenShown().connect([this]() {
CHECK_UI_THREAD();

StatusInfo info{
collectGeneralInfo(), collectionInterval_->status(), scheduler_->status(), xmrManager_->status()};

Expand All @@ -167,18 +162,20 @@ int XiboApp::run()
[](const LayoutSchedule& schedule) { schedule.toFile(ProjectResources::schedulePath()); });

collectionInterval_->startRegularCollection();
mainWindow_->showAll();
mainWindow_->show();

return mainLoop_->run(*mainWindow_);
}

void XiboApp::setupLayoutManager()
{
layoutsManager_->mainLayoutFetched().connect([this](const MainLayoutWidget& layout) {
CHECK_UI_THREAD();

if (layout)
{
mainWindow_->setMainLayout(layout);
layout->showAll();
layout->show();
}
else
{
Expand All @@ -187,10 +184,12 @@ void XiboApp::setupLayoutManager()
});

layoutsManager_->overlaysFetched().connect([this](const OverlaysWidgets& overlays) {
CHECK_UI_THREAD();

mainWindow_->setOverlays(overlays);
for (auto&& layout : overlays)
{
layout->showAll();
layout->show();
}
});
}
Expand Down Expand Up @@ -219,15 +218,23 @@ std::unique_ptr<CollectionInterval> XiboApp::createCollectionInterval(XmdsReques
interval->collectionFinished().connect(std::bind(&XiboApp::onCollectionFinished, this, ph::_1));
interval->settingsUpdated().connect(std::bind(&XiboApp::updateAndApplySettings, this, ph::_1));
interval->scheduleAvailable().connect([this](const Schedule::Result& result) {
CHECK_UI_THREAD();

scheduler_->reloadSchedule(LayoutSchedule::fromString(result.scheduleXml));
});
interval->filesDownloaded().connect([this]() { scheduler_->reloadQueue(); });
interval->filesDownloaded().connect([this]() {
CHECK_UI_THREAD();

scheduler_->reloadQueue();
});

return interval;
}

void XiboApp::onCollectionFinished(const PlayerError& error)
{
CHECK_UI_THREAD();

if (error)
{
Log::error("[CollectionInterval] {}", error);
Expand All @@ -236,6 +243,8 @@ void XiboApp::onCollectionFinished(const PlayerError& error)

void XiboApp::updateAndApplySettings(const PlayerSettings& settings)
{
CHECK_UI_THREAD();

applyPlayerSettings(settings);

playerSettings_ = std::move(settings);
Expand Down
15 changes: 5 additions & 10 deletions player/XiboApp.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#pragma once

#include <memory>
#include <spdlog/common.h>

#include "common/settings/CmsSettings.hpp"
#include "common/settings/PlayerSettings.hpp"

#include "control/ApplicationWindow.hpp"
#include "control/GeneralInfo.hpp"
#include "control/widgets/gtk/WindowGtk.hpp"

#include <boost/noncopyable.hpp>
#include <memory>

class MainLoop;
class XmdsRequestSender;
class HttpClient;
Expand All @@ -28,13 +28,9 @@ class XiboApp;

XiboApp& xiboApp();

class XiboApp
class XiboApp : boost::noncopyable
{
public:
XiboApp(const XiboApp& other) = delete;
XiboApp& operator=(const XiboApp& other) = delete;
~XiboApp();

static XiboApp& create(const std::string& name);

FileCache& fileManager();
Expand All @@ -44,9 +40,8 @@ class XiboApp
int run();

private:
static std::vector<spdlog::sink_ptr> createLoggerSinks();

XiboApp(const std::string& name);

void setupXmrManager();
void setupLayoutManager();
std::unique_ptr<CollectionInterval> createCollectionInterval(XmdsRequestSender& xmdsManager);
Expand Down
Loading

0 comments on commit 9540592

Please sign in to comment.