Implement frame return functionality
This commit is contained in:
parent
f48d5bfe4a
commit
bdfe027352
|
@ -49,6 +49,9 @@ namespace uvg_rtp {
|
|||
/* Return reference to the vector that holds all installed handlers */
|
||||
std::vector<uvg_rtp::packet_handler>& get_handlers();
|
||||
|
||||
/* Return a processed RTP frame to user either through frame queue or receive hook */
|
||||
void return_frame(uvg_rtp::frame::rtp_frame *frame);
|
||||
|
||||
/* RTP packet dispatcher thread */
|
||||
static void runner(uvg_rtp::pkt_dispatcher *dispatcher, uvg_rtp::socket *socket, int flags);
|
||||
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
#include "pkt_dispatch.hh"
|
||||
#include "util.hh"
|
||||
|
||||
uvg_rtp::pkt_dispatcher::pkt_dispatcher()
|
||||
uvg_rtp::pkt_dispatcher::pkt_dispatcher():
|
||||
recv_hook_arg_(nullptr),
|
||||
recv_hook_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -90,6 +92,17 @@ std::vector<uvg_rtp::packet_handler>& uvg_rtp::pkt_dispatcher::get_handlers()
|
|||
return packet_handlers_;
|
||||
}
|
||||
|
||||
void uvg_rtp::pkt_dispatcher::return_frame(uvg_rtp::frame::rtp_frame *frame)
|
||||
{
|
||||
if (recv_hook_) {
|
||||
recv_hook_(recv_hook_arg_, frame);
|
||||
} else {
|
||||
frames_mtx_.lock();
|
||||
frames_.push_back(frame);
|
||||
frames_mtx_.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/* The point of packet dispatcher is to provide much-needed isolation between different layers
|
||||
* of uvgRTP. For example, HEVC handler should not concern itself with RTP packet validation
|
||||
* because that should be a global operation done for all packets.
|
||||
|
@ -171,6 +184,7 @@ void uvg_rtp::pkt_dispatcher::runner(uvg_rtp::pkt_dispatcher *dispatcher, uvg_rt
|
|||
|
||||
/* "out" contains an RTP packet that can be returned to the user */
|
||||
case RTP_PKT_READY:
|
||||
dispatcher->return_frame(frame);
|
||||
break;
|
||||
|
||||
/* the received packet is not handled at all or only partially by the called handler
|
||||
|
|
Loading…
Reference in New Issue