]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/rtp.c
svg module: fix memleak.
[vlc] / modules / stream_out / rtp.c
index c74f65953016033b12bb8ad0283e1ce393e14db0..fb79a6881801efd34feb9e7338aa63b2e4cc85f1 100644 (file)
@@ -234,7 +234,7 @@ static int               MuxSend( sout_stream_t *, sout_stream_id_t *,
 static sout_access_out_t *GrabberCreate( sout_stream_t *p_sout );
 static void ThreadSend( vlc_object_t *p_this );
 
-static void SDPHandleUrl( sout_stream_t *, char * );
+static void SDPHandleUrl( sout_stream_t *, const char * );
 
 static int SapSetup( sout_stream_t *p_stream );
 static int FileSetup( sout_stream_t *p_stream );
@@ -607,7 +607,7 @@ static void Close( vlc_object_t * p_this )
 /*****************************************************************************
  * SDPHandleUrl:
  *****************************************************************************/
-static void SDPHandleUrl( sout_stream_t *p_stream, char *psz_url )
+static void SDPHandleUrl( sout_stream_t *p_stream, const char *psz_url )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
     vlc_url_t url;
@@ -945,6 +945,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
             msg_Err (p_stream, "bad SRTP key/salt combination (%m)");
             goto error;
         }
+        id->i_sequence = 0; /* FIXME: awful hack for libvlc_srtp */
     }
 
     vlc_mutex_init( &id->lock_sink );
@@ -1054,6 +1055,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
         case VLC_FOURCC( 'm', 'p', '3', ' ' ):
             id->i_payload_type = 14;
             id->psz_enc = "MPA";
+            id->i_clock_rate = 90000; /* not 44100 */
             id->pf_packetize = rtp_packetize_mpa;
             break;
         case VLC_FOURCC( 'm', 'p', 'g', 'v' ):
@@ -1309,6 +1311,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
     block_t *p_next;
 
     assert( p_stream->p_sys->p_mux == NULL );
+    (void)p_stream;
 
     while( p_buffer != NULL )
     {
@@ -1431,7 +1434,7 @@ 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;
 
-    while( !id->b_die )
+    while( vlc_object_alive (id) )
     {
         block_t *out = block_FifoGet( id->p_fifo );
         if( out == NULL )
@@ -1440,16 +1443,10 @@ static void ThreadSend( vlc_object_t *p_this )
         if( id->srtp )
         {   /* FIXME: this is awfully inefficient */
             size_t len = out->i_buffer;
-            int val = srtp_send( id->srtp, out->p_buffer, &len,
-                                out->i_buffer );
-            if( val == ENOSPC )
-            {
-                out = block_Realloc( out, 0, len );
-                if( out == NULL )
-                    continue;
-                val = srtp_send( id->srtp, out->p_buffer, &len,
-                                 out->i_buffer );
-            }
+            out = block_Realloc( out, 0, len + 10 );
+            out->i_buffer = len;
+
+            int val = srtp_send( id->srtp, out->p_buffer, &len, len + 10 );
             if( val )
             {
                 errno = val;
@@ -1642,8 +1639,8 @@ static int MuxDel( sout_stream_t *p_stream, sout_stream_id_t *id )
 }
 
 
-static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
-                                        const block_t *p_buffer )
+static ssize_t AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
+                                            const block_t *p_buffer )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
     sout_stream_id_t *id = p_sys->es[0];
@@ -1651,14 +1648,14 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
     int64_t  i_dts = p_buffer->i_dts;
 
     uint8_t         *p_data = p_buffer->p_buffer;
-    unsigned int    i_data  = p_buffer->i_buffer;
-    unsigned int    i_max   = id->i_mtu - 12;
+    size_t          i_data  = p_buffer->i_buffer;
+    size_t          i_max   = id->i_mtu - 12;
 
-    unsigned i_packet = ( p_buffer->i_buffer + i_max - 1 ) / i_max;
+    size_t i_packet = ( p_buffer->i_buffer + i_max - 1 ) / i_max;
 
     while( i_data > 0 )
     {
-        unsigned int i_size;
+        size_t i_size;
 
         /* output complete packet */
         if( p_sys->packet &&
@@ -1693,8 +1690,8 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
 }
 
 
-static int AccessOutGrabberWrite( sout_access_out_t *p_access,
-                                  block_t *p_buffer )
+static ssize_t AccessOutGrabberWrite( sout_access_out_t *p_access,
+                                      block_t *p_buffer )
 {
     sout_stream_t *p_stream = (sout_stream_t*)p_access->p_sys;