]> git.sesse.net Git - vlc/blob - include/vlc_messages.h
Remove msg_cb_data_t and simplify accordingly
[vlc] / include / vlc_messages.h
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
7  * $Id$
8  *
9  * Authors: Vincent Seguin <seguin@via.ecp.fr>
10  *          Samuel Hocevar <sam@zoy.org>
11  *
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.
16  *
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.
21  *
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  *****************************************************************************/
26
27 #ifndef VLC_MESSAGES_H_
28 #define VLC_MESSAGES_H_
29
30 /**
31  * \file
32  * This file defines structures and functions to handle messages and statistics gathering
33  */
34
35 #include <stdarg.h>
36
37 /**
38  * \defgroup messages Messages
39  * This library provides basic functions for threads to interact with user
40  * interface, such as message output.
41  *
42  * @{
43  */
44
45 /** Message types */
46 enum msg_item_type
47 {
48     VLC_MSG_INFO=0, /**< Important information */
49     VLC_MSG_ERR,    /**< Error */
50     VLC_MSG_WARN,   /**< Warning */
51     VLC_MSG_DBG,    /**< Debug */
52 };
53
54 /**
55  * Log message
56  */
57 typedef struct
58 {
59     unsigned    i_type;  /**< Message type, see @ref msg_item_type */
60     uintptr_t   i_object_id; /**< Emitter (temporaly) unique object ID or 0 */
61     const char *psz_object_type; /**< Emitter object type name */
62     const char *psz_module; /**< Emitter module (source code) */
63     const char *psz_header; /**< Additional header (used by VLM media) */
64     char       *psz_msg; /**< Message text */
65 } msg_item_t;
66
67 VLC_MALLOC VLC_USED
68 static inline msg_item_t *msg_Copy (const msg_item_t *msg)
69 {
70     msg_item_t *copy = (msg_item_t *)xmalloc (sizeof (*copy));
71     copy->i_type = msg->i_type;
72     copy->i_object_id = msg->i_object_id;
73     copy->psz_object_type = msg->psz_object_type;
74     copy->psz_module = strdup (msg->psz_module);
75     copy->psz_msg = strdup (msg->psz_msg);
76     copy->psz_header = msg->psz_header ? strdup (msg->psz_header) : NULL;
77     return copy;
78 }
79
80 static inline void msg_Free (msg_item_t *msg)
81 {
82     free ((char *)msg->psz_module);
83     free ((char *)msg->psz_header);
84     free (msg->psz_msg);
85     free (msg);
86 }
87
88 /**
89  * Used by interface plugins which subscribe to the message bank.
90  */
91 typedef struct msg_subscription_t msg_subscription_t;
92
93 /*****************************************************************************
94  * Prototypes
95  *****************************************************************************/
96 VLC_API void vlc_Log(vlc_object_t *, int,
97                      const char *, const char *, ...) VLC_FORMAT( 4, 5 );
98 VLC_API void vlc_vaLog(vlc_object_t *, int,
99                        const char *, const char *, va_list);
100 #define msg_GenericVa(a, b, c, d, e) vlc_vaLog(VLC_OBJECT(a), b, c, d, e)
101
102 #define msg_Info( p_this, ... ) \
103     vlc_Log( VLC_OBJECT(p_this), VLC_MSG_INFO, MODULE_STRING, __VA_ARGS__ )
104 #define msg_Err( p_this, ... ) \
105     vlc_Log( VLC_OBJECT(p_this), VLC_MSG_ERR,  MODULE_STRING, __VA_ARGS__ )
106 #define msg_Warn( p_this, ... ) \
107     vlc_Log( VLC_OBJECT(p_this), VLC_MSG_WARN, MODULE_STRING, __VA_ARGS__ )
108 #define msg_Dbg( p_this, ... ) \
109     vlc_Log( VLC_OBJECT(p_this), VLC_MSG_DBG,  MODULE_STRING, __VA_ARGS__ )
110
111 /**
112  * Message logging callback signature.
113  * Accepts one private data pointer, the message, and an overrun counter.
114  */
115 typedef void (*msg_callback_t) (void *, const msg_item_t *);
116
117 VLC_API msg_subscription_t *vlc_Subscribe(msg_callback_t, void *) VLC_USED;
118 VLC_API void vlc_Unsubscribe(msg_subscription_t *);
119
120 /**
121  * @}
122  */
123
124 /**
125  * \defgroup statistics Statistics
126  *
127  * @{
128  */
129
130 /****************************
131  * Generic stats stuff
132  ****************************/
133 enum
134 {
135     STATS_LAST,
136     STATS_COUNTER,
137     STATS_MAX,
138     STATS_MIN,
139     STATS_DERIVATIVE,
140     STATS_TIMER
141 };
142
143 struct counter_sample_t
144 {
145     vlc_value_t value;
146     mtime_t     date;
147 };
148
149 struct counter_t
150 {
151     unsigned int        i_id;
152     char              * psz_name;
153     int                 i_type;
154     void              * p_obj;
155     int                 i_compute_type;
156     int                 i_samples;
157     counter_sample_t ** pp_samples;
158
159     mtime_t             update_interval;
160     mtime_t             last_update;
161 };
162
163 enum
164 {
165     STATS_INPUT_BITRATE,
166     STATS_READ_BYTES,
167     STATS_READ_PACKETS,
168     STATS_DEMUX_READ,
169     STATS_DEMUX_BITRATE,
170     STATS_DEMUX_CORRUPTED,
171     STATS_DEMUX_DISCONTINUITY,
172     STATS_PLAYED_ABUFFERS,
173     STATS_LOST_ABUFFERS,
174     STATS_DECODED_AUDIO,
175     STATS_DECODED_VIDEO,
176     STATS_DECODED_SUB,
177     STATS_CLIENT_CONNECTIONS,
178     STATS_ACTIVE_CONNECTIONS,
179     STATS_SOUT_SENT_PACKETS,
180     STATS_SOUT_SENT_BYTES,
181     STATS_SOUT_SEND_BITRATE,
182     STATS_DISPLAYED_PICTURES,
183     STATS_LOST_PICTURES,
184
185     STATS_TIMER_PLAYLIST_BUILD,
186     STATS_TIMER_ML_LOAD,
187     STATS_TIMER_ML_DUMP,
188     STATS_TIMER_INTERACTION,
189     STATS_TIMER_PREPARSE,
190     STATS_TIMER_INPUT_LAUNCHING,
191     STATS_TIMER_MODULE_NEED,
192     STATS_TIMER_VIDEO_FRAME_ENCODING,
193     STATS_TIMER_AUDIO_FRAME_ENCODING,
194
195     STATS_TIMER_SKINS_PLAYTREE_IMAGE,
196 };
197
198 /*********
199  * Timing
200  ********/
201 VLC_API void stats_TimerStart(vlc_object_t*, const char *, unsigned int );
202 VLC_API void stats_TimerStop(vlc_object_t*, unsigned int);
203 VLC_API void stats_TimerDump(vlc_object_t*, unsigned int);
204 VLC_API void stats_TimersDumpAll(vlc_object_t*);
205 #define stats_TimerStart(a,b,c) stats_TimerStart( VLC_OBJECT(a), b,c )
206 #define stats_TimerStop(a,b) stats_TimerStop( VLC_OBJECT(a), b )
207 #define stats_TimerDump(a,b) stats_TimerDump( VLC_OBJECT(a), b )
208 #define stats_TimersDumpAll(a) stats_TimersDumpAll( VLC_OBJECT(a) )
209
210 VLC_API void stats_TimersCleanAll(vlc_object_t * );
211 #define stats_TimersCleanAll(a) stats_TimersCleanAll( VLC_OBJECT(a) )
212
213 VLC_API void stats_TimerClean(vlc_object_t *, unsigned int );
214 #define stats_TimerClean(a,b) stats_TimerClean( VLC_OBJECT(a), b )
215
216 /**
217  * @}
218  */
219 #endif