#endif
#include <vlc/vlc.h>
+#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_block.h>
#include <errno.h>
+#include <assert.h>
+
/*****************************************************************************
* Module descriptor
*****************************************************************************/
"session will be made available. You must use an url: http://location to " \
"access the SDP via HTTP, rtsp://location for RTSP access, and sap:// " \
"for the SDP to be announced via SAP." )
+#define SAP_TEXT N_("SAP announcing")
+#define SAP_LONGTEXT N_("Announce this session with SAP.")
#define MUX_TEXT N_("Muxer")
#define MUX_LONGTEXT N_( \
"This allows you to specify the muxer used for the streaming output. " \
#define MAX_EMPTY_BLOCKS 200
vlc_module_begin();
- set_shortname( _("RTP"));
- set_description( _("RTP stream output") );
+ set_shortname( N_("RTP"));
+ set_description( N_("RTP stream output") );
set_capability( "sout stream", 0 );
add_shortcut( "rtp" );
set_category( CAT_SOUT );
SDP_LONGTEXT, true );
add_string( SOUT_CFG_PREFIX "mux", "", NULL, MUX_TEXT,
MUX_LONGTEXT, true );
+ add_bool( SOUT_CFG_PREFIX "sap", false, NULL, SAP_TEXT, SAP_LONGTEXT,
+ true );
add_string( SOUT_CFG_PREFIX "name", "", NULL, NAME_TEXT,
NAME_LONGTEXT, true );
*****************************************************************************/
static const char *ppsz_sout_options[] = {
"dst", "name", "port", "port-audio", "port-video", "*sdp", "ttl", "mux",
- "description", "url", "email", "phone",
+ "sap", "description", "url", "email", "phone",
"proto", "rtcp-mux",
"mp4a-latm", NULL
};
p_stream->p_sys = p_sys;
- vlc_mutex_init( p_stream, &p_sys->lock_sdp );
- vlc_mutex_init( p_stream, &p_sys->lock_es );
+ vlc_mutex_init( &p_sys->lock_sdp );
+ vlc_mutex_init( &p_sys->lock_es );
psz = var_GetNonEmptyString( p_stream, SOUT_CFG_PREFIX "mux" );
if( psz != NULL )
p_stream->pf_send = Send;
}
+ if( var_GetBool( p_stream, SOUT_CFG_PREFIX"sap" ) )
+ SDPHandleUrl( p_stream, "sap" );
+
psz = var_GetNonEmptyString( p_stream, SOUT_CFG_PREFIX "sdp" );
if( psz != NULL )
{
msg_Dbg( p_stream, "maximum RTP packet size: %d bytes", id->i_mtu );
- vlc_mutex_init( p_stream, &id->lock_sink );
+ vlc_mutex_init( &id->lock_sink );
id->sinkc = 0;
id->sinkv = NULL;
id->rtsp_id = NULL;
p_sys->psz_destination,
p_sys->i_ttl, id->i_port, id->i_port + 1 );
- id->p_fifo = block_FifoNew( p_stream );
+ id->p_fifo = block_FifoNew();
if( vlc_thread_create( id, "RTP send thread", ThreadSend,
VLC_THREAD_PRIORITY_HIGHEST, false ) )
goto error;
{
sout_stream_id_t *id = (sout_stream_id_t *)p_this;
unsigned i_caching = id->i_caching;
-#ifdef HAVE_TEE
- int fd[5] = { -1, -1, -1, -1, -1 };
-
- if( pipe( fd ) )
- fd[0] = fd[1] = -1;
- else
- if( pipe( fd ) )
- fd[2] = fd[3] = -1;
- else
- fd[4] = open( "/dev/null", O_WRONLY );
-#endif
while( !id->b_die )
{
mtime_t i_date = out->i_dts + i_caching;
ssize_t len = out->i_buffer;
-#ifdef HAVE_TEE
- if( fd[4] != -1 )
- len = write( fd[1], out->p_buffer, len);
- if( len == -1 )
- continue; /* Uho - should not happen */
-#endif
mwait( i_date );
vlc_mutex_lock( &id->lock_sink );
{
SendRTCP( id->sinkv[i].rtcp, out );
-#ifdef HAVE_TEE
- tee( fd[0], fd[3], len, 0 );
- if( splice( fd[2], NULL, id->sinkv[i].rtp_fd, NULL, len,
- SPLICE_F_NONBLOCK ) >= 0 )
- continue;
- if( errno == EAGAIN )
- continue;
-
- /* splice failed */
- splice( fd[2], NULL, fd[4], NULL, len, 0 );
-#else
if( send( id->sinkv[i].rtp_fd, out->p_buffer, len, 0 ) >= 0 )
continue;
-#endif
/* Retry sending to root out soft-errors */
if( send( id->sinkv[i].rtp_fd, out->p_buffer, len, 0 ) >= 0 )
continue;
deadv[deadc++] = id->sinkv[i].rtp_fd;
}
vlc_mutex_unlock( &id->lock_sink );
-
block_Release( out );
-#ifdef HAVE_TEE
- splice( fd[0], NULL, fd[4], NULL, len, 0 );
-#endif
for( unsigned i = 0; i < deadc; i++ )
{
rtp_add_sink( id, fd, true );
}
}
-
-#ifdef HAVE_TEE
- for( unsigned i = 0; i < 5; i++ )
- close( fd[i] );
-#endif
}
int rtp_add_sink( sout_stream_id_t *id, int fd, bool rtcp_mux )