multiplex: remove remote_sockaddr (4 and 6) from socket along with functions that used them
This commit is contained in:
parent
4d56a20943
commit
de82b282a5
|
@ -397,7 +397,6 @@ namespace uvgrtp {
|
|||
bool ipv6_;
|
||||
rtp_format_t fmt_;
|
||||
bool new_socket_;
|
||||
bool hooked_;
|
||||
|
||||
/* Media context config */
|
||||
int rce_flags_ = 0;
|
||||
|
|
|
@ -97,7 +97,9 @@ uvgrtp::formats::h26x::h26x(std::shared_ptr<uvgrtp::socket> socket, std::shared_
|
|||
completed_ts_(),
|
||||
rtp_ctx_(rtp),
|
||||
last_garbage_collection_(uvgrtp::clock::hrc::now()),
|
||||
discard_until_key_frame_(true)
|
||||
discard_until_key_frame_(true),
|
||||
remote_sockaddr_({}),
|
||||
remote_sockaddr_ip6_({})
|
||||
{}
|
||||
|
||||
uvgrtp::formats::h26x::~h26x()
|
||||
|
@ -382,7 +384,7 @@ rtp_error_t uvgrtp::formats::h26x::push_media_frame(uint8_t* data, size_t data_l
|
|||
}
|
||||
|
||||
// actually send the packets
|
||||
ret = fqueue_->flush_queue();
|
||||
ret = fqueue_->flush_queue(remote_sockaddr_, remote_sockaddr_ip6_);
|
||||
clear_aggregation_info();
|
||||
|
||||
return ret;
|
||||
|
@ -739,6 +741,14 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int rce_flags, uvgrtp::frame::
|
|||
return RTP_OK; // no frame was completed, but everything went ok for this fragment
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::formats::h26x::set_remote_addr(sockaddr_in& addr, sockaddr_in6& addr6)
|
||||
{
|
||||
remote_sockaddr_ = addr;
|
||||
remote_sockaddr_ip6_ = addr6;
|
||||
return RTP_OK;
|
||||
}
|
||||
|
||||
|
||||
void uvgrtp::formats::h26x::garbage_collect_lost_frames(size_t timout)
|
||||
{
|
||||
if (uvgrtp::clock::hrc::diff_now(last_garbage_collection_) >= GARBAGE_COLLECTION_INTERVAL_MS) {
|
||||
|
|
|
@ -10,6 +10,12 @@
|
|||
#include <deque>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#ifdef _WIN32
|
||||
#include <mswsock.h>
|
||||
#include <ws2ipdef.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
namespace uvgrtp {
|
||||
|
||||
|
@ -109,6 +115,12 @@ namespace uvgrtp {
|
|||
* Return RTP_GENERIC_ERROR if the packet was corrupted in some way */
|
||||
rtp_error_t packet_handler(int rce_flags, frame::rtp_frame** frame);
|
||||
|
||||
/// \cond DO_NOT_DOCUMENT
|
||||
|
||||
rtp_error_t set_remote_addr(sockaddr_in& addr, sockaddr_in6& addr6);
|
||||
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
|
||||
/* Handles small packets. May support aggregate packets or not*/
|
||||
|
@ -182,6 +194,9 @@ namespace uvgrtp {
|
|||
uvgrtp::clock::hrc::hrc_t last_garbage_collection_;
|
||||
|
||||
bool discard_until_key_frame_ = true;
|
||||
|
||||
sockaddr_in remote_sockaddr_;
|
||||
sockaddr_in6 remote_sockaddr_ip6_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,23 +21,26 @@ uvgrtp::formats::media::~media()
|
|||
fqueue_ = nullptr;
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::formats::media::push_frame(uint8_t *data, size_t data_len, int rtp_flags)
|
||||
rtp_error_t uvgrtp::formats::media::push_frame(sockaddr_in& addr, sockaddr_in6& addr6,
|
||||
uint8_t *data, size_t data_len, int rtp_flags)
|
||||
{
|
||||
if (!data || !data_len)
|
||||
return RTP_INVALID_VALUE;
|
||||
|
||||
return push_media_frame(data, data_len, rtp_flags);
|
||||
return push_media_frame(addr, addr6, data, data_len, rtp_flags);
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::formats::media::push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int rtp_flags)
|
||||
rtp_error_t uvgrtp::formats::media::push_frame(sockaddr_in& addr, sockaddr_in6& addr6,
|
||||
std::unique_ptr<uint8_t[]> data, size_t data_len, int rtp_flags)
|
||||
{
|
||||
if (!data || !data_len)
|
||||
return RTP_INVALID_VALUE;
|
||||
|
||||
return push_media_frame(data.get(), data_len, rtp_flags);
|
||||
return push_media_frame(addr, addr6, data.get(), data_len, rtp_flags);
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::formats::media::push_media_frame(uint8_t *data, size_t data_len, int rtp_flags)
|
||||
rtp_error_t uvgrtp::formats::media::push_media_frame(sockaddr_in& addr, sockaddr_in6& addr6,
|
||||
uint8_t *data, size_t data_len, int rtp_flags)
|
||||
{
|
||||
(void)rtp_flags;
|
||||
|
||||
|
@ -69,7 +72,7 @@ rtp_error_t uvgrtp::formats::media::push_media_frame(uint8_t *data, size_t data_
|
|||
return ret;
|
||||
}
|
||||
|
||||
return fqueue_->flush_queue();
|
||||
return fqueue_->flush_queue(addr, addr6);
|
||||
}
|
||||
|
||||
size_t payload_size = rtp_ctx_->get_payload_size();
|
||||
|
@ -92,7 +95,7 @@ rtp_error_t uvgrtp::formats::media::push_media_frame(uint8_t *data, size_t data_
|
|||
return ret;
|
||||
}
|
||||
|
||||
return fqueue_->flush_queue();
|
||||
return fqueue_->flush_queue(addr, addr6);
|
||||
}
|
||||
|
||||
uvgrtp::formats::media_frame_info_t *uvgrtp::formats::media::get_media_frame_info()
|
||||
|
|
|
@ -7,6 +7,13 @@
|
|||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <mswsock.h>
|
||||
#include <ws2ipdef.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
namespace uvgrtp {
|
||||
|
||||
class socket;
|
||||
|
@ -47,8 +54,8 @@ namespace uvgrtp {
|
|||
* implement if they require more processing than what the default implementation offers
|
||||
*
|
||||
* Return RTP_OK on success */
|
||||
rtp_error_t push_frame(uint8_t *data, size_t data_len, int rtp_flags);
|
||||
rtp_error_t push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int rtp_flags);
|
||||
rtp_error_t push_frame(sockaddr_in& addr, sockaddr_in6& addr6, uint8_t *data, size_t data_len, int rtp_flags);
|
||||
rtp_error_t push_frame(sockaddr_in& addr, sockaddr_in6& addr6, std::unique_ptr<uint8_t[]> data, size_t data_len, int rtp_flags);
|
||||
|
||||
/* Media-specific packet handler. The default handler, depending on what "rce_flags_" contains,
|
||||
* may only return the received RTP packet or it may merge multiple packets together before
|
||||
|
@ -68,7 +75,7 @@ namespace uvgrtp {
|
|||
void set_fps(ssize_t enumarator, ssize_t denominator);
|
||||
|
||||
protected:
|
||||
virtual rtp_error_t push_media_frame(uint8_t *data, size_t data_len, int rtp_flags);
|
||||
virtual rtp_error_t push_media_frame(sockaddr_in& addr, sockaddr_in6& addr6, uint8_t *data, size_t data_len, int rtp_flags);
|
||||
|
||||
std::shared_ptr<uvgrtp::socket> socket_;
|
||||
std::shared_ptr<uvgrtp::rtp> rtp_ctx_;
|
||||
|
|
|
@ -268,7 +268,7 @@ rtp_error_t uvgrtp::frame_queue::enqueue_message(buf_vec& buffers)
|
|||
return RTP_OK;
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::frame_queue::flush_queue()
|
||||
rtp_error_t uvgrtp::frame_queue::flush_queue(sockaddr_in& addr, sockaddr_in6& addr6)
|
||||
{
|
||||
if (active_->packets.empty()) {
|
||||
UVG_LOG_ERROR("Cannot send an empty packet!");
|
||||
|
@ -340,7 +340,7 @@ rtp_error_t uvgrtp::frame_queue::flush_queue()
|
|||
std::this_thread::sleep_for(next_packet - std::chrono::high_resolution_clock::now());
|
||||
|
||||
// send pkt vects
|
||||
if (socket_->sendto(active_->packets[i], 0) != RTP_OK) {
|
||||
if (socket_->sendto(addr, addr6, active_->packets[i], 0) != RTP_OK) {
|
||||
UVG_LOG_ERROR("Failed to send packet: %li", errno);
|
||||
(void)deinit_transaction();
|
||||
return RTP_SEND_ERROR;
|
||||
|
@ -348,7 +348,7 @@ rtp_error_t uvgrtp::frame_queue::flush_queue()
|
|||
}
|
||||
|
||||
}
|
||||
else if (socket_->sendto(active_->packets, 0) != RTP_OK) {
|
||||
else if (socket_->sendto(addr, addr6, active_->packets, 0) != RTP_OK) {
|
||||
UVG_LOG_ERROR("Failed to flush the message queue: %li", errno);
|
||||
(void)deinit_transaction();
|
||||
return RTP_SEND_ERROR;
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace uvgrtp {
|
|||
* Return RTP_OK on success
|
||||
* Return RTP_INVALID_VALUE if "sender" is nullptr or message buffer is empty
|
||||
* return RTP_SEND_ERROR if send fails */
|
||||
rtp_error_t flush_queue();
|
||||
rtp_error_t flush_queue(sockaddr_in& addr, sockaddr_in6& addr6);
|
||||
|
||||
/* Media may have extra headers (f.ex. NAL and FU headers for HEVC).
|
||||
* These headers must be valid until the message is sent (ie. they cannot be saved to
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
uvgrtp::holepuncher::holepuncher(std::shared_ptr<uvgrtp::socket> socket):
|
||||
socket_(socket),
|
||||
last_dgram_sent_(0),
|
||||
remote_sockaddr_({}),
|
||||
remote_sockaddr_ip6_({}),
|
||||
active_(false)
|
||||
{}
|
||||
|
||||
|
@ -36,6 +38,14 @@ rtp_error_t uvgrtp::holepuncher::stop()
|
|||
return RTP_OK;
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::holepuncher::set_remote_address(sockaddr_in& addr, sockaddr_in6& addr6)
|
||||
{
|
||||
remote_sockaddr_ = addr;
|
||||
remote_sockaddr_ip6_ = addr6;
|
||||
return RTP_OK;
|
||||
}
|
||||
|
||||
|
||||
void uvgrtp::holepuncher::notify()
|
||||
{
|
||||
last_dgram_sent_ = uvgrtp::clock::ntp::now();
|
||||
|
@ -54,7 +64,7 @@ void uvgrtp::holepuncher::keepalive()
|
|||
|
||||
UVG_LOG_DEBUG("Sending keep-alive");
|
||||
uint8_t payload = 0x00;
|
||||
socket_->sendto(&payload, 1, 0);
|
||||
socket_->sendto(remote_sockaddr_, remote_sockaddr_ip6_, &payload, 1, 0);
|
||||
last_dgram_sent_ = uvgrtp::clock::ntp::now();
|
||||
}
|
||||
UVG_LOG_DEBUG("Stopping holepuncher");
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#ifdef _WIN32
|
||||
#include <mswsock.h>
|
||||
#include <ws2ipdef.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
namespace uvgrtp {
|
||||
|
||||
|
@ -23,6 +29,7 @@ namespace uvgrtp {
|
|||
|
||||
/* Stop the holepuncher */
|
||||
rtp_error_t stop();
|
||||
rtp_error_t set_remote_address(sockaddr_in& addr, sockaddr_in6& addr6);
|
||||
|
||||
/* Notify the holepuncher that application has called push_frame()
|
||||
* and keepalive functionality is not needed for the following time period */
|
||||
|
@ -33,6 +40,8 @@ namespace uvgrtp {
|
|||
|
||||
std::shared_ptr<uvgrtp::socket> socket_;
|
||||
std::atomic<uint64_t> last_dgram_sent_;
|
||||
sockaddr_in remote_sockaddr_;
|
||||
sockaddr_in6 remote_sockaddr_ip6_;
|
||||
|
||||
bool active_;
|
||||
std::unique_ptr<std::thread> runner_;
|
||||
|
|
|
@ -49,7 +49,6 @@ uvgrtp::media_stream::media_stream(std::string cname, std::string remote_addr,
|
|||
ipv6_(false),
|
||||
fmt_(fmt),
|
||||
new_socket_(false),
|
||||
hooked_(false),
|
||||
rce_flags_(rce_flags),
|
||||
initialized_(false),
|
||||
rtp_handler_key_(0),
|
||||
|
@ -115,12 +114,11 @@ rtp_error_t uvgrtp::media_stream::init_connection()
|
|||
// no reason to fail sending even if binding fails so we set remote address first
|
||||
if (ipv6_) {
|
||||
remote_sockaddr_ip6_ = socket_->create_ip6_sockaddr(remote_address_, dst_port_);
|
||||
socket_->set_sockaddr6(remote_sockaddr_ip6_);
|
||||
}
|
||||
else {
|
||||
remote_sockaddr_ = socket_->create_sockaddr(AF_INET, remote_address_, dst_port_);
|
||||
socket_->set_sockaddr(remote_sockaddr_);
|
||||
}
|
||||
}
|
||||
holepuncher_->set_remote_address(remote_sockaddr_, remote_sockaddr_ip6_);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -177,6 +175,7 @@ rtp_error_t uvgrtp::media_stream::create_media(rtp_format_t fmt)
|
|||
case RTP_FORMAT_H264:
|
||||
{
|
||||
uvgrtp::formats::h264* format_264 = new uvgrtp::formats::h264(socket_, rtp_, rce_flags_);
|
||||
format_264->set_remote_addr(remote_sockaddr_, remote_sockaddr_ip6_);
|
||||
reception_flow_->install_aux_handler_cpp(
|
||||
rtp_handler_key_,
|
||||
std::bind(&uvgrtp::formats::h264::packet_handler, format_264, std::placeholders::_1, std::placeholders::_2),
|
||||
|
@ -187,6 +186,7 @@ rtp_error_t uvgrtp::media_stream::create_media(rtp_format_t fmt)
|
|||
case RTP_FORMAT_H265:
|
||||
{
|
||||
uvgrtp::formats::h265* format_265 = new uvgrtp::formats::h265(socket_, rtp_, rce_flags_);
|
||||
format_265->set_remote_addr(remote_sockaddr_, remote_sockaddr_ip6_);
|
||||
reception_flow_->install_aux_handler_cpp(
|
||||
rtp_handler_key_,
|
||||
std::bind(&uvgrtp::formats::h265::packet_handler, format_265, std::placeholders::_1, std::placeholders::_2),
|
||||
|
@ -197,6 +197,7 @@ rtp_error_t uvgrtp::media_stream::create_media(rtp_format_t fmt)
|
|||
case RTP_FORMAT_H266:
|
||||
{
|
||||
uvgrtp::formats::h266* format_266 = new uvgrtp::formats::h266(socket_, rtp_, rce_flags_);
|
||||
format_266->set_remote_addr(remote_sockaddr_, remote_sockaddr_ip6_);
|
||||
reception_flow_->install_aux_handler_cpp(
|
||||
rtp_handler_key_,
|
||||
std::bind(&uvgrtp::formats::h266::packet_handler, format_266, std::placeholders::_1, std::placeholders::_2),
|
||||
|
@ -475,11 +476,11 @@ rtp_error_t uvgrtp::media_stream::push_frame(uint8_t *data, size_t data_len, int
|
|||
{
|
||||
data = copy_frame(data, data_len);
|
||||
std::unique_ptr<uint8_t[]> data_copy(data);
|
||||
ret = media_->push_frame(std::move(data_copy), data_len, rtp_flags);
|
||||
ret = media_->push_frame(remote_sockaddr_, remote_sockaddr_ip6_, std::move(data_copy), data_len, rtp_flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = media_->push_frame(data, data_len, rtp_flags);
|
||||
ret = media_->push_frame(remote_sockaddr_, remote_sockaddr_ip6_, data, data_len, rtp_flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -495,7 +496,7 @@ rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, si
|
|||
holepuncher_->notify();
|
||||
|
||||
// making a copy of a smart pointer does not make sense
|
||||
ret = media_->push_frame(std::move(data), data_len, rtp_flags);
|
||||
ret = media_->push_frame(remote_sockaddr_, remote_sockaddr_ip6_, std::move(data), data_len, rtp_flags);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -514,11 +515,11 @@ rtp_error_t uvgrtp::media_stream::push_frame(uint8_t *data, size_t data_len, uin
|
|||
{
|
||||
data = copy_frame(data, data_len);
|
||||
std::unique_ptr<uint8_t[]> data_copy(data);
|
||||
ret = media_->push_frame(std::move(data_copy), data_len, rtp_flags);
|
||||
ret = media_->push_frame(remote_sockaddr_, remote_sockaddr_ip6_, std::move(data_copy), data_len, rtp_flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = media_->push_frame(data, data_len, rtp_flags);
|
||||
ret = media_->push_frame(remote_sockaddr_, remote_sockaddr_ip6_, data, data_len, rtp_flags);
|
||||
}
|
||||
rtp_->set_timestamp(INVALID_TS);
|
||||
}
|
||||
|
@ -540,11 +541,11 @@ rtp_error_t uvgrtp::media_stream::push_frame(uint8_t* data, size_t data_len, uin
|
|||
{
|
||||
data = copy_frame(data, data_len);
|
||||
std::unique_ptr<uint8_t[]> data_copy(data);
|
||||
ret = media_->push_frame(std::move(data_copy), data_len, rtp_flags);
|
||||
ret = media_->push_frame(remote_sockaddr_, remote_sockaddr_ip6_, std::move(data_copy), data_len, rtp_flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = media_->push_frame(data, data_len, rtp_flags);
|
||||
ret = media_->push_frame(remote_sockaddr_, remote_sockaddr_ip6_, data, data_len, rtp_flags);
|
||||
}
|
||||
rtp_->set_timestamp(INVALID_TS);
|
||||
}
|
||||
|
@ -562,7 +563,7 @@ rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, si
|
|||
|
||||
// making a copy of a smart pointer does not make sense
|
||||
rtp_->set_timestamp(ts);
|
||||
ret = media_->push_frame(std::move(data), data_len, rtp_flags);
|
||||
ret = media_->push_frame(remote_sockaddr_, remote_sockaddr_ip6_, std::move(data), data_len, rtp_flags);
|
||||
rtp_->set_timestamp(INVALID_TS);
|
||||
}
|
||||
|
||||
|
@ -580,7 +581,7 @@ rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, si
|
|||
// making a copy of a smart pointer does not make sense
|
||||
rtp_->set_timestamp(ts);
|
||||
rtp_->set_sampling_ntp(ntp_ts);
|
||||
ret = media_->push_frame(std::move(data), data_len, rtp_flags);
|
||||
ret = media_->push_frame(remote_sockaddr_, remote_sockaddr_ip6_, std::move(data), data_len, rtp_flags);
|
||||
rtp_->set_timestamp(INVALID_TS);
|
||||
}
|
||||
|
||||
|
@ -667,7 +668,6 @@ rtp_error_t uvgrtp::media_stream::install_receive_hook(void *arg, void (*hook)(v
|
|||
if (!hook) {
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
hooked_ = true;
|
||||
return reception_flow_->install_receive_hook(arg, hook, remote_ssrc_.get()->load());
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,7 @@ using namespace mingw;
|
|||
|
||||
uvgrtp::socket::socket(int rce_flags) :
|
||||
socket_(0),
|
||||
remote_address_(),
|
||||
local_address_(),
|
||||
remote_ip6_address_(),
|
||||
local_ip6_address_(),
|
||||
ipv6_(false),
|
||||
rce_flags_(rce_flags),
|
||||
|
@ -341,11 +339,12 @@ sockaddr_in6 uvgrtp::socket::create_ip6_sockaddr_any(short src_port) {
|
|||
}
|
||||
|
||||
std::string uvgrtp::socket::get_socket_path_string() const
|
||||
{
|
||||
if (ipv6_) {
|
||||
{
|
||||
/*if (ipv6_) {
|
||||
return sockaddr_ip6_to_string(local_ip6_address_) + " -> " + sockaddr_ip6_to_string(remote_ip6_address_);
|
||||
}
|
||||
return sockaddr_to_string(local_address_) + " -> " + sockaddr_to_string(remote_address_);
|
||||
return sockaddr_to_string(local_address_) + " -> " + sockaddr_to_string(remote_address_);*/
|
||||
return "Not implemented";
|
||||
}
|
||||
|
||||
std::string uvgrtp::socket::sockaddr_to_string(const sockaddr_in& addr) const
|
||||
|
@ -382,16 +381,6 @@ std::string uvgrtp::socket::sockaddr_ip6_to_string(const sockaddr_in6& addr6) co
|
|||
return string;
|
||||
}
|
||||
|
||||
void uvgrtp::socket::set_sockaddr(sockaddr_in addr)
|
||||
{
|
||||
remote_address_ = addr;
|
||||
}
|
||||
|
||||
void uvgrtp::socket::set_sockaddr6(sockaddr_in6 addr)
|
||||
{
|
||||
remote_ip6_address_ = addr;
|
||||
}
|
||||
|
||||
socket_t& uvgrtp::socket::get_raw_socket()
|
||||
{
|
||||
return socket_;
|
||||
|
@ -471,16 +460,6 @@ rtp_error_t uvgrtp::socket::__sendto(sockaddr_in& addr, sockaddr_in6& addr6, boo
|
|||
return RTP_OK;
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::socket::sendto(uint8_t *buf, size_t buf_len, int send_flags)
|
||||
{
|
||||
return __sendto(remote_address_, remote_ip6_address_, ipv6_, buf, buf_len, send_flags, nullptr);
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::socket::sendto(uint8_t *buf, size_t buf_len, int send_flags, int *bytes_sent)
|
||||
{
|
||||
return __sendto(remote_address_, remote_ip6_address_, ipv6_, buf, buf_len, send_flags, bytes_sent);
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, sockaddr_in6& addr6, uint8_t *buf, size_t buf_len, int send_flags, int *bytes_sent)
|
||||
{
|
||||
return __sendto(addr, addr6, ipv6_, buf, buf_len, send_flags, bytes_sent);
|
||||
|
@ -574,34 +553,6 @@ rtp_error_t uvgrtp::socket::__sendtov(
|
|||
return RTP_OK;
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::socket::sendto(buf_vec& buffers, int send_flags)
|
||||
{
|
||||
rtp_error_t ret = RTP_OK;
|
||||
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffers)) != RTP_OK) {
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return __sendtov(remote_address_, remote_ip6_address_, ipv6_, buffers, send_flags, nullptr);
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::socket::sendto(buf_vec& buffers, int send_flags, int *bytes_sent)
|
||||
{
|
||||
rtp_error_t ret = RTP_OK;
|
||||
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffers)) != RTP_OK) {
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return __sendtov(remote_address_, remote_ip6_address_, ipv6_, buffers, send_flags, bytes_sent);
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, sockaddr_in6& addr6, buf_vec& buffers, int send_flags)
|
||||
{
|
||||
rtp_error_t ret = RTP_OK;
|
||||
|
@ -785,36 +736,6 @@ send_:
|
|||
return return_value;
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::socket::sendto(pkt_vec& buffers, int send_flags)
|
||||
{
|
||||
rtp_error_t ret = RTP_OK;
|
||||
|
||||
for (auto& buffer : buffers) {
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffer)) != RTP_OK) {
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __sendtov(remote_address_, remote_ip6_address_, ipv6_, buffers, send_flags, nullptr);
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::socket::sendto(pkt_vec& buffers, int send_flags, int *bytes_sent)
|
||||
{
|
||||
rtp_error_t ret = RTP_OK;
|
||||
|
||||
for (auto& buffer : buffers) {
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffer)) != RTP_OK) {
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __sendtov(remote_address_, remote_ip6_address_, ipv6_, buffers, send_flags, bytes_sent);
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, sockaddr_in6& addr6, pkt_vec& buffers, int send_flags)
|
||||
{
|
||||
rtp_error_t ret = RTP_OK;
|
||||
|
@ -1041,8 +962,3 @@ rtp_error_t uvgrtp::socket::recvfrom(uint8_t *buf, size_t buf_len, int recv_flag
|
|||
{
|
||||
return __recvfrom(buf, buf_len, recv_flags, nullptr, nullptr);
|
||||
}
|
||||
|
||||
sockaddr_in& uvgrtp::socket::get_out_address()
|
||||
{
|
||||
return remote_address_;
|
||||
}
|
||||
|
|
|
@ -102,9 +102,10 @@ namespace uvgrtp {
|
|||
* Return RTP_GENERIC_ERROR if setsockopt failed */
|
||||
rtp_error_t setsockopt(int level, int optname, const void *optval, socklen_t optlen);
|
||||
|
||||
/* Same as send(2), send message to remote with send_flags
|
||||
* This function uses the internal addr_ object as remote address so it MUST be set
|
||||
*
|
||||
/* Same as send(2), send message to the given address with send_flags
|
||||
* It is required to give at least one type of address: sockaddr_in or sockaddr_in6. It is possible
|
||||
* to give both and the function wil pick the correct one to use
|
||||
*
|
||||
* It is possible to combine multiple buffers and send them as one RTP frame by calling
|
||||
* the sendto() with a vector containing the buffers and their lengths
|
||||
*
|
||||
|
@ -112,14 +113,7 @@ namespace uvgrtp {
|
|||
*
|
||||
* Return RTP_OK on success and write the amount of bytes sent to "bytes_sent"
|
||||
* Return RTP_SEND_ERROR on error and set "bytes_sent" to -1 */
|
||||
rtp_error_t sendto(uint8_t *buf, size_t buf_len, int send_flags);
|
||||
rtp_error_t sendto(uint8_t *buf, size_t buf_len, int send_flags, int *bytes_sent);
|
||||
rtp_error_t sendto(buf_vec& buffers, int send_flags);
|
||||
rtp_error_t sendto(buf_vec& buffers, int send_flags, int *bytes_sent);
|
||||
rtp_error_t sendto(pkt_vec& buffers, int send_flags);
|
||||
rtp_error_t sendto(pkt_vec& buffers, int send_flags, int *bytes_sent);
|
||||
|
||||
/* Same as sendto() but the remote address given as parameter */
|
||||
rtp_error_t sendto(sockaddr_in& addr, sockaddr_in6& addr6, uint8_t *buf, size_t buf_len, int send_flags);
|
||||
rtp_error_t sendto(sockaddr_in& addr, sockaddr_in6& addr6, uint8_t *buf, size_t buf_len, int send_flags, int *bytes_sent);
|
||||
rtp_error_t sendto(sockaddr_in& addr, sockaddr_in6& addr6, buf_vec& buffers, int send_flags);
|
||||
|
@ -172,14 +166,6 @@ namespace uvgrtp {
|
|||
/* Get reference to the actual socket object */
|
||||
socket_t& get_raw_socket();
|
||||
|
||||
/* Initialize the private "addr_" object with "addr"
|
||||
* This is used when calling send() */
|
||||
void set_sockaddr(sockaddr_in addr);
|
||||
|
||||
void set_sockaddr6(sockaddr_in6 addr);
|
||||
/* Get the out address for the socket if it exists */
|
||||
sockaddr_in& get_out_address();
|
||||
|
||||
/* Install a packet handler for vector-based send operations.
|
||||
*
|
||||
* This handler allows the caller to inject extra functionality to the send operation
|
||||
|
@ -204,9 +190,9 @@ namespace uvgrtp {
|
|||
rtp_error_t __sendtov(sockaddr_in& addr, sockaddr_in6& addr6, bool ipv6, uvgrtp::pkt_vec& buffers, int send_flags, int *bytes_sent);
|
||||
|
||||
socket_t socket_;
|
||||
sockaddr_in remote_address_;
|
||||
//sockaddr_in remote_address_;
|
||||
sockaddr_in local_address_;
|
||||
sockaddr_in6 remote_ip6_address_;
|
||||
//sockaddr_in6 remote_ip6_address_;
|
||||
sockaddr_in6 local_ip6_address_;
|
||||
bool ipv6_;
|
||||
|
||||
|
|
|
@ -378,9 +378,13 @@ rtp_error_t uvgrtp::zrtp::begin_session()
|
|||
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
|
||||
std::string path = local_socket_->get_socket_path_string();
|
||||
// This was disabled when remote_addresses were removed from socket
|
||||
// -> get_socket_path_to_string will need some changes, <--TODO
|
||||
|
||||
//std::string path = local_socket_->get_socket_path_string();
|
||||
//UVG_LOG_DEBUG("Sending ZRTP hello # %i, path: %s", i + 1, path.c_str());
|
||||
UVG_LOG_DEBUG("Sending ZRTP hello # %i", i + 1);
|
||||
|
||||
UVG_LOG_DEBUG("Sending ZRTP hello # %i, path: %s", i + 1, path.c_str());
|
||||
int type = 0;
|
||||
|
||||
if (hello.send_msg(local_socket_, remote_addr_, remote_ip6_addr_) != RTP_OK) {
|
||||
|
|
Loading…
Reference in New Issue