From 201cf281966c32d0fb87a9c9f89cd72d9f53e7a1 Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Thu, 27 Feb 2025 17:57:54 +0100 Subject: [PATCH 1/8] Fix for issue #197 --- daemon/igmp.hpp | 2 +- daemon/interface.cpp | 2 +- daemon/netlink_client.hpp | 3 +-- daemon/sap.hpp | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/daemon/igmp.hpp b/daemon/igmp.hpp index 58b350b..71ad1b0 100644 --- a/daemon/igmp.hpp +++ b/daemon/igmp.hpp @@ -104,7 +104,7 @@ class IGMP { } private: - io_service io_service_; + io_context io_service_; ip::udp::socket socket_{io_service_}; udp::endpoint listen_endpoint_{udp::endpoint(address_v4::any(), 0)}; std::unordered_map mcast_ref; diff --git a/daemon/interface.cpp b/daemon/interface.cpp index dbe3b0f..17402f1 100644 --- a/daemon/interface.cpp +++ b/daemon/interface.cpp @@ -168,7 +168,7 @@ bool ping(const std::string& ip) { // this requires root priv try { - io_service io_service; + io_context io_service; icmp::socket socket{io_service, icmp::v4()}; ip::icmp::endpoint destination(ip::icmp::v4(), ip::address_v4::from_string(ip).to_ulong()); diff --git a/daemon/netlink_client.hpp b/daemon/netlink_client.hpp index 95e00cf..1842568 100644 --- a/daemon/netlink_client.hpp +++ b/daemon/netlink_client.hpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -94,7 +93,7 @@ class NetlinkClient { } private: - boost::asio::io_service io_service_; + boost::asio::io_context io_service_; boost::asio::basic_raw_socket socket_{io_service_}; deadline_timer deadline_{io_service_}; std::string name_; diff --git a/daemon/sap.hpp b/daemon/sap.hpp index fbe8e52..b91f1de 100644 --- a/daemon/sap.hpp +++ b/daemon/sap.hpp @@ -62,7 +62,7 @@ class SAP { const std::string& sdp); std::string addr_; - io_service io_service_; + io_context io_service_; ip::udp::socket socket_{io_service_}; ip::udp::endpoint remote_endpoint_{ ip::udp::endpoint(ip::address::from_string(addr_), port)}; From efcf95522b12c1a32685454da8837bc30eb71d17 Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Thu, 27 Feb 2025 20:06:17 +0100 Subject: [PATCH 2/8] Replace ip::address::to_string() with ip::make_address() to support Boost 1.87, see #197 --- daemon/config.cpp | 4 ++-- daemon/igmp.hpp | 14 ++++++-------- daemon/interface.cpp | 2 +- daemon/rtsp_client.cpp | 2 +- daemon/rtsp_server.hpp | 6 +++--- daemon/sap.cpp | 4 ++-- daemon/sap.hpp | 4 ++-- daemon/session_manager.cpp | 9 +++++---- 8 files changed, 22 insertions(+), 23 deletions(-) diff --git a/daemon/config.cpp b/daemon/config.cpp index 634fa49..2316248 100644 --- a/daemon/config.cpp +++ b/daemon/config.cpp @@ -79,11 +79,11 @@ std::shared_ptr Config::parse(const std::string& filename, config.streamer_player_buffer_files_num_ = 1; boost::system::error_code ec; - ip::address_v4::from_string(config.rtp_mcast_base_.c_str(), ec); + ip::make_address(config.rtp_mcast_base_.c_str(), ec); if (ec) { config.rtp_mcast_base_ = "239.1.0.1"; } - ip::address_v4::from_string(config.sap_mcast_addr_.c_str(), ec); + ip::make_address(config.sap_mcast_addr_.c_str(), ec); if (ec) { config.sap_mcast_addr_ = "224.2.127.254"; } diff --git a/daemon/igmp.hpp b/daemon/igmp.hpp index 71ad1b0..3cf83a0 100644 --- a/daemon/igmp.hpp +++ b/daemon/igmp.hpp @@ -40,7 +40,7 @@ class IGMP { bool join(const std::string& interface_ip, const std::string& mcast_ip) { uint32_t mcast_ip_addr = - ip::address_v4::from_string(mcast_ip.c_str()).to_ulong(); + ip::make_address(mcast_ip.c_str()).to_v4().to_ulong(); std::scoped_lock lock{mutex}; auto it = mcast_ref.find(mcast_ip_addr); @@ -50,9 +50,8 @@ class IGMP { } error_code ec; - ip::multicast::join_group option( - ip::address::from_string(mcast_ip).to_v4(), - ip::address::from_string(interface_ip).to_v4()); + ip::multicast::join_group option(ip::make_address(mcast_ip).to_v4(), + ip::make_address(interface_ip).to_v4()); socket_.set_option(option, ec); if (ec) { BOOST_LOG_TRIVIAL(error) << "igmp:: failed to joined multicast group " @@ -75,7 +74,7 @@ class IGMP { bool leave(const std::string& interface_ip, const std::string& mcast_ip) { uint32_t mcast_ip_addr = - ip::address_v4::from_string(mcast_ip.c_str()).to_ulong(); + ip::make_address(mcast_ip.c_str()).to_v4().to_ulong(); std::scoped_lock lock{mutex}; auto it = mcast_ref.find(mcast_ip_addr); @@ -88,9 +87,8 @@ class IGMP { } error_code ec; - ip::multicast::leave_group option( - ip::address::from_string(mcast_ip).to_v4(), - ip::address::from_string(interface_ip).to_v4()); + ip::multicast::leave_group option(ip::make_address(mcast_ip).to_v4(), + ip::make_address(interface_ip).to_v4()); socket_.set_option(option, ec); if (ec) { BOOST_LOG_TRIVIAL(error) << "igmp:: failed to leave multicast group " diff --git a/daemon/interface.cpp b/daemon/interface.cpp index 17402f1..8ccca65 100644 --- a/daemon/interface.cpp +++ b/daemon/interface.cpp @@ -171,7 +171,7 @@ bool ping(const std::string& ip) { io_context io_service; icmp::socket socket{io_service, icmp::v4()}; ip::icmp::endpoint destination(ip::icmp::v4(), - ip::address_v4::from_string(ip).to_ulong()); + ip::make_address(ip).to_v4().to_ulong()); socket.send_to(boost::asio::buffer(buffer, sizeof buffer), destination); } catch (...) { BOOST_LOG_TRIVIAL(error) << "ping:: send_to() failed"; diff --git a/daemon/rtsp_client.cpp b/daemon/rtsp_client.cpp index ff085e2..af9df89 100644 --- a/daemon/rtsp_client.cpp +++ b/daemon/rtsp_client.cpp @@ -206,7 +206,7 @@ std::pair RtspClient::process( << crc16(reinterpret_cast(res.body.c_str()), res.body.length()); /*<< std::hex << - * ip::address_v4::from_string(address.c_str()).to_ulong();*/ + * ip::make_address(address.c_str()).to_ulong();*/ rtsp_source.id = ss.str(); rtsp_source.source = "mDNS"; rtsp_source.address = address; diff --git a/daemon/rtsp_server.hpp b/daemon/rtsp_server.hpp index 971b7f4..eec1b3c 100644 --- a/daemon/rtsp_server.hpp +++ b/daemon/rtsp_server.hpp @@ -89,9 +89,9 @@ class RtspServer { : session_manager_(session_manager), config_(config), acceptor_(io_service_, - tcp::endpoint(boost::asio::ip::address::from_string( - config_->get_ip_addr_str()), - config_->get_rtsp_port())) {} + tcp::endpoint( + boost::asio::ip::make_address(config_->get_ip_addr_str()), + config_->get_rtsp_port())) {} bool init() { accept(); /* start rtsp server on a separate thread */ diff --git a/daemon/sap.cpp b/daemon/sap.cpp index cb7e3ae..be45383 100644 --- a/daemon/sap.cpp +++ b/daemon/sap.cpp @@ -27,7 +27,7 @@ using namespace boost::asio::ip; SAP::SAP(const std::string& sap_mcast_addr) : addr_(sap_mcast_addr) -// remote_endpoint_(ip::address::from_string(addr_), port) +// remote_endpoint_(ip::make_address(addr_), port) { socket_.open(boost::asio::ip::udp::v4()); socket_.set_option(udp::socket::reuse_address(true)); @@ -36,7 +36,7 @@ SAP::SAP(const std::string& sap_mcast_addr) } bool SAP::set_multicast_interface(const std::string& interface_ip) { - ip::address_v4 local_interface = ip::address_v4::from_string(interface_ip); + ip::address_v4 local_interface = ip::make_address(interface_ip).to_v4(); ip::multicast::outbound_interface oi_option(local_interface); boost::system::error_code ec; socket_.set_option(oi_option, ec); diff --git a/daemon/sap.hpp b/daemon/sap.hpp index b91f1de..c25bc92 100644 --- a/daemon/sap.hpp +++ b/daemon/sap.hpp @@ -65,9 +65,9 @@ class SAP { io_context io_service_; ip::udp::socket socket_{io_service_}; ip::udp::endpoint remote_endpoint_{ - ip::udp::endpoint(ip::address::from_string(addr_), port)}; + ip::udp::endpoint(ip::make_address(addr_), port)}; ip::udp::endpoint listen_endpoint_{ - ip::udp::endpoint(ip::address::from_string("0.0.0.0"), port)}; + ip::udp::endpoint(ip::make_address("0.0.0.0"), port)}; deadline_timer deadline_{io_service_}; }; diff --git a/daemon/session_manager.cpp b/daemon/session_manager.cpp index c997b2e..e0eecd2 100644 --- a/daemon/session_manager.cpp +++ b/daemon/session_manager.cpp @@ -255,7 +255,7 @@ bool SessionManager::parse_sdp(const std::string& sdp, StreamInfo& info) const { return false; } info.stream.m_ui32DestIP = - ip::address_v4::from_string(fields[2].c_str()).to_ulong(); + ip::make_address(fields[2].c_str()).to_v4().to_ulong(); if (info.stream.m_ui32DestIP == INADDR_NONE) { BOOST_LOG_TRIVIAL(error) << "session_manager:: invalid IPv4 " "connection address in SDP at line " @@ -524,13 +524,14 @@ std::error_code SessionManager::add_source(const StreamSource& source) { info.stream.m_ui32RTCPSrcIP = config_->get_ip_addr(); info.stream.m_ui32SrcIP = config_->get_ip_addr(); // only for Source boost::system::error_code ec; - ip::address_v4::from_string(source.address, ec); + ip::make_address(source.address, ec); if (!ec) { info.stream.m_ui32DestIP = - ip::address_v4::from_string(source.address).to_ulong(); + ip::make_address(source.address).to_v4().to_ulong(); } else { info.stream.m_ui32DestIP = - ip::address_v4::from_string(config_->get_rtp_mcast_base().c_str()) + ip::make_address(config_->get_rtp_mcast_base().c_str()) + .to_v4() .to_ulong() + source.id; } From 21690a858909107340cc60cdd7fe150122445b51 Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Thu, 27 Feb 2025 20:54:39 +0100 Subject: [PATCH 3/8] Replace ip::address_v4::to_ulong() with ip::address_v4::to_uint() to support boost 1.87, see #197 --- daemon/igmp.hpp | 4 ++-- daemon/interface.cpp | 2 +- daemon/rtsp_client.cpp | 2 +- daemon/session_manager.cpp | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/daemon/igmp.hpp b/daemon/igmp.hpp index 3cf83a0..2fb808c 100644 --- a/daemon/igmp.hpp +++ b/daemon/igmp.hpp @@ -40,7 +40,7 @@ class IGMP { bool join(const std::string& interface_ip, const std::string& mcast_ip) { uint32_t mcast_ip_addr = - ip::make_address(mcast_ip.c_str()).to_v4().to_ulong(); + ip::make_address(mcast_ip.c_str()).to_v4().to_uint(); std::scoped_lock lock{mutex}; auto it = mcast_ref.find(mcast_ip_addr); @@ -74,7 +74,7 @@ class IGMP { bool leave(const std::string& interface_ip, const std::string& mcast_ip) { uint32_t mcast_ip_addr = - ip::make_address(mcast_ip.c_str()).to_v4().to_ulong(); + ip::make_address(mcast_ip.c_str()).to_v4().to_uint(); std::scoped_lock lock{mutex}; auto it = mcast_ref.find(mcast_ip_addr); diff --git a/daemon/interface.cpp b/daemon/interface.cpp index 8ccca65..826daf3 100644 --- a/daemon/interface.cpp +++ b/daemon/interface.cpp @@ -171,7 +171,7 @@ bool ping(const std::string& ip) { io_context io_service; icmp::socket socket{io_service, icmp::v4()}; ip::icmp::endpoint destination(ip::icmp::v4(), - ip::make_address(ip).to_v4().to_ulong()); + ip::make_address(ip).to_v4().to_uint()); socket.send_to(boost::asio::buffer(buffer, sizeof buffer), destination); } catch (...) { BOOST_LOG_TRIVIAL(error) << "ping:: send_to() failed"; diff --git a/daemon/rtsp_client.cpp b/daemon/rtsp_client.cpp index af9df89..9d34ff4 100644 --- a/daemon/rtsp_client.cpp +++ b/daemon/rtsp_client.cpp @@ -206,7 +206,7 @@ std::pair RtspClient::process( << crc16(reinterpret_cast(res.body.c_str()), res.body.length()); /*<< std::hex << - * ip::make_address(address.c_str()).to_ulong();*/ + * ip::make_address(address.c_str()).to_uint();*/ rtsp_source.id = ss.str(); rtsp_source.source = "mDNS"; rtsp_source.address = address; diff --git a/daemon/session_manager.cpp b/daemon/session_manager.cpp index e0eecd2..6603926 100644 --- a/daemon/session_manager.cpp +++ b/daemon/session_manager.cpp @@ -255,7 +255,7 @@ bool SessionManager::parse_sdp(const std::string& sdp, StreamInfo& info) const { return false; } info.stream.m_ui32DestIP = - ip::make_address(fields[2].c_str()).to_v4().to_ulong(); + ip::make_address(fields[2].c_str()).to_v4().to_uint(); if (info.stream.m_ui32DestIP == INADDR_NONE) { BOOST_LOG_TRIVIAL(error) << "session_manager:: invalid IPv4 " "connection address in SDP at line " @@ -527,12 +527,12 @@ std::error_code SessionManager::add_source(const StreamSource& source) { ip::make_address(source.address, ec); if (!ec) { info.stream.m_ui32DestIP = - ip::make_address(source.address).to_v4().to_ulong(); + ip::make_address(source.address).to_v4().to_uint(); } else { info.stream.m_ui32DestIP = ip::make_address(config_->get_rtp_mcast_base().c_str()) .to_v4() - .to_ulong() + + .to_uint() + source.id; } info.stream.m_usSrcPort = config_->get_rtp_port(); From 4fc96c9491bfc8e24bc092a45a03e47e2b8ea931 Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Thu, 27 Feb 2025 21:31:48 +0100 Subject: [PATCH 4/8] Replaced boost::asio::io_service with boost::asio::io_context in rtsp_server.hpp, see #197 --- daemon/rtsp_server.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/rtsp_server.hpp b/daemon/rtsp_server.hpp index eec1b3c..6ca393f 100644 --- a/daemon/rtsp_server.hpp +++ b/daemon/rtsp_server.hpp @@ -125,7 +125,7 @@ class RtspServer { void accept(); std::mutex mutex_; - boost::asio::io_service io_service_; + boost::asio::io_context io_service_; std::shared_ptr session_manager_; std::shared_ptr config_; std::vector > sessions_{session_num_max}; From 6ff785a8d22ac1b885260b42ff881eacffd06c7c Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Thu, 27 Feb 2025 22:01:20 +0100 Subject: [PATCH 5/8] Fixes for daemon_test.cpp, see #197 --- daemon/tests/daemon_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/daemon/tests/daemon_test.cpp b/daemon/tests/daemon_test.cpp index 6c6db84..12cc24c 100644 --- a/daemon/tests/daemon_test.cpp +++ b/daemon/tests/daemon_test.cpp @@ -97,8 +97,8 @@ struct Client { socket_.set_option(udp::socket::reuse_address(true)); socket_.bind(listen_endpoint_); socket_.set_option( - multicast::join_group(address::from_string(g_sap_address).to_v4(), - address::from_string(g_daemon_address).to_v4())); + multicast::join_group(make_address(g_sap_address).to_v4(), + make_address(g_daemon_address).to_v4())); cli_.set_connection_timeout(30); cli_.set_read_timeout(30); @@ -362,10 +362,10 @@ struct Client { private: httplib::Client cli_{g_daemon_address, g_daemon_port}; - io_service io_service_; + io_context io_service_; udp::socket socket_{io_service_}; udp::endpoint listen_endpoint_{ - udp::endpoint(address::from_string("0.0.0.0"), g_sap_port)}; + udp::endpoint(make_address("0.0.0.0"), g_sap_port)}; }; BOOST_AUTO_TEST_CASE(is_alive) { From 1e652a046dc5cc5708698cdd84baec3cbe996662 Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Fri, 28 Feb 2025 17:46:53 +0100 Subject: [PATCH 6/8] Set of changes to keep compatibility between boost version 1.87 and earlier versions --- daemon/config.cpp | 8 ++++++++ daemon/igmp.hpp | 25 +++++++++++++++++++++++++ daemon/interface.cpp | 4 ++++ daemon/netlink_client.hpp | 4 ++++ daemon/rtsp_client.cpp | 2 -- daemon/rtsp_server.hpp | 8 ++++++++ daemon/sap.cpp | 9 +++++---- daemon/sap.hpp | 23 +++++++++++++++++++---- daemon/session_manager.cpp | 18 ++++++++++++++++++ 9 files changed, 91 insertions(+), 10 deletions(-) diff --git a/daemon/config.cpp b/daemon/config.cpp index 2316248..8446889 100644 --- a/daemon/config.cpp +++ b/daemon/config.cpp @@ -79,11 +79,19 @@ std::shared_ptr Config::parse(const std::string& filename, config.streamer_player_buffer_files_num_ = 1; boost::system::error_code ec; +#if BOOST_VERSION < 108700 + ip::address_v4::from_string(config.rtp_mcast_base_.c_str(), ec); +#else ip::make_address(config.rtp_mcast_base_.c_str(), ec); +#endif if (ec) { config.rtp_mcast_base_ = "239.1.0.1"; } +#if BOOST_VERSION < 108700 + ip::address_v4::from_string(config.sap_mcast_addr_.c_str(), ec); +#else ip::make_address(config.sap_mcast_addr_.c_str(), ec); +#endif if (ec) { config.sap_mcast_addr_ = "224.2.127.254"; } diff --git a/daemon/igmp.hpp b/daemon/igmp.hpp index 2fb808c..b7e6440 100644 --- a/daemon/igmp.hpp +++ b/daemon/igmp.hpp @@ -40,7 +40,11 @@ class IGMP { bool join(const std::string& interface_ip, const std::string& mcast_ip) { uint32_t mcast_ip_addr = +#if BOOST_VERSION < 108700 + ip::address_v4::from_string(mcast_ip.c_str()).to_ulong(); +#else ip::make_address(mcast_ip.c_str()).to_v4().to_uint(); +#endif std::scoped_lock lock{mutex}; auto it = mcast_ref.find(mcast_ip_addr); @@ -50,8 +54,14 @@ class IGMP { } error_code ec; +#if BOOST_VERSION < 108700 + ip::multicast::join_group option( + ip::address::from_string(mcast_ip).to_v4(), + ip::address::from_string(interface_ip).to_v4()); +#else ip::multicast::join_group option(ip::make_address(mcast_ip).to_v4(), ip::make_address(interface_ip).to_v4()); +#endif socket_.set_option(option, ec); if (ec) { BOOST_LOG_TRIVIAL(error) << "igmp:: failed to joined multicast group " @@ -74,7 +84,11 @@ class IGMP { bool leave(const std::string& interface_ip, const std::string& mcast_ip) { uint32_t mcast_ip_addr = +#if BOOST_VERSION < 108700 + ip::address_v4::from_string(mcast_ip.c_str()).to_ulong(); +#else ip::make_address(mcast_ip.c_str()).to_v4().to_uint(); +#endif std::scoped_lock lock{mutex}; auto it = mcast_ref.find(mcast_ip_addr); @@ -87,8 +101,15 @@ class IGMP { } error_code ec; + +#if BOOST_VERSION < 108700 + ip::multicast::leave_group option( + ip::address::from_string(mcast_ip).to_v4(), + ip::address::from_string(interface_ip).to_v4()); +#else ip::multicast::leave_group option(ip::make_address(mcast_ip).to_v4(), ip::make_address(interface_ip).to_v4()); +#endif socket_.set_option(option, ec); if (ec) { BOOST_LOG_TRIVIAL(error) << "igmp:: failed to leave multicast group " @@ -102,7 +123,11 @@ class IGMP { } private: +#if BOOST_VERSION < 108700 + io_service io_service_; +#else io_context io_service_; +#endif ip::udp::socket socket_{io_service_}; udp::endpoint listen_endpoint_{udp::endpoint(address_v4::any(), 0)}; std::unordered_map mcast_ref; diff --git a/daemon/interface.cpp b/daemon/interface.cpp index 826daf3..696e121 100644 --- a/daemon/interface.cpp +++ b/daemon/interface.cpp @@ -171,7 +171,11 @@ bool ping(const std::string& ip) { io_context io_service; icmp::socket socket{io_service, icmp::v4()}; ip::icmp::endpoint destination(ip::icmp::v4(), +#if BOOST_VERSION < 108700 + ip::address_v4::from_string(ip).to_ulong()); +#else ip::make_address(ip).to_v4().to_uint()); +#endif socket.send_to(boost::asio::buffer(buffer, sizeof buffer), destination); } catch (...) { BOOST_LOG_TRIVIAL(error) << "ping:: send_to() failed"; diff --git a/daemon/netlink_client.hpp b/daemon/netlink_client.hpp index 1842568..630d181 100644 --- a/daemon/netlink_client.hpp +++ b/daemon/netlink_client.hpp @@ -93,7 +93,11 @@ class NetlinkClient { } private: +#if BOOST_VERSION < 108700 + boost::asio::io_service io_service_; +#else boost::asio::io_context io_service_; +#endif boost::asio::basic_raw_socket socket_{io_service_}; deadline_timer deadline_{io_service_}; std::string name_; diff --git a/daemon/rtsp_client.cpp b/daemon/rtsp_client.cpp index 9d34ff4..284627e 100644 --- a/daemon/rtsp_client.cpp +++ b/daemon/rtsp_client.cpp @@ -205,8 +205,6 @@ std::pair RtspClient::process( ss << "rtsp:" << std::hex << crc16(reinterpret_cast(res.body.c_str()), res.body.length()); - /*<< std::hex << - * ip::make_address(address.c_str()).to_uint();*/ rtsp_source.id = ss.str(); rtsp_source.source = "mDNS"; rtsp_source.address = address; diff --git a/daemon/rtsp_server.hpp b/daemon/rtsp_server.hpp index 6ca393f..a7ca63f 100644 --- a/daemon/rtsp_server.hpp +++ b/daemon/rtsp_server.hpp @@ -90,7 +90,11 @@ class RtspServer { config_(config), acceptor_(io_service_, tcp::endpoint( +#if BOOST_VERSION < 108700 + boost::asio::ip::address::from_string(config_->get_ip_addr_str()), +#else boost::asio::ip::make_address(config_->get_ip_addr_str()), +#endif config_->get_rtsp_port())) {} bool init() { accept(); @@ -125,7 +129,11 @@ class RtspServer { void accept(); std::mutex mutex_; +#if BOOST_VERSION < 108700 + boost::asio::io_service io_service_; +#else boost::asio::io_context io_service_; +#endif std::shared_ptr session_manager_; std::shared_ptr config_; std::vector > sessions_{session_num_max}; diff --git a/daemon/sap.cpp b/daemon/sap.cpp index be45383..67e932a 100644 --- a/daemon/sap.cpp +++ b/daemon/sap.cpp @@ -25,10 +25,7 @@ using namespace boost::placeholders; using namespace boost::asio; using namespace boost::asio::ip; -SAP::SAP(const std::string& sap_mcast_addr) - : addr_(sap_mcast_addr) -// remote_endpoint_(ip::make_address(addr_), port) -{ +SAP::SAP(const std::string& sap_mcast_addr) : addr_(sap_mcast_addr) { socket_.open(boost::asio::ip::udp::v4()); socket_.set_option(udp::socket::reuse_address(true)); socket_.bind(listen_endpoint_); @@ -36,7 +33,11 @@ SAP::SAP(const std::string& sap_mcast_addr) } bool SAP::set_multicast_interface(const std::string& interface_ip) { +#if BOOST_VERSION < 108700 + ip::address_v4 local_interface = ip::address_v4::from_string(interface_ip); +#else ip::address_v4 local_interface = ip::make_address(interface_ip).to_v4(); +#endif ip::multicast::outbound_interface oi_option(local_interface); boost::system::error_code ec; socket_.set_option(oi_option, ec); diff --git a/daemon/sap.hpp b/daemon/sap.hpp index c25bc92..c7b1354 100644 --- a/daemon/sap.hpp +++ b/daemon/sap.hpp @@ -62,12 +62,27 @@ class SAP { const std::string& sdp); std::string addr_; +#if BOOST_VERSION < 108700 + io_service io_service_; +#else io_context io_service_; +#endif ip::udp::socket socket_{io_service_}; - ip::udp::endpoint remote_endpoint_{ - ip::udp::endpoint(ip::make_address(addr_), port)}; - ip::udp::endpoint listen_endpoint_{ - ip::udp::endpoint(ip::make_address("0.0.0.0"), port)}; + ip::udp::endpoint remote_endpoint_ { +#if BOOST_VERSION < 108700 + ip::udp::endpoint(ip::address::from_string(addr_), port) +#else + ip::udp::endpoint(ip::make_address(addr_), port) +#endif + }; + ip::udp::endpoint listen_endpoint_ { +#if BOOST_VERSION < 108700 + ip::udp::endpoint(ip::address::from_string("0.0.0.0"), port) + }; +#else + ip::udp::endpoint(ip::make_address("0.0.0.0"), port) + }; +#endif deadline_timer deadline_{io_service_}; }; diff --git a/daemon/session_manager.cpp b/daemon/session_manager.cpp index 6603926..be2809d 100644 --- a/daemon/session_manager.cpp +++ b/daemon/session_manager.cpp @@ -255,7 +255,12 @@ bool SessionManager::parse_sdp(const std::string& sdp, StreamInfo& info) const { return false; } info.stream.m_ui32DestIP = +#if BOOST_VERSION < 108700 + ip::address_v4::from_string(fields[2].c_str()).to_ulong(); +#else + ip::make_address(fields[2].c_str()).to_v4().to_uint(); +#endif if (info.stream.m_ui32DestIP == INADDR_NONE) { BOOST_LOG_TRIVIAL(error) << "session_manager:: invalid IPv4 " "connection address in SDP at line " @@ -524,15 +529,28 @@ std::error_code SessionManager::add_source(const StreamSource& source) { info.stream.m_ui32RTCPSrcIP = config_->get_ip_addr(); info.stream.m_ui32SrcIP = config_->get_ip_addr(); // only for Source boost::system::error_code ec; +#if BOOST_VERSION < 108700 + ip::address_v4::from_string(source.address, ec); +#else ip::make_address(source.address, ec); +#endif if (!ec) { info.stream.m_ui32DestIP = +#if BOOST_VERSION < 108700 + ip::address_v4::from_string(source.address).to_ulong(); +#else ip::make_address(source.address).to_v4().to_uint(); +#endif } else { info.stream.m_ui32DestIP = +#if BOOST_VERSION < 108700 + ip::address_v4::from_string(config_->get_rtp_mcast_base().c_str()) + .to_ulong() + +#else ip::make_address(config_->get_rtp_mcast_base().c_str()) .to_v4() .to_uint() + +#endif source.id; } info.stream.m_usSrcPort = config_->get_rtp_port(); From dbaca1e213cb8302bf497dba2d634fe1cbf09d50 Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Fri, 28 Feb 2025 17:57:14 +0100 Subject: [PATCH 7/8] Added tests/daemon_test.cpp --- daemon/tests/daemon_test.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/daemon/tests/daemon_test.cpp b/daemon/tests/daemon_test.cpp index 12cc24c..a539e5e 100644 --- a/daemon/tests/daemon_test.cpp +++ b/daemon/tests/daemon_test.cpp @@ -97,9 +97,14 @@ struct Client { socket_.set_option(udp::socket::reuse_address(true)); socket_.bind(listen_endpoint_); socket_.set_option( +#if BOOST_VERSION < 108700 + multicast::join_group(address::from_string(g_sap_address).to_v4(), + address::from_string(g_daemon_address).to_v4()) +#else multicast::join_group(make_address(g_sap_address).to_v4(), - make_address(g_daemon_address).to_v4())); - + make_address(g_daemon_address).to_v4()) +#endif + ); cli_.set_connection_timeout(30); cli_.set_read_timeout(30); cli_.set_write_timeout(30); @@ -362,10 +367,18 @@ struct Client { private: httplib::Client cli_{g_daemon_address, g_daemon_port}; +#if BOOST_VERSION < 108700 + io_service io_service_; +#else io_context io_service_; +#endif udp::socket socket_{io_service_}; udp::endpoint listen_endpoint_{ +#if BOOST_VERSION < 108700 + udp::endpoint(address::from_string("0.0.0.0"), g_sap_port)}; +#else udp::endpoint(make_address("0.0.0.0"), g_sap_port)}; +#endif }; BOOST_AUTO_TEST_CASE(is_alive) { From 396648df9b004043dd594b003bdd5bd85d6f2a69 Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Tue, 4 Mar 2025 16:49:22 +0100 Subject: [PATCH 8/8] Changed daemon version to v2.0.3 --- daemon/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index bfaec6b..429f55c 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -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.2"); +static const std::string version("bondagit-2.0.3"); static std::atomic terminate = false; void termination_handler(int signum) {