mirror of
https://github.com/mpv-player/mpv
synced 2024-12-24 07:42:17 +00:00
0728726251
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.
89 lines
1.8 KiB
C
89 lines
1.8 KiB
C
#ifndef MP_OSD_STATE_H_
|
|
#define MP_OSD_STATE_H_
|
|
|
|
#include <pthread.h>
|
|
|
|
#include "osd.h"
|
|
|
|
enum mp_osdtype {
|
|
OSDTYPE_SUB,
|
|
OSDTYPE_SUB2, // IDs must be numerically successive
|
|
|
|
OSDTYPE_OSD,
|
|
|
|
OSDTYPE_EXTERNAL,
|
|
OSDTYPE_EXTERNAL2,
|
|
|
|
OSDTYPE_COUNT
|
|
};
|
|
|
|
struct ass_state {
|
|
struct mp_log *log;
|
|
struct ass_track *track;
|
|
struct ass_renderer *render;
|
|
struct ass_library *library;
|
|
int res_x, res_y;
|
|
};
|
|
|
|
struct osd_object {
|
|
int type; // OSDTYPE_*
|
|
bool is_sub;
|
|
|
|
// OSDTYPE_OSD
|
|
bool osd_changed;
|
|
char *text;
|
|
struct osd_progbar_state progbar_state;
|
|
|
|
// OSDTYPE_SUB/OSDTYPE_SUB2
|
|
struct dec_sub *sub;
|
|
|
|
// OSDTYPE_EXTERNAL
|
|
struct osd_external **externals;
|
|
int num_externals;
|
|
|
|
// OSDTYPE_EXTERNAL2
|
|
struct sub_bitmaps *external2;
|
|
|
|
// VO cache state
|
|
int vo_change_id;
|
|
struct mp_osd_res vo_res;
|
|
|
|
// Internally used by osd_libass.c
|
|
bool changed;
|
|
struct ass_state ass;
|
|
struct mp_ass_packer *ass_packer;
|
|
struct ass_image **ass_imgs;
|
|
};
|
|
|
|
struct osd_external {
|
|
struct osd_external_ass ov;
|
|
struct ass_state ass;
|
|
};
|
|
|
|
struct osd_state {
|
|
pthread_mutex_t lock;
|
|
|
|
struct osd_object *objs[MAX_OSD_PARTS];
|
|
|
|
bool render_subs_in_filter;
|
|
double force_video_pts;
|
|
|
|
bool want_redraw;
|
|
bool want_redraw_notification;
|
|
|
|
struct m_config_cache *opts_cache;
|
|
struct mp_osd_render_opts *opts;
|
|
struct mpv_global *global;
|
|
struct mp_log *log;
|
|
|
|
struct mp_draw_sub_cache *draw_cache;
|
|
};
|
|
|
|
// defined in osd_libass.c and osd_dummy.c
|
|
void osd_object_get_bitmaps(struct osd_state *osd, struct osd_object *obj,
|
|
int format, struct sub_bitmaps *out_imgs);
|
|
void osd_init_backend(struct osd_state *osd);
|
|
void osd_destroy_backend(struct osd_state *osd);
|
|
|
|
#endif
|