diff --git a/include/pkt_dispatch.hh b/include/pkt_dispatch.hh index b65de9c..c1ae896 100644 --- a/include/pkt_dispatch.hh +++ b/include/pkt_dispatch.hh @@ -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& get_handlers(); @@ -29,5 +35,8 @@ namespace uvg_rtp { uvg_rtp::socket socket_; std::vector packet_handlers_; + + void *recv_hook_arg_; + void (*recv_hook_)(void *arg, uvg_rtp::frame::rtp_frame *frame); }; } diff --git a/src/pkt_dispatch.cc b/src/pkt_dispatch.cc index 49a8d02..32cf8ce 100644 --- a/src/pkt_dispatch.cc +++ b/src/pkt_dispatch.cc @@ -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)