]> git.sesse.net Git - vlc/blob - include/vlc_interface.h
Revert "Remove b_should_run_on_first_thread"
[vlc] / include / vlc_interface.h
1 /*****************************************************************************
2  * vlc_interface.h: interface access for other threads
3  * This library provides basic functions for threads to interact with user
4  * interface, such as message output.
5  *****************************************************************************
6  * Copyright (C) 1999, 2000 VLC authors and VideoLAN
7  * $Id$
8  *
9  * Authors: Vincent Seguin <seguin@via.ecp.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation; either version 2.1 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #ifndef VLC_INTF_H_
27 #define VLC_INTF_H_
28
29 # ifdef __cplusplus
30 extern "C" {
31 # endif
32
33 typedef struct intf_dialog_args_t intf_dialog_args_t;
34
35 /**
36  * \file
37  * This file contains structures and function prototypes for
38  * interface management in vlc
39  */
40
41 /**
42  * \defgroup vlc_interface Interface
43  * These functions and structures are for interface management
44  * @{
45  */
46
47 typedef struct intf_sys_t intf_sys_t;
48
49 /** Describe all interface-specific data of the interface thread */
50 typedef struct intf_thread_t
51 {
52     VLC_COMMON_MEMBERS
53
54     struct intf_thread_t *p_next; /** LibVLC interfaces book keeping */
55     vlc_thread_t thread; /** LibVLC thread */
56     /* Thread properties and locks */
57 #if defined( __APPLE__ )
58     bool          b_should_run_on_first_thread;
59 #endif
60
61     /* Specific interfaces */
62     intf_sys_t *        p_sys;                          /** system interface */
63
64     /** Interface module */
65     module_t *   p_module;
66     void      ( *pf_run )    ( struct intf_thread_t * ); /** Run function */
67
68     /** Specific for dialogs providers */
69     void ( *pf_show_dialog ) ( struct intf_thread_t *, int, int,
70                                intf_dialog_args_t * );
71
72     config_chain_t *p_cfg;
73 } intf_thread_t;
74
75 /** \brief Arguments passed to a dialogs provider
76  *  This describes the arguments passed to the dialogs provider. They are
77  *  mainly used with INTF_DIALOG_FILE_GENERIC.
78  */
79 struct intf_dialog_args_t
80 {
81     intf_thread_t *p_intf;
82     char *psz_title;
83
84     char **psz_results;
85     int  i_results;
86
87     void (*pf_callback) ( intf_dialog_args_t * );
88     void *p_arg;
89
90     /* Specifically for INTF_DIALOG_FILE_GENERIC */
91     char *psz_extensions;
92     bool b_save;
93     bool b_multiple;
94
95     /* Specific to INTF_DIALOG_INTERACTION */
96     struct interaction_dialog_t *p_dialog;
97 };
98
99 VLC_API int intf_Create( vlc_object_t *, const char * );
100 #define intf_Create(a,b) intf_Create(VLC_OBJECT(a),b)
101
102 VLC_API void libvlc_Quit( libvlc_int_t * );
103
104 /**
105  * \defgroup vlc_subscription Log messages subscription
106  * These functions deal with log messages.
107  * @{
108  */
109
110 /**
111  * Message logging callback signature.
112  * Accepts one private data pointer, the message, and an overrun counter.
113  */
114 typedef void (*msg_callback_t) (void *, int, const msg_item_t *,
115                                 const char *, va_list);
116
117 /**
118  * Used by interface plugins which subscribe to the message bank.
119  */
120 typedef struct msg_subscription
121 {
122     struct msg_subscription *prev, *next;
123     msg_callback_t func;
124     void *opaque;
125 } msg_subscription_t;
126
127 VLC_API void vlc_Subscribe(msg_subscription_t *, msg_callback_t, void *);
128 VLC_API void vlc_Unsubscribe(msg_subscription_t *);
129
130 /*@}*/
131
132 #if defined( WIN32 ) && !defined( UNDER_CE )
133 #    define CONSOLE_INTRO_MSG \
134          if( !getenv( "PWD" ) ) /* detect Cygwin shell or Wine */ \
135          { \
136          AllocConsole(); \
137          freopen( "CONOUT$", "w", stdout ); \
138          freopen( "CONOUT$", "w", stderr ); \
139          freopen( "CONIN$", "r", stdin ); \
140          } \
141          msg_Info( p_intf, "VLC media player - %s", VERSION_MESSAGE ); \
142          msg_Info( p_intf, "%s", COPYRIGHT_MESSAGE ); \
143          msg_Info( p_intf, _("\nWarning: if you cannot access the GUI " \
144                              "anymore, open a command-line window, go to the " \
145                              "directory where you installed VLC and run " \
146                              "\"vlc -I qt\"\n") )
147 #else
148 #    define CONSOLE_INTRO_MSG (void)0
149 #endif
150
151 /* Interface dialog ids for dialog providers */
152 typedef enum vlc_dialog {
153     INTF_DIALOG_FILE_SIMPLE = 1,
154     INTF_DIALOG_FILE,
155     INTF_DIALOG_DISC,
156     INTF_DIALOG_NET,
157     INTF_DIALOG_CAPTURE,
158     INTF_DIALOG_SAT,
159     INTF_DIALOG_DIRECTORY,
160
161     INTF_DIALOG_STREAMWIZARD,
162     INTF_DIALOG_WIZARD,
163
164     INTF_DIALOG_PLAYLIST,
165     INTF_DIALOG_MESSAGES,
166     INTF_DIALOG_FILEINFO,
167     INTF_DIALOG_PREFS,
168     INTF_DIALOG_BOOKMARKS,
169     INTF_DIALOG_EXTENDED,
170
171     INTF_DIALOG_POPUPMENU = 20,
172     INTF_DIALOG_AUDIOPOPUPMENU,
173     INTF_DIALOG_VIDEOPOPUPMENU,
174     INTF_DIALOG_MISCPOPUPMENU,
175
176     INTF_DIALOG_FILE_GENERIC = 30,
177     INTF_DIALOG_INTERACTION = 50,
178
179     INTF_DIALOG_UPDATEVLC = 90,
180     INTF_DIALOG_VLM,
181
182     INTF_DIALOG_EXIT = 99
183 } vlc_dialog_t;
184
185 /* Useful text messages shared by interfaces */
186 #define INTF_ABOUT_MSG LICENSE_MSG
187
188 #define EXTENSIONS_AUDIO_CSV "3ga", "669", "a52", "aac", "ac3", "ape", "awb", "dts", "flac", "it", \
189                          "m4a", "m4p", "mka", "mlp", "mod", "mp1", "mp2", "mp3", "mpc", "mpga", \
190                          "oga", "ogg", "oma", "qcp", "ra", "rmi", "s3m", "spx", "thd", "tta", \
191                          "wav", "wma", "wv", "xm"
192
193 #define EXTENSIONS_VIDEO_CSV "asf", "avi", "divx", "drc", "dv", "f4v", "flv", "gvi", "gxf", "iso", \
194                              "m1v", "m2v", "m2t", "m2ts", "m4v", "mkv", "mov",\
195                              "mp2", "mp4", "mpeg", "mpeg1", \
196                              "mpeg2", "mpeg4", "mpg", "mts", "mtv", "mxf", "mxg", "nuv", \
197                              "ogg", "ogm", "ogv", "ogx", "ps", \
198                              "rec", "rm", "rmvb", "ts", "vob", "wm", "wmv"
199
200 #define EXTENSIONS_AUDIO \
201     "*.3ga;" \
202     "*.669;" \
203     "*.a52;" \
204     "*.aac;" \
205     "*.ac3;" \
206     "*.adt;" \
207     "*.adts;" \
208     "*.aif;"\
209     "*.aifc;"\
210     "*.aiff;"\
211     "*.amr;" \
212     "*.aob;" \
213     "*.ape;" \
214     "*.awb;" \
215     "*.caf;" \
216     "*.cda;" \
217     "*.dts;" \
218     "*.flac;"\
219     "*.it;"  \
220     "*.m4a;" \
221     "*.m4p;" \
222     "*.mid;" \
223     "*.mka;" \
224     "*.mlp;" \
225     "*.mod;" \
226     "*.mp1;" \
227     "*.mp2;" \
228     "*.mp3;" \
229     "*.mpc;" \
230     "*.mpga;" \
231     "*.oga;" \
232     "*.ogg;" \
233     "*.oma;" \
234     "*.qcp;" \
235     "*.ra;" \
236     "*.rmi;" \
237     "*.s3m;" \
238     "*.spx;" \
239     "*.thd;" \
240     "*.tta;" \
241     "*.voc;" \
242     "*.vqf;" \
243     "*.w64;" \
244     "*.wav;" \
245     "*.wma;" \
246     "*.wv;"  \
247     "*.xa;"  \
248     "*.xm"
249
250 #define EXTENSIONS_VIDEO "*.3g2;*.3gp;*.3gp2;*.3gpp;*.amv;*.asf;*.avi;*.bin;*.divx;*.drc;*.dv;*f4v;*.flv;*.gvi;*.gxf;*.iso;*.m1v;*.m2v;" \
251                          "*.m2t;*.m2ts;*.m4v;*.mkv;*.mov;*.mp2;*.mp2v;*.mp4;*.mp4v;*.mpa;*.mpe;*.mpeg;*.mpeg1;" \
252                          "*.mpeg2;*.mpeg4;*.mpg;*.mpv2;*.mts;*.mtv;*.mxf;*.mxg;*.nsv;*.nuv;" \
253                          "*.ogg;*.ogm;*.ogv;*.ogx;*.ps;" \
254                          "*.rec;*.rm;*.rmvb;*.tod;*.ts;*.tts;*.vob;*.vro;*.webm;*.wm;*.wmv"
255
256 #define EXTENSIONS_PLAYLIST "*.asx;*.b4s;*.cue;*.ifo;*.m3u;*.m3u8;*.pls;*.ram;*.rar;*.sdp;*.vlc;*.xspf;*.wvx;*.zip;*.conf"
257
258 #define EXTENSIONS_MEDIA EXTENSIONS_VIDEO ";" EXTENSIONS_AUDIO ";" \
259                           EXTENSIONS_PLAYLIST
260
261 #define EXTENSIONS_SUBTITLE "*.cdg;*.idx;*.srt;" \
262                             "*.sub;*.utf;*.ass;" \
263                             "*.ssa;*.aqt;" \
264                             "*.jss;*.psb;" \
265                             "*.rt;*.smi;*.txt;" \
266                             "*.smil;*.stl;*.usf" \
267                             "*.dks;*.pjs;*.mpl2"
268
269 /** \defgroup vlc_interaction Interaction
270  * \ingroup vlc_interface
271  * Interaction between user and modules
272  * @{
273  */
274
275 /**
276  * This structure describes a piece of interaction with the user
277  */
278 typedef struct interaction_dialog_t
279 {
280     int             i_type;             ///< Type identifier
281     char           *psz_title;          ///< Title
282     char           *psz_description;    ///< Descriptor string
283     char           *psz_default_button;  ///< default button title (~OK)
284     char           *psz_alternate_button;///< alternate button title (~NO)
285     /// other button title (optional,~Cancel)
286     char           *psz_other_button;
287
288     char           *psz_returned[1];    ///< returned responses from the user
289
290     vlc_value_t     val;                ///< value coming from core for dialogue
291     int             i_timeToGo;         ///< time (in sec) until shown progress is finished
292     bool      b_cancelled;        ///< was the dialogue cancelled ?
293
294     void *          p_private;          ///< Private interface data
295
296     int             i_status;           ///< Dialog status;
297     int             i_action;           ///< Action to perform;
298     int             i_flags;            ///< Misc flags
299     int             i_return;           ///< Return status
300
301     vlc_object_t   *p_parent;           ///< The vlc object that asked
302                                         //for interaction
303     intf_thread_t  *p_interface;
304     vlc_mutex_t    *p_lock;
305 } interaction_dialog_t;
306
307 /**
308  * Possible flags . Dialog types
309  */
310 #define DIALOG_GOT_ANSWER           0x01
311 #define DIALOG_YES_NO_CANCEL        0x02
312 #define DIALOG_LOGIN_PW_OK_CANCEL   0x04
313 #define DIALOG_PSZ_INPUT_OK_CANCEL  0x08
314 #define DIALOG_BLOCKING_ERROR       0x10
315 #define DIALOG_NONBLOCKING_ERROR    0x20
316 #define DIALOG_USER_PROGRESS        0x80
317 #define DIALOG_INTF_PROGRESS        0x100
318
319 /** Possible return codes */
320 enum
321 {
322     DIALOG_OK_YES,
323     DIALOG_NO,
324     DIALOG_CANCELLED
325 };
326
327 /** Possible status  */
328 enum
329 {
330     ANSWERED_DIALOG,            ///< Got "answer"
331     DESTROYED_DIALOG,           ///< Interface has destroyed it
332 };
333
334 /** Possible actions */
335 enum
336 {
337     INTERACT_NEW,
338     INTERACT_UPDATE,
339     INTERACT_HIDE,
340     INTERACT_DESTROY
341 };
342
343 #define intf_UserStringInput( a, b, c, d ) (VLC_OBJECT(a),b,c,d, VLC_EGENERIC)
344 #define interaction_Register( t ) (t, VLC_EGENERIC)
345 #define interaction_Unregister( t ) (t, VLC_EGENERIC)
346
347
348 /** @} */
349 /** @} */
350
351 # ifdef __cplusplus
352 }
353 # endif
354 #endif