Replace ip::address::to_string() with ip::make_address() to support Boost 1.87, see #197

This commit is contained in:
Andrea Bondavalli 2025-02-27 20:06:17 +01:00
parent 201cf28196
commit efcf95522b
8 changed files with 22 additions and 23 deletions

View File

@ -79,11 +79,11 @@ std::shared_ptr<Config> Config::parse(const std::string& filename,
config.streamer_player_buffer_files_num_ = 1; config.streamer_player_buffer_files_num_ = 1;
boost::system::error_code ec; 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) { if (ec) {
config.rtp_mcast_base_ = "239.1.0.1"; 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) { if (ec) {
config.sap_mcast_addr_ = "224.2.127.254"; config.sap_mcast_addr_ = "224.2.127.254";
} }

View File

@ -40,7 +40,7 @@ class IGMP {
bool join(const std::string& interface_ip, const std::string& mcast_ip) { bool join(const std::string& interface_ip, const std::string& mcast_ip) {
uint32_t mcast_ip_addr = 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<std::mutex> lock{mutex}; std::scoped_lock<std::mutex> lock{mutex};
auto it = mcast_ref.find(mcast_ip_addr); auto it = mcast_ref.find(mcast_ip_addr);
@ -50,9 +50,8 @@ class IGMP {
} }
error_code ec; error_code ec;
ip::multicast::join_group option( ip::multicast::join_group option(ip::make_address(mcast_ip).to_v4(),
ip::address::from_string(mcast_ip).to_v4(), ip::make_address(interface_ip).to_v4());
ip::address::from_string(interface_ip).to_v4());
socket_.set_option(option, ec); socket_.set_option(option, ec);
if (ec) { if (ec) {
BOOST_LOG_TRIVIAL(error) << "igmp:: failed to joined multicast group " 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) { bool leave(const std::string& interface_ip, const std::string& mcast_ip) {
uint32_t mcast_ip_addr = 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<std::mutex> lock{mutex}; std::scoped_lock<std::mutex> lock{mutex};
auto it = mcast_ref.find(mcast_ip_addr); auto it = mcast_ref.find(mcast_ip_addr);
@ -88,9 +87,8 @@ class IGMP {
} }
error_code ec; error_code ec;
ip::multicast::leave_group option( ip::multicast::leave_group option(ip::make_address(mcast_ip).to_v4(),
ip::address::from_string(mcast_ip).to_v4(), ip::make_address(interface_ip).to_v4());
ip::address::from_string(interface_ip).to_v4());
socket_.set_option(option, ec); socket_.set_option(option, ec);
if (ec) { if (ec) {
BOOST_LOG_TRIVIAL(error) << "igmp:: failed to leave multicast group " BOOST_LOG_TRIVIAL(error) << "igmp:: failed to leave multicast group "

View File

@ -171,7 +171,7 @@ bool ping(const std::string& ip) {
io_context io_service; io_context io_service;
icmp::socket socket{io_service, icmp::v4()}; icmp::socket socket{io_service, icmp::v4()};
ip::icmp::endpoint destination(ip::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); socket.send_to(boost::asio::buffer(buffer, sizeof buffer), destination);
} catch (...) { } catch (...) {
BOOST_LOG_TRIVIAL(error) << "ping:: send_to() failed"; BOOST_LOG_TRIVIAL(error) << "ping:: send_to() failed";

View File

@ -206,7 +206,7 @@ std::pair<bool, RtspSource> RtspClient::process(
<< crc16(reinterpret_cast<const uint8_t*>(res.body.c_str()), << crc16(reinterpret_cast<const uint8_t*>(res.body.c_str()),
res.body.length()); res.body.length());
/*<< std::hex << /*<< 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.id = ss.str();
rtsp_source.source = "mDNS"; rtsp_source.source = "mDNS";
rtsp_source.address = address; rtsp_source.address = address;

View File

@ -89,9 +89,9 @@ class RtspServer {
: session_manager_(session_manager), : session_manager_(session_manager),
config_(config), config_(config),
acceptor_(io_service_, acceptor_(io_service_,
tcp::endpoint(boost::asio::ip::address::from_string( tcp::endpoint(
config_->get_ip_addr_str()), boost::asio::ip::make_address(config_->get_ip_addr_str()),
config_->get_rtsp_port())) {} config_->get_rtsp_port())) {}
bool init() { bool init() {
accept(); accept();
/* start rtsp server on a separate thread */ /* start rtsp server on a separate thread */

View File

@ -27,7 +27,7 @@ using namespace boost::asio::ip;
SAP::SAP(const std::string& sap_mcast_addr) SAP::SAP(const std::string& sap_mcast_addr)
: addr_(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_.open(boost::asio::ip::udp::v4());
socket_.set_option(udp::socket::reuse_address(true)); 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) { 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); ip::multicast::outbound_interface oi_option(local_interface);
boost::system::error_code ec; boost::system::error_code ec;
socket_.set_option(oi_option, ec); socket_.set_option(oi_option, ec);

View File

@ -65,9 +65,9 @@ class SAP {
io_context io_service_; io_context io_service_;
ip::udp::socket socket_{io_service_}; ip::udp::socket socket_{io_service_};
ip::udp::endpoint remote_endpoint_{ 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 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_}; deadline_timer deadline_{io_service_};
}; };

View File

@ -255,7 +255,7 @@ bool SessionManager::parse_sdp(const std::string& sdp, StreamInfo& info) const {
return false; return false;
} }
info.stream.m_ui32DestIP = 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) { if (info.stream.m_ui32DestIP == INADDR_NONE) {
BOOST_LOG_TRIVIAL(error) << "session_manager:: invalid IPv4 " BOOST_LOG_TRIVIAL(error) << "session_manager:: invalid IPv4 "
"connection address in SDP at line " "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_ui32RTCPSrcIP = config_->get_ip_addr();
info.stream.m_ui32SrcIP = config_->get_ip_addr(); // only for Source info.stream.m_ui32SrcIP = config_->get_ip_addr(); // only for Source
boost::system::error_code ec; boost::system::error_code ec;
ip::address_v4::from_string(source.address, ec); ip::make_address(source.address, ec);
if (!ec) { if (!ec) {
info.stream.m_ui32DestIP = info.stream.m_ui32DestIP =
ip::address_v4::from_string(source.address).to_ulong(); ip::make_address(source.address).to_v4().to_ulong();
} else { } else {
info.stream.m_ui32DestIP = 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() + .to_ulong() +
source.id; source.id;
} }