/* Environment variable containing the memcpy method */
#define MEMCPY_METHOD_VAR "vlc_memcpy"
-/*
- * Decoders FIFO configuration
- */
-
-/* Size of the FIFO. FIFO_SIZE+1 must be a power of 2 */
-#define FIFO_SIZE 1023
-
/*
* Paths
*/
/*****************************************************************************
* input_ext-dec.h: structures exported to the VideoLAN decoders
*****************************************************************************
- * Copyright (C) 1999-2000 VideoLAN
- * $Id: input_ext-dec.h,v 1.46 2001/12/27 01:49:34 massiot Exp $
+ * Copyright (C) 1999-2001 VideoLAN
+ * $Id: input_ext-dec.h,v 1.47 2001/12/27 03:47:08 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr>
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ext-intf.h,v 1.53 2001/12/12 13:48:09 massiot Exp $
+ * $Id: input_ext-intf.h,v 1.54 2001/12/27 03:47:08 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
/*
* Communication input -> interface
*/
-#define INPUT_MAX_PLUGINS 1
/* FIXME ! */
#define REQUESTED_MPEG 1
#define REQUESTED_AC3 2
#define SPU_ES 0x02
#define NAV_ES 0x03
#define UNKNOWN_ES 0xFF
+
/*****************************************************************************
* pgrm_descriptor_t
*****************************************************************************
/* Read & Demultiplex */
int (* pf_read)( struct input_thread_s *,
- struct data_packet_s * pp_packets[] );
+ struct data_packet_s ** );
void (* pf_demux)( struct input_thread_s *,
struct data_packet_s * );
int i_handle; /* socket or file descriptor */
FILE * p_stream; /* if applicable */
void * p_handle; /* if i_handle isn't suitable */
- int i_read_once; /* number of packet read by
- * pf_read once */
void * p_method_data; /* data of the packet manager */
void * p_plugin_data; /* data of the plugin */
* but exported to plug-ins
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: input_ext-plugins.h,v 1.12 2001/12/27 01:49:34 massiot Exp $
+ * $Id: input_ext-plugins.h,v 1.13 2001/12/27 03:47:08 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
*/
/* FIXME: you've gotta move this move this, you've gotta move this move this */
-#define INPUT_READ_ONCE 7 /* We live in a world dominated by Ethernet. *
- * Ethernet MTU is 1500 bytes, so in a UDP *
- * packet we can put : 1500/188 = 7 TS *
- * packets. Have a nice day and merry Xmas. */
#define PADDING_PACKET_SIZE 188 /* Size of the NULL packet inserted in case
* of data loss (this should be < 188). */
#define PADDING_PACKET_NUMBER 10 /* Number of padding packets top insert to
vlc_mutex_t lock; \
PACKETS_LIFO( pes_packet_t, pes ) \
PACKETS_LIFO( data_packet_t, data ) \
- BUFFERS_LIFO( data_buffer_t, buffers[NB_LIFO] ) \
+ BUFFERS_LIFO( _data_buffer_t, buffers[NB_LIFO] ) \
size_t i_allocated; \
} input_buffers_t;
-typedef struct data_buffer_s
+typedef struct _data_buffer_s
{
int i_refcount;
unsigned int i_size;
- struct data_buffer_s * p_next;
- byte_t payload_start;
-} data_buffer_t;
+ struct _data_buffer_s * p_next;
+} _data_buffer_t;
/*****************************************************************************
\
for( i = 0; i < NB_LIFO; i++ ) \
{ \
- data_buffer_t * p_next; \
- data_buffer_t * p_buf = p_buffers->buffers[i].p_stack; \
+ _data_buffer_t * p_next; \
+ _data_buffer_t * p_buf = p_buffers->buffers[i].p_stack; \
BUFFERS_END_BUFFERS_LOOP; \
} \
BUFFERS_NEWPACKET_END )
#define DECLARE_BUFFERS_NEWPACKET_SHARED( FLAGS, NB_LIFO ) \
- BUFFERS_NEWPACKET( FLAGS, NB_LIFO, data_buffer_t, buffers, \
+ BUFFERS_NEWPACKET( FLAGS, NB_LIFO, _data_buffer_t, buffers, \
BUFFERS_NEWPACKET_EXTRA_DECLARATION_SHARED, \
BUFFERS_NEWPACKET_EXTRA_SHARED, BUFFERS_NEWPACKET_END_SHARED )
data_packet_t * p_buf = p_data;
#define BUFFERS_DELETEPACKET_EXTRA_SHARED( FLAGS, NB_LIFO, DATA_CACHE_SIZE )\
- data_buffer_t * p_buf = (data_buffer_t *)p_data->p_buffer; \
+ _data_buffer_t * p_buf = (_data_buffer_t *)p_data->p_buffer; \
\
/* Get rid of the data packet */ \
if( p_buffers->data.i_depth < DATA_CACHE_SIZE ) \
#define DECLARE_BUFFERS_DELETEPACKET_SHARED( FLAGS, NB_LIFO, \
DATA_CACHE_SIZE ) \
- BUFFERS_DELETEPACKET( FLAGS, NB_LIFO, DATA_CACHE_SIZE, data_buffer_t, \
+ BUFFERS_DELETEPACKET( FLAGS, NB_LIFO, DATA_CACHE_SIZE, _data_buffer_t, \
buffers, BUFFERS_DELETEPACKET_EXTRA_SHARED )
/*****************************************************************************
{ \
input_buffers_t * p_buffers = (input_buffers_t *)_p_buffers; \
data_packet_t * p_data; \
- data_buffer_t * p_buf = (data_buffer_t *)p_shared_data->p_buffer; \
+ _data_buffer_t * p_buf = (_data_buffer_t *)p_shared_data->p_buffer; \
\
vlc_mutex_lock( &p_buffers->lock ); \
\
/* Finish initialization of p_data */ \
p_data->p_buffer = p_shared_data->p_buffer; \
p_data->p_demux_start = p_data->p_payload_start \
- = p_shared_data->p_buffer + sizeof( data_buffer_t ); \
+ = p_shared_data->p_buffer + sizeof( _data_buffer_t ); \
p_data->p_payload_end = p_shared_data->p_buffer + p_buf->i_size; \
\
/* Update refcount */ \
* modules.h : Module management functions.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: modules.h,v 1.36 2001/12/09 17:01:35 sam Exp $
+ * $Id: modules.h,v 1.37 2001/12/27 03:47:08 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
void * );
int ( * pf_read ) ( struct input_thread_s *,
- struct data_packet_s *
- pp_packets[] );
+ struct data_packet_s ** );
void ( * pf_demux )( struct input_thread_s *,
struct data_packet_s * );
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: input_dvd.c,v 1.110 2001/12/27 01:49:34 massiot Exp $
+ * $Id: input_dvd.c,v 1.111 2001/12/27 03:47:08 massiot Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
/* how many blocks DVDRead will read in each loop */
#define DVD_BLOCK_READ_ONCE 64
-#define DVD_DATA_READ_ONCE (4 * DVD_BLOCK_READ_ONCE)
/*****************************************************************************
* Local prototypes
return;
}
- /* We read DVD_BLOCK_READ_ONCE in each loop, so the input will receive
- * DVD_DATA_READ_ONCE at most */
+ /* We read DVD_BLOCK_READ_ONCE in each loop */
p_dvd->i_block_once = DVD_BLOCK_READ_ONCE;
- /* this value mustn't be modifed */
- p_input->i_read_once = DVD_DATA_READ_ONCE;
/* Ifo allocation & initialisation */
if( IfoCreate( p_dvd ) < 0 )
/*****************************************************************************
* DVDRead: reads data packets into the netlist.
*****************************************************************************
- * Returns -1 in case of error, 0 if everything went well, and 1 in case of
- * EOF.
+ * Returns -1 in case of error, 0 in case of EOF, otherwise the number of
+ * packets.
*****************************************************************************/
static int DVDRead( input_thread_t * p_input,
- data_packet_t ** pp_packets )
+ data_packet_t ** pp_data )
{
thread_dvd_data_t * p_dvd;
- struct iovec p_vec[DVD_DATA_READ_ONCE];
+ struct iovec p_vec[DVD_BLOCK_READ_ONCE];
u8 * pi_cur;
int i_block_once;
int i_packet_size;
p_dvd = (thread_dvd_data_t *)p_input->p_plugin_data;
+ *pp_data = NULL;
+
b_eoc = 0;
i_sector = p_dvd->i_title_start + p_dvd->i_sector;
i_block_once = p_dvd->i_end_sector - p_dvd->i_sector + 1;
/* Find cell index in adress map */
if( DVDFindSector( p_dvd ) < 0 )
{
- pp_packets[0] = NULL;
intf_ErrMsg( "dvd error: can't find next cell" );
return 1;
}
*/
/* Get iovecs */
- p_data = input_BuffersToIO( p_input->p_method_data, p_vec,
- DVD_DATA_READ_ONCE );
+ *pp_data = p_data = input_BuffersToIO( p_input->p_method_data, p_vec,
+ DVD_BLOCK_READ_ONCE );
if ( p_data == NULL )
{
{
pi_cur = (u8*)p_vec[i_iovec].iov_base + i_pos;
- /*default header */
+ /* Default header */
if( U32_AT( pi_cur ) != 0x1BA )
{
/* That's the case for all packets, except pack header. */
if( i_pos != 0 )
{
- pp_packets[i_packet] = input_ShareBuffer(
- p_input->p_method_data, p_current );
+ *pp_data = input_ShareBuffer( p_input->p_method_data,
+ p_current );
}
else
{
- pp_packets[i_packet] = p_data;
+ *pp_data = p_data;
p_data = p_data->p_next;
}
- pp_packets[i_packet]->p_payload_start =
- pp_packets[i_packet]->p_demux_start =
- pp_packets[i_packet]->p_demux_start + i_pos;
+ (*pp_data)->p_payload_start = (*pp_data)->p_demux_start =
+ (*pp_data)->p_demux_start + i_pos;
- pp_packets[i_packet]->p_payload_end =
- pp_packets[i_packet]->p_payload_start + i_packet_size + 6;
+ (*pp_data)->p_payload_end =
+ (*pp_data)->p_payload_start + i_packet_size + 6;
i_packet++;
i_pos += i_packet_size + 6;
+ pp_data = &(*pp_data)->p_next;
}
}
- pp_packets[i_packet] = NULL;
-
p_input->pf_delete_packet( p_input->p_method_data, p_data );
+ if( i_packet != 0 )
+ {
+ (*pp_data)->p_next = NULL;
+ }
vlc_mutex_lock( &p_input->stream.stream_lock );
{
/* EOF */
vlc_mutex_unlock( &p_input->stream.stream_lock );
- return 1;
+ return 0;
}
/* EOT */
p_dvd->i_title++;
DVDSetArea( p_input, p_input->stream.pp_areas[p_dvd->i_title] );
vlc_mutex_unlock( &p_input->stream.stream_lock );
- return 0;
+ return( i_packet );
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
- if( i_read_blocks == i_block_once )
+ if( i_read_blocks != i_block_once )
{
- return 0;
+ return -1;
}
- return -1;
+ return( i_packet );
}
/*****************************************************************************
* input_es.c: Elementary Stream demux and packet management
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: input_es.c,v 1.7 2001/12/27 01:49:34 massiot Exp $
+ * $Id: input_es.c,v 1.8 2001/12/27 03:47:08 massiot Exp $
*
* Author: Christophe Massiot <massiot@via.ecp.fr>
*
* Local prototypes
*****************************************************************************/
static int ESProbe ( probedata_t * );
-static int ESRead ( struct input_thread_s *,
- data_packet_t * p_packets[INPUT_READ_ONCE] );
+static int ESRead ( struct input_thread_s *, data_packet_t ** );
static void ESInit ( struct input_thread_s * );
static void ESEnd ( struct input_thread_s * );
static void ESSeek ( struct input_thread_s *, off_t );
/*****************************************************************************
* ESRead: reads data packets
*****************************************************************************
- * Returns -1 in case of error, 0 if everything went well, and 1 in case of
- * EOF.
+ * Returns -1 in case of error, 0 in case of EOF, otherwise the number of
+ * packets.
*****************************************************************************/
static int ESRead( input_thread_t * p_input,
- data_packet_t * pp_packets[INPUT_READ_ONCE] )
+ data_packet_t ** pp_data )
{
- int i_read, i_loop;
- struct iovec p_iovec[INPUT_READ_ONCE];
+ int i_read;
+ struct iovec p_iovec[ES_READ_ONCE];
data_packet_t * p_data;
/* Get iovecs */
- p_data = input_BuffersToIO( p_input->p_method_data, p_iovec,
- INPUT_READ_ONCE );
+ *pp_data = p_data = input_BuffersToIO( p_input->p_method_data, p_iovec,
+ ES_READ_ONCE );
if ( p_data == NULL )
{
return( -1 );
}
- memset( pp_packets, 0, INPUT_READ_ONCE * sizeof(data_packet_t *) );
-
- i_read = readv( p_input->i_handle, p_iovec, INPUT_READ_ONCE );
+ i_read = readv( p_input->i_handle, p_iovec, ES_READ_ONCE );
if( i_read == -1 )
{
intf_ErrMsg( "input error: ES readv error" );
+ p_input->pf_delete_packet( p_input->p_method_data, p_data );
return( -1 );
}
+ p_input->stream.p_selected_area->i_tell += i_read;
+ i_read /= ES_PACKET_SIZE;
- for( i_loop = 0; i_loop * ES_PACKET_SIZE < i_read; i_loop++ )
- {
- pp_packets[i_loop] = p_data;
- p_data = p_data->p_next;
- pp_packets[i_loop]->p_next = NULL;
- }
- /* Delete remaining packets */
- input_DeletePacket( p_input->p_method_data, p_data );
- for( ; i_loop < INPUT_READ_ONCE ; i_loop++ )
+ if( i_read != ES_READ_ONCE )
{
- pp_packets[i_loop] = NULL;
- }
+ /* We got fewer packets than wanted. Give remaining packets
+ * back to the buffer allocator. */
+ int i_loop;
- /* EOF */
- if( i_read == 0 && p_input->stream.b_seekable )
- {
- return( 1 );
+ for( i_loop = 0; i_loop + 1 < i_read; i_loop++ )
+ {
+ p_data = p_data->p_next;
+ }
+ p_input->pf_delete_packet( p_input->p_method_data, p_data->p_next );
+ if( i_read != 0 )
+ {
+ p_data->p_next = NULL;
+ }
}
- p_input->stream.p_selected_area->i_tell += i_read;
-
- return( 0 );
+ return( i_read );
}
/*****************************************************************************
* input_es.h: thread structure of the ES plugin
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: input_es.h,v 1.2 2001/12/12 17:41:15 massiot Exp $
+ * $Id: input_es.h,v 1.3 2001/12/27 03:47:09 massiot Exp $
*
- * Authors:
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*****************************************************************************/
#define ES_PACKET_SIZE 2048
-#define MAX_PACKETS_IN_FIFO 14
+#define ES_READ_ONCE 50
+#define MAX_PACKETS_IN_FIFO 50
* input_ps.c: PS demux and packet management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: input_ps.c,v 1.7 2001/12/27 01:49:34 massiot Exp $
+ * $Id: input_ps.c,v 1.8 2001/12/27 03:47:09 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
* Local prototypes
*****************************************************************************/
static int PSProbe ( probedata_t * );
-static int PSRead ( struct input_thread_s *,
- data_packet_t * p_packets[INPUT_READ_ONCE] );
+static int PSRead ( struct input_thread_s *, data_packet_t ** );
static void PSInit ( struct input_thread_s * );
static void PSEnd ( struct input_thread_s * );
static int PSSetProgram ( struct input_thread_s * , pgrm_descriptor_t * );
while( !p_input->b_die && !p_input->b_error
&& !p_demux_data->b_has_PSM )
{
- int i_result, i;
- data_packet_t * pp_packets[INPUT_READ_ONCE];
+ int i_result;
+ data_packet_t * p_data;
+ data_packet_t * p_saved_data;
- i_result = PSRead( p_input, pp_packets );
+ i_result = PSRead( p_input, &p_data );
+ p_saved_data = p_data;
- if( i_result == 1 )
+ while( p_data != NULL )
+ {
+ input_ParsePS( p_input, p_data );
+ p_data = p_data->p_next;
+ }
+
+ p_input->pf_delete_packet( p_input->p_method_data, p_saved_data );
+
+ if( i_result == 0 )
{
/* EOF */
vlc_mutex_lock( &p_input->stream.stream_lock );
break;
}
- for( i = 0; i < INPUT_READ_ONCE && pp_packets[i] != NULL; i++ )
- {
- /* FIXME: use i_p_config_t */
- input_ParsePS( p_input, pp_packets[i] );
- p_input->pf_delete_packet( p_input->p_method_data, pp_packets[i] );
- }
-
/* File too big. */
if( p_input->stream.p_selected_area->i_tell >
INPUT_PREPARSE_LENGTH )
{
if( feof( p_input->p_stream ) )
{
- return( 1 );
+ return( 0 );
}
if( (i_error = ferror( p_input->p_stream )) )
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.p_selected_area->i_tell += i_len;
vlc_mutex_unlock( &p_input->stream.stream_lock );
- return( 0 );
+ return( i_len );
}
/*****************************************************************************
* PSRead: reads data packets
*****************************************************************************
- * Returns -1 in case of error, 0 if everything went well, and 1 in case of
- * EOF.
+ * Returns -1 in case of error, 0 in case of EOF, otherwise the number of
+ * packets.
*****************************************************************************/
static int PSRead( input_thread_t * p_input,
- data_packet_t * pp_packets[INPUT_READ_ONCE] )
+ data_packet_t ** pp_data )
{
byte_t p_header[6];
data_packet_t * p_data;
size_t i_packet_size;
int i_packet, i_error;
- memset( pp_packets, 0, INPUT_READ_ONCE * sizeof(data_packet_t *) );
- for( i_packet = 0; i_packet < INPUT_READ_ONCE; i_packet++ )
+ *pp_data = NULL;
+
+ for( i_packet = 0; i_packet < PS_READ_ONCE; i_packet++ )
{
/* Read what we believe to be a packet header. */
- if( (i_error = SafeRead( p_input, p_header, 4 )) )
+ if( (i_error = SafeRead( p_input, p_header, 4 )) <= 0 )
{
return( i_error );
}
}
else
{
- return( 1 );
+ return( 0 );
}
}
/* Packet found. */
if( U32_AT(p_header) != 0x1B9 )
{
/* The packet is at least 6 bytes long. */
- if( (i_error = SafeRead( p_input, p_header + 4, 2 )) )
+ if( (i_error = SafeRead( p_input, p_header + 4, 2 )) <= 0 )
{
return( i_error );
}
/* Read the remaining of the packet. */
if( i_packet_size && (i_error =
- SafeRead( p_input, p_data->p_demux_start + 6, i_packet_size )) )
+ SafeRead( p_input, p_data->p_demux_start + 6,
+ i_packet_size )) <= 0 )
{
+ p_input->pf_delete_packet( p_input->p_method_data, p_data );
return( i_error );
}
/* MPEG-2 stuffing bytes */
byte_t p_garbage[8];
if( (i_error = SafeRead( p_input, p_garbage,
- p_data->p_demux_start[13] & 0x7)) )
+ p_data->p_demux_start[13] & 0x7)) <= 0 )
{
+ p_input->pf_delete_packet( p_input->p_method_data,
+ p_data );
return( i_error );
}
}
}
/* Give the packet to the other input stages. */
- pp_packets[i_packet] = p_data;
+ *pp_data = p_data;
+ pp_data = &p_data->p_next;
}
- return( 0 );
+ return( i_packet + 1 );
}
/*****************************************************************************
* input_ps.h: thread structure of the PS plugin
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ps.h,v 1.1 2001/12/09 17:01:36 sam Exp $
+ * $Id: input_ps.h,v 1.2 2001/12/27 03:47:09 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#define DATA_CACHE_SIZE 150
-#define PES_CACHE_SIZE 150
-#define SMALL_CACHE_SIZE 150
-#define LARGE_CACHE_SIZE 150
-#define MAX_SMALL_SIZE 50 // frontier between small and large packets
-
-typedef struct
-{
- data_packet_t ** p_stack;
- long l_index;
-} data_packet_cache_t;
-
-
-typedef struct
-{
- pes_packet_t ** p_stack;
- long l_index;
-} pes_packet_cache_t;
-
-
-typedef struct
-{
- byte_t * p_data;
- long l_size;
-} packet_buffer_t;
-
-
-typedef struct
-{
- packet_buffer_t * p_stack;
- long l_index;
-} small_buffer_cache_t;
-
-
-typedef struct
-{
- packet_buffer_t * p_stack;
- long l_index;
-} large_buffer_cache_t;
-
-
-typedef struct
-{
- vlc_mutex_t lock;
- data_packet_cache_t data;
- pes_packet_cache_t pes;
- small_buffer_cache_t smallbuffer;
- large_buffer_cache_t largebuffer;
-} packet_cache_t;
-
-
+#define PS_READ_ONCE 50
* input_ts.c: TS demux and netlist management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: input_ts.c,v 1.6 2001/12/27 01:49:34 massiot Exp $
+ * $Id: input_ts.c,v 1.7 2001/12/27 03:47:09 massiot Exp $
*
* Authors: Henri Fallon <henri@videolan.org>
*
static int TSProbe ( probedata_t * );
static void TSInit ( struct input_thread_s * );
static void TSEnd ( struct input_thread_s * );
-static int TSRead ( struct input_thread_s *,
- data_packet_t * p_packets[INPUT_READ_ONCE] );
+static int TSRead ( struct input_thread_s *, data_packet_t ** );
/*****************************************************************************
* Declare a buffer manager
/*****************************************************************************
* TSRead: reads data packets
*****************************************************************************
- * Returns -1 in case of error, 0 if everything went well, and 1 in case of
- * EOF.
+ * Returns -1 in case of error, 0 in case of EOF, otherwise the number of
+ * packets.
*****************************************************************************/
static int TSRead( input_thread_t * p_input,
- data_packet_t * pp_packets[INPUT_READ_ONCE] )
+ data_packet_t ** pp_data )
{
thread_ts_data_t * p_method;
- unsigned int i_loop;
- int i_read;
+ int i_read = 0, i_loop;
int i_data = 1;
- struct iovec p_iovec[INPUT_READ_ONCE];
+ struct iovec p_iovec[TS_READ_ONCE];
data_packet_t * p_data;
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 500000;
- /* Reset pointer table */
- memset( pp_packets, 0, INPUT_READ_ONCE * sizeof(data_packet_t *) );
-
/* Fill if some data is available */
#if defined( WIN32 )
if ( ! p_input->stream.b_pace_control )
if( i_data )
{
/* Get iovecs */
- p_data = input_BuffersToIO( p_input->p_method_data, p_iovec,
- INPUT_READ_ONCE );
+ *pp_data = p_data = input_BuffersToIO( p_input->p_method_data, p_iovec,
+ TS_READ_ONCE );
if ( p_data == NULL )
{
#if defined( WIN32 )
if( p_input->stream.b_pace_control )
{
- i_read = readv( p_input->i_handle, p_iovec, INPUT_READ_ONCE );
+ i_read = readv( p_input->i_handle, p_iovec, TS_READ_ONCE );
}
else
{
i_read = readv_network( p_input->i_handle, p_iovec,
- INPUT_READ_ONCE, p_method );
+ TS_READ_ONCE, p_method );
}
#else
- i_read = readv( p_input->i_handle, p_iovec, INPUT_READ_ONCE );
+ i_read = readv( p_input->i_handle, p_iovec, TS_READ_ONCE );
/* Shouldn't happen, but it does - at least under Linux */
if( (i_read == -1) && ( (errno == EAGAIN) || (errno = EWOULDBLOCK) ) )
i_read = 0;
}
#endif
- /* check correct TS header */
- for( i_loop=0; i_loop * TS_PACKET_SIZE < i_read; i_loop++ )
- {
- pp_packets[i_loop] = p_data;
- p_data = p_data->p_next;
- pp_packets[i_loop]->p_next = NULL;
-
- if( pp_packets[i_loop]->p_demux_start[0] != 0x47 )
- intf_ErrMsg( "input error: bad TS packet (starts with "
- "0x%.2x, should be 0x47)",
- pp_packets[i_loop]->p_demux_start[0] );
- }
- /* Delete remaining packets */
- input_DeletePacket( p_input->p_method_data, p_data );
- for( ; i_loop < INPUT_READ_ONCE ; i_loop++ )
- {
- pp_packets[i_loop] = NULL;
- }
-
/* Error */
if( i_read == -1 )
{
intf_ErrMsg( "input error: TS readv error" );
+ p_input->pf_delete_packet( p_input->p_method_data, p_data );
return( -1 );
}
+ p_input->stream.p_selected_area->i_tell += i_read;
+ i_read /= TS_PACKET_SIZE;
- /* EOF */
- if( i_read == 0 && p_input->stream.b_seekable )
+ /* Check correct TS header */
+ for( i_loop = 0; i_loop + 1 < i_read; i_loop++ )
{
- return( 1 );
+ if( p_data->p_demux_start[0] != 0x47 )
+ {
+ intf_ErrMsg( "input error: bad TS packet (starts with "
+ "0x%.2x, should be 0x47)",
+ p_data->p_demux_start[0] );
+ }
+ p_data = p_data->p_next;
}
+ /* Last packet */
+ if( p_data->p_demux_start[0] != 0x47 )
+ {
+ intf_ErrMsg( "input error: bad TS packet (starts with "
+ "0x%.2x, should be 0x47)",
+ p_data->p_demux_start[0] );
+ }
- p_input->stream.p_selected_area->i_tell += i_read;
+ if( i_read != TS_READ_ONCE )
+ {
+ /* Delete remaining packets */
+ p_input->pf_delete_packet( p_input->p_method_data, p_data->p_next );
+ if( i_read != 0 )
+ {
+ p_data->p_next = NULL;
+ }
+ }
}
- return 0;
+ return( i_read );
}
* input_ts.h: structures of the input not exported to other modules
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ts.h,v 1.3 2001/12/12 17:41:15 massiot Exp $
+ * $Id: input_ts.h,v 1.4 2001/12/27 03:47:09 massiot Exp $
*
* Authors: Henri Fallon <henri@via.ecp.fr>
* Boris Dorès <babal@via.ecp.fr>
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#define BUFFER_SIZE (7 * TS_PACKET_SIZE)
+/* UDP packets contain 1500 bytes, that is 7 TS packets */
+#define TS_READ_ONCE 7
+
+#ifdef WIN32
+# define BUFFER_SIZE (7 * TS_PACKET_SIZE)
+#endif
/*****************************************************************************
* thread_ts_data_t: private input data
intf_ErrMsg( "vcd error: could not read TOC" );
}
- p_input->i_read_once = VCD_DATA_ONCE;
-
/* Set stream and area data */
vlc_mutex_lock( &p_input->stream.stream_lock );
/*****************************************************************************
* VCDRead: reads from the VCD into PES packets.
*****************************************************************************
- * Returns -1 in case of error, 0 if everything went well, and 1 in case of
- * EOF.
+ * Returns -1 in case of error, 0 in case of EOF, otherwise the number of
+ * packets.
*****************************************************************************/
-static int VCDRead( input_thread_t * p_input, data_packet_t ** pp_packets )
+static int VCDRead( input_thread_t * p_input, data_packet_t ** pp_data )
{
thread_vcd_data_t * p_vcd;
data_packet_t * p_data;
p_vcd = (thread_vcd_data_t *)p_input->p_plugin_data;
i_packet = 0;
+ *pp_data = NULL;
while( i_packet < VCD_DATA_ONCE
&& !p_vcd->b_end_of_track )
break;
}
-#ifdef DEBUG
intf_DbgMsg("i_index : %d\n", i_index);
intf_DbgMsg("i_packet_size : %d\n", i_packet_size);
-#endif
if ( i_index + i_packet_size > BUFFER_SIZE )
{
}
/* Give the packet to the other input stages. */
- pp_packets[i_packet] = p_data;
- i_packet++;
+ *pp_data = p_data;
+ pp_data = &p_data->p_next;
}
}
- pp_packets[i_packet] = NULL;
-
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.p_selected_area->i_tell =
if( p_vcd->i_track >= p_vcd->nb_tracks - 1 )
{
vlc_mutex_unlock( &p_input->stream.stream_lock );
- return 1;
+ return 0;
}
intf_WarnMsg( 4, "vcd info: new title" );
vlc_mutex_unlock( &p_input->stream.stream_lock );
- return 0;
+ return( i_packet + 1 );
}
/*****************************************************************************
* decoders.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: input.c,v 1.165 2001/12/12 02:13:50 sam Exp $
+ * $Id: input.c,v 1.166 2001/12/27 03:47:09 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
return( NULL );
}
- /* Packets read once */
- p_input->i_read_once = INPUT_READ_ONCE;
-
/* Initialize thread properties */
p_input->b_die = 0;
p_input->b_error = 0;
*****************************************************************************/
static void RunThread( input_thread_t *p_input )
{
- int i_error, i;
- data_packet_t ** pp_packets;
-
if( InitThread( p_input ) )
{
/* If we failed, wait before we are killed, and exit */
return;
}
- /* initialization is completed */
+ /* initialization is complete */
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.b_changed = 1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
- pp_packets = (data_packet_t **) malloc( p_input->i_read_once *
- sizeof( data_packet_t * ) );
- if( pp_packets == NULL )
- {
- intf_ErrMsg( "input error: out of memory" );
- free( pp_packets );
- p_input->b_error = 1;
- }
-
while( !p_input->b_die && !p_input->b_error && !p_input->b_eof )
{
+ data_packet_t * p_data;
+ int i_count, i;
+
p_input->c_loops++;
vlc_mutex_lock( &p_input->stream.stream_lock );
vlc_mutex_unlock( &p_input->stream.stream_lock );
- i_error = p_input->pf_read( p_input, pp_packets );
+ i_count = p_input->pf_read( p_input, &p_data );
/* Demultiplex read packets. */
- for( i = 0; i < p_input->i_read_once && pp_packets[i] != NULL; i++ )
+ while( p_data != NULL )
{
+ data_packet_t * p_next = p_data->p_next;
+ p_data->p_next = NULL;
+
p_input->stream.c_packets_read++;
- p_input->pf_demux( p_input, pp_packets[i] );
+ p_input->pf_demux( p_input, p_data );
+
+ p_data = p_next;
}
- if( i_error )
+ if( i_count == 0 && p_input->stream.b_seekable )
{
- if( i_error == 1 )
- {
- /* End of file - we do not set b_die because only the
- * interface is allowed to do so. */
- intf_WarnMsg( 3, "input: EOF reached" );
- p_input->b_eof = 1;
- }
- else
- {
- p_input->b_error = 1;
- }
+ /* End of file - we do not set b_die because only the
+ * interface is allowed to do so. */
+ intf_WarnMsg( 3, "input: EOF reached" );
+ p_input->b_eof = 1;
+ }
+ else if( i_count < 0 )
+ {
+ p_input->b_error = 1;
}
}
- free( pp_packets );
-
if( p_input->b_error || p_input->b_eof )
{
ErrorThread( p_input );