extension.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * extension.h: Lua Extensions (meta data, web information, ...)
00003  *****************************************************************************
00004  * Copyright (C) 2009-2010 VideoLAN and authors
00005  * $Id: eb54b385b8e0b34f1a196136ba4a0a0136a5c3ae $
00006  *
00007  * Authors: Jean-Philippe André < jpeg # videolan.org >
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef LUA_EXTENSION_H
00025 #define LUA_EXTENSION_H
00026 
00027 #include <vlc_extensions.h>
00028 #include <vlc_arrays.h>
00029 
00030 ///< Array of extension_t
00031 TYPEDEF_ARRAY( extension_t, array_extension_t );
00032 
00033 /* List of available commands */
00034 #define CMD_ACTIVATE    1
00035 #define CMD_DEACTIVATE  2
00036 #define CMD_TRIGGERMENU 3    /* Arg1 = int*, pointing to id to trigger. free */
00037 #define CMD_CLICK       4    /* Arg1 = extension_widget_t* */
00038 #define CMD_CLOSE       5
00039 #define CMD_SET_INPUT   6    /* No arg. Just signal current input changed */
00040 #define CMD_UPDATE_META 7    /* No arg. Just signal current input item meta
00041                               * changed */
00042 #define CMD_PLAYING_CHANGED 8 /* Arg1 = int*, New playing status  */
00043 
00044 //Data types
00045 typedef enum
00046 {
00047     LUA_END = 0,
00048     LUA_NUM,
00049     LUA_TEXT
00050 } lua_datatype_e;
00051 
00052 struct extensions_manager_sys_t
00053 {
00054     /* List of activated extensions */
00055     DECL_ARRAY( extension_t* ) activated_extensions;
00056 
00057     /* Lock for this list */
00058     vlc_mutex_t lock;
00059 
00060     /* Flag indicating that the module is about to be unloaded */
00061     bool b_killed;
00062 };
00063 
00064 struct extension_sys_t
00065 {
00066     /* Extension general */
00067     int i_capabilities;
00068 
00069     /* Lua specific */
00070     lua_State *L;
00071 
00072     /* Thread data */
00073     vlc_thread_t thread;
00074     vlc_mutex_t command_lock;
00075     vlc_mutex_t running_lock;
00076     vlc_cond_t wait;
00077 
00078     /* The input this extension should use for vlc.input
00079      * or NULL if it should use playlist's current input */
00080     struct input_thread_t *p_input;
00081 
00082     extensions_manager_t *p_mgr;     ///< Parent
00083     /* Queue of commands to execute */
00084     struct command_t
00085     {
00086         int i_command;
00087         void *data[10];         ///< Optional void* arguments
00088         struct command_t *next; ///< Next command
00089     } *command;
00090 
00091     bool b_exiting;
00092 };
00093 
00094 /* Extensions: manager functions */
00095 int Activate( extensions_manager_t *p_mgr, extension_t * );
00096 bool IsActivated( extensions_manager_t *p_mgr, extension_t * );
00097 int Deactivate( extensions_manager_t *p_mgr, extension_t * );
00098 void WaitForDeactivation( extension_t *p_ext );
00099 int __PushCommand( extension_t *ext, bool unique, int cmd, va_list options );
00100 static inline int PushCommand( extension_t *ext, int cmd, ... )
00101 {
00102     va_list args;
00103     va_start( args, cmd );
00104     int i_ret = __PushCommand( ext, false, cmd, args );
00105     va_end( args );
00106     return i_ret;
00107 }
00108 static inline int PushCommandUnique( extension_t *ext, int cmd, ... )
00109 {
00110     va_list args;
00111     va_start( args, cmd );
00112     int i_ret = __PushCommand( ext, true, cmd, args );
00113     va_end( args );
00114     return i_ret;
00115 }
00116 bool LockExtension( extension_t *p_ext );
00117 void UnlockExtension( extension_t *p_ext );
00118 
00119 /* Lua specific functions */
00120 void vlclua_extension_set( lua_State *L, extension_t * );
00121 extension_t *vlclua_extension_get( lua_State *L );
00122 int lua_ExtensionActivate( extensions_manager_t *, extension_t * );
00123 int lua_ExtensionDeactivate( extensions_manager_t *, extension_t * );
00124 int lua_ExecuteFunctionVa( extensions_manager_t *p_mgr, extension_t *p_ext,
00125                             const char *psz_function, va_list args );
00126 int lua_ExecuteFunction( extensions_manager_t *p_mgr, extension_t *p_ext,
00127                          const char *psz_function, ... );
00128 int lua_ExtensionWidgetClick( extensions_manager_t *p_mgr,
00129                               extension_t *p_ext,
00130                               extension_widget_t *p_widget );
00131 int lua_ExtensionTriggerMenu( extensions_manager_t *p_mgr,
00132                               extension_t *p_ext, int id );
00133 
00134 /* Dialog specific */
00135 int lua_DialogFlush( lua_State *L );
00136 
00137 #endif // LUA_EXTENSION_H

Generated on Tue May 25 08:04:59 2010 for VLC by  doxygen 1.5.6