static int Demux( demux_t *p_demux ) { lua_State *L = p_demux->p_sys->L; char *psz_filename = p_demux->p_sys->psz_filename; input_item_t *p_current_input = input_GetItem( p_demux->p_input ); luaL_register_namespace( L, "vlc", p_reg_parse ); lua_getglobal( L, "parse" ); if( !lua_isfunction( L, -1 ) ) { msg_Warn( p_demux, "Error while running script %s, " "function parse() not found", psz_filename ); return VLC_EGENERIC; } if( lua_pcall( L, 0, 1, 0 ) ) { msg_Warn( p_demux, "Error while running script %s, " "function parse(): %s", psz_filename, lua_tostring( L, lua_gettop( L ) ) ); return VLC_EGENERIC; } if( lua_gettop( L ) ) vlclua_playlist_add_internal( p_demux, L, NULL, p_current_input, 0 ); else msg_Err( p_demux, "Script went completely foobar" ); return -1; /* Needed for correct operation of go back */ }
static int vlclua_playlist_enqueue( lua_State *L ) { int i_count; vlc_object_t *p_this = vlclua_get_this( L ); playlist_t *p_playlist = vlclua_get_playlist_internal( L ); i_count = vlclua_playlist_add_internal( p_this, L, p_playlist, NULL, false ); lua_pushinteger( L, i_count ); return 1; }