summaryrefslogtreecommitdiffstats
path: root/player/lua.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-23 11:40:27 +0100
committerwm4 <wm4@nowhere>2019-12-23 11:44:24 +0100
commit07287262513c0d1ea46b7beaf100e73f2008295f (patch)
tree01548db64854e14caf2f0985fde8696488e57247 /player/lua.c
parent96932fe77c912f86d8fc51e073b4fd26a124a1fb (diff)
downloadmpv-07287262513c0d1ea46b7beaf100e73f2008295f.tar.bz2
mpv-07287262513c0d1ea46b7beaf100e73f2008295f.tar.xz
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is used by osc.lua and console.lua. Apparently, 3rd party scripts also use this. It's probably time to make this a public API. The Lua implementation just bypassed the libmpv API. To make it usable by any type of client, turn it into a command, "osd-overlay". There's already a "overlay-add". Ignore it (although the manpage admits guiltiness). I don't really want to deal with that old command. Its main problem is that it uses global IDs, while I'd like to avoid that scripts mess with each others overlays (whether that is accidentally or intentionally). Maybe "overlay-add" can eventually be merged into "osd-overlay", but I'm too lazy to do that now. Scripting now uses the commands. There is a helper to manage OSD overlays. The helper is very "thin"; I only want to force script authors to use the ID allocation, which may help with putting multiple scripts into a single .lua file without causing conflicts (basically, avoiding singletons within a script's environment). The old set_osd_ass() is emulated with the new API. The JS scripting wrapper also provides a set_osd_ass() function, which calls internal mpv API. Comment that part (to keep it compiling), but I'm leaving it to @avih to finish the change.
Diffstat (limited to 'player/lua.c')
-rw-r--r--player/lua.c27
1 files changed, 0 insertions, 27 deletions
diff --git a/player/lua.c b/player/lua.c
index 69977dfd42..aec9908b69 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -998,31 +998,6 @@ static int script_raw_abort_async_command(lua_State *L)
return 0;
}
-static int script_set_osd_ass(lua_State *L)
-{
- struct script_ctx *ctx = get_ctx(L);
- int res_x = luaL_checkinteger(L, 1);
- int res_y = luaL_checkinteger(L, 2);
- const char *text = luaL_checkstring(L, 3);
- if (!text[0])
- text = " "; // force external OSD initialization
- osd_set_external(ctx->mpctx->osd, ctx->client, res_x, res_y, (char *)text);
- mp_wakeup_core(ctx->mpctx);
- return 0;
-}
-
-static int script_get_osd_size(lua_State *L)
-{
- struct MPContext *mpctx = get_mpctx(L);
- struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd);
- double aspect = 1.0 * vo_res.w / MPMAX(vo_res.h, 1) /
- (vo_res.display_par ? vo_res.display_par : 1);
- lua_pushnumber(L, vo_res.w);
- lua_pushnumber(L, vo_res.h);
- lua_pushnumber(L, aspect);
- return 3;
-}
-
static int script_get_osd_margins(lua_State *L)
{
struct MPContext *mpctx = get_mpctx(L);
@@ -1275,8 +1250,6 @@ static const struct fn_entry main_fns[] = {
FN_ENTRY(set_property_native),
FN_ENTRY(raw_observe_property),
FN_ENTRY(raw_unobserve_property),
- FN_ENTRY(set_osd_ass),
- FN_ENTRY(get_osd_size),
FN_ENTRY(get_osd_margins),
FN_ENTRY(get_mouse_pos),
FN_ENTRY(get_time),