/** * Processes a packet received from the RTP socket. */ static void rtp_process (demux_t *demux, block_t *block) { demux_sys_t *sys = demux->p_sys; if (block->i_buffer < 2) goto drop; const uint8_t ptype = rtp_ptype (block); if (ptype >= 72 && ptype <= 76) goto drop; /* Muxed RTCP, ignore for now FIXME */ #ifdef HAVE_SRTP if (sys->srtp != NULL) { size_t len = block->i_buffer; if (srtp_recv (sys->srtp, block->p_buffer, &len)) { msg_Dbg (demux, "SRTP authentication/decryption failed"); goto drop; } block->i_buffer = len; } #endif /* TODO: use SDP and get rid of this hack */ if (unlikely(sys->autodetect)) { /* Autodetect payload type, _before_ rtp_queue() */ rtp_autodetect (demux, sys->session, block); sys->autodetect = false; } rtp_queue (demux, sys->session, block); return; drop: block_Release (block); }
static block_t *rtp_recv (demux_t *demux) { demux_sys_t *p_sys = demux->p_sys; for (block_t *block;; block_Release (block)) { block = p_sys->framed_rtp ? rtp_stream_recv (VLC_OBJECT (demux), p_sys->fd) : rtp_dgram_recv (VLC_OBJECT (demux), p_sys->fd); if (block == NULL) { msg_Err (demux, "RTP flow stopped"); break; /* fatal error */ } if (block->i_buffer < 2) continue; /* FIXME */ const uint8_t ptype = rtp_ptype (block); if (ptype >= 72 && ptype <= 76) continue; /* Muxed RTCP, ignore for now */ #ifdef HAVE_SRTP if (p_sys->srtp) { size_t len = block->i_buffer; int canc, err; canc = vlc_savecancel (); err = srtp_recv (p_sys->srtp, block->p_buffer, &len); vlc_restorecancel (canc); if (err) { msg_Dbg (demux, "SRTP authentication/decryption failed"); continue; } block->i_buffer = len; } #endif return block; /* success! */ } return NULL; }