1 /*****************************************************************************
2 * ogg.c: ogg muxer module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 VideoLAN
5 * $Id: ogg.c,v 1.13 2003/09/28 22:18:57 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 SetQWLE( &p_stream->header.i_time_unit,
339 I64C(10000000)/(int64_t)25 ); // FIXME (25fps)
340 SetQWLE( &p_stream->header.i_samples_per_unit, 1 );
341 SetDWLE( &p_stream->header.i_default_len, 0 ); /* ??? */
342 SetDWLE( &p_stream->header.i_buffer_size, 1024*1024 );
343 SetWLE( &p_stream->header.i_bits_per_sample, 0 );
344 SetDWLE( &p_stream->header.header.video.i_width,
345 p_input->p_fmt->i_width );
346 SetDWLE( &p_stream->header.header.video.i_height,
347 p_input->p_fmt->i_height );
348 msg_Dbg( p_mux, "mp4v/div3 stream" );
351 case VLC_FOURCC( 't', 'h', 'e', 'o' ):
352 msg_Dbg( p_mux, "theora stream" );
356 FREE( p_input->p_sys );
357 return( VLC_EGENERIC );
362 switch( p_stream->i_fourcc )
364 case VLC_FOURCC( 'm', 'p','g', 'a' ):
365 case VLC_FOURCC( 'a', '5','2', ' ' ):
366 memcpy( p_stream->header.stream_type, "audio ", 8 );
367 if( p_stream->i_fourcc == VLC_FOURCC( 'm', 'p','g', 'a' ) )
369 memcpy( p_stream->header.sub_type, "55 ", 4 );
371 else if( p_stream->i_fourcc == VLC_FOURCC( 'a', '5','2', ' ' ) )
373 memcpy( p_stream->header.sub_type, "2000", 4 );
375 SetDWLE( &p_stream->header.i_size,
376 sizeof( ogg_stream_header_t ) - 1);
377 SetQWLE( &p_stream->header.i_time_unit, 1000000 ); /*is it used ?*/
378 SetDWLE( &p_stream->header.i_default_len, 0 ); /* ??? */
379 SetDWLE( &p_stream->header.i_buffer_size, 30*1024 );
380 SetQWLE( &p_stream->header.i_samples_per_unit,
381 p_input->p_fmt->i_sample_rate );
382 SetWLE( &p_stream->header.i_bits_per_sample, 0 );
383 SetDWLE( &p_stream->header.header.audio.i_channels,
384 p_input->p_fmt->i_channels );
385 SetDWLE( &p_stream->header.header.audio.i_block_align,
386 p_input->p_fmt->i_block_align );
387 SetDWLE( &p_stream->header.header.audio.i_avgbytespersec, 0 );
388 msg_Dbg( p_mux, "mpga/a52 stream" );
391 case VLC_FOURCC( 'v', 'o', 'r', 'b' ):
392 msg_Dbg( p_mux, "vorbis stream" );
396 FREE( p_input->p_sys );
397 return( VLC_EGENERIC );
402 switch( p_stream->i_fourcc )
404 case VLC_FOURCC( 's', 'u','b', 't' ):
405 memcpy( p_stream->header.stream_type, "text ", 8 );
406 msg_Dbg( p_mux, "subtitles stream" );
410 FREE( p_input->p_sys );
411 return( VLC_EGENERIC );
415 FREE( p_input->p_sys );
416 return( VLC_EGENERIC );
419 p_stream->b_new = VLC_TRUE;
421 p_sys->i_add_streams++;
423 return( VLC_SUCCESS );
426 /*****************************************************************************
427 * DelStream: Delete an elementary stream from the muxed stream
428 *****************************************************************************/
429 static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
431 sout_mux_sys_t *p_sys = p_mux->p_sys;
432 ogg_stream_t *p_stream = (ogg_stream_t*)p_input->p_sys;
435 msg_Dbg( p_mux, "removing input" );
437 /* flush all remaining data */
440 if( ( p_og = OggStreamFlush( p_mux, &p_stream->os, 0 ) ) )
442 OggSetDate( p_og, p_stream->i_dts, p_stream->i_length );
443 sout_AccessOutWrite( p_mux->p_access, p_og );
446 /* move input in delete queue */
447 if( !p_stream->b_new )
449 p_sys->pp_del_streams = realloc( p_sys->pp_del_streams,
450 (p_sys->i_del_streams + 1) *
451 sizeof(ogg_stream_t *) );
452 p_sys->pp_del_streams[p_sys->i_del_streams++] = p_stream;
456 /* Wasn't already added so get rid of it */
457 ogg_stream_clear( &p_stream->os );
459 p_sys->i_add_streams--;
463 p_input->p_sys = NULL;
468 /*****************************************************************************
469 * Ogg bitstream manipulation routines
470 *****************************************************************************/
471 static sout_buffer_t *OggStreamFlush( sout_mux_t *p_mux,
472 ogg_stream_state *p_os, mtime_t i_pts )
474 sout_buffer_t *p_og, *p_og_first = NULL;
482 if( ( i_result = ogg_stream_flush( p_os, &og ) ) == 0 )
487 i_size = og.header_len + og.body_len;
488 p_og = sout_BufferNew( p_mux->p_sout, i_size);
490 memcpy( p_og->p_buffer, og.header, og.header_len );
491 memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len );
492 p_og->i_size = i_size;
497 i_pts = 0; // write it only once
499 sout_BufferChain( &p_og_first, p_og );
502 return( p_og_first );
505 static sout_buffer_t *OggStreamPageOut( sout_mux_t *p_mux,
506 ogg_stream_state *p_os, mtime_t i_pts )
508 sout_buffer_t *p_og, *p_og_first = NULL;
516 if( ( i_result = ogg_stream_pageout( p_os, &og ) ) == 0 )
521 i_size = og.header_len + og.body_len;
522 p_og = sout_BufferNew( p_mux->p_sout, i_size);
524 memcpy( p_og->p_buffer, og.header, og.header_len );
525 memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len );
526 p_og->i_size = i_size;
531 i_pts = 0; // write them only once
533 sout_BufferChain( &p_og_first, p_og );
536 return( p_og_first );
539 static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
541 sout_buffer_t *p_hdr = NULL;
546 /* Write header for each stream. All b_o_s (beginning of stream) packets
547 * must appear first in the ogg stream so we take care of them first. */
548 for( i = 0; i < p_mux->i_nb_inputs; i++ )
550 ogg_stream_t *p_stream = (ogg_stream_t*)p_mux->pp_inputs[i]->p_sys;
551 p_stream->b_new = VLC_FALSE;
553 msg_Dbg( p_mux, "creating header for %4.4s",
554 (char *)&p_stream->i_fourcc );
556 ogg_stream_init( &p_stream->os, rand() );
557 p_stream->i_packet_no = 0;
559 if( p_stream->i_fourcc == VLC_FOURCC( 'v', 'o', 'r', 'b' ) ||
560 p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
562 /* Special case, headers are already there in the
565 /* first packet in order: vorbis info */
566 p_og = sout_FifoGet( p_mux->pp_inputs[i]->p_fifo );
567 op.packet = p_og->p_buffer;
568 op.bytes = p_og->i_size;
572 op.packetno = p_stream->i_packet_no++;
573 ogg_stream_packetin( &p_stream->os, &op );
578 op.packet = (uint8_t*)&p_stream->header;
579 op.bytes = sizeof( ogg_stream_header_t );
583 op.packetno = p_stream->i_packet_no++;
584 ogg_stream_packetin( &p_stream->os, &op );
587 p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
588 sout_BufferChain( &p_hdr, p_og );
591 /* Take care of the non b_o_s headers */
592 for( i = 0; i < p_mux->i_nb_inputs; i++ )
594 ogg_stream_t *p_stream = (ogg_stream_t*)p_mux->pp_inputs[i]->p_sys;
596 if( p_stream->i_fourcc == VLC_FOURCC( 'v', 'o', 'r', 'b' ) ||
597 p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
599 /* Special case, headers are already there in the incoming stream.
600 * We need to gather them an mark them as headers. */
602 for( j = 0; j < 2; j++ )
604 /* next packets in order: comments and codebooks */
605 p_og = sout_FifoGet( p_mux->pp_inputs[i]->p_fifo );
606 op.packet = p_og->p_buffer;
607 op.bytes = p_og->i_size;
611 op.packetno = p_stream->i_packet_no++;
612 ogg_stream_packetin( &p_stream->os, &op );
621 com[0] = PACKET_TYPE_COMMENT;
622 i_com = snprintf( &com[1], 128, VERSION" stream output" ) + 1;
628 op.packetno = p_stream->i_packet_no++;
629 ogg_stream_packetin( &p_stream->os, &op );
632 p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
633 sout_BufferChain( &p_hdr, p_og );
636 /* set HEADER flag */
637 for( p_og = p_hdr; p_og != NULL; p_og = p_og->p_next )
639 p_og->i_flags |= SOUT_BUFFER_FLAGS_HEADER;
644 static sout_buffer_t *OggCreateFooter( sout_mux_t *p_mux, mtime_t i_dts )
646 sout_mux_sys_t *p_sys = p_mux->p_sys;
647 sout_buffer_t *p_hdr = NULL;
652 /* flush all remaining data */
653 for( i = 0; i < p_mux->i_nb_inputs; i++ )
655 ogg_stream_t *p_stream = p_mux->pp_inputs[i]->p_sys;
657 /* skip newly added streams */
658 if( p_stream->b_new ) continue;
660 if( ( p_og = OggStreamFlush( p_mux, &p_stream->os, 0 ) ) )
662 OggSetDate( p_og, p_stream->i_dts, p_stream->i_length );
663 sout_AccessOutWrite( p_mux->p_access, p_og );
667 /* Write eos packets for each stream. */
668 for( i = 0; i < p_mux->i_nb_inputs; i++ )
670 ogg_stream_t *p_stream = p_mux->pp_inputs[i]->p_sys;
672 /* skip newly added streams */
673 if( p_stream->b_new ) continue;
680 op.packetno = p_stream->i_packet_no++;
681 ogg_stream_packetin( &p_stream->os, &op );
683 p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
684 sout_BufferChain( &p_hdr, p_og );
685 ogg_stream_clear( &p_stream->os );
688 for( i = 0; i < p_sys->i_del_streams; i++ )
695 op.packetno = p_sys->pp_del_streams[i]->i_packet_no++;
696 ogg_stream_packetin( &p_sys->pp_del_streams[i]->os, &op );
698 p_og = OggStreamFlush( p_mux, &p_sys->pp_del_streams[i]->os, 0 );
699 sout_BufferChain( &p_hdr, p_og );
700 ogg_stream_clear( &p_sys->pp_del_streams[i]->os );
706 static void OggSetDate( sout_buffer_t *p_og, mtime_t i_dts, mtime_t i_length )
709 sout_buffer_t *p_tmp;
712 for( p_tmp = p_og, i_count = 0; p_tmp != NULL; p_tmp = p_tmp->p_next )
716 i_delta = i_length / i_count;
718 for( p_tmp = p_og; p_tmp != NULL; p_tmp = p_tmp->p_next )
720 p_tmp->i_dts = i_dts;
721 p_tmp->i_length = i_delta;
727 /*****************************************************************************
728 * Mux: multiplex available data in input fifos into the Ogg bitstream
729 *****************************************************************************/
730 static int Mux( sout_mux_t *p_mux )
732 sout_mux_sys_t *p_sys = p_mux->p_sys;
733 sout_buffer_t *p_og = NULL;
737 if( p_sys->i_add_streams || p_sys->i_del_streams )
739 /* Open new ogg stream */
740 if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
742 msg_Dbg( p_mux, "waiting for data..." );
743 return( VLC_SUCCESS );
746 if( p_sys->i_streams )
748 /* Close current ogg stream */
751 msg_Dbg( p_mux, "writing footer" );
752 sout_BufferChain( &p_og, OggCreateFooter( p_mux, 0 ) );
754 /* Remove deleted logical streams */
755 for( i = 0; i < p_sys->i_del_streams; i++ )
757 FREE( p_sys->pp_del_streams[i] );
759 FREE( p_sys->pp_del_streams );
760 p_sys->i_streams = 0;
763 msg_Dbg( p_mux, "writing header" );
764 p_sys->i_start_dts = i_dts;
765 p_sys->i_streams = p_mux->i_nb_inputs;
766 p_sys->i_del_streams = 0;
767 p_sys->i_add_streams = 0;
768 sout_BufferChain( &p_og, OggCreateHeader( p_mux, i_dts ) );
770 /* Write header and/or footer */
771 OggSetDate( p_og, i_dts, 0 );
772 sout_AccessOutWrite( p_mux->p_access, p_og );
778 sout_input_t *p_input;
779 ogg_stream_t *p_stream;
780 sout_buffer_t *p_data;
783 if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
785 return( VLC_SUCCESS );
788 p_input = p_mux->pp_inputs[i_stream];
789 p_stream = (ogg_stream_t*)p_input->p_sys;
790 p_data = sout_FifoGet( p_input->p_fifo );
792 if( p_stream->i_fourcc != VLC_FOURCC( 'v', 'o', 'r', 'b' ) &&
793 p_stream->i_fourcc != VLC_FOURCC( 't', 'h', 'e', 'o' ) )
795 sout_BufferReallocFromPreHeader( p_mux->p_sout, p_data, 1 );
796 p_data->p_buffer[0] = PACKET_IS_SYNCPOINT; // FIXME
799 op.packet = p_data->p_buffer;
800 op.bytes = p_data->i_size;
803 op.packetno = p_stream->i_packet_no++;
805 if( p_stream->i_cat == AUDIO_ES )
807 if( p_stream->i_fourcc == VLC_FOURCC( 'v', 'o', 'r', 'b' ) )
809 /* number of sample from begining + current packet */
811 ( i_dts + p_data->i_length - p_sys->i_start_dts ) *
812 p_input->p_fmt->i_sample_rate / (int64_t)1000000;
816 /* number of sample from begining */
817 op.granulepos = ( i_dts - p_sys->i_start_dts ) *
818 p_stream->header.i_samples_per_unit / (int64_t)1000000;
821 else if( p_stream->i_cat == VIDEO_ES )
823 if( p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
825 op.granulepos = op.packetno; /* FIXME */
828 op.granulepos = ( i_dts - p_sys->i_start_dts )
829 * I64C(10) / p_stream->header.i_time_unit;
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 );