* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: common.h,v 1.57 2001/12/12 02:13:50 sam Exp $
+ * $Id: common.h,v 1.97 2002/04/24 00:36:24 sam Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
/*****************************************************************************
* Required system headers
*****************************************************************************/
-#include <string.h> /* strerror() */
+#ifdef HAVE_STRING_H
+# include <string.h> /* strerror() */
+#endif
-/*****************************************************************************
- * Required vlc headers
- *****************************************************************************/
-#include "config.h"
-#include "int_types.h"
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
/*****************************************************************************
* 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;
* Classes declaration
*****************************************************************************/
+/* System */
+struct main_sys_s;
+
+typedef struct main_sys_s * p_main_sys_t;
+
/* Plugins */
struct plugin_bank_s;
struct plugin_info_s;
typedef struct plugin_bank_s * p_plugin_bank_t;
typedef struct plugin_info_s * p_plugin_info_t;
-/* Plugins */
+/* Playlist */
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 vout_thread_s;
struct vout_font_s;
struct vout_sys_s;
+struct chroma_sys_s;
struct vdec_thread_s;
struct vpar_thread_s;
struct video_parser_s;
typedef struct vpar_thread_s * p_vpar_thread_t;
typedef struct video_parser_s * p_video_parser_t;
+/* Decoders */
+struct decoder_config_s;
+struct decoder_fifo_s;
+
/* Misc */
struct macroblock_s;
struct data_packet_s;
struct dm_par_s;
struct picture_s;
struct picture_sys_s;
+struct picture_heap_s;
struct es_descriptor_s;
struct pgrm_descriptor_s;
struct pes_packet_s;
struct input_area_s;
struct bit_stream_s;
-
-/* Decoders */
-struct decoder_config_s;
-struct decoder_fifo_s;
+struct input_buffers_s;
+struct network_socket_s;
+struct intf_subscription_s;
/*****************************************************************************
* Macros and inline functions
__r.__l[1] = __bswap_32 (__w.__l[0]); \
} \
__r.__ll; }))
+# else
+# define __bswap_64(i) \
+ (u64)((__bswap_32((i) & 0xffffffff) << 32) | \
+ __bswap_32(((i) >> 32) & 0xffffffff ))
# endif
#else /* NTOHL_IN_SYS_PARAM_H || WIN32 */
/* 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) ) ) )
# define ATTR_ALIGN(align)
#endif
-/* Alignment of critical dynamic data structure */
+/* Alignment of critical dynamic data structure
+ *
+ * Not all platforms support memalign so we provide a vlc_memalign wrapper
+ * void *vlc_memalign( size_t align, size_t size, void **pp_orig )
+ * *pp_orig is the pointer that has to be freed afterwards.
+ */
+#if 0
+#ifdef HAVE_POSIX_MEMALIGN
+# define vlc_memalign(align,size,pp_orig) \
+ ( !posix_memalign( pp_orig, align, size ) ? *(pp_orig) : NULL )
+#endif
+#endif
#ifdef HAVE_MEMALIGN
/* Some systems have memalign() but no declaration for it */
void * memalign( size_t align, size_t size );
-#else
-# ifdef HAVE_VALLOC
- /* That's like using a hammer to kill a fly, but eh... */
-# include <unistd.h>
-# define memalign(align,size) valloc(size)
-# else
- /* Assume malloc alignment is sufficient */
-# define memalign(align,size) malloc(size)
-# endif
+
+# define vlc_memalign(align,size,pp_orig) \
+ ( *(pp_orig) = memalign( align, size ) )
+
+#else /* We don't have any choice but to align manually */
+# define vlc_memalign(align,size,pp_orig) \
+ (( *(pp_orig) = malloc( size + align - 1 )) ? \
+ (void *)( (((unsigned long)*(pp_orig)) + 15) & ~0xFUL ) : NULL )
+
#endif
+
#define I64C(x) x##LL
* 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 strcasecmp stricmp
+# define S_IFBLK 0x3000 /* Block */
# define S_ISBLK(m) (0)
# define S_ISCHR(m) (0)
# define S_ISFIFO(m) (((m)&_S_IFMT) == _S_IFIFO)
# define S_ISREG(m) (((m)&_S_IFMT) == _S_IFREG)
-# undef I64C(x)
+# undef I64C
# define I64C(x) x##i64
# endif
# else
# define off_t __int64
# endif
-# 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
#endif
+/*****************************************************************************
+ * CPU capabilities
+ *****************************************************************************/
+#define CPU_CAPABILITY_NONE 0
+#define CPU_CAPABILITY_486 (1<<0)
+#define CPU_CAPABILITY_586 (1<<1)
+#define CPU_CAPABILITY_PPRO (1<<2)
+#define CPU_CAPABILITY_MMX (1<<3)
+#define CPU_CAPABILITY_3DNOW (1<<4)
+#define CPU_CAPABILITY_MMXEXT (1<<5)
+#define CPU_CAPABILITY_SSE (1<<6)
+#define CPU_CAPABILITY_ALTIVEC (1<<16)
+#define CPU_CAPABILITY_FPU (1<<31)
+
/*****************************************************************************
* I18n stuff
*****************************************************************************/
-#if defined( ENABLE_NLS ) && defined ( HAVE_GETTEXT )
+#ifndef PACKAGE /* Borland C++ uses this ! */
+#define PACKAGE VLC_PACKAGE
+#endif
+#define VERSION VLC_VERSION
+
+#if defined( ENABLE_NLS ) && defined ( HAVE_GETTEXT ) && !defined( __BORLANDC__ ) && !defined( MODULE_NAME_IS_gnome )
# include <libintl.h>
-#else
+# undef _
+# define _(String) dgettext (PACKAGE, String)
+# ifdef gettext_noop
+# define N_(String) gettext_noop (String)
+# else
+# define N_(String) (String)
+# endif
+#elif !defined( MODULE_NAME_IS_gnome )
# 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 ( * TestProgram ) ( char * );
- int ( * TestMethod ) ( char *, char * );
- int ( * TestCPU ) ( int );
-
- int ( * intf_ProcessKey ) ( struct intf_thread_s *, int );
- void ( * intf_AssignKey ) ( struct intf_thread_s *, int, int, int );
+ struct main_sys_s* p_main_sys;
+ 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 * );
+ float ( * config_GetFloatVariable ) ( const char * );
+ char * ( * config_GetPszVariable ) ( const char * );
+ void ( * config_PutIntVariable ) ( const char *, int );
+ void ( * config_PutFloatVariable ) ( const char *, float );
+ 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_config_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 );
-
- int ( * input_NetlistInit ) ( struct input_thread_s *,
- int, int, int, size_t, int );
- struct iovec * ( * input_NetlistGetiovec ) ( void * p_method_data );
- void ( * input_NetlistMviovec ) ( void * , int,
- struct data_packet_s **);
- struct data_packet_s * ( * input_NetlistNewPacket ) ( void *, size_t );
- struct data_packet_s * ( * input_NetlistNewPtr ) ( void * );
- struct pes_packet_s * ( * input_NetlistNewPES ) ( void * );
- void ( * input_NetlistDeletePacket ) ( void *, struct data_packet_s * );
- void ( * input_NetlistDeletePES ) ( void *, struct pes_packet_s * );
- void ( * input_NetlistEnd ) ( struct input_thread_s * );
-
- 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, int, int );
- struct subpicture_s * (* vout_CreateSubPicture) ( struct vout_thread_s *,
- int, int );
- struct picture_s * ( * vout_CreatePicture ) ( struct vout_thread_s *,
- int, int, int, int );
+ struct vout_thread_s * (* vout_CreateThread) ( int *, int, int, u32, int );
+ void ( * vout_DestroyThread ) ( struct vout_thread_s *, int * );
- void ( * vout_DestroySubPicture ) ( struct vout_thread_s *,
- struct subpicture_s * );
- void ( * vout_DisplaySubPicture ) ( struct vout_thread_s *,
- struct subpicture_s * );
+ struct picture_s * ( * vout_CreatePicture )
+ ( struct vout_thread_s *,
+ boolean_t, boolean_t, boolean_t );
+ void ( * vout_AllocatePicture )( struct picture_s *, int, int, u32 );
void ( * vout_DisplayPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_DestroyPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_LinkPicture ) ( struct vout_thread_s *,
struct picture_s * );
- void ( * vout_UnlinkPicture ) ( struct vout_thread_s *,
+ void ( * vout_UnlinkPicture ) ( struct vout_thread_s *,
struct picture_s * );
- void ( * vout_DatePicture ) ( struct vout_thread_s *p_vout,
- struct picture_s *p_pic, mtime_t );
+ void ( * vout_DatePicture ) ( struct vout_thread_s *,
+ struct picture_s *, mtime_t );
+ void ( * vout_PlacePicture ) ( struct vout_thread_s *, int, int,
+ int *, int *, int *, int * );
+
+ struct subpicture_s * (* vout_CreateSubPicture)
+ ( struct vout_thread_s *, int, int );
+ void ( * vout_DestroySubPicture ) ( struct vout_thread_s *,
+ struct subpicture_s * );
+ void ( * vout_DisplaySubPicture ) ( struct vout_thread_s *,
+ struct subpicture_s * );
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, void * );
- 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
+#ifdef __PLUGIN__
extern module_symbols_t* p_symbols;
#endif
-/*****************************************************************************
- * Required vlc headers
- *****************************************************************************/
-#include "main.h"
-