📄 vlc.c
字号:
} \ lua_pop( L, 1 ); /* pop a */ TRY_META( "title", Title ); TRY_META( "artist", Artist ); TRY_META( "genre", Genre ); TRY_META( "copyright", Copyright ); TRY_META( "album", Album ); TRY_META( "tracknum", TrackNum ); TRY_META( "description", Description ); TRY_META( "rating", Rating ); TRY_META( "date", Date ); TRY_META( "setting", Setting ); TRY_META( "url", URL ); TRY_META( "language", Language ); TRY_META( "nowplaying", NowPlaying ); TRY_META( "publisher", Publisher ); TRY_META( "encodedby", EncodedBy ); TRY_META( "arturl", ArtURL ); TRY_META( "trackid", TrackID );}void __vlclua_read_custom_meta_data( vlc_object_t *p_this, lua_State *L, input_item_t *p_input ){ /* ... item */ lua_getfield( L, -1, "meta" ); /* ... item meta */ if( lua_istable( L, -1 ) ) { lua_pushnil( L ); /* ... item meta nil */ 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 { 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, psz_meta_value ); } lua_pop( L, 1 ); /* pop item */ /* ... item meta key value key2 */ } /* ... item meta key value */ } lua_pop( L, 1 ); /* pop category */ /* ... item meta key */ } /* ... item meta */ } lua_pop( L, 1 ); /* pop "meta" */ /* ... item -> back to original stack */}/***************************************************************************** * Playlist utilities ****************************************************************************//** * 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, int *pi_options, char ***pppsz_options ){ lua_getfield( L, -1, "options" ); if( lua_istable( L, -1 ) ) { lua_pushnil( L ); while( lua_next( L, -2 ) ) { if( lua_isstring( L, -1 ) ) { char *psz_option = strdup( lua_tostring( L, -1 ) ); msg_Dbg( p_this, "Option: %s", psz_option ); INSERT_ELEM( *pppsz_options, *pi_options, *pi_options, psz_option ); } else { msg_Warn( p_this, "Option should be a string" ); } lua_pop( L, 1 ); /* pop option */ } } lua_pop( L, 1 ); /* pop "options" */}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 ){ int i_count = 0; assert( p_parent || p_playlist ); /* playlist */ if( lua_istable( L, -1 ) ) { lua_pushnil( L ); /* playlist nil */ while( lua_next( L, -2 ) ) { /* playlist key item */ /* <Parse playlist item> */ if( lua_istable( L, -1 ) ) { lua_getfield( L, -1, "path" ); /* playlist key item path */ if( lua_isstring( L, -1 ) ) { const char *psz_path = NULL; const char *psz_name = NULL; char **ppsz_options = NULL; int i_options = 0; mtime_t i_duration = -1; input_item_t *p_input; /* Read path and name */ psz_path = lua_tostring( L, -1 ); msg_Dbg( p_this, "Path: %s", psz_path ); lua_getfield( L, -2, "name" ); /* playlist key item path name */ if( lua_isstring( L, -1 ) ) { psz_name = lua_tostring( L, -1 ); msg_Dbg( p_this, "Name: %s", psz_name ); } else { if( !lua_isnil( L, -1 ) ) msg_Warn( p_this, "Playlist item name should be a string." ); psz_name = psz_path; } /* Read duration */ lua_getfield( L, -3, "duration" ); /* playlist key item path name duration */ if( lua_isnumber( L, -1 ) ) { i_duration = (mtime_t)(lua_tonumber( L, -1 )*1e6); } else if( !lua_isnil( L, -1 ) ) { msg_Warn( p_this, "Playlist item duration should be a number (in seconds)." ); } lua_pop( L, 1 ); /* pop "duration" */ /* playlist key item path name */ /* Read options: item must be on top of stack */ lua_pushvalue( L, -3 ); /* playlist key item path name item */ 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, (const char **)ppsz_options, i_duration ); lua_pop( L, 3 ); /* pop "path name item" */ /* playlist key item */ /* Read meta data: item must be on top of stack */ vlclua_read_meta_data( p_this, L, p_input ); /* Read custom meta data: item must be on top of stack*/ vlclua_read_custom_meta_data( p_this, L, p_input ); /* Append item to playlist */ if( p_parent ) /* Add to node */ input_item_AddSubItem( p_parent, p_input ); else /* Play or Enqueue (preparse) */ /* FIXME: playlist_AddInput() can fail */ playlist_AddInput( p_playlist, p_input, PLAYLIST_APPEND | ( b_play ? PLAYLIST_GO : PLAYLIST_PREPARSE ), PLAYLIST_END, true, false ); i_count ++; /* increment counter */ vlc_gc_decref( p_input ); while( i_options > 0 ) free( ppsz_options[--i_options] ); free( ppsz_options ); } else { lua_pop( L, 1 ); /* pop "path" */ msg_Warn( p_this, "Playlist item's path should be a string" ); } /* playlist key item */ } else { msg_Warn( p_this, "Playlist item should be a table" ); } /* <Parse playlist item> */ lua_pop( L, 1 ); /* pop the value, keep the key for * the next lua_next() call */ /* playlist key */ } /* playlist */ } else { msg_Warn( p_this, "Playlist should be a table." ); } return i_count;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -