multiplex: Add function for installing new handlers to reception_flow
This commit is contained in:
parent
00823467b3
commit
7441109929
|
|
@ -37,6 +37,11 @@ uvgrtp::reception_flow::reception_flow(bool ipv6) :
|
||||||
receiver_(nullptr),
|
receiver_(nullptr),
|
||||||
//user_hook_arg_(nullptr),
|
//user_hook_arg_(nullptr),
|
||||||
//user_hook_(nullptr),
|
//user_hook_(nullptr),
|
||||||
|
rtp_handlers_({}),
|
||||||
|
rtcp_handlers_({}),
|
||||||
|
zrtp_handlers_({}),
|
||||||
|
srtp_handlers_({}),
|
||||||
|
srtcp_handlers_({}),
|
||||||
ring_buffer_(),
|
ring_buffer_(),
|
||||||
ring_read_index_(-1), // invalid first index that will increase to a valid one
|
ring_read_index_(-1), // invalid first index that will increase to a valid one
|
||||||
last_ring_write_index_(-1),
|
last_ring_write_index_(-1),
|
||||||
|
|
@ -321,6 +326,39 @@ rtp_error_t uvgrtp::reception_flow::install_aux_handler(
|
||||||
return RTP_OK;
|
return RTP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtp_error_t uvgrtp::reception_flow::new_install_handler(int type, std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc,
|
||||||
|
packet_handler_new handler, std::function<rtp_error_t(uvgrtp::frame::rtp_frame**)> getter)
|
||||||
|
{
|
||||||
|
handler_new pair = {handler, getter};
|
||||||
|
switch (type) {
|
||||||
|
case 1: {
|
||||||
|
rtp_handlers_[remote_ssrc] = { handler, getter };
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
rtcp_handlers_[remote_ssrc] = { handler, getter };
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
zrtp_handlers_[remote_ssrc] = { handler, getter };
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: {
|
||||||
|
srtp_handlers_[remote_ssrc] = { handler, getter };
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5: {
|
||||||
|
srtcp_handlers_[remote_ssrc] = { handler, getter };
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
UVG_LOG_ERROR("Invalid type, only types 1-5 are allowed");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return RTP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
rtp_error_t uvgrtp::reception_flow::install_aux_handler_cpp(uint32_t key,
|
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(int, uvgrtp::frame::rtp_frame**)> handler,
|
||||||
std::function<rtp_error_t(uvgrtp::frame::rtp_frame**)> getter)
|
std::function<rtp_error_t(uvgrtp::frame::rtp_frame**)> getter)
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,18 @@ namespace uvgrtp {
|
||||||
* Return 0 "handler" is nullptr */
|
* Return 0 "handler" is nullptr */
|
||||||
uint32_t install_handler(packet_handler handler);
|
uint32_t install_handler(packet_handler handler);
|
||||||
|
|
||||||
|
/*
|
||||||
|
handler types
|
||||||
|
1 rtp
|
||||||
|
2 rtcp
|
||||||
|
3 zrtp
|
||||||
|
4 srtp
|
||||||
|
5 srtcp
|
||||||
|
getter can be nullptr if there is no getter (for media handlers mostly)
|
||||||
|
*/
|
||||||
|
rtp_error_t new_install_handler(int type, std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc,
|
||||||
|
packet_handler_new handler, std::function<rtp_error_t(uvgrtp::frame::rtp_frame**)> getter);
|
||||||
|
|
||||||
/* Install auxiliary handler for the packet
|
/* Install auxiliary handler for the packet
|
||||||
*
|
*
|
||||||
* This handler is responsible for doing auxiliary operations on the packet
|
* This handler is responsible for doing auxiliary operations on the packet
|
||||||
|
|
@ -271,9 +283,9 @@ namespace uvgrtp {
|
||||||
//void (*user_hook_)(void* arg, uint8_t* payload);
|
//void (*user_hook_)(void* arg, uint8_t* payload);
|
||||||
|
|
||||||
// Map different types of handlers by remote SSRCs
|
// Map different types of handlers by remote SSRCs
|
||||||
|
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, handler_new> rtp_handlers_;
|
||||||
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, handler_new> rtcp_handlers_;
|
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, handler_new> rtcp_handlers_;
|
||||||
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, handler_new> zrtp_handlers_;
|
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, handler_new> zrtp_handlers_;
|
||||||
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, handler_new> rtp_handlers_;
|
|
||||||
|
|
||||||
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, handler_new> srtp_handlers_;
|
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, handler_new> srtp_handlers_;
|
||||||
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, handler_new> srtcp_handlers_;
|
std::map<std::shared_ptr<std::atomic<std::uint32_t>>, handler_new> srtcp_handlers_;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue