Set of changes to keep compatibility between boost version 1.87 and earlier versions
This commit is contained in:
parent
6ff785a8d2
commit
1e652a046d
@ -79,11 +79,19 @@ std::shared_ptr<Config> 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";
|
||||
}
|
||||
|
@ -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<std::mutex> 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<std::mutex> 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<uint32_t, int> mcast_ref;
|
||||
|
@ -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";
|
||||
|
@ -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<nl_protocol> socket_{io_service_};
|
||||
deadline_timer deadline_{io_service_};
|
||||
std::string name_;
|
||||
|
@ -205,8 +205,6 @@ std::pair<bool, RtspSource> RtspClient::process(
|
||||
ss << "rtsp:" << std::hex
|
||||
<< crc16(reinterpret_cast<const uint8_t*>(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;
|
||||
|
@ -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<SessionManager> session_manager_;
|
||||
std::shared_ptr<Config> config_;
|
||||
std::vector<std::weak_ptr<RtspSession> > sessions_{session_num_max};
|
||||
|
@ -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);
|
||||
|
@ -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_};
|
||||
};
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user