[vlc-devel] [RFC PATCH] vout: add the window provider module
Steve Lhomme
robux4 at ycbcr.xyz
Thu Apr 4 05:50:21 CEST 2019
> On 3 Apr 2019, at 17:56, Thomas Guillem <thomas at gllm.fr> wrote:
>
> I didn't include is_decorated in this API, I don't really know the usecase.
>
It's possible to create a standalone video window with no button or chrome at all (and placed at a particular position with video-x and video-x). This can be useful.
> TODO:
> - Add vlc_player_SetWindowProvider(vlc_player_t, void *data, <callback_list>);
> - Document every callback inside vlc_player.h
> - Use it from QT and remove the old QT "vout window" plugin.
> - And later: plug it into libvlc, without breaking legacy window functions
>
> ---
> modules/video_output/Makefile.am | 2 +
> modules/video_output/wprovider.c | 193 +++++++++++++++++++++++++++++++
> 2 files changed, 195 insertions(+)
> create mode 100644 modules/video_output/wprovider.c
>
> diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
> index 3081e9c14e..0d8e0f834c 100644
> --- a/modules/video_output/Makefile.am
> +++ b/modules/video_output/Makefile.am
> @@ -473,6 +473,7 @@ libvdummy_plugin_la_SOURCES = video_output/vdummy.c
> libvideo_splitter_plugin_la_SOURCES = video_output/splitter.c
> libvmem_plugin_la_SOURCES = video_output/vmem.c
> libwdummy_plugin_la_SOURCES = video_output/wdummy.c
> +libwprovider_plugin_la_SOURCES = video_output/wprovider.c
> libyuv_plugin_la_SOURCES = video_output/yuv.c
> libvgl_plugin_la_SOURCES = video_output/vgl.c
>
> @@ -482,5 +483,6 @@ vout_LTLIBRARIES += \
> libvideo_splitter_plugin.la \
> libvmem_plugin.la \
> libwdummy_plugin.la \
> + libwprovider_plugin.la \
> libvgl_plugin.la \
> libyuv_plugin.la
> diff --git a/modules/video_output/wprovider.c b/modules/video_output/wprovider.c
> new file mode 100644
> index 0000000000..d087fe742b
> --- /dev/null
> +++ b/modules/video_output/wprovider.c
> @@ -0,0 +1,193 @@
> +/*****************************************************************************
> + * wprovider.c: window provider
> + *****************************************************************************
> + *****************************************************************************
> + * Copyright (C) 2019 VLC authors and VideoLAN
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as published by
> + * the Free Software Foundation; either version 2.1 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public License
> + * along with this program; if not, write to the Free Software Foundation,
> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
> + *****************************************************************************/
> +
> +#ifdef HAVE_CONFIG_H
> +# include <config.h>
> +#endif
> +
> +#include <assert.h>
> +
> +#include <vlc_common.h>
> +#include <vlc_plugin.h>
> +#include <vlc_vout_window.h>
> +
> +struct context
> +{
> + void *opaque;
> + int (*enable)(void *opaque, bool is_fullscreen,
> + unsigned width, unsigned height, unsigned *type,
> + void **handle);
> + void (*disable)(void *opaque);
> + void (*resize)(void *opaque, unsigned width, unsigned height);
> + void (*destroy)(void *opaque);
> + void (*set_state)(void *opaque, unsigned state);
> + void (*unset_fullscreen)(void *opaque);
> + void (*set_fullscreen)(void *opaque, const char *id);
> + void (*set_title)(void *opaque, const char *id);
> +};
> +
> +static int
> +Enable(struct vout_window_t *wnd, const vout_window_cfg_t *cfg)
> +{
> + struct context *ctx = wnd->sys;
> + assert(ctx->enable);
> +
> + unsigned type; void *handle;
> + int ret = ctx->enable(ctx->opaque, cfg->is_fullscreen,
> + cfg->width, cfg->height, &type, &handle);
> + if (ret == 0)
> + {
> + wnd->type = type;
> + switch (type)
> + {
> + case VOUT_WINDOW_TYPE_XID:
> + wnd->handle.xid = (uintptr_t) handle;
> + break;
> + case VOUT_WINDOW_TYPE_HWND:
> + wnd->handle.hwnd = handle;
> + break;
> + case VOUT_WINDOW_TYPE_NSOBJECT:
> + wnd->handle.nsobject = handle;
> + break;
> + case VOUT_WINDOW_TYPE_ANDROID_NATIVE:
> + wnd->handle.anativewindow = handle;
> + break;
> + case VOUT_WINDOW_TYPE_WAYLAND:
> + wnd->handle.wl = handle;
> + break;
> + default:
> + break;
> + }
> + }
> + return ret;
> +}
> +
> +static void
> +Disable(struct vout_window_t *wnd)
> +{
> + struct context *ctx = wnd->sys;
> +
> + if (ctx->disable)
> + ctx->disable(ctx->opaque);
> +}
> +
> +static void
> +Resize(struct vout_window_t *wnd, unsigned width, unsigned height)
> +{
> + struct context *ctx = wnd->sys;
> +
> + if (ctx->resize)
> + ctx->resize(ctx->opaque, width, height);
> +}
> +
> +static void
> +Destroy(struct vout_window_t *wnd)
> +{
> + struct context *ctx = wnd->sys;
> + if (ctx->destroy)
> + ctx->destroy(ctx->opaque);
> + free(ctx);
> +}
> +
> +static void
> +SetState(struct vout_window_t *wnd, unsigned state)
> +{
> + struct context *ctx = wnd->sys;
> +
> + if (ctx->set_state)
> + ctx->set_state(ctx->opaque, state);
> +}
> +
> +static void
> +UnsetFullscreen(struct vout_window_t *wnd)
> +{
> + struct context *ctx = wnd->sys;
> +
> + if (ctx->unset_fullscreen)
> + ctx->unset_fullscreen(ctx->opaque);
> +}
> +
> +static void
> +SetFullscreen(struct vout_window_t *wnd, const char *id)
> +{
> + struct context *ctx = wnd->sys;
> +
> + if (ctx->set_fullscreen)
> + ctx->set_fullscreen(ctx->opaque, id);
> +}
> +
> +static void
> +SetTitle(struct vout_window_t *wnd, const char *id)
> +{
> + struct context *ctx = wnd->sys;
> +
> + if (ctx->set_title)
> + ctx->set_title(ctx->opaque, id);
> +}
> +
> +static int Open(vout_window_t *wnd)
> +{
> + static const struct vout_window_operations ops = {
> + .enable = Enable,
> + .disable = Disable,
> + .resize = Resize,
> + .destroy = Destroy,
> + .set_state = SetState,
> + .unset_fullscreen = UnsetFullscreen,
> + .set_fullscreen = SetFullscreen,
> + .set_title = SetTitle
> + };
> +
> + struct context *ctx = malloc(sizeof(*ctx));
> + if (!ctx)
> + return VLC_ENOMEM;
> +
> + ctx->enable = var_InheritAddress(wnd, "wprovider-enable");
> + if (!ctx->enable)
> + {
> + free(ctx);
> + return VLC_EGENERIC;
> + }
> +
> + ctx->opaque = var_InheritAddress(wnd, "wprovider-data");
> + ctx->disable = var_InheritAddress(wnd, "wprovider-disable-cb");
> + ctx->resize = var_InheritAddress(wnd, "wprovider-resize-cb");
> + ctx->destroy = var_InheritAddress(wnd, "wprovider-destroy-cb");
> + ctx->set_state = var_InheritAddress(wnd, "wprovider-set-state-cb");
> + ctx->unset_fullscreen = var_InheritAddress(wnd, "wprovider-unset-fullscreen-cb");
> + ctx->set_fullscreen = var_InheritAddress(wnd, "wprovider-set-fullscreen-cb");
> + ctx->set_title = var_InheritAddress(wnd, "wprovider-set-title-cb");
> +
> + wnd->type = VOUT_WINDOW_TYPE_DUMMY;
> + wnd->ops = &ops;
> + wnd->sys = ctx;
> + wnd->info.has_double_click = var_InheritBool(wnd, "wprovider-has-double-click");
> + return VLC_SUCCESS;
> +}
> +
> +vlc_module_begin()
> + set_shortname(N_("Window provider"))
> + set_category(CAT_VIDEO)
> + set_subcategory(SUBCAT_VIDEO_VOUT)
> + set_capability("vout window", 0)
> + set_callbacks(Open, NULL)
> + add_shortcut("provider", "callbacks")
> +vlc_module_end()
> --
> 2.20.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list