1 /*****************************************************************************
2 * ogg.c: ogg muxer module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 VideoLAN
5 * $Id: ogg.c,v 1.11 2003/09/28 19:58:19 gbazin Exp $
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Gildas Bazin <gbazin@netcourrier.com>
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.
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.
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 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
30 #include <sys/types.h>
33 #include <vlc/input.h>
40 /*****************************************************************************
42 *****************************************************************************/
43 static int Open ( vlc_object_t * );
44 static void Close ( vlc_object_t * );
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 * );
51 static sout_buffer_t *OggCreateHeader( sout_mux_t *, mtime_t );
52 static sout_buffer_t *OggCreateFooter( sout_mux_t *, mtime_t );
54 /*****************************************************************************
56 *****************************************************************************/
58 set_description( _("Ogg/ogm muxer") );
59 set_capability( "sout mux", 10 );
60 add_shortcut( "ogg" );
61 add_shortcut( "ogm" );
62 set_callbacks( Open, Close );
65 /*****************************************************************************
67 *****************************************************************************/
68 #define FREE( p ) if( p ) { free( p ); (p) = NULL; }
70 /* Structures used for OggDS headers used in ogm files */
72 #define PACKET_TYPE_HEADER 0x01
73 #define PACKET_TYPE_COMMENT 0x03
74 #define PACKET_IS_SYNCPOINT 0x08
77 #ifdef HAVE_ATTRIBUTE_PACKED
78 __attribute__((__packed__))
83 } ogg_stream_header_video_t;
86 #ifdef HAVE_ATTRIBUTE_PACKED
87 __attribute__((__packed__))
91 int16_t i_block_align;
92 int32_t i_avgbytespersec;
93 } ogg_stream_header_audio_t;
96 #ifdef HAVE_ATTRIBUTE_PACKED
97 __attribute__((__packed__))
100 uint8_t i_packet_type;
108 int64_t i_samples_per_unit;
109 int32_t i_default_len;
111 int32_t i_buffer_size;
112 int16_t i_bits_per_sample;
113 int16_t i_padding_0; // hum hum
116 ogg_stream_header_video_t video;
117 ogg_stream_header_audio_t audio;
120 } ogg_stream_header_t;
122 /* Helper writer functions */
124 #define SetWLE( p, v ) _SetWLE( (uint8_t*)p, v)
125 static void _SetWLE( uint8_t *p, uint16_t i_dw )
127 p[1] = ( i_dw >> 8 )&0xff;
128 p[0] = ( i_dw )&0xff;
131 #define SetDWLE( p, v ) _SetDWLE( (uint8_t*)p, v)
132 static void _SetDWLE( uint8_t *p, uint32_t i_dw )
134 p[3] = ( i_dw >> 24 )&0xff;
135 p[2] = ( i_dw >> 16 )&0xff;
136 p[1] = ( i_dw >> 8 )&0xff;
137 p[0] = ( i_dw )&0xff;
139 #define SetQWLE( p, v ) _SetQWLE( (uint8_t*)p, v)
140 static void _SetQWLE( uint8_t *p, uint64_t i_qw )
142 SetDWLE( p, i_qw&0xffffffff );
143 SetDWLE( p+4, ( i_qw >> 32)&0xffffffff );
147 * TODO move this function to src/stream_output.c (used by nearly all muxers)
149 static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
155 for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
159 p_fifo = p_mux->pp_inputs[i]->p_fifo;
161 if( p_fifo->i_depth > 2 )
163 sout_buffer_t *p_buf;
165 p_buf = sout_FifoShow( p_fifo );
166 if( i_stream < 0 || p_buf->i_dts < i_dts )
168 i_dts = p_buf->i_dts;
174 // wait that all fifo have at least 3 packets (3 vorbis headers)
180 *pi_stream = i_stream;
189 /*****************************************************************************
190 * Definitions of structures and functions used by this plugins
191 *****************************************************************************/
204 ogg_stream_header_t header;
208 struct sout_mux_sys_t
214 /* number of logical streams pending to be added */
217 /* logical streams pending to be deleted */
219 ogg_stream_t **pp_del_streams;
222 static void OggSetDate( sout_buffer_t *, mtime_t , mtime_t );
223 static sout_buffer_t *OggStreamFlush( sout_mux_t *, ogg_stream_state *,
226 /*****************************************************************************
228 *****************************************************************************/
229 static int Open( vlc_object_t *p_this )
231 sout_mux_t *p_mux = (sout_mux_t*)p_this;
232 sout_mux_sys_t *p_sys;
234 msg_Info( p_mux, "Open" );
236 p_sys = malloc( sizeof( sout_mux_sys_t ) );
237 p_sys->i_streams = 0;
238 p_sys->i_add_streams = 0;
239 p_sys->i_del_streams = 0;
240 p_sys->pp_del_streams = 0;
242 p_mux->p_sys = p_sys;
243 p_mux->pf_capacity = Capability;
244 p_mux->pf_addstream = AddStream;
245 p_mux->pf_delstream = DelStream;
247 p_mux->i_preheader = 1;
252 /*****************************************************************************
253 * Close: Finalize ogg bitstream and close muxer
254 *****************************************************************************/
255 static void Close( vlc_object_t * p_this )
257 sout_mux_t *p_mux = (sout_mux_t*)p_this;
258 sout_mux_sys_t *p_sys = p_mux->p_sys;
260 msg_Info( p_mux, "Close" );
262 if( p_sys->i_del_streams )
264 sout_buffer_t *p_og = NULL;
268 /* Close the current ogg stream */
269 msg_Dbg( p_mux, "writing footer" );
270 sout_BufferChain( &p_og, OggCreateFooter( p_mux, 0 ) );
272 /* Remove deleted logical streams */
273 for( i = 0; i < p_sys->i_del_streams; i++ )
275 i_dts = p_sys->pp_del_streams[i]->i_dts;
276 ogg_stream_clear( &p_sys->pp_del_streams[i]->os );
277 FREE( p_sys->pp_del_streams[i] );
279 FREE( p_sys->pp_del_streams );
280 p_sys->i_streams -= p_sys->i_del_streams;
283 OggSetDate( p_og, i_dts, 0 );
284 sout_AccessOutWrite( p_mux->p_access, p_og );
290 static int Capability( sout_mux_t *p_mux, int i_query, void *p_args,
295 case SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME:
296 *(vlc_bool_t*)p_answer = VLC_TRUE;
297 return( SOUT_MUX_CAP_ERR_OK );
299 return( SOUT_MUX_CAP_ERR_UNIMPLEMENTED );
303 /*****************************************************************************
304 * AddStream: Add an elementary stream to the muxed stream
305 *****************************************************************************/
306 static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
308 sout_mux_sys_t *p_sys = p_mux->p_sys;
309 ogg_stream_t *p_stream;
311 msg_Dbg( p_mux, "adding input" );
313 p_input->p_sys = (void *)p_stream = malloc( sizeof( ogg_stream_t ) );
315 p_stream->i_cat = p_input->p_fmt->i_cat;
316 p_stream->i_fourcc = p_input->p_fmt->i_fourcc;
317 p_stream->i_packet_no = 0;
319 p_stream->header.i_packet_type = PACKET_TYPE_HEADER;
320 switch( p_input->p_fmt->i_cat )
323 switch( p_stream->i_fourcc )
325 case VLC_FOURCC( 'm', 'p','4', 'v' ):
326 case VLC_FOURCC( 'D', 'I','V', '3' ):
327 memcpy( p_stream->header.stream_type, "video ", 8 );
328 if( p_stream->i_fourcc == VLC_FOURCC( 'm', 'p','4', 'v' ) )
330 memcpy( p_stream->header.sub_type, "XVID", 4 );
332 else if( p_stream->i_fourcc == VLC_FOURCC( 'D', 'I','V', '3' ) )
334 memcpy( p_stream->header.sub_type, "DIV3", 4 );
336 SetDWLE( &p_stream->header.i_size,
337 sizeof( ogg_stream_header_t ) - 1);
338 /* XXX this won't make mplayer happy,
339 * but vlc can read that without any problem so...*/
340 SetQWLE( &p_stream->header.i_time_unit, 10*1000 );
341 //(int64_t)10*1000*1000/(int64_t)25 ); // FIXME (25fps)
342 SetQWLE( &p_stream->header.i_samples_per_unit, 1 );
343 SetDWLE( &p_stream->header.i_default_len, 0 ); /* ??? */
344 SetDWLE( &p_stream->header.i_buffer_size, 1024*1024 );
345 SetWLE( &p_stream->header.i_bits_per_sample, 0 );
346 SetDWLE( &p_stream->header.header.video.i_width,
347 p_input->p_fmt->i_width );
348 SetDWLE( &p_stream->header.header.video.i_height,
349 p_input->p_fmt->i_height );
350 msg_Dbg( p_mux, "mp4v/div3 stream" );
353 case VLC_FOURCC( 't', 'h', 'e', 'o' ):
354 msg_Dbg( p_mux, "theora stream" );
358 FREE( p_input->p_sys );
359 return( VLC_EGENERIC );
364 switch( p_stream->i_fourcc )
366 case VLC_FOURCC( 'm', 'p','g', 'a' ):
367 case VLC_FOURCC( 'a', '5','2', ' ' ):
368 memcpy( p_stream->header.stream_type, "audio ", 8 );
369 if( p_stream->i_fourcc == VLC_FOURCC( 'm', 'p','g', 'a' ) )
371 memcpy( p_stream->header.sub_type, "55 ", 4 );
373 else if( p_stream->i_fourcc == VLC_FOURCC( 'a', '5','2', ' ' ) )
375 memcpy( p_stream->header.sub_type, "2000", 4 );
377 SetDWLE( &p_stream->header.i_size,
378 sizeof( ogg_stream_header_t ) - 1);
379 SetQWLE( &p_stream->header.i_time_unit, 1000000 ); /*is it used ?*/
380 SetDWLE( &p_stream->header.i_default_len, 0 ); /* ??? */
381 SetDWLE( &p_stream->header.i_buffer_size, 30*1024 );
382 SetQWLE( &p_stream->header.i_samples_per_unit,
383 p_input->p_fmt->i_sample_rate );
384 SetWLE( &p_stream->header.i_bits_per_sample, 0 );
385 SetDWLE( &p_stream->header.header.audio.i_channels,
386 p_input->p_fmt->i_channels );
387 SetDWLE( &p_stream->header.header.audio.i_block_align,
388 p_input->p_fmt->i_block_align );
389 SetDWLE( &p_stream->header.header.audio.i_avgbytespersec, 0 );
390 msg_Dbg( p_mux, "mpga/a52 stream" );
393 case VLC_FOURCC( 'v', 'o', 'r', 'b' ):
394 msg_Dbg( p_mux, "vorbis stream" );
398 FREE( p_input->p_sys );
399 return( VLC_EGENERIC );
404 switch( p_stream->i_fourcc )
406 case VLC_FOURCC( 's', 'u','b', 't' ):
407 memcpy( p_stream->header.stream_type, "text ", 8 );
408 msg_Dbg( p_mux, "subtitles stream" );
412 FREE( p_input->p_sys );
413 return( VLC_EGENERIC );
417 FREE( p_input->p_sys );
418 return( VLC_EGENERIC );
421 p_stream->b_new = VLC_TRUE;
423 p_sys->i_add_streams++;
425 return( VLC_SUCCESS );
428 /*****************************************************************************
429 * DelStream: Delete an elementary stream from the muxed stream
430 *****************************************************************************/
431 static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
433 sout_mux_sys_t *p_sys = p_mux->p_sys;
434 ogg_stream_t *p_stream = (ogg_stream_t*)p_input->p_sys;
437 msg_Dbg( p_mux, "removing input" );
439 /* flush all remaining data */
442 if( ( p_og = OggStreamFlush( p_mux, &p_stream->os, 0 ) ) )
444 OggSetDate( p_og, p_stream->i_dts, p_stream->i_length );
445 sout_AccessOutWrite( p_mux->p_access, p_og );
448 /* move input in delete queue */
449 if( !p_stream->b_new )
451 p_sys->pp_del_streams = realloc( p_sys->pp_del_streams,
452 (p_sys->i_del_streams + 1) *
453 sizeof(ogg_stream_t *) );
454 p_sys->pp_del_streams[p_sys->i_del_streams++] = p_stream;
458 /* Wasn't already added so get rid of it */
459 ogg_stream_clear( &p_stream->os );
461 p_sys->i_add_streams--;
465 p_input->p_sys = NULL;
470 /*****************************************************************************
471 * Ogg bitstream manipulation routines
472 *****************************************************************************/
473 static sout_buffer_t *OggStreamFlush( sout_mux_t *p_mux,
474 ogg_stream_state *p_os, mtime_t i_pts )
476 sout_buffer_t *p_og, *p_og_first = NULL;
484 if( ( i_result = ogg_stream_flush( p_os, &og ) ) == 0 )
489 i_size = og.header_len + og.body_len;
490 p_og = sout_BufferNew( p_mux->p_sout, i_size);
492 memcpy( p_og->p_buffer, og.header, og.header_len );
493 memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len );
494 p_og->i_size = i_size;
499 i_pts = 0; // write it only once
501 sout_BufferChain( &p_og_first, p_og );
504 return( p_og_first );
507 static sout_buffer_t *OggStreamPageOut( sout_mux_t *p_mux,
508 ogg_stream_state *p_os, mtime_t i_pts )
510 sout_buffer_t *p_og, *p_og_first = NULL;
518 if( ( i_result = ogg_stream_pageout( p_os, &og ) ) == 0 )
523 i_size = og.header_len + og.body_len;
524 p_og = sout_BufferNew( p_mux->p_sout, i_size);
526 memcpy( p_og->p_buffer, og.header, og.header_len );
527 memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len );
528 p_og->i_size = i_size;
533 i_pts = 0; // write them only once
535 sout_BufferChain( &p_og_first, p_og );
538 return( p_og_first );
541 static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
543 sout_buffer_t *p_hdr = NULL;
548 /* Write header for each stream. All b_o_s (beginning of stream) packets
549 * must appear first in the ogg stream so we take care of them first. */
550 for( i = 0; i < p_mux->i_nb_inputs; i++ )
552 ogg_stream_t *p_stream = (ogg_stream_t*)p_mux->pp_inputs[i]->p_sys;
553 p_stream->b_new = VLC_FALSE;
555 msg_Dbg( p_mux, "creating header for %4.4s",
556 (char *)&p_stream->i_fourcc );
558 ogg_stream_init( &p_stream->os, rand() );
559 p_stream->i_packet_no = 0;
561 if( p_stream->i_fourcc == VLC_FOURCC( 'v', 'o', 'r', 'b' ) ||
562 p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
564 /* Special case, headers are already there in the
567 /* first packet in order: vorbis info */
568 p_og = sout_FifoGet( p_mux->pp_inputs[i]->p_fifo );
569 op.packet = p_og->p_buffer;
570 op.bytes = p_og->i_size;
574 op.packetno = p_stream->i_packet_no++;
575 ogg_stream_packetin( &p_stream->os, &op );
580 op.packet = (uint8_t*)&p_stream->header;
581 op.bytes = sizeof( ogg_stream_header_t );
585 op.packetno = p_stream->i_packet_no++;
586 ogg_stream_packetin( &p_stream->os, &op );
589 p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
590 sout_BufferChain( &p_hdr, p_og );
593 /* Take care of the non b_o_s headers */
594 for( i = 0; i < p_mux->i_nb_inputs; i++ )
596 ogg_stream_t *p_stream = (ogg_stream_t*)p_mux->pp_inputs[i]->p_sys;
598 if( p_stream->i_fourcc == VLC_FOURCC( 'v', 'o', 'r', 'b' ) ||
599 p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
601 /* Special case, headers are already there in the incoming stream.
602 * We need to gather them an mark them as headers. */
604 for( j = 0; j < 2; j++ )
606 /* next packets in order: comments and codebooks */
607 p_og = sout_FifoGet( p_mux->pp_inputs[i]->p_fifo );
608 op.packet = p_og->p_buffer;
609 op.bytes = p_og->i_size;
613 op.packetno = p_stream->i_packet_no++;
614 ogg_stream_packetin( &p_stream->os, &op );
623 com[0] = PACKET_TYPE_COMMENT;
624 i_com = snprintf( &com[1], 128, VERSION" stream output" ) + 1;
630 op.packetno = p_stream->i_packet_no++;
631 ogg_stream_packetin( &p_stream->os, &op );
634 p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
635 sout_BufferChain( &p_hdr, p_og );
638 /* set HEADER flag */
639 for( p_og = p_hdr; p_og != NULL; p_og = p_og->p_next )
641 p_og->i_flags |= SOUT_BUFFER_FLAGS_HEADER;
646 static sout_buffer_t *OggCreateFooter( sout_mux_t *p_mux, mtime_t i_dts )
648 sout_mux_sys_t *p_sys = p_mux->p_sys;
649 sout_buffer_t *p_hdr = NULL;
654 /* flush all remaining data */
655 for( i = 0; i < p_mux->i_nb_inputs; i++ )
657 ogg_stream_t *p_stream = p_mux->pp_inputs[i]->p_sys;
659 /* skip newly added streams */
660 if( p_stream->b_new ) continue;
662 if( ( p_og = OggStreamFlush( p_mux, &p_stream->os, 0 ) ) )
664 OggSetDate( p_og, p_stream->i_dts, p_stream->i_length );
665 sout_AccessOutWrite( p_mux->p_access, p_og );
669 /* Write eos packets for each stream. */
670 for( i = 0; i < p_mux->i_nb_inputs; i++ )
672 ogg_stream_t *p_stream = p_mux->pp_inputs[i]->p_sys;
674 /* skip newly added streams */
675 if( p_stream->b_new ) continue;
682 op.packetno = p_stream->i_packet_no++;
683 ogg_stream_packetin( &p_stream->os, &op );
685 p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
686 sout_BufferChain( &p_hdr, p_og );
687 ogg_stream_clear( &p_stream->os );
690 for( i = 0; i < p_sys->i_del_streams; i++ )
697 op.packetno = p_sys->pp_del_streams[i]->i_packet_no++;
698 ogg_stream_packetin( &p_sys->pp_del_streams[i]->os, &op );
700 p_og = OggStreamFlush( p_mux, &p_sys->pp_del_streams[i]->os, 0 );
701 sout_BufferChain( &p_hdr, p_og );
702 ogg_stream_clear( &p_sys->pp_del_streams[i]->os );
708 static void OggSetDate( sout_buffer_t *p_og, mtime_t i_dts, mtime_t i_length )
711 sout_buffer_t *p_tmp;
714 for( p_tmp = p_og, i_count = 0; p_tmp != NULL; p_tmp = p_tmp->p_next )
718 i_delta = i_length / i_count;
720 for( p_tmp = p_og; p_tmp != NULL; p_tmp = p_tmp->p_next )
722 p_tmp->i_dts = i_dts;
723 p_tmp->i_length = i_delta;
729 /*****************************************************************************
730 * Mux: multiplex available data in input fifos into the Ogg bitstream
731 *****************************************************************************/
732 static int Mux( sout_mux_t *p_mux )
734 sout_mux_sys_t *p_sys = p_mux->p_sys;
735 sout_buffer_t *p_og = NULL;
739 if( p_sys->i_add_streams || p_sys->i_del_streams )
741 /* Open new ogg stream */
742 if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
744 msg_Dbg( p_mux, "waiting for data..." );
745 return( VLC_SUCCESS );
748 if( p_sys->i_streams )
750 /* Close current ogg stream */
753 msg_Dbg( p_mux, "writing footer" );
754 sout_BufferChain( &p_og, OggCreateFooter( p_mux, 0 ) );
756 /* Remove deleted logical streams */
757 for( i = 0; i < p_sys->i_del_streams; i++ )
759 FREE( p_sys->pp_del_streams[i] );
761 FREE( p_sys->pp_del_streams );
762 p_sys->i_streams = 0;
765 msg_Dbg( p_mux, "writing header" );
766 p_sys->i_start_dts = i_dts;
767 p_sys->i_streams = p_mux->i_nb_inputs;
768 p_sys->i_del_streams = 0;
769 p_sys->i_add_streams = 0;
770 sout_BufferChain( &p_og, OggCreateHeader( p_mux, i_dts ) );
772 /* Write header and/or footer */
773 OggSetDate( p_og, i_dts, 0 );
774 sout_AccessOutWrite( p_mux->p_access, p_og );
780 sout_input_t *p_input;
781 ogg_stream_t *p_stream;
782 sout_buffer_t *p_data;
785 if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
787 return( VLC_SUCCESS );
790 p_input = p_mux->pp_inputs[i_stream];
791 p_stream = (ogg_stream_t*)p_input->p_sys;
792 p_data = sout_FifoGet( p_input->p_fifo );
794 if( p_stream->i_fourcc != VLC_FOURCC( 'v', 'o', 'r', 'b' ) )
796 sout_BufferReallocFromPreHeader( p_mux->p_sout, p_data, 1 );
797 p_data->p_buffer[0] = PACKET_IS_SYNCPOINT; // FIXME
800 op.packet = p_data->p_buffer;
801 op.bytes = p_data->i_size;
804 op.packetno = p_stream->i_packet_no++;
806 if( p_stream->i_cat == AUDIO_ES )
808 if( p_stream->i_fourcc == VLC_FOURCC( 'v', 'o', 'r', 'b' ) )
810 /* number of sample from begining + current packet */
812 ( i_dts + p_data->i_length - p_sys->i_start_dts ) *
813 p_input->p_fmt->i_sample_rate / (int64_t)1000000;
817 /* number of sample from begining */
818 op.granulepos = ( i_dts - p_sys->i_start_dts ) *
819 p_stream->header.i_samples_per_unit / (int64_t)1000000;
822 else if( p_stream->i_cat == VIDEO_ES )
824 if( p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
826 op.granulepos = op.packetno; /* FIXME */
829 op.granulepos = ( i_dts - p_sys->i_start_dts ) / 1000;
831 else if( p_stream->i_cat == SPU_ES )
833 /* granulepos is in milisec */
834 op.granulepos = ( i_dts - p_sys->i_start_dts ) / 1000;
837 ogg_stream_packetin( &p_stream->os, &op );
839 sout_BufferChain( &p_og, OggStreamPageOut( p_mux, &p_stream->os,
844 OggSetDate( p_og, p_stream->i_dts, p_stream->i_length );
845 p_stream->i_dts = -1;
846 p_stream->i_length = 0;
848 sout_AccessOutWrite( p_mux->p_access, p_og );
854 if( p_stream->i_dts < 0 )
856 p_stream->i_dts = p_data->i_dts;
858 p_stream->i_length += p_data->i_length;
861 sout_BufferDelete( p_mux->p_sout, p_data );
864 return( VLC_SUCCESS );