From 135a7217b92c0b1c29ea40ab405566e72d23ae4b Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 22 Jan 2016 16:18:28 +0100 Subject: command: add vf-command command --- video/filter/vf.c | 11 +++++++++++ video/filter/vf.h | 3 +++ video/filter/vf_lavfi.c | 8 ++++++++ 3 files changed, 22 insertions(+) (limited to 'video/filter') diff --git a/video/filter/vf.c b/video/filter/vf.c index 35de0f23a7..f710d81ea7 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -163,6 +163,17 @@ static void vf_control_all(struct vf_chain *c, int cmd, void *arg) } } +int vf_send_command(struct vf_chain *c, char *label, char *cmd, char *arg) +{ + char *args[2] = {cmd, arg}; + if (strcmp(label, "all") == 0) { + vf_control_all(c, VFCTRL_COMMAND, args); + return 0; + } else { + return vf_control_by_label(c, VFCTRL_COMMAND, args, bstr0(label)); + } +} + static void vf_fix_img_params(struct mp_image *img, struct mp_image_params *p) { // Filters must absolutely set these correctly. diff --git a/video/filter/vf.h b/video/filter/vf.h index f828d4e735..c982b612e1 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -144,6 +144,7 @@ enum vf_ctrl { /* Hack to make the OSD state object available to vf_sub which * access OSD/subtitle state outside of normal OSD draw time. */ VFCTRL_INIT_OSD, + VFCTRL_COMMAND, }; struct vf_chain *vf_new(struct mpv_global *global); @@ -164,6 +165,8 @@ struct vf_instance *vf_find_by_label(struct vf_chain *c, const char *label); void vf_print_filter_chain(struct vf_chain *c, int msglevel, struct vf_instance *vf); +int vf_send_command(struct vf_chain *c, char *label, char *cmd, char *arg); + // Filter internal API struct mp_image *vf_alloc_out_image(struct vf_instance *vf); bool vf_make_out_image_writeable(struct vf_instance *vf, struct mp_image *img); diff --git a/video/filter/vf_lavfi.c b/video/filter/vf_lavfi.c index e1705f6874..8cfd27a7bd 100644 --- a/video/filter/vf_lavfi.c +++ b/video/filter/vf_lavfi.c @@ -335,6 +335,14 @@ static int control(vf_instance_t *vf, int request, void *data) case VFCTRL_SEEK_RESET: reset(vf); return CONTROL_OK; + case VFCTRL_COMMAND: { + if (!vf->priv->graph) + break; + char **args = data; + return avfilter_graph_send_command(vf->priv->graph, "all", + args[0], args[1], &(char){0}, 0, 0) + >= 0 ? CONTROL_OK : CONTROL_ERROR; + } case VFCTRL_GET_METADATA: if (vf->priv && vf->priv->metadata) { *(struct mp_tags *)data = *vf->priv->metadata; -- cgit v1.2.3