#define CONFIG_TEXT N_("Lua interface configuration")
#define CONFIG_LONGTEXT N_("Lua interface configuration string. Format is: '[\"<interface module name>\"] = { <option> = <value>, ...}, ...'.")
-#define HOST_TEXT N_( "Host address" )
-#define HOST_LONGTEXT N_( \
- "Address and port the HTTP interface will listen on. It defaults to " \
- "all network interfaces (0.0.0.0)." \
- " If you want the HTTP interface to be available only on the local " \
- "machine, enter 127.0.0.1" )
#define SRC_TEXT N_( "Source directory" )
#define SRC_LONGTEXT N_( "Source directory" )
#define INDEX_TEXT N_( "Directory index" )
static int vlc_sd_probe_Open( vlc_object_t * );
vlc_module_begin ()
- set_shortname( N_("Lua Interface Module") )
- set_description( N_("Interfaces implemented using lua scripts") )
- add_shortcut( "luaintf" )
- add_shortcut( "luahttp" )
- /* add_shortcut( "http" ) */
- add_shortcut( "luatelnet" )
- add_shortcut( "telnet" )
- add_shortcut( "luahotkeys" )
- /* add_shortcut( "hotkeys" ) */
- set_capability( "interface", 0 )
+ set_shortname( N_("Lua") )
+ set_description( N_("Lua interpreter") )
set_category( CAT_INTERFACE )
set_subcategory( SUBCAT_INTERFACE_CONTROL )
add_string( "lua-intf", "dummy",
INTF_TEXT, INTF_LONGTEXT, false )
add_string( "lua-config", "",
CONFIG_TEXT, CONFIG_LONGTEXT, false )
+ set_capability( "interface", 0 )
+ set_callbacks( Open_LuaIntf, Close_LuaIntf )
+ add_shortcut( "luaintf" )
+
+ add_submodule ()
set_section( N_("Lua HTTP"), 0 )
- add_string ( "http-host", NULL, HOST_TEXT, HOST_LONGTEXT, true )
add_string ( "http-src", NULL, SRC_TEXT, SRC_LONGTEXT, true )
add_bool ( "http-index", false, INDEX_TEXT, INDEX_LONGTEXT, true )
+ set_capability( "interface", 0 )
+ set_callbacks( Open_LuaHTTP, Close_LuaIntf )
+ add_shortcut( "luahttp", "http" )
+
+ add_submodule ()
set_section( N_("Lua CLI"), 0 )
add_string( "rc-host", NULL, RCHOST_TEXT, RCHOST_LONGTEXT, true )
add_string( "cli-host", NULL, CLIHOST_TEXT, CLIHOST_LONGTEXT, true )
+ set_capability( "interface", 25 )
+ set_callbacks( Open_LuaCLI, Close_LuaIntf )
+#ifndef WIN32
+ add_shortcut( "luacli", "luarc", "cli", "rc" )
+#else
+ add_shortcut( "luacli", "luarc" )
+#endif
+
+ add_submodule ()
set_section( N_("Lua Telnet"), 0 )
add_string( "telnet-host", "localhost", TELNETHOST_TEXT,
TELNETHOST_LONGTEXT, true )
add_integer( "telnet-port", TELNETPORT_DEFAULT, TELNETPORT_TEXT,
TELNETPORT_LONGTEXT, true )
add_password( "telnet-password", TELNETPWD_DEFAULT, TELNETPWD_TEXT,
+
TELNETPWD_LONGTEXT, true )
+ set_capability( "interface", 0 )
+ set_callbacks( Open_LuaTelnet, Close_LuaIntf )
+ add_shortcut( "luatelnet", "telnet" )
- set_callbacks( Open_LuaIntf, Close_LuaIntf )
+ /* add_shortcut( "luahotkeys" ) */
+ /* add_shortcut( "hotkeys" ) */
add_submodule ()
set_shortname( N_( "Lua Meta Fetcher" ) )
set_capability( "demux", 2 )
set_callbacks( Import_LuaPlaylist, Close_LuaPlaylist )
- add_submodule ()
- set_description( N_("Lua Interface Module (shortcuts)") )
- add_shortcut( "luacli" )
- add_shortcut( "luarc" )
-#ifndef WIN32
- add_shortcut( "cli" )
- add_shortcut( "rc" )
-#endif
- set_capability( "interface", 25 )
- set_callbacks( Open_LuaIntf, Close_LuaIntf )
-
add_submodule ()
set_shortname( N_( "Lua Art" ) )
set_description( N_("Fetch artwork using lua scripts") )
i++;
free( datadir );
-#if !(defined(__APPLE__) || defined(WIN32))
+#if !(defined(__APPLE__) || defined(WIN32) || defined(__OS2__))
if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s",
config_GetLibDir(), luadirname ) != -1) )
i++;
* Meta data setters utility.
* Playlist item table should be on top of the stack when these are called
*****************************************************************************/
-void __vlclua_read_meta_data( vlc_object_t *p_this, lua_State *L,
- input_item_t *p_input )
+#undef vlclua_read_meta_data
+void vlclua_read_meta_data( vlc_object_t *p_this, lua_State *L,
+ input_item_t *p_input )
{
#define TRY_META( a, b ) \
lua_getfield( L, -1, a ); \
TRY_META( "trackid", TrackID );
}
-void __vlclua_read_custom_meta_data( vlc_object_t *p_this, lua_State *L,
+#undef vlclua_read_custom_meta_data
+void vlclua_read_custom_meta_data( vlc_object_t *p_this, lua_State *L,
input_item_t *p_input )
{
+ /* Lock the input item and create the meta table if needed */
+ vlc_mutex_lock( &p_input->lock );
+
+ if( !p_input->p_meta )
+ p_input->p_meta = vlc_meta_New();
+
/* ... item */
lua_getfield( L, -1, "meta" );
/* ... item meta */
while( lua_next( L, -2 ) )
{
/* ... item meta key value */
- if( !lua_isstring( L, -2 ) )
- {
- msg_Warn( p_this, "Custom meta data category name must be "
- "a string" );
- }
- else if( !lua_istable( L, -1 ) )
- {
- msg_Warn( p_this, "Custom meta data category contents "
- "must be a table" );
- }
- else
+ if( !lua_isstring( L, -2 ) || !lua_isstring( L, -1 ) )
{
- const char *psz_meta_category = lua_tostring( L, -2 );
- msg_Dbg( p_this, "Found custom meta data category: %s",
- psz_meta_category );
- lua_pushnil( L );
- /* ... item meta key value nil */
- while( lua_next( L, -2 ) )
- {
- /* ... item meta key value key2 value2 */
- if( !lua_isstring( L, -2 ) )
- {
- msg_Warn( p_this, "Custom meta category item name "
- "must be a string." );
- }
- else if( !lua_isstring( L, -1 ) )
- {
- msg_Warn( p_this, "Custom meta category item value "
- "must be a string." );
- }
- else
- {
- const char *psz_meta_name =
- lua_tostring( L, -2 );
- const char *psz_meta_value =
- lua_tostring( L, -1 );
- msg_Dbg( p_this, "Custom meta %s, %s: %s",
- psz_meta_category, psz_meta_name,
- psz_meta_value );
- input_item_AddInfo( p_input, psz_meta_category,
- psz_meta_name, "%s", psz_meta_value );
- }
- lua_pop( L, 1 ); /* pop item */
- /* ... item meta key value key2 */
- }
- /* ... item meta key value */
+ msg_Err( p_this, "'meta' keys and values must be strings");
+ lua_pop( L, 1 ); /* pop "value" */
+ continue;
}
- lua_pop( L, 1 ); /* pop category */
- /* ... item meta key */
+ const char *psz_key = lua_tostring( L, -2 );
+ const char *psz_value = lua_tostring( L, -1 );
+
+ vlc_meta_AddExtra( p_input->p_meta, psz_key, psz_value );
+
+ lua_pop( L, 1 ); /* pop "value" */
}
- /* ... item meta */
}
lua_pop( L, 1 ); /* pop "meta" */
/* ... item -> back to original stack */
+
+ vlc_mutex_unlock( &p_input->lock );
}
/*****************************************************************************
/**
* Playlist item table should be on top of the stack when this is called
*/
-void __vlclua_read_options( vlc_object_t *p_this, lua_State *L,
+#undef vlclua_read_options
+void vlclua_read_options( vlc_object_t *p_this, lua_State *L,
int *pi_options, char ***pppsz_options )
{
lua_getfield( L, -1, "options" );
lua_pop( L, 1 ); /* pop "options" */
}
-int __vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
+#undef vlclua_playlist_add_internal
+int vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
playlist_t *p_playlist,
input_item_t *p_parent, bool b_play )
{
if( lua_isstring( L, -1 ) )
{
const char *psz_path = NULL;
+ char *psz_u8path = NULL;
const char *psz_name = NULL;
char **ppsz_options = NULL;
int i_options = 0;
{
if( !lua_isnil( L, -1 ) )
msg_Warn( p_this, "Playlist item name should be a string." );
- psz_name = psz_path;
+ psz_name = NULL;
}
/* Read duration */
vlclua_read_options( p_this, L, &i_options, &ppsz_options );
/* Create input item */
- p_input = input_item_NewExt( p_playlist, psz_path,
- psz_name, i_options,
+ p_input = input_item_NewExt( psz_path, psz_name, i_options,
(const char **)ppsz_options,
VLC_INPUT_OPTION_TRUSTED,
i_duration );
while( i_options > 0 )
free( ppsz_options[--i_options] );
free( ppsz_options );
+ free( psz_u8path );
}
else
{
return count;
}
-int __vlclua_add_modules_path( vlc_object_t *obj, lua_State *L, const char *psz_filename )
+#undef vlclua_add_modules_path
+int vlclua_add_modules_path( vlc_object_t *obj, lua_State *L, const char *psz_filename )
{
/* Setup the module search path:
* * "The script's directory"/modules