1 /*****************************************************************************
2 * messages.h: messages interface
3 * This library provides basic functions for threads to interact with user
4 * interface, such as message output.
5 *****************************************************************************
6 * Copyright (C) 1999, 2000, 2001, 2002 the VideoLAN team
9 * Authors: Vincent Seguin <seguin@via.ecp.fr>
10 * Samuel Hocevar <sam@zoy.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
29 int vlc_mutex_lock( vlc_mutex_t * ) ;
30 int vlc_mutex_unlock( vlc_mutex_t * ) ;
33 * \defgroup messages Messages
34 * This library provides basic functions for threads to interact with user
35 * interface, such as message output.
42 * Store a single message.
46 int i_type; /**< message type, see below */
50 char * psz_msg; /**< the message itself */
51 char * psz_header; /**< Additional header */
53 mtime_t date; /**< Message date */
57 /** standard messages */
58 #define VLC_MSG_INFO 0
61 /** warning messages */
62 #define VLC_MSG_WARN 2
66 #define MSG_QUEUE_NORMAL 0
67 #define MSG_QUEUE_HTTPD_ACCESS 1
70 * Store all data requiered by messages interfaces.
76 msg_queue_t **pp_queues;
83 /** Message queue lock */
85 vlc_bool_t b_overflow;
88 msg_item_t msg[VLC_MSG_QSIZE]; /**< message queue */
94 msg_subscription_t **pp_sub;
96 /* Logfile for WinCE */
103 * Used by interface plugins which subscribe to the message bank.
105 struct msg_subscription_t
114 /*****************************************************************************
116 *****************************************************************************/
117 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 5, 6 ) );
118 VLC_EXPORT( void, __msg_GenericVa, ( vlc_object_t *, int, int, const char *, const char *, va_list args ) );
119 #define msg_GenericVa(a, b, c, d, e,f) __msg_GenericVa(VLC_OBJECT(a), b, c, d, e,f)
120 VLC_EXPORT( void, __msg_Info, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
121 VLC_EXPORT( void, __msg_Err, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
122 VLC_EXPORT( void, __msg_Warn, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
123 VLC_EXPORT( void, __msg_Dbg, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
125 #ifdef HAVE_VARIADIC_MACROS
127 # define msg_Info( p_this, psz_format, args... ) \
128 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL,VLC_MSG_INFO, MODULE_STRING, \
129 psz_format, ## args )
131 # define msg_Err( p_this, psz_format, args... ) \
132 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_ERR, MODULE_STRING, \
133 psz_format, ## args )
135 # define msg_Warn( p_this, psz_format, args... ) \
136 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_WARN, MODULE_STRING, \
137 psz_format, ## args )
139 # define msg_Dbg( p_this, psz_format, args... ) \
140 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_DBG, MODULE_STRING, \
141 psz_format, ## args )
143 #elif defined(_MSC_VER) /* To avoid warnings and even errors with c++ files */
145 inline void msg_Info( void *p_this, const char *psz_format, ... )
148 va_start( ap, psz_format );
149 __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL,VLC_MSG_INFO, MODULE_STRING,
153 inline void msg_Err( void *p_this, const char *psz_format, ... )
156 va_start( ap, psz_format );
157 __msg_GenericVa( ( vlc_object_t *)p_this,MSG_QUEUE_NORMAL, VLC_MSG_ERR, MODULE_STRING,
161 inline void msg_Warn( void *p_this, const char *psz_format, ... )
164 va_start( ap, psz_format );
165 __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL, VLC_MSG_WARN, MODULE_STRING,
169 inline void msg_Dbg( void *p_this, const char *psz_format, ... )
172 va_start( ap, psz_format );
173 __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL, VLC_MSG_DBG, MODULE_STRING,
180 # define msg_Info __msg_Info
181 # define msg_Err __msg_Err
182 # define msg_Warn __msg_Warn
183 # define msg_Dbg __msg_Dbg
185 #endif /* HAVE_VARIADIC_MACROS */
187 #define msg_Create(a) __msg_Create(VLC_OBJECT(a))
188 #define msg_Flush(a) __msg_Flush(VLC_OBJECT(a))
189 #define msg_Destroy(a) __msg_Destroy(VLC_OBJECT(a))
190 void __msg_Create ( vlc_object_t * );
191 void __msg_Flush ( vlc_object_t * );
192 void __msg_Destroy ( vlc_object_t * );
194 #define msg_Subscribe(a,b) __msg_Subscribe(VLC_OBJECT(a),b)
195 #define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b)
196 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t *, int ) );
197 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
205 * \defgroup statistics Statistics
210 /****************************
211 * Generic stats stuff
212 ****************************/
223 struct counter_sample_t
231 /* The list is *NOT* sorted at the moment, it could be ... */
237 counter_sample_t ** pp_samples;
239 mtime_t update_interval;
250 STATS_PLAYED_ABUFFERS,
255 STATS_CLIENT_CONNECTIONS,
256 STATS_ACTIVE_CONNECTIONS,
257 STATS_SOUT_SENT_PACKETS,
258 STATS_SOUT_SENT_BYTES,
259 STATS_SOUT_SEND_BITRATE,
260 STATS_DISPLAYED_PICTURES,
263 STATS_TIMER_PLAYLIST_WALK,
264 STATS_TIMER_INTERACTION,
265 STATS_TIMER_PREPARSE,
267 STATS_TIMER_SKINS_PLAYTREE_IMAGE,
270 struct stats_handler_t
275 counter_t **pp_counters;
278 VLC_EXPORT( void, stats_HandlerDestroy, (stats_handler_t*) );
280 #define stats_Update(a,b,c,d) __stats_Update( VLC_OBJECT( a ), b, c, d )
281 VLC_EXPORT( int, __stats_Update, (vlc_object_t*, unsigned int, vlc_value_t, vlc_value_t *) );
282 #define stats_Create(a,b,c,d,e) __stats_Create( VLC_OBJECT(a), b, c, d,e )
283 VLC_EXPORT( int, __stats_Create, (vlc_object_t*, const char *, unsigned int, int, int) );
284 #define stats_Get(a,b,c,d) __stats_Get( VLC_OBJECT(a), b, c, d )
285 VLC_EXPORT( int, __stats_Get, (vlc_object_t*, int, unsigned int, vlc_value_t*) );
286 #define stats_CounterGet(a,b,c) __stats_CounterGet( VLC_OBJECT(a), b, c )
287 VLC_EXPORT( counter_t*, __stats_CounterGet, (vlc_object_t*, int, unsigned int ) );
289 #define stats_GetInteger(a,b,c,d) __stats_GetInteger( VLC_OBJECT(a), b, c, d )
290 static inline int __stats_GetInteger( vlc_object_t *p_obj, int i_id,
291 unsigned int i_counter, int *value )
294 int i_ret = __stats_Get( p_obj, i_id, i_counter, &val );
299 #define stats_GetFloat(a,b,c,d) __stats_GetFloat( VLC_OBJECT(a), b, c, d )
300 static inline int __stats_GetFloat( vlc_object_t *p_obj, int i_id,
301 unsigned int i_counter, float *value )
304 int i_ret = __stats_Get( p_obj, i_id, i_counter, &val );
305 *value = val.f_float;
308 #define stats_UpdateInteger(a,b,c,d) __stats_UpdateInteger( VLC_OBJECT(a),b,c,d )
309 static inline int __stats_UpdateInteger( vlc_object_t *p_obj,
310 unsigned int i_counter, int i,
317 i_ret = __stats_Update( p_obj, i_counter, val , &new_val );
319 *pi_new = new_val.i_int;
322 #define stats_UpdateFloat(a,b,c,d) __stats_UpdateFloat( VLC_OBJECT(a),b,c,d )
323 static inline int __stats_UpdateFloat( vlc_object_t *p_obj,
324 unsigned int i_counter, float f,
331 i_ret = __stats_Update( p_obj, i_counter, val, &new_val );
333 *pf_new = new_val.f_float;
347 float f_input_bitrate;
348 float f_average_input_bitrate;
351 int i_demux_read_packets;
352 int i_demux_read_bytes;
353 float f_demux_bitrate;
354 float f_average_demux_bitrate;
361 int i_displayed_pictures;
367 float f_send_bitrate;
370 int i_played_abuffers;
374 VLC_EXPORT( void, stats_ComputeInputStats, (input_thread_t*, input_stats_t*) );
375 VLC_EXPORT( void, stats_ReinitInputStats, (input_stats_t *) );
376 VLC_EXPORT( void, stats_DumpInputStats, (input_stats_t *) );
378 /********************
381 struct global_stats_t
385 float f_input_bitrate;
386 float f_demux_bitrate;
387 float f_output_bitrate;
392 #define stats_ComputeGlobalStats(a,b) __stats_ComputeGlobalStats( VLC_OBJECT(a),b)
393 VLC_EXPORT( void, __stats_ComputeGlobalStats, (vlc_object_t*,global_stats_t*));
400 #define stats_TimerStart(a,b,c) __stats_TimerStart( VLC_OBJECT(a), b,c )
401 #define stats_TimerStop(a,b) __stats_TimerStop( VLC_OBJECT(a), b )
402 #define stats_TimerDump(a,b) __stats_TimerDump( VLC_OBJECT(a), b )
403 #define stats_TimersDumpAll(a) __stats_TimersDumpAll( VLC_OBJECT(a) )
405 #define stats_TimerStart(a,b,c) {}
406 #define stats_TimerStop(a,b) {}
407 #define stats_TimerDump(a,b) {}
408 #define stats_TimersDumpAll(a) {}
410 VLC_EXPORT( void,__stats_TimerStart, (vlc_object_t*, const char *, unsigned int ) );
411 VLC_EXPORT( void,__stats_TimerStop, (vlc_object_t*, unsigned int) );
412 VLC_EXPORT( void,__stats_TimerDump, (vlc_object_t*, unsigned int) );
413 VLC_EXPORT( void,__stats_TimersDumpAll, (vlc_object_t*) );