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 VLC authors and VideoLAN
00005  * Copyright © 2006-2007 Rémi Denis-Courmont
00006  * $Id: 4eec20bc48fdd931e7db59aaea8560a1ea593f40 $
00007  *
00008  * Authors: Vincent Seguin <seguin@via.ecp.fr>
00009  *
00010  * This program is free software; you can redistribute it and/or modify it
00011  * under the terms of the GNU Lesser General Public License as published by
00012  * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public License
00021  * along with this program; if not, write to the Free Software Foundation,
00022  * 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 extern const char psz_vlc_changeset[];
00029 
00030 typedef struct variable_t variable_t;
00031 
00032 /* Actions (hot keys) */
00033 struct vlc_actions;
00034 struct vlc_actions *vlc_InitActions (libvlc_int_t *);
00035 extern void vlc_DeinitActions (libvlc_int_t *, struct vlc_actions *);
00036 
00037 size_t vlc_towc (const char *str, uint32_t *restrict pwc);
00038 
00039 /*
00040  * OS-specific initialization
00041  */
00042 void system_Init      ( void );
00043 void system_Configure ( libvlc_int_t *, int, const char *const [] );
00044 void system_End       ( void );
00045 
00046 void vlc_CPU_init(void);
00047 void vlc_CPU_dump(vlc_object_t *);
00048 
00049 /*
00050  * Threads subsystem
00051  */
00052 
00053 /* This cannot be used as is from plugins yet: */
00054 int vlc_clone_detach (vlc_thread_t *, void *(*)(void *), void *, int);
00055 
00056 int vlc_object_waitpipe (vlc_object_t *obj);
00057 
00058 int vlc_set_priority( vlc_thread_t, int );
00059 
00060 void vlc_threads_setup (libvlc_int_t *);
00061 
00062 void vlc_trace (const char *fn, const char *file, unsigned line);
00063 #define vlc_backtrace() vlc_trace(__func__, __FILE__, __LINE__)
00064 
00065 #if defined (LIBVLC_USE_PTHREAD) && !defined (NDEBUG)
00066 void vlc_assert_locked (vlc_mutex_t *);
00067 #else
00068 # define vlc_assert_locked( m ) (void)m
00069 #endif
00070 
00071 /*
00072  * LibVLC exit event handling
00073  */
00074 typedef struct vlc_exit
00075 {
00076     vlc_mutex_t lock;
00077     void (*handler) (void *);
00078     void *opaque;
00079     bool killed;
00080 } vlc_exit_t;
00081 
00082 void vlc_ExitInit( vlc_exit_t * );
00083 void vlc_ExitDestroy( vlc_exit_t * );
00084 
00085 /*
00086  * LibVLC objects stuff
00087  */
00088 
00089 /**
00090  * Creates a VLC object.
00091  *
00092  * Note that because the object name pointer must remain valid, potentially
00093  * even after the destruction of the object (through the message queues), this
00094  * function CANNOT be exported to plugins as is. In this case, the old
00095  * vlc_object_create() must be used instead.
00096  *
00097  * @param p_this an existing VLC object
00098  * @param i_size byte size of the object structure
00099  * @param psz_type object type name
00100  * @return the created object, or NULL.
00101  */
00102 extern void *
00103 vlc_custom_create (vlc_object_t *p_this, size_t i_size, const char *psz_type);
00104 #define vlc_custom_create(o, s, n) \
00105         vlc_custom_create(VLC_OBJECT(o), s, n)
00106 
00107 /**
00108  * Assign a name to an object for vlc_object_find_name().
00109  */
00110 extern int vlc_object_set_name(vlc_object_t *, const char *);
00111 #define vlc_object_set_name(o, n) vlc_object_set_name(VLC_OBJECT(o), n)
00112 
00113 /* Types */
00114 typedef void (*vlc_destructor_t) (struct vlc_object_t *);
00115 void vlc_object_set_destructor (vlc_object_t *, vlc_destructor_t);
00116 #define vlc_object_set_destructor(a,b) \
00117         vlc_object_set_destructor (VLC_OBJECT(a), b)
00118 
00119 /*
00120  * To be cleaned-up module stuff:
00121  */
00122 module_t *module_find_by_shortcut (const char *psz_shortcut);
00123 
00124 /**
00125  * Private LibVLC data for each object.
00126  */
00127 typedef struct vlc_object_internals vlc_object_internals_t;
00128 
00129 struct vlc_object_internals
00130 {
00131     char           *psz_name; /* given name */
00132 
00133     /* Object variables */
00134     void           *var_root;
00135     vlc_mutex_t     var_lock;
00136     vlc_cond_t      var_wait;
00137 
00138     /* Objects thread synchronization */
00139     int             pipes[2];
00140 
00141     /* Objects management */
00142     vlc_spinlock_t   ref_spin;
00143     unsigned         i_refcount;
00144     vlc_destructor_t pf_destructor;
00145 
00146     /* Objects tree structure */
00147     vlc_object_internals_t *next;  /* next sibling */
00148     vlc_object_internals_t *prev;  /* previous sibling */
00149     vlc_object_internals_t *first; /* first child */
00150 };
00151 
00152 #define ZOOM_SECTION N_("Zoom")
00153 #define ZOOM_QUARTER_KEY_TEXT N_("1:4 Quarter")
00154 #define ZOOM_HALF_KEY_TEXT N_("1:2 Half")
00155 #define ZOOM_ORIGINAL_KEY_TEXT N_("1:1 Original")
00156 #define ZOOM_DOUBLE_KEY_TEXT N_("2:1 Double")
00157 
00158 #define vlc_internals( obj ) (((vlc_object_internals_t*)(VLC_OBJECT(obj)))-1)
00159 #define vlc_externals( priv ) ((vlc_object_t *)((priv) + 1))
00160 
00161 typedef struct sap_handler_t sap_handler_t;
00162 
00163 /**
00164  * Private LibVLC instance data.
00165  */
00166 typedef struct libvlc_priv_t
00167 {
00168     libvlc_int_t       public_data;
00169 
00170     bool               playlist_active;
00171 
00172     /* Messages */
00173     signed char        i_verbose;   ///< info messages
00174     bool               b_color;     ///< color messages?
00175     bool               b_stats;     ///< Whether to collect stats
00176 
00177     /* Singleton objects */
00178     module_t          *p_memcpy_module;  ///< Fast memcpy plugin used
00179     playlist_t        *p_playlist; ///< the playlist singleton
00180     struct media_library_t *p_ml;    ///< the ML singleton
00181     vlc_mutex_t       ml_lock; ///< Mutex for ML creation
00182     vlm_t             *p_vlm;  ///< the VLM singleton (or NULL)
00183     vlc_object_t      *p_dialog_provider; ///< dialog provider
00184 #ifdef ENABLE_SOUT
00185     sap_handler_t     *p_sap; ///< SAP SDP advertiser
00186 #endif
00187     struct vlc_actions *actions; ///< Hotkeys handler
00188 
00189     /* Interfaces */
00190     struct intf_thread_t *p_intf; ///< Interfaces linked-list
00191 
00192     /* Objects tree */
00193     vlc_mutex_t        structure_lock;
00194 
00195     /* Exit callback */
00196     vlc_exit_t       exit;
00197 } libvlc_priv_t;
00198 
00199 static inline libvlc_priv_t *libvlc_priv (libvlc_int_t *libvlc)
00200 {
00201     return (libvlc_priv_t *)libvlc;
00202 }
00203 
00204 void playlist_ServicesDiscoveryKillAll( playlist_t *p_playlist );
00205 void intf_DestroyAll( libvlc_int_t * );
00206 
00207 #define libvlc_stats( o ) (libvlc_priv((VLC_OBJECT(o))->p_libvlc)->b_stats)
00208 
00209 /*
00210  * Variables stuff
00211  */
00212 void var_OptionParse (vlc_object_t *, const char *, bool trusted);
00213 
00214 /*
00215  * Stats stuff
00216  */
00217 enum
00218 {
00219     STATS_COUNTER,
00220     STATS_DERIVATIVE,
00221 };
00222 
00223 typedef struct counter_sample_t
00224 {
00225     uint64_t value;
00226     mtime_t  date;
00227 } counter_sample_t;
00228 
00229 typedef struct counter_t
00230 {
00231     int                 i_compute_type;
00232     int                 i_samples;
00233     counter_sample_t ** pp_samples;
00234 
00235     mtime_t             last_update;
00236 } counter_t;
00237 
00238 enum
00239 {
00240     STATS_INPUT_BITRATE,
00241     STATS_READ_BYTES,
00242     STATS_READ_PACKETS,
00243     STATS_DEMUX_READ,
00244     STATS_DEMUX_BITRATE,
00245     STATS_DEMUX_CORRUPTED,
00246     STATS_DEMUX_DISCONTINUITY,
00247     STATS_PLAYED_ABUFFERS,
00248     STATS_LOST_ABUFFERS,
00249     STATS_DECODED_AUDIO,
00250     STATS_DECODED_VIDEO,
00251     STATS_DECODED_SUB,
00252     STATS_CLIENT_CONNECTIONS,
00253     STATS_ACTIVE_CONNECTIONS,
00254     STATS_SOUT_SENT_PACKETS,
00255     STATS_SOUT_SENT_BYTES,
00256     STATS_SOUT_SEND_BITRATE,
00257     STATS_DISPLAYED_PICTURES,
00258     STATS_LOST_PICTURES,
00259 };
00260 
00261 counter_t * stats_CounterCreate (int);
00262 void stats_Update (counter_t *, uint64_t, uint64_t *);
00263 void stats_CounterClean (counter_t * );
00264 
00265 void stats_ComputeInputStats(input_thread_t*, input_stats_t*);
00266 void stats_ReinitInputStats(input_stats_t *);
00267 
00268 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines