Skip to content

Commit

Permalink
- renamed USE_STREAMER compilation flag to _USE_STREAMER_
Browse files Browse the repository at this point in the history
- changed cpp-httplib git submodule path to https://github.com/bondagit/cpp-httplib.git
- removed compilation warning related to the usage of Boost bind global placeholders
- updated daemon version to 2.0.2
  • Loading branch information
bondagit committed Sep 16, 2024
1 parent 622417d commit 47da082
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion 3rdparty/cpp-httplib
Submodule cpp-httplib updated 52 files
+26 −0 .github/workflows/cifuzz.yaml
+27 −3 .github/workflows/test.yaml
+6 −1 .gitignore
+74 −60 CMakeLists.txt
+311 −92 README.md
+0 −14 appveyor.yml
+178 −0 cmake/FindBrotli.cmake
+12 −0 example/Dockerfile.hello
+26 −15 example/Makefile
+2 −2 example/client.cc
+1 −1 example/hello.cc
+5 −8 example/simplecli.cc
+1 −1 example/simplesvr.cc
+21 −0 example/ssecli.cc
+12 −21 example/ssesvr.cc
+6 −0 example/uploader.sh
+4,778 −2,082 httplib.h
+9 −0 httplibConfig.cmake.in
+111 −0 meson.build
+9 −0 meson_options.txt
+60 −25 split.py
+51 −8 test/Makefile
+ test/clusterfuzz-testcase-minimized-server_fuzzer-5042094968537088
+27 −0 test/fuzzing/Makefile
+1 −0 test/fuzzing/corpus/1
+5 −0 test/fuzzing/corpus/2
+ test/fuzzing/corpus/3
+ test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5372331946541056
+ test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5386708825800704
+ test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5667822731132928
+ test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5886572146327552
+ test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-5942767436562432
+ test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-6007379124158464
+7 −0 test/fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-6508706672541696
+19 −0 test/fuzzing/corpus/issue1264
+88 −0 test/fuzzing/server_fuzzer.cc
+224 −0 test/fuzzing/server_fuzzer.dict
+35 −0 test/fuzzing/standalone_fuzz_target_runner.cpp
+5,807 −2,437 test/gtest/gtest-all.cc
+9,334 −16,527 test/gtest/gtest.h
+19 −4 test/gtest/gtest_main.cc
+5 −0 test/include_httplib.cc
+112 −0 test/meson.build
+0 −1 test/proxy/down.sh
+0 −1 test/proxy/up.sh
+2,874 −378 test/test.cc
+3 −0 test/test.conf
+8 −2 test/test.vcxproj
+36 −31 test/test_proxy.cc
+7 −0 test/www/dir/meson.build
+6 −0 test/www2/dir/meson.build
+6 −0 test/www3/dir/meson.build
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ cmake \
-DWITH_AVAHI=ON \
-DFAKE_DRIVER=OFF \
-DWITH_SYSTEMD=ON \
-DWITH_STREAMER=ON \
.
make
cd ..
Expand Down
2 changes: 1 addition & 1 deletion daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
19 changes: 18 additions & 1 deletion daemon/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

#define BOOST_BIND_GLOBAL_PLACEHOLDERS

#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -72,7 +74,8 @@ std::shared_ptr<Config> 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;
Expand Down Expand Up @@ -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_;
}
4 changes: 2 additions & 2 deletions daemon/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_; };
Expand Down Expand Up @@ -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_;
Expand Down
6 changes: 4 additions & 2 deletions daemon/http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

#define BOOST_BIND_GLOBAL_PLACEHOLDERS

#include <boost/foreach.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions daemon/http_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "config.hpp"
#include "session_manager.hpp"

#ifdef USE_STREAMER
#ifdef _USE_STREAMER_
#include "streamer.hpp"
#endif

Expand All @@ -35,13 +35,13 @@ class HttpServer {
HttpServer() = delete;
explicit HttpServer(std::shared_ptr<SessionManager> session_manager,
std::shared_ptr<Browser> browser,
#ifdef USE_STREAMER
#ifdef _USE_STREAMER_
std::shared_ptr<Streamer> streamer,
#endif
std::shared_ptr<Config> config)
: session_manager_(session_manager),
browser_(browser),
#ifdef USE_STREAMER
#ifdef _USE_STREAMER_
streamer_(streamer),
#endif
config_(config){};
Expand All @@ -51,7 +51,7 @@ class HttpServer {
private:
std::shared_ptr<SessionManager> session_manager_;
std::shared_ptr<Browser> browser_;
#ifdef USE_STREAMER
#ifdef _USE_STREAMER_
std::shared_ptr<Streamer> streamer_;
#endif
std::shared_ptr<Config> config_;
Expand Down
7 changes: 5 additions & 2 deletions daemon/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

#define BOOST_BIND_GLOBAL_PLACEHOLDERS

#include <boost/foreach.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
Expand Down Expand Up @@ -290,14 +292,15 @@ std::string remote_sources_to_json(const std::list<RemoteSource>& 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)
Expand Down
4 changes: 2 additions & 2 deletions daemon/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "browser.hpp"
#include "session_manager.hpp"

#ifdef USE_STREAMER
#ifdef _USE_STREAMER_
#include "streamer.hpp"
#endif

Expand All @@ -42,7 +42,7 @@ std::string streams_to_json(const std::list<StreamSource>& sources,
const std::list<StreamSink>& sinks);
std::string remote_source_to_json(const RemoteSource& source);
std::string remote_sources_to_json(const std::list<RemoteSource>& sources);
#ifdef USE_STREAMER
#ifdef _USE_STREAMER_
std::string streamer_info_to_json(const StreamerInfo& info);
#endif

Expand Down
8 changes: 4 additions & 4 deletions daemon/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "rtsp_server.hpp"
#include "session_manager.hpp"

#ifdef USE_STREAMER
#ifdef _USE_STREAMER_
#include "streamer.hpp"
#endif

Expand All @@ -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<bool> terminate = false;

void termination_handler(int signum) {
Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -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"));
Expand Down
3 changes: 2 additions & 1 deletion daemon/netlink_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
#include <boost/asio.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <cstdlib>
#include <iostream>

#include "netlink.hpp"

using namespace boost::placeholders;
using boost::asio::deadline_timer;

class NetlinkClient {
Expand Down
3 changes: 2 additions & 1 deletion daemon/sap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include "sap.hpp"

using namespace boost::placeholders;
using namespace boost::asio;
using namespace boost::asio::ip;

Expand Down
3 changes: 2 additions & 1 deletion daemon/session_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//

#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH 4096 // max for SDP file
#define BOOST_BIND_GLOBAL_PLACEHOLDERS

#include <stdlib.h>
#include <httplib.h>
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions daemon/tests/daemon_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
//

#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH 4096 // max for SDP file
#define BOOST_BIND_GLOBAL_PLACEHOLDERS

#include <httplib.h>
#include <boost/foreach.hpp>
#include <boost/asio.hpp>
Expand Down Expand Up @@ -404,7 +406,8 @@ BOOST_AUTO_TEST_CASE(get_config) {
auto streamer_channels = pt.get<int>("streamer_channels");
auto streamer_files_num = pt.get<int>("streamer_files_num");
auto streamer_file_duration = pt.get<int>("streamer_file_duration");
auto streamer_player_buffer_files_num = pt.get<int>("streamer_player_buffer_files_num");
auto streamer_player_buffer_files_num =
pt.get<int>("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");
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 47da082

Please sign in to comment.