input_item_t * GetCurrentItem(demux_t *p_demux) { input_thread_t *p_input_thread = demux_GetParentInput( p_demux ); input_item_t *p_current_input = input_GetItem( p_input_thread ); vlc_gc_incref(p_current_input); vlc_object_release(p_input_thread); return p_current_input; }
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_thread_t *p_input_thread = demux_GetParentInput( p_demux ); input_item_t *p_current_input = input_GetItem( p_input_thread ); playlist_t *p_playlist = pl_Hold( p_demux ); luaL_register( L, "vlc", p_reg_parse ); lua_getglobal( L, "parse" ); if( !lua_isfunction( L, -1 ) ) { msg_Warn( p_demux, "Error while runing script %s, " "function parse() not found", psz_filename ); pl_Release( p_demux ); return VLC_EGENERIC; } if( lua_pcall( L, 0, 1, 0 ) ) { msg_Warn( p_demux, "Error while runing script %s, " "function parse(): %s", psz_filename, lua_tostring( L, lua_gettop( L ) ) ); pl_Release( p_demux ); return VLC_EGENERIC; } if( lua_gettop( L ) ) vlclua_playlist_add_internal( p_demux, L, p_playlist, p_current_input, 0 ); else msg_Err( p_demux, "Script went completely foobar" ); vlc_object_release( p_input_thread ); vlclua_release_playlist_internal( p_playlist ); return -1; /* Needed for correct operation of go back */ }