[vlc-commits] lua: libs: input: Allow a subtitle to be added by its mrl
Hugo Beauzée-Luyssen
git at videolan.org
Thu Sep 21 17:49:49 CEST 2017
vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Sep 21 13:57:21 2017 +0200| [78afc66c23094e32e589d4fae4cde9cce0b08fee] | committer: Hugo Beauzée-Luyssen
lua: libs: input: Allow a subtitle to be added by its mrl
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=78afc66c23094e32e589d4fae4cde9cce0b08fee
---
modules/lua/libs/input.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/modules/lua/libs/input.c b/modules/lua/libs/input.c
index 150bcb9d61..4c07c3ad01 100644
--- a/modules/lua/libs/input.c
+++ b/modules/lua/libs/input.c
@@ -224,7 +224,7 @@ static int vlclua_input_item_stats( lua_State *L )
return 1;
}
-static int vlclua_input_add_subtitle( lua_State *L )
+static int vlclua_input_add_subtitle( lua_State *L, bool b_path )
{
input_thread_t *p_input = vlclua_get_input_internal( L );
bool b_autoselect = false;
@@ -234,17 +234,32 @@ static int vlclua_input_add_subtitle( lua_State *L )
return luaL_error( L, "vlc.input.add_subtitle() usage: (path)" );
if( lua_gettop( L ) >= 2 )
b_autoselect = lua_toboolean( L, 2 );
- const char *psz_path = luaL_checkstring( L, 1 );
- char* psz_mrl = vlc_path2uri( psz_path, NULL );
- if( psz_mrl )
+ const char *psz_sub = luaL_checkstring( L, 1 );
+ if( !b_path )
+ input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_sub, b_autoselect, true );
+ else
{
- input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_mrl, b_autoselect, true );
- free( psz_mrl );
+ char* psz_mrl = vlc_path2uri( psz_sub, NULL );
+ if ( psz_mrl )
+ {
+ input_AddSlave( p_input, SLAVE_TYPE_SPU, psz_mrl, b_autoselect, true );
+ free( psz_mrl );
+ }
}
vlc_object_release( p_input );
return 1;
}
+static int vlclua_input_add_subtitle_path( lua_State *L )
+{
+ return vlclua_input_add_subtitle( L, true );
+}
+
+static int vlclua_input_add_subtitle_mrl( lua_State *L )
+{
+ return vlclua_input_add_subtitle( L, false );
+}
+
/*****************************************************************************
* Input items
*****************************************************************************/
@@ -394,7 +409,8 @@ static int vlclua_input_item_set_meta( lua_State *L )
static const luaL_Reg vlclua_input_reg[] = {
{ "is_playing", vlclua_input_is_playing },
{ "item", vlclua_input_item_get_current },
- { "add_subtitle", vlclua_input_add_subtitle },
+ { "add_subtitle", vlclua_input_add_subtitle_path },
+ { "add_subtitle_mrl", vlclua_input_add_subtitle_mrl },
{ NULL, NULL }
};
More information about the vlc-commits
mailing list