Start the RTP packet dispatcher in pkt_dispatch.cc
This commit is contained in:
parent
96ba50a159
commit
1dd628d927
|
@ -29,6 +29,12 @@ namespace uvg_rtp {
|
|||
* Return RTP_INVALID_VALUE if "hook" is nullptr */
|
||||
rtp_error_t install_receive_hook(void *arg, void (*hook)(void *, uvg_rtp::frame::rtp_frame *));
|
||||
|
||||
/* Start the RTP packet dispatcher
|
||||
*
|
||||
* Return RTP_OK on success
|
||||
* Return RTP_MEMORY_ERROR if allocation of a thread object fails */
|
||||
rtp_error_t start(uvg_rtp::socket *socket, int flags);
|
||||
|
||||
/* Fetchj frame from the frame queue that contains all received frame.
|
||||
* pull_frame() will block until there is a frame that can be returned.
|
||||
* If "timeout" is given, pull_frame() will block only for however long
|
||||
|
|
|
@ -110,7 +110,7 @@ rtp_error_t uvg_rtp::media_stream::init()
|
|||
return RTP_MEMORY_ERROR;
|
||||
}
|
||||
|
||||
pkt_dispatcher_->install_handler(rtp_->packet_handler);
|
||||
/* pkt_dispatcher_->install_handler(rtp_->packet_handler); */
|
||||
|
||||
switch (fmt_) {
|
||||
case RTP_FORMAT_HEVC:
|
||||
|
@ -131,17 +131,10 @@ rtp_error_t uvg_rtp::media_stream::init()
|
|||
delete pkt_dispatcher_;
|
||||
return RTP_MEMORY_ERROR;
|
||||
}
|
||||
pkt_dispatcher_->install_handler(media_->packet_handler);
|
||||
/* pkt_dispatcher_->install_handler(media_->packet_handler); */
|
||||
|
||||
initialized_ = !!(dispatcher_thread_ = new std::thread(
|
||||
pkt_dispatcher_->runner,
|
||||
pkt_dispatcher_,
|
||||
&socket_,
|
||||
ctx_config_.flags
|
||||
)
|
||||
);
|
||||
|
||||
return pkt_dispatcher_->start();
|
||||
initialized_ = true;
|
||||
return pkt_dispatcher_->start(&socket_, ctx_config_.flags);
|
||||
}
|
||||
|
||||
#ifdef __RTP_CRYPTO__
|
||||
|
|
|
@ -20,6 +20,15 @@ uvg_rtp::pkt_dispatcher::~pkt_dispatcher()
|
|||
{
|
||||
}
|
||||
|
||||
rtp_error_t uvg_rtp::pkt_dispatcher::start(uvg_rtp::socket *socket, int flags)
|
||||
{
|
||||
if (!(runner_ = new std::thread(runner, this, socket, flags)))
|
||||
return RTP_MEMORY_ERROR;
|
||||
|
||||
runner_->detach();
|
||||
return uvg_rtp::runner::start();
|
||||
}
|
||||
|
||||
rtp_error_t uvg_rtp::pkt_dispatcher::install_receive_hook(
|
||||
void *arg,
|
||||
void (*hook)(void *, uvg_rtp::frame::rtp_frame *)
|
||||
|
@ -118,7 +127,7 @@ std::vector<uvg_rtp::packet_handler>& uvg_rtp::pkt_dispatcher::get_handlers()
|
|||
*
|
||||
* If a handler receives a non-null "out", it can safely ignore "packet" and operate just on
|
||||
* the "out" parameter because at that point it already contains all needed information. */
|
||||
static void runner(uvg_rtp::pkt_dispatcher *dispatcher, uvg_rtp::socket *socket, int flags)
|
||||
void uvg_rtp::pkt_dispatcher::runner(uvg_rtp::pkt_dispatcher *dispatcher, uvg_rtp::socket *socket, int flags)
|
||||
{
|
||||
int nread;
|
||||
fd_set read_fds;
|
||||
|
|
Loading…
Reference in New Issue