]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/rtp.c
Include assert.h where assert() is used
[vlc] / modules / stream_out / rtp.c
index b0f6dd0ee0d76d6201076fa8570e16d820c4cfdd..1cd6ee53b7e547004364398d473546dc19f19ce0 100644 (file)
@@ -31,6 +31,7 @@
 #endif
 
 #include <vlc/vlc.h>
+#include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_block.h>
 
@@ -60,6 +61,8 @@
 
 #include <errno.h>
 
+#include <assert.h>
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -73,6 +76,8 @@
     "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. " \
@@ -144,8 +149,8 @@ static void Close( vlc_object_t * );
 #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 );
@@ -158,6 +163,8 @@ vlc_module_begin();
                 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 );
@@ -196,7 +203,7 @@ vlc_module_end();
  *****************************************************************************/
 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
 };
@@ -434,8 +441,8 @@ static int Open( vlc_object_t *p_this )
 
     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 )
@@ -496,6 +503,9 @@ static int Open( vlc_object_t *p_this )
         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 )
     {
@@ -884,7 +894,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
 
     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;
@@ -1162,7 +1172,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
                                  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;
@@ -1361,17 +1371,6 @@ static void ThreadSend( vlc_object_t *p_this )
 {
     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 )
     {
@@ -1382,12 +1381,6 @@ static void ThreadSend( vlc_object_t *p_this )
         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 );
@@ -1398,20 +1391,8 @@ static void ThreadSend( vlc_object_t *p_this )
         {
             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;
@@ -1419,11 +1400,7 @@ static void ThreadSend( vlc_object_t *p_this )
             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++ )
         {
@@ -1441,11 +1418,6 @@ static void ThreadSend( vlc_object_t *p_this )
             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 )