Commit 3ef18d45 authored by Pierre Ynard's avatar Pierre Ynard

rtsp: clean up multicast parameters

parent 87423359
...@@ -316,7 +316,6 @@ struct sout_stream_sys_t ...@@ -316,7 +316,6 @@ struct sout_stream_sys_t
uint16_t i_port_video; uint16_t i_port_video;
uint8_t proto; uint8_t proto;
bool rtcp_mux; bool rtcp_mux;
int i_ttl:9;
bool b_latm; bool b_latm;
/* VoD */ /* VoD */
...@@ -502,14 +501,11 @@ static int Open( vlc_object_t *p_this ) ...@@ -502,14 +501,11 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_sys->i_ttl = var_GetInteger( p_stream, SOUT_CFG_PREFIX "ttl" ); int i_ttl = var_GetInteger( p_stream, SOUT_CFG_PREFIX "ttl" );
if( p_sys->i_ttl == -1 ) if( i_ttl != -1 )
{ {
/* Normally, we should let the default hop limit up to the core, var_Create( p_stream, "ttl", VLC_VAR_INTEGER );
* but we have to know it to write our RTSP headers properly, var_SetInteger( p_stream, "ttl", i_ttl );
* which is why we ask the core. FIXME: broken when neither
* sout-rtp-ttl nor ttl are set. */
p_sys->i_ttl = var_InheritInteger( p_stream, "ttl" );
} }
p_sys->b_latm = var_GetBool( p_stream, SOUT_CFG_PREFIX "mp4a-latm" ); p_sys->b_latm = var_GetBool( p_stream, SOUT_CFG_PREFIX "mp4a-latm" );
...@@ -1020,6 +1016,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -1020,6 +1016,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->i_seq_sent_next = id->i_sequence; id->i_seq_sent_next = id->i_sequence;
int mcast_fd = -1;
if( p_sys->psz_destination != NULL ) if( p_sys->psz_destination != NULL )
{ {
/* Choose the port */ /* Choose the port */
...@@ -1094,9 +1091,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -1094,9 +1091,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
default: default:
{ {
int ttl = (p_sys->i_ttl >= 0) ? p_sys->i_ttl : -1;
int fd = net_ConnectDgram( p_stream, p_sys->psz_destination, int fd = net_ConnectDgram( p_stream, p_sys->psz_destination,
i_port, ttl, p_sys->proto ); i_port, -1, p_sys->proto );
if( fd == -1 ) if( fd == -1 )
{ {
msg_Err( p_stream, "cannot create RTP socket" ); msg_Err( p_stream, "cannot create RTP socket" );
...@@ -1107,6 +1103,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -1107,6 +1103,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &(int){ 0 }, setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &(int){ 0 },
sizeof (int)); sizeof (int));
rtp_add_sink( id, fd, p_sys->rtcp_mux, NULL ); rtp_add_sink( id, fd, p_sys->rtcp_mux, NULL );
/* FIXME: test if this is multicast */
mcast_fd = fd;
} }
} }
} }
...@@ -1143,11 +1141,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -1143,11 +1141,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
p_sys->i_pts_offset ); p_sys->i_pts_offset );
if( p_sys->rtsp != NULL ) if( p_sys->rtsp != NULL )
id->rtsp_id = RtspAddId( p_sys->rtsp, id, id->rtsp_id = RtspAddId( p_sys->rtsp, id, GetDWBE( id->ssrc ),
GetDWBE( id->ssrc ), id->rtp_fmt.clock_rate, mcast_fd );
id->rtp_fmt.clock_rate,
p_sys->psz_destination,
p_sys->i_ttl, id->i_port, id->i_port + 1 );
id->p_fifo = block_FifoNew(); id->p_fifo = block_FifoNew();
if( unlikely(id->p_fifo == NULL) ) if( unlikely(id->p_fifo == NULL) )
......
...@@ -31,8 +31,7 @@ void RtspUnsetup( rtsp_stream_t *rtsp ); ...@@ -31,8 +31,7 @@ void RtspUnsetup( rtsp_stream_t *rtsp );
rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid, rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
uint32_t ssrc, unsigned clock_rate, uint32_t ssrc, unsigned clock_rate,
const char *dst, int ttl, int mcast_fd );
unsigned loport, unsigned hiport );
void RtspDelId( rtsp_stream_t *rtsp, rtsp_stream_id_t * ); void RtspDelId( rtsp_stream_t *rtsp, rtsp_stream_id_t * );
char *RtspAppendTrackPath( rtsp_stream_id_t *id, const char *base ); char *RtspAppendTrackPath( rtsp_stream_id_t *id, const char *base );
......
...@@ -170,13 +170,11 @@ struct rtsp_stream_id_t ...@@ -170,13 +170,11 @@ struct rtsp_stream_id_t
{ {
rtsp_stream_t *stream; rtsp_stream_t *stream;
sout_stream_id_t *sout_id; sout_stream_id_t *sout_id;
unsigned clock_rate; /* needed to compute rtptime in RTP-Info */
httpd_url_t *url; httpd_url_t *url;
const char *dst;
int ttl;
unsigned track_id; unsigned track_id;
uint32_t ssrc; uint32_t ssrc;
uint16_t loport, hiport; unsigned clock_rate; /* needed to compute rtptime in RTP-Info */
int mcast_fd;
}; };
...@@ -226,9 +224,7 @@ char *RtspAppendTrackPath( rtsp_stream_id_t *id, const char *base ) ...@@ -226,9 +224,7 @@ char *RtspAppendTrackPath( rtsp_stream_id_t *id, const char *base )
rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid, rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
uint32_t ssrc, unsigned clock_rate, uint32_t ssrc, unsigned clock_rate,
/* Multicast stuff - TODO: cleanup */ int mcast_fd)
const char *dst, int ttl,
unsigned loport, unsigned hiport )
{ {
if (rtsp->track_id > 999) if (rtsp->track_id > 999)
{ {
...@@ -248,13 +244,7 @@ rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid, ...@@ -248,13 +244,7 @@ rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
id->track_id = rtsp->track_id; id->track_id = rtsp->track_id;
id->ssrc = ssrc; id->ssrc = ssrc;
id->clock_rate = clock_rate; id->clock_rate = clock_rate;
id->dst = dst; id->mcast_fd = mcast_fd;
if( id->dst != NULL )
{
id->ttl = ttl;
id->loport = loport;
id->hiport = hiport;
}
urlbuf = RtspAppendTrackPath( id, rtsp->psz_path ); urlbuf = RtspAppendTrackPath( id, rtsp->psz_path );
if( urlbuf == NULL ) if( urlbuf == NULL )
...@@ -684,7 +674,7 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id, ...@@ -684,7 +674,7 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
tpt = transport_next( tpt ) ) tpt = transport_next( tpt ) )
{ {
bool b_multicast = true, b_unsupp = false; bool b_multicast = true, b_unsupp = false;
unsigned loport = 5004, hiport = 5005; /* from RFC3551 */ unsigned loport = 5004, hiport; /* from RFC3551 */
/* Check transport protocol. */ /* Check transport protocol. */
/* Currently, we only support RTP/AVP over UDP */ /* Currently, we only support RTP/AVP over UDP */
...@@ -752,10 +742,19 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id, ...@@ -752,10 +742,19 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
if( b_multicast ) if( b_multicast )
{ {
const char *dst = id->dst; char dst[NI_MAXNUMERICHOST];
if( dst == NULL ) int dport, ttl;
if( id->mcast_fd == -1 )
continue; continue;
net_GetPeerAddress(id->mcast_fd, dst, &dport);
ttl = var_InheritInteger(owner, "ttl");
if (ttl <= 0)
/* FIXME: the TTL is left to the OS default, we can
* only guess that it's 1. */
ttl = 1;
if( psz_session == NULL ) if( psz_session == NULL )
{ {
/* Create a dummy session ID */ /* Create a dummy session ID */
...@@ -768,8 +767,8 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id, ...@@ -768,8 +767,8 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
httpd_MsgAdd( answer, "Transport", httpd_MsgAdd( answer, "Transport",
"RTP/AVP/UDP;destination=%s;port=%u-%u;" "RTP/AVP/UDP;destination=%s;port=%u-%u;"
"ttl=%d;mode=play", "ttl=%d;mode=play",
dst, id->loport, id->hiport, dst, dport, dport + 1, ttl );
( id->ttl > 0 ) ? id->ttl : 1 ); /* FIXME: this doesn't work with RTP + RTCP mux */
} }
else else
{ {
......
...@@ -301,7 +301,7 @@ static vod_media_t *MediaNew( vod_t *p_vod, const char *psz_name, ...@@ -301,7 +301,7 @@ static vod_media_t *MediaNew( vod_t *p_vod, const char *psz_name,
{ {
media_es_t *p_es = p_media->es[i]; media_es_t *p_es = p_media->es[i];
p_es->rtsp_id = RtspAddId(p_media->rtsp, NULL, 0, p_es->rtsp_id = RtspAddId(p_media->rtsp, NULL, 0,
p_es->rtp_fmt.clock_rate, NULL, 0, 0, 0); p_es->rtp_fmt.clock_rate, -1);
if (p_es->rtsp_id == NULL) if (p_es->rtsp_id == NULL)
goto error; goto error;
} }
......
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