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

* mux: sout_buffer_t -> block_t.

parent 8547ffaa
......@@ -2,7 +2,7 @@
* asf.c
*****************************************************************************
* 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>
*
......@@ -92,7 +92,7 @@ struct sout_mux_sys_t
vlc_bool_t b_write_header;
sout_buffer_t *pk;
block_t *pk;
int i_pk_used;
int i_pk_frame;
mtime_t i_pk_dts;
......@@ -110,10 +110,10 @@ struct sout_mux_sys_t
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 sout_buffer_t *asf_packet_create( sout_mux_t *,
asf_track_t *, sout_buffer_t * );
static sout_buffer_t *asf_stream_end_create( sout_mux_t *);
static block_t *asf_header_create( sout_mux_t *, vlc_bool_t b_broadcast );
static block_t *asf_packet_create( sout_mux_t *,
asf_track_t *, block_t * );
static block_t *asf_stream_end_create( sout_mux_t *);
typedef struct
{
......@@ -215,7 +215,7 @@ static void Close( vlc_object_t * p_this )
{
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *out;
block_t *out;
int i;
msg_Dbg( p_mux, "Asf muxer closed" );
......@@ -499,9 +499,9 @@ static int Mux ( sout_mux_t *p_mux )
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 );
p_sys->b_write_header = VLC_FALSE;
......@@ -513,8 +513,8 @@ static int Mux ( sout_mux_t *p_mux )
asf_track_t *tk;
int i_stream;
mtime_t i_dts;
sout_buffer_t *data;
sout_buffer_t *pk;
block_t *data;
block_t *pk;
if( MuxGetStream( p_mux, &i_stream, &i_dts ) )
{
......@@ -534,7 +534,7 @@ static int Mux ( sout_mux_t *p_mux )
p_input = p_mux->pp_inputs[i_stream];
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 ) ) )
{
......@@ -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++ )
{
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 )
{
......@@ -571,7 +571,7 @@ static int MuxGetStream( sout_mux_t *p_mux,
continue;
}
p_data = sout_FifoShow( p_input->p_fifo );
p_data = block_FifoShow( p_input->p_fifo );
if( i_stream == -1 ||
p_data->i_dts < i_dts )
{
......@@ -790,7 +790,7 @@ static void asf_chunk_add( bo_t *bo,
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 )
{
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,
int i_size;
int i_ci_size;
int i_cd_size = 0;
sout_buffer_t *out;
block_t *out;
bo_t bo;
int i;
......@@ -843,13 +843,13 @@ static sout_buffer_t *asf_header_create( sout_mux_t *p_mux,
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 );
asf_chunk_add( &bo, 0x4824, i_size + 50, 0xc00, p_sys->i_seq++ );
}
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 );
}
/* header object */
......@@ -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,
asf_track_t *tk, sout_buffer_t *data )
static block_t *asf_packet_create( sout_mux_t *p_mux,
asf_track_t *tk, block_t *data )
{
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;
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;
while( i_pos < i_data )
......@@ -983,8 +983,8 @@ static sout_buffer_t *asf_packet_create( sout_mux_t *p_mux,
if( p_sys->pk == NULL )
{
p_sys->pk = sout_BufferNew( p_mux->p_sout,
p_sys->i_packet_size + i_preheader);
p_sys->pk = block_New( p_mux,
p_sys->i_packet_size + i_preheader);
/* reserve 14 bytes for the packet header */
p_sys->i_pk_used = 14 + i_preheader;
p_sys->i_pk_frame = 0;
......@@ -1043,21 +1043,21 @@ static sout_buffer_t *asf_packet_create( sout_mux_t *p_mux,
}
tk->i_sequence++;
sout_BufferDelete( p_mux->p_sout, data );
block_Release( data );
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_buffer_t *out = NULL;
block_t *out = NULL;
bo_t bo;
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 );
asf_chunk_add( &bo, 0x4524, 0, 0x00, p_sys->i_seq++ );
}
......
......@@ -2,7 +2,7 @@
* avi.c
*****************************************************************************
* 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>
*
......@@ -119,8 +119,8 @@ struct sout_mux_sys_t
#define AVIIF_KEYFRAME 0x00000010L /* this frame is a key frame.*/
static sout_buffer_t *avi_HeaderCreateRIFF( sout_mux_t * );
static sout_buffer_t *avi_HeaderCreateidx1( sout_mux_t * );
static block_t *avi_HeaderCreateRIFF( sout_mux_t * );
static block_t *avi_HeaderCreateidx1( sout_mux_t * );
static void SetFCC( uint8_t *p, char *fcc )
{
......@@ -154,7 +154,6 @@ static int Open( vlc_object_t *p_this )
p_mux->pf_delstream = DelStream;
p_mux->pf_mux = Mux;
p_mux->p_sys = p_sys;
p_mux->i_preheader = 8; /* (fourcc,length) header */
return VLC_SUCCESS;
}
......@@ -167,14 +166,14 @@ static void Close( vlc_object_t * p_this )
sout_mux_t *p_mux = (sout_mux_t*)p_this;
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;
msg_Dbg( p_mux, "AVI muxer closed" );
/* first create idx1 chunk (write at the end of the stream */
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 );
/* calculate some value for headers creations */
......@@ -388,7 +387,7 @@ static int Mux ( sout_mux_t *p_mux )
if( p_sys->b_write_header )
{
sout_buffer_t *p_hdr;
block_t *p_hdr;
msg_Dbg( p_mux, "writing header" );
......@@ -401,7 +400,7 @@ static int Mux ( sout_mux_t *p_mux )
for( i = 0; i < p_mux->i_nb_inputs; i++ )
{
int i_count;
sout_fifo_t *p_fifo;
block_fifo_t *p_fifo;
i_stream = *((int*)p_mux->pp_inputs[i]->p_sys );
p_stream = &p_sys->stream[i_stream];
......@@ -411,27 +410,32 @@ static int Mux ( sout_mux_t *p_mux )
while( i_count > 0 )
{
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++;
if( p_data->i_length < 0 )
{
msg_Warn( p_mux, "argg length < 0 l" );
sout_BufferDelete( p_mux->p_sout, p_data );
block_Release( p_data );
i_count--;
continue;
}
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 */
p_idx = &p_sys->idx1.entry[p_sys->idx1.i_entry_count];
memcpy( p_idx->fcc, p_stream->fcc, 4 );
p_idx->i_flags = AVIIF_KEYFRAME;
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++;
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 )
p_sys->idx1.i_entry_max * sizeof( avi_idx1_entry_t ) );
}
if( sout_BufferReallocFromPreHeader( p_mux->p_sout, p_data, 8 ) )
{
/* 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
p_data = block_Realloc( p_data, 8, 0 );
if( p_data )
{
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 )
{
sout_BufferRealloc( p_mux->p_sout, p_data, p_data->i_size + 1 );
p_data->i_size += 1;
}
if( p_data->i_buffer & 0x01 )
{
p_data = block_Realloc( p_data, 0, p_data->i_buffer + 1 );
}
p_sys->i_movi_size += p_data->i_size;
sout_AccessOutWrite( p_mux->p_access, p_data );
p_sys->i_movi_size += p_data->i_buffer;
sout_AccessOutWrite( p_mux->p_access, p_data );
}
i_count--;
}
......@@ -774,16 +764,16 @@ static int avi_HeaderAdd_strl( sout_mux_t *p_mux,
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_buffer_t *p_hdr;
block_t *p_hdr;
int i_stream;
int i_maxbytespersec;
int i_junk;
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 );
bo_Init( &bo, HDR_SIZE, p_hdr->p_buffer );
......@@ -814,17 +804,17 @@ static sout_buffer_t *avi_HeaderCreateRIFF( sout_mux_t *p_mux )
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_buffer_t *p_idx1;
block_t *p_idx1;
uint32_t i_idx1_size;
unsigned int i;
buffer_out_t bo;
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 );
bo_Init( &bo, i_idx1_size, p_idx1->p_buffer );
......
......@@ -2,7 +2,7 @@
* dummy.c: dummy muxer module for vlc
*****************************************************************************
* 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>
* Eric Petit <titer@videolan.org>
......@@ -28,10 +28,8 @@
#include <stdlib.h>
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/sout.h>
#include "codecs.h"
/*****************************************************************************
* Module descriptor
......@@ -130,22 +128,18 @@ static int Mux( sout_mux_t *p_mux )
for( i = 0; i < p_mux->i_nb_inputs; i++ )
{
block_fifo_t *p_fifo;
int i_count;
sout_fifo_t *p_fifo;
if( p_sys->b_header && p_mux->pp_inputs[i]->p_fmt->i_extra )
{
/* Write header data */
sout_buffer_t *p_data;
p_data = sout_BufferNew( p_mux->p_sout,
p_mux->pp_inputs[i]->p_fmt->i_extra );
block_t *p_data;
p_data = block_New( p_mux, p_mux->pp_inputs[i]->p_fmt->i_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_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" );
sout_AccessOutWrite( p_mux->p_access, p_data );
}
......@@ -154,15 +148,12 @@ static int Mux( sout_mux_t *p_mux )
i_count = p_fifo->i_depth;
while( i_count > 0 )
{
sout_buffer_t *p_data;
p_data = sout_FifoGet( p_fifo );
block_t *p_data = block_FifoGet( p_fifo );
sout_AccessOutWrite( p_mux->p_access, p_data );
i_count--;
}
}
p_sys->b_header = VLC_FALSE;
......
......@@ -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 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 );
......@@ -217,7 +217,7 @@ static void Close( vlc_object_t * p_this )
{
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_hdr;
block_t *p_hdr;
bo_t bo, *moov;
vlc_value_t val;
......@@ -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
* 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;
int i_moov_size = moov->i_buffer;
while( i_size > 0 )
{
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,
p_sys->i_mdat_pos + i_size - 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 )
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;
sout_buffer_t *p_buf;
block_fifo_t *p_fifo = p_mux->pp_inputs[i]->p_fifo;
block_t *p_buf;
if( p_fifo->i_depth <= 1 )
{
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 )
{
i_dts = p_buf->i_dts;
......@@ -458,7 +458,7 @@ static int Mux( sout_mux_t *p_mux )
sout_input_t *p_input;
int i_stream;
mp4_stream_t *p_stream;
sout_buffer_t *p_data;
block_t *p_data;
mtime_t i_dts;
if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
......@@ -469,10 +469,10 @@ static int Mux( sout_mux_t *p_mux )
p_input = p_mux->pp_inputs[i_stream];
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 )
{
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;
if( i_diff < I64C(1000000 ) ) /* protection */
......@@ -509,7 +509,7 @@ static int Mux( sout_mux_t *p_mux )
/* 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_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=
__MAX( p_data->i_pts - p_data->i_dts, 0 );
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 )
/* update */
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 */
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 )
stss = NULL;
for( i = 0, i_index = 0; i < p_stream->i_entry_count; i++ )
{
if( p_stream->entry[i].i_flags &
(BLOCK_FLAG_TYPE_I << SOUT_BUFFER_FLAGS_BLOCK_SHIFT) )
if( p_stream->entry[i].i_flags & BLOCK_FLAG_TYPE_I )
{
if( stss == NULL )
{
......@@ -1704,24 +1703,22 @@ static void box_gather ( bo_t *box, bo_t *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 )
{
memcpy( p_buf->p_buffer, box->p_buffer, box->i_buffer );
}
p_buf->i_size = box->i_buffer;
return p_buf;
}
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 );
box_free( box );
......
......@@ -2,7 +2,7 @@
* pes.c: PES packetizer used by the MPEG multiplexers
*****************************************************************************
* 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>
* 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,
}
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 )
{
sout_buffer_t *p_es_sav, *p_pes;
block_t *p_es_sav, *p_pes;
mtime_t i_pts, i_dts, i_length;
uint8_t *p_data;
......@@ -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_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;
*pp_pes = p_pes = NULL;
......@@ -274,12 +274,7 @@ int E_( EStoPES )( sout_instance_t *p_sout,
if( p_es )
{
if( sout_BufferReallocFromPreHeader( p_sout, p_es, i_pes_header ) )
{
msg_Err( p_sout,
"cannot realloc preheader (should never happen)" );
return( -1 );
}
p_es = block_Realloc( p_es, i_pes_header, 0 );
/* reuse p_es for first frame */
*pp_pes = p_pes = p_es;
/* 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,
}
else
{
p_pes->p_next = sout_BufferNew( p_sout,
i_pes_header + i_pes_payload );
p_pes->p_next = block_New( p_sout, i_pes_header + i_pes_payload );
p_pes = p_pes->p_next;
p_pes->i_dts = 0;
......@@ -307,16 +301,10 @@ int E_( EStoPES )( sout_instance_t *p_sout,
i_size -= 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 );
/* 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 */
i_dts = (*pp_pes)->i_dts;
i_length = (*pp_pes)->i_length / i_pes_count;
......
......@@ -2,7 +2,7 @@
* pes.h
*****************************************************************************
* 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>
* Eric Petit <titer@videolan.org>
......@@ -35,5 +35,5 @@
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 );
......@@ -3,7 +3,7 @@
* multiplexer module for vlc
*****************************************************************************
* 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>
* Eric Petit <titer@videolan.org>
......@@ -72,8 +72,8 @@ static int Mux ( sout_mux_t * );
*****************************************************************************/
static int MuxGetStream ( sout_mux_t *, int *, mtime_t * );
static void MuxWritePackHeader ( sout_mux_t *, sout_buffer_t **, mtime_t );
static void MuxWriteSystemHeader( sout_mux_t *, sout_buffer_t ** );
static void MuxWritePackHeader ( sout_mux_t *, block_t **, mtime_t );
static void MuxWriteSystemHeader( sout_mux_t *, block_t ** );
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 );
......@@ -120,7 +120,6 @@ static int Open( vlc_object_t *p_this )
p_mux->pf_addstream = AddStream;
p_mux->pf_delstream = DelStream;
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 ) );
/* Init free stream id */
......@@ -149,11 +148,11 @@ static void Close( vlc_object_t * p_this )
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys;
sout_buffer_t *p_end;
block_t *p_end;
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[1] = 0x00;
p_end->p_buffer[2] = 0x01;
......@@ -297,7 +296,7 @@ static int Mux( sout_mux_t *p_mux )
sout_input_t *p_input;
ps_stream_t *p_stream;
sout_buffer_t *p_ps, *p_data;
block_t *p_ps, *p_data;
mtime_t i_dts;
int i_stream;
......@@ -320,25 +319,25 @@ static int Mux( sout_mux_t *p_mux )
/* Write regulary SystemHeader */
if( p_sys->i_pes_count % 300 == 0 )
{
sout_buffer_t *p_pk;
block_t *p_pk;
MuxWriteSystemHeader( p_mux, &p_ps );
/* For MPEG1 streaming, set HEADER flag */
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 */
p_data = sout_FifoGet( p_input->p_fifo );
p_data = block_FifoGet( p_input->p_fifo );
E_( EStoPES )( p_mux->p_sout,
&p_data, p_data,
p_stream->i_stream_id,
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 );
/* Increase counter */
......@@ -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;
}
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 )
{
sout_buffer_t *p_hdr;
block_t *p_hdr;
bits_buffer_t bits;
mtime_t i_src;
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_write( &bits, 32, 0x01ba );
......@@ -426,15 +425,15 @@ static void MuxWritePackHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf,
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_buffer_t *p_hdr;
block_t *p_hdr;
bits_buffer_t bits;
vlc_bool_t b_private;
int i_nb_private, i_nb_stream;
......@@ -456,7 +455,7 @@ static void MuxWriteSystemHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf )
/* Private stream are declared only one time */
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_write( &bits, 32, 0x01bb );
......@@ -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,
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_buffer_t *p_data;
block_t *p_data;
if( p_input->p_fifo->i_depth <= 0 )
{
......@@ -551,7 +550,7 @@ static int MuxGetStream( sout_mux_t *p_mux,
continue;
}
p_data = sout_FifoShow( p_input->p_fifo );
p_data = block_FifoShow( p_input->p_fifo );
if( i_stream == -1 ||
p_data->i_dts < i_dts )
{
......
This diff is collapsed.
This diff is collapsed.
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