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
219 struct counter_sample_t
232 counter_sample_t ** pp_samples;
234 mtime_t update_interval;
238 struct stats_handler_t
243 counter_t **pp_counters;
246 VLC_EXPORT( void, stats_HandlerDestroy, (stats_handler_t*) );
248 #define stats_Update( a,b,c) __stats_Update( VLC_OBJECT( a ), b, c )
249 VLC_EXPORT( int, __stats_Update, (vlc_object_t*, char *, vlc_value_t) );
250 #define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
251 VLC_EXPORT( int, __stats_Create, (vlc_object_t*, char *, int, int) );
252 #define stats_Get( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
253 VLC_EXPORT( int, __stats_Get, (vlc_object_t*, int, char *, vlc_value_t*) );
254 #define stats_CounterGet( a,b,c) __stats_CounterGet( VLC_OBJECT(a), b, c )
255 VLC_EXPORT( counter_t*, __stats_CounterGet, (vlc_object_t*, int, char * ) );
257 #define stats_GetInteger( a,b,c,d ) __stats_GetInteger( VLC_OBJECT(a), b, c, d )
258 static inline int __stats_GetInteger( vlc_object_t *p_obj, int i_id,
259 char *psz_name, int *value )
262 int i_ret = __stats_Get( p_obj, i_id, psz_name, &val );
267 #define stats_GetFloat(a,b,c,d ) __stats_GetFloat( VLC_OBJECT(a), b, c, d )
268 static inline int __stats_GetFloat( vlc_object_t *p_obj, int i_id,
269 char *psz_name, float *value )
272 int i_ret = __stats_Get( p_obj, i_id, psz_name, &val );
273 *value = val.f_float;
276 #define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c )
277 static inline int __stats_UpdateInteger( vlc_object_t *p_obj, char *psz_name,
282 return __stats_Update( p_obj, psz_name, val );
284 #define stats_UpdateFloat( a,b,c ) __stats_UpdateFloat( VLC_OBJECT(a),b,c )
285 static inline int __stats_UpdateFloat( vlc_object_t *p_obj, char *psz_name,
290 return __stats_Update( p_obj, psz_name, val );
301 float f_input_bitrate;
302 float f_average_input_bitrate;
305 int i_demux_read_packets;
306 int i_demux_read_bytes;
307 float f_demux_bitrate;
308 float f_average_demux_bitrate;
315 int i_displayed_pictures;
319 VLC_EXPORT( void, stats_ComputeInputStats, (input_thread_t*, input_stats_t*) );
320 VLC_EXPORT( void, stats_ReinitInputStats, (input_stats_t *) );
321 VLC_EXPORT( void, stats_DumpInputStats, (input_stats_t *) );