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 the VideoLAN team
00007  * $Id$
00008  *
00009  * Authors: Vincent Seguin <seguin@via.ecp.fr>
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 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 General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, 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 /** Describe all interface-specific data of the interface thread */
00048 struct intf_thread_t
00049 {
00050     VLC_COMMON_MEMBERS
00051 
00052     /* Thread properties and locks */
00053 #ifdef __APPLE__
00054     bool          b_should_run_on_first_thread;
00055 #endif
00056 
00057     /* Specific interfaces */
00058     intf_console_t *    p_console;                               /** console */
00059     intf_sys_t *        p_sys;                          /** system interface */
00060     char *              psz_intf;                    /** intf name specified */
00061 
00062     /** Interface module */
00063     module_t *   p_module;
00064     void      ( *pf_run )    ( intf_thread_t * ); /** Run function */
00065 
00066     /** Specific for dialogs providers */
00067     void ( *pf_show_dialog ) ( intf_thread_t *, int, int,
00068                                intf_dialog_args_t * );
00069 
00070     /** Interaction stuff */
00071     bool b_interaction;
00072 
00073     /* XXX: new message passing stuff will go here */
00074     vlc_mutex_t  change_lock;
00075     bool   b_menu_change;
00076     bool   b_menu;
00077 
00078     /* Provides the ability to switch an interface on the fly */
00079     char *psz_switch_intf;
00080 };
00081 
00082 /** \brief Arguments passed to a dialogs provider
00083  *  This describes the arguments passed to the dialogs provider. They are
00084  *  mainly used with INTF_DIALOG_FILE_GENERIC.
00085  */
00086 struct intf_dialog_args_t
00087 {
00088     intf_thread_t *p_intf;
00089     char *psz_title;
00090 
00091     char **psz_results;
00092     int  i_results;
00093 
00094     void (*pf_callback) ( intf_dialog_args_t * );
00095     void *p_arg;
00096 
00097     /* Specifically for INTF_DIALOG_FILE_GENERIC */
00098     char *psz_extensions;
00099     bool b_save;
00100     bool b_multiple;
00101 
00102     /* Specific to INTF_DIALOG_INTERACTION */
00103     interaction_dialog_t *p_dialog;
00104 };
00105 
00106 /*****************************************************************************
00107  * Prototypes
00108  *****************************************************************************/
00109 #define intf_Create(a,b) __intf_Create(VLC_OBJECT(a),b)
00110 VLC_EXPORT( intf_thread_t *, __intf_Create,     ( vlc_object_t *, const char * ) );
00111 VLC_EXPORT( int,               intf_RunThread,  ( intf_thread_t * ) );
00112 VLC_EXPORT( void,              intf_StopThread, ( intf_thread_t * ) );
00113 
00114 /* If the interface is in the main thread, it should listen both to
00115  * p_intf->b_die and p_libvlc->b_die */
00116 #define intf_ShouldDie( p_intf ) (p_intf->b_die || p_intf->p_libvlc->b_die )
00117 
00118 #define intf_Eject(a,b) __intf_Eject(VLC_OBJECT(a),b)
00119 VLC_EXPORT( int, __intf_Eject, ( vlc_object_t *, const char * ) );
00120 
00121 /*@}*/
00122 
00123 /*****************************************************************************
00124  * Macros
00125  *****************************************************************************/
00126 #if defined( WIN32 ) && !defined( UNDER_CE )
00127 #    define CONSOLE_INTRO_MSG \
00128          if( !getenv( "PWD" ) || !getenv( "PS1" ) ) /* detect cygwin shell */ \
00129          { \
00130          AllocConsole(); \
00131          freopen( "CONOUT$", "w", stdout ); \
00132          freopen( "CONOUT$", "w", stderr ); \
00133          freopen( "CONIN$", "r", stdin ); \
00134          } \
00135          msg_Info( p_intf, COPYRIGHT_MESSAGE ); \
00136          msg_Info( p_intf, _("\nWarning: if you can't access the GUI " \
00137                              "anymore, open a command-line window, go to the " \
00138                              "directory where you installed VLC and run " \
00139                              "\"vlc -I qt\"\n") )
00140 #else
00141 #    define CONSOLE_INTRO_MSG
00142 #endif
00143 
00144 /* Interface dialog ids for dialog providers */
00145 typedef enum vlc_dialog {
00146     INTF_DIALOG_FILE_SIMPLE = 1,
00147     INTF_DIALOG_FILE,
00148     INTF_DIALOG_DISC,
00149     INTF_DIALOG_NET,
00150     INTF_DIALOG_CAPTURE,
00151     INTF_DIALOG_SAT,
00152     INTF_DIALOG_DIRECTORY,
00153 
00154     INTF_DIALOG_STREAMWIZARD,
00155     INTF_DIALOG_WIZARD,
00156 
00157     INTF_DIALOG_PLAYLIST,
00158     INTF_DIALOG_MESSAGES,
00159     INTF_DIALOG_FILEINFO,
00160     INTF_DIALOG_PREFS,
00161     INTF_DIALOG_BOOKMARKS,
00162     INTF_DIALOG_EXTENDED,
00163 
00164     INTF_DIALOG_POPUPMENU = 20,
00165     INTF_DIALOG_AUDIOPOPUPMENU,
00166     INTF_DIALOG_VIDEOPOPUPMENU,
00167     INTF_DIALOG_MISCPOPUPMENU,
00168 
00169     INTF_DIALOG_FILE_GENERIC = 30,
00170     INTF_DIALOG_INTERACTION = 50,
00171 
00172     INTF_DIALOG_UPDATEVLC = 90,
00173     INTF_DIALOG_VLM,
00174 
00175     INTF_DIALOG_EXIT = 99
00176 } vlc_dialog_t;
00177 
00178 /* Useful text messages shared by interfaces */
00179 #define INTF_ABOUT_MSG LICENSE_MSG
00180 
00181 #define EXTENSIONS_AUDIO "*.a52;*.aac;*.ac3;*.dts;*.flac;*.m4a;*.m4p;*.mka;" \
00182                          "*.mod;*.mp1;*.mp2;*.mp3;*.ogg;*.oma;*.spx;" \
00183                          "*.wav;*.wma;*.xm"
00184 
00185 #define EXTENSIONS_VIDEO "*.asf;*.avi;*.divx;*.dv;*.flv;*.gxf;*.m1v;*.m2v;" \
00186                          "*.m2ts;*.m4v;*.mkv;*.mov;*.mp2;*.mp4;*.mpeg;*.mpeg1;" \
00187                          "*.mpeg2;*.mpeg4;*.mpg;*.mts;*.mxf;*.ogg;*.ogm;" \
00188                          "*.ps;*.ts;*.vob;*.wmv"
00189 
00190 #define EXTENSIONS_PLAYLIST "*.asx;*.b4s;*.m3u;*.pls;*.vlc;*.xspf"
00191 
00192 #define EXTENSIONS_MEDIA EXTENSIONS_VIDEO ";" EXTENSIONS_AUDIO ";" \
00193                           EXTENSIONS_PLAYLIST
00194 
00195 #define EXTENSIONS_SUBTITLE "*.cdg;*.idx;*.srt;*.sub;*.utf;*.ass;*.ssa;*.aqt;" \
00196                             "*.jss;*.psb;*.rt;*.smi"
00197 
00198 /** \defgroup vlc_interaction Interaction
00199  * \ingroup vlc_interface
00200  * Interaction between user and modules
00201  * @{
00202  */
00203 
00204 /**
00205  * This structure describes a piece of interaction with the user
00206  */
00207 struct interaction_dialog_t
00208 {
00209     int             i_id;               ///< Unique ID
00210     int             i_type;             ///< Type identifier
00211     char           *psz_title;          ///< Title
00212     char           *psz_description;    ///< Descriptor string
00213     char           *psz_default_button;  ///< default button title (~OK)
00214     char           *psz_alternate_button;///< alternate button title (~NO)
00215     /// other button title (optional,~Cancel)
00216     char           *psz_other_button;
00217 
00218     char           *psz_returned[1];    ///< returned responses from the user
00219 
00220     vlc_value_t     val;                ///< value coming from core for dialogue
00221     int             i_timeToGo;         ///< time (in sec) until shown progress is finished
00222     bool      b_cancelled;        ///< was the dialogue cancelled ?
00223 
00224     void *          p_private;          ///< Private interface data
00225 
00226     int             i_status;           ///< Dialog status;
00227     int             i_action;           ///< Action to perform;
00228     int             i_flags;            ///< Misc flags
00229     int             i_return;           ///< Return status
00230 
00231     interaction_t  *p_interaction;      ///< Parent interaction object
00232     vlc_object_t   *p_parent;           ///< The vlc object that asked
00233                                         //for interaction
00234 };
00235 
00236 /**
00237  * Possible flags . Dialog types
00238  */
00239 #define DIALOG_GOT_ANSWER           0x01
00240 #define DIALOG_YES_NO_CANCEL        0x02
00241 #define DIALOG_LOGIN_PW_OK_CANCEL   0x04
00242 #define DIALOG_PSZ_INPUT_OK_CANCEL  0x08
00243 #define DIALOG_BLOCKING_ERROR       0x10
00244 #define DIALOG_NONBLOCKING_ERROR    0x20
00245 #define DIALOG_WARNING              0x40
00246 #define DIALOG_USER_PROGRESS        0x80
00247 #define DIALOG_INTF_PROGRESS        0x100
00248 
00249 /** Possible return codes */
00250 enum
00251 {
00252     DIALOG_DEFAULT,
00253     DIALOG_OK_YES,
00254     DIALOG_NO,
00255     DIALOG_CANCELLED
00256 };
00257 
00258 /** Possible status  */
00259 enum
00260 {
00261     NEW_DIALOG,                 ///< Just created
00262     SENT_DIALOG,                ///< Sent to interface
00263     UPDATED_DIALOG,             ///< Update to send
00264     ANSWERED_DIALOG,            ///< Got "answer"
00265     HIDING_DIALOG,              ///< Hiding requested
00266     HIDDEN_DIALOG,              ///< Now hidden. Requesting destruction
00267     DESTROYED_DIALOG,           ///< Interface has destroyed it
00268 };
00269 
00270 /** Possible interaction types */
00271 enum
00272 {
00273     INTERACT_DIALOG_ONEWAY,     ///< Dialog box without feedback
00274     INTERACT_DIALOG_TWOWAY,     ///< Dialog box with feedback
00275 };
00276 
00277 /** Possible actions */
00278 enum
00279 {
00280     INTERACT_NEW,
00281     INTERACT_UPDATE,
00282     INTERACT_HIDE,
00283     INTERACT_DESTROY
00284 };
00285 
00286 /**
00287  * This structure contains the active interaction dialogs, and is
00288  * used by the manager
00289  */
00290 struct interaction_t
00291 {
00292     VLC_COMMON_MEMBERS
00293 
00294     int                         i_dialogs;      ///< Number of dialogs
00295     interaction_dialog_t      **pp_dialogs;     ///< Dialogs
00296     intf_thread_t              *p_intf;         ///< Interface to use
00297     int                         i_last_id;      ///< Last attributed ID
00298 };
00299 
00300 /***************************************************************************
00301  * Exported symbols
00302  ***************************************************************************/
00303 
00304 #define intf_UserFatal( a, b, c, d, e... ) __intf_UserFatal( VLC_OBJECT(a),b,c,d, ## e )
00305 VLC_EXPORT( int, __intf_UserFatal,( vlc_object_t*, bool, const char*, const char*, ...) LIBVLC_FORMAT( 4, 5 ) );
00306 #define intf_UserWarn( a, c, d, e... ) __intf_UserWarn( VLC_OBJECT(a),c,d, ## e )
00307 VLC_EXPORT( int, __intf_UserWarn,( vlc_object_t*, const char*, const char*, ...) LIBVLC_FORMAT( 3, 4 ) );
00308 #define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( VLC_OBJECT(a),b,c,d,e)
00309 VLC_EXPORT( int, __intf_UserLoginPassword,( vlc_object_t*, const char*, const char*, char **, char **) );
00310 #define intf_UserYesNo( a, b, c, d, e, f ) __intf_UserYesNo( VLC_OBJECT(a),b,c, d, e, f )
00311 VLC_EXPORT( int, __intf_UserYesNo,( vlc_object_t*, const char*, const char*, const char*, const char*, const char*) );
00312 #define intf_UserStringInput( a, b, c, d ) __intf_UserStringInput( VLC_OBJECT(a),b,c,d )
00313 VLC_EXPORT( int, __intf_UserStringInput,(vlc_object_t*, const char*, const char*, char **) );
00314 
00315 #define intf_IntfProgress( a, b, c ) __intf_Progress( VLC_OBJECT(a), NULL, b,c, -1 )
00316 #define intf_UserProgress( a, b, c, d, e ) __intf_Progress( VLC_OBJECT(a),b,c,d,e )
00317 VLC_EXPORT( int, __intf_Progress,( vlc_object_t*, const char*, const char*, float, int) );
00318 #define intf_ProgressUpdate( a, b, c, d, e ) __intf_ProgressUpdate( VLC_OBJECT(a),b,c,d,e )
00319 VLC_EXPORT( void, __intf_ProgressUpdate,( vlc_object_t*, int, const char*, float, int) );
00320 #define intf_ProgressIsCancelled( a, b ) __intf_UserProgressIsCancelled( VLC_OBJECT(a),b )
00321 VLC_EXPORT( bool, __intf_UserProgressIsCancelled,( vlc_object_t*, int ) );
00322 #define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b )
00323 VLC_EXPORT( void, __intf_UserHide,( vlc_object_t *, int ));
00324 
00325 /** @} */
00326 /** @} */
00327 
00328 # ifdef __cplusplus
00329 }
00330 # endif
00331 #endif

Generated on Wed Aug 13 08:02:37 2008 for VLC by  doxygen 1.5.1