#define RTP_HEADER_LEN 12
static block_t *BlockUDP( access_t * );
-static block_t *BlockTCP( access_t * );
+static block_t *BlockPrebufferRTP( access_t *p_access, block_t *p_block );
static block_t *BlockRTP( access_t * );
static block_t *BlockChoose( access_t * );
static int Control( access_t *, int, va_list );
/* Set up p_access */
access_InitFields( p_access );
- ACCESS_SET_CALLBACKS( NULL, BlockRTP, Control, NULL );
+ ACCESS_SET_CALLBACKS( NULL, BlockPrebufferRTP, Control, NULL );
p_access->info.b_prebuffered = VLC_FALSE;
MALLOC_ERR( p_access->p_sys, access_sys_t ); p_sys = p_access->p_sys;
memset (p_sys, 0, sizeof (*p_sys));
case IPPROTO_TCP:
p_sys->fd = net_ConnectTCP( p_access, psz_server_addr, i_server_port );
+ p_access->pf_block = BlockRTP;
p_sys->b_framed_rtp = VLC_TRUE;
break;
/* Read RTP framing */
if (p_block->i_buffer < 2)
{
- /* FIXME: not very efficient */
int i_read = net_Read( p_access, p_sys->fd, NULL,
p_block->p_buffer + p_block->i_buffer,
2 - p_block->i_buffer, VLC_FALSE );
}
/*****************************************************************************
- * BlockParseRTP/BlockRTP:
+ * BlockParseRTP: decapsulate the RTP packet and return it
*****************************************************************************/
static block_t *BlockParseRTP( access_t *p_access, block_t *p_block )
{
return NULL;
}
+/*****************************************************************************
+ * BlockPrebufferRTP: waits until we have at least two RTP datagrams,
+ * so that we can synchronize the RTP sequence number.
+ * This is only useful for non-reliable transport protocols.
+ ****************************************************************************/
static block_t *BlockPrebufferRTP( access_t *p_access, block_t *p_block )
{
access_sys_t *p_sys = p_access->p_sys;
int i_count = 0;
block_t *p = p_block;
+ if( BlockParseRTP( p_access, p_block ) == NULL )
+ return NULL;
+
for( ;; )
{
mtime_t i_date = mdate();
if( !p && (i_date - i_first) > p_sys->i_rtp_late )
{
msg_Err( p_access, "error in RTP prebuffering!" );
- break;
+ return NULL;
}
}
return p;
}
+/*****************************************************************************
+ * BlockRTP: receives an RTP packet, parses it, queues it queue,
+ * then dequeues the oldest packet and returns it to input/demux.
+ ****************************************************************************/
static block_t *BlockRTP( access_t *p_access )
{
access_sys_t *p_sys = p_access->p_sys;
return p_block;
}
- if( !BlockParseRTP( p_access, p_block )) return NULL;
-
p_access->pf_block = BlockRTP;
-
return BlockPrebufferRTP( p_access, p_block );
}