vlc_interface.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_interface.h: interface access for other threads
00003  * This library provides basic functions for threads to interact with user
00004  * interface, such as message output.
00005  *****************************************************************************
00006  * Copyright (C) 1999, 2000 VLC authors and VideoLAN
00007  * $Id: 14898e38f04b029c883c65adb40e3b31a225a8ad $
00008  *
00009  * Authors: Vincent Seguin <seguin@via.ecp.fr>
00010  *
00011  * This program is free software; you can redistribute it and/or modify it
00012  * under the terms of the GNU Lesser General Public License as published by
00013  * the Free Software Foundation; either version 2.1 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019  * GNU Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00024  *****************************************************************************/
00025 
00026 #ifndef VLC_INTF_H_
00027 #define VLC_INTF_H_
00028 
00029 # ifdef __cplusplus
00030 extern "C" {
00031 # endif
00032 
00033 typedef struct intf_dialog_args_t intf_dialog_args_t;
00034 
00035 /**
00036  * \file
00037  * This file contains structures and function prototypes for
00038  * interface management in vlc
00039  */
00040 
00041 /**
00042  * \defgroup vlc_interface Interface
00043  * These functions and structures are for interface management
00044  * @{
00045  */
00046 
00047 typedef struct intf_sys_t intf_sys_t;
00048 
00049 /** Describe all interface-specific data of the interface thread */
00050 typedef struct intf_thread_t
00051 {
00052     VLC_COMMON_MEMBERS
00053 
00054     struct intf_thread_t *p_next; /** LibVLC interfaces book keeping */
00055     vlc_thread_t thread; /** LibVLC thread */
00056     /* Thread properties and locks */
00057 #if defined( __APPLE__ )
00058     bool          b_should_run_on_first_thread;
00059 #endif
00060 
00061     /* Specific interfaces */
00062     intf_sys_t *        p_sys;                          /** system interface */
00063 
00064     /** Interface module */
00065     module_t *   p_module;
00066     void      ( *pf_run )    ( struct intf_thread_t * ); /** Run function */
00067 
00068     /** Specific for dialogs providers */
00069     void ( *pf_show_dialog ) ( struct intf_thread_t *, int, int,
00070                                intf_dialog_args_t * );
00071 
00072     config_chain_t *p_cfg;
00073 } intf_thread_t;
00074 
00075 /** \brief Arguments passed to a dialogs provider
00076  *  This describes the arguments passed to the dialogs provider. They are
00077  *  mainly used with INTF_DIALOG_FILE_GENERIC.
00078  */
00079 struct intf_dialog_args_t
00080 {
00081     intf_thread_t *p_intf;
00082     char *psz_title;
00083 
00084     char **psz_results;
00085     int  i_results;
00086 
00087     void (*pf_callback) ( intf_dialog_args_t * );
00088     void *p_arg;
00089 
00090     /* Specifically for INTF_DIALOG_FILE_GENERIC */
00091     char *psz_extensions;
00092     bool b_save;
00093     bool b_multiple;
00094 
00095     /* Specific to INTF_DIALOG_INTERACTION */
00096     struct interaction_dialog_t *p_dialog;
00097 };
00098 
00099 VLC_API int intf_Create( vlc_object_t *, const char * );
00100 #define intf_Create(a,b) intf_Create(VLC_OBJECT(a),b)
00101 
00102 VLC_API void libvlc_Quit( libvlc_int_t * );
00103 
00104 /**
00105  * \defgroup vlc_subscription Log messages subscription
00106  * These functions deal with log messages.
00107  * @{
00108  */
00109 
00110 /**
00111  * Message logging callback signature.
00112  * Accepts one private data pointer, the message, and an overrun counter.
00113  */
00114 typedef void (*msg_callback_t) (void *, int, const msg_item_t *,
00115                                 const char *, va_list);
00116 
00117 /**
00118  * Used by interface plugins which subscribe to the message bank.
00119  */
00120 typedef struct msg_subscription
00121 {
00122     struct msg_subscription *prev, *next;
00123     msg_callback_t func;
00124     void *opaque;
00125 } msg_subscription_t;
00126 
00127 VLC_API void vlc_Subscribe(msg_subscription_t *, msg_callback_t, void *);
00128 VLC_API void vlc_Unsubscribe(msg_subscription_t *);
00129 
00130 /*@}*/
00131 
00132 #if defined( WIN32 ) && !defined( UNDER_CE )
00133 #    define CONSOLE_INTRO_MSG \
00134          if( !getenv( "PWD" ) ) /* detect Cygwin shell or Wine */ \
00135          { \
00136          AllocConsole(); \
00137          freopen( "CONOUT$", "w", stdout ); \
00138          freopen( "CONOUT$", "w", stderr ); \
00139          freopen( "CONIN$", "r", stdin ); \
00140          } \
00141          msg_Info( p_intf, "VLC media player - %s", VERSION_MESSAGE ); \
00142          msg_Info( p_intf, "%s", COPYRIGHT_MESSAGE ); \
00143          msg_Info( p_intf, _("\nWarning: if you cannot access the GUI " \
00144                              "anymore, open a command-line window, go to the " \
00145                              "directory where you installed VLC and run " \
00146                              "\"vlc -I qt\"\n") )
00147 #else
00148 #    define CONSOLE_INTRO_MSG (void)0
00149 #endif
00150 
00151 /* Interface dialog ids for dialog providers */
00152 typedef enum vlc_dialog {
00153     INTF_DIALOG_FILE_SIMPLE = 1,
00154     INTF_DIALOG_FILE,
00155     INTF_DIALOG_DISC,
00156     INTF_DIALOG_NET,
00157     INTF_DIALOG_CAPTURE,
00158     INTF_DIALOG_SAT,
00159     INTF_DIALOG_DIRECTORY,
00160 
00161     INTF_DIALOG_STREAMWIZARD,
00162     INTF_DIALOG_WIZARD,
00163 
00164     INTF_DIALOG_PLAYLIST,
00165     INTF_DIALOG_MESSAGES,
00166     INTF_DIALOG_FILEINFO,
00167     INTF_DIALOG_PREFS,
00168     INTF_DIALOG_BOOKMARKS,
00169     INTF_DIALOG_EXTENDED,
00170 
00171     INTF_DIALOG_POPUPMENU = 20,
00172     INTF_DIALOG_AUDIOPOPUPMENU,
00173     INTF_DIALOG_VIDEOPOPUPMENU,
00174     INTF_DIALOG_MISCPOPUPMENU,
00175 
00176     INTF_DIALOG_FILE_GENERIC = 30,
00177     INTF_DIALOG_INTERACTION = 50,
00178 
00179     INTF_DIALOG_UPDATEVLC = 90,
00180     INTF_DIALOG_VLM,
00181 
00182     INTF_DIALOG_EXIT = 99
00183 } vlc_dialog_t;
00184 
00185 /* Useful text messages shared by interfaces */
00186 #define INTF_ABOUT_MSG LICENSE_MSG
00187 
00188 #define EXTENSIONS_AUDIO_CSV "3ga", "669", "a52", "aac", "ac3", "ape", "awb", "dts", "flac", "it", \
00189                          "m4a", "m4p", "mka", "mlp", "mod", "mp1", "mp2", "mp3", "mpc", "mpga", \
00190                          "oga", "ogg", "oma", "qcp", "ra", "rmi", "s3m", "spx", "thd", "tta", \
00191                          "wav", "wma", "wv", "xm"
00192 
00193 #define EXTENSIONS_VIDEO_CSV "asf", "avi", "divx", "drc", "dv", "f4v", "flv", "gvi", "gxf", "iso", \
00194                              "m1v", "m2v", "m2t", "m2ts", "m4v", "mkv", "mov",\
00195                              "mp2", "mp4", "mpeg", "mpeg1", \
00196                              "mpeg2", "mpeg4", "mpg", "mts", "mtv", "mxf", "mxg", "nuv", \
00197                              "ogg", "ogm", "ogv", "ogx", "ps", \
00198                              "rec", "rm", "rmvb", "ts", "vob", "wm", "wmv"
00199 
00200 #define EXTENSIONS_AUDIO \
00201     "*.3ga;" \
00202     "*.669;" \
00203     "*.a52;" \
00204     "*.aac;" \
00205     "*.ac3;" \
00206     "*.adt;" \
00207     "*.adts;" \
00208     "*.aif;"\
00209     "*.aifc;"\
00210     "*.aiff;"\
00211     "*.amr;" \
00212     "*.aob;" \
00213     "*.ape;" \
00214     "*.awb;" \
00215     "*.caf;" \
00216     "*.cda;" \
00217     "*.dts;" \
00218     "*.flac;"\
00219     "*.it;"  \
00220     "*.m4a;" \
00221     "*.m4p;" \
00222     "*.mid;" \
00223     "*.mka;" \
00224     "*.mlp;" \
00225     "*.mod;" \
00226     "*.mp1;" \
00227     "*.mp2;" \
00228     "*.mp3;" \
00229     "*.mpc;" \
00230     "*.mpga;" \
00231     "*.oga;" \
00232     "*.ogg;" \
00233     "*.oma;" \
00234     "*.qcp;" \
00235     "*.ra;" \
00236     "*.rmi;" \
00237     "*.s3m;" \
00238     "*.spx;" \
00239     "*.thd;" \
00240     "*.tta;" \
00241     "*.voc;" \
00242     "*.vqf;" \
00243     "*.w64;" \
00244     "*.wav;" \
00245     "*.wma;" \
00246     "*.wv;"  \
00247     "*.xa;"  \
00248     "*.xm"
00249 
00250 #define EXTENSIONS_VIDEO "*.3g2;*.3gp;*.3gp2;*.3gpp;*.amv;*.asf;*.avi;*.bin;*.divx;*.drc;*.dv;*f4v;*.flv;*.gvi;*.gxf;*.iso;*.m1v;*.m2v;" \
00251                          "*.m2t;*.m2ts;*.m4v;*.mkv;*.mov;*.mp2;*.mp2v;*.mp4;*.mp4v;*.mpa;*.mpe;*.mpeg;*.mpeg1;" \
00252                          "*.mpeg2;*.mpeg4;*.mpg;*.mpv2;*.mts;*.mtv;*.mxf;*.mxg;*.nsv;*.nuv;" \
00253                          "*.ogg;*.ogm;*.ogv;*.ogx;*.ps;" \
00254                          "*.rec;*.rm;*.rmvb;*.tod;*.ts;*.tts;*.vob;*.vro;*.webm;*.wm;*.wmv"
00255 
00256 #define EXTENSIONS_PLAYLIST "*.asx;*.b4s;*.cue;*.ifo;*.m3u;*.m3u8;*.pls;*.ram;*.rar;*.sdp;*.vlc;*.xspf;*.wvx;*.zip;*.conf"
00257 
00258 #define EXTENSIONS_MEDIA EXTENSIONS_VIDEO ";" EXTENSIONS_AUDIO ";" \
00259                           EXTENSIONS_PLAYLIST
00260 
00261 #define EXTENSIONS_SUBTITLE "*.cdg;*.idx;*.srt;" \
00262                             "*.sub;*.utf;*.ass;" \
00263                             "*.ssa;*.aqt;" \
00264                             "*.jss;*.psb;" \
00265                             "*.rt;*.smi;*.txt;" \
00266                             "*.smil;*.stl;*.usf" \
00267                             "*.dks;*.pjs;*.mpl2"
00268 
00269 /** \defgroup vlc_interaction Interaction
00270  * \ingroup vlc_interface
00271  * Interaction between user and modules
00272  * @{
00273  */
00274 
00275 /**
00276  * This structure describes a piece of interaction with the user
00277  */
00278 typedef struct interaction_dialog_t
00279 {
00280     int             i_type;             ///< Type identifier
00281     char           *psz_title;          ///< Title
00282     char           *psz_description;    ///< Descriptor string
00283     char           *psz_default_button;  ///< default button title (~OK)
00284     char           *psz_alternate_button;///< alternate button title (~NO)
00285     /// other button title (optional,~Cancel)
00286     char           *psz_other_button;
00287 
00288     char           *psz_returned[1];    ///< returned responses from the user
00289 
00290     vlc_value_t     val;                ///< value coming from core for dialogue
00291     int             i_timeToGo;         ///< time (in sec) until shown progress is finished
00292     bool      b_cancelled;        ///< was the dialogue cancelled ?
00293 
00294     void *          p_private;          ///< Private interface data
00295 
00296     int             i_status;           ///< Dialog status;
00297     int             i_action;           ///< Action to perform;
00298     int             i_flags;            ///< Misc flags
00299     int             i_return;           ///< Return status
00300 
00301     vlc_object_t   *p_parent;           ///< The vlc object that asked
00302                                         //for interaction
00303     intf_thread_t  *p_interface;
00304     vlc_mutex_t    *p_lock;
00305 } interaction_dialog_t;
00306 
00307 /**
00308  * Possible flags . Dialog types
00309  */
00310 #define DIALOG_GOT_ANSWER           0x01
00311 #define DIALOG_YES_NO_CANCEL        0x02
00312 #define DIALOG_LOGIN_PW_OK_CANCEL   0x04
00313 #define DIALOG_PSZ_INPUT_OK_CANCEL  0x08
00314 #define DIALOG_BLOCKING_ERROR       0x10
00315 #define DIALOG_NONBLOCKING_ERROR    0x20
00316 #define DIALOG_USER_PROGRESS        0x80
00317 #define DIALOG_INTF_PROGRESS        0x100
00318 
00319 /** Possible return codes */
00320 enum
00321 {
00322     DIALOG_OK_YES,
00323     DIALOG_NO,
00324     DIALOG_CANCELLED
00325 };
00326 
00327 /** Possible status  */
00328 enum
00329 {
00330     ANSWERED_DIALOG,            ///< Got "answer"
00331     DESTROYED_DIALOG,           ///< Interface has destroyed it
00332 };
00333 
00334 /** Possible actions */
00335 enum
00336 {
00337     INTERACT_NEW,
00338     INTERACT_UPDATE,
00339     INTERACT_HIDE,
00340     INTERACT_DESTROY
00341 };
00342 
00343 #define intf_UserStringInput( a, b, c, d ) (VLC_OBJECT(a),b,c,d, VLC_EGENERIC)
00344 #define interaction_Register( t ) (t, VLC_EGENERIC)
00345 #define interaction_Unregister( t ) (t, VLC_EGENERIC)
00346 
00347 
00348 /** @} */
00349 /** @} */
00350 
00351 # ifdef __cplusplus
00352 }
00353 # endif
00354 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines