-#define TRY_META( a, b ) \
- lua_getfield( p_state, t+2, a ); \
- if( lua_isstring( p_state, t+5 ) ) \
- { \
- psz_title = lua_tostring( p_state, t+5 ); \
- msg_Dbg( p_demux, #b ": %s", psz_title ); \
- vlc_meta_Set ## b ( p_input->p_meta, psz_title ); \
- } \
+ /* Read options */
+ lua_getfield( p_state, t+2, "options" );
+ if( lua_istable( p_state, t+5 ) )
+ {
+ lua_pushnil( p_state );
+ while( lua_next( p_state, t+5 ) )
+ {
+ if( lua_isstring( p_state, t+7 ) )
+ {
+ char *psz_option = strdup(
+ lua_tostring( p_state, t+7 ) );
+ msg_Dbg( p_demux, "Option: %s",
+ psz_option );
+ INSERT_ELEM( ppsz_options, i_options,
+ i_options, psz_option );
+ }
+ else
+ {
+ msg_Warn( p_demux,
+ "Option should be a string" );
+ }
+ lua_pop( p_state, 1 ); /* pop option */
+ }
+ }
+ lua_pop( p_state, 1 ); /* pop "options" */
+
+ /* Create input item */
+ p_input = input_ItemNewExt( p_playlist, psz_path,
+ psz_name, i_options,
+ (const char **)ppsz_options,
+ -1 );
+ lua_pop( p_state, 1 ); /* pop "name" */
+
+ /* Read meta data */
+ p_input->p_meta = vlc_meta_New();
+#define TRY_META( a, b ) \
+ lua_getfield( p_state, t+2, a ); \
+ if( lua_isstring( p_state, t+4 ) ) \
+ { \
+ psz_name = lua_tostring( p_state, t+4 ); \
+ msg_Dbg( p_demux, #b ": %s", psz_name ); \
+ vlc_meta_Set ## b ( p_input->p_meta, psz_name ); \
+ } \