pf_rtp_packetizer_t pf_packetize;
int i_mtu;
- /* for sending the packets */
+ /* Packets sinks */
sout_access_out_t *p_access;
vlc_mutex_t lock_sink;
- int i_sink;
- sout_access_out_t **sink;
- rtsp_stream_id_t *rtsp_id;
+ int fdc;
+ int *fdv;
+ rtsp_stream_id_t *rtsp_id;
};
{
if( !b_rtsp )
{
- msg_Err( p_stream, "missing destination and not in rtsp mode" );
+ msg_Err( p_stream, "missing destination and not in RTSP mode" );
free( p_sys );
return VLC_EGENERIC;
}
id->p_stream = p_stream;
vlc_mutex_init( p_stream, &id->lock_sink );
- id->i_sink = 0;
- id->sink = NULL;
+ id->fdc = 0;
+ id->fdv = NULL;
id->rtsp_id = NULL;
/* Check muxer type */
id->rtsp_id = NULL;
vlc_mutex_init( p_stream, &id->lock_sink );
- id->i_sink = 0;
- id->sink = NULL;
+ id->fdc = 0;
+ id->fdv = NULL;
switch( p_fmt->i_codec )
{
RtspDelId( p_sys->rtsp, id->rtsp_id );
vlc_mutex_destroy( &id->lock_sink );
- free( id->sink );
+ free( id->fdv );
/* Update SDP (sap/file) */
if( p_sys->b_export_sap && !p_sys->p_mux ) SapSetup( p_stream );
{
int i;
vlc_mutex_lock( &id->lock_sink );
- for( i = 0; i < id->i_sink; i++ )
+ for( i = 0; i < id->fdc; i++ )
{
- sout_AccessOutWrite( id->sink[i], block_Duplicate( out ) );
+ send( id->fdv[i], out->p_buffer, out->i_buffer, 0 );
}
vlc_mutex_unlock( &id->lock_sink );
}
}
-int rtp_add_sink( sout_stream_id_t *id, sout_access_out_t *access )
+int rtp_add_sink( sout_stream_id_t *id, int fd )
{
vlc_mutex_lock( &id->lock_sink );
- TAB_APPEND( id->i_sink, id->sink, access );
+ TAB_APPEND( id->fdc, id->fdv, fd );
vlc_mutex_unlock( &id->lock_sink );
return VLC_SUCCESS;
}
-void rtp_del_sink( sout_stream_id_t *id, sout_access_out_t *access )
+void rtp_del_sink( sout_stream_id_t *id, int fd )
{
- /* NOTE: must be safe to use if access is not a sink to id */
+ /* NOTE: must be safe to use if fd is not included */
vlc_mutex_lock( &id->lock_sink );
- TAB_REMOVE( id->i_sink, id->sink, access );
+ TAB_REMOVE( id->fdc, id->fdv, fd );
vlc_mutex_unlock( &id->lock_sink );
+ net_Close( fd );
}
static int rtp_packetize_mpa( sout_stream_t *p_stream, sout_stream_id_t *id,
struct rtsp_strack_t
{
sout_stream_id_t *id;
- sout_access_out_t *access;
+ int fd;
vlc_bool_t playing;
};
if( ses->trackv[j].id == id->sout_id )
{
rtsp_strack_t *tr = ses->trackv + j;
- sout_AccessOutDelete( tr->access );
+ net_Close( tr->fd );
REMOVE_ELEM( ses->trackv, ses->trackc, j );
- /* FIXME: are we supposed to notify the client? */
}
}
}
TAB_REMOVE( rtsp->sessionc, rtsp->sessionv, session );
for( i = 0; i < session->trackc; i++ )
- {
- rtp_del_sink( session->trackv[i].id, session->trackv[i].access );
- sout_AccessOutDelete( session->trackv[i].access );
- }
+ rtp_del_sink( session->trackv[i].id, session->trackv[i].fd );
free( session->trackv );
free( session );
}
else
{
- char ip[NI_MAXNUMERICHOST], url[NI_MAXNUMERICHOST + 8];
- static const char access[] = "udp{raw,rtcp}";
+ char ip[NI_MAXNUMERICHOST], src[NI_MAXNUMERICHOST];
rtsp_session_t *ses = NULL;
- rtsp_strack_t track = { id->sout_id, NULL, VLC_FALSE };
+ rtsp_strack_t track = { id->sout_id, -1, VLC_FALSE };
+ int sport;
if( httpd_ClientIP( cl, ip ) == NULL )
{
continue;
}
- snprintf( url, sizeof( url ),
- ( strchr( ip, ':' ) != NULL )
- ? "[%s]:%d" : "%s:%d",
- ip, loport );
-
- track.access = sout_AccessOutNew( p_stream->p_sout,
- access, url );
- if( track.access == NULL )
+ track.fd = net_ConnectDgram( p_stream, ip, loport, -1,
+ IPPROTO_UDP );
+ if( track.fd == -1 )
{
msg_Err( p_stream,
- "cannot create access output for %s://%s",
- access, url );
+ "cannot create RTP socket for %s port %u",
+ ip, loport );
answer->i_status = 500;
continue;
}
- char *src = var_GetNonEmptyString( track.access,
- "src-addr" );
- int sport = var_GetInteger( track.access, "src-port" );
+ net_GetSockAddress( track.fd, src, &sport );
vlc_mutex_lock( &rtsp->lock );
if( psz_session == NULL )
httpd_ServerIP( cl, ip );
- if( ( src != NULL ) && strcmp( src, ip ) )
+ if( strcmp( src, ip ) )
{
/* Specify source IP if it is different from the RTSP
* control connection server address */
}
answer->i_status = 200;
- free( src );
}
break;
}
&& ( ( id == NULL ) || ( tr->id == id->sout_id ) ) )
{
tr->playing = VLC_TRUE;
- rtp_add_sink( tr->id, tr->access );
+ rtp_add_sink( tr->id, tr->fd );
}
}
}
{
if( ses->trackv[i].id == id->sout_id )
{
- rtp_del_sink( id->sout_id, ses->trackv[i].access );
- sout_AccessOutDelete( ses->trackv[i].access );
+ rtp_del_sink( id->sout_id, ses->trackv[i].fd );
REMOVE_ELEM( ses->trackv, ses->trackc, i );
}
}