summaryrefslogtreecommitdiffstats
path: root/video/filter
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-22 16:18:28 +0100
committerwm4 <wm4@nowhere>2016-01-22 16:18:28 +0100
commit135a7217b92c0b1c29ea40ab405566e72d23ae4b (patch)
tree491bfc975d15c4df6095a30720dd9bd404f73e70 /video/filter
parentce0b26c60ff31166b4b4317d269c52fe7d576c5c (diff)
downloadmpv-135a7217b92c0b1c29ea40ab405566e72d23ae4b.tar.bz2
mpv-135a7217b92c0b1c29ea40ab405566e72d23ae4b.tar.xz
command: add vf-command command
Diffstat (limited to 'video/filter')
-rw-r--r--video/filter/vf.c11
-rw-r--r--video/filter/vf.h3
-rw-r--r--video/filter/vf_lavfi.c8
3 files changed, 22 insertions, 0 deletions
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;