vlc | branch: master | Edward Wang <[email protected]> | Thu Jan 12 15:54:39 2012 -0500| [95f73b03b7933b767f82b3cb57851b7ff0214ff2] | committer: Jean-Baptiste Kempf
Lua SD: add methods to item object to change metadata Close #3474 Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=95f73b03b7933b767f82b3cb57851b7ff0214ff2 --- modules/lua/libs/sd.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ share/lua/README.txt | 20 +++++++++++++++ 2 files changed, 84 insertions(+), 0 deletions(-) diff --git a/modules/lua/libs/sd.c b/modules/lua/libs/sd.c index d1009c8..a1b97f1 100644 --- a/modules/lua/libs/sd.c +++ b/modules/lua/libs/sd.c @@ -54,6 +54,64 @@ static const luaL_Reg vlclua_node_reg[] = { { NULL, NULL } }; +#define vlclua_item_luareg( a ) \ +{ "set_" # a, vlclua_item_set_ ## a }, + +#define vlclua_item_meta( lowercase, normal ) \ +static int vlclua_item_set_ ## lowercase ( lua_State *L )\ +{\ + services_discovery_t *p_sd = (services_discovery_t *)vlclua_get_this( L );\ + input_item_t **pp_node = (input_item_t **)luaL_checkudata( L, 1, "input_item_t" );\ + if( *pp_node )\ + {\ + if( lua_isstring( L, -1 ) )\ + {\ + input_item_Set ## normal ( *pp_node, lua_tostring( L, -1 ) );\ + } else\ + msg_Err( p_sd, "Error parsing set_ " # lowercase " arguments" );\ + }\ + return 1;\ +} + +vlclua_item_meta(title, Title) +vlclua_item_meta(artist, Artist) +vlclua_item_meta(genre, Genre) +vlclua_item_meta(copyright, Copyright) +vlclua_item_meta(album, Album) +vlclua_item_meta(tracknum, TrackNum) +vlclua_item_meta(description, Description) +vlclua_item_meta(rating, Rating) +vlclua_item_meta(date, Date) +vlclua_item_meta(setting, Setting) +vlclua_item_meta(url, URL) +vlclua_item_meta(language, Language) +vlclua_item_meta(nowplaying, NowPlaying) +vlclua_item_meta(publisher, Publisher) +vlclua_item_meta(encodedby, EncodedBy) +vlclua_item_meta(arturl, ArtworkURL) +vlclua_item_meta(trackid, TrackID) + +static const luaL_Reg vlclua_item_reg[] = { + vlclua_item_luareg(title) + vlclua_item_luareg(artist) + vlclua_item_luareg(genre) + vlclua_item_luareg(copyright) + vlclua_item_luareg(album) + vlclua_item_luareg(tracknum) + vlclua_item_luareg(description) + vlclua_item_luareg(rating) + vlclua_item_luareg(date) + vlclua_item_luareg(setting) + vlclua_item_luareg(url) + vlclua_item_luareg(language) + vlclua_item_luareg(nowplaying) + vlclua_item_luareg(publisher) + vlclua_item_luareg(encodedby) + vlclua_item_luareg(arturl) + vlclua_item_luareg(trackid) + { NULL, NULL } +}; + static int vlclua_sd_get_services_names( lua_State *L ) { playlist_t *p_playlist = vlclua_get_playlist_internal( L ); @@ -185,6 +243,9 @@ static int vlclua_sd_add_item( lua_State *L ) *udata = p_input; if( luaL_newmetatable( L, "input_item_t" ) ) { + lua_newtable( L ); + luaL_register( L, NULL, vlclua_item_reg ); + lua_setfield( L, -2, "__index" ); lua_pushliteral( L, "none of your business" ); lua_setfield( L, -2, "__metatable" ); } @@ -257,6 +318,9 @@ static int vlclua_node_add_subitem( lua_State *L ) *udata = p_input; if( luaL_newmetatable( L, "input_item_t" ) ) { + lua_newtable( L ); + luaL_register( L, NULL, vlclua_item_reg ); + lua_setfield( L, -2, "__index" ); lua_pushliteral( L, "none of your business" ); lua_setfield( L, -2, "__metatable" ); } diff --git a/share/lua/README.txt b/share/lua/README.txt index 747d8e4..b22fbd0 100644 --- a/share/lua/README.txt +++ b/share/lua/README.txt @@ -338,6 +338,26 @@ n = vlc.sd.add_node( {title="Node"} ) n:add_subitem( ... ): Same as sd.add_item(), but as a subitem of n. n:add_subnode( ... ): Same as sd.add_node(), but as a subnode of n. +d = vlc.sd.add_item( ... ) Get an item object to perform following set operations on it: +d:set_name(): the item's name in playlist +d:set_title(): the item's Title (OPTIONAL, meta data) +d:set_artist(): the item's Artist (OPTIONAL, meta data) +d:set_genre(): the item's Genre (OPTIONAL, meta data) +d:set_copyright(): the item's Copyright (OPTIONAL, meta data) +d:set_album(): the item's Album (OPTIONAL, meta data) +d:set_tracknum(): the item's Tracknum (OPTIONAL, meta data) +d:set_description(): the item's Description (OPTIONAL, meta data) +d:set_rating(): the item's Rating (OPTIONAL, meta data) +d:set_date(): the item's Date (OPTIONAL, meta data) +d:set_setting(): the item's Setting (OPTIONAL, meta data) +d:set_url(): the item's URL (OPTIONAL, meta data) +d:set_language(): the item's Language (OPTIONAL, meta data) +d:set_nowplaying(): the item's NowPlaying (OPTIONAL, meta data) +d:set_publisher(): the item's Publisher (OPTIONAL, meta data) +d:set_encodedby(): the item's EncodedBy (OPTIONAL, meta data) +d:set_arturl(): the item's ArtURL (OPTIONAL, meta data) +d:set_trackid(): the item's TrackID (OPTIONAL, meta data) + Stream ------ stream( url ): Instantiate a stream object for specific url. _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
