Commit 085985d5 authored by Laurent Aimar's avatar Laurent Aimar

* mux: sout_buffer_t -> block_t.

parent 8547ffaa
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* asf.c * asf.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: asf.c,v 1.10 2004/01/25 13:37:12 kuehne Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -92,7 +92,7 @@ struct sout_mux_sys_t ...@@ -92,7 +92,7 @@ struct sout_mux_sys_t
vlc_bool_t b_write_header; vlc_bool_t b_write_header;
sout_buffer_t *pk; block_t *pk;
int i_pk_used; int i_pk_used;
int i_pk_frame; int i_pk_frame;
mtime_t i_pk_dts; mtime_t i_pk_dts;
...@@ -110,10 +110,10 @@ struct sout_mux_sys_t ...@@ -110,10 +110,10 @@ struct sout_mux_sys_t
static int MuxGetStream( sout_mux_t *, int *pi_stream, mtime_t *pi_dts ); static int MuxGetStream( sout_mux_t *, int *pi_stream, mtime_t *pi_dts );
static sout_buffer_t *asf_header_create( sout_mux_t *, vlc_bool_t b_broadcast ); static block_t *asf_header_create( sout_mux_t *, vlc_bool_t b_broadcast );
static sout_buffer_t *asf_packet_create( sout_mux_t *, static block_t *asf_packet_create( sout_mux_t *,
asf_track_t *, sout_buffer_t * ); asf_track_t *, block_t * );
static sout_buffer_t *asf_stream_end_create( sout_mux_t *); static block_t *asf_stream_end_create( sout_mux_t *);
typedef struct typedef struct
{ {
...@@ -215,7 +215,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -215,7 +215,7 @@ static void Close( vlc_object_t * p_this )
{ {
sout_mux_t *p_mux = (sout_mux_t*)p_this; sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *out; block_t *out;
int i; int i;
msg_Dbg( p_mux, "Asf muxer closed" ); msg_Dbg( p_mux, "Asf muxer closed" );
...@@ -499,9 +499,9 @@ static int Mux ( sout_mux_t *p_mux ) ...@@ -499,9 +499,9 @@ static int Mux ( sout_mux_t *p_mux )
if( p_sys->b_write_header ) if( p_sys->b_write_header )
{ {
sout_buffer_t *out = asf_header_create( p_mux, VLC_TRUE ); block_t *out = asf_header_create( p_mux, VLC_TRUE );
out->i_flags |= SOUT_BUFFER_FLAGS_HEADER; out->i_flags |= BLOCK_FLAG_HEADER;
sout_AccessOutWrite( p_mux->p_access, out ); sout_AccessOutWrite( p_mux->p_access, out );
p_sys->b_write_header = VLC_FALSE; p_sys->b_write_header = VLC_FALSE;
...@@ -513,8 +513,8 @@ static int Mux ( sout_mux_t *p_mux ) ...@@ -513,8 +513,8 @@ static int Mux ( sout_mux_t *p_mux )
asf_track_t *tk; asf_track_t *tk;
int i_stream; int i_stream;
mtime_t i_dts; mtime_t i_dts;
sout_buffer_t *data; block_t *data;
sout_buffer_t *pk; block_t *pk;
if( MuxGetStream( p_mux, &i_stream, &i_dts ) ) if( MuxGetStream( p_mux, &i_stream, &i_dts ) )
{ {
...@@ -534,7 +534,7 @@ static int Mux ( sout_mux_t *p_mux ) ...@@ -534,7 +534,7 @@ static int Mux ( sout_mux_t *p_mux )
p_input = p_mux->pp_inputs[i_stream]; p_input = p_mux->pp_inputs[i_stream];
tk = (asf_track_t*)p_input->p_sys; tk = (asf_track_t*)p_input->p_sys;
data = sout_FifoGet( p_input->p_fifo ); data = block_FifoGet( p_input->p_fifo );
if( ( pk = asf_packet_create( p_mux, tk, data ) ) ) if( ( pk = asf_packet_create( p_mux, tk, data ) ) )
{ {
...@@ -557,7 +557,7 @@ static int MuxGetStream( sout_mux_t *p_mux, ...@@ -557,7 +557,7 @@ static int MuxGetStream( sout_mux_t *p_mux,
for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ ) for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
{ {
sout_input_t *p_input = p_mux->pp_inputs[i]; sout_input_t *p_input = p_mux->pp_inputs[i];
sout_buffer_t *p_data; block_t *p_data;
if( p_input->p_fifo->i_depth <= 0 ) if( p_input->p_fifo->i_depth <= 0 )
{ {
...@@ -571,7 +571,7 @@ static int MuxGetStream( sout_mux_t *p_mux, ...@@ -571,7 +571,7 @@ static int MuxGetStream( sout_mux_t *p_mux,
continue; continue;
} }
p_data = sout_FifoShow( p_input->p_fifo ); p_data = block_FifoShow( p_input->p_fifo );
if( i_stream == -1 || if( i_stream == -1 ||
p_data->i_dts < i_dts ) p_data->i_dts < i_dts )
{ {
...@@ -790,7 +790,7 @@ static void asf_chunk_add( bo_t *bo, ...@@ -790,7 +790,7 @@ static void asf_chunk_add( bo_t *bo,
bo_addle_u16( bo, i_len + 8 ); bo_addle_u16( bo, i_len + 8 );
} }
static sout_buffer_t *asf_header_create( sout_mux_t *p_mux, static block_t *asf_header_create( sout_mux_t *p_mux,
vlc_bool_t b_broadcast ) vlc_bool_t b_broadcast )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
...@@ -800,7 +800,7 @@ static sout_buffer_t *asf_header_create( sout_mux_t *p_mux, ...@@ -800,7 +800,7 @@ static sout_buffer_t *asf_header_create( sout_mux_t *p_mux,
int i_size; int i_size;
int i_ci_size; int i_ci_size;
int i_cd_size = 0; int i_cd_size = 0;
sout_buffer_t *out; block_t *out;
bo_t bo; bo_t bo;
int i; int i;
...@@ -843,13 +843,13 @@ static sout_buffer_t *asf_header_create( sout_mux_t *p_mux, ...@@ -843,13 +843,13 @@ static sout_buffer_t *asf_header_create( sout_mux_t *p_mux,
if( p_sys->b_asf_http ) if( p_sys->b_asf_http )
{ {
out = sout_BufferNew( p_mux->p_sout, i_size + 50 + 12 ); out = block_New( p_mux, i_size + 50 + 12 );
bo_init( &bo, out->p_buffer, i_size + 50 + 12 ); bo_init( &bo, out->p_buffer, i_size + 50 + 12 );
asf_chunk_add( &bo, 0x4824, i_size + 50, 0xc00, p_sys->i_seq++ ); asf_chunk_add( &bo, 0x4824, i_size + 50, 0xc00, p_sys->i_seq++ );
} }
else else
{ {
out = sout_BufferNew( p_mux->p_sout, i_size + 50 ); out = block_New( p_mux, i_size + 50 );
bo_init( &bo, out->p_buffer, i_size + 50 ); bo_init( &bo, out->p_buffer, i_size + 50 );
} }
/* header object */ /* header object */
...@@ -965,15 +965,15 @@ static sout_buffer_t *asf_header_create( sout_mux_t *p_mux, ...@@ -965,15 +965,15 @@ static sout_buffer_t *asf_header_create( sout_mux_t *p_mux,
/**************************************************************************** /****************************************************************************
* *
****************************************************************************/ ****************************************************************************/
static sout_buffer_t *asf_packet_create( sout_mux_t *p_mux, static block_t *asf_packet_create( sout_mux_t *p_mux,
asf_track_t *tk, sout_buffer_t *data ) asf_track_t *tk, block_t *data )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
int i_data = data->i_size; int i_data = data->i_buffer;
int i_pos = 0; int i_pos = 0;
uint8_t *p_data= data->p_buffer; uint8_t *p_data= data->p_buffer;
sout_buffer_t *first = NULL, **last = &first; block_t *first = NULL, **last = &first;
int i_preheader = p_sys->b_asf_http ? 12 : 0; int i_preheader = p_sys->b_asf_http ? 12 : 0;
while( i_pos < i_data ) while( i_pos < i_data )
...@@ -983,7 +983,7 @@ static sout_buffer_t *asf_packet_create( sout_mux_t *p_mux, ...@@ -983,7 +983,7 @@ static sout_buffer_t *asf_packet_create( sout_mux_t *p_mux,
if( p_sys->pk == NULL ) if( p_sys->pk == NULL )
{ {
p_sys->pk = sout_BufferNew( p_mux->p_sout, p_sys->pk = block_New( p_mux,
p_sys->i_packet_size + i_preheader); p_sys->i_packet_size + i_preheader);
/* reserve 14 bytes for the packet header */ /* reserve 14 bytes for the packet header */
p_sys->i_pk_used = 14 + i_preheader; p_sys->i_pk_used = 14 + i_preheader;
...@@ -1043,21 +1043,21 @@ static sout_buffer_t *asf_packet_create( sout_mux_t *p_mux, ...@@ -1043,21 +1043,21 @@ static sout_buffer_t *asf_packet_create( sout_mux_t *p_mux,
} }
tk->i_sequence++; tk->i_sequence++;
sout_BufferDelete( p_mux->p_sout, data ); block_Release( data );
return first; return first;
} }
static sout_buffer_t *asf_stream_end_create( sout_mux_t *p_mux ) static block_t *asf_stream_end_create( sout_mux_t *p_mux )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *out = NULL; block_t *out = NULL;
bo_t bo; bo_t bo;
if( p_sys->b_asf_http ) if( p_sys->b_asf_http )
{ {
out = sout_BufferNew( p_mux->p_sout, 12 ); out = block_New( p_mux, 12 );
bo_init( &bo, out->p_buffer, 12 ); bo_init( &bo, out->p_buffer, 12 );
asf_chunk_add( &bo, 0x4524, 0, 0x00, p_sys->i_seq++ ); asf_chunk_add( &bo, 0x4524, 0, 0x00, p_sys->i_seq++ );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* avi.c * avi.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: avi.c,v 1.18 2004/02/06 23:43:32 gbazin Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -119,8 +119,8 @@ struct sout_mux_sys_t ...@@ -119,8 +119,8 @@ struct sout_mux_sys_t
#define AVIIF_KEYFRAME 0x00000010L /* this frame is a key frame.*/ #define AVIIF_KEYFRAME 0x00000010L /* this frame is a key frame.*/
static sout_buffer_t *avi_HeaderCreateRIFF( sout_mux_t * ); static block_t *avi_HeaderCreateRIFF( sout_mux_t * );
static sout_buffer_t *avi_HeaderCreateidx1( sout_mux_t * ); static block_t *avi_HeaderCreateidx1( sout_mux_t * );
static void SetFCC( uint8_t *p, char *fcc ) static void SetFCC( uint8_t *p, char *fcc )
{ {
...@@ -154,7 +154,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -154,7 +154,6 @@ static int Open( vlc_object_t *p_this )
p_mux->pf_delstream = DelStream; p_mux->pf_delstream = DelStream;
p_mux->pf_mux = Mux; p_mux->pf_mux = Mux;
p_mux->p_sys = p_sys; p_mux->p_sys = p_sys;
p_mux->i_preheader = 8; /* (fourcc,length) header */
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -167,14 +166,14 @@ static void Close( vlc_object_t * p_this ) ...@@ -167,14 +166,14 @@ static void Close( vlc_object_t * p_this )
sout_mux_t *p_mux = (sout_mux_t*)p_this; sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_hdr, *p_idx1; block_t *p_hdr, *p_idx1;
int i_stream; int i_stream;
msg_Dbg( p_mux, "AVI muxer closed" ); msg_Dbg( p_mux, "AVI muxer closed" );
/* first create idx1 chunk (write at the end of the stream */ /* first create idx1 chunk (write at the end of the stream */
p_idx1 = avi_HeaderCreateidx1( p_mux ); p_idx1 = avi_HeaderCreateidx1( p_mux );
p_sys->i_idx1_size = p_idx1->i_size; p_sys->i_idx1_size = p_idx1->i_buffer;
sout_AccessOutWrite( p_mux->p_access, p_idx1 ); sout_AccessOutWrite( p_mux->p_access, p_idx1 );
/* calculate some value for headers creations */ /* calculate some value for headers creations */
...@@ -388,7 +387,7 @@ static int Mux ( sout_mux_t *p_mux ) ...@@ -388,7 +387,7 @@ static int Mux ( sout_mux_t *p_mux )
if( p_sys->b_write_header ) if( p_sys->b_write_header )
{ {
sout_buffer_t *p_hdr; block_t *p_hdr;
msg_Dbg( p_mux, "writing header" ); msg_Dbg( p_mux, "writing header" );
...@@ -401,7 +400,7 @@ static int Mux ( sout_mux_t *p_mux ) ...@@ -401,7 +400,7 @@ static int Mux ( sout_mux_t *p_mux )
for( i = 0; i < p_mux->i_nb_inputs; i++ ) for( i = 0; i < p_mux->i_nb_inputs; i++ )
{ {
int i_count; int i_count;
sout_fifo_t *p_fifo; block_fifo_t *p_fifo;
i_stream = *((int*)p_mux->pp_inputs[i]->p_sys ); i_stream = *((int*)p_mux->pp_inputs[i]->p_sys );
p_stream = &p_sys->stream[i_stream]; p_stream = &p_sys->stream[i_stream];
...@@ -411,27 +410,32 @@ static int Mux ( sout_mux_t *p_mux ) ...@@ -411,27 +410,32 @@ static int Mux ( sout_mux_t *p_mux )
while( i_count > 0 ) while( i_count > 0 )
{ {
avi_idx1_entry_t *p_idx; avi_idx1_entry_t *p_idx;
sout_buffer_t *p_data; block_t *p_data;
p_data = sout_FifoGet( p_fifo ); p_data = block_FifoGet( p_fifo );
if( p_fifo->i_depth > 0 )
{
block_t *p_next = block_FifoShow( p_fifo );
p_data->i_length = p_next->i_dts - p_data->i_dts;
}
p_stream->i_frames++; p_stream->i_frames++;
if( p_data->i_length < 0 ) if( p_data->i_length < 0 )
{ {
msg_Warn( p_mux, "argg length < 0 l" ); msg_Warn( p_mux, "argg length < 0 l" );
sout_BufferDelete( p_mux->p_sout, p_data ); block_Release( p_data );
i_count--; i_count--;
continue; continue;
} }
p_stream->i_duration += p_data->i_length; p_stream->i_duration += p_data->i_length;
p_stream->i_totalsize += p_data->i_size; p_stream->i_totalsize += p_data->i_buffer;
/* add idx1 entry for this frame */ /* add idx1 entry for this frame */
p_idx = &p_sys->idx1.entry[p_sys->idx1.i_entry_count]; p_idx = &p_sys->idx1.entry[p_sys->idx1.i_entry_count];
memcpy( p_idx->fcc, p_stream->fcc, 4 ); memcpy( p_idx->fcc, p_stream->fcc, 4 );
p_idx->i_flags = AVIIF_KEYFRAME; p_idx->i_flags = AVIIF_KEYFRAME;
p_idx->i_pos = p_sys->i_movi_size + 4; p_idx->i_pos = p_sys->i_movi_size + 4;
p_idx->i_length= p_data->i_size; p_idx->i_length= p_data->i_buffer;
p_sys->idx1.i_entry_count++; p_sys->idx1.i_entry_count++;
if( p_sys->idx1.i_entry_count >= p_sys->idx1.i_entry_max ) if( p_sys->idx1.i_entry_count >= p_sys->idx1.i_entry_max )
{ {
...@@ -440,34 +444,20 @@ static int Mux ( sout_mux_t *p_mux ) ...@@ -440,34 +444,20 @@ static int Mux ( sout_mux_t *p_mux )
p_sys->idx1.i_entry_max * sizeof( avi_idx1_entry_t ) ); p_sys->idx1.i_entry_max * sizeof( avi_idx1_entry_t ) );
} }
p_data = block_Realloc( p_data, 8, 0 );
if( sout_BufferReallocFromPreHeader( p_mux->p_sout, p_data, 8 ) ) if( p_data )
{
/* there isn't enough data in preheader */
sout_buffer_t *p_hdr;
p_hdr = sout_BufferNew( p_mux->p_sout, 8 );
SetFCC( p_hdr->p_buffer, p_stream->fcc );
SetDWLE( p_hdr->p_buffer + 4, p_data->i_size );
sout_AccessOutWrite( p_mux->p_access, p_hdr );
p_sys->i_movi_size += p_hdr->i_size;
}
else
{ {
SetFCC( p_data->p_buffer, p_stream->fcc ); SetFCC( p_data->p_buffer, p_stream->fcc );
SetDWLE( p_data->p_buffer + 4, p_data->i_size - 8 ); SetDWLE( p_data->p_buffer + 4, p_data->i_buffer - 8 );
}
if( p_data->i_size & 0x01 ) if( p_data->i_buffer & 0x01 )
{ {
sout_BufferRealloc( p_mux->p_sout, p_data, p_data->i_size + 1 ); p_data = block_Realloc( p_data, 0, p_data->i_buffer + 1 );
p_data->i_size += 1;
} }
p_sys->i_movi_size += p_data->i_size; p_sys->i_movi_size += p_data->i_buffer;
sout_AccessOutWrite( p_mux->p_access, p_data ); sout_AccessOutWrite( p_mux->p_access, p_data );
}
i_count--; i_count--;
} }
...@@ -774,16 +764,16 @@ static int avi_HeaderAdd_strl( sout_mux_t *p_mux, ...@@ -774,16 +764,16 @@ static int avi_HeaderAdd_strl( sout_mux_t *p_mux,
AVI_BOX_EXIT( 0 ); AVI_BOX_EXIT( 0 );
} }
static sout_buffer_t *avi_HeaderCreateRIFF( sout_mux_t *p_mux ) static block_t *avi_HeaderCreateRIFF( sout_mux_t *p_mux )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_hdr; block_t *p_hdr;
int i_stream; int i_stream;
int i_maxbytespersec; int i_maxbytespersec;
int i_junk; int i_junk;
buffer_out_t bo; buffer_out_t bo;
p_hdr = sout_BufferNew( p_mux->p_sout, HDR_SIZE ); p_hdr = block_New( p_mux, HDR_SIZE );
memset( p_hdr->p_buffer, 0, HDR_SIZE ); memset( p_hdr->p_buffer, 0, HDR_SIZE );
bo_Init( &bo, HDR_SIZE, p_hdr->p_buffer ); bo_Init( &bo, HDR_SIZE, p_hdr->p_buffer );
...@@ -814,17 +804,17 @@ static sout_buffer_t *avi_HeaderCreateRIFF( sout_mux_t *p_mux ) ...@@ -814,17 +804,17 @@ static sout_buffer_t *avi_HeaderCreateRIFF( sout_mux_t *p_mux )
return( p_hdr ); return( p_hdr );
} }
static sout_buffer_t * avi_HeaderCreateidx1( sout_mux_t *p_mux ) static block_t * avi_HeaderCreateidx1( sout_mux_t *p_mux )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_idx1; block_t *p_idx1;
uint32_t i_idx1_size; uint32_t i_idx1_size;
unsigned int i; unsigned int i;
buffer_out_t bo; buffer_out_t bo;
i_idx1_size = 16 * p_sys->idx1.i_entry_count; i_idx1_size = 16 * p_sys->idx1.i_entry_count;
p_idx1 = sout_BufferNew( p_mux->p_sout, i_idx1_size + 8 ); p_idx1 = block_New( p_mux, i_idx1_size + 8 );
memset( p_idx1->p_buffer, 0, i_idx1_size ); memset( p_idx1->p_buffer, 0, i_idx1_size );
bo_Init( &bo, i_idx1_size, p_idx1->p_buffer ); bo_Init( &bo, i_idx1_size, p_idx1->p_buffer );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dummy.c: dummy muxer module for vlc * dummy.c: dummy muxer module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: dummy.c,v 1.10 2003/12/14 22:49:28 gbazin Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -28,10 +28,8 @@ ...@@ -28,10 +28,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/sout.h> #include <vlc/sout.h>
#include "codecs.h"
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -130,22 +128,18 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -130,22 +128,18 @@ static int Mux( sout_mux_t *p_mux )
for( i = 0; i < p_mux->i_nb_inputs; i++ ) for( i = 0; i < p_mux->i_nb_inputs; i++ )
{ {
block_fifo_t *p_fifo;
int i_count; int i_count;
sout_fifo_t *p_fifo;
if( p_sys->b_header && p_mux->pp_inputs[i]->p_fmt->i_extra ) if( p_sys->b_header && p_mux->pp_inputs[i]->p_fmt->i_extra )
{ {
/* Write header data */ /* Write header data */
sout_buffer_t *p_data; block_t *p_data;
p_data = sout_BufferNew( p_mux->p_sout, p_data = block_New( p_mux, p_mux->pp_inputs[i]->p_fmt->i_extra );
p_mux->pp_inputs[i]->p_fmt->i_extra );
memcpy( p_data->p_buffer, p_mux->pp_inputs[i]->p_fmt->p_extra, memcpy( p_data->p_buffer, p_mux->pp_inputs[i]->p_fmt->p_extra,
p_mux->pp_inputs[i]->p_fmt->i_extra ); p_mux->pp_inputs[i]->p_fmt->i_extra );
p_data->i_size = p_mux->pp_inputs[i]->p_fmt->i_extra;
p_data->i_dts = p_data->i_pts = p_data->i_length = 0;
msg_Dbg( p_mux, "writing header data" ); msg_Dbg( p_mux, "writing header data" );
sout_AccessOutWrite( p_mux->p_access, p_data ); sout_AccessOutWrite( p_mux->p_access, p_data );
} }
...@@ -154,15 +148,12 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -154,15 +148,12 @@ static int Mux( sout_mux_t *p_mux )
i_count = p_fifo->i_depth; i_count = p_fifo->i_depth;
while( i_count > 0 ) while( i_count > 0 )
{ {
sout_buffer_t *p_data; block_t *p_data = block_FifoGet( p_fifo );
p_data = sout_FifoGet( p_fifo );
sout_AccessOutWrite( p_mux->p_access, p_data ); sout_AccessOutWrite( p_mux->p_access, p_data );
i_count--; i_count--;
} }
} }
p_sys->b_header = VLC_FALSE; p_sys->b_header = VLC_FALSE;
......
...@@ -151,7 +151,7 @@ static void box_gather ( bo_t *box, bo_t *box2 ); ...@@ -151,7 +151,7 @@ static void box_gather ( bo_t *box, bo_t *box2 );
static void box_send( sout_mux_t *p_mux, bo_t *box ); static void box_send( sout_mux_t *p_mux, bo_t *box );
static sout_buffer_t *bo_to_sout( sout_instance_t *p_sout, bo_t *box ); static block_t *bo_to_sout( sout_instance_t *p_sout, bo_t *box );
static bo_t *GetMoovBox( sout_mux_t *p_mux ); static bo_t *GetMoovBox( sout_mux_t *p_mux );
...@@ -217,7 +217,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -217,7 +217,7 @@ static void Close( vlc_object_t * p_this )
{ {
sout_mux_t *p_mux = (sout_mux_t*)p_this; sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_hdr; block_t *p_hdr;
bo_t bo, *moov; bo_t bo, *moov;
vlc_value_t val; vlc_value_t val;
...@@ -260,14 +260,14 @@ static void Close( vlc_object_t * p_this ) ...@@ -260,14 +260,14 @@ static void Close( vlc_object_t * p_this )
{ {
/* Move data to the end of the file so we can fit the moov header /* Move data to the end of the file so we can fit the moov header
* at the start */ * at the start */
sout_buffer_t *p_buf; block_t *p_buf;
int64_t i_chunk, i_size = p_sys->i_pos - p_sys->i_mdat_pos; int64_t i_chunk, i_size = p_sys->i_pos - p_sys->i_mdat_pos;
int i_moov_size = moov->i_buffer; int i_moov_size = moov->i_buffer;
while( i_size > 0 ) while( i_size > 0 )
{ {
i_chunk = __MIN( 32768, i_size ); i_chunk = __MIN( 32768, i_size );
p_buf = sout_BufferNew( p_mux->p_sout, i_chunk ); p_buf = block_New( p_mux, i_chunk );
sout_AccessOutSeek( p_mux->p_access, sout_AccessOutSeek( p_mux->p_access,
p_sys->i_mdat_pos + i_size - i_chunk ); p_sys->i_mdat_pos + i_size - i_chunk );
if( sout_AccessOutRead( p_mux->p_access, p_buf ) < i_chunk ) if( sout_AccessOutRead( p_mux->p_access, p_buf ) < i_chunk )
...@@ -420,15 +420,15 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts ) ...@@ -420,15 +420,15 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ ) for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
{ {
sout_fifo_t *p_fifo = p_mux->pp_inputs[i]->p_fifo; block_fifo_t *p_fifo = p_mux->pp_inputs[i]->p_fifo;
sout_buffer_t *p_buf; block_t *p_buf;
if( p_fifo->i_depth <= 1 ) if( p_fifo->i_depth <= 1 )
{ {
return -1; // wait that all fifo have at least 2 packets return -1; // wait that all fifo have at least 2 packets
} }
p_buf = sout_FifoShow( p_fifo ); p_buf = block_FifoShow( p_fifo );
if( i_stream < 0 || p_buf->i_dts < i_dts ) if( i_stream < 0 || p_buf->i_dts < i_dts )
{ {
i_dts = p_buf->i_dts; i_dts = p_buf->i_dts;
...@@ -458,7 +458,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -458,7 +458,7 @@ static int Mux( sout_mux_t *p_mux )
sout_input_t *p_input; sout_input_t *p_input;
int i_stream; int i_stream;
mp4_stream_t *p_stream; mp4_stream_t *p_stream;
sout_buffer_t *p_data; block_t *p_data;
mtime_t i_dts; mtime_t i_dts;
if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 ) if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
...@@ -469,10 +469,10 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -469,10 +469,10 @@ static int Mux( sout_mux_t *p_mux )
p_input = p_mux->pp_inputs[i_stream]; p_input = p_mux->pp_inputs[i_stream];
p_stream = (mp4_stream_t*)p_input->p_sys; p_stream = (mp4_stream_t*)p_input->p_sys;
p_data = sout_FifoGet( p_input->p_fifo ); p_data = block_FifoGet( p_input->p_fifo );
if( p_input->p_fifo->i_depth > 0 ) if( p_input->p_fifo->i_depth > 0 )
{ {
sout_buffer_t *p_next = sout_FifoShow( p_input->p_fifo ); block_t *p_next = block_FifoShow( p_input->p_fifo );
int64_t i_diff = p_next->i_dts - p_data->i_dts; int64_t i_diff = p_next->i_dts - p_data->i_dts;
if( i_diff < I64C(1000000 ) ) /* protection */ if( i_diff < I64C(1000000 ) ) /* protection */
...@@ -509,7 +509,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -509,7 +509,7 @@ static int Mux( sout_mux_t *p_mux )
/* add index entry */ /* add index entry */
p_stream->entry[p_stream->i_entry_count].i_pos = p_sys->i_pos; p_stream->entry[p_stream->i_entry_count].i_pos = p_sys->i_pos;
p_stream->entry[p_stream->i_entry_count].i_size = p_data->i_size; p_stream->entry[p_stream->i_entry_count].i_size = p_data->i_buffer;
p_stream->entry[p_stream->i_entry_count].i_pts_dts= p_stream->entry[p_stream->i_entry_count].i_pts_dts=
__MAX( p_data->i_pts - p_data->i_dts, 0 ); __MAX( p_data->i_pts - p_data->i_dts, 0 );
p_stream->entry[p_stream->i_entry_count].i_length = p_data->i_length; p_stream->entry[p_stream->i_entry_count].i_length = p_data->i_length;
...@@ -526,7 +526,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -526,7 +526,7 @@ static int Mux( sout_mux_t *p_mux )
/* update */ /* update */
p_stream->i_duration += p_data->i_length; p_stream->i_duration += p_data->i_length;
p_sys->i_pos += p_data->i_size; p_sys->i_pos += p_data->i_buffer;
/* write data */ /* write data */
sout_AccessOutWrite( p_mux->p_access, p_data ); sout_AccessOutWrite( p_mux->p_access, p_data );
...@@ -1116,8 +1116,7 @@ static bo_t *GetStblBox( sout_mux_t *p_mux, mp4_stream_t *p_stream ) ...@@ -1116,8 +1116,7 @@ static bo_t *GetStblBox( sout_mux_t *p_mux, mp4_stream_t *p_stream )
stss = NULL; stss = NULL;
for( i = 0, i_index = 0; i < p_stream->i_entry_count; i++ ) for( i = 0, i_index = 0; i < p_stream->i_entry_count; i++ )
{ {
if( p_stream->entry[i].i_flags & if( p_stream->entry[i].i_flags & BLOCK_FLAG_TYPE_I )
(BLOCK_FLAG_TYPE_I << SOUT_BUFFER_FLAGS_BLOCK_SHIFT) )
{ {
if( stss == NULL ) if( stss == NULL )
{ {
...@@ -1704,24 +1703,22 @@ static void box_gather ( bo_t *box, bo_t *box2 ) ...@@ -1704,24 +1703,22 @@ static void box_gather ( bo_t *box, bo_t *box2 )
box_free( box2 ); box_free( box2 );
} }
static sout_buffer_t * bo_to_sout( sout_instance_t *p_sout, bo_t *box ) static block_t * bo_to_sout( sout_instance_t *p_sout, bo_t *box )
{ {
sout_buffer_t *p_buf; block_t *p_buf;
p_buf = sout_BufferNew( p_sout, box->i_buffer ); p_buf = block_New( p_sout, box->i_buffer );
if( box->i_buffer > 0 ) if( box->i_buffer > 0 )
{ {
memcpy( p_buf->p_buffer, box->p_buffer, box->i_buffer ); memcpy( p_buf->p_buffer, box->p_buffer, box->i_buffer );
} }
p_buf->i_size = box->i_buffer;
return p_buf; return p_buf;
} }
static void box_send( sout_mux_t *p_mux, bo_t *box ) static void box_send( sout_mux_t *p_mux, bo_t *box )
{ {
sout_buffer_t *p_buf; block_t *p_buf;
p_buf = bo_to_sout( p_mux->p_sout, box ); p_buf = bo_to_sout( p_mux->p_sout, box );
box_free( box ); box_free( box );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* pes.c: PES packetizer used by the MPEG multiplexers * pes.c: PES packetizer used by the MPEG multiplexers
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: pes.c,v 1.15 2004/03/03 11:34:41 massiot Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -229,12 +229,12 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts, ...@@ -229,12 +229,12 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
} }
int E_( EStoPES )( sout_instance_t *p_sout, int E_( EStoPES )( sout_instance_t *p_sout,
sout_buffer_t **pp_pes, block_t **pp_pes,
sout_buffer_t *p_es, block_t *p_es,
int i_stream_id, int i_stream_id,
int b_mpeg2 ) int b_mpeg2 )
{ {
sout_buffer_t *p_es_sav, *p_pes; block_t *p_es_sav, *p_pes;
mtime_t i_pts, i_dts, i_length; mtime_t i_pts, i_dts, i_length;
uint8_t *p_data; uint8_t *p_data;
...@@ -258,7 +258,7 @@ int E_( EStoPES )( sout_instance_t *p_sout, ...@@ -258,7 +258,7 @@ int E_( EStoPES )( sout_instance_t *p_sout,
i_pts = p_es->i_pts <= 0 ? 0 : p_es->i_pts * 9 / 100; // 90000 units clock i_pts = p_es->i_pts <= 0 ? 0 : p_es->i_pts * 9 / 100; // 90000 units clock
i_dts = p_es->i_dts <= 0 ? 0 : p_es->i_dts * 9 / 100; // 90000 units clock i_dts = p_es->i_dts <= 0 ? 0 : p_es->i_dts * 9 / 100; // 90000 units clock
i_size = p_es->i_size; i_size = p_es->i_buffer;
p_data = p_es->p_buffer; p_data = p_es->p_buffer;
*pp_pes = p_pes = NULL; *pp_pes = p_pes = NULL;
...@@ -274,12 +274,7 @@ int E_( EStoPES )( sout_instance_t *p_sout, ...@@ -274,12 +274,7 @@ int E_( EStoPES )( sout_instance_t *p_sout,
if( p_es ) if( p_es )
{ {
if( sout_BufferReallocFromPreHeader( p_sout, p_es, i_pes_header ) ) p_es = block_Realloc( p_es, i_pes_header, 0 );
{
msg_Err( p_sout,
"cannot realloc preheader (should never happen)" );
return( -1 );
}
/* reuse p_es for first frame */ /* reuse p_es for first frame */
*pp_pes = p_pes = p_es; *pp_pes = p_pes = p_es;
/* don't touch i_dts, i_pts, i_length as are already set :) */ /* don't touch i_dts, i_pts, i_length as are already set :) */
...@@ -287,8 +282,7 @@ int E_( EStoPES )( sout_instance_t *p_sout, ...@@ -287,8 +282,7 @@ int E_( EStoPES )( sout_instance_t *p_sout,
} }
else else
{ {
p_pes->p_next = sout_BufferNew( p_sout, p_pes->p_next = block_New( p_sout, i_pes_header + i_pes_payload );
i_pes_header + i_pes_payload );
p_pes = p_pes->p_next; p_pes = p_pes->p_next;
p_pes->i_dts = 0; p_pes->i_dts = 0;
...@@ -307,16 +301,10 @@ int E_( EStoPES )( sout_instance_t *p_sout, ...@@ -307,16 +301,10 @@ int E_( EStoPES )( sout_instance_t *p_sout,
i_size -= i_pes_payload; i_size -= i_pes_payload;
p_data += i_pes_payload; p_data += i_pes_payload;
p_pes->i_size = i_pes_header + i_pes_payload; p_pes->i_buffer = i_pes_header + i_pes_payload;
} while( i_size > 0 ); } while( i_size > 0 );
/* save some space */
if( p_es_sav->i_size + 10*1024 < p_es_sav->i_buffer_size )
{
sout_BufferRealloc( p_sout, p_es_sav, p_es_sav->i_size );
}
/* Now redate all pes */ /* Now redate all pes */
i_dts = (*pp_pes)->i_dts; i_dts = (*pp_pes)->i_dts;
i_length = (*pp_pes)->i_length / i_pes_count; i_length = (*pp_pes)->i_length / i_pes_count;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* pes.h * pes.h
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: pes.h,v 1.3 2003/01/08 10:34:58 fenrir Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -35,5 +35,5 @@ ...@@ -35,5 +35,5 @@
int E_( EStoPES )( sout_instance_t *p_sout, int E_( EStoPES )( sout_instance_t *p_sout,
sout_buffer_t **pp_pes, sout_buffer_t *p_es, block_t **pp_pes, block_t *p_es,
int i_stream_id, int b_mpeg2 ); int i_stream_id, int b_mpeg2 );
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* multiplexer module for vlc * multiplexer module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: ps.c,v 1.16 2003/11/21 15:32:08 fenrir Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -72,8 +72,8 @@ static int Mux ( sout_mux_t * ); ...@@ -72,8 +72,8 @@ static int Mux ( sout_mux_t * );
*****************************************************************************/ *****************************************************************************/
static int MuxGetStream ( sout_mux_t *, int *, mtime_t * ); static int MuxGetStream ( sout_mux_t *, int *, mtime_t * );
static void MuxWritePackHeader ( sout_mux_t *, sout_buffer_t **, mtime_t ); static void MuxWritePackHeader ( sout_mux_t *, block_t **, mtime_t );
static void MuxWriteSystemHeader( sout_mux_t *, sout_buffer_t ** ); static void MuxWriteSystemHeader( sout_mux_t *, block_t ** );
static void StreamIdInit ( vlc_bool_t *id, int i_range ); static void StreamIdInit ( vlc_bool_t *id, int i_range );
static int StreamIdGet ( vlc_bool_t *id, int i_id_min, int i_id_max ); static int StreamIdGet ( vlc_bool_t *id, int i_id_min, int i_id_max );
...@@ -120,7 +120,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -120,7 +120,6 @@ static int Open( vlc_object_t *p_this )
p_mux->pf_addstream = AddStream; p_mux->pf_addstream = AddStream;
p_mux->pf_delstream = DelStream; p_mux->pf_delstream = DelStream;
p_mux->pf_mux = Mux; p_mux->pf_mux = Mux;
p_mux->i_preheader = 30; // really enough for a pes header
p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) ); p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) );
/* Init free stream id */ /* Init free stream id */
...@@ -149,11 +148,11 @@ static void Close( vlc_object_t * p_this ) ...@@ -149,11 +148,11 @@ static void Close( vlc_object_t * p_this )
sout_mux_t *p_mux = (sout_mux_t*)p_this; sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_end; block_t *p_end;
msg_Info( p_mux, "Close" ); msg_Info( p_mux, "Close" );
p_end = sout_BufferNew( p_mux->p_sout, 4 ); p_end = block_New( p_mux, 4 );
p_end->p_buffer[0] = 0x00; p_end->p_buffer[0] = 0x00;
p_end->p_buffer[1] = 0x00; p_end->p_buffer[1] = 0x00;
p_end->p_buffer[2] = 0x01; p_end->p_buffer[2] = 0x01;
...@@ -297,7 +296,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -297,7 +296,7 @@ static int Mux( sout_mux_t *p_mux )
sout_input_t *p_input; sout_input_t *p_input;
ps_stream_t *p_stream; ps_stream_t *p_stream;
sout_buffer_t *p_ps, *p_data; block_t *p_ps, *p_data;
mtime_t i_dts; mtime_t i_dts;
int i_stream; int i_stream;
...@@ -320,25 +319,25 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -320,25 +319,25 @@ static int Mux( sout_mux_t *p_mux )
/* Write regulary SystemHeader */ /* Write regulary SystemHeader */
if( p_sys->i_pes_count % 300 == 0 ) if( p_sys->i_pes_count % 300 == 0 )
{ {
sout_buffer_t *p_pk; block_t *p_pk;
MuxWriteSystemHeader( p_mux, &p_ps ); MuxWriteSystemHeader( p_mux, &p_ps );
/* For MPEG1 streaming, set HEADER flag */ /* For MPEG1 streaming, set HEADER flag */
for( p_pk = p_ps; p_pk != NULL; p_pk = p_pk->p_next ) for( p_pk = p_ps; p_pk != NULL; p_pk = p_pk->p_next )
{ {
p_pk->i_flags |= SOUT_BUFFER_FLAGS_HEADER; p_pk->i_flags |= BLOCK_FLAG_HEADER;
} }
} }
/* Get and mux a packet */ /* Get and mux a packet */
p_data = sout_FifoGet( p_input->p_fifo ); p_data = block_FifoGet( p_input->p_fifo );
E_( EStoPES )( p_mux->p_sout, E_( EStoPES )( p_mux->p_sout,
&p_data, p_data, &p_data, p_data,
p_stream->i_stream_id, p_stream->i_stream_id,
p_mux->p_sys->b_mpeg2 ); p_mux->p_sys->b_mpeg2 );
sout_BufferChain( &p_ps, p_data ); block_ChainAppend( &p_ps, p_data );
sout_AccessOutWrite( p_mux->p_access, p_ps ); sout_AccessOutWrite( p_mux->p_access, p_ps );
/* Increase counter */ /* Increase counter */
...@@ -381,16 +380,16 @@ static void StreamIdRelease( vlc_bool_t *id, int i_id_min, int i_id ) ...@@ -381,16 +380,16 @@ static void StreamIdRelease( vlc_bool_t *id, int i_id_min, int i_id )
id[i_id - i_id_min] = VLC_TRUE; id[i_id - i_id_min] = VLC_TRUE;
} }
static void MuxWritePackHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf, static void MuxWritePackHeader( sout_mux_t *p_mux, block_t **p_buf,
mtime_t i_dts ) mtime_t i_dts )
{ {
sout_buffer_t *p_hdr; block_t *p_hdr;
bits_buffer_t bits; bits_buffer_t bits;
mtime_t i_src; mtime_t i_src;
i_src = i_dts * 9 / 100; i_src = i_dts * 9 / 100;
p_hdr = sout_BufferNew( p_mux->p_sout, 18 ); p_hdr = block_New( p_mux, 18 );
bits_initwrite( &bits, 14, p_hdr->p_buffer ); bits_initwrite( &bits, 14, p_hdr->p_buffer );
bits_write( &bits, 32, 0x01ba ); bits_write( &bits, 32, 0x01ba );
...@@ -426,15 +425,15 @@ static void MuxWritePackHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf, ...@@ -426,15 +425,15 @@ static void MuxWritePackHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf,
bits_write( &bits, 3, 0 ); // stuffing bytes bits_write( &bits, 3, 0 ); // stuffing bytes
} }
p_hdr->i_size = p_mux->p_sys->b_mpeg2 ? 14: 12; p_hdr->i_buffer = p_mux->p_sys->b_mpeg2 ? 14: 12;
sout_BufferChain( p_buf, p_hdr ); block_ChainAppend( p_buf, p_hdr );
} }
static void MuxWriteSystemHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf ) static void MuxWriteSystemHeader( sout_mux_t *p_mux, block_t **p_buf )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_hdr; block_t *p_hdr;
bits_buffer_t bits; bits_buffer_t bits;
vlc_bool_t b_private; vlc_bool_t b_private;
int i_nb_private, i_nb_stream; int i_nb_private, i_nb_stream;
...@@ -456,7 +455,7 @@ static void MuxWriteSystemHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf ) ...@@ -456,7 +455,7 @@ static void MuxWriteSystemHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf )
/* Private stream are declared only one time */ /* Private stream are declared only one time */
i_nb_stream = p_mux->i_nb_inputs - ( i_nb_private > 0 ? i_nb_private - 1 : 0 ); i_nb_stream = p_mux->i_nb_inputs - ( i_nb_private > 0 ? i_nb_private - 1 : 0 );
p_hdr = sout_BufferNew( p_mux->p_sout, 12 + i_nb_stream * 3 ); p_hdr = block_New( p_mux, 12 + i_nb_stream * 3 );
bits_initwrite( &bits, 12 + i_nb_stream * 3, p_hdr->p_buffer ); bits_initwrite( &bits, 12 + i_nb_stream * 3, p_hdr->p_buffer );
bits_write( &bits, 32, 0x01bb ); bits_write( &bits, 32, 0x01bb );
...@@ -520,7 +519,7 @@ static void MuxWriteSystemHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf ) ...@@ -520,7 +519,7 @@ static void MuxWriteSystemHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf )
} }
} }
sout_BufferChain( p_buf, p_hdr ); block_ChainAppend( p_buf, p_hdr );
} }
/* /*
...@@ -537,7 +536,7 @@ static int MuxGetStream( sout_mux_t *p_mux, ...@@ -537,7 +536,7 @@ static int MuxGetStream( sout_mux_t *p_mux,
for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ ) for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
{ {
sout_input_t *p_input = p_mux->pp_inputs[i]; sout_input_t *p_input = p_mux->pp_inputs[i];
sout_buffer_t *p_data; block_t *p_data;
if( p_input->p_fifo->i_depth <= 0 ) if( p_input->p_fifo->i_depth <= 0 )
{ {
...@@ -551,7 +550,7 @@ static int MuxGetStream( sout_mux_t *p_mux, ...@@ -551,7 +550,7 @@ static int MuxGetStream( sout_mux_t *p_mux,
continue; continue;
} }
p_data = sout_FifoShow( p_input->p_fifo ); p_data = block_FifoShow( p_input->p_fifo );
if( i_stream == -1 || if( i_stream == -1 ||
p_data->i_dts < i_dts ) p_data->i_dts < i_dts )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ts.c: MPEG-II TS Muxer * ts.c: MPEG-II TS Muxer
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: ts.c,v 1.46 2004/03/03 11:34:41 massiot Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -95,13 +95,13 @@ vlc_module_end(); ...@@ -95,13 +95,13 @@ vlc_module_end();
/***************************************************************************** /*****************************************************************************
* Local data structures * Local data structures
*****************************************************************************/ *****************************************************************************/
#define SOUT_BUFFER_FLAGS_PRIVATE_PCR ( 1 << SOUT_BUFFER_FLAGS_PRIVATE_SHIFT ) #define SOUT_BUFFER_FLAGS_PRIVATE_PCR ( 1 << BLOCK_FLAG_PRIVATE_SHIFT )
#define SOUT_BUFFER_FLAGS_PRIVATE_CSA ( 2 << SOUT_BUFFER_FLAGS_PRIVATE_SHIFT ) #define SOUT_BUFFER_FLAGS_PRIVATE_CSA ( 2 << BLOCK_FLAG_PRIVATE_SHIFT )
typedef struct typedef struct
{ {
int i_depth; int i_depth;
sout_buffer_t *p_first; block_t *p_first;
sout_buffer_t **pp_last; block_t **pp_last;
} sout_buffer_chain_t; } sout_buffer_chain_t;
static inline void BufferChainInit ( sout_buffer_chain_t *c ) static inline void BufferChainInit ( sout_buffer_chain_t *c )
...@@ -110,7 +110,7 @@ static inline void BufferChainInit ( sout_buffer_chain_t *c ) ...@@ -110,7 +110,7 @@ static inline void BufferChainInit ( sout_buffer_chain_t *c )
c->p_first = NULL; c->p_first = NULL;
c->pp_last = &c->p_first; c->pp_last = &c->p_first;
} }
static inline void BufferChainAppend( sout_buffer_chain_t *c, sout_buffer_t *b ) static inline void BufferChainAppend( sout_buffer_chain_t *c, block_t *b )
{ {
*c->pp_last = b; *c->pp_last = b;
c->i_depth++; c->i_depth++;
...@@ -122,9 +122,9 @@ static inline void BufferChainAppend( sout_buffer_chain_t *c, sout_buffer_t *b ) ...@@ -122,9 +122,9 @@ static inline void BufferChainAppend( sout_buffer_chain_t *c, sout_buffer_t *b )
} }
c->pp_last = &b->p_next; c->pp_last = &b->p_next;
} }
static inline sout_buffer_t *BufferChainGet( sout_buffer_chain_t *c ) static inline block_t *BufferChainGet( sout_buffer_chain_t *c )
{ {
sout_buffer_t *b = c->p_first; block_t *b = c->p_first;
if( b ) if( b )
{ {
...@@ -140,19 +140,19 @@ static inline sout_buffer_t *BufferChainGet( sout_buffer_chain_t *c ) ...@@ -140,19 +140,19 @@ static inline sout_buffer_t *BufferChainGet( sout_buffer_chain_t *c )
} }
return b; return b;
} }
static inline sout_buffer_t *BufferChainPeek( sout_buffer_chain_t *c ) static inline block_t *BufferChainPeek( sout_buffer_chain_t *c )
{ {
sout_buffer_t *b = c->p_first; block_t *b = c->p_first;
return b; return b;
} }
static inline void BufferChainClean( sout_instance_t *p_sout, sout_buffer_chain_t *c ) static inline void BufferChainClean( sout_instance_t *p_sout, sout_buffer_chain_t *c )
{ {
sout_buffer_t *b; block_t *b;
while( ( b = BufferChainGet( c ) ) ) while( ( b = BufferChainGet( c ) ) )
{ {
sout_BufferDelete( p_sout, b ); block_Release( b );
} }
BufferChainInit( c ); BufferChainInit( c );
} }
...@@ -260,10 +260,10 @@ static void TSDate ( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts, ...@@ -260,10 +260,10 @@ static void TSDate ( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
static void GetPAT( sout_mux_t *p_mux, sout_buffer_chain_t *c ); static void GetPAT( sout_mux_t *p_mux, sout_buffer_chain_t *c );
static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c ); static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c );
static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_t b_pcr ); static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_t b_pcr );
static void TSSetPCR( sout_buffer_t *p_ts, mtime_t i_dts ); static void TSSetPCR( block_t *p_ts, mtime_t i_dts );
static void PEStoTS ( sout_instance_t *, sout_buffer_chain_t *, sout_buffer_t *, ts_stream_t * ); static void PEStoTS ( sout_instance_t *, sout_buffer_chain_t *, block_t *, ts_stream_t * );
/***************************************************************************** /*****************************************************************************
* Open: * Open:
...@@ -283,7 +283,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -283,7 +283,6 @@ static int Open( vlc_object_t *p_this )
p_mux->pf_delstream = DelStream; p_mux->pf_delstream = DelStream;
p_mux->pf_mux = Mux; p_mux->pf_mux = Mux;
p_mux->p_sys = p_sys; p_mux->p_sys = p_sys;
p_mux->i_preheader = 30; // really enough for a pes header
srand( (uint32_t)mdate() ); srand( (uint32_t)mdate() );
...@@ -773,7 +772,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -773,7 +772,7 @@ static int Mux( sout_mux_t *p_mux )
for( ;; ) for( ;; )
{ {
vlc_bool_t b_ok = VLC_TRUE; vlc_bool_t b_ok = VLC_TRUE;
sout_buffer_t *p_data; block_t *p_data;
/* Accumulate enough data in the pcr stream (>i_shaping_delay) */ /* Accumulate enough data in the pcr stream (>i_shaping_delay) */
/* Accumulate enough data in all other stream ( >= length of pcr) */ /* Accumulate enough data in all other stream ( >= length of pcr) */
...@@ -804,10 +803,10 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -804,10 +803,10 @@ static int Mux( sout_mux_t *p_mux )
} }
b_ok = VLC_FALSE; b_ok = VLC_FALSE;
p_data = sout_FifoGet( p_input->p_fifo ); p_data = block_FifoGet( p_input->p_fifo );
if( p_input->p_fifo->i_depth > 0 ) if( p_input->p_fifo->i_depth > 0 )
{ {
sout_buffer_t *p_next = sout_FifoShow( p_input->p_fifo ); block_t *p_next = block_FifoShow( p_input->p_fifo );
p_data->i_length = p_next->i_dts - p_data->i_dts; p_data->i_length = p_next->i_dts - p_data->i_dts;
} }
...@@ -820,7 +819,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -820,7 +819,7 @@ static int Mux( sout_mux_t *p_mux )
p_data->i_dts, p_data->i_dts,
p_stream->i_pes_dts, p_stream->i_pes_dts,
p_pcr_stream->i_pes_dts ); p_pcr_stream->i_pes_dts );
sout_BufferDelete( p_mux->p_sout, p_data ); block_Release( p_data );
BufferChainClean( p_mux->p_sout, &p_stream->chain_pes ); BufferChainClean( p_mux->p_sout, &p_stream->chain_pes );
p_stream->i_pes_dts = 0; p_stream->i_pes_dts = 0;
...@@ -853,8 +852,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -853,8 +852,7 @@ static int Mux( sout_mux_t *p_mux )
BufferChainAppend( &p_stream->chain_pes, p_data ); BufferChainAppend( &p_stream->chain_pes, p_data );
if( p_sys->b_use_key_frames && p_stream == p_pcr_stream if( p_sys->b_use_key_frames && p_stream == p_pcr_stream
&& (p_data->i_flags & (BLOCK_FLAG_TYPE_I && (p_data->i_flags & BLOCK_FLAG_TYPE_I )
<< SOUT_BUFFER_FLAGS_BLOCK_SHIFT))
&& (p_stream->i_pes_length > 300000) ) && (p_stream->i_pes_length > 300000) )
{ {
i_shaping_delay = p_stream->i_pes_length; i_shaping_delay = p_stream->i_pes_length;
...@@ -881,12 +879,12 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -881,12 +879,12 @@ static int Mux( sout_mux_t *p_mux )
for( i = 0; i < p_mux->i_nb_inputs; i++ ) for( i = 0; i < p_mux->i_nb_inputs; i++ )
{ {
ts_stream_t *p_stream = (ts_stream_t*)p_mux->pp_inputs[i]->p_sys; ts_stream_t *p_stream = (ts_stream_t*)p_mux->pp_inputs[i]->p_sys;
sout_buffer_t *p_pes; block_t *p_pes;
/* False for pcr stream but it will be enough to do PCR algo */ /* False for pcr stream but it will be enough to do PCR algo */
for( p_pes = p_stream->chain_pes.p_first; p_pes != NULL; p_pes = p_pes->p_next ) for( p_pes = p_stream->chain_pes.p_first; p_pes != NULL; p_pes = p_pes->p_next )
{ {
int i_size = p_pes->i_size; int i_size = p_pes->i_buffer;
if( p_pes->i_dts + p_pes->i_length > p_pcr_stream->i_pes_dts + p_pcr_stream->i_pes_length ) if( p_pes->i_dts + p_pes->i_length > p_pcr_stream->i_pes_dts + p_pcr_stream->i_pes_length )
{ {
mtime_t i_frag = p_pcr_stream->i_pes_dts + p_pcr_stream->i_pes_length - p_pes->i_dts; mtime_t i_frag = p_pcr_stream->i_pes_dts + p_pcr_stream->i_pes_length - p_pes->i_dts;
...@@ -895,7 +893,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -895,7 +893,7 @@ static int Mux( sout_mux_t *p_mux )
/* Next stream */ /* Next stream */
break; break;
} }
i_size = p_pes->i_size * i_frag / p_pes->i_length; i_size = p_pes->i_buffer * i_frag / p_pes->i_length;
} }
i_packet_count += ( i_size + 183 ) / 184; i_packet_count += ( i_size + 183 ) / 184;
} }
...@@ -918,7 +916,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -918,7 +916,7 @@ static int Mux( sout_mux_t *p_mux )
int i_stream; int i_stream;
mtime_t i_dts; mtime_t i_dts;
ts_stream_t *p_stream; ts_stream_t *p_stream;
sout_buffer_t *p_ts; block_t *p_ts;
vlc_bool_t b_pcr; vlc_bool_t b_pcr;
/* Select stream (lowest dts) */ /* Select stream (lowest dts) */
...@@ -987,7 +985,7 @@ static void TSSchedule( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts, ...@@ -987,7 +985,7 @@ static void TSSchedule( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
for( i = 0; i < i_packet_count; i++ ) for( i = 0; i < i_packet_count; i++ )
{ {
sout_buffer_t *p_ts = BufferChainGet( p_chain_ts ); block_t *p_ts = BufferChainGet( p_chain_ts );
mtime_t i_new_dts = i_pcr_dts + i_pcr_length * i / i_packet_count; mtime_t i_new_dts = i_pcr_dts + i_pcr_length * i / i_packet_count;
BufferChainAppend( &new_chain, p_ts ); BufferChainAppend( &new_chain, p_ts );
...@@ -1069,7 +1067,7 @@ static void TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts, ...@@ -1069,7 +1067,7 @@ static void TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
/* msg_Dbg( p_mux, "real pck=%d", i_packet_count ); */ /* msg_Dbg( p_mux, "real pck=%d", i_packet_count ); */
for( i = 0; i < i_packet_count; i++ ) for( i = 0; i < i_packet_count; i++ )
{ {
sout_buffer_t *p_ts = BufferChainGet( p_chain_ts ); block_t *p_ts = BufferChainGet( p_chain_ts );
mtime_t i_new_dts = i_pcr_dts + i_pcr_length * i / i_packet_count; mtime_t i_new_dts = i_pcr_dts + i_pcr_length * i / i_packet_count;
p_ts->i_dts = i_new_dts; p_ts->i_dts = i_new_dts;
...@@ -1092,10 +1090,10 @@ static void TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts, ...@@ -1092,10 +1090,10 @@ static void TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
} }
} }
static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_t b_pcr ) static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_t b_pcr )
{ {
sout_buffer_t *p_pes = p_stream->chain_pes.p_first; block_t *p_pes = p_stream->chain_pes.p_first;
sout_buffer_t *p_ts; block_t *p_ts;
vlc_bool_t b_new_pes = VLC_FALSE; vlc_bool_t b_new_pes = VLC_FALSE;
vlc_bool_t b_adaptation_field = VLC_FALSE; vlc_bool_t b_adaptation_field = VLC_FALSE;
...@@ -1107,14 +1105,14 @@ static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_ ...@@ -1107,14 +1105,14 @@ static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_
{ {
b_new_pes = VLC_TRUE; b_new_pes = VLC_TRUE;
} }
i_payload = __MIN( (int)p_pes->i_size - p_stream->i_pes_used, i_payload_max ); i_payload = __MIN( (int)p_pes->i_buffer - p_stream->i_pes_used, i_payload_max );
if( b_pcr || i_payload < i_payload_max ) if( b_pcr || i_payload < i_payload_max )
{ {
b_adaptation_field = VLC_TRUE; b_adaptation_field = VLC_TRUE;
} }
p_ts = sout_BufferNew( p_mux->p_sout, 188 ); p_ts = block_New( p_mux, 188 );
p_ts->i_dts = p_pes->i_dts; p_ts->i_dts = p_pes->i_dts;
p_ts->p_buffer[0] = 0x47; p_ts->p_buffer[0] = 0x47;
...@@ -1168,13 +1166,13 @@ static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_ ...@@ -1168,13 +1166,13 @@ static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_
memcpy( &p_ts->p_buffer[188 - i_payload], &p_pes->p_buffer[p_stream->i_pes_used], i_payload ); memcpy( &p_ts->p_buffer[188 - i_payload], &p_pes->p_buffer[p_stream->i_pes_used], i_payload );
p_stream->i_pes_used += i_payload; p_stream->i_pes_used += i_payload;
p_stream->i_pes_dts = p_pes->i_dts + p_pes->i_length * p_stream->i_pes_used / p_pes->i_size; p_stream->i_pes_dts = p_pes->i_dts + p_pes->i_length * p_stream->i_pes_used / p_pes->i_buffer;
p_stream->i_pes_length -= p_pes->i_length * i_payload / p_pes->i_size; p_stream->i_pes_length -= p_pes->i_length * i_payload / p_pes->i_buffer;
if( p_stream->i_pes_used >= (int)p_pes->i_size ) if( p_stream->i_pes_used >= (int)p_pes->i_buffer )
{ {
p_pes = BufferChainGet( &p_stream->chain_pes ); p_pes = BufferChainGet( &p_stream->chain_pes );
sout_BufferDelete( p_mux->p_sout, p_pes ); block_Release( p_pes );
p_pes = p_stream->chain_pes.p_first; p_pes = p_stream->chain_pes.p_first;
if( p_pes ) if( p_pes )
...@@ -1200,7 +1198,7 @@ static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_ ...@@ -1200,7 +1198,7 @@ static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_
} }
static void TSSetPCR( sout_buffer_t *p_ts, mtime_t i_dts ) static void TSSetPCR( block_t *p_ts, mtime_t i_dts )
{ {
mtime_t i_pcr = 9 * i_dts / 100; mtime_t i_pcr = 9 * i_dts / 100;
...@@ -1232,7 +1230,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t ...@@ -1232,7 +1230,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t
if( i_packets < i_packets_min && i_packets_min > 0 ) if( i_packets < i_packets_min && i_packets_min > 0 )
{ {
sout_buffer_t *p_pk; block_t *p_pk;
int i_div = ( i_packets_min - i_packets ) / i_packets; int i_div = ( i_packets_min - i_packets ) / i_packets;
int i_mod = ( i_packets_min - i_packets ) % i_packets; int i_mod = ( i_packets_min - i_packets ) % i_packets;
int i_rest = 0; int i_rest = 0;
...@@ -1254,7 +1252,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t ...@@ -1254,7 +1252,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t
for( i = 0; i < i_null; i++ ) for( i = 0; i < i_null; i++ )
{ {
sout_buffer_t *p_null; block_t *p_null;
p_null = sout_BufferNew( p_mux->p_sout, 188 ); p_null = sout_BufferNew( p_mux->p_sout, 188 );
p_null->p_buffer[0] = 0x47; p_null->p_buffer[0] = 0x47;
...@@ -1273,7 +1271,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t ...@@ -1273,7 +1271,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t
} }
else if( i_packets > i_packets_max && i_packets_max > 0 ) else if( i_packets > i_packets_max && i_packets_max > 0 )
{ {
sout_buffer_t *p_pk; block_t *p_pk;
int i; int i;
/* Arg, we need to drop packets, I don't do something clever (like /* Arg, we need to drop packets, I don't do something clever (like
...@@ -1298,7 +1296,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t ...@@ -1298,7 +1296,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t
#endif #endif
static void PEStoTS( sout_instance_t *p_sout, static void PEStoTS( sout_instance_t *p_sout,
sout_buffer_chain_t *c, sout_buffer_t *p_pes, sout_buffer_chain_t *c, block_t *p_pes,
ts_stream_t *p_stream ) ts_stream_t *p_stream )
{ {
uint8_t *p_data; uint8_t *p_data;
...@@ -1306,7 +1304,7 @@ static void PEStoTS( sout_instance_t *p_sout, ...@@ -1306,7 +1304,7 @@ static void PEStoTS( sout_instance_t *p_sout,
int b_new_pes; int b_new_pes;
/* get PES total size */ /* get PES total size */
i_size = p_pes->i_size; i_size = p_pes->i_buffer;
p_data = p_pes->p_buffer; p_data = p_pes->p_buffer;
b_new_pes = VLC_TRUE; b_new_pes = VLC_TRUE;
...@@ -1315,9 +1313,9 @@ static void PEStoTS( sout_instance_t *p_sout, ...@@ -1315,9 +1313,9 @@ static void PEStoTS( sout_instance_t *p_sout,
{ {
int b_adaptation_field; int b_adaptation_field;
int i_copy; int i_copy;
sout_buffer_t *p_ts; block_t *p_ts;
p_ts = sout_BufferNew( p_sout, 188 ); p_ts = block_New( p_sout, 188 );
/* write header /* write header
* 8b 0x47 sync byte * 8b 0x47 sync byte
* 1b transport_error_indicator * 1b transport_error_indicator
...@@ -1366,17 +1364,17 @@ static void PEStoTS( sout_instance_t *p_sout, ...@@ -1366,17 +1364,17 @@ static void PEStoTS( sout_instance_t *p_sout,
if( i_size <= 0 ) if( i_size <= 0 )
{ {
sout_buffer_t *p_next = p_pes->p_next; block_t *p_next = p_pes->p_next;
p_pes->p_next = NULL; p_pes->p_next = NULL;
sout_BufferDelete( p_sout, p_pes ); block_Release( p_pes );
if( p_next == NULL ) if( p_next == NULL )
{ {
break; break;
} }
b_new_pes = VLC_TRUE; b_new_pes = VLC_TRUE;
p_pes = p_next; p_pes = p_next;
i_size = p_pes->i_size; i_size = p_pes->i_buffer;
p_data = p_pes->p_buffer; p_data = p_pes->p_buffer;
} }
} }
...@@ -1472,10 +1470,10 @@ static void GetPAT( sout_mux_t *p_mux, ...@@ -1472,10 +1470,10 @@ static void GetPAT( sout_mux_t *p_mux,
sout_buffer_chain_t *c ) sout_buffer_chain_t *c )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_pat; block_t *p_pat;
bits_buffer_t bits; bits_buffer_t bits;
p_pat = sout_BufferNew( p_mux->p_sout, 1024 ); p_pat = block_New( p_mux, 1024 );
p_pat->i_pts = 0; p_pat->i_pts = 0;
p_pat->i_dts = 0; p_pat->i_dts = 0;
...@@ -1502,7 +1500,7 @@ static void GetPAT( sout_mux_t *p_mux, ...@@ -1502,7 +1500,7 @@ static void GetPAT( sout_mux_t *p_mux,
bits_write( &bits, 32, CalculateCRC( bits.p_data + 1, bits.i_data - 1) ); bits_write( &bits, 32, CalculateCRC( bits.p_data + 1, bits.i_data - 1) );
p_pat->i_size = bits.i_data; p_pat->i_buffer = bits.i_data;
PEStoTS( p_mux->p_sout, c, p_pat, &p_sys->pat ); PEStoTS( p_mux->p_sout, c, p_pat, &p_sys->pat );
} }
...@@ -1511,11 +1509,11 @@ static void GetPMT( sout_mux_t *p_mux, ...@@ -1511,11 +1509,11 @@ static void GetPMT( sout_mux_t *p_mux,
sout_buffer_chain_t *c ) sout_buffer_chain_t *c )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_pmt; block_t *p_pmt;
bits_buffer_t bits; bits_buffer_t bits;
int i_stream; int i_stream;
p_pmt = sout_BufferNew( p_mux->p_sout, 1024 ); p_pmt = block_New( p_mux, 1024 );
p_pmt->i_pts = 0; p_pmt->i_pts = 0;
p_pmt->i_dts = 0; p_pmt->i_dts = 0;
...@@ -1558,16 +1556,16 @@ static void GetPMT( sout_mux_t *p_mux, ...@@ -1558,16 +1556,16 @@ static void GetPMT( sout_mux_t *p_mux,
bits_write( &bits, 32, CalculateCRC( bits.p_data + 1, bits.i_data - 1) ); bits_write( &bits, 32, CalculateCRC( bits.p_data + 1, bits.i_data - 1) );
p_pmt->i_size = bits.i_data; p_pmt->i_buffer = bits.i_data;
PEStoTS( p_mux->p_sout, c, p_pmt, &p_sys->pmt ); PEStoTS( p_mux->p_sout, c, p_pmt, &p_sys->pmt );
} }
#elif defined MODULE_NAME_IS_mux_ts_dvbpsi #elif defined MODULE_NAME_IS_mux_ts_dvbpsi
static sout_buffer_t *WritePSISection( sout_instance_t *p_sout, static block_t *WritePSISection( sout_instance_t *p_sout,
dvbpsi_psi_section_t* p_section ) dvbpsi_psi_section_t* p_section )
{ {
sout_buffer_t *p_psi, *p_first = NULL; block_t *p_psi, *p_first = NULL;
while( p_section ) while( p_section )
...@@ -1577,18 +1575,18 @@ static sout_buffer_t *WritePSISection( sout_instance_t *p_sout, ...@@ -1577,18 +1575,18 @@ static sout_buffer_t *WritePSISection( sout_instance_t *p_sout,
i_size = (uint32_t)( p_section->p_payload_end - p_section->p_data )+ i_size = (uint32_t)( p_section->p_payload_end - p_section->p_data )+
( p_section->b_syntax_indicator ? 4 : 0 ); ( p_section->b_syntax_indicator ? 4 : 0 );
p_psi = sout_BufferNew( p_sout, i_size + 1 ); p_psi = block_New( p_sout, i_size + 1 );
p_psi->i_pts = 0; p_psi->i_pts = 0;
p_psi->i_dts = 0; p_psi->i_dts = 0;
p_psi->i_length = 0; p_psi->i_length = 0;
p_psi->i_size = i_size + 1; p_psi->i_buffer = i_size + 1;
p_psi->p_buffer[0] = 0; // pointer p_psi->p_buffer[0] = 0; // pointer
memcpy( p_psi->p_buffer + 1, memcpy( p_psi->p_buffer + 1,
p_section->p_data, p_section->p_data,
i_size ); i_size );
sout_BufferChain( &p_first, p_psi ); block_ChainAppend( &p_first, p_psi );
p_section = p_section->p_next; p_section = p_section->p_next;
} }
...@@ -1600,7 +1598,7 @@ static void GetPAT( sout_mux_t *p_mux, ...@@ -1600,7 +1598,7 @@ static void GetPAT( sout_mux_t *p_mux,
sout_buffer_chain_t *c ) sout_buffer_chain_t *c )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_pat; block_t *p_pat;
dvbpsi_pat_t pat; dvbpsi_pat_t pat;
dvbpsi_psi_section_t *p_section; dvbpsi_psi_section_t *p_section;
...@@ -1639,7 +1637,7 @@ static void GetPMT( sout_mux_t *p_mux, ...@@ -1639,7 +1637,7 @@ static void GetPMT( sout_mux_t *p_mux,
sout_buffer_chain_t *c ) sout_buffer_chain_t *c )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_pmt; block_t *p_pmt;
dvbpsi_pmt_t pmt; dvbpsi_pmt_t pmt;
dvbpsi_pmt_es_t *p_es; dvbpsi_pmt_es_t *p_es;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ogg.c: ogg muxer module for vlc * ogg.c: ogg muxer module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: ogg.c,v 1.28 2004/02/06 23:43:32 gbazin Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com> * Gildas Bazin <gbazin@netcourrier.com>
...@@ -41,22 +41,11 @@ ...@@ -41,22 +41,11 @@
#include <ogg/ogg.h> #include <ogg/ogg.h>
/***************************************************************************** /*****************************************************************************
* Exported prototypes * Module descriptor
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static int Capability(sout_mux_t *, int, void *, void * );
static int AddStream( sout_mux_t *, sout_input_t * );
static int DelStream( sout_mux_t *, sout_input_t * );
static int Mux ( sout_mux_t * );
static sout_buffer_t *OggCreateHeader( sout_mux_t *, mtime_t );
static sout_buffer_t *OggCreateFooter( sout_mux_t *, mtime_t );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin(); vlc_module_begin();
set_description( _("Ogg/ogm muxer") ); set_description( _("Ogg/ogm muxer") );
set_capability( "sout mux", 10 ); set_capability( "sout mux", 10 );
...@@ -65,6 +54,18 @@ vlc_module_begin(); ...@@ -65,6 +54,18 @@ vlc_module_begin();
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Capability(sout_mux_t *, int, void *, void * );
static int AddStream( sout_mux_t *, sout_input_t * );
static int DelStream( sout_mux_t *, sout_input_t * );
static int Mux ( sout_mux_t * );
static block_t *OggCreateHeader( sout_mux_t *, mtime_t );
static block_t *OggCreateFooter( sout_mux_t *, mtime_t );
/***************************************************************************** /*****************************************************************************
* Misc declarations * Misc declarations
*****************************************************************************/ *****************************************************************************/
...@@ -137,7 +138,7 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts ) ...@@ -137,7 +138,7 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ ) for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
{ {
sout_fifo_t *p_fifo; block_fifo_t *p_fifo;
p_fifo = p_mux->pp_inputs[i]->p_fifo; p_fifo = p_mux->pp_inputs[i]->p_fifo;
...@@ -150,9 +151,9 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts ) ...@@ -150,9 +151,9 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
( p_mux->pp_inputs[i]->p_fmt->i_cat == SPU_ES && ( p_mux->pp_inputs[i]->p_fmt->i_cat == SPU_ES &&
p_fifo->i_depth > 0 ) ) p_fifo->i_depth > 0 ) )
{ {
sout_buffer_t *p_buf; block_t *p_buf;
p_buf = sout_FifoShow( p_fifo ); p_buf = block_FifoShow( p_fifo );
if( i_stream < 0 || p_buf->i_dts < i_dts ) if( i_stream < 0 || p_buf->i_dts < i_dts )
{ {
i_dts = p_buf->i_dts; i_dts = p_buf->i_dts;
...@@ -195,7 +196,7 @@ typedef struct ...@@ -195,7 +196,7 @@ typedef struct
oggds_header_t oggds_header; oggds_header_t oggds_header;
sout_buffer_t *pp_sout_headers[3]; block_t *pp_sout_headers[3];
int i_sout_headers; int i_sout_headers;
} ogg_stream_t; } ogg_stream_t;
...@@ -215,8 +216,8 @@ struct sout_mux_sys_t ...@@ -215,8 +216,8 @@ struct sout_mux_sys_t
ogg_stream_t **pp_del_streams; ogg_stream_t **pp_del_streams;
}; };
static void OggSetDate( sout_buffer_t *, mtime_t , mtime_t ); static void OggSetDate( block_t *, mtime_t , mtime_t );
static sout_buffer_t *OggStreamFlush( sout_mux_t *, ogg_stream_state *, static block_t *OggStreamFlush( sout_mux_t *, ogg_stream_state *,
mtime_t ); mtime_t );
/***************************************************************************** /*****************************************************************************
...@@ -240,7 +241,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -240,7 +241,6 @@ static int Open( vlc_object_t *p_this )
p_mux->pf_addstream = AddStream; p_mux->pf_addstream = AddStream;
p_mux->pf_delstream = DelStream; p_mux->pf_delstream = DelStream;
p_mux->pf_mux = Mux; p_mux->pf_mux = Mux;
p_mux->i_preheader = 1;
/* First serial number is random. /* First serial number is random.
* (Done like this because on win32 you need to seed the random number * (Done like this because on win32 you need to seed the random number
...@@ -263,13 +263,13 @@ static void Close( vlc_object_t * p_this ) ...@@ -263,13 +263,13 @@ static void Close( vlc_object_t * p_this )
if( p_sys->i_del_streams ) if( p_sys->i_del_streams )
{ {
sout_buffer_t *p_og = NULL; block_t *p_og = NULL;
mtime_t i_dts = -1; mtime_t i_dts = -1;
int i; int i;
/* Close the current ogg stream */ /* Close the current ogg stream */
msg_Dbg( p_mux, "writing footer" ); msg_Dbg( p_mux, "writing footer" );
sout_BufferChain( &p_og, OggCreateFooter( p_mux, 0 ) ); block_ChainAppend( &p_og, OggCreateFooter( p_mux, 0 ) );
/* Remove deleted logical streams */ /* Remove deleted logical streams */
for( i = 0; i < p_sys->i_del_streams; i++ ) for( i = 0; i < p_sys->i_del_streams; i++ )
...@@ -455,7 +455,7 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -455,7 +455,7 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
ogg_stream_t *p_stream = (ogg_stream_t*)p_input->p_sys; ogg_stream_t *p_stream = (ogg_stream_t*)p_input->p_sys;
sout_buffer_t *p_og; block_t *p_og;
msg_Dbg( p_mux, "removing input" ); msg_Dbg( p_mux, "removing input" );
...@@ -473,7 +473,7 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -473,7 +473,7 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
for( i = 0; i < p_stream->i_sout_headers; i++ ) for( i = 0; i < p_stream->i_sout_headers; i++ )
{ {
sout_BufferDelete( p_mux->p_sout, p_stream->pp_sout_headers[i] ); block_Release( p_stream->pp_sout_headers[i] );
p_stream->i_sout_headers = 0; p_stream->i_sout_headers = 0;
} }
...@@ -502,10 +502,10 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -502,10 +502,10 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
/***************************************************************************** /*****************************************************************************
* Ogg bitstream manipulation routines * Ogg bitstream manipulation routines
*****************************************************************************/ *****************************************************************************/
static sout_buffer_t *OggStreamFlush( sout_mux_t *p_mux, static block_t *OggStreamFlush( sout_mux_t *p_mux,
ogg_stream_state *p_os, mtime_t i_pts ) ogg_stream_state *p_os, mtime_t i_pts )
{ {
sout_buffer_t *p_og, *p_og_first = NULL; block_t *p_og, *p_og_first = NULL;
ogg_page og; ogg_page og;
for( ;; ) for( ;; )
...@@ -519,27 +519,26 @@ static sout_buffer_t *OggStreamFlush( sout_mux_t *p_mux, ...@@ -519,27 +519,26 @@ static sout_buffer_t *OggStreamFlush( sout_mux_t *p_mux,
} }
i_size = og.header_len + og.body_len; i_size = og.header_len + og.body_len;
p_og = sout_BufferNew( p_mux->p_sout, i_size); p_og = block_New( p_mux, i_size);
memcpy( p_og->p_buffer, og.header, og.header_len ); memcpy( p_og->p_buffer, og.header, og.header_len );
memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len ); memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len );
p_og->i_size = i_size;
p_og->i_dts = 0; p_og->i_dts = 0;
p_og->i_pts = i_pts; p_og->i_pts = i_pts;
p_og->i_length = 0; p_og->i_length = 0;
i_pts = 0; // write it only once i_pts = 0; // write it only once
sout_BufferChain( &p_og_first, p_og ); block_ChainAppend( &p_og_first, p_og );
} }
return( p_og_first ); return( p_og_first );
} }
static sout_buffer_t *OggStreamPageOut( sout_mux_t *p_mux, static block_t *OggStreamPageOut( sout_mux_t *p_mux,
ogg_stream_state *p_os, mtime_t i_pts ) ogg_stream_state *p_os, mtime_t i_pts )
{ {
sout_buffer_t *p_og, *p_og_first = NULL; block_t *p_og, *p_og_first = NULL;
ogg_page og; ogg_page og;
for( ;; ) for( ;; )
...@@ -553,27 +552,26 @@ static sout_buffer_t *OggStreamPageOut( sout_mux_t *p_mux, ...@@ -553,27 +552,26 @@ static sout_buffer_t *OggStreamPageOut( sout_mux_t *p_mux,
} }
i_size = og.header_len + og.body_len; i_size = og.header_len + og.body_len;
p_og = sout_BufferNew( p_mux->p_sout, i_size); p_og = block_New( p_mux, i_size);
memcpy( p_og->p_buffer, og.header, og.header_len ); memcpy( p_og->p_buffer, og.header, og.header_len );
memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len ); memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len );
p_og->i_size = i_size;
p_og->i_dts = 0; p_og->i_dts = 0;
p_og->i_pts = i_pts; p_og->i_pts = i_pts;
p_og->i_length = 0; p_og->i_length = 0;
i_pts = 0; // write them only once i_pts = 0; // write them only once
sout_BufferChain( &p_og_first, p_og ); block_ChainAppend( &p_og_first, p_og );
} }
return( p_og_first ); return( p_og_first );
} }
static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts ) static block_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
{ {
sout_buffer_t *p_hdr = NULL; block_t *p_hdr = NULL;
sout_buffer_t *p_og; block_t *p_og;
ogg_packet op; ogg_packet op;
int i; int i;
...@@ -600,9 +598,9 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts ) ...@@ -600,9 +598,9 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
/* first packet in order: vorbis/speex/theora info */ /* first packet in order: vorbis/speex/theora info */
if( !p_stream->i_sout_headers ) if( !p_stream->i_sout_headers )
{ {
p_og = sout_FifoGet( p_mux->pp_inputs[i]->p_fifo ); p_og = block_FifoGet( p_mux->pp_inputs[i]->p_fifo );
op.packet = p_og->p_buffer; op.packet = p_og->p_buffer;
op.bytes = p_og->i_size; op.bytes = p_og->i_buffer;
op.b_o_s = 1; op.b_o_s = 1;
op.e_o_s = 0; op.e_o_s = 0;
op.granulepos = 0; op.granulepos = 0;
...@@ -612,8 +610,7 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts ) ...@@ -612,8 +610,7 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
OggStreamFlush( p_mux, &p_stream->os, 0 ); OggStreamFlush( p_mux, &p_stream->os, 0 );
p_stream->i_sout_headers++; p_stream->i_sout_headers++;
} }
p_og = sout_BufferDuplicate( p_mux->p_sout, p_og = block_Duplicate( p_stream->pp_sout_headers[0] );
p_stream->pp_sout_headers[0] );
/* Get keyframe_granule_shift for theora granulepos calculation */ /* Get keyframe_granule_shift for theora granulepos calculation */
if( p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) ) if( p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
...@@ -655,7 +652,7 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts ) ...@@ -655,7 +652,7 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
p_og = OggStreamFlush( p_mux, &p_stream->os, 0 ); p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
} }
sout_BufferChain( &p_hdr, p_og ); block_ChainAppend( &p_hdr, p_og );
} }
/* Take care of the non b_o_s headers */ /* Take care of the non b_o_s headers */
...@@ -675,9 +672,9 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts ) ...@@ -675,9 +672,9 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
if( p_stream->i_sout_headers < j + 2 ) if( p_stream->i_sout_headers < j + 2 )
{ {
/* next packets in order: comments and codebooks */ /* next packets in order: comments and codebooks */
p_og = sout_FifoGet( p_mux->pp_inputs[i]->p_fifo ); p_og = block_FifoGet( p_mux->pp_inputs[i]->p_fifo );
op.packet = p_og->p_buffer; op.packet = p_og->p_buffer;
op.bytes = p_og->i_size; op.bytes = p_og->i_buffer;
op.b_o_s = 0; op.b_o_s = 0;
op.e_o_s = 0; op.e_o_s = 0;
op.granulepos = 0; op.granulepos = 0;
...@@ -688,9 +685,8 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts ) ...@@ -688,9 +685,8 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
p_stream->i_sout_headers++; p_stream->i_sout_headers++;
} }
p_og = sout_BufferDuplicate( p_mux->p_sout, p_og = block_Duplicate( p_stream->pp_sout_headers[j+1] );
p_stream->pp_sout_headers[j+1] ); block_ChainAppend( &p_hdr, p_og );
sout_BufferChain( &p_hdr, p_og );
} }
} }
else if( p_stream->i_fourcc != VLC_FOURCC( 'f', 'l', 'a', 'c' ) ) else if( p_stream->i_fourcc != VLC_FOURCC( 'f', 'l', 'a', 'c' ) )
...@@ -709,7 +705,7 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts ) ...@@ -709,7 +705,7 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
op.packetno = p_stream->i_packet_no++; op.packetno = p_stream->i_packet_no++;
ogg_stream_packetin( &p_stream->os, &op ); ogg_stream_packetin( &p_stream->os, &op );
p_og = OggStreamFlush( p_mux, &p_stream->os, 0 ); p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
sout_BufferChain( &p_hdr, p_og ); block_ChainAppend( &p_hdr, p_og );
} }
/* Special case for mp4v and flac */ /* Special case for mp4v and flac */
...@@ -734,23 +730,23 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts ) ...@@ -734,23 +730,23 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
op.packetno = p_stream->i_packet_no++; op.packetno = p_stream->i_packet_no++;
ogg_stream_packetin( &p_stream->os, &op ); ogg_stream_packetin( &p_stream->os, &op );
p_og = OggStreamFlush( p_mux, &p_stream->os, 0 ); p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
sout_BufferChain( &p_hdr, p_og ); block_ChainAppend( &p_hdr, p_og );
} }
} }
/* set HEADER flag */ /* set HEADER flag */
for( p_og = p_hdr; p_og != NULL; p_og = p_og->p_next ) for( p_og = p_hdr; p_og != NULL; p_og = p_og->p_next )
{ {
p_og->i_flags |= SOUT_BUFFER_FLAGS_HEADER; p_og->i_flags |= BLOCK_FLAG_HEADER;
} }
return( p_hdr ); return( p_hdr );
} }
static sout_buffer_t *OggCreateFooter( sout_mux_t *p_mux, mtime_t i_dts ) static block_t *OggCreateFooter( sout_mux_t *p_mux, mtime_t i_dts )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_hdr = NULL; block_t *p_hdr = NULL;
sout_buffer_t *p_og; block_t *p_og;
ogg_packet op; ogg_packet op;
int i; int i;
...@@ -786,7 +782,7 @@ static sout_buffer_t *OggCreateFooter( sout_mux_t *p_mux, mtime_t i_dts ) ...@@ -786,7 +782,7 @@ static sout_buffer_t *OggCreateFooter( sout_mux_t *p_mux, mtime_t i_dts )
ogg_stream_packetin( &p_stream->os, &op ); ogg_stream_packetin( &p_stream->os, &op );
p_og = OggStreamFlush( p_mux, &p_stream->os, 0 ); p_og = OggStreamFlush( p_mux, &p_stream->os, 0 );
sout_BufferChain( &p_hdr, p_og ); block_ChainAppend( &p_hdr, p_og );
ogg_stream_clear( &p_stream->os ); ogg_stream_clear( &p_stream->os );
} }
...@@ -801,17 +797,17 @@ static sout_buffer_t *OggCreateFooter( sout_mux_t *p_mux, mtime_t i_dts ) ...@@ -801,17 +797,17 @@ static sout_buffer_t *OggCreateFooter( sout_mux_t *p_mux, mtime_t i_dts )
ogg_stream_packetin( &p_sys->pp_del_streams[i]->os, &op ); ogg_stream_packetin( &p_sys->pp_del_streams[i]->os, &op );
p_og = OggStreamFlush( p_mux, &p_sys->pp_del_streams[i]->os, 0 ); p_og = OggStreamFlush( p_mux, &p_sys->pp_del_streams[i]->os, 0 );
sout_BufferChain( &p_hdr, p_og ); block_ChainAppend( &p_hdr, p_og );
ogg_stream_clear( &p_sys->pp_del_streams[i]->os ); ogg_stream_clear( &p_sys->pp_del_streams[i]->os );
} }
return( p_hdr ); return( p_hdr );
} }
static void OggSetDate( sout_buffer_t *p_og, mtime_t i_dts, mtime_t i_length ) static void OggSetDate( block_t *p_og, mtime_t i_dts, mtime_t i_length )
{ {
int i_count; int i_count;
sout_buffer_t *p_tmp; block_t *p_tmp;
mtime_t i_delta; mtime_t i_delta;
for( p_tmp = p_og, i_count = 0; p_tmp != NULL; p_tmp = p_tmp->p_next ) for( p_tmp = p_og, i_count = 0; p_tmp != NULL; p_tmp = p_tmp->p_next )
...@@ -835,7 +831,7 @@ static void OggSetDate( sout_buffer_t *p_og, mtime_t i_dts, mtime_t i_length ) ...@@ -835,7 +831,7 @@ static void OggSetDate( sout_buffer_t *p_og, mtime_t i_dts, mtime_t i_length )
static int Mux( sout_mux_t *p_mux ) static int Mux( sout_mux_t *p_mux )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_og = NULL; block_t *p_og = NULL;
int i_stream; int i_stream;
mtime_t i_dts; mtime_t i_dts;
...@@ -854,7 +850,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -854,7 +850,7 @@ static int Mux( sout_mux_t *p_mux )
int i; int i;
msg_Dbg( p_mux, "writing footer" ); msg_Dbg( p_mux, "writing footer" );
sout_BufferChain( &p_og, OggCreateFooter( p_mux, 0 ) ); block_ChainAppend( &p_og, OggCreateFooter( p_mux, 0 ) );
/* Remove deleted logical streams */ /* Remove deleted logical streams */
for( i = 0; i < p_sys->i_del_streams; i++ ) for( i = 0; i < p_sys->i_del_streams; i++ )
...@@ -870,7 +866,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -870,7 +866,7 @@ static int Mux( sout_mux_t *p_mux )
p_sys->i_streams = p_mux->i_nb_inputs; p_sys->i_streams = p_mux->i_nb_inputs;
p_sys->i_del_streams = 0; p_sys->i_del_streams = 0;
p_sys->i_add_streams = 0; p_sys->i_add_streams = 0;
sout_BufferChain( &p_og, OggCreateHeader( p_mux, i_dts ) ); block_ChainAppend( &p_og, OggCreateHeader( p_mux, i_dts ) );
/* Write header and/or footer */ /* Write header and/or footer */
OggSetDate( p_og, i_dts, 0 ); OggSetDate( p_og, i_dts, 0 );
...@@ -882,7 +878,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -882,7 +878,7 @@ static int Mux( sout_mux_t *p_mux )
{ {
sout_input_t *p_input; sout_input_t *p_input;
ogg_stream_t *p_stream; ogg_stream_t *p_stream;
sout_buffer_t *p_data; block_t *p_data;
ogg_packet op; ogg_packet op;
if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 ) if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
...@@ -892,19 +888,19 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -892,19 +888,19 @@ static int Mux( sout_mux_t *p_mux )
p_input = p_mux->pp_inputs[i_stream]; p_input = p_mux->pp_inputs[i_stream];
p_stream = (ogg_stream_t*)p_input->p_sys; p_stream = (ogg_stream_t*)p_input->p_sys;
p_data = sout_FifoGet( p_input->p_fifo ); p_data = block_FifoGet( p_input->p_fifo );
if( p_stream->i_fourcc != VLC_FOURCC( 'v', 'o', 'r', 'b' ) && if( p_stream->i_fourcc != VLC_FOURCC( 'v', 'o', 'r', 'b' ) &&
p_stream->i_fourcc != VLC_FOURCC( 'f', 'l', 'a', 'c' ) && p_stream->i_fourcc != VLC_FOURCC( 'f', 'l', 'a', 'c' ) &&
p_stream->i_fourcc != VLC_FOURCC( 's', 'p', 'x', ' ' ) && p_stream->i_fourcc != VLC_FOURCC( 's', 'p', 'x', ' ' ) &&
p_stream->i_fourcc != VLC_FOURCC( 't', 'h', 'e', 'o' ) ) p_stream->i_fourcc != VLC_FOURCC( 't', 'h', 'e', 'o' ) )
{ {
sout_BufferReallocFromPreHeader( p_mux->p_sout, p_data, 1 ); p_data = block_Realloc( p_data, 1, 0 );
p_data->p_buffer[0] = PACKET_IS_SYNCPOINT; // FIXME p_data->p_buffer[0] = PACKET_IS_SYNCPOINT; // FIXME
} }
op.packet = p_data->p_buffer; op.packet = p_data->p_buffer;
op.bytes = p_data->i_size; op.bytes = p_data->i_buffer;
op.b_o_s = 0; op.b_o_s = 0;
op.e_o_s = 0; op.e_o_s = 0;
op.packetno = p_stream->i_packet_no++; op.packetno = p_stream->i_packet_no++;
...@@ -952,12 +948,12 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -952,12 +948,12 @@ static int Mux( sout_mux_t *p_mux )
{ {
/* Subtitles or Speex packets are quite small so they /* Subtitles or Speex packets are quite small so they
* need to be flushed to be sent on time */ * need to be flushed to be sent on time */
sout_BufferChain( &p_og, OggStreamFlush( p_mux, &p_stream->os, block_ChainAppend( &p_og, OggStreamFlush( p_mux, &p_stream->os,
p_data->i_dts ) ); p_data->i_dts ) );
} }
else else
{ {
sout_BufferChain( &p_og, OggStreamPageOut( p_mux, &p_stream->os, block_ChainAppend( &p_og, OggStreamPageOut( p_mux, &p_stream->os,
p_data->i_dts ) ); p_data->i_dts ) );
} }
...@@ -980,8 +976,8 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -980,8 +976,8 @@ static int Mux( sout_mux_t *p_mux )
p_stream->i_length += p_data->i_length; p_stream->i_length += p_data->i_length;
} }
sout_BufferDelete( p_mux->p_sout, p_data ); block_Release( p_data );
} }
return( VLC_SUCCESS ); return VLC_SUCCESS;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment