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 */
52 mtime_t date; /**< Message date */
56 /** standard messages */
57 #define VLC_MSG_INFO 0
60 /** warning messages */
61 #define VLC_MSG_WARN 2
65 #define MSG_QUEUE_NORMAL 0
66 #define MSG_QUEUE_HTTPD_ACCESS 1
69 * Store all data requiered by messages interfaces.
75 msg_queue_t **pp_queues;
82 /** Message queue lock */
84 vlc_bool_t b_overflow;
87 msg_item_t msg[VLC_MSG_QSIZE]; /**< message queue */
93 msg_subscription_t **pp_sub;
95 /* Logfile for WinCE */
102 * Used by interface plugins which subscribe to the message bank.
104 struct msg_subscription_t
113 /*****************************************************************************
115 *****************************************************************************/
116 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 5, 6 ) );
117 VLC_EXPORT( void, __msg_GenericVa, ( vlc_object_t *, int, int, const char *, const char *, va_list args ) );
118 #define msg_GenericVa(a, b, c, d, e,f) __msg_GenericVa(VLC_OBJECT(a), b, c, d, e,f)
119 VLC_EXPORT( void, __msg_Info, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
120 VLC_EXPORT( void, __msg_Err, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
121 VLC_EXPORT( void, __msg_Warn, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
122 VLC_EXPORT( void, __msg_Dbg, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
124 #ifdef HAVE_VARIADIC_MACROS
126 # define msg_Info( p_this, psz_format, args... ) \
127 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL,VLC_MSG_INFO, MODULE_STRING, \
128 psz_format, ## args )
130 # define msg_Err( p_this, psz_format, args... ) \
131 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_ERR, MODULE_STRING, \
132 psz_format, ## args )
134 # define msg_Warn( p_this, psz_format, args... ) \
135 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_WARN, MODULE_STRING, \
136 psz_format, ## args )
138 # define msg_Dbg( p_this, psz_format, args... ) \
139 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_DBG, MODULE_STRING, \
140 psz_format, ## args )
142 #elif defined(_MSC_VER) /* To avoid warnings and even errors with c++ files */
144 inline void msg_Info( void *p_this, const char *psz_format, ... )
147 va_start( ap, psz_format );
148 __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL,VLC_MSG_INFO, MODULE_STRING,
152 inline void msg_Err( void *p_this, const char *psz_format, ... )
155 va_start( ap, psz_format );
156 __msg_GenericVa( ( vlc_object_t *)p_this,MSG_QUEUE_NORMAL, VLC_MSG_ERR, MODULE_STRING,
160 inline void msg_Warn( void *p_this, const char *psz_format, ... )
163 va_start( ap, psz_format );
164 __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL, VLC_MSG_WARN, MODULE_STRING,
168 inline void msg_Dbg( void *p_this, const char *psz_format, ... )
171 va_start( ap, psz_format );
172 __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL, VLC_MSG_DBG, MODULE_STRING,
179 # define msg_Info __msg_Info
180 # define msg_Err __msg_Err
181 # define msg_Warn __msg_Warn
182 # define msg_Dbg __msg_Dbg
184 #endif /* HAVE_VARIADIC_MACROS */
186 #define msg_Create(a) __msg_Create(VLC_OBJECT(a))
187 #define msg_Flush(a) __msg_Flush(VLC_OBJECT(a))
188 #define msg_Destroy(a) __msg_Destroy(VLC_OBJECT(a))
189 void __msg_Create ( vlc_object_t * );
190 void __msg_Flush ( vlc_object_t * );
191 void __msg_Destroy ( vlc_object_t * );
193 #define msg_Subscribe(a,b) __msg_Subscribe(VLC_OBJECT(a),b)
194 #define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b)
195 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t *, int ) );
196 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
204 * \defgroup statistics Statistics
218 struct counter_sample_t
231 counter_sample_t ** pp_samples;
233 mtime_t update_interval;
237 struct stats_handler_t
242 counter_t **pp_counters;
245 #define stats_Update( a,b,c) __stats_Update( VLC_OBJECT( a ), b, c )
246 VLC_EXPORT( int, __stats_Update, (vlc_object_t*, char *, vlc_value_t) );
247 #define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
248 VLC_EXPORT( int, __stats_Create, (vlc_object_t*, char *, int, int) );
249 #define stats_Get( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
250 VLC_EXPORT( int, __stats_Get, (vlc_object_t*, int, char *, vlc_value_t*) );
251 #define stats_CounterGet( a,b,c) __stats_CounterGet( VLC_OBJECT(a), b, c )
252 VLC_EXPORT( counter_t*, __stats_CounterGet, (vlc_object_t*, int, char * ) );
254 #define stats_GetInteger( a,b,c,d ) __stats_GetInteger( VLC_OBJECT(a), b, c, d )
255 static inline int __stats_GetInteger( vlc_object_t *p_obj, int i_id,
256 char *psz_name, int *value )
259 int i_ret = __stats_Get( p_obj, i_id, psz_name, &val );
264 #define stats_GetFloat(a,b,c,d ) __stats_GetFloat( VLC_OBJECT(a), b, c, d )
265 static inline int __stats_GetFloat( vlc_object_t *p_obj, int i_id,
266 char *psz_name, float *value )
269 int i_ret = __stats_Get( p_obj, i_id, psz_name, &val );
270 *value = val.f_float;
273 #define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c )
274 static inline int __stats_UpdateInteger( vlc_object_t *p_obj, char *psz_name,
279 return __stats_Update( p_obj, psz_name, val );
281 #define stats_UpdateFloat( a,b,c ) __stats_UpdateFloat( VLC_OBJECT(a),b,c )
282 static inline int __stats_UpdateFloat( vlc_object_t *p_obj, char *psz_name,
287 return __stats_Update( p_obj, psz_name, val );
298 float f_input_bitrate;
299 float f_average_input_bitrate;
302 int i_demux_read_packets;
303 int i_demux_read_bytes;
304 float f_demux_bitrate;
305 float f_average_demux_bitrate;
312 int i_displayed_pictures;
316 VLC_EXPORT( void, stats_ComputeInputStats, (input_thread_t*, input_stats_t*) );
317 VLC_EXPORT( void, stats_ReinitInputStats, (input_stats_t *) );
318 VLC_EXPORT( void, stats_DumpInputStats, (input_stats_t *) );