]> git.sesse.net Git - vlc/blob - modules/mux/ogg.c
* modules/demux/ogg.c: reworked a bit. Ogg web radios should work again, vorbis audio...
[vlc] / modules / mux / ogg.c
1 /*****************************************************************************
2  * ogg.c: ogg muxer module for vlc
3  *****************************************************************************
4  * Copyright (C) 2001, 2002 VideoLAN
5  * $Id: ogg.c,v 1.9 2003/09/25 23:09:41 gbazin Exp $
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *          Gildas Bazin <gbazin@netcourrier.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <stdlib.h>
29 #include <string.h>
30 #include <sys/types.h>
31
32 #include <vlc/vlc.h>
33 #include <vlc/input.h>
34 #include <vlc/sout.h>
35
36 #include "codecs.h"
37
38 #include <ogg/ogg.h>
39
40 /*****************************************************************************
41  * Exported prototypes
42  *****************************************************************************/
43 static int     Open   ( vlc_object_t * );
44 static void    Close  ( vlc_object_t * );
45
46 static int Capability(sout_mux_t *, int, void *, void * );
47 static int AddStream( sout_mux_t *, sout_input_t * );
48 static int DelStream( sout_mux_t *, sout_input_t * );
49 static int Mux      ( sout_mux_t * );
50
51 /*****************************************************************************
52  * Module descriptor
53  *****************************************************************************/
54 vlc_module_begin();
55     set_description( _("Ogg/ogm muxer") );
56     set_capability( "sout mux", 10 );
57     add_shortcut( "ogg" );
58     add_shortcut( "ogm" );
59     set_callbacks( Open, Close );
60 vlc_module_end();
61
62 /*****************************************************************************
63  *
64  *****************************************************************************/
65 #define FREE( p ) if( p ) { free( p ); (p) = NULL; }
66
67 #define PACKET_TYPE_HEADER   0x01
68 #define PACKET_TYPE_COMMENT  0x03
69
70 #define PACKET_IS_SYNCPOINT      0x08
71
72 typedef struct
73 #ifdef HAVE_ATTRIBUTE_PACKED
74     __attribute__((__packed__))
75 #endif
76 {
77     int32_t i_width;
78     int32_t i_height;
79 } ogg_stream_header_video_t;
80
81 typedef struct
82 #ifdef HAVE_ATTRIBUTE_PACKED
83     __attribute__((__packed__))
84 #endif
85 {
86     int16_t i_channels;
87     int16_t i_block_align;
88     int32_t i_avgbytespersec;
89 } ogg_stream_header_audio_t;
90
91 typedef struct
92 #ifdef HAVE_ATTRIBUTE_PACKED
93     __attribute__((__packed__))
94 #endif
95 {
96     uint8_t i_packet_type;
97
98     char stream_type[8];
99     char sub_type[4];
100
101     int32_t i_size;
102
103     int64_t i_time_unit;
104     int64_t i_samples_per_unit;
105     int32_t i_default_len;
106
107     int32_t i_buffer_size;
108     int16_t i_bits_per_sample;
109     int16_t i_padding_0;            // hum hum
110     union
111     {
112         ogg_stream_header_video_t video;
113         ogg_stream_header_audio_t audio;
114     } header;
115
116 } ogg_stream_header_t;
117
118
119 typedef struct
120 {
121     int i_cat;
122     int i_fourcc;
123
124     ogg_stream_header_t header;
125
126     int i_packet_no;
127
128     mtime_t             i_dts;
129     mtime_t             i_length;
130     ogg_stream_state    os;
131
132 } ogg_stream_t;
133
134 struct sout_mux_sys_t
135 {
136     int     b_write_header;
137     int     i_streams;
138
139     mtime_t i_start_dts;
140 };
141
142 #define SetWLE( p, v ) _SetWLE( (uint8_t*)p, v)
143 static void _SetWLE( uint8_t *p, uint16_t i_dw )
144 {
145     p[1] = ( i_dw >>  8 )&0xff;
146     p[0] = ( i_dw       )&0xff;
147 }
148
149 #define SetDWLE( p, v ) _SetDWLE( (uint8_t*)p, v)
150 static void _SetDWLE( uint8_t *p, uint32_t i_dw )
151 {
152     p[3] = ( i_dw >> 24 )&0xff;
153     p[2] = ( i_dw >> 16 )&0xff;
154     p[1] = ( i_dw >>  8 )&0xff;
155     p[0] = ( i_dw       )&0xff;
156 }
157 #define SetQWLE( p, v ) _SetQWLE( (uint8_t*)p, v)
158 static void _SetQWLE( uint8_t *p, uint64_t i_qw )
159 {
160     SetDWLE( p,   i_qw&0xffffffff );
161     SetDWLE( p+4, ( i_qw >> 32)&0xffffffff );
162 }
163
164 static void OggSetDate( sout_buffer_t *, mtime_t , mtime_t  );
165 static sout_buffer_t *OggStreamFlush( sout_mux_t *, ogg_stream_state *,
166                                       mtime_t );
167
168 /*****************************************************************************
169  * Open:
170  *****************************************************************************/
171 static int Open( vlc_object_t *p_this )
172 {
173     sout_mux_t      *p_mux = (sout_mux_t*)p_this;
174     sout_mux_sys_t  *p_sys;
175
176     msg_Info( p_mux, "Open" );
177
178     p_sys                 = malloc( sizeof( sout_mux_sys_t ) );
179     p_sys->i_streams      = 0;
180     p_sys->b_write_header = VLC_TRUE;
181
182     p_mux->p_sys        = p_sys;
183     p_mux->pf_capacity  = Capability;
184     p_mux->pf_addstream = AddStream;
185     p_mux->pf_delstream = DelStream;
186     p_mux->pf_mux       = Mux;
187     p_mux->i_preheader  = 1;
188
189     return VLC_SUCCESS;
190 }
191
192 /*****************************************************************************
193  * Close:
194  *****************************************************************************/
195
196 static void Close( vlc_object_t * p_this )
197 {
198     sout_mux_t      *p_mux = (sout_mux_t*)p_this;
199     sout_mux_sys_t  *p_sys = p_mux->p_sys;
200
201     msg_Info( p_mux, "Close" );
202
203     free( p_sys );
204 }
205
206 static int Capability( sout_mux_t *p_mux, int i_query, void *p_args,
207                        void *p_answer )
208 {
209    switch( i_query )
210    {
211         case SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME:
212             *(vlc_bool_t*)p_answer = VLC_FALSE;
213             return( SOUT_MUX_CAP_ERR_OK );
214         default:
215             return( SOUT_MUX_CAP_ERR_UNIMPLEMENTED );
216    }
217 }
218
219 static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
220 {
221     sout_mux_sys_t  *p_sys = p_mux->p_sys;
222     ogg_stream_t        *p_stream;
223
224     msg_Dbg( p_mux, "adding input" );
225     p_input->p_sys = (void*)p_stream = malloc( sizeof( ogg_stream_t ) );
226
227     p_stream->i_cat       = p_input->p_fmt->i_cat;
228     p_stream->i_fourcc    = p_input->p_fmt->i_fourcc;
229     p_stream->i_packet_no = 0;
230
231     p_stream->header.i_packet_type = PACKET_TYPE_HEADER;
232     switch( p_input->p_fmt->i_cat )
233     {
234     case VIDEO_ES:
235         switch( p_input->p_fmt->i_fourcc )
236         {
237         case VLC_FOURCC( 'm', 'p','4', 'v' ):
238         case VLC_FOURCC( 'D', 'I','V', '3' ):
239             memcpy( p_stream->header.stream_type, "video    ", 8 );
240             if( p_input->p_fmt->i_fourcc == VLC_FOURCC( 'm', 'p','4', 'v' ) )
241             {
242                 memcpy( p_stream->header.sub_type, "XVID", 4 );
243             }
244             else if( p_input->p_fmt->i_fourcc ==
245                      VLC_FOURCC( 'D', 'I','V', '3' ) )
246             {
247                 memcpy( p_stream->header.sub_type, "DIV3", 4 );
248             }
249             SetDWLE( &p_stream->header.i_size,
250                      sizeof( ogg_stream_header_t ) - 1);
251             /* XXX this won't make mplayer happy,
252              * but vlc can read that without any problem so...*/
253             SetQWLE( &p_stream->header.i_time_unit, 10*1000 );
254             //(int64_t)10*1000*1000/(int64_t)25 );  // FIXME (25fps)
255             SetQWLE( &p_stream->header.i_samples_per_unit, 1 );
256             SetDWLE( &p_stream->header.i_default_len, 0 );      /* ??? */
257             SetDWLE( &p_stream->header.i_buffer_size, 1024*1024 );
258             SetWLE( &p_stream->header.i_bits_per_sample, 0 );
259             SetDWLE( &p_stream->header.header.video.i_width,
260                      p_input->p_fmt->i_width );
261             SetDWLE( &p_stream->header.header.video.i_height,
262                      p_input->p_fmt->i_height );
263             break;
264
265         case VLC_FOURCC( 't', 'h', 'e', 'o' ):
266           msg_Dbg( p_mux, "theora stream" );
267           break;
268
269         default:
270             FREE( p_input->p_sys );
271             return( VLC_EGENERIC );
272         }
273         break;
274
275     case AUDIO_ES:
276         switch( p_input->p_fmt->i_fourcc )
277         {
278         case VLC_FOURCC( 'm', 'p','g', 'a' ):
279         case VLC_FOURCC( 'a', '5','2', ' ' ):
280             memcpy( p_stream->header.stream_type, "audio    ", 8 );
281             if( p_input->p_fmt->i_fourcc == VLC_FOURCC( 'm', 'p','g', 'a' ) )
282             {
283                 memcpy( p_stream->header.sub_type, "55  ", 4 );
284             }
285             else if( p_input->p_fmt->i_fourcc ==
286                      VLC_FOURCC( 'a', '5','2', ' ' ) )
287             {
288                 memcpy( p_stream->header.sub_type, "2000", 4 );
289             }
290             SetDWLE( &p_stream->header.i_size,
291                      sizeof( ogg_stream_header_t ) - 1);
292             SetQWLE( &p_stream->header.i_time_unit, 1000000 );  /* is it used ? */
293             SetDWLE( &p_stream->header.i_default_len, 0 );      /* ??? */
294             SetDWLE( &p_stream->header.i_buffer_size, 30*1024 );
295             SetQWLE( &p_stream->header.i_samples_per_unit,
296                      p_input->p_fmt->i_sample_rate );
297             SetWLE( &p_stream->header.i_bits_per_sample, 0 );
298             SetDWLE( &p_stream->header.header.audio.i_channels,
299                      p_input->p_fmt->i_channels );
300             SetDWLE( &p_stream->header.header.audio.i_block_align,
301                      p_input->p_fmt->i_block_align );
302             SetDWLE( &p_stream->header.header.audio.i_avgbytespersec, 0 );
303             break;
304
305         case VLC_FOURCC( 'v', 'o', 'r', 'b' ):
306           msg_Dbg( p_mux, "vorbis stream" );
307           break;
308
309         default:
310             FREE( p_input->p_sys );
311             return( VLC_EGENERIC );
312         }
313         break;
314
315     default:
316         FREE( p_input->p_sys );
317         return( VLC_EGENERIC );
318     }
319
320     ogg_stream_init( &p_stream->os, rand () );
321
322     p_sys->i_streams++;
323     return( VLC_SUCCESS );
324 }
325
326 static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
327 {
328     ogg_stream_t        *p_stream = (ogg_stream_t*)p_input->p_sys;
329     sout_buffer_t       *p_og;
330
331     msg_Dbg( p_mux, "removing input" );
332
333     /* flush all remaining data */
334
335     if( p_input->p_sys )
336     {
337         p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
338         if( p_og )
339         {
340             OggSetDate( p_og, p_stream->i_dts, p_stream->i_length );
341
342             sout_AccessOutWrite( p_mux->p_access, p_og );
343         }
344
345         ogg_stream_clear( &p_stream->os );
346
347         FREE( p_input->p_sys );
348     }
349     return( 0 );
350 }
351
352 /*
353  * TODO  move this function to src/stream_output.c (used by nearly all muxers)
354  */
355 static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
356 {
357     mtime_t i_dts;
358     int     i_stream;
359     int     i;
360
361     for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
362     {
363         sout_fifo_t  *p_fifo;
364
365         p_fifo = p_mux->pp_inputs[i]->p_fifo;
366
367         if( p_fifo->i_depth > 1 )
368         {
369             sout_buffer_t *p_buf;
370
371             p_buf = sout_FifoShow( p_fifo );
372             if( i_stream < 0 || p_buf->i_dts < i_dts )
373             {
374                 i_dts = p_buf->i_dts;
375                 i_stream = i;
376             }
377         }
378         else
379         {
380             return( -1 ); // wait that all fifo have at least 2 packets
381         }
382     }
383     if( pi_stream )
384     {
385         *pi_stream = i_stream;
386     }
387     if( pi_dts )
388     {
389         *pi_dts = i_dts;
390     }
391     return( i_stream );
392 }
393
394 static sout_buffer_t *OggStreamFlush( sout_mux_t *p_mux,
395                                       ogg_stream_state *p_os, mtime_t i_pts )
396 {
397     sout_buffer_t *p_og, *p_og_first = NULL;
398     ogg_page      og;
399
400     for( ;; )
401     {
402         /* flush all data */
403         int i_result;
404         int i_size;
405         if( ( i_result = ogg_stream_flush( p_os, &og ) ) == 0 )
406         {
407             break;
408         }
409         i_size = og.header_len + og.body_len;
410         p_og = sout_BufferNew( p_mux->p_sout, i_size);
411
412         memcpy( p_og->p_buffer, og.header, og.header_len );
413         memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len );
414         p_og->i_size    = i_size;
415         p_og->i_dts     = 0;
416         p_og->i_pts     = i_pts;
417         p_og->i_length  = 0;
418
419         i_pts   = 0; // write it only once
420
421         sout_BufferChain( &p_og_first, p_og );
422     }
423
424     return( p_og_first );
425 }
426
427 static sout_buffer_t *OggStreamPageOut( sout_mux_t *p_mux,
428                                         ogg_stream_state *p_os, mtime_t i_pts )
429 {
430     sout_buffer_t *p_og, *p_og_first = NULL;
431     ogg_page      og;
432
433     for( ;; )
434     {
435         /* flush all data */
436         int i_result;
437         int i_size;
438         if( ( i_result = ogg_stream_pageout( p_os, &og ) ) == 0 )
439         {
440             break;
441         }
442         i_size = og.header_len + og.body_len;
443         p_og = sout_BufferNew( p_mux->p_sout, i_size);
444
445         memcpy( p_og->p_buffer, og.header, og.header_len );
446         memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len );
447         p_og->i_size    = i_size;
448         p_og->i_dts     = 0;
449         p_og->i_pts     = i_pts;
450         p_og->i_length  = 0;
451
452         i_pts   = 0; // write them only once
453
454         sout_BufferChain( &p_og_first, p_og );
455     }
456
457     return( p_og_first );
458 }
459
460 static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
461 {
462     sout_buffer_t *p_hdr = NULL;
463     sout_buffer_t *p_og;
464     ogg_packet    op;
465     int i;
466
467     /* Write header for each stream. All b_o_s (beginning of stream) packets
468      * must appear first in the ogg stream so we take care of them first. */
469     for( i = 0; i < p_mux->i_nb_inputs; i++ )
470     {
471         ogg_stream_t *p_stream;
472
473         p_stream = (ogg_stream_t*)p_mux->pp_inputs[i]->p_sys;
474
475         if( p_stream->i_fourcc == VLC_FOURCC( 'v', 'o', 'r', 'b' ) ||
476             p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
477         {
478             /* Special case, headers are already there in the
479              * incoming stream */
480
481             /* first packet in order: vorbis info */
482             p_og = sout_FifoGet( p_mux->pp_inputs[i]->p_fifo );
483             op.packet = p_og->p_buffer;
484             op.bytes  = p_og->i_size;
485             op.b_o_s  = 1;
486             op.e_o_s  = 0;
487             op.granulepos = 0;
488             op.packetno = p_stream->i_packet_no++;
489             ogg_stream_packetin( &p_stream->os, &op );
490         }
491         else
492         {
493             /* ds header */
494             op.packet = (uint8_t*)&p_stream->header;
495             op.bytes  = sizeof( ogg_stream_t );
496             op.b_o_s  = 1;
497             op.e_o_s  = 0;
498             op.granulepos = 0;
499             op.packetno = p_stream->i_packet_no++;
500             ogg_stream_packetin( &p_stream->os, &op );
501         }
502
503         p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
504         sout_BufferChain( &p_hdr, p_og );
505     }
506
507     /* Take care of the non b_o_s headers */
508     for( i = 0; i < p_mux->i_nb_inputs; i++ )
509     {
510         ogg_stream_t *p_stream;
511
512         p_stream = (ogg_stream_t*)p_mux->pp_inputs[i]->p_sys;
513
514         if( p_stream->i_fourcc == VLC_FOURCC( 'v', 'o', 'r', 'b' ) ||
515             p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
516         {
517             /* Special case, headers are already there in the incoming stream.
518              * We need to gather them an mark them as headers. */
519             int j;
520             for( j = 0; j < 2; j++ )
521             {
522                 /* next packets in order: comments and codebooks */
523                 p_og = sout_FifoGet( p_mux->pp_inputs[i]->p_fifo );
524                 op.packet = p_og->p_buffer;
525                 op.bytes  = p_og->i_size;
526                 op.b_o_s  = 0;
527                 op.e_o_s  = 0;
528                 op.granulepos = 0;
529                 op.packetno = p_stream->i_packet_no++;
530                 ogg_stream_packetin( &p_stream->os, &op );
531             }
532         }
533         else
534         {
535             uint8_t com[128];
536             int     i_com;
537
538             /* comment */
539             com[0] = PACKET_TYPE_COMMENT;
540             i_com = snprintf( &com[1], 128, "VLC 0.5.x stream output" ) + 1;
541             op.packet = com;
542             op.bytes  = i_com;
543             op.b_o_s  = 0;
544             op.e_o_s  = 0;
545             op.granulepos = 0;
546             op.packetno = p_stream->i_packet_no++;
547             ogg_stream_packetin( &p_stream->os, &op );
548         }
549
550         p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
551         sout_BufferChain( &p_hdr, p_og );
552     }
553
554     /* set HEADER flag */
555     for( p_og = p_hdr; p_og != NULL; p_og = p_og->p_next )
556     {
557         p_og->i_flags |= SOUT_BUFFER_FLAGS_HEADER;
558     }
559     return( p_hdr );
560 }
561
562 static void OggSetDate( sout_buffer_t *p_og, mtime_t i_dts, mtime_t i_length )
563 {
564     int i_count;
565     sout_buffer_t *p_tmp;
566     mtime_t i_delta;
567
568     for( p_tmp = p_og, i_count = 0; p_tmp != NULL; p_tmp = p_tmp->p_next )
569     {
570         i_count++;
571     }
572     i_delta = i_length / i_count;
573
574     for( p_tmp = p_og; p_tmp != NULL; p_tmp = p_tmp->p_next )
575     {
576         p_tmp->i_dts    = i_dts;
577         p_tmp->i_length = i_delta;
578
579         i_dts += i_delta;
580     }
581 }
582
583 static int Mux( sout_mux_t *p_mux )
584 {
585     sout_mux_sys_t      *p_sys  = p_mux->p_sys;
586     sout_buffer_t       *p_og = NULL;
587     int                 i_stream;
588     mtime_t             i_dts;
589
590     if( p_sys->b_write_header )
591     {
592         if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
593         {
594             msg_Dbg( p_mux, "waiting data..." );
595             return( VLC_SUCCESS );
596         }
597         p_sys->i_start_dts = i_dts;
598
599         msg_Dbg( p_mux, "writing header" );
600         sout_BufferChain( &p_og, OggCreateHeader( p_mux, i_dts ) );
601         p_sys->b_write_header = VLC_FALSE;
602     }
603
604     for( ;; )
605     {
606         sout_input_t    *p_input;
607         ogg_stream_t    *p_stream;
608         sout_buffer_t   *p_data;
609         ogg_packet          op;
610
611         if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
612         {
613             //msg_Dbg( p_mux, "waiting data..." );
614             return( VLC_SUCCESS );
615         }
616         //msg_Dbg( p_mux, "doing job" );
617
618         if( p_sys->i_start_dts <= 0 ) p_sys->i_start_dts = i_dts;
619
620         p_input  = p_mux->pp_inputs[i_stream];
621         p_stream = (ogg_stream_t*)p_input->p_sys;
622
623         p_data  = sout_FifoGet( p_input->p_fifo );
624
625         if( p_stream->i_fourcc != VLC_FOURCC( 'v', 'o', 'r', 'b' ) )
626         {
627             sout_BufferReallocFromPreHeader( p_mux->p_sout, p_data, 1 );
628             p_data->p_buffer[0] = PACKET_IS_SYNCPOINT;      // FIXME
629         }
630
631         op.packet   = p_data->p_buffer;
632         op.bytes    = p_data->i_size;
633         op.b_o_s    = 0;
634         op.e_o_s    = 0;
635         op.packetno = p_stream->i_packet_no++;
636
637         if( p_stream->i_cat == AUDIO_ES )
638         {
639             if( p_stream->i_fourcc == VLC_FOURCC( 'v', 'o', 'r', 'b' ) )
640             {
641                 /* number of sample from begining + current packet */
642                 op.granulepos =
643                     ( i_dts + p_data->i_length - p_sys->i_start_dts ) *
644                     p_input->p_fmt->i_sample_rate / (int64_t)1000000;
645             }
646             else
647             {
648                 /* number of sample from begining */
649                 op.granulepos = ( i_dts - p_sys->i_start_dts ) *
650                     p_stream->header.i_samples_per_unit / (int64_t)1000000;
651             }
652         }
653         else if( p_stream->i_cat == VIDEO_ES )
654         {
655             if( p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
656             {
657                 op.granulepos = op.packetno; /* FIXME */
658             }
659             else
660                 op.granulepos = ( i_dts - p_sys->i_start_dts ) / 1000;
661         }
662
663         ogg_stream_packetin( &p_stream->os, &op );
664
665         sout_BufferChain( &p_og, OggStreamPageOut( p_mux, &p_stream->os,
666                                                    p_data->i_dts ) );
667
668         if( p_og )
669         {
670             OggSetDate( p_og, p_stream->i_dts, p_stream->i_length );
671             p_stream->i_dts = -1;
672             p_stream->i_length = 0;
673
674             sout_AccessOutWrite( p_mux->p_access, p_og );
675
676             p_og = NULL;
677         }
678         else
679         {
680             if( p_stream->i_dts < 0 )
681             {
682                 p_stream->i_dts = p_data->i_dts;
683             }
684             p_stream->i_length += p_data->i_length;
685         }
686
687         sout_BufferDelete( p_mux->p_sout, p_data );
688     }
689
690     return( VLC_SUCCESS );
691 }