* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: common.h,v 1.64 2002/01/04 14:01:34 sam Exp $
+ * $Id: common.h,v 1.89 2002/03/25 23:36:57 ipkiss Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
* Required system headers
*****************************************************************************/
#include <string.h> /* strerror() */
+#include <sys/types.h>
/*****************************************************************************
* Basic types definitions
*****************************************************************************/
+typedef unsigned char u8;
+typedef signed char s8;
+
+typedef unsigned short u16;
+typedef signed short s16;
+
+typedef unsigned int u32;
+typedef signed int s32;
+
+#if defined( _MSC_VER ) || ( defined( WIN32 ) && !defined( __MINGW32__ ) )
+typedef unsigned __int64 u64;
+typedef signed __int64 s64;
+#else
+typedef unsigned long long u64;
+typedef signed long long s64;
+#endif
+
typedef u8 byte_t;
/* Boolean type */
#ifdef BOOLEAN_T_IN_SYS_TYPES_H
-# include <sys/types.h>
+ /* <sys/types.h> already included */
#elif defined(BOOLEAN_T_IN_PTHREAD_H)
# include <pthread.h>
#elif defined(BOOLEAN_T_IN_CTHREADS_H)
# endif
#endif
+#if defined( WIN32 )
+typedef int ssize_t;
+#endif
+
/* Counter for statistics and profiling */
typedef unsigned long count_t;
struct playlist_s;
struct playlist_item_s;
struct module_s;
+struct module_config_s;
typedef struct playlist_s * p_playlist_t;
typedef struct playlist_item_s * p_playlist_item_t;
+typedef struct module_s * p_module_t;
+typedef struct module_config_s * p_module_config_t;
/* Interface */
struct intf_thread_s;
struct pes_packet_s;
struct input_area_s;
struct bit_stream_s;
-struct probedata_s;
+struct input_buffers_s;
+struct network_socket_s;
+struct intf_subscription_s;
/*****************************************************************************
* Macros and inline functions
/* PAD: PAD(n, d) = CEIL(n ,d) * d */
#define PAD(n, d) ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
-/* MAX and MIN: self explanatory */
-#ifndef MAX
-# define MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
+/* __MAX and __MIN: self explanatory */
+#ifndef __MAX
+# define __MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
#endif
-#ifndef MIN
-# define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
+#ifndef __MIN
+# define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
#endif
/* MSB (big endian)/LSB (little endian) conversions - network order is always
* byte orders other than little and big endians are not supported, but only
* the VAX seems to have such exotic properties - note that these 'functions'
* needs <netinet/in.h> or the local equivalent. */
-/* FIXME: hton64 should be declared as an extern inline function to avoid
- * border effects (see byteorder.h) */
+#if !defined( WIN32 )
#if WORDS_BIGENDIAN
# define hton16 htons
# define hton32 htonl
#else
# define hton16 htons
# define hton32 htonl
-# define hton64(i) ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
+ static __inline__ u64 __hton64( u64 i )
+ {
+ return ((u64)(htonl((i) & 0xffffffff)) << 32)
+ | htonl(((i) >> 32) & 0xffffffff );
+ }
+# define hton64(i) __hton64( i )
# define ntoh16 ntohs
# define ntoh32 ntohl
# define ntoh64 hton64
#endif
+#endif /* !defined( WIN32 ) */
/* Macros with automatic casts */
#define U64_AT(p) ( ntoh64 ( *( (u64 *)(p) ) ) )
* ourselves. ( several plugins use them and it is too much hassle to link
* winsock with each of them ;-)
*/
-# undef ntoh32(x)
-# undef ntoh16(x)
-# undef ntoh64(x)
-# undef hton32(x)
-# undef hton16(x)
-# undef hton64(x)
-
# ifdef WORDS_BIGENDIAN
# define ntoh32(x) (x)
# define ntoh16(x) (x)
# define ntoh64(x) __bswap_32 (x)
# define hton32(x) __bswap_32 (x)
# define hton16(x) __bswap_16 (x)
-# define hton64(x) __bswap_32 (x)
+# define hton64(x) __bswap_64 (x)
# endif
/* win32, cl and icl support */
-# if defined( _MSC_VER )
+# if defined( _MSC_VER ) || !defined( __MINGW32__ )
# define __attribute__(x)
# define __inline__ __inline
# define strncasecmp strnicmp
# define stat _stati64
# endif
+# if defined( __BORLANDC__ )
+# undef off_t
+# define off_t unsigned __int64
+# endif
+
+# ifndef O_NONBLOCK
+# define O_NONBLOCK 0
+# endif
+
# ifndef snprintf
# define snprintf _snprintf /* snprintf not defined in mingw32 (bug?) */
# endif
#else
# define _(String) (String)
# define N_(String) (String)
-# define textdomain(Domain)
-# define bindtextdomain(Package, Directory) 1
#endif
/*****************************************************************************
typedef struct module_symbols_s
{
struct main_s* p_main;
- struct aout_bank_s* p_aout_bank;
- struct vout_bank_s* p_vout_bank;
-
- int ( * main_GetIntVariable ) ( char *, int );
- char * ( * main_GetPszVariable ) ( char *, char * );
- void ( * main_PutIntVariable ) ( char *, int );
- void ( * main_PutPszVariable ) ( char *, char * );
-
- int ( * intf_ProcessKey ) ( struct intf_thread_s *, int );
- void ( * intf_AssignKey ) ( struct intf_thread_s *, int, int, int );
+ struct module_bank_s* p_module_bank;
+ struct input_bank_s* p_input_bank;
+ struct aout_bank_s* p_aout_bank;
+ struct vout_bank_s* p_vout_bank;
+
+ int ( * config_GetIntVariable ) ( const char * );
+ char * ( * config_GetPszVariable ) ( const char * );
+ void ( * config_PutIntVariable ) ( const char *, int );
+ void ( * config_PutPszVariable ) ( const char *, char * );
+ int ( * config_LoadConfigFile ) ( const char * );
+ int ( * config_SaveConfigFile ) ( const char * );
+ struct module_config_s * ( * config_FindConfig ) ( const char * );
+ struct module_config_s * ( * config_Duplicate ) ( struct module_s * );
+
+ struct intf_subscription_s * ( * intf_MsgSub ) ( void );
+ void ( * intf_MsgUnsub ) ( struct intf_subscription_s * );
void ( * intf_Msg ) ( char *, ... );
void ( * intf_ErrMsg ) ( char *, ... );
void ( * intf_StatMsg ) ( char *, ... );
void ( * intf_WarnMsg ) ( int, char *, ... );
- void ( * intf_WarnMsgImm ) ( int, char *, ... );
-#ifdef TRACE
- void ( * intf_DbgMsg ) ( char *, char *, int, char *, ... );
- void ( * intf_DbgMsgImm ) ( char *, char *, int, char *, ... );
-#endif
int ( * intf_PlaylistAdd ) ( struct playlist_s *, int, const char* );
int ( * intf_PlaylistDelete ) ( struct playlist_s *, int );
void ( * intf_PlaylistDestroy ) ( struct playlist_s * );
void ( * intf_PlaylistJumpto ) ( struct playlist_s *, int );
void ( * intf_UrlDecode ) ( char * );
+ int ( * intf_Eject ) ( const char * );
- void ( * msleep ) ( mtime_t );
- mtime_t ( * mdate ) ( void );
+ void ( * msleep ) ( mtime_t );
+ mtime_t ( * mdate ) ( void );
+ char * ( * mstrtime ) ( char *, mtime_t );
int ( * network_ChannelCreate )( void );
int ( * network_ChannelJoin ) ( int );
struct es_descriptor_s *, boolean_t );
int ( * input_ChangeArea ) ( struct input_thread_s *,
struct input_area_s * );
+ int ( * input_ChangeProgram ) ( struct input_thread_s *, u16 );
struct es_descriptor_s * ( * input_FindES ) ( struct input_thread_s *,
u16 );
struct es_descriptor_s * ( * input_AddES ) ( struct input_thread_s *,
void ( * ) ( struct bit_stream_s *,
boolean_t ),
void * );
+ void ( * BitstreamNextDataPacket )( struct bit_stream_s * );
+ boolean_t ( * NextDataPacket ) ( struct decoder_fifo_s *,
+ struct data_packet_s ** );
void ( * DecoderError ) ( struct decoder_fifo_s * p_fifo );
int ( * input_InitStream ) ( struct input_thread_s *, size_t );
void ( * input_EndStream ) ( struct input_thread_s * );
struct pes_packet_s * );
struct es_descriptor_s * ( * input_ParsePS ) ( struct input_thread_s *,
struct data_packet_s * );
+ ssize_t ( * input_ReadPS ) ( struct input_thread_s *,
+ struct data_packet_s ** );
void ( * input_DemuxPS ) ( struct input_thread_s *,
struct data_packet_s * );
+ ssize_t ( * input_ReadTS ) ( struct input_thread_s *,
+ struct data_packet_s ** );
void ( * input_DemuxTS ) ( struct input_thread_s *,
struct data_packet_s * );
void ( * input_DemuxPSI ) ( struct input_thread_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 );
-
- struct aout_fifo_s * ( * aout_CreateFifo )
- ( int, int, long, long, long, void * );
+ 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 * );
struct vout_thread_s * (* vout_CreateThread) ( int *, int, int, u32, int );
u32 ( * UnalignedShowBits ) ( struct bit_stream_s *, unsigned int );
void ( * UnalignedRemoveBits ) ( struct bit_stream_s * );
u32 ( * UnalignedGetBits ) ( struct bit_stream_s *, unsigned int );
+ void ( * CurrentPTS ) ( struct bit_stream_s *, mtime_t *,
+ mtime_t * );
char * ( * DecodeLanguage ) ( u16 );
- struct module_s * ( * module_Need ) ( int, char *, struct probedata_s * );
- void ( * module_Unneed ) ( struct module_s * );
+ struct module_s * ( * module_Need ) ( int, char *, void * );
+ void ( * module_Unneed ) ( struct module_s * );
+
} module_symbols_t;
#ifdef PLUGIN