00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef VLC_LUA_H
00026 #define VLC_LUA_H
00027
00028
00029
00030
00031 #include <vlc_common.h>
00032 #include <vlc_input.h>
00033 #include <vlc_playlist.h>
00034 #include <vlc_meta.h>
00035 #include <vlc_url.h>
00036 #include <vlc_strings.h>
00037 #include <vlc_stream.h>
00038
00039 #include <lua.h>
00040 #include <lauxlib.h>
00041 #include <lualib.h>
00042
00043
00044
00045
00046 int ReadMeta( vlc_object_t * );
00047 int FetchMeta( vlc_object_t * );
00048 int FindArt( vlc_object_t * );
00049
00050 int Import_LuaPlaylist( vlc_object_t * );
00051 void Close_LuaPlaylist( vlc_object_t * );
00052
00053 int Open_LuaIntf( vlc_object_t * );
00054 void Close_LuaIntf( vlc_object_t * );
00055
00056 int Open_Extension( vlc_object_t * );
00057 void Close_Extension( vlc_object_t * );
00058
00059 int Open_LuaSD( vlc_object_t * );
00060 void Close_LuaSD( vlc_object_t * );
00061
00062
00063
00064
00065 static inline void lua_Dbg( vlc_object_t * p_this, const char * ppz_fmt, ... )
00066 {
00067 va_list ap;
00068 va_start( ap, ppz_fmt );
00069 msg_GenericVa( p_this, VLC_MSG_DBG, MODULE_STRING, ppz_fmt, ap );
00070 va_end( ap );
00071 }
00072
00073
00074
00075
00076 static inline int luaL_checkboolean( lua_State *L, int narg )
00077 {
00078 luaL_checktype( L, narg, LUA_TBOOLEAN );
00079 return lua_toboolean( L, narg );
00080 }
00081
00082 static inline int luaL_optboolean( lua_State *L, int narg, int def )
00083 {
00084 return luaL_opt( L, luaL_checkboolean, narg, def );
00085 }
00086
00087 static inline const char *luaL_nilorcheckstring( lua_State *L, int narg )
00088 {
00089 if( lua_isnil( L, narg ) )
00090 return NULL;
00091 return luaL_checkstring( L, narg );
00092 }
00093
00094 void vlclua_set_this( lua_State *, vlc_object_t * );
00095 #define vlclua_set_this(a, b) vlclua_set_this(a, VLC_OBJECT(b))
00096 vlc_object_t * vlclua_get_this( lua_State * );
00097
00098 struct intf_sys_t;
00099 void vlclua_set_intf( lua_State *, struct intf_sys_t * );
00100
00101
00102
00103
00104 #define vlclua_error( L ) luaL_error( L, "VLC lua error in file %s line %d (function %s)", __FILE__, __LINE__, __func__ )
00105 int vlclua_push_ret( lua_State *, int i_error );
00106
00107
00108
00109
00110
00111 int vlclua_scripts_batch_execute( vlc_object_t *p_this, const char * luadirname,
00112 int (*func)(vlc_object_t *, const char *, void *),
00113 void * user_data );
00114 int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname, char ***pppsz_dir_list );
00115 void vlclua_dir_list_free( char **ppsz_dir_list );
00116 char *vlclua_find_file( vlc_object_t *p_this, const char *psz_luadirname, const char *psz_name );
00117
00118
00119
00120
00121 void __vlclua_read_options( vlc_object_t *, lua_State *, int *, char *** );
00122 #define vlclua_read_options(a,b,c,d) __vlclua_read_options(VLC_OBJECT(a),b,c,d)
00123 void __vlclua_read_meta_data( vlc_object_t *, lua_State *, input_item_t * );
00124 #define vlclua_read_meta_data(a,b,c) __vlclua_read_meta_data(VLC_OBJECT(a),b,c)
00125 void __vlclua_read_custom_meta_data( vlc_object_t *, lua_State *,
00126 input_item_t *);
00127 #define vlclua_read_custom_meta_data(a,b,c) __vlclua_read_custom_meta_data(VLC_OBJECT(a),b,c)
00128 int __vlclua_playlist_add_internal( vlc_object_t *, lua_State *, playlist_t *,
00129 input_item_t *, bool );
00130 #define vlclua_playlist_add_internal(a,b,c,d,e) __vlclua_playlist_add_internal(VLC_OBJECT(a),b,c,d,e)
00131
00132 int __vlclua_add_modules_path( vlc_object_t *, lua_State *, const char *psz_filename );
00133 #define vlclua_add_modules_path( a, b, c ) __vlclua_add_modules_path(VLC_OBJECT(a), b, c)
00134
00135
00136
00137
00138 struct intf_sys_t
00139 {
00140 char *psz_filename;
00141 lua_State *L;
00142
00143 vlc_thread_t thread;
00144 vlc_mutex_t lock;
00145 vlc_cond_t wait;
00146 bool exiting;
00147 };
00148
00149 #endif
00150