[vlc-commits] Lua: split sd function for SD and for interfaces plugins (fixes #10308)
Rémi Denis-Courmont
git at videolan.org
Sun Mar 23 22:09:12 CET 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Mar 23 23:04:45 2014 +0200| [5384c38e49ced921fbe576465ef363e9369bcff2] | committer: Rémi Denis-Courmont
Lua: split sd function for SD and for interfaces plugins (fixes #10308)
Functions casting this to a services_discovery_t pointer are only
usable by SD plugins. Functions looking up the playlist are only usable
by interfaces plugins and extensions.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5384c38e49ced921fbe576465ef363e9369bcff2
---
modules/lua/extension.c | 2 +-
modules/lua/intf.c | 2 +-
modules/lua/libs.h | 3 ++-
modules/lua/libs/sd.c | 25 ++++++++++++++++++-------
modules/lua/services_discovery.c | 2 +-
share/lua/README.txt | 10 ++++++++--
6 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/modules/lua/extension.c b/modules/lua/extension.c
index 439083a..f1efb87 100644
--- a/modules/lua/extension.c
+++ b/modules/lua/extension.c
@@ -828,7 +828,7 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
luaopen_object( L );
luaopen_osd( L );
luaopen_playlist( L );
- luaopen_sd( L );
+ luaopen_sd_intf( L );
luaopen_stream( L );
luaopen_strings( L );
luaopen_variables( L );
diff --git a/modules/lua/intf.c b/modules/lua/intf.c
index f23eed3..9dacd8d 100644
--- a/modules/lua/intf.c
+++ b/modules/lua/intf.c
@@ -259,7 +259,7 @@ static int Start_LuaIntf( vlc_object_t *p_this, const char *name )
luaopen_object( L );
luaopen_osd( L );
luaopen_playlist( L );
- luaopen_sd( L );
+ luaopen_sd_intf( L );
luaopen_stream( L );
luaopen_strings( L );
luaopen_variables( L );
diff --git a/modules/lua/libs.h b/modules/lua/libs.h
index 7e62f18..1951cf8 100644
--- a/modules/lua/libs.h
+++ b/modules/lua/libs.h
@@ -35,7 +35,8 @@ void luaopen_net_intf( lua_State * );
void luaopen_object( lua_State * );
void luaopen_osd( lua_State * );
void luaopen_playlist( lua_State * );
-void luaopen_sd( lua_State * );
+void luaopen_sd_sd( lua_State * );
+void luaopen_sd_intf( lua_State * );
void luaopen_stream( lua_State * );
void luaopen_strings( lua_State * );
void luaopen_variables( lua_State * );
diff --git a/modules/lua/libs/sd.c b/modules/lua/libs/sd.c
index 1b54ca6..f162847 100644
--- a/modules/lua/libs/sd.c
+++ b/modules/lua/libs/sd.c
@@ -475,11 +475,7 @@ static int vlclua_node_add_subnode( lua_State *L )
/*****************************************************************************
*
*****************************************************************************/
-static const luaL_Reg vlclua_sd_reg[] = {
- { "get_services_names", vlclua_sd_get_services_names },
- { "add", vlclua_sd_add },
- { "remove", vlclua_sd_remove },
- { "is_loaded", vlclua_sd_is_loaded },
+static const luaL_Reg vlclua_sd_sd_reg[] = {
{ "add_node", vlclua_sd_add_node },
{ "add_item", vlclua_sd_add_item },
{ "remove_item", vlclua_sd_remove_item },
@@ -488,9 +484,24 @@ static const luaL_Reg vlclua_sd_reg[] = {
{ NULL, NULL }
};
-void luaopen_sd( lua_State *L )
+void luaopen_sd_sd( lua_State *L )
+{
+ lua_newtable( L );
+ luaL_register( L, NULL, vlclua_sd_sd_reg );
+ lua_setfield( L, -2, "sd" );
+}
+
+static const luaL_Reg vlclua_sd_intf_reg[] = {
+ { "get_services_names", vlclua_sd_get_services_names },
+ { "add", vlclua_sd_add },
+ { "remove", vlclua_sd_remove },
+ { "is_loaded", vlclua_sd_is_loaded },
+ { NULL, NULL }
+};
+
+void luaopen_sd_intf( lua_State *L )
{
lua_newtable( L );
- luaL_register( L, NULL, vlclua_sd_reg );
+ luaL_register( L, NULL, vlclua_sd_intf_reg );
lua_setfield( L, -2, "sd" );
}
diff --git a/modules/lua/services_discovery.c b/modules/lua/services_discovery.c
index c81d31b..74c8c6c 100644
--- a/modules/lua/services_discovery.c
+++ b/modules/lua/services_discovery.c
@@ -110,7 +110,7 @@ int Open_LuaSD( vlc_object_t *p_this )
luaopen_input( L );
luaopen_msg( L );
luaopen_object( L );
- luaopen_sd( L );
+ luaopen_sd_sd( L );
luaopen_strings( L );
luaopen_variables( L );
luaopen_stream( L );
diff --git a/share/lua/README.txt b/share/lua/README.txt
index dc506af..c29cc4a 100644
--- a/share/lua/README.txt
+++ b/share/lua/README.txt
@@ -310,13 +310,19 @@ playlist.move( id_item, id_where ): take id_item and if id_where has children, i
FIXME: add methods to get an item's meta, options, es ...
-SD
---
+Services discovery
+------------------
+
+Interfaces and extensions can use the following SD functions:
+
sd.get_services_names(): Get a table of all available service discovery
modules. The module name is used as key, the long name is used as value.
sd.add( name ): Add service discovery.
sd.remove( name ): Remove service discovery.
sd.is_loaded( name ): Check if service discovery is loaded.
+
+Services discovery scripts can use the following SD functions:
+
sd.add_node( ... ): Add a node to the service discovery.
The node object has the following members:
.title: the node's name
More information about the vlc-commits
mailing list