]> git.sesse.net Git - vlc/blobdiff - include/common.h
* ./AUTHORS: added people locations, just for fun.
[vlc] / include / common.h
index 526170106557fd1856fe191f5d7cf364149c5b02..7972b6ad8f77aaea852bef349046c06c76aa1c61 100644 (file)
@@ -3,7 +3,7 @@
  * 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.94 2002/04/17 11:43:31 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
+
+#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)
@@ -61,6 +84,10 @@ typedef int                 ptrdiff_t;
 #   endif
 #endif
 
+#if defined( WIN32 )
+typedef int                 ssize_t;
+#endif
+
 /* Counter for statistics and profiling */
 typedef unsigned long       count_t;
 
@@ -86,6 +113,11 @@ typedef s64 mtime_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;
@@ -93,13 +125,16 @@ 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;
@@ -167,7 +202,9 @@ struct pgrm_descriptor_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
@@ -260,6 +297,10 @@ struct probedata_s;
                     __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 */
@@ -273,12 +314,12 @@ struct probedata_s;
 /* 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
@@ -286,8 +327,7 @@ struct probedata_s;
  * 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
@@ -298,11 +338,17 @@ struct probedata_s;
 #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) ) ) )
@@ -316,21 +362,33 @@ struct probedata_s;
 #   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
 
 
@@ -340,13 +398,6 @@ struct probedata_s;
  * 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)
@@ -360,20 +411,21 @@ struct probedata_s;
 #       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
 
@@ -395,7 +447,15 @@ typedef __int64 off_t;
 #       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
@@ -421,13 +481,23 @@ typedef __int64 off_t;
 /*****************************************************************************
  * 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
 
 /*****************************************************************************
@@ -436,26 +506,28 @@ typedef __int64 off_t;
 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 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 * );
+    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 );
@@ -464,9 +536,11 @@ typedef struct module_symbols_s
     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 );
@@ -483,6 +557,7 @@ typedef struct module_symbols_s
                                       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 *,
@@ -506,6 +581,9 @@ typedef struct module_symbols_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 * );
@@ -520,21 +598,46 @@ typedef struct module_symbols_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 );
@@ -567,11 +670,14 @@ typedef struct module_symbols_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, 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