Commit 231d0470 authored by Gildas Bazin's avatar Gildas Bazin

* include/vlc_common.h: include stdlib.h
* include/ninput.h, src/input/stream.c, src/input/input.c:
    new stream_Block() function to read a block_t from the input.
    es_out_Send() takes a block_t as input, for PES (deprecated) use es_out_SendPES().
* modules/demux/*: changed to new es_out_Send(). asf.c and avi.c still use es_out_SendPES() though.
parent 571f69ba
......@@ -2,7 +2,7 @@
* ninput.h
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ninput.h,v 1.17 2003/11/20 22:10:55 fenrir Exp $
* $Id: ninput.h,v 1.18 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -35,7 +35,8 @@ enum es_out_query_e
struct es_out_t
{
es_out_id_t *(*pf_add) ( es_out_t *, es_format_t * );
int (*pf_send) ( es_out_t *, es_out_id_t *, pes_packet_t * );
int (*pf_send) ( es_out_t *, es_out_id_t *, block_t * );
int (*pf_send_pes)( es_out_t *, es_out_id_t *, pes_packet_t * );
void (*pf_del) ( es_out_t *, es_out_id_t * );
int (*pf_control)( es_out_t *, int i_query, va_list );
......@@ -50,9 +51,15 @@ static inline void es_out_Del( es_out_t *out, es_out_id_t *id )
{
out->pf_del( out, id );
}
static inline int es_out_Send( es_out_t *out, es_out_id_t *id, pes_packet_t *p_pes )
static inline int es_out_Send( es_out_t *out, es_out_id_t *id,
block_t *p_block )
{
return out->pf_send( out, id, p_pes );
return out->pf_send( out, id, p_block );
}
static inline int es_out_SendPES( es_out_t *out, es_out_id_t *id,
pes_packet_t *p_pes )
{
return out->pf_send_pes( out, id, p_pes );
}
static inline int es_out_vaControl( es_out_t *out, int i_query, va_list args )
{
......@@ -101,6 +108,7 @@ VLC_EXPORT( int, stream_Read, ( stream_t *, void *p_read,
VLC_EXPORT( int, stream_Peek, ( stream_t *, uint8_t **pp_peek, int i_peek ) );
VLC_EXPORT( data_packet_t *,stream_DataPacket, ( stream_t *, int i_size, vlc_bool_t b_force ) );
VLC_EXPORT( pes_packet_t *, stream_PesPacket, ( stream_t *, int i_size ) );
VLC_EXPORT( block_t *, stream_Block, ( stream_t *, int i_size ) );
static int64_t inline stream_Tell( stream_t *s )
{
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.86 2003/11/16 21:07:30 gbazin Exp $
* $Id: vlc_common.h,v 1.87 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -51,6 +51,7 @@
/*****************************************************************************
* Required system headers
*****************************************************************************/
#include <stdlib.h>
#include <stdarg.h>
#ifdef HAVE_STRING_H
......
......@@ -2,7 +2,7 @@
* a52.c : Raw a52 Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: a52sys.c,v 1.9 2003/11/16 21:07:31 gbazin Exp $
* $Id: a52sys.c,v 1.10 2003/11/21 00:38:00 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -177,7 +177,7 @@ error:
static int Demux( input_thread_t * p_input )
{
demux_sys_t *p_sys = p_input->p_demux_data;
pes_packet_t *p_pes;
block_t *p_block;
int i_channels, i_sample_rate, i_frame_size;
......@@ -227,18 +227,18 @@ static int Demux( input_thread_t * p_input )
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
if( ( p_pes = stream_PesPacket( p_input->s, i_frame_size ) ) == NULL )
if( ( p_block = stream_Block( p_input->s, i_frame_size ) ) == NULL )
{
msg_Warn( p_input, "cannot read data" );
return 0;
}
p_pes->i_dts =
p_pes->i_pts = input_ClockGetTS( p_input,
p_block->i_dts =
p_block->i_pts = input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes );
es_out_Send( p_input->p_es_out, p_sys->p_es, p_block );
p_sys->i_time += (mtime_t)1000000 *
(mtime_t)1536 /
......
......@@ -2,7 +2,7 @@
* aac.c : Raw aac Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: aac.c,v 1.7 2003/11/16 21:07:31 gbazin Exp $
* $Id: aac.c,v 1.8 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -194,7 +194,7 @@ error:
static int Demux( input_thread_t * p_input )
{
demux_sys_t *p_sys = p_input->p_demux_data;
pes_packet_t *p_pes;
block_t *p_block;
uint8_t h[8];
uint8_t *p_peek;
......@@ -243,18 +243,18 @@ static int Demux( input_thread_t * p_input )
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
if( ( p_pes = stream_PesPacket( p_input->s, AAC_FRAME_SIZE( h ) ) )==NULL )
if( ( p_block = stream_Block( p_input->s, AAC_FRAME_SIZE( h ) ) ) == NULL )
{
msg_Warn( p_input, "cannot read data" );
return 0;
}
p_pes->i_dts =
p_pes->i_pts = input_ClockGetTS( p_input,
p_block->i_dts =
p_block->i_pts = input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes );
es_out_Send( p_input->p_es_out, p_sys->p_es, p_block );
p_sys->i_time += (mtime_t)1000000 *
(mtime_t)AAC_FRAME_SAMPLES( h ) /
......
......@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
* $Id: asf.c,v 1.43 2003/11/20 22:10:56 fenrir Exp $
* $Id: asf.c,v 1.44 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -716,7 +716,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
/* send complete packet to decoder */
if( p_stream->p_pes->i_pes_size > 0 )
{
es_out_Send( p_input->p_es_out, p_stream->p_es, p_stream->p_pes );
es_out_SendPES( p_input->p_es_out, p_stream->p_es, p_stream->p_pes );
p_stream->p_pes = NULL;
}
}
......
......@@ -2,7 +2,7 @@
* au.c : au file input module for vlc
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: au.c,v 1.10 2003/11/16 22:54:12 gbazin Exp $
* $Id: au.c,v 1.11 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -325,7 +325,7 @@ error:
static int DemuxPCM( input_thread_t *p_input )
{
demux_sys_t *p_sys = p_input->p_demux_data;
pes_packet_t *p_pes;
block_t *p_block;
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
{
......@@ -345,17 +345,17 @@ static int DemuxPCM( input_thread_t *p_input )
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
if( ( p_pes = stream_PesPacket( p_input->s, p_sys->i_frame_size ) )==NULL )
if( ( p_block = stream_Block( p_input->s, p_sys->i_frame_size ) ) == NULL )
{
msg_Warn( p_input, "cannot read data" );
return 0;
}
p_pes->i_dts =
p_pes->i_pts = input_ClockGetTS( p_input,
p_block->i_dts =
p_block->i_pts = input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes );
es_out_Send( p_input->p_es_out, p_sys->p_es, p_block );
p_sys->i_time += p_sys->i_frame_length;
......
......@@ -2,7 +2,7 @@
* avi.c : AVI file Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: avi.c,v 1.71 2003/11/20 22:10:56 fenrir Exp $
* $Id: avi.c,v 1.72 2003/11/21 00:38:01 gbazin Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -776,7 +776,7 @@ static int Demux_Seekable( input_thread_t *p_input )
p_pes->i_rate = p_input->stream.control.i_rate;
if( b_play_audio || tk->i_cat != AUDIO_ES )
{
es_out_Send( p_input->p_es_out, tk->p_es, p_pes );
es_out_SendPES( p_input->p_es_out, tk->p_es, p_pes );
}
else
{
......@@ -902,7 +902,7 @@ static int Demux_UnSeekable( input_thread_t *p_input )
AVI_GetPTS( p_stream ) * 9/100);
p_pes->i_rate = p_input->stream.control.i_rate;
es_out_Send( p_input->p_es_out, p_stream->p_es, p_pes );
es_out_SendPES( p_input->p_es_out, p_stream->p_es, p_pes );
}
else
{
......
......@@ -2,7 +2,7 @@
* live.cpp : live.com support.
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: livedotcom.cpp,v 1.9 2003/11/20 23:13:28 sigmunau Exp $
* $Id: livedotcom.cpp,v 1.10 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -854,10 +854,9 @@ static void StreamRead( void *p_private, unsigned int i_size, struct timeval pts
live_track_t *tk = (live_track_t*)p_private;
input_thread_t *p_input = tk->p_input;
demux_sys_t *p_sys = p_input->p_demux_data;
pes_packet_t *p_pes;
data_packet_t *p_data;
block_t *p_block;
mtime_t i_pts = (mtime_t)pts.tv_sec * 1000000LL + (mtime_t)pts.tv_usec;
mtime_t i_pts = (mtime_t)pts.tv_sec * 1000000LL + (mtime_t)pts.tv_usec;
if( tk->b_quicktime && tk->p_es == NULL )
{
......@@ -888,41 +887,31 @@ static void StreamRead( void *p_private, unsigned int i_size, struct timeval pts
i_size,
pts.tv_sec * 1000000LL + pts.tv_usec );
#endif
/* Create a PES */
if( ( p_pes = input_NewPES( p_input->p_method_data ) ) == NULL )
{
return;
}
if( i_size > 65536 )
{
msg_Warn( p_input, "buffer overflow" );
}
/* FIXME could i_size be > buffer size ? */
p_data = input_NewPacket( p_input->p_method_data, i_size );
memcpy( p_data->p_payload_start, tk->buffer, i_size );
p_data->p_payload_end = p_data->p_payload_start + i_size;
p_block = block_New( p_input, i_size );
p_pes->p_first = p_pes->p_last = p_data;
p_pes->i_nb_data = 1;
p_pes->i_pes_size = i_size;
p_pes->i_rate = p_input->stream.control.i_rate;
memcpy( p_block->p_buffer, tk->buffer, i_size );
//p_block->i_rate = p_input->stream.control.i_rate;
if( i_pts != tk->i_pts )
{
p_pes->i_dts =
p_pes->i_pts = input_ClockGetTS( p_input,
p_block->i_dts =
p_block->i_pts = input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
i_pts * 9 / 100 );
}
else
{
p_pes->i_dts = 0;
p_pes->i_pts = 0;
p_block->i_dts = 0;
p_block->i_pts = 0;
}
//fprintf( stderr, "tk -> dpts=%lld\n", i_pts - tk->i_pts );
es_out_Send( p_input->p_es_out, tk->p_es, p_pes );
es_out_Send( p_input->p_es_out, tk->p_es, p_block );
/* warm that's ok */
p_sys->event = 0xff;
......
......@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mkv.cpp,v 1.42 2003/11/20 22:10:55 fenrir Exp $
* $Id: mkv.cpp,v 1.43 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -1369,27 +1369,13 @@ static int BlockGet( input_thread_t *p_input, KaxBlock **pp_block, int64_t *pi_r
}
}
static pes_packet_t *MemToPES( input_thread_t *p_input, uint8_t *p_mem, int i_mem )
static block_t *MemToBlock( input_thread_t *p_input, uint8_t *p_mem, int i_mem)
{
pes_packet_t *p_pes;
data_packet_t *p_data;
if( ( p_pes = input_NewPES( p_input->p_method_data ) ) == NULL )
{
return NULL;
}
p_data = input_NewPacket( p_input->p_method_data, i_mem);
memcpy( p_data->p_payload_start, p_mem, i_mem );
p_data->p_payload_end = p_data->p_payload_start + i_mem;
p_pes->p_first = p_pes->p_last = p_data;
p_pes->i_nb_data = 1;
p_pes->i_pes_size = i_mem;
p_pes->i_rate = p_input->stream.control.i_rate;
return p_pes;
block_t *p_block;
if( !(p_block = block_New( p_input, i_mem ) ) ) return NULL;
memcpy( p_block->p_buffer, p_mem, i_mem );
//p_block->i_rate = p_input->stream.control.i_rate;
return p_block;
}
static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts, mtime_t i_duration )
......@@ -1430,7 +1416,7 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
/* First send init data */
if( !tk.b_inited && tk.i_data_init > 0 )
{
pes_packet_t *p_init;
block_t *p_init;
msg_Dbg( p_input, "sending header (%d bytes)", tk.i_data_init );
......@@ -1462,17 +1448,17 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
i_size[1] = __MIN( i_size[1], tk.i_data_init - i_offset - i_size[0] );
i_size[2] = tk.i_data_init - i_offset - i_size[0] - i_size[1];
p_init = MemToPES( p_input, &tk.p_data_init[i_offset], i_size[0] );
p_init = MemToBlock( p_input, &tk.p_data_init[i_offset], i_size[0] );
if( p_init )
{
es_out_Send( p_input->p_es_out, tk.p_es, p_init );
}
p_init = MemToPES( p_input, &tk.p_data_init[i_offset+i_size[0]], i_size[1] );
p_init = MemToBlock( p_input, &tk.p_data_init[i_offset+i_size[0]], i_size[1] );
if( p_init )
{
es_out_Send( p_input->p_es_out, tk.p_es, p_init );
}
p_init = MemToPES( p_input, &tk.p_data_init[i_offset+i_size[0]+i_size[1]], i_size[2] );
p_init = MemToBlock( p_input, &tk.p_data_init[i_offset+i_size[0]+i_size[1]], i_size[2] );
if( p_init )
{
es_out_Send( p_input->p_es_out, tk.p_es, p_init );
......@@ -1480,7 +1466,7 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
}
else
{
p_init = MemToPES( p_input, tk.p_data_init, tk.i_data_init );
p_init = MemToBlock( p_input, tk.p_data_init, tk.i_data_init );
if( p_init )
{
es_out_Send( p_input->p_es_out, tk.p_es, p_init );
......@@ -1492,35 +1478,35 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
for( i = 0; i < block->NumberFrames(); i++ )
{
pes_packet_t *p_pes;
block_t *p_block;
DataBuffer &data = block->GetBuffer(i);
p_pes = MemToPES( p_input, data.Buffer(), data.Size() );
if( p_pes == NULL )
p_block = MemToBlock( p_input, data.Buffer(), data.Size() );
if( p_block == NULL )
{
break;
}
p_pes->i_pts = i_pts;
p_pes->i_dts = i_pts;
p_block->i_pts = i_pts;
p_block->i_dts = i_pts;
if( tk.fmt.i_cat == SPU_ES && strcmp( tk.psz_codec, "S_VOBSUB" ) )
{
if( i_duration > 0 )
{
p_pes->i_dts += i_duration * 1000;
p_block->i_dts += i_duration * 1000;
}
else
{
p_pes->i_dts = 0;
p_block->i_dts = 0;
}
if( p_pes->p_first && p_pes->i_pes_size > 0 )
if( p_block->i_buffer > 0 )
{
p_pes->p_first->p_payload_end[0] = '\0';
p_block->p_buffer[p_block->i_buffer-1] = '\0';
}
}
es_out_Send( p_input->p_es_out, tk.p_es, p_pes );
es_out_Send( p_input->p_es_out, tk.p_es, p_block );
/* use time stamp only for first block */
i_pts = 0;
......
......@@ -2,7 +2,7 @@
* sub.c
*****************************************************************************
* Copyright (C) 1999-2003 VideoLAN
* $Id: sub.c,v 1.37 2003/11/20 22:10:56 fenrir Exp $
* $Id: sub.c,v 1.38 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -518,9 +518,7 @@ static int sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate )
while( p_sub->i_subtitle < p_sub->i_subtitles &&
p_sub->subtitle[p_sub->i_subtitle].i_start < i_maxdate )
{
pes_packet_t *p_pes;
data_packet_t *p_data;
block_t *p_block;
int i_len;
i_len = strlen( p_sub->subtitle[p_sub->i_subtitle].psz_text ) + 1;
......@@ -531,22 +529,14 @@ static int sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate )
p_sub->i_subtitle++;
continue;
}
if( !( p_pes = input_NewPES( p_sub->p_input->p_method_data ) ) )
{
p_sub->i_subtitle++;
continue;
}
if( !( p_data = input_NewPacket( p_sub->p_input->p_method_data,
i_len ) ) )
if( !( p_block = block_New( p_sub->p_input, i_len ) ) )
{
input_DeletePES( p_sub->p_input->p_method_data, p_pes );
p_sub->i_subtitle++;
continue;
}
p_data->p_payload_end = p_data->p_payload_start + i_len;
p_pes->i_pts =
p_block->i_pts =
input_ClockGetTS( p_sub->p_input,
p_sub->p_input->stream.p_selected_program,
p_sub->subtitle[p_sub->i_subtitle].i_start*9/100);
......@@ -555,32 +545,26 @@ static int sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate )
/* FIXME kludge ...
* i_dts means end of display...
*/
p_pes->i_dts =
p_block->i_dts =
input_ClockGetTS( p_sub->p_input,
p_sub->p_input->stream.p_selected_program,
p_sub->subtitle[p_sub->i_subtitle].i_stop *9/100);
}
else
{
p_pes->i_dts = 0;
p_block->i_dts = 0;
}
p_pes->i_nb_data = 1;
p_pes->p_first =
p_pes->p_last = p_data;
p_pes->i_pes_size = i_len;
memcpy( p_data->p_payload_start,
p_sub->subtitle[p_sub->i_subtitle].psz_text,
i_len );
memcpy( p_block->p_buffer,
p_sub->subtitle[p_sub->i_subtitle].psz_text, i_len );
if( p_pes->i_pts > 0 )
if( p_block->i_pts > 0 )
{
es_out_Send( p_input->p_es_out, p_sub->p_es, p_pes );
es_out_Send( p_input->p_es_out, p_sub->p_es, p_block );
}
else
{
input_DeletePES( p_sub->p_input->p_method_data, p_pes );
block_Release( p_block );
}
p_sub->i_subtitle++;
......
......@@ -2,7 +2,7 @@
* wav.c : wav file input module for vlc
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: wav.c,v 1.10 2003/11/16 22:54:12 gbazin Exp $
* $Id: wav.c,v 1.11 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -230,7 +230,7 @@ static int Demux( input_thread_t *p_input )
{
demux_sys_t *p_sys = p_input->p_demux_data;
int64_t i_pos;
pes_packet_t *p_pes;
block_t *p_block;
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
{
......@@ -258,17 +258,17 @@ static int Demux( input_thread_t *p_input )
return 0;
}
if( ( p_pes = stream_PesPacket( p_input->s, p_sys->i_frame_size ) )==NULL )
if( ( p_block = stream_Block( p_input->s, p_sys->i_frame_size ) ) == NULL )
{
msg_Warn( p_input, "cannot read data" );
return 0;
}
p_pes->i_dts =
p_pes->i_pts = input_ClockGetTS( p_input,
p_block->i_dts =
p_block->i_pts = input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 );
es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes );
es_out_Send( p_input->p_es_out, p_sys->p_es, p_block );
p_sys->i_time += p_sys->i_frame_length;
......
......@@ -4,7 +4,7 @@
* decoders.
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: input.c,v 1.257 2003/11/20 22:10:56 fenrir Exp $
* $Id: input.c,v 1.258 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -988,7 +988,8 @@ struct es_out_id_t
};
static es_out_id_t *EsOutAdd ( es_out_t *, es_format_t * );
static int EsOutSend ( es_out_t *, es_out_id_t *, pes_packet_t * );
static int EsOutSend ( es_out_t *, es_out_id_t *, block_t * );
static int EsOutSendPES( es_out_t *, es_out_id_t *, pes_packet_t * );
static void EsOutDel ( es_out_t *, es_out_id_t * );
static int EsOutControl( es_out_t *, int i_query, va_list );
......@@ -998,6 +999,7 @@ static es_out_t *EsOutCreate( input_thread_t *p_input )
out->pf_add = EsOutAdd;
out->pf_send = EsOutSend;
out->pf_send_pes= EsOutSendPES;
out->pf_del = EsOutDel;
out->pf_control = EsOutControl;
......@@ -1216,7 +1218,42 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt )
return id;
}
static int EsOutSend( es_out_t *out, es_out_id_t *id, pes_packet_t *p_pes )
static int EsOutSend( es_out_t *out, es_out_id_t *id, block_t *p_block )
{
if( id->p_es->p_decoder_fifo )
{
pes_packet_t *p_pes;
if( !(p_pes = input_NewPES( out->p_sys->p_input->p_method_data ) ) )
{
return VLC_SUCCESS;
}
p_pes->p_first = p_pes->p_last =
input_NewPacket( out->p_sys->p_input->p_method_data,
p_block->i_buffer );
p_pes->i_nb_data = 1;
p_pes->i_pts = p_block->i_pts;
p_pes->i_dts = p_block->i_dts;
p_pes->p_first->p_payload_end =
p_pes->p_first->p_payload_start + p_block->i_buffer;
memcpy( p_pes->p_first->p_payload_start,
p_block->p_buffer, p_block->i_buffer );
block_Release( p_block );
input_DecodePES( id->p_es->p_decoder_fifo, p_pes );
}
else
{
block_Release( p_block );
}
return VLC_SUCCESS;
}
static int EsOutSendPES( es_out_t *out, es_out_id_t *id, pes_packet_t *p_pes )
{
if( id->p_es->p_decoder_fifo )
{
......
......@@ -2,7 +2,7 @@
* stream.c
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: stream.c,v 1.6 2003/10/08 21:01:07 gbazin Exp $
* $Id: stream.c,v 1.7 2003/11/21 00:38:01 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -265,6 +265,28 @@ int stream_Peek( stream_t *s, uint8_t **pp_peek, int i_data )
return input_Peek( s->p_input, pp_peek, i_data );
}
/**
* Read "i_size" bytes and store them in a block_t. If less than "i_size"
* bytes are available then return what is left and if nothing is availble,
* return NULL.
*/
block_t *stream_Block( stream_t *s, int i_size )
{
block_t *p_block;
if( i_size <= 0 ) return NULL;
if( !(p_block = block_New( s->p_input, i_size ) ) ) return NULL;
p_block->i_buffer = stream_Read( s, p_block->p_buffer, i_size );
if( !p_block->i_buffer )
{
block_Release( p_block );
p_block = NULL;
}
return p_block;
}
/**
* Read "i_size" bytes and store them in a pes_packet_t. Only fields
* p_first, p_last, i_nb_data, and i_pes_size are set. (Of course,
......
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