[vlc-devel] Re: modules/codec/ffmpeg/mux.c oddness

Olivier Houchard cognet at ci0.org
Thu Feb 15 16:10:45 CET 2007


On Thu, Feb 15, 2007 at 03:31:50PM +0100, Remi Denis-Courmont wrote:
> 
> On Wed, 14 Feb 2007 17:34:32 +0100, Olivier Houchard <cognet at ci0.org> wrote:
> > In modules/codec/ffmpeg/mux.c, IOWrite(), the callback used by ffmpeg to
> > write
> > into the buffer, wrongly assumes sout_AccessWrite() returns the number of
> > bytes
> > written. It is true for the "file" access_out, however it is wrong for
> > others,
> > such as http, which just returns 0 on success. I applied the attached
> > patch,
> > which just returns the value returned by sout_AccessWrite() to ffmpeg.
> > That
> > should work, as ffmpeg assumes any negative value to be an error, and just
> > discards any >= 0 value.
> > Most other muxers just ignore the return value of sout_AccessWrite().
> 
> Still, this looks very much like a bug in the http access output rather
> than ffmpeg muxer.
> 

Well I agree.
Attached patch naively calculate the length for http and udp, both of which
used to return 0.

Comments ?

Regards,

Olivier
-------------- next part --------------
Index: http.c
===================================================================
--- http.c	(revision 18840)
+++ http.c	(working copy)
@@ -374,6 +374,7 @@
 {
     sout_access_out_sys_t *p_sys = p_access->p_sys;
     int i_err = 0;
+    int i_len = 0;
 
     while( p_buffer )
     {
@@ -409,6 +410,7 @@
                                 p_sys->i_header_size );
         }
 
+        i_len += p_buffer->i_buffer;
         /* send data */
         i_err = httpd_StreamSend( p_sys->p_httpd_stream, p_buffer->p_buffer,
                                   p_buffer->i_buffer );
@@ -428,7 +430,7 @@
         block_ChainRelease( p_buffer );
     }
 
-    return( i_err < 0 ? VLC_EGENERIC : VLC_SUCCESS );
+    return( i_err < 0 ? VLC_EGENERIC : i_len );
 }
 
 /*****************************************************************************
Index: udp.c
===================================================================
--- udp.c	(revision 18840)
+++ udp.c	(working copy)
@@ -386,6 +386,7 @@
 static int Write( sout_access_out_t *p_access, block_t *p_buffer )
 {
     sout_access_out_sys_t *p_sys = p_access->p_sys;
+    int i_len = 0;
 
     while( p_buffer )
     {
@@ -413,6 +414,7 @@
             p_sys->p_buffer = NULL;
         }
 
+        i_len += p_buffer->i_buffer;
         while( p_buffer->i_buffer )
         {
             int i_payload_size = p_sys->i_mtu;
@@ -462,7 +464,7 @@
         p_buffer = p_next;
     }
 
-    return( p_sys->p_thread->b_error ? -1 : 0 );
+    return( p_sys->p_thread->b_error ? -1 : i_len );
 }
 
 /*****************************************************************************
@@ -472,6 +474,7 @@
 {
     sout_access_out_sys_t   *p_sys = p_access->p_sys;
     block_t *p_buf;
+    int i_len;
 
     while ( p_sys->p_thread->p_empty_blocks->i_depth >= MAX_EMPTY_BLOCKS )
     {
@@ -479,9 +482,10 @@
         block_Release( p_buf );
     }
 
+    i_len = p_buffer->i_buffer;
     block_FifoPut( p_sys->p_thread->p_fifo, p_buffer );
 
-    return( p_sys->p_thread->b_error ? -1 : 0 );
+    return( p_sys->p_thread->b_error ? -1 : i_len );
 }
 
 /*****************************************************************************


More information about the vlc-devel mailing list