[vlc-commits] LUA: add support for category field in SD nodes and items

Gaurav Narula git at videolan.org
Tue Jan 17 23:30:13 CET 2012


vlc/vlc-1.2 | branch: master | Gaurav Narula <gnarula94 at gmail.com> | Mon Jan 16 04:02:32 2012 +0530| [ead8a18c357650e9e7ba2077369d6891e955e997] | committer: Jean-Baptiste Kempf

LUA: add support for category field in SD nodes and items

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit f8fa7854726df936f683f239c726f4719cb82ca7)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=ead8a18c357650e9e7ba2077369d6891e955e997
---

 modules/lua/libs/sd.c |   14 +++++++++++---
 share/lua/README.txt  |    4 +++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/modules/lua/libs/sd.c b/modules/lua/libs/sd.c
index 033a896..8096ce4 100644
--- a/modules/lua/libs/sd.c
+++ b/modules/lua/libs/sd.c
@@ -190,7 +190,9 @@ static int vlclua_sd_add_node( lua_State *L )
                     input_item_SetArtURL( p_input, psz_value );
                     free( psz_value );
                 }
-                services_discovery_AddItem( p_sd, p_input, NULL );
+                lua_pop( L, 1 );
+                lua_getfield( L, -1, "category" );
+                services_discovery_AddItem( p_sd, p_input, luaL_checkstring( L, -1 ) );
                 input_item_t **udata = (input_item_t **)
                                        lua_newuserdata( L, sizeof( input_item_t * ) );
                 *udata = p_input;
@@ -222,8 +224,12 @@ static int vlclua_sd_add_item( lua_State *L )
             char **ppsz_options = NULL;
             int i_options = 0;
             const char *psz_path = lua_tostring( L, -1 );
+
             vlclua_read_options( p_sd, L, &i_options, &ppsz_options );
-            input_item_t *p_input = input_item_NewExt( psz_path, psz_path,
+            lua_pop( L, 1 );
+            lua_getfield( L, -1, "title" );
+            const char *psz_title = luaL_checkstring( L, -1 ) ? luaL_checkstring( L, -1 ) : psz_path;
+            input_item_t *p_input = input_item_NewExt( psz_path, psz_title,
                                                        i_options,
                                                        (const char **)ppsz_options,
                                                        VLC_INPUT_OPTION_TRUSTED, -1 );
@@ -241,7 +247,9 @@ static int vlclua_sd_add_item( lua_State *L )
                 else if( !lua_isnil( L, -1 ) )
                     msg_Warn( p_sd, "Item duration should be a number (in seconds)." );
                 lua_pop( L, 1 );
-                services_discovery_AddItem( p_sd, p_input, NULL );
+                lua_getfield( L, -1, "category" );
+                services_discovery_AddItem( p_sd, p_input, luaL_checkstring( L, -1 ) );
+                lua_pop( L, 1 );
                 input_item_t **udata = (input_item_t **)
                                        lua_newuserdata( L, sizeof( input_item_t * ) );
                 *udata = p_input;
diff --git a/share/lua/README.txt b/share/lua/README.txt
index 5048b51..52b5f5a 100644
--- a/share/lua/README.txt
+++ b/share/lua/README.txt
@@ -329,8 +329,10 @@ sd.add_node( ... ): Add a node to the service discovery.
   The node object has the following members:
       .title: the node's name
       .arturl: the node's ArtURL (OPTIONAL)
+      .category: the node's category (OPTIONAL)
 sd.add_item( ... ): Add an item to the service discovery.
-  The item object has the same members as the one in playlist.add().
+  The item object has the same members as the one in playlist.add() along with:
+      .category: the item's category (OPTIONAL)
   Returns the input item.
 sd.remove_item( item ): remove the item.
 



More information about the vlc-commits mailing list