multiplex: Remove deprecated functions

This commit is contained in:
Heikki Tampio 2023-06-15 13:20:21 +03:00
parent c145213756
commit 0e6a6e61d6
3 changed files with 5 additions and 147 deletions

View File

@ -87,9 +87,6 @@ uvgrtp::media_stream::~media_stream()
sfp_->clear_port(src_port_, socket_);
}
}
if (rce_flags_ & RCE_RTCP_MUX) {
reception_flow_->clear_rtcp_from_rec(remote_ssrc_);
}
(void)free_resources(RTP_OK);
}
@ -323,12 +320,6 @@ rtp_error_t uvgrtp::media_stream::init()
socket_->install_handler(rtcp_.get(), rtcp_->send_packet_handler_vec);
rtp_handler_key_ = reception_flow_->install_handler(rtp_->packet_handler);
reception_flow_->map_handler_key(rtp_handler_key_, remote_ssrc_);
reception_flow_->install_aux_handler(rtp_handler_key_, rtcp_.get(), rtcp_->recv_packet_handler, nullptr);
reception_flow_->new_install_handler(
1, remote_ssrc_,
std::bind(&uvgrtp::rtp::new_packet_handler, rtp_, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
@ -402,14 +393,6 @@ rtp_error_t uvgrtp::media_stream::init(std::shared_ptr<uvgrtp::zrtp> zrtp)
socket_->install_handler(rtcp_.get(), rtcp_->send_packet_handler_vec);
socket_->install_handler(srtp_.get(), srtp_->send_packet_handler);
rtp_handler_key_ = reception_flow_->install_handler(rtp_->packet_handler);
zrtp_handler_key_ = reception_flow_->install_handler(zrtp->packet_handler);
reception_flow_->map_handler_key(rtp_handler_key_, remote_ssrc_);
reception_flow_->map_handler_key(zrtp_handler_key_, remote_ssrc_);
reception_flow_->install_aux_handler(rtp_handler_key_, srtp_.get(), srtp_->recv_packet_handler, nullptr);
reception_flow_->install_aux_handler(rtp_handler_key_, rtcp_.get(), rtcp_->recv_packet_handler, nullptr);
if (rce_flags_ & RCE_RTCP_MUX) {
rtcp_->set_socket(socket_);
}

View File

@ -32,7 +32,6 @@ constexpr size_t DEFAULT_INITIAL_BUFFER_SIZE = 4194304;
uvgrtp::reception_flow::reception_flow(bool ipv6) :
hooks_({}),
handler_mapping_({}),
should_stop_(true),
receiver_(nullptr),
//user_hook_arg_(nullptr),
@ -285,43 +284,6 @@ uvgrtp::frame::rtp_frame* uvgrtp::reception_flow::pull_frame(ssize_t timeout_ms,
return nullptr;
}
uint32_t uvgrtp::reception_flow::install_handler(uvgrtp::packet_handler handler)
{
uint32_t key;
if (!handler)
return 0;
do {
key = uvgrtp::random::generate_32();
} while (!key || (packet_handlers_.find(key) != packet_handlers_.end()));
packet_handlers_[key].primary = handler;
return key;
}
rtp_error_t uvgrtp::reception_flow::install_aux_handler(
uint32_t key,
void *arg,
uvgrtp::packet_handler_aux handler,
uvgrtp::frame_getter getter
)
{
if (!handler)
return RTP_INVALID_VALUE;
if (packet_handlers_.find(key) == packet_handlers_.end())
return RTP_INVALID_VALUE;
auxiliary_handler aux;
aux.arg = arg;
aux.getter = getter;
aux.handler = handler;
packet_handlers_[key].auxiliary.push_back(aux);
return RTP_OK;
}
rtp_error_t uvgrtp::reception_flow::new_install_handler(int type, std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc,
std::function<rtp_error_t(void*, int, uint8_t*, size_t, frame::rtp_frame** out)> handler, void* args)
{
@ -380,22 +342,6 @@ rtp_error_t uvgrtp::reception_flow::new_remove_handlers(std::shared_ptr<std::ato
return RTP_INVALID_VALUE;
}
rtp_error_t uvgrtp::reception_flow::install_aux_handler_cpp(uint32_t key,
std::function<rtp_error_t(int, uvgrtp::frame::rtp_frame**)> handler,
std::function<rtp_error_t(uvgrtp::frame::rtp_frame**)> getter)
{
if (!handler)
return RTP_INVALID_VALUE;
if (packet_handlers_.find(key) == packet_handlers_.end())
return RTP_INVALID_VALUE;
auxiliary_handler_cpp ahc = {handler, getter};
packet_handlers_[key].auxiliary_cpp.push_back(ahc);
return RTP_OK;
}
void uvgrtp::reception_flow::return_frame(uvgrtp::frame::rtp_frame *frame)
{
uint32_t ssrc = frame->header.ssrc;
@ -652,7 +598,7 @@ void uvgrtp::reception_flow::process_packet(int rce_flags)
if (rce_flags & RCE_RTCP) {
retval = handlers->handler_rtcp_common.handler(handlers->handler_rtcp_common.args, rce_flags, &ptr[0], size, &frame);
}
if (retval == RTP_PKT_MODIFIED) {
if (retval == RTP_PKT_MODIFIED || retval == RTP_PKT_NOT_HANDLED) {
retval = handlers->handler_media.handler(handlers->handler_media.args, rce_flags, &ptr[0], size, &frame);
if (retval == RTP_PKT_READY) {
return_frame(frame);
@ -737,43 +683,20 @@ void uvgrtp::reception_flow::increase_buffer_size(ssize_t next_write_index)
}
}
bool uvgrtp::reception_flow::map_handler_key(uint32_t key, std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc)
{
if (handler_mapping_.find(key) == handler_mapping_.end()) {
handler_mapping_[key] = remote_ssrc;
return true;
}
return false;
}
int uvgrtp::reception_flow::clear_stream_from_flow(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc, uint32_t handler_key)
{
// Clear all the data structures
if (hooks_.find(remote_ssrc) != hooks_.end()) {
hooks_.erase(remote_ssrc);
}
if (packet_handlers_.find(handler_key) != packet_handlers_.end()) {
packet_handlers_.erase(handler_key);
}
if (handler_mapping_.find(handler_key) != handler_mapping_.end()) {
handler_mapping_.erase(handler_key);
if (NEW_packet_handlers_.find(remote_ssrc) != NEW_packet_handlers_.end()) {
NEW_packet_handlers_.erase(remote_ssrc);
}
// If all the data structures are empty, return 1 which means that there is no streams left for this reception_flow
// and it can be safely deleted
if (hooks_.empty() && packet_handlers_.empty() && handler_mapping_.empty()) {
if (hooks_.empty() && NEW_packet_handlers_.empty()) {
return 1;
}
return 0;
}
rtp_error_t uvgrtp::reception_flow::clear_rtcp_from_rec(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc)
{
rtp_error_t ret = RTP_GENERIC_ERROR;
rtcp_map_mutex_.lock();
if (rtcps_map_.find(remote_ssrc) != rtcps_map_.end()) {
rtcps_map_.erase(remote_ssrc);
ret = RTP_OK;
}
rtcp_map_mutex_.unlock();
return ret;
}

View File

@ -121,18 +121,6 @@ namespace uvgrtp {
reception_flow(bool ipv6);
~reception_flow();
/* Install a primary handler for an incoming UDP datagram
*
* This handler is responsible for creating an operable RTP packet
* that auxiliary handlers can work with.
*
* It is also responsible for validating the packet on a high level
* (ZRTP checksum/RTP version etc) before passing it onto other handlers.
*
* Return a key on success that differentiates primary packet handlers
* Return 0 "handler" is nullptr */
uint32_t install_handler(packet_handler handler);
/*
handler types
1 rtp
@ -152,26 +140,6 @@ namespace uvgrtp {
rtp_error_t new_remove_handlers(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc);
/* Install auxiliary handler for the packet
*
* This handler is responsible for doing auxiliary operations on the packet
* such as gathering sessions statistics data or decrypting the packet
* It is called only after the primary handler of the auxiliary handler is called
*
* "key" is used to specify for which primary handlers for "handler"
* An auxiliary handler can be installed to multiple primary handlers
*
* "arg" is an optional argument that is passed to the handler when it's called
* It can be null if the handler does not require additional data
*
* Return RTP_OK on success
* Return RTP_INVALID_VALUE if "handler" is nullptr or if "key" is not valid */
rtp_error_t install_aux_handler(uint32_t key, void *arg, packet_handler_aux handler, frame_getter getter);
rtp_error_t install_aux_handler_cpp(uint32_t key,
std::function<rtp_error_t(int, uvgrtp::frame::rtp_frame**)> handler,
std::function<rtp_error_t(uvgrtp::frame::rtp_frame**)> getter);
/* Install receive hook in reception flow
*
* Return RTP_OK on success
@ -204,14 +172,6 @@ namespace uvgrtp {
uvgrtp::frame::rtp_frame* pull_frame(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc);
uvgrtp::frame::rtp_frame* pull_frame(ssize_t timeout_ms, std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc);
/* Map a packet handler key to a REMOTE SSRC of a stream
*
* Return true if a handler with the given key exists in the reception_flow -> mapping succesful
* Return false if there is no handler with this key -> no mapping is done */
bool map_handler_key(uint32_t key, std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc);
rtp_error_t clear_rtcp_from_rec(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc);
/* Clear the packet handlers associated with this handler key from the reception_flow
* Also clear the hooks associated with this remote_ssrc
*
@ -244,9 +204,6 @@ namespace uvgrtp {
inline void increase_buffer_size(ssize_t next_write_index);
/* Primary handlers for the socket */
std::unordered_map<uint32_t, packet_handlers> packet_handlers_;
inline ssize_t next_buffer_location(ssize_t current_location);
void create_ring_buffer();
@ -263,11 +220,6 @@ namespace uvgrtp {
//void (*recv_hook_)(void *arg, uvgrtp::frame::rtp_frame *frame);
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, receive_pkt_hook> hooks_;
// Map handler keys to media streams remote ssrcs
std::map<uint32_t, std::shared_ptr<std::atomic<std::uint32_t>>> handler_mapping_;
std::mutex rtcp_map_mutex_;
std::map<std::shared_ptr<std::atomic<uint32_t>>, std::shared_ptr<uvgrtp::rtcp>> rtcps_map_;
std::mutex flow_mutex_;
bool should_stop_;