Commit d0bf23fa authored by Christophe Massiot's avatar Christophe Massiot

Input III (Episode 1).

- Major rewrite of the buffer core functions
- Modularity of access plugins (file, udp, http)
- Modularity of network stack (ipv4, soon ipv6)
- Autodetection of the type of stream

And a new killing feature : HTTP streams are now seekable.

Please note that dvd, dvdread and vcd plug-ins are broken and thus disabled.
parent eba980c2
......@@ -15,6 +15,7 @@ endif
#
PLUGINS_DIR := ac3_adec \
ac3_spdif \
access \
alsa \
arts \
beos \
......@@ -57,6 +58,9 @@ PLUGINS_DIR := ac3_adec \
PLUGINS_TARGETS := ac3_adec/ac3_adec \
ac3_spdif/ac3_spdif \
access/file \
access/udp \
access/http \
alsa/alsa \
arts/arts \
beos/beos \
......@@ -119,6 +123,7 @@ PLUGINS_TARGETS := ac3_adec/ac3_adec \
mpeg_system/mpeg_ts \
mpeg_adec/mpeg_adec \
mpeg_vdec/mpeg_vdec \
network/ipv4 \
qnx/qnx \
qt/qt \
sdl/sdl \
......@@ -136,7 +141,7 @@ PLUGINS_TARGETS := ac3_adec/ac3_adec \
# C Objects
#
INTERFACE := main interface intf_msg intf_playlist intf_eject
INPUT := input input_ext-dec input_ext-intf input_dec input_programs input_clock mpeg_system
INPUT := input input_ext-plugins input_ext-dec input_ext-intf input_dec input_programs input_clock mpeg_system
VIDEO_OUTPUT := video_output video_text vout_pictures vout_subpictures
AUDIO_OUTPUT := audio_output aout_ext-dec aout_pcm aout_spdif
MISC := mtime modules configuration netutils iso_lang
......
This diff is collapsed.
......@@ -443,7 +443,7 @@ esac
dnl
dnl default modules
dnl
BUILTINS="${BUILTINS} mpeg_es mpeg_ps mpeg_ts memcpy idct idctclassic motion imdct downmix chroma_i420_rgb chroma_i420_yuy2 chroma_i422_yuy2 chroma_i420_ymga mpeg_adec ac3_adec mpeg_vdec"
BUILTINS="${BUILTINS} mpeg_es mpeg_ps mpeg_ts file udp http ipv4 memcpy idct idctclassic motion imdct downmix chroma_i420_rgb chroma_i420_yuy2 chroma_i422_yuy2 chroma_i420_ymga mpeg_adec ac3_adec mpeg_vdec"
PLUGINS="${PLUGINS} lpcm_adec ac3_spdif spudec filter_deinterlace filter_invert filter_wall filter_transform filter_distort fx_scope"
dnl
......@@ -788,7 +788,7 @@ AC_ARG_WITH(dvdcss,
[ case "x${withval}" in
xlocal-static|xyes)
# local libdvdcss, statically linked
BUILTINS="${BUILTINS} dvd"
#BUILTINS="${BUILTINS} dvd"
if test x${CAN_BUILD_LIBDVDCSS} = x1
then
NEED_LIBDVDCSS=1
......@@ -799,7 +799,7 @@ AC_ARG_WITH(dvdcss,
;;
xlocal-shared)
# local libdvdcss, dynamically linked
PLUGINS="${PLUGINS} dvd"
#PLUGINS="${PLUGINS} dvd"
if test x${CAN_BUILD_LIBDVDCSS} = x1
then
NEED_LIBDVDCSS=1
......@@ -809,7 +809,7 @@ AC_ARG_WITH(dvdcss,
;;
xno)
# don't use libdvdcss at all, build a DVD module that can dlopen() it
BUILTINS="${BUILTINS} dvd"
#BUILTINS="${BUILTINS} dvd"
DUMMY_LIBDVDCSS=1
SRC_DVD_EXTRA="${SRC_DVD_EXTRA} dummy_dvdcss.c"
CFLAGS_DVD="${CFLAGS_DVD} -DGOD_DAMN_DMCA"
......@@ -818,7 +818,7 @@ AC_ARG_WITH(dvdcss,
;;
*)
# existing libdvdcss
PLUGINS="${PLUGINS} dvd"
#PLUGINS="${PLUGINS} dvd"
if test "x$withval" != "xyes"
then
LIB_DVD="${LIB_DVD} -L"$withval"/lib"
......@@ -830,14 +830,14 @@ AC_ARG_WITH(dvdcss,
# if libdvdcss is in the archive, or to use the dummy replacement otherwise.
[ if test x${CAN_BUILD_LIBDVDCSS} = x1
then
BUILTINS="${BUILTINS} dvd"
#BUILTINS="${BUILTINS} dvd"
NEED_LIBDVDCSS=1
STATIC_LIBDVDCSS=1
CFLAGS_DVD="${CFLAGS_DVD} -I../../extras/libdvdcss"
LIB_DVD="${LIB_DVD} lib/libdvdcss.a ${LIB_LIBDVDCSS}"
else
# XXX: no check for libdl is done, don't try this at home !
BUILTINS="${BUILTINS} dvd"
#BUILTINS="${BUILTINS} dvd"
DUMMY_LIBDVDCSS=1
SRC_DVD_EXTRA="${SRC_DVD_EXTRA} dummy_dvdcss.c"
CFLAGS_DVD="${CFLAGS_DVD} -DGOD_DAMN_DMCA"
......@@ -868,11 +868,11 @@ AC_ARG_WITH(dvdread,
x)
if test x${STATIC_LIBDVDREAD} = x1
then
BUILTINS="${BUILTINS} dvdread"
#BUILTINS="${BUILTINS} dvdread"
CFLAGS_DVDREAD="${CFLAGS_DVDREAD} ${CFLAGS_DVD} -I../../extras/libdvdread"
LIB_DVDREAD="${LIB_DVDREAD} lib/libdvdread.a ${LIB_DVD}"
else
PLUGINS="${PLUGINS} dvdread"
#PLUGINS="${PLUGINS} dvdread"
CFLAGS_DVDREAD="${CFLAGS_DVDREAD} -I../../extras/libdvdread ${CFLAGS_DVD}"
LIB_DVDREAD="${LIB_DVDREAD} -Llib -ldvdread ${LIB_DVD}"
fi
......@@ -890,7 +890,7 @@ AC_ARG_WITH(dvdread,
then
AC_MSG_ERROR([Can't link shared dvdread with static dvdcss])
else
PLUGINS="${PLUGINS} dvdread"
#PLUGINS="${PLUGINS} dvdread"
CFLAGS_DVDREAD="${CFLAGS_DVDREAD} ${CFLAGS_DVD}"
LIB_DVDREAD="${LIB_DVDREAD} -ldvdread ${LIB_DVD}"
fi
......@@ -911,18 +911,19 @@ AC_ARG_ENABLE(vcd,
if test x$enable_vcd != xno
then
AC_EGREP_HEADER(cdrom_msf0,linux/cdrom.h,[
BUILTINS="${BUILTINS} vcd"
#BUILTINS="${BUILTINS} vcd"
])
fi
if test x$enable_vcd != xno -a "${SYS}" = "bsdi"
then
BUILTINS="${BUILTINS} vcd"
#BUILTINS="${BUILTINS} vcd"
true #delete me
fi
if test x$enable_vcd != xno -a "${SYS}" = "darwin"
then
BUILTINS="${BUILTINS} vcd"
#BUILTINS="${BUILTINS} vcd"
LIB_VCD="${LIB_VCD} -framework IOKit"
fi
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.79 2002/02/27 03:47:56 sam Exp $
* $Id: common.h,v 1.80 2002/03/01 00:33:17 massiot Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -171,6 +171,8 @@ struct pgrm_descriptor_s;
struct pes_packet_s;
struct input_area_s;
struct bit_stream_s;
struct input_buffers_s;
struct network_socket_s;
struct intf_subscription_s;
/*****************************************************************************
......@@ -537,10 +539,31 @@ typedef struct module_symbols_s
struct data_packet_s *,
struct es_descriptor_s *,
boolean_t, boolean_t );
int ( * input_ClockManageControl ) ( struct input_thread_s *,
struct pgrm_descriptor_s *,
mtime_t );
void ( * input_FDSeek ) ( struct input_thread_s *, off_t );
void ( * input_FDClose ) ( struct input_thread_s * );
ssize_t ( * input_FDRead ) ( struct input_thread_s *, byte_t *,
size_t );
ssize_t ( * input_FDNetworkRead ) ( struct input_thread_s *, byte_t *,
size_t );
void * ( * input_BuffersInit )( void );
void ( * input_BuffersEnd )( struct input_buffers_s * );
struct data_buffer_s * ( * input_NewBuffer )( struct input_buffers_s *, size_t );
void ( * input_ReleaseBuffer )( struct input_buffers_s *, struct data_buffer_s * );
struct data_packet_s * ( * input_ShareBuffer )( struct input_buffers_s *,
struct data_buffer_s * );
struct data_packet_s * ( * input_NewPacket )( struct input_buffers_s *, size_t );
void ( * input_DeletePacket )( struct input_buffers_s *, struct data_packet_s * );
struct pes_packet_s * ( * input_NewPES )( struct input_buffers_s * );
void ( * input_DeletePES )( struct input_buffers_s *, struct pes_packet_s * );
ssize_t ( * input_FillBuffer )( struct input_thread_s * );
ssize_t ( * input_Peek )( struct input_thread_s *, byte_t **, size_t );
ssize_t ( * input_SplitBuffer )( struct input_thread_s *, struct data_packet_s **, size_t );
int ( * input_AccessInit )( struct input_thread_s * );
void ( * input_AccessReinit )( struct input_thread_s * );
void ( * input_AccessEnd )( struct input_thread_s * );
struct aout_fifo_s * ( * aout_CreateFifo ) ( int, int, int, int, void * );
void ( * aout_DestroyFifo ) ( struct aout_fifo_s * );
......
......@@ -2,7 +2,7 @@
* input_ext-dec.h: structures exported to the VideoLAN decoders
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: input_ext-dec.h,v 1.52 2002/01/21 23:57:46 massiot Exp $
* $Id: input_ext-dec.h,v 1.53 2002/03/01 00:33:17 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr>
......@@ -40,25 +40,21 @@
*****************************************************************************
* Describe a data packet.
*****************************************************************************/
#define DATA_PACKET \
/* start of the PS or TS packet */ \
byte_t * p_demux_start; \
/* start of the PES payload in this packet */ \
byte_t * p_payload_start; \
byte_t * p_payload_end; /* guess ? :-) */ \
/* is the packet messed up ? */ \
boolean_t b_discard_payload;
typedef struct data_packet_s
{
/* Used to chain the packets that carry data for a same PES or PSI */
struct data_packet_s * p_next;
DATA_PACKET
/* start of the PS or TS packet */
byte_t * p_demux_start;
/* start of the PES payload in this packet */
byte_t * p_payload_start;
byte_t * p_payload_end; /* guess ? :-) */
/* is the packet messed up ? */
boolean_t b_discard_payload;
/* Please note that at least one buffer allocator (in particular, the
* Next Generation Buffer Allocator) extends this structure with
* private data after DATA_PACKET. */
/* pointer to the real data */
struct data_buffer_s * p_buffer;
} data_packet_t;
/*****************************************************************************
......@@ -113,10 +109,8 @@ typedef struct decoder_fifo_s
/* Communication interface between input and decoders */
boolean_t b_die; /* the decoder should return now */
boolean_t b_error; /* the decoder is in an error loop */
void * p_packets_mgt; /* packets management services
* data (netlist...) */
void (* pf_delete_pes)( void *, pes_packet_t * );
/* function to use when releasing a PES */
struct input_buffers_s *p_packets_mgt; /* packets management services
* data */
} decoder_fifo_t;
/*****************************************************************************
......
......@@ -4,7 +4,7 @@
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.60 2002/02/24 21:36:20 jobi Exp $
* $Id: input_ext-intf.h,v 1.61 2002/03/01 00:33:17 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -261,49 +261,45 @@ typedef struct input_thread_s
vlc_thread_t thread_id; /* id for thread functions */
int i_status; /* status flag */
/* Input module */
struct module_s * p_input_module;
/* Init/End */
int (* pf_probe)( struct input_thread_s * );
void (* pf_init)( struct input_thread_s * );
void (* pf_open)( struct input_thread_s * );
/* Access module */
struct module_s * p_access_module;
int (* pf_open)( struct input_thread_s * );
void (* pf_close)( struct input_thread_s * );
void (* pf_end)( struct input_thread_s * );
/* Read & Demultiplex */
int (* pf_read)( struct input_thread_s *,
struct data_packet_s ** );
void (* pf_demux)( struct input_thread_s *,
struct data_packet_s * );
/* Packet management facilities */
struct data_packet_s *(*pf_new_packet)( void *, size_t );
struct pes_packet_s *(* pf_new_pes)( void * );
void (* pf_delete_packet)( void *,
struct data_packet_s * );
void (* pf_delete_pes)( void *, struct pes_packet_s * );
/* Stream control capabilities */
ssize_t (* pf_read) ( struct input_thread_s *,
byte_t *, size_t );
int (* pf_set_program)( struct input_thread_s *,
struct pgrm_descriptor_s * );
int (* pf_set_area)( struct input_thread_s *,
struct input_area_s * );
void (* pf_seek)( struct input_thread_s *, off_t );
void * p_access_data;
size_t i_mtu;
/* Demux module */
struct module_s * p_demux_module;
int (* pf_init)( struct input_thread_s * );
void (* pf_end)( struct input_thread_s * );
int (* pf_demux)( struct input_thread_s * );
int (* pf_rewind)( struct input_thread_s * );
/* NULL if we don't support going *
* backwards (it's gonna be fun) */
void (* pf_seek)( struct input_thread_s *, off_t );
void * p_demux_data; /* data of the demux */
char * p_source;
int i_handle; /* socket or file descriptor */
FILE * p_stream; /* if applicable */
void * p_handle; /* if i_handle isn't suitable */
void * p_method_data; /* data of the packet manager */
void * p_plugin_data; /* data of the plugin */
/* Buffer manager */
struct input_buffers_s *p_method_data; /* data of the packet manager */
struct data_buffer_s * p_data_buffer;
byte_t * p_current_data;
byte_t * p_last_data;
size_t i_bufsize;
/* General stream description */
stream_descriptor_t stream; /* PAT tables */
stream_descriptor_t stream;
/* Playlist item */
char * psz_source;
char * psz_access;
char * psz_demux;
char * psz_name;
count_t c_loops;
} input_thread_t;
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* modules.h : Module management functions.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.h,v 1.43 2002/02/24 22:06:50 sam Exp $
* $Id: modules.h,v 1.44 2002/03/01 00:33:18 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -52,10 +52,10 @@ static __inline__ char *GetCapabilityName( unsigned int i_capa )
#define MODULE_CAPABILITY_INTF 1 /* Interface */
"access",
#define MODULE_CAPABILITY_ACCESS 2 /* Input */
"input",
#define MODULE_CAPABILITY_INPUT 3 /* Input */
"decaps",
#define MODULE_CAPABILITY_DECAPS 4 /* Decaps */
"demux",
#define MODULE_CAPABILITY_DEMUX 3 /* Input */
"network",
#define MODULE_CAPABILITY_NETWORK 4 /* Network */
"decoder",
#define MODULE_CAPABILITY_DECODER 5 /* Audio or video decoder */
"motion",
......@@ -174,38 +174,33 @@ typedef struct function_list_s
void ( * pf_run ) ( struct intf_thread_s * );
} intf;
/* Input plugin */
/* Access plugin */
struct
{
int ( * pf_probe )( struct input_thread_s * );
void ( * pf_init ) ( struct input_thread_s * );
void ( * pf_open ) ( struct input_thread_s * );
int ( * pf_open ) ( struct input_thread_s * );
void ( * pf_close )( struct input_thread_s * );
void ( * pf_end ) ( struct input_thread_s * );
void ( * pf_init_bit_stream ) ( struct bit_stream_s *,
struct decoder_fifo_s *,
void (* pf_bitstream_callback)( struct bit_stream_s *,
boolean_t ),
void * );
int ( * pf_read ) ( struct input_thread_s *,
struct data_packet_s ** );
void ( * pf_demux )( struct input_thread_s *,
struct data_packet_s * );
struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
struct pes_packet_s * ( * pf_new_pes ) ( void * );
void ( * pf_delete_packet ) ( void *, struct data_packet_s * );
void ( * pf_delete_pes ) ( void *, struct pes_packet_s * );
ssize_t ( * pf_read ) ( struct input_thread_s *, byte_t *, size_t );
void ( * pf_seek ) ( struct input_thread_s *, off_t );
int ( * pf_set_program ) ( struct input_thread_s *,
struct pgrm_descriptor_s * );
struct pgrm_descriptor_s * );
int ( * pf_set_area ) ( struct input_thread_s *,
struct input_area_s * );
} access;
/* Demux plugin */
struct
{
int ( * pf_init ) ( struct input_thread_s * );
void ( * pf_end ) ( struct input_thread_s * );
int ( * pf_demux )( struct input_thread_s * );
int ( * pf_rewind ) ( struct input_thread_s * );
void ( * pf_seek ) ( struct input_thread_s *, off_t );
} input;
} demux;
/* Network plugin */
struct
{
int ( * pf_open )( struct network_socket_s * );
} network;
/* Audio output plugin */
struct
......@@ -312,8 +307,8 @@ typedef struct module_functions_s
/* XXX: The order here has to be the same as above for the #defines */
function_list_t intf;
function_list_t access;
function_list_t input;
function_list_t decaps;
function_list_t demux;
function_list_t network;
function_list_t dec;
function_list_t motion;
function_list_t idct;
......
/*****************************************************************************
* input_es.h: thread structure of the ES plugin
* network.h: interface to communicate with network plug-ins
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_es.h,v 1.3 2001/12/27 03:47:09 massiot Exp $
* Copyright (C) 2002 VideoLAN
* $Id: network.h,v 1.1 2002/03/01 00:33:18 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -21,6 +21,26 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#define ES_PACKET_SIZE 2048
#define ES_READ_ONCE 50
#define MAX_PACKETS_IN_FIFO 50
/*****************************************************************************
* network_socket_t: structure passed to a network plug-in to define the
* kind of socket we want
*****************************************************************************/
typedef struct network_socket_s
{
unsigned int i_type;
char * psz_bind_addr;
int i_bind_port;
char * psz_server_addr;
int i_server_port;
/* Return values */
int i_handle;
size_t i_mtu;
} network_socket_t;
/* Socket types */
#define NETWORK_UDP 1
#define NETWORK_TCP 2
......@@ -3,7 +3,7 @@
* This header provides a portable threads implementation.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: threads.h,v 1.36 2002/02/27 03:47:56 sam Exp $
* $Id: threads.h,v 1.37 2002/03/01 00:33:18 massiot Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -37,6 +37,10 @@
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) /* pthreads (like Linux & BSD) */
# include <pthread.h>
# ifdef DEBUG
/* Needed for pthread_cond_timedwait */
# include <errno.h>
# endif
/* This is not prototyped under Linux, though it exists. */
int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind );
......@@ -716,15 +720,21 @@ static __inline__ int _vlc_cond_wait( char * psz_file, int i_line,
timeout.tv_sec = now.tv_sec + THREAD_COND_TIMEOUT;
timeout.tv_nsec = now.tv_usec * 1000;
if( (i_result = pthread_cond_timedwait( p_condvar, p_mutex, &timeout )) )
i_result = pthread_cond_timedwait( p_condvar, p_mutex, &timeout );
if( i_result == ETIMEDOUT )
{
intf_WarnMsg( 1, "thread %d warning: Possible deadlock detected in cond_wait at %s:%d (%s)",
pthread_self(), psz_file, i_line, strerror(i_result) );
continue;
}
else
if( i_result )
{
return i_result;
intf_ErrMsg( "thread %d error: cond_wait failed at %s:%d (%s)",
pthread_self(), psz_file, i_line, strerror(i_result) );
}
return( i_result );
}
#endif
......
......@@ -4,7 +4,7 @@
* includes all common video types and constants.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video.h,v 1.43 2002/02/19 00:50:19 sam Exp $
* $Id: video.h,v 1.44 2002/03/01 00:33:18 massiot Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -84,11 +84,6 @@ typedef struct picture_s
boolean_t b_repeat_first_field; /* RFF bit */
boolean_t b_top_field_first; /* which field is first */
/* Macroblock counter - the decoder uses it to verify if it has
* decoded all the macroblocks of the picture */
int i_deccount;
vlc_mutex_t lock_deccount;
/* Private data - the video output plugin might want to put stuff here to
* keep track of the picture */
struct picture_sys_s *p_sys;
......
.dep
*.lo
*.o.*
*.lo.*
file_SOURCES = file.c
udp_SOURCES = udp.c
http_SOURCES = http.c
/*****************************************************************************
* file.c: file input (file: access plug-in)
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: file.c,v 1.1 2002/03/01 00:33:18 massiot Exp $
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <videolan/vlc.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#elif defined( _MSC_VER ) && defined( _WIN32 )
# include <io.h>
#endif
#include "stream_control.h"
#include "input_ext-intf.h"
#include "input_ext-dec.h"
#include "input_ext-plugins.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static void input_getfunctions( function_list_t * );
static int FileOpen ( struct input_thread_s * );
static int FileSetProgram ( struct input_thread_s * , pgrm_descriptor_t * );
/*****************************************************************************
* Build configuration tree.
*****************************************************************************/
MODULE_CONFIG_START
MODULE_CONFIG_STOP
MODULE_INIT_START
SET_DESCRIPTION( "Standard filesystem file reading" )
ADD_CAPABILITY( ACCESS, 50 )
ADD_SHORTCUT( "file" )
ADD_SHORTCUT( "stream" )
MODULE_INIT_STOP
MODULE_ACTIVATE_START
input_getfunctions( &p_module->p_functions->access );
MODULE_ACTIVATE_STOP
MODULE_DEACTIVATE_START
MODULE_DEACTIVATE_STOP
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
static void input_getfunctions( function_list_t * p_function_list )
{
#define input p_function_list->functions.access
input.pf_open = FileOpen;
input.pf_read = input_FDRead;
input.pf_close = input_FDClose;
input.pf_set_program = FileSetProgram;
input.pf_set_area = NULL;
input.pf_seek = input_FDSeek;
#undef input
}
/*****************************************************************************
* FileOpen: open the file
*****************************************************************************/
static int FileOpen( input_thread_t * p_input )
{
char * psz_name = p_input->psz_name;
int i_stat;
struct stat stat_info;
input_socket_t * p_access_data;
boolean_t b_stdin;
p_input->i_mtu = 0;
b_stdin = ( strlen( p_input->psz_name ) == 1 )
&& *p_input->psz_name == '-';
if( !b_stdin && (i_stat = stat( psz_name, &stat_info )) == (-1) )
{
intf_ErrMsg( "input error: cannot stat() file `%s' (%s)",
psz_name, strerror(errno));
return( -1 );
}
vlc_mutex_lock( &p_input->stream.stream_lock );
if( p_input->psz_access != NULL
&& !strncmp( p_input->psz_access, "stream", 7 ) )
{
/* stream:%s */
p_input->stream.b_pace_control = 0;
p_input->stream.b_seekable = 0;
p_input->stream.p_selected_area->i_size = 0;
}
else
{
/* file:%s or %s */
p_input->stream.b_pace_control = 1;
if( b_stdin )
{
p_input->stream.b_seekable = 0;
p_input->stream.p_selected_area->i_size = 0;
}
else if( S_ISREG(stat_info.st_mode) || S_ISCHR(stat_info.st_mode)
|| S_ISBLK(stat_info.st_mode) )
{
p_input->stream.b_seekable = 1;
p_input->stream.p_selected_area->i_size = stat_info.st_size;
}
else if( S_ISFIFO(stat_info.st_mode)
#if !defined( SYS_BEOS ) && !defined( WIN32 )
|| S_ISSOCK(stat_info.st_mode)
#endif
)
{
p_input->stream.b_seekable = 0;
p_input->stream.p_selected_area->i_size = 0;
}
else
{
vlc_mutex_unlock( &p_input->stream.stream_lock );
intf_ErrMsg( "input error: unknown file type for `%s'",
psz_name );
return( -1 );
}
}
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.i_method = INPUT_METHOD_FILE;
vlc_mutex_unlock( &p_input->stream.stream_lock );
intf_WarnMsg( 2, "input: opening file `%s'", psz_name );
p_access_data = malloc( sizeof(input_socket_t) );
p_input->p_access_data = (void *)p_access_data;
if( p_access_data == NULL )
{
intf_ErrMsg( "input error: Out of memory" );
return( -1 );
}
if( b_stdin )
{
p_access_data->i_handle = 0;
}
else if( (p_access_data->i_handle = open( psz_name,
/*O_NONBLOCK | O_LARGEFILE*/ 0 )) == (-1) )
{
intf_ErrMsg( "input error: cannot open file %s (%s)", psz_name,
strerror(errno) );
free( p_access_data );
return( -1 );
}
return( 0 );
}
/*****************************************************************************
* FileSetProgram: Do nothing
*****************************************************************************/
static int FileSetProgram( input_thread_t * p_input,
pgrm_descriptor_t * p_program )
{
return( 0 );
}
This diff is collapsed.
/*****************************************************************************
* udp.c: raw UDP access plug-in
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: udp.c,v 1.1 2002/03/01 00:33:18 massiot Exp $
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <videolan/vlc.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#elif defined( _MSC_VER ) && defined( _WIN32 )
# include <io.h>
#endif
#include "stream_control.h"
#include "input_ext-intf.h"
#include "input_ext-dec.h"
#include "input_ext-plugins.h"
#include "network.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static void input_getfunctions( function_list_t * );
static int UDPOpen ( struct input_thread_s * );
static int UDPSetProgram ( struct input_thread_s * , pgrm_descriptor_t * );
/*****************************************************************************
* Build configuration tree.
*****************************************************************************/
MODULE_CONFIG_START
MODULE_CONFIG_STOP
MODULE_INIT_START
SET_DESCRIPTION( "Raw UDP access plug-in" )
ADD_CAPABILITY( ACCESS, 0 )
ADD_SHORTCUT( "udp" )
ADD_SHORTCUT( "udpstream" )
ADD_SHORTCUT( "udp4" )
ADD_SHORTCUT( "udp6" )
MODULE_INIT_STOP
MODULE_ACTIVATE_START
input_getfunctions( &p_module->p_functions->access );
MODULE_ACTIVATE_STOP
MODULE_DEACTIVATE_START
MODULE_DEACTIVATE_STOP
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
static void input_getfunctions( function_list_t * p_function_list )
{
#define input p_function_list->functions.access
input.pf_open = UDPOpen;
input.pf_read = input_FDNetworkRead;
input.pf_close = input_FDClose;
input.pf_set_program = UDPSetProgram;
input.pf_set_area = NULL;
input.pf_seek = NULL;
#undef input
}
/*****************************************************************************
* UDPOpen: open the socket
*****************************************************************************/
static int UDPOpen( input_thread_t * p_input )
{
input_socket_t * p_access_data;
struct module_s * p_network;
char * psz_network = NULL;
char * psz_parser = p_input->psz_name;
char * psz_server_addr = NULL;
char * psz_server_port = NULL;
char * psz_bind_addr = NULL;
char * psz_bind_port = NULL;
int i_bind_port = 0, i_server_port = 0;
network_socket_t socket_desc;
if( p_input->psz_access != NULL )
{
/* Find out which shortcut was used */
if( !strncmp( p_input->psz_access, "udp6", 5 ) )
{
psz_network = "ipv6";
}
else if( !strncmp( p_input->psz_access, "udp4", 5 ) )
{
psz_network = "ipv4";
}
}
/* Parse psz_name syntax :
* [serveraddr[:serverport]][@[bindaddr]:[bindport]] */
if( *psz_parser && *psz_parser != '@' )
{
/* Found server */
psz_server_addr = psz_parser;
while( *psz_parser && *psz_parser != ':' && *psz_parser != '@' )
{
psz_parser++;
}
if( *psz_parser == ':' )
{
/* Found server port */
*psz_parser = '\0'; /* Terminate server name */
psz_parser++;
psz_server_port = psz_parser;
while( *psz_parser && *psz_parser != '@' )
{
psz_parser++;
}
}
}
if( *psz_parser == '@' )
{
/* Found bind address or bind port */
*psz_parser = '\0'; /* Terminate server port or name if necessary */ psz_parser++;
if( *psz_parser && *psz_parser != ':' )
{
/* Found bind address */
psz_bind_addr = psz_parser;
while( *psz_parser && *psz_parser != ':' )
{
psz_parser++;
}
}
if( *psz_parser == ':' )
{
/* Found bind port */
*psz_parser = '\0'; /* Terminate bind address if necessary */
psz_parser++;
psz_bind_port = psz_parser;
}
}
/* Convert ports format */
if( psz_server_port != NULL )
{
i_server_port = strtol( psz_server_port, &psz_parser, 10 );
if( *psz_parser )
{
intf_ErrMsg( "input error: cannot parse server port near %s",
psz_parser );
return( -1 );
}
}
if( psz_bind_port != NULL )
{
i_bind_port = strtol( psz_bind_port, &psz_parser, 10 );
if( *psz_parser )
{
intf_ErrMsg( "input error: cannot parse bind port near %s",
psz_parser );
return( -1 );
}
}
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.b_pace_control = 0;
p_input->stream.b_seekable = 0;
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.i_method = INPUT_METHOD_NETWORK;
vlc_mutex_unlock( &p_input->stream.stream_lock );
intf_WarnMsg( 2, "input: opening server=%s:%d local=%s:%d",
psz_server_addr, i_server_port, psz_bind_addr, i_bind_port );
/* Prepare the network_socket_t structure */
socket_desc.i_type = NETWORK_UDP;
socket_desc.psz_bind_addr = psz_bind_addr;
socket_desc.i_bind_port = i_bind_port;
socket_desc.psz_server_addr = psz_server_addr;
socket_desc.i_server_port = i_server_port;
/* Find an appropriate network module */
p_network = module_Need( MODULE_CAPABILITY_NETWORK, psz_network,
&socket_desc );
if( p_network == NULL )
{
return( -1 );
}
module_Unneed( p_network );
p_access_data = p_input->p_access_data = malloc( sizeof(input_socket_t) );
if( p_access_data == NULL )
{
intf_ErrMsg( "input error: Out of memory" );
return( -1 );
}
p_access_data->i_handle = socket_desc.i_handle;
p_input->i_mtu = socket_desc.i_mtu;
return( 0 );
}
/*****************************************************************************
* UDPSetProgram: Do nothing
*****************************************************************************/
static int UDPSetProgram( input_thread_t * p_input,
pgrm_descriptor_t * p_program )
{
return( 0 );
}
......@@ -2,7 +2,7 @@
* dummy.c : dummy plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: dummy.c,v 1.16 2002/02/27 03:47:56 sam Exp $
* $Id: dummy.c,v 1.17 2002/03/01 00:33:18 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -32,7 +32,8 @@
/*****************************************************************************
* Capabilities defined in the other files.
*****************************************************************************/
void _M( input_getfunctions ) ( function_list_t * p_function_list );
void _M( access_getfunctions ) ( function_list_t * p_function_list );
void _M( demux_getfunctions ) ( function_list_t * p_function_list );
void _M( aout_getfunctions ) ( function_list_t * p_function_list );
void _M( vout_getfunctions ) ( function_list_t * p_function_list );
void _M( intf_getfunctions ) ( function_list_t * p_function_list );
......@@ -48,17 +49,19 @@ MODULE_INIT_START
SET_DESCRIPTION( "dummy functions module" )
/* Capability score set to 0 because we don't want to be spawned
* unless explicitly requested to */
ADD_CAPABILITY( AOUT, 1 )
ADD_CAPABILITY( VOUT, 1 )
ADD_CAPABILITY( INTF, 1 )
/* This one is ok. */
ADD_CAPABILITY( INPUT, 100 )
ADD_CAPABILITY( AOUT, 0 )
ADD_CAPABILITY( VOUT, 0 )
ADD_CAPABILITY( INTF, 0 )
ADD_CAPABILITY( ACCESS, 0 )
ADD_CAPABILITY( DEMUX, 0 )
ADD_SHORTCUT( "dummy" )
ADD_SHORTCUT( "vlc" )
MODULE_INIT_STOP
MODULE_ACTIVATE_START
_M( input_getfunctions )( &p_module->p_functions->input );
_M( access_getfunctions )( &p_module->p_functions->access );
_M( demux_getfunctions )( &p_module->p_functions->demux );
_M( aout_getfunctions )( &p_module->p_functions->aout );
_M( vout_getfunctions )( &p_module->p_functions->vout );
_M( intf_getfunctions )( &p_module->p_functions->intf );
......
/*****************************************************************************
* input_dummy.c: dummy input plugin, to manage "vlc:***" special options
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_dummy.c,v 1.15 2002/02/15 13:32:53 sam Exp $
* Copyright (C) 2001, 2002 VideoLAN
* $Id: input_dummy.c,v 1.16 2002/03/01 00:33:18 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -31,10 +31,6 @@
#include <videolan/vlc.h>
#ifdef STRNCASECMP_IN_STRINGS_H
# include <strings.h>
#endif
#include "interface.h"
#include "intf_playlist.h"
......@@ -46,25 +42,23 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int DummyProbe ( struct input_thread_s * );
static void DummyInit ( struct input_thread_s * );
static void DummyOpen ( struct input_thread_s * );
static int DummyInit ( struct input_thread_s * );
static int DummyOpen ( struct input_thread_s * );
static void DummyClose ( struct input_thread_s * );
static void DummyEnd ( struct input_thread_s * );
static int DummyRead ( struct input_thread_s *, data_packet_t ** );
static int DummyDemux ( struct input_thread_s * );
/*****************************************************************************
* dummy_data_t: private input data
* access_sys_t: private input data
*****************************************************************************/
typedef struct dummy_data_s
struct demux_sys_s
{
/* The real command */
int i_command;
/* Used for the pause command */
mtime_t expiration;
} dummy_data_t;
};
#define COMMAND_NOP 0
#define COMMAND_QUIT 1
......@@ -75,48 +69,37 @@ typedef struct dummy_data_s
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
void _M( input_getfunctions )( function_list_t * p_function_list )
void _M( access_getfunctions )( function_list_t * p_function_list )
{
#define input p_function_list->functions.input
input.pf_probe = DummyProbe;
input.pf_init = DummyInit;
#define input p_function_list->functions.access
input.pf_open = DummyOpen;
input.pf_read = NULL;
input.pf_close = DummyClose;
input.pf_end = DummyEnd;
input.pf_set_program = NULL;
input.pf_set_area = NULL;
input.pf_read = DummyRead;
input.pf_demux = NULL;
input.pf_new_packet = NULL;
input.pf_new_pes = NULL;
input.pf_delete_packet = NULL;
input.pf_delete_pes = NULL;
input.pf_rewind = NULL;
input.pf_seek = NULL;
#undef input
}
/*****************************************************************************
* DummyProbe: verifies that the input is a vlc command
*****************************************************************************/
static int DummyProbe( input_thread_t *p_input )
void _M( demux_getfunctions )( function_list_t * p_function_list )
{
char *psz_name = p_input->p_source;
if( ( strlen(psz_name) > 4 ) && !strncasecmp( psz_name, "vlc:", 4 ) )
{
/* If the user specified "vlc:" then it's probably a special command */
return 0;
}
return -1;
#define input p_function_list->functions.demux
input.pf_init = DummyInit;
input.pf_end = DummyEnd;
input.pf_demux = DummyDemux;
input.pf_rewind = NULL;
#undef input
}
/*****************************************************************************
* DummyOpen: open the target, ie. do nothing
*****************************************************************************/
static void DummyOpen( input_thread_t * p_input )
static int DummyOpen( input_thread_t * p_input )
{
p_input->stream.i_method = INPUT_METHOD_NONE;
/* Force dummy demux plug-in */
p_input->psz_demux = "vlc";
return( 0 );
}
/*****************************************************************************
......@@ -124,41 +107,28 @@ static void DummyOpen( input_thread_t * p_input )
*****************************************************************************/
static void DummyClose( input_thread_t * p_input )
{
;
}
/*****************************************************************************
* DummyOpen: initialize the target, ie. parse the command
* DummyInit: initialize the target, ie. parse the command
*****************************************************************************/
static void DummyInit( struct input_thread_s *p_input )
static int DummyInit( struct input_thread_s *p_input )
{
dummy_data_t* p_method;
char *psz_name = p_input->p_source;
int i_len = strlen( psz_name );
char * psz_name = p_input->psz_name;
int i_len = strlen( psz_name );
struct demux_sys_s * p_method;
int i_arg;
p_input->stream.b_seekable = 0;
if( ( i_len <= 4 ) || strncasecmp( psz_name, "vlc:", 4 ) )
{
/* If the command doesn't start with "vlc:" then it's not for us */
p_input->b_error = 1;
return;
}
/* We don't need the "vlc:" stuff any more */
psz_name += 4;
i_len -= 4;
p_method = malloc( sizeof( dummy_data_t ) );
p_method = malloc( sizeof( struct demux_sys_s ) );
if( p_method == NULL )
{
intf_ErrMsg( "input: out of memory" );
p_input->b_error = 1;
return;
return( -1 );
}
p_input->p_plugin_data = (void *)p_method;
p_input->p_demux_data = p_method;
p_input->stream.p_demux_data = NULL;
/* Check for a "vlc:nop" command */
......@@ -166,7 +136,7 @@ static void DummyInit( struct input_thread_s *p_input )
{
intf_WarnMsg( 2, "input: command `nop'" );
p_method->i_command = COMMAND_NOP;
return;
return( 0 );
}
/* Check for a "vlc:quit" command */
......@@ -174,7 +144,7 @@ static void DummyInit( struct input_thread_s *p_input )
{
intf_WarnMsg( 2, "input: command `quit'" );
p_method->i_command = COMMAND_QUIT;
return;
return( 0 );
}
/* Check for a "vlc:loop" command */
......@@ -182,7 +152,7 @@ static void DummyInit( struct input_thread_s *p_input )
{
intf_WarnMsg( 2, "input: command `loop'" );
p_method->i_command = COMMAND_LOOP;
return;
return( 0 );
}
/* Check for a "vlc:pause:***" command */
......@@ -192,14 +162,14 @@ static void DummyInit( struct input_thread_s *p_input )
intf_WarnMsg( 2, "input: command `pause %i'", i_arg );
p_method->i_command = COMMAND_PAUSE;
p_method->expiration = mdate() + (mtime_t)i_arg * (mtime_t)1000000;
return;
return( 0 );
}
intf_ErrMsg( "input error: unknown command `%s'", psz_name );
free( p_input->p_plugin_data );
free( p_input->p_demux_data );
p_input->b_error = 1;
return;
return( -1 );
}
/*****************************************************************************
......@@ -207,21 +177,20 @@ static void DummyInit( struct input_thread_s *p_input )
*****************************************************************************/
static void DummyEnd( struct input_thread_s *p_input )
{
free( p_input->p_plugin_data );
free( p_input->p_demux_data );
}
/*****************************************************************************
* DummyRead: do what the command says
* DummyDemux: do what the command says
*****************************************************************************/
static int DummyRead( struct input_thread_s *p_input, data_packet_t **pp_data )
static int DummyDemux( struct input_thread_s *p_input )
{
dummy_data_t* p_method = (dummy_data_t *)p_input->p_plugin_data;
struct demux_sys_s * p_method = p_input->p_demux_data;
switch( p_method->i_command )
{
case COMMAND_QUIT:
p_main->p_intf->b_die = 1;
p_input->b_eof = 1;
p_input->b_die = 1;
break;
case COMMAND_LOOP:
......@@ -246,8 +215,6 @@ static int DummyRead( struct input_thread_s *p_input, data_packet_t **pp_data )
break;
}
*pp_data = NULL;
return 0;
return 1;
}
......@@ -2,7 +2,7 @@
* dvd.c : DVD input module for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: dvd.c,v 1.20 2002/02/26 01:17:13 stef Exp $
* $Id: dvd.c,v 1.21 2002/03/01 00:33:18 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -37,7 +37,8 @@
/*****************************************************************************
* Capabilities defined in the other files.
*****************************************************************************/
void _M( input_getfunctions )( function_list_t * p_function_list );
void _M( access_getfunctions )( function_list_t * p_function_list );
void _M( demux_getfunctions )( function_list_t * p_function_list );
/*****************************************************************************
* Local prototypes.
......@@ -57,16 +58,17 @@ MODULE_CONFIG_STOP
MODULE_INIT_START
#ifdef GOD_DAMN_DMCA
SET_DESCRIPTION( "DVD input module, uses libdvdcss if present" )
ADD_CAPABILITY( INPUT, 90 )
#else
SET_DESCRIPTION( "DVD input module, linked with libdvdcss" )
ADD_CAPABILITY( INPUT, 100 )
#endif
ADD_CAPABILITY( ACCESS, 0 )
ADD_CAPABILITY( DEMUX, 0 )
ADD_SHORTCUT( "dvd" )
MODULE_INIT_STOP
MODULE_ACTIVATE_START
_M( input_getfunctions )( &p_module->p_functions->input );
_M( access_getfunctions )( &p_module->p_functions->access );
_M( demux_getfunctions )( &p_module->p_functions->demux );
#ifdef GOD_DAMN_DMCA
ProbeLibDVDCSS();
#endif
......
......@@ -2,7 +2,7 @@
* gtk_display.c: Gtk+ tools for main interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: gtk_display.c,v 1.15 2002/02/24 21:36:20 jobi Exp $
* $Id: gtk_display.c,v 1.16 2002/03/01 00:33:18 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr>
......@@ -131,7 +131,7 @@ gint GtkModeManage( intf_thread_t * p_intf )
p_intf->p_sys->p_window ),
"label_status" );
gtk_label_set_text( GTK_LABEL( p_label ),
p_input_bank->pp_input[0]->p_source );
p_input_bank->pp_input[0]->psz_source );
break;
case INPUT_METHOD_DISC:
//intf_WarnMsg( 2, "intf info: disc method" );
......@@ -144,7 +144,7 @@ gint GtkModeManage( intf_thread_t * p_intf )
p_intf->p_sys->p_window ),
"network_address_label" );
gtk_label_set_text( GTK_LABEL( p_label ),
p_input_bank->pp_input[0]->p_source );
p_input_bank->pp_input[0]->psz_source );
p_channel = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_window ), "network_channel_box" ) );
if( config_GetIntVariable( INPUT_NETWORK_CHANNEL_VAR ) )
......@@ -164,7 +164,7 @@ gint GtkModeManage( intf_thread_t * p_intf )
p_intf->p_sys->p_window ),
"label_status" );
gtk_label_set_text( GTK_LABEL( p_label ),
p_input_bank->pp_input[0]->p_source );
p_input_bank->pp_input[0]->psz_source );
break;
}
......
mpeg_es_SOURCES = mpeg_es.c input_es.c
mpeg_ps_SOURCES = mpeg_ps.c input_ps.c
mpeg_ts_SOURCES = mpeg_ts.c input_ts.c
mpeg_es_SOURCES = mpeg_es.c
mpeg_ps_SOURCES = mpeg_ps.c
mpeg_ts_SOURCES = mpeg_ts.c
/*****************************************************************************
* input_es.c: Elementary Stream demux and packet management
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_es.c,v 1.13 2002/02/15 13:32:53 sam Exp $
*
* Author: 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <videolan/vlc.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <fcntl.h>
#if defined( WIN32 )
# include <io.h> /* read() */
#else
# include <sys/uio.h> /* struct iovec */
#endif
#if defined( WIN32 )
# include "input_iovec.h"
#endif
#include "stream_control.h"
#include "input_ext-intf.h"
#include "input_ext-dec.h"
#include "input_ext-plugins.h"
#include "input_es.h"
#include "debug.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int ESProbe ( struct input_thread_s * );
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 );
static int ESSetProgram ( struct input_thread_s *, pgrm_descriptor_t * );
static void ESDemux ( struct input_thread_s *,
struct data_packet_s * );
/*****************************************************************************
* Declare a buffer manager
*****************************************************************************/
#define FLAGS BUFFERS_UNIQUE_SIZE
#define NB_LIFO 1
DECLARE_BUFFERS_EMBEDDED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_INIT( FLAGS, NB_LIFO );
DECLARE_BUFFERS_END( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_TOIO( FLAGS, ES_PACKET_SIZE );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
void _M( input_getfunctions )( function_list_t * p_function_list )
{
#define input p_function_list->functions.input
input.pf_probe = ESProbe;
input.pf_init = ESInit;
input.pf_open = NULL;
input.pf_close = NULL;
input.pf_end = ESEnd;
input.pf_set_area = NULL;
input.pf_set_program = ESSetProgram;
input.pf_read = ESRead;
input.pf_demux = ESDemux;
input.pf_new_packet = input_NewPacket;
input.pf_new_pes = input_NewPES;
input.pf_delete_packet = input_DeletePacket;
input.pf_delete_pes = input_DeletePES;
input.pf_rewind = NULL;
input.pf_seek = ESSeek;
#undef input
}
/*
* Data reading functions
*/
/*****************************************************************************
* ESProbe: verifies that the stream is a ES stream
*****************************************************************************/
static int ESProbe( input_thread_t *p_input )
{
return 0;
}
/*****************************************************************************
* ESInit: initializes ES structures
*****************************************************************************/
static void ESInit( input_thread_t * p_input )
{
es_descriptor_t * p_es;
p_input->p_method_data = NULL;
if( (p_input->p_method_data = input_BuffersInit()) == NULL )
{
p_input->b_error = 1;
return;
}
/* FIXME : detect if InitStream failed */
input_InitStream( p_input, 0 );
input_AddProgram( p_input, 0, 0 );
p_input->stream.p_selected_program = p_input->stream.pp_programs[0];
vlc_mutex_lock( &p_input->stream.stream_lock );
p_es = input_AddES( p_input, p_input->stream.p_selected_program, 0xE0, 0 );
p_es->i_stream_id = 0xE0;
p_es->i_type = MPEG1_VIDEO_ES;
p_es->i_cat = VIDEO_ES;
input_SelectES( p_input, p_es );
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.p_selected_program->b_is_ok = 1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
/*****************************************************************************
* ESEnd: frees unused data
*****************************************************************************/
static void ESEnd( input_thread_t * p_input )
{
input_BuffersEnd( p_input->p_method_data );
}
/*****************************************************************************
* ESRead: reads data packets
*****************************************************************************
* 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_data )
{
int i_read;
struct iovec p_iovec[ES_READ_ONCE];
data_packet_t * p_data;
/* Get iovecs */
*pp_data = p_data = input_BuffersToIO( p_input->p_method_data, p_iovec,
ES_READ_ONCE );
if ( p_data == NULL )
{
return( -1 );
}
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;
if( i_read != ES_READ_ONCE )
{
/* We got fewer packets than wanted. Give remaining packets
* back to the buffer allocator. */
int i_loop;
for( i_loop = 0; i_loop < i_read; i_loop++ )
{
pp_data = &(*pp_data)->p_next;
}
p_input->pf_delete_packet( p_input->p_method_data, *pp_data );
*pp_data = NULL;
}
return( i_read );
}
/*****************************************************************************
* ESSeek: changes the stream position indicator
*****************************************************************************/
static void ESSeek( input_thread_t * p_input, off_t i_position )
{
lseek( p_input->i_handle, i_position, SEEK_SET );
p_input->stream.p_selected_area->i_tell = i_position;
}
/*****************************************************************************
* ESSetProgram: Does nothing
*****************************************************************************/
static int ESSetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm )
{
return( 0 );
}
/*****************************************************************************
* ESDemux: fakes a demultiplexer
*****************************************************************************/
static void ESDemux( input_thread_t * p_input, data_packet_t * p_data )
{
pes_packet_t * p_pes = p_input->pf_new_pes( p_input->p_method_data );
decoder_fifo_t * p_fifo =
p_input->stream.p_selected_program->pp_es[0]->p_decoder_fifo;
if( p_pes == NULL )
{
intf_ErrMsg("Out of memory");
p_input->b_error = 1;
return;
}
p_pes->i_rate = p_input->stream.control.i_rate;
p_pes->p_first = p_pes->p_last = p_data;
p_pes->i_nb_data = 1;
vlc_mutex_lock( &p_input->stream.stream_lock );
if( p_fifo->i_depth >= MAX_PACKETS_IN_FIFO )
{
/* Wait for the decoder. */
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
if( (p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT)
| (input_ClockManageControl( p_input,
p_input->stream.p_selected_program,
(mtime_t)0 ) == PAUSE_S) )
{
intf_WarnMsg( 2, "synchro reinit" );
p_pes->i_pts = mdate() + DEFAULT_PTS_DELAY;
p_input->stream.p_selected_program->i_synchro_state = SYNCHRO_OK;
}
input_DecodePES( p_fifo, p_pes );
}
This diff is collapsed.
/*****************************************************************************
* input_ps.h: thread structure of the PS plugin
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $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>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#define PS_READ_ONCE 50
This diff is collapsed.
/*****************************************************************************
* input_ts.h: structures of the input not exported to other modules
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ts.h,v 1.5 2001/12/30 07:09:55 sam Exp $
*
* Authors: Henri Fallon <henri@via.ecp.fr>
* Boris Dors <babal@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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* 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
*****************************************************************************/
typedef struct thread_ts_data_s
{
/* The file descriptor we select() on */
fd_set fds;
#if defined( WIN32 )
char p_buffer[ BUFFER_SIZE ]; /* temporary buffer for readv_network */
int i_length; /* length of the UDP packet */
int i_offset; /* number of bytes already read from the buffer */
#endif
} thread_ts_data_t;
/*****************************************************************************
* network readv() replacement for iovec-impaired C libraries
*****************************************************************************/
#if defined(WIN32)
static __inline__ int read_network( int i_fd, char * p_base,
thread_ts_data_t *p_sys, int i_len )
{
int i_bytes;
if( p_sys->i_offset >= p_sys->i_length )
{
p_sys->i_length = recv( i_fd, p_sys->p_buffer, BUFFER_SIZE, 0 );
if ( p_sys->i_length == SOCKET_ERROR )
{
return -1;
}
p_sys->i_offset = 0;
}
if( i_len <= p_sys->i_length - p_sys->i_offset )
{
i_bytes = i_len;
}
else
{
i_bytes = p_sys->i_length - p_sys->i_offset;
}
FAST_MEMCPY( p_base, p_sys->p_buffer + p_sys->i_offset, i_bytes );
p_sys->i_offset += i_bytes;
return i_bytes;
}
static __inline__ int readv_network( int i_fd, struct iovec *p_iovec,
int i_count, thread_ts_data_t *p_sys )
{
int i_index, i_len, i_total = 0;
u8 *p_base;
for( i_index = i_count; i_index; i_index-- )
{
register signed int i_bytes;
i_len = p_iovec->iov_len;
p_base = p_iovec->iov_base;
/* Loop is unrolled one time to spare the (i_bytes <= 0) test */
if( i_len > 0 )
{
i_bytes = read_network( i_fd, p_base, p_sys, i_len );
if( ( i_total == 0 ) && ( i_bytes < 0 ) )
{
return -1;
}
if( i_bytes <= 0 )
{
return i_total;
}
i_len -= i_bytes; i_total += i_bytes; p_base += i_bytes;
while( i_len > 0 )
{
i_bytes = read_network( i_fd, p_base, p_sys, i_len );
if( i_bytes <= 0 )
{
return i_total;
}
i_len -= i_bytes; i_total += i_bytes; p_base += i_bytes;
}
}
p_iovec++;
}
return i_total;
}
#endif
......@@ -2,7 +2,7 @@
* mpeg_es.c : Elementary Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mpeg_es.c,v 1.3 2002/02/15 13:32:53 sam Exp $
* $Id: mpeg_es.c,v 1.4 2002/03/01 00:33:18 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -26,13 +26,30 @@
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#include <errno.h>
#include <videolan/vlc.h>
#include <sys/types.h>
#include "stream_control.h"
#include "input_ext-intf.h"
#include "input_ext-dec.h"
#include "input_ext-plugins.h"
/*****************************************************************************
* Constants
*****************************************************************************/
#define ES_PACKET_SIZE 65536
#define MAX_PACKETS_IN_FIFO 3
/*****************************************************************************
* Capabilities defined in the other files.
* Local prototypes
*****************************************************************************/
void _M( input_getfunctions )( function_list_t * p_function_list );
static void input_getfunctions( function_list_t * p_function_list );
static int ESDemux ( struct input_thread_s * );
static int ESInit ( struct input_thread_s * );
static void ESEnd ( struct input_thread_s * );
/*****************************************************************************
* Build configuration tree.
......@@ -41,15 +58,165 @@ MODULE_CONFIG_START
MODULE_CONFIG_STOP
MODULE_INIT_START
SET_DESCRIPTION( "ISO 13818-1 MPEG Elementary Stream input" )
ADD_CAPABILITY( INPUT, 5 )
SET_DESCRIPTION( "ISO 13818-2 MPEG Elementary Stream input" )
ADD_CAPABILITY( DEMUX, 150 )
ADD_SHORTCUT( "es" )
MODULE_INIT_STOP
MODULE_ACTIVATE_START
_M( input_getfunctions )( &p_module->p_functions->input );
input_getfunctions( &p_module->p_functions->demux );
MODULE_ACTIVATE_STOP
MODULE_DEACTIVATE_START
MODULE_DEACTIVATE_STOP
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
static void input_getfunctions( function_list_t * p_function_list )
{
#define input p_function_list->functions.demux
input.pf_init = ESInit;
input.pf_end = ESEnd;
input.pf_demux = ESDemux;
input.pf_rewind = NULL;
#undef input
}
/*
* Data reading functions
*/
/*****************************************************************************
* ESInit: initializes ES structures
*****************************************************************************/
static int ESInit( input_thread_t * p_input )
{
es_descriptor_t * p_es;
byte_t * p_peek;
/* Initialize access plug-in structures. */
if( p_input->i_mtu == 0 )
{
/* Improve speed. */
p_input->i_bufsize = INPUT_DEFAULT_BUFSIZE;
}
/* Have a peep at the show. */
if( input_Peek( p_input, &p_peek, 4 ) < 4 )
{
/* Stream shorter than 4 bytes... */
intf_ErrMsg( "input error: cannot peek() (mpeg_es)" );
return( -1 );
}
if( *p_peek || *(p_peek + 1) || *(p_peek + 2) != 1 )
{
if( p_input->psz_demux && strncmp( p_input->psz_demux, "es", 3 ) )
{
/* User forced */
intf_ErrMsg( "input error: this doesn't seem like an MPEG stream, continuing" );
}
else
{
intf_WarnMsg( 2, "input: ES plug-in discarded (no startcode)" );
return( -1 );
}
}
else if( *(p_peek + 3) > 0xb9 )
{
if( p_input->psz_demux && strncmp( p_input->psz_demux, "es", 3 ) )
{
/* User forced */
intf_ErrMsg( "input error: this seems to be a system stream (PS plug-in ?), but continuing" );
}
else
{
intf_WarnMsg( 2, "input: ES plug-in discarded (system startcode)" );
return( -1 );
}
}
if( input_InitStream( p_input, 0 ) == -1 )
{
return( -1 );
}
input_AddProgram( p_input, 0, 0 );
p_input->stream.p_selected_program = p_input->stream.pp_programs[0];
vlc_mutex_lock( &p_input->stream.stream_lock );
p_es = input_AddES( p_input, p_input->stream.p_selected_program, 0xE0, 0 );
p_es->i_stream_id = 0xE0;
p_es->i_type = MPEG1_VIDEO_ES;
p_es->i_cat = VIDEO_ES;
input_SelectES( p_input, p_es );
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.p_selected_program->b_is_ok = 1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
return( 0 );
}
/*****************************************************************************
* ESEnd: frees unused data
*****************************************************************************/
static void ESEnd( input_thread_t * p_input )
{
}
/*****************************************************************************
* ESDemux: reads and demuxes data packets
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static int ESDemux( input_thread_t * p_input )
{
ssize_t i_read;
decoder_fifo_t * p_fifo =
p_input->stream.p_selected_program->pp_es[0]->p_decoder_fifo;
pes_packet_t * p_pes;
data_packet_t * p_data;
i_read = input_SplitBuffer( p_input, &p_data, ES_PACKET_SIZE );
if ( i_read <= 0 )
{
return( i_read );
}
p_pes = input_NewPES( p_input->p_method_data );
if( p_pes == NULL )
{
intf_ErrMsg("Out of memory");
input_DeletePacket( p_input->p_method_data, p_data );
return( -1 );
}
p_pes->i_rate = p_input->stream.control.i_rate;
p_pes->p_first = p_pes->p_last = p_data;
p_pes->i_nb_data = 1;
vlc_mutex_lock( &p_fifo->data_lock );
if( p_fifo->i_depth >= MAX_PACKETS_IN_FIFO )
{
/* Wait for the decoder. */
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
vlc_mutex_unlock( &p_fifo->data_lock );
if( (p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT)
| (input_ClockManageControl( p_input,
p_input->stream.p_selected_program,
(mtime_t)0 ) == PAUSE_S) )
{
intf_WarnMsg( 2, "synchro reinit" );
p_pes->i_pts = mdate() + DEFAULT_PTS_DELAY;
p_input->stream.p_selected_program->i_synchro_state = SYNCHRO_OK;
}
input_DecodePES( p_fifo, p_pes );
return( 1 );
}
This diff is collapsed.
This diff is collapsed.
.dep
*.lo
*.o.*
*.lo.*
ipv4_SOURCES = ipv4.c
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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