Add receive hook to RTP packet dispatcher

This commit is contained in:
Aaro Altonen 2020-08-03 10:58:50 +03:00
parent 9e49ad4b09
commit d721a52a3d
2 changed files with 21 additions and 0 deletions

View File

@ -21,6 +21,12 @@ namespace uvg_rtp {
* Return RTP_INVALID_VALUE if "handler" is nullptr */
rtp_error_t install_handler(packet_handler handler);
/* Install receive hook for the RTP packet dispatcher
*
* Return RTP_OK on success
* Return RTP_INVALID_VALUE if "hook" is nullptr */
rtp_error_t install_receive_hook(void *arg, void (*hook)(void *, uvg_rtp::frame::rtp_frame *));
/* Return reference to the vector that holds all installed handlers */
std::vector<uvg_rtp::packet_handler>& get_handlers();
@ -29,5 +35,8 @@ namespace uvg_rtp {
uvg_rtp::socket socket_;
std::vector<packet_handler> packet_handlers_;
void *recv_hook_arg_;
void (*recv_hook_)(void *arg, uvg_rtp::frame::rtp_frame *frame);
};
}

View File

@ -20,6 +20,18 @@ uvg_rtp::pkt_dispatcher::~pkt_dispatcher()
{
}
rtp_error_t uvg_rtp::pkt_dispatcher::install_receive_hook(
void *arg,
void (*hook)(void *, uvg_rtp::frame::rtp_frame *)
)
{
if (!hook)
return RTP_INVALID_VALUE;
recv_hook_ = hook;
recv_hook_arg_ = arg;
}
rtp_error_t uvg_rtp::pkt_dispatcher::install_handler(uvg_rtp::packet_handler handler)
{
if (!handler)