vlc.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc.h: VLC specific lua library functions.
00003  *****************************************************************************
00004  * Copyright (C) 2007-2008 the VideoLAN team
00005  * $Id: 71dfcc78114fb0d9f7d188f61b83def3c6e45e31 $
00006  *
00007  * Authors: Antoine Cellerier <dionoea at videolan tod org>
00008  *          Pierre d'Herbemont <pdherbemont # videolan.org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef VLC_LUA_H
00026 #define VLC_LUA_H
00027 /*****************************************************************************
00028  * Preamble
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>        /* Low level lua C API */
00040 #include <lauxlib.h>    /* Higher level C API */
00041 #include <lualib.h>     /* Lua libs */
00042 
00043 /*****************************************************************************
00044  * Module entry points
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  * Lua debug
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  * Functions that should be in lua ... but aren't for some obscure reason
00075  *****************************************************************************/
00076 static inline int luaL_checkboolean( lua_State *L, int narg )
00077 {
00078     luaL_checktype( L, narg, LUA_TBOOLEAN ); /* can raise an error */
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  * Lua function bridge
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  * Will execute func on all scripts in luadirname, and stop if func returns
00109  * success.
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  * Playlist and meta data internal utilities.
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  * Per-interface private state
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 /* VLC_LUA_H */
00150 

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