vlc_messages.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * messages.h: messages interface
00003  * This library provides basic functions for threads to interact with user
00004  * interface, such as message output.
00005  *****************************************************************************
00006  * Copyright (C) 1999, 2000, 2001, 2002 the VideoLAN team
00007  * $Id$
00008  *
00009  * Authors: Vincent Seguin <seguin@via.ecp.fr>
00010  *          Samuel Hocevar <sam@zoy.org>
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00025  *****************************************************************************/
00026 
00027 #ifndef VLC_MESSAGES_H_
00028 #define VLC_MESSAGES_H_
00029 
00030 #include <stdarg.h>
00031 
00032 /**
00033  * \defgroup messages Messages
00034  * This library provides basic functions for threads to interact with user
00035  * interface, such as message output.
00036  *
00037  * @{
00038  */
00039 
00040 /**
00041  * Store a single message sent to user.
00042  */
00043 typedef struct
00044 {
00045     int     i_type;                             /**< message type, see below */
00046     int     i_object_id;
00047     const char *psz_object_type;
00048     char *  psz_module;
00049     char *  psz_msg;                            /**< the message itself */
00050     char *  psz_header;                         /**< Additional header */
00051 
00052     mtime_t date;                               /**< Message date */
00053 } msg_item_t;
00054 
00055 /* Message types */
00056 /** standard messages */
00057 #define VLC_MSG_INFO  0
00058 /** error messages */
00059 #define VLC_MSG_ERR   1
00060 /** warning messages */
00061 #define VLC_MSG_WARN  2
00062 /** debug messages */
00063 #define VLC_MSG_DBG   3
00064 
00065 /**
00066  * Used by interface plugins which subscribe to the message bank.
00067  */
00068 struct msg_subscription_t
00069 {
00070     int   i_start;
00071     int*  pi_stop;
00072 
00073     msg_item_t*  p_msg;
00074     vlc_mutex_t* p_lock;
00075 };
00076 
00077 /*****************************************************************************
00078  * Prototypes
00079  *****************************************************************************/
00080 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, const char *, const char *, ... ) LIBVLC_FORMAT( 4, 5 ) );
00081 VLC_EXPORT( void, __msg_GenericVa, ( vlc_object_t *, int, const char *, const char *, va_list args ) );
00082 #define msg_GenericVa(a, b, c, d, e) __msg_GenericVa(VLC_OBJECT(a), b, c, d, e)
00083 VLC_EXPORT( void, __msg_Info,    ( vlc_object_t *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) );
00084 VLC_EXPORT( void, __msg_Err,     ( vlc_object_t *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) );
00085 VLC_EXPORT( void, __msg_Warn,    ( vlc_object_t *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) );
00086 VLC_EXPORT( void, __msg_Dbg,    ( vlc_object_t *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) );
00087 
00088 #define msg_Info( p_this, ... ) \
00089       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_INFO, \
00090                      MODULE_STRING, __VA_ARGS__ )
00091 #define msg_Err( p_this, ... ) \
00092       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_ERR, \
00093                      MODULE_STRING, __VA_ARGS__ )
00094 #define msg_Warn( p_this, ... ) \
00095       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_WARN, \
00096                      MODULE_STRING, __VA_ARGS__ )
00097 #define msg_Dbg( p_this, ... ) \
00098       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_DBG, \
00099                      MODULE_STRING, __VA_ARGS__ )
00100 
00101 #define msg_Subscribe(a) __msg_Subscribe(VLC_OBJECT(a))
00102 #define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b)
00103 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t * ) );
00104 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
00105 
00106 /**
00107  * @}
00108  */
00109 
00110 /**
00111  * \defgroup statistics Statistics
00112  *
00113  * @{
00114  */
00115 
00116 /****************************
00117  * Generic stats stuff
00118  ****************************/
00119 enum
00120 {
00121     STATS_LAST,
00122     STATS_COUNTER,
00123     STATS_MAX,
00124     STATS_MIN,
00125     STATS_DERIVATIVE,
00126     STATS_TIMER
00127 };
00128 
00129 struct counter_sample_t
00130 {
00131     vlc_value_t value;
00132     mtime_t     date;
00133 };
00134 
00135 struct counter_t
00136 {
00137     unsigned int        i_id;
00138     char              * psz_name;
00139     int                 i_type;
00140     void              * p_obj;
00141     int                 i_compute_type;
00142     int                 i_samples;
00143     counter_sample_t ** pp_samples;
00144 
00145     mtime_t             update_interval;
00146     mtime_t             last_update;
00147 };
00148 
00149 enum
00150 {
00151     STATS_INPUT_BITRATE,
00152     STATS_READ_BYTES,
00153     STATS_READ_PACKETS,
00154     STATS_DEMUX_READ,
00155     STATS_DEMUX_BITRATE,
00156     STATS_PLAYED_ABUFFERS,
00157     STATS_LOST_ABUFFERS,
00158     STATS_DECODED_AUDIO,
00159     STATS_DECODED_VIDEO,
00160     STATS_DECODED_SUB,
00161     STATS_CLIENT_CONNECTIONS,
00162     STATS_ACTIVE_CONNECTIONS,
00163     STATS_SOUT_SENT_PACKETS,
00164     STATS_SOUT_SENT_BYTES,
00165     STATS_SOUT_SEND_BITRATE,
00166     STATS_DISPLAYED_PICTURES,
00167     STATS_LOST_PICTURES,
00168 
00169     STATS_TIMER_PLAYLIST_BUILD,
00170     STATS_TIMER_ML_LOAD,
00171     STATS_TIMER_ML_DUMP,
00172     STATS_TIMER_INTERACTION,
00173     STATS_TIMER_PREPARSE,
00174     STATS_TIMER_INPUT_LAUNCHING,
00175     STATS_TIMER_MODULE_NEED,
00176     STATS_TIMER_VIDEO_FRAME_ENCODING,
00177     STATS_TIMER_AUDIO_FRAME_ENCODING,
00178 
00179     STATS_TIMER_SKINS_PLAYTREE_IMAGE,
00180 };
00181 
00182 #define stats_Update(a,b,c) __stats_Update( VLC_OBJECT(a), b, c )
00183 VLC_EXPORT( int, __stats_Update, (vlc_object_t*, counter_t *, vlc_value_t, vlc_value_t *) );
00184 #define stats_CounterCreate(a,b,c) __stats_CounterCreate( VLC_OBJECT(a), b, c )
00185 VLC_EXPORT( counter_t *, __stats_CounterCreate, (vlc_object_t*, int, int) );
00186 #define stats_Get(a,b,c) __stats_Get( VLC_OBJECT(a), b, c)
00187 VLC_EXPORT( int, __stats_Get, (vlc_object_t*, counter_t *, vlc_value_t*) );
00188 
00189 VLC_EXPORT (void, stats_CounterClean, (counter_t * ) );
00190 
00191 #define stats_GetInteger(a,b,c) __stats_GetInteger( VLC_OBJECT(a), b, c )
00192 static inline int __stats_GetInteger( vlc_object_t *p_obj, counter_t *p_counter,
00193                                       int *value )
00194 {
00195     int i_ret;
00196     vlc_value_t val; val.i_int = 0;
00197     if( !p_counter ) return VLC_EGENERIC;
00198     i_ret = __stats_Get( p_obj, p_counter, &val );
00199     *value = val.i_int;
00200     return i_ret;
00201 }
00202 
00203 #define stats_GetFloat(a,b,c) __stats_GetFloat( VLC_OBJECT(a), b, c )
00204 static inline int __stats_GetFloat( vlc_object_t *p_obj, counter_t *p_counter,
00205                                     float *value )
00206 {
00207     int i_ret;
00208     vlc_value_t val; val.f_float = 0.0;
00209     if( !p_counter ) return VLC_EGENERIC;
00210     i_ret = __stats_Get( p_obj, p_counter, &val );
00211     *value = val.f_float;
00212     return i_ret;
00213 }
00214 #define stats_UpdateInteger(a,b,c,d) __stats_UpdateInteger( VLC_OBJECT(a),b,c,d )
00215 static inline int __stats_UpdateInteger( vlc_object_t *p_obj,counter_t *p_co,
00216                                          int i, int *pi_new )
00217 {
00218     int i_ret;
00219     vlc_value_t val;
00220     vlc_value_t new_val; new_val.i_int = 0;
00221     if( !p_co ) return VLC_EGENERIC;
00222     val.i_int = i;
00223     i_ret = __stats_Update( p_obj, p_co, val, &new_val );
00224     if( pi_new )
00225         *pi_new = new_val.i_int;
00226     return i_ret;
00227 }
00228 #define stats_UpdateFloat(a,b,c,d) __stats_UpdateFloat( VLC_OBJECT(a),b,c,d )
00229 static inline int __stats_UpdateFloat( vlc_object_t *p_obj, counter_t *p_co,
00230                                        float f, float *pf_new )
00231 {
00232     vlc_value_t val;
00233     int i_ret;
00234     vlc_value_t new_val;new_val.f_float = 0.0;
00235     if( !p_co ) return VLC_EGENERIC;
00236     val.f_float = f;
00237     i_ret =  __stats_Update( p_obj, p_co, val, &new_val );
00238     if( pf_new )
00239         *pf_new = new_val.f_float;
00240     return i_ret;
00241 }
00242 
00243 /******************
00244  * Input stats
00245  ******************/
00246 struct input_stats_t
00247 {
00248     vlc_mutex_t         lock;
00249 
00250     /* Input */
00251     int i_read_packets;
00252     int i_read_bytes;
00253     float f_input_bitrate;
00254     float f_average_input_bitrate;
00255 
00256     /* Demux */
00257     int i_demux_read_packets;
00258     int i_demux_read_bytes;
00259     float f_demux_bitrate;
00260     float f_average_demux_bitrate;
00261 
00262     /* Decoders */
00263     int i_decoded_audio;
00264     int i_decoded_video;
00265 
00266     /* Vout */
00267     int i_displayed_pictures;
00268     int i_lost_pictures;
00269 
00270     /* Sout */
00271     int i_sent_packets;
00272     int i_sent_bytes;
00273     float f_send_bitrate;
00274 
00275     /* Aout */
00276     int i_played_abuffers;
00277     int i_lost_abuffers;
00278 };
00279 
00280 VLC_EXPORT( void, stats_ComputeInputStats, (input_thread_t*, input_stats_t*) );
00281 VLC_EXPORT( void, stats_ReinitInputStats, (input_stats_t *) );
00282 VLC_EXPORT( void, stats_DumpInputStats, (input_stats_t *) );
00283 
00284 /********************
00285  * Global stats
00286  *******************/
00287 struct global_stats_t
00288 {
00289     vlc_mutex_t lock;
00290 
00291     float f_input_bitrate;
00292     float f_demux_bitrate;
00293     float f_output_bitrate;
00294 
00295     int i_http_clients;
00296 };
00297 
00298 #define stats_ComputeGlobalStats(a,b) __stats_ComputeGlobalStats( VLC_OBJECT(a),b)
00299 VLC_EXPORT( void, __stats_ComputeGlobalStats, (vlc_object_t*,global_stats_t*));
00300 
00301 
00302 /*********
00303  * Timing
00304  ********/
00305 #define stats_TimerStart(a,b,c) __stats_TimerStart( VLC_OBJECT(a), b,c )
00306 #define stats_TimerStop(a,b) __stats_TimerStop( VLC_OBJECT(a), b )
00307 #define stats_TimerDump(a,b) __stats_TimerDump( VLC_OBJECT(a), b )
00308 #define stats_TimersDumpAll(a) __stats_TimersDumpAll( VLC_OBJECT(a) )
00309 VLC_EXPORT( void,__stats_TimerStart, (vlc_object_t*, const char *, unsigned int ) );
00310 VLC_EXPORT( void,__stats_TimerStop, (vlc_object_t*, unsigned int) );
00311 VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, unsigned int) );
00312 VLC_EXPORT( void,__stats_TimersDumpAll, (vlc_object_t*) );
00313 #define stats_TimersCleanAll(a) __stats_TimersCleanAll( VLC_OBJECT(a) )
00314 VLC_EXPORT( void, __stats_TimersCleanAll, (vlc_object_t * ) );
00315 
00316 #define stats_TimerClean(a,b) __stats_TimerClean( VLC_OBJECT(a), b )
00317 VLC_EXPORT( void, __stats_TimerClean, (vlc_object_t *, unsigned int ) );
00318 
00319 #endif

Generated on Wed Aug 13 08:02:37 2008 for VLC by  doxygen 1.5.1