diff --git a/.gitmodules b/.gitmodules index d03a0f8..ac58ae1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "3rdparty/cpp-httplib"] path = 3rdparty/cpp-httplib - url = git@github.com:bondagit/cpp-httplib.git + url = https://github.com/bondagit/cpp-httplib.git diff --git a/3rdparty/cpp-httplib b/3rdparty/cpp-httplib index 42f9f91..07c6e58 160000 --- a/3rdparty/cpp-httplib +++ b/3rdparty/cpp-httplib @@ -1 +1 @@ -Subproject commit 42f9f9107f87ad2ee04be117dbbadd621c449552 +Subproject commit 07c6e58951931f8c74de8291ff35a3298fe481c4 diff --git a/build.sh b/build.sh index 6ad4446..3948fb0 100755 --- a/build.sh +++ b/build.sh @@ -39,6 +39,7 @@ cmake \ -DWITH_AVAHI=ON \ -DFAKE_DRIVER=OFF \ -DWITH_SYSTEMD=ON \ + -DWITH_STREAMER=ON \ . make cd .. diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 1d054d5..b7a8b6e 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -39,7 +39,7 @@ set(SOURCES error_code.cpp json.cpp main.cpp session_manager.cpp http_server.cpp if(WITH_STREAMER) MESSAGE(STATUS "WITH_STREAMER") - add_definitions(-DUSE_STREAMER) + add_definitions(-D_USE_STREAMER_) list(APPEND SOURCES streamer.cpp) endif() diff --git a/daemon/config.cpp b/daemon/config.cpp index 08bd7c5..634fa49 100644 --- a/daemon/config.cpp +++ b/daemon/config.cpp @@ -17,6 +17,8 @@ // along with this program. If not, see . // +#define BOOST_BIND_GLOBAL_PLACEHOLDERS + #include #include #include @@ -72,7 +74,8 @@ std::shared_ptr Config::parse(const std::string& filename, config.streamer_file_duration_ = 1; if (config.streamer_files_num_ < 4 || config.streamer_files_num_ > 16) config.streamer_files_num_ = 8; - if (config.streamer_player_buffer_files_num_ < 1 || config.streamer_player_buffer_files_num_ > 2) + if (config.streamer_player_buffer_files_num_ < 1 || + config.streamer_player_buffer_files_num_ > 2) config.streamer_player_buffer_files_num_ = 1; boost::system::error_code ec; @@ -169,3 +172,17 @@ std::string Config::get_node_id() const { return custom_node_id_; } } + +bool Config::get_streamer_enabled() const { +#ifndef _USE_STREAMER_ + return false; +#endif + return streamer_enabled_; +} + +bool Config::get_mdns_enabled() const { +#ifndef _USE_AVAHI_ + return false; +#endif + return mdns_enabled_; +} diff --git a/daemon/config.hpp b/daemon/config.hpp index 90a56e8..05879cd 100644 --- a/daemon/config.hpp +++ b/daemon/config.hpp @@ -45,7 +45,7 @@ class Config { return streamer_player_buffer_files_num_; }; uint8_t get_streamer_channels() const { return streamer_channels_; }; - bool get_streamer_enabled() const { return streamer_enabled_; }; + bool get_streamer_enabled() const; int get_log_severity() const { return log_severity_; }; uint32_t get_playout_delay() const { return playout_delay_; }; uint32_t get_tic_frame_size_at_1fs() const { return tic_frame_size_at_1fs_; }; @@ -73,7 +73,7 @@ class Config { const std::string& get_ip_addr_str() const { return ip_str_; }; bool get_daemon_restart() const { return daemon_restart_; }; bool get_driver_restart() const { return driver_restart_; }; - bool get_mdns_enabled() const { return mdns_enabled_; }; + bool get_mdns_enabled() const; int get_interface_idx() const { return interface_idx_; }; const std::string& get_ptp_status_script() const { return ptp_status_script_; diff --git a/daemon/http_server.cpp b/daemon/http_server.cpp index 1ada3d0..4ce4bf5 100644 --- a/daemon/http_server.cpp +++ b/daemon/http_server.cpp @@ -17,6 +17,8 @@ // along with this program. If not, see . // +#define BOOST_BIND_GLOBAL_PLACEHOLDERS + #include #include #include @@ -323,7 +325,7 @@ bool HttpServer::init() { }); /* retrieve streamer info and position */ -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ svr_.Get("/api/streamer/info/([0-9]+)", [this](const Request& req, Response& res) { uint32_t id; @@ -383,7 +385,7 @@ bool HttpServer::init() { /* retrieve streamer file */ svr_.Get("/api/streamer/stream/([0-9]+)/([0-9]+)", [this](const Request& req, Response& res) { -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ if (!config_->get_streamer_enabled()) { set_error(400, "streamer not enabled", res); return; diff --git a/daemon/http_server.hpp b/daemon/http_server.hpp index 1ac24e2..41a25b4 100644 --- a/daemon/http_server.hpp +++ b/daemon/http_server.hpp @@ -26,7 +26,7 @@ #include "config.hpp" #include "session_manager.hpp" -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ #include "streamer.hpp" #endif @@ -35,13 +35,13 @@ class HttpServer { HttpServer() = delete; explicit HttpServer(std::shared_ptr session_manager, std::shared_ptr browser, -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ std::shared_ptr streamer, #endif std::shared_ptr config) : session_manager_(session_manager), browser_(browser), -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ streamer_(streamer), #endif config_(config){}; @@ -51,7 +51,7 @@ class HttpServer { private: std::shared_ptr session_manager_; std::shared_ptr browser_; -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ std::shared_ptr streamer_; #endif std::shared_ptr config_; diff --git a/daemon/json.cpp b/daemon/json.cpp index 275e0cf..2a7c680 100644 --- a/daemon/json.cpp +++ b/daemon/json.cpp @@ -17,6 +17,8 @@ // along with this program. If not, see . // +#define BOOST_BIND_GLOBAL_PLACEHOLDERS + #include #include #include @@ -290,14 +292,15 @@ std::string remote_sources_to_json(const std::list& sources) { return ss.str(); } -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ std::string streamer_info_to_json(const StreamerInfo& info) { std::stringstream ss; ss << "{" << "\n \"status\": " << unsigned(info.status) << ",\n \"file_duration\": " << unsigned(info.file_duration) << ",\n \"files_num\": " << unsigned(info.files_num) - << ",\n \"player_buffer_files_num\": " << unsigned(info.player_buffer_files_num) + << ",\n \"player_buffer_files_num\": " + << unsigned(info.player_buffer_files_num) << ",\n \"start_file_id\": " << unsigned(info.start_file_id) << ",\n \"current_file_id\": " << unsigned(info.current_file_id) << ",\n \"channels\": " << unsigned(info.channels) diff --git a/daemon/json.hpp b/daemon/json.hpp index b250f5a..2804bd3 100644 --- a/daemon/json.hpp +++ b/daemon/json.hpp @@ -25,7 +25,7 @@ #include "browser.hpp" #include "session_manager.hpp" -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ #include "streamer.hpp" #endif @@ -42,7 +42,7 @@ std::string streams_to_json(const std::list& sources, const std::list& sinks); std::string remote_source_to_json(const RemoteSource& source); std::string remote_sources_to_json(const std::list& sources); -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ std::string streamer_info_to_json(const StreamerInfo& info); #endif diff --git a/daemon/main.cpp b/daemon/main.cpp index 513bd3a..bfaec6b 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -31,7 +31,7 @@ #include "rtsp_server.hpp" #include "session_manager.hpp" -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ #include "streamer.hpp" #endif @@ -43,7 +43,7 @@ namespace po = boost::program_options; namespace postyle = boost::program_options::command_line_style; namespace logging = boost::log; -static const std::string version("bondagit-2.0.1"); +static const std::string version("bondagit-2.0.2"); static std::atomic terminate = false; void termination_handler(int signum) { @@ -184,7 +184,7 @@ int main(int argc, char* argv[]) { } /* start streamer */ -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ auto streamer = Streamer::create(session_manager, config); if (config->get_streamer_enabled() && (streamer == nullptr || !streamer->init())) { @@ -254,7 +254,7 @@ int main(int argc, char* argv[]) { } /* stop streamer */ -#ifdef USE_STREAMER +#ifdef _USE_STREAMER_ if (config->get_streamer_enabled()) { if (!streamer->terminate()) { throw std::runtime_error(std::string("Streamer:: terminate failed")); diff --git a/daemon/netlink_client.hpp b/daemon/netlink_client.hpp index f8ce5e8..95e00cf 100644 --- a/daemon/netlink_client.hpp +++ b/daemon/netlink_client.hpp @@ -23,13 +23,14 @@ #include #include #include -#include +#include #include #include #include #include "netlink.hpp" +using namespace boost::placeholders; using boost::asio::deadline_timer; class NetlinkClient { diff --git a/daemon/sap.cpp b/daemon/sap.cpp index 03232d7..cb7e3ae 100644 --- a/daemon/sap.cpp +++ b/daemon/sap.cpp @@ -17,10 +17,11 @@ // along with this program. If not, see . // -#include +#include #include "sap.hpp" +using namespace boost::placeholders; using namespace boost::asio; using namespace boost::asio::ip; diff --git a/daemon/session_manager.cpp b/daemon/session_manager.cpp index 27bfc25..c997b2e 100644 --- a/daemon/session_manager.cpp +++ b/daemon/session_manager.cpp @@ -18,6 +18,7 @@ // #define CPPHTTPLIB_PAYLOAD_MAX_LENGTH 4096 // max for SDP file +#define BOOST_BIND_GLOBAL_PLACEHOLDERS #include #include @@ -463,7 +464,7 @@ void SessionManager::add_source_observer(SourceObserverType type, } void SessionManager::add_sink_observer(SinkObserverType type, - const SinkObserver& cb) { + const SinkObserver& cb) { switch (type) { case SinkObserverType::add_sink: add_sink_observers_.push_back(cb); diff --git a/daemon/tests/daemon_test.cpp b/daemon/tests/daemon_test.cpp index 0dc994d..940c05c 100644 --- a/daemon/tests/daemon_test.cpp +++ b/daemon/tests/daemon_test.cpp @@ -17,6 +17,8 @@ // #define CPPHTTPLIB_PAYLOAD_MAX_LENGTH 4096 // max for SDP file +#define BOOST_BIND_GLOBAL_PLACEHOLDERS + #include #include #include @@ -404,7 +406,8 @@ BOOST_AUTO_TEST_CASE(get_config) { auto streamer_channels = pt.get("streamer_channels"); auto streamer_files_num = pt.get("streamer_files_num"); auto streamer_file_duration = pt.get("streamer_file_duration"); - auto streamer_player_buffer_files_num = pt.get("streamer_player_buffer_files_num"); + auto streamer_player_buffer_files_num = + pt.get("streamer_player_buffer_files_num"); BOOST_CHECK_MESSAGE(http_port == 9999, "config as excepcted"); // BOOST_CHECK_MESSAGE(log_severity == 5, "config as excepcted"); BOOST_CHECK_MESSAGE(playout_delay == 0, "config as excepcted"); @@ -432,7 +435,8 @@ BOOST_AUTO_TEST_CASE(get_config) { BOOST_CHECK_MESSAGE(streamer_channels == 8, "config as excepcted"); BOOST_CHECK_MESSAGE(streamer_files_num == 6, "config as excepcted"); BOOST_CHECK_MESSAGE(streamer_file_duration == 3, "config as excepcted"); - BOOST_CHECK_MESSAGE(streamer_player_buffer_files_num == 2, "config as excepcted"); + BOOST_CHECK_MESSAGE(streamer_player_buffer_files_num == 2, + "config as excepcted"); } BOOST_AUTO_TEST_CASE(get_ptp_status) {