Commit 51a5b2be authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

RTP: add Framed RTP over TCP support

(untested as I have no software capable of sending this)
parent 1b441157
......@@ -92,6 +92,8 @@ vlc_module_begin ();
change_integer_range (0, 32767);
add_shortcut ("dccp");
/*add_shortcut ("sctp");*/
add_shortcut ("rtptcp"); /* "tcp" is already taken :( */
add_shortcut ("rtp");
add_shortcut ("udplite");
vlc_module_end ();
......@@ -131,6 +133,9 @@ static int Open (vlc_object_t *obj)
if (!strcmp (demux->psz_access, "dccp"))
tp = IPPROTO_DCCP;
else
if (!strcmp (demux->psz_access, "rtptcp"))
tp = IPPROTO_TCP;
else
if (!strcmp (demux->psz_access, "rtp"))
tp = IPPROTO_UDP;
else
......@@ -181,6 +186,10 @@ static int Open (vlc_object_t *obj)
msg_Err (obj, "DCCP support not included");
#endif
break;
case IPPROTO_TCP:
fd = net_Connect (obj, shost, sport, SOCK_STREAM, tp);
break;
}
free (tmp);
......@@ -199,6 +208,7 @@ static int Open (vlc_object_t *obj)
p_sys->max_dropout = var_CreateGetInteger (obj, "rtp-max-dropout");
p_sys->max_misorder = var_CreateGetInteger (obj, "rtp-max-misorder");
p_sys->autodetect = true;
p_sys->framed_rtp = (tp == IPPROTO_TCP);
demux->pf_demux = Demux;
demux->pf_control = Control;
......@@ -331,6 +341,45 @@ static block_t *rtp_dgram_recv (demux_t *demux, int fd)
return block_Realloc (block, 0, len);
}
/**
* Gets a framed RTP packet, or NULL in case of fatal error.
*/
static block_t *rtp_stream_recv (demux_t *demux, int fd)
{
ssize_t len = 0;
uint8_t hdr[2]; /* frame header */
/* Receives the RTP frame header */
do
{
ssize_t val = net_Read (VLC_OBJECT (demux), fd, NULL,
hdr + len, 2 - len, false);
if (val <= 0)
return NULL;
len += val;
}
while (len < 2);
block_t *block = block_Alloc (GetWBE (hdr));
/* Receives the RTP packet */
for (ssize_t i = 0; i < len;)
{
ssize_t val;
val = net_Read (VLC_OBJECT (demux), fd, NULL,
block->p_buffer + i, block->i_buffer - i, false);
if (val <= 0)
{
block_Release (block);
return NULL;
}
i += val;
}
return block;
}
/*
* Generic packet handlers
......@@ -518,7 +567,9 @@ static int Demux (demux_t *demux)
demux_sys_t *p_sys = demux->p_sys;
block_t *block;
block = rtp_dgram_recv (demux, p_sys->fd);
block = p_sys->framed_rtp
? rtp_dgram_recv (demux, p_sys->fd)
: rtp_stream_recv (demux, p_sys->fd);
if (!block)
return 0;
......
......@@ -51,5 +51,6 @@ struct demux_sys_t
uint16_t max_dropout;
uint16_t max_misorder;
bool autodetect;
bool framed_rtp;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment