]> git.sesse.net Git - vlc/blobdiff - include/common.h
* Added a win32 interface plugin, developed with Borland C++ Builder.
[vlc] / include / common.h
index 526170106557fd1856fe191f5d7cf364149c5b02..2b53a94d1c9cdc0049d715044b6c1c91055d7747 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.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)
@@ -61,6 +79,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;
 
@@ -97,9 +119,12 @@ typedef struct plugin_info_s *          p_plugin_info_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;
@@ -167,7 +192,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
@@ -273,12 +300,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 +313,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 +324,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) ) ) )
@@ -340,13 +372,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,11 +385,11 @@ 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
@@ -398,6 +423,15 @@ typedef __int64 off_t;
 #       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
@@ -426,8 +460,6 @@ typedef __int64 off_t;
 #else
 #   define _(String) (String)
 #   define N_(String) (String)
-#   define textdomain(Domain)
-#   define bindtextdomain(Package, Directory) 1
 #endif
 
 /*****************************************************************************
@@ -436,26 +468,27 @@ 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 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 +497,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 +518,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 +542,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 +559,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 +631,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