libvlc.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * libvlc.h: Internal libvlc generic/misc declaration
00003  *****************************************************************************
00004  * Copyright (C) 1999, 2000, 2001, 2002 the VideoLAN team
00005  * Copyright © 2006-2007 Rémi Denis-Courmont
00006  * $Id: f7da7b820875b547c5bb2bd71b256e4e32e03260 $
00007  *
00008  * Authors: Vincent Seguin <seguin@via.ecp.fr>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef LIBVLC_LIBVLC_H
00026 # define LIBVLC_LIBVLC_H 1
00027 
00028 typedef struct variable_t variable_t;
00029 
00030 /* Actions (hot keys) */
00031 typedef struct action
00032 {
00033     char name[24];
00034     int  value;
00035 } action_t;
00036 extern const struct action libvlc_actions[];
00037 extern const size_t libvlc_actions_count;
00038 extern int vlc_key_to_action (vlc_object_t *, const char *,
00039                               vlc_value_t, vlc_value_t, void *);
00040 
00041 /*
00042  * OS-specific initialization
00043  */
00044 void system_Init      ( libvlc_int_t *, int *, const char *[] );
00045 void system_Configure ( libvlc_int_t *, int *, const char *[] );
00046 void system_End       ( libvlc_int_t * );
00047 
00048 /*
00049  * Legacy object stuff that is still used within libvlccore (only)
00050  */
00051 #define vlc_object_signal_unlocked( obj )
00052 
00053 vlc_list_t *vlc_list_find( vlc_object_t *, int, int );
00054 
00055 /*
00056  * Threads subsystem
00057  */
00058 
00059 /* This cannot be used as is from plugins: */
00060 void vlc_detach (vlc_thread_t);
00061 
00062 /* Hopefully, no need to export this. There is a new thread API instead. */
00063 void vlc_thread_cancel (vlc_object_t *);
00064 int vlc_object_waitpipe (vlc_object_t *obj);
00065 
00066 void vlc_threads_setup (libvlc_int_t *);
00067 
00068 void vlc_trace (const char *fn, const char *file, unsigned line);
00069 #define vlc_backtrace() vlc_trace(__func__, __FILE__, __LINE__)
00070 
00071 #if defined (LIBVLC_USE_PTHREAD) && !defined (NDEBUG)
00072 void vlc_assert_locked (vlc_mutex_t *);
00073 #else
00074 # define vlc_assert_locked( m ) (void)m
00075 #endif
00076 
00077 /*
00078  * CPU capabilities
00079  */
00080 extern uint32_t cpu_flags;
00081 uint32_t CPUCapabilities( void );
00082 
00083 /*
00084  * Message/logging stuff
00085  */
00086 
00087 /**
00088  * Store all data required by messages interfaces.
00089  */
00090 typedef struct msg_bank_t
00091 {
00092     /** Message queue lock */
00093     vlc_rwlock_t lock;
00094 
00095     /* Subscribers */
00096     int i_sub;
00097     msg_subscription_t **pp_sub;
00098 
00099     /* Logfile for WinCE */
00100 #ifdef UNDER_CE
00101     FILE *logfile;
00102 #endif
00103 } msg_bank_t;
00104 
00105 void msg_Create  (libvlc_int_t *);
00106 void msg_Destroy (libvlc_int_t *);
00107 
00108 /** Internal message stack context */
00109 void msg_StackSet ( int, const char*, ... );
00110 void msg_StackAdd ( const char*, ... );
00111 const char* msg_StackMsg ( void );
00112 void msg_StackDestroy (void *);
00113 
00114 /*
00115  * Unicode stuff
00116  */
00117 char *vlc_fix_readdir (const char *);
00118 
00119 /*
00120  * LibVLC objects stuff
00121  */
00122 
00123 /**
00124  * Creates a VLC object.
00125  *
00126  * Note that because the object name pointer must remain valid, potentially
00127  * even after the destruction of the object (through the message queues), this
00128  * function CANNOT be exported to plugins as is. In this case, the old
00129  * vlc_object_create() must be used instead.
00130  *
00131  * @param p_this an existing VLC object
00132  * @param i_size byte size of the object structure
00133  * @param i_type object type, usually VLC_OBJECT_CUSTOM
00134  * @param psz_type object type name
00135  * @return the created object, or NULL.
00136  */
00137 extern void *
00138 __vlc_custom_create (vlc_object_t *p_this, size_t i_size, int i_type,
00139                      const char *psz_type);
00140 #define vlc_custom_create(o, s, t, n) \
00141         __vlc_custom_create(VLC_OBJECT(o), s, t, n)
00142 
00143 /**
00144  * Assign a name to an object for vlc_object_find_name().
00145  */
00146 extern int vlc_object_set_name(vlc_object_t *, const char *);
00147 #define vlc_object_set_name(o, n) vlc_object_set_name(VLC_OBJECT(o), n)
00148 
00149 /*
00150  * To be cleaned-up module stuff:
00151  */
00152 extern char *psz_vlcpath;
00153 
00154 /* Return a NULL terminated array with the names of the modules that have a
00155  * certain capability.
00156  * Free after uses both the string and the table. */
00157 char **module_GetModulesNamesForCapability (const char * psz_capability,
00158                                             char ***psz_longname);
00159 module_t *module_find_by_shortcut (const char *psz_shortcut);
00160 
00161 /**
00162  * Private LibVLC data for each object.
00163  */
00164 typedef struct vlc_object_internals_t
00165 {
00166     int             i_object_type; /* Object type, deprecated */
00167     char           *psz_name; /* given name */
00168 
00169     /* Object variables */
00170     variable_t *    p_vars;
00171     vlc_mutex_t     var_lock;
00172     vlc_cond_t      var_wait;
00173     int             i_vars;
00174 
00175     /* Thread properties, if any */
00176     vlc_thread_t    thread_id;
00177     bool            b_thread;
00178 
00179     /* Objects thread synchronization */
00180     int             pipes[2];
00181 
00182     /* Objects management */
00183     vlc_spinlock_t   ref_spin;
00184     unsigned         i_refcount;
00185     vlc_destructor_t pf_destructor;
00186 
00187     /* Objects tree structure */
00188     vlc_object_t   **pp_children;
00189     int              i_children;
00190 } vlc_object_internals_t;
00191 
00192 #define ZOOM_SECTION N_("Zoom")
00193 #define ZOOM_QUARTER_KEY_TEXT N_("1:4 Quarter")
00194 #define ZOOM_HALF_KEY_TEXT N_("1:2 Half")
00195 #define ZOOM_ORIGINAL_KEY_TEXT N_("1:1 Original")
00196 #define ZOOM_DOUBLE_KEY_TEXT N_("2:1 Double")
00197 
00198 #define vlc_internals( obj ) (((vlc_object_internals_t*)(VLC_OBJECT(obj)))-1)
00199 
00200 typedef struct sap_handler_t sap_handler_t;
00201 
00202 /**
00203  * Private LibVLC instance data.
00204  */
00205 typedef struct libvlc_priv_t
00206 {
00207     libvlc_int_t       public_data;
00208     vlc_cond_t         exiting; ///< signaled when VLC wants to exit
00209 
00210     int                i_last_input_id ; ///< Last id of input item
00211 
00212     /* Messages */
00213     msg_bank_t         msg_bank;    ///< The message bank
00214     int                i_verbose;   ///< info messages
00215     bool               b_color;     ///< color messages?
00216     vlc_dictionary_t   msg_enabled_objects; ///< Enabled objects
00217     bool               msg_all_objects_enabled; ///< Should we print all objects?
00218 
00219     /* Timer stats */
00220     vlc_mutex_t        timer_lock;  ///< Lock to protect timers
00221     counter_t        **pp_timers;   ///< Array of all timers
00222     int                i_timers;    ///< Number of timers
00223     bool               b_stats;     ///< Whether to collect stats
00224 
00225     /* Singleton objects */
00226     module_t          *p_memcpy_module;  ///< Fast memcpy plugin used
00227     playlist_t        *p_playlist; //< the playlist singleton
00228     vlm_t             *p_vlm;  ///< the VLM singleton (or NULL)
00229     vlc_object_t      *p_dialog_provider; ///< dialog provider
00230     httpd_t           *p_httpd; ///< HTTP daemon (src/network/httpd.c)
00231 #ifdef ENABLE_SOUT
00232     sap_handler_t     *p_sap; ///< SAP SDP advertiser
00233 #endif
00234 
00235     /* Interfaces */
00236     struct intf_thread_t *p_intf; ///< Interfaces linked-list
00237 
00238     /* Objects tree */
00239     vlc_mutex_t        structure_lock;
00240 } libvlc_priv_t;
00241 
00242 static inline libvlc_priv_t *libvlc_priv (libvlc_int_t *libvlc)
00243 {
00244     return (libvlc_priv_t *)libvlc;
00245 }
00246 
00247 void playlist_ServicesDiscoveryKillAll( playlist_t *p_playlist );
00248 void intf_DestroyAll( libvlc_int_t * );
00249 
00250 #define libvlc_stats( o ) (libvlc_priv((VLC_OBJECT(o))->p_libvlc)->b_stats)
00251 
00252 /**
00253  * LibVLC "main module" configuration settings array.
00254  */
00255 extern module_config_t libvlc_config[];
00256 extern const size_t libvlc_config_count;
00257 
00258 /*
00259  * Variables stuff
00260  */
00261 void var_OptionParse (vlc_object_t *, const char *, bool trusted);
00262 
00263 
00264 /*
00265  * Stats stuff
00266  */
00267 #define stats_Update(a,b,c) __stats_Update( VLC_OBJECT(a), b, c )
00268 int __stats_Update (vlc_object_t*, counter_t *, vlc_value_t, vlc_value_t *);
00269 #define stats_CounterCreate(a,b,c) __stats_CounterCreate( VLC_OBJECT(a), b, c )
00270 counter_t * __stats_CounterCreate (vlc_object_t*, int, int);
00271 #define stats_Get(a,b,c) __stats_Get( VLC_OBJECT(a), b, c)
00272 int __stats_Get (vlc_object_t*, counter_t *, vlc_value_t*);
00273 
00274 void stats_CounterClean (counter_t * );
00275 
00276 #define stats_GetInteger(a,b,c) __stats_GetInteger( VLC_OBJECT(a), b, c )
00277 static inline int __stats_GetInteger( vlc_object_t *p_obj, counter_t *p_counter,
00278                                       int *value )
00279 {
00280     int i_ret;
00281     vlc_value_t val; val.i_int = 0;
00282     if( !p_counter ) return VLC_EGENERIC;
00283     i_ret = __stats_Get( p_obj, p_counter, &val );
00284     *value = val.i_int;
00285     return i_ret;
00286 }
00287 
00288 #define stats_GetFloat(a,b,c) __stats_GetFloat( VLC_OBJECT(a), b, c )
00289 static inline int __stats_GetFloat( vlc_object_t *p_obj, counter_t *p_counter,
00290                                     float *value )
00291 {
00292     int i_ret;
00293     vlc_value_t val; val.f_float = 0.0;
00294     if( !p_counter ) return VLC_EGENERIC;
00295     i_ret = __stats_Get( p_obj, p_counter, &val );
00296     *value = val.f_float;
00297     return i_ret;
00298 }
00299 #define stats_UpdateInteger(a,b,c,d) __stats_UpdateInteger( VLC_OBJECT(a),b,c,d )
00300 static inline int __stats_UpdateInteger( vlc_object_t *p_obj,counter_t *p_co,
00301                                          int i, int *pi_new )
00302 {
00303     int i_ret;
00304     vlc_value_t val;
00305     vlc_value_t new_val; new_val.i_int = 0;
00306     if( !p_co ) return VLC_EGENERIC;
00307     val.i_int = i;
00308     i_ret = __stats_Update( p_obj, p_co, val, &new_val );
00309     if( pi_new )
00310         *pi_new = new_val.i_int;
00311     return i_ret;
00312 }
00313 #define stats_UpdateFloat(a,b,c,d) __stats_UpdateFloat( VLC_OBJECT(a),b,c,d )
00314 static inline int __stats_UpdateFloat( vlc_object_t *p_obj, counter_t *p_co,
00315                                        float f, float *pf_new )
00316 {
00317     vlc_value_t val;
00318     int i_ret;
00319     vlc_value_t new_val;new_val.f_float = 0.0;
00320     if( !p_co ) return VLC_EGENERIC;
00321     val.f_float = f;
00322     i_ret =  __stats_Update( p_obj, p_co, val, &new_val );
00323     if( pf_new )
00324         *pf_new = new_val.f_float;
00325     return i_ret;
00326 }
00327 
00328 VLC_EXPORT( void, stats_ComputeInputStats, (input_thread_t*, input_stats_t*) );
00329 VLC_EXPORT( void, stats_ReinitInputStats, (input_stats_t *) );
00330 VLC_EXPORT( void, stats_DumpInputStats, (input_stats_t *) );
00331 
00332 /*
00333  * Replacement functions
00334  */
00335 # ifndef HAVE_DIRENT_H
00336 typedef void DIR;
00337 #  ifndef FILENAME_MAX
00338 #      define FILENAME_MAX (260)
00339 #  endif
00340 struct dirent
00341 {
00342     long            d_ino;          /* Always zero. */
00343     unsigned short  d_reclen;       /* Always zero. */
00344     unsigned short  d_namlen;       /* Length of name in d_name. */
00345     char            d_name[FILENAME_MAX]; /* File name. */
00346 };
00347 #  define opendir vlc_opendir
00348 #  define readdir vlc_readdir
00349 #  define closedir vlc_closedir
00350 #  define rewinddir vlc_rewindir
00351 void *vlc_opendir (const char *);
00352 void *vlc_readdir (void *);
00353 int   vlc_closedir(void *);
00354 void  vlc_rewinddir(void *);
00355 # endif
00356 
00357 #if defined (WIN32)
00358 #   include <dirent.h>
00359 void *vlc_wopendir (const wchar_t *);
00360 /* void *vlc_wclosedir (void *); in vlc's exported symbols */
00361 struct _wdirent *vlc_wreaddir (void *);
00362 void vlc_rewinddir (void *);
00363 #   define _wopendir vlc_wopendir
00364 #   define _wreaddir vlc_wreaddir
00365 #   define _wclosedir vlc_wclosedir
00366 #   define rewinddir vlc_rewinddir
00367 #endif
00368 
00369 #endif

Generated on Sat Nov 21 08:05:24 2009 for VLC by  doxygen 1.5.6