From 6048f87e3c07d03df8a59da58c81608c5375f6dc Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 26 Sep 2013 00:41:14 +0200 Subject: Add initial Lua scripting support This is preliminary. There are still tons of issues, and any aspect of scripting may change in the future. I decided to merge this (preliminary) work now because it makes it easier to develop it, not because it's done. lua.rst is clear enough about it (plus some sarcasm). This requires linking to Lua. Lua has no official pkg-config file, but there are distribution specific .pc files, all with different names. Adding a non-pkg-config based configure test was considered, but we'd rather not. One major complication is that libquvi links against Lua too, and if the Lua version is different from mpv's, you will get a crash as soon as libquvi uses Lua. (libquvi by design always runs when a file is opened.) I would consider this the problem of distros and whoever builds mpv, but to make things easier for users, we add a terrible runtime test to the configure script, which probes whether libquvi will crash. This is disabled when cross-compiling, but in that case we hope the user knows what he is doing. --- sub/osd_libass.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'sub/osd_libass.c') diff --git a/sub/osd_libass.c b/sub/osd_libass.c index 36e2a0ca0f..45edbc7cc8 100644 --- a/sub/osd_libass.c +++ b/sub/osd_libass.c @@ -347,6 +347,38 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj) ass_draw_reset(d); } +static void update_external(struct osd_state *osd, struct osd_object *obj) +{ + create_osd_ass_track(osd, obj); + clear_obj(obj); + + if (osd->external_res_x < 1 || osd->external_res_y < 1) + return; + + ASS_Track *track = obj->osd_track; + + if (track->PlayResX != osd->external_res_x || + track->PlayResY != osd->external_res_y) + { + track->PlayResX = osd->external_res_x; + track->PlayResY = osd->external_res_y; + // Force libass to clear its internal cache - it doesn't check for + // PlayRes changes itself. + ass_set_frame_size(osd->osd_render, 1, 1); + } + + bstr t = bstr0(osd->external); + while (t.len) { + bstr line; + bstr_split_tok(t, "\n", &line, &t); + if (line.len) { + char *tmp = bstrdup0(NULL, line); + add_osd_ass_event(obj->osd_track, tmp); + talloc_free(tmp); + } + } +} + static void update_sub(struct osd_state *osd, struct osd_object *obj) { struct MPOpts *opts = osd->opts; @@ -386,6 +418,9 @@ static void update_object(struct osd_state *osd, struct osd_object *obj) case OSDTYPE_PROGBAR: update_progbar(osd, obj); break; + case OSDTYPE_EXTERNAL: + update_external(osd, obj); + break; } } @@ -405,3 +440,10 @@ void osd_object_get_bitmaps(struct osd_state *osd, struct osd_object *obj, &obj->parts_cache, out_imgs); talloc_steal(obj, obj->parts_cache); } + +void osd_object_get_resolution(struct osd_state *osd, struct osd_object *obj, + int *out_w, int *out_h) +{ + *out_w = obj->osd_track ? obj->osd_track->PlayResX : 0; + *out_h = obj->osd_track ? obj->osd_track->PlayResY : 0; +} -- cgit v1.2.3