Skip to content

Commit 1e652a0

Browse files
committed
Set of changes to keep compatibility between boost version 1.87 and earlier versions
1 parent 6ff785a commit 1e652a0

File tree

9 files changed

+91
-10
lines changed

9 files changed

+91
-10
lines changed

daemon/config.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,19 @@ std::shared_ptr<Config> Config::parse(const std::string& filename,
7979
config.streamer_player_buffer_files_num_ = 1;
8080

8181
boost::system::error_code ec;
82+
#if BOOST_VERSION < 108700
83+
ip::address_v4::from_string(config.rtp_mcast_base_.c_str(), ec);
84+
#else
8285
ip::make_address(config.rtp_mcast_base_.c_str(), ec);
86+
#endif
8387
if (ec) {
8488
config.rtp_mcast_base_ = "239.1.0.1";
8589
}
90+
#if BOOST_VERSION < 108700
91+
ip::address_v4::from_string(config.sap_mcast_addr_.c_str(), ec);
92+
#else
8693
ip::make_address(config.sap_mcast_addr_.c_str(), ec);
94+
#endif
8795
if (ec) {
8896
config.sap_mcast_addr_ = "224.2.127.254";
8997
}

daemon/igmp.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ class IGMP {
4040

4141
bool join(const std::string& interface_ip, const std::string& mcast_ip) {
4242
uint32_t mcast_ip_addr =
43+
#if BOOST_VERSION < 108700
44+
ip::address_v4::from_string(mcast_ip.c_str()).to_ulong();
45+
#else
4346
ip::make_address(mcast_ip.c_str()).to_v4().to_uint();
47+
#endif
4448
std::scoped_lock<std::mutex> lock{mutex};
4549

4650
auto it = mcast_ref.find(mcast_ip_addr);
@@ -50,8 +54,14 @@ class IGMP {
5054
}
5155

5256
error_code ec;
57+
#if BOOST_VERSION < 108700
58+
ip::multicast::join_group option(
59+
ip::address::from_string(mcast_ip).to_v4(),
60+
ip::address::from_string(interface_ip).to_v4());
61+
#else
5362
ip::multicast::join_group option(ip::make_address(mcast_ip).to_v4(),
5463
ip::make_address(interface_ip).to_v4());
64+
#endif
5565
socket_.set_option(option, ec);
5666
if (ec) {
5767
BOOST_LOG_TRIVIAL(error) << "igmp:: failed to joined multicast group "
@@ -74,7 +84,11 @@ class IGMP {
7484

7585
bool leave(const std::string& interface_ip, const std::string& mcast_ip) {
7686
uint32_t mcast_ip_addr =
87+
#if BOOST_VERSION < 108700
88+
ip::address_v4::from_string(mcast_ip.c_str()).to_ulong();
89+
#else
7790
ip::make_address(mcast_ip.c_str()).to_v4().to_uint();
91+
#endif
7892
std::scoped_lock<std::mutex> lock{mutex};
7993

8094
auto it = mcast_ref.find(mcast_ip_addr);
@@ -87,8 +101,15 @@ class IGMP {
87101
}
88102

89103
error_code ec;
104+
105+
#if BOOST_VERSION < 108700
106+
ip::multicast::leave_group option(
107+
ip::address::from_string(mcast_ip).to_v4(),
108+
ip::address::from_string(interface_ip).to_v4());
109+
#else
90110
ip::multicast::leave_group option(ip::make_address(mcast_ip).to_v4(),
91111
ip::make_address(interface_ip).to_v4());
112+
#endif
92113
socket_.set_option(option, ec);
93114
if (ec) {
94115
BOOST_LOG_TRIVIAL(error) << "igmp:: failed to leave multicast group "
@@ -102,7 +123,11 @@ class IGMP {
102123
}
103124

104125
private:
126+
#if BOOST_VERSION < 108700
127+
io_service io_service_;
128+
#else
105129
io_context io_service_;
130+
#endif
106131
ip::udp::socket socket_{io_service_};
107132
udp::endpoint listen_endpoint_{udp::endpoint(address_v4::any(), 0)};
108133
std::unordered_map<uint32_t, int> mcast_ref;

daemon/interface.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ bool ping(const std::string& ip) {
171171
io_context io_service;
172172
icmp::socket socket{io_service, icmp::v4()};
173173
ip::icmp::endpoint destination(ip::icmp::v4(),
174+
#if BOOST_VERSION < 108700
175+
ip::address_v4::from_string(ip).to_ulong());
176+
#else
174177
ip::make_address(ip).to_v4().to_uint());
178+
#endif
175179
socket.send_to(boost::asio::buffer(buffer, sizeof buffer), destination);
176180
} catch (...) {
177181
BOOST_LOG_TRIVIAL(error) << "ping:: send_to() failed";

daemon/netlink_client.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ class NetlinkClient {
9393
}
9494

9595
private:
96+
#if BOOST_VERSION < 108700
97+
boost::asio::io_service io_service_;
98+
#else
9699
boost::asio::io_context io_service_;
100+
#endif
97101
boost::asio::basic_raw_socket<nl_protocol> socket_{io_service_};
98102
deadline_timer deadline_{io_service_};
99103
std::string name_;

daemon/rtsp_client.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ std::pair<bool, RtspSource> RtspClient::process(
205205
ss << "rtsp:" << std::hex
206206
<< crc16(reinterpret_cast<const uint8_t*>(res.body.c_str()),
207207
res.body.length());
208-
/*<< std::hex <<
209-
* ip::make_address(address.c_str()).to_uint();*/
210208
rtsp_source.id = ss.str();
211209
rtsp_source.source = "mDNS";
212210
rtsp_source.address = address;

daemon/rtsp_server.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ class RtspServer {
9090
config_(config),
9191
acceptor_(io_service_,
9292
tcp::endpoint(
93+
#if BOOST_VERSION < 108700
94+
boost::asio::ip::address::from_string(config_->get_ip_addr_str()),
95+
#else
9396
boost::asio::ip::make_address(config_->get_ip_addr_str()),
97+
#endif
9498
config_->get_rtsp_port())) {}
9599
bool init() {
96100
accept();
@@ -125,7 +129,11 @@ class RtspServer {
125129
void accept();
126130

127131
std::mutex mutex_;
132+
#if BOOST_VERSION < 108700
133+
boost::asio::io_service io_service_;
134+
#else
128135
boost::asio::io_context io_service_;
136+
#endif
129137
std::shared_ptr<SessionManager> session_manager_;
130138
std::shared_ptr<Config> config_;
131139
std::vector<std::weak_ptr<RtspSession> > sessions_{session_num_max};

daemon/sap.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@ using namespace boost::placeholders;
2525
using namespace boost::asio;
2626
using namespace boost::asio::ip;
2727

28-
SAP::SAP(const std::string& sap_mcast_addr)
29-
: addr_(sap_mcast_addr)
30-
// remote_endpoint_(ip::make_address(addr_), port)
31-
{
28+
SAP::SAP(const std::string& sap_mcast_addr) : addr_(sap_mcast_addr) {
3229
socket_.open(boost::asio::ip::udp::v4());
3330
socket_.set_option(udp::socket::reuse_address(true));
3431
socket_.bind(listen_endpoint_);
3532
check_deadline();
3633
}
3734

3835
bool SAP::set_multicast_interface(const std::string& interface_ip) {
36+
#if BOOST_VERSION < 108700
37+
ip::address_v4 local_interface = ip::address_v4::from_string(interface_ip);
38+
#else
3939
ip::address_v4 local_interface = ip::make_address(interface_ip).to_v4();
40+
#endif
4041
ip::multicast::outbound_interface oi_option(local_interface);
4142
boost::system::error_code ec;
4243
socket_.set_option(oi_option, ec);

daemon/sap.hpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,27 @@ class SAP {
6262
const std::string& sdp);
6363

6464
std::string addr_;
65+
#if BOOST_VERSION < 108700
66+
io_service io_service_;
67+
#else
6568
io_context io_service_;
69+
#endif
6670
ip::udp::socket socket_{io_service_};
67-
ip::udp::endpoint remote_endpoint_{
68-
ip::udp::endpoint(ip::make_address(addr_), port)};
69-
ip::udp::endpoint listen_endpoint_{
70-
ip::udp::endpoint(ip::make_address("0.0.0.0"), port)};
71+
ip::udp::endpoint remote_endpoint_ {
72+
#if BOOST_VERSION < 108700
73+
ip::udp::endpoint(ip::address::from_string(addr_), port)
74+
#else
75+
ip::udp::endpoint(ip::make_address(addr_), port)
76+
#endif
77+
};
78+
ip::udp::endpoint listen_endpoint_ {
79+
#if BOOST_VERSION < 108700
80+
ip::udp::endpoint(ip::address::from_string("0.0.0.0"), port)
81+
};
82+
#else
83+
ip::udp::endpoint(ip::make_address("0.0.0.0"), port)
84+
};
85+
#endif
7186
deadline_timer deadline_{io_service_};
7287
};
7388

daemon/session_manager.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,12 @@ bool SessionManager::parse_sdp(const std::string& sdp, StreamInfo& info) const {
255255
return false;
256256
}
257257
info.stream.m_ui32DestIP =
258+
#if BOOST_VERSION < 108700
259+
ip::address_v4::from_string(fields[2].c_str()).to_ulong();
260+
#else
261+
258262
ip::make_address(fields[2].c_str()).to_v4().to_uint();
263+
#endif
259264
if (info.stream.m_ui32DestIP == INADDR_NONE) {
260265
BOOST_LOG_TRIVIAL(error) << "session_manager:: invalid IPv4 "
261266
"connection address in SDP at line "
@@ -524,15 +529,28 @@ std::error_code SessionManager::add_source(const StreamSource& source) {
524529
info.stream.m_ui32RTCPSrcIP = config_->get_ip_addr();
525530
info.stream.m_ui32SrcIP = config_->get_ip_addr(); // only for Source
526531
boost::system::error_code ec;
532+
#if BOOST_VERSION < 108700
533+
ip::address_v4::from_string(source.address, ec);
534+
#else
527535
ip::make_address(source.address, ec);
536+
#endif
528537
if (!ec) {
529538
info.stream.m_ui32DestIP =
539+
#if BOOST_VERSION < 108700
540+
ip::address_v4::from_string(source.address).to_ulong();
541+
#else
530542
ip::make_address(source.address).to_v4().to_uint();
543+
#endif
531544
} else {
532545
info.stream.m_ui32DestIP =
546+
#if BOOST_VERSION < 108700
547+
ip::address_v4::from_string(config_->get_rtp_mcast_base().c_str())
548+
.to_ulong() +
549+
#else
533550
ip::make_address(config_->get_rtp_mcast_base().c_str())
534551
.to_v4()
535552
.to_uint() +
553+
#endif
536554
source.id;
537555
}
538556
info.stream.m_usSrcPort = config_->get_rtp_port();

0 commit comments

Comments
 (0)