[vlc-devel] [PATCH 13/15] video_output: Add PPAPI plugin

Thomas Guillem thomas at gllm.fr
Thu Mar 9 11:29:11 CET 2017



On Wed, Mar 8, 2017, at 15:55, Julian Scheel wrote:
> ---
>  configure.ac                         |   1 +
>  include/vlc_vout_window.h            |   9 +
>  modules/video_output/Makefile.am     |  19 ++
>  modules/video_output/ppapi/display.c | 324
>  +++++++++++++++++++++++++++++++++++
>  modules/video_output/ppapi/gl.c      | 133 ++++++++++++++
>  modules/video_output/ppapi/window.c  |  96 +++++++++++
>  6 files changed, 582 insertions(+)
>  create mode 100644 modules/video_output/ppapi/display.c
>  create mode 100644 modules/video_output/ppapi/gl.c
>  create mode 100644 modules/video_output/ppapi/window.c
> 
> diff --git a/configure.ac b/configure.ac
> index 6a0958c9d7..b74cea42a0 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -300,6 +300,7 @@ case "${host_os}" in
>    *nacl*)
>      SYS=nacl
>      AC_DEFINE([_XOPEN_SOURCE], [700], [POSIX and XPG 7th edition])
> +    VLC_ADD_LIBS([nacl],[-lppapi -lppapi_gles2])
>      ;;
>    *)
>      SYS="${host_os}"
> diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h
> index 69a719bd2a..6f32a94e12 100644
> --- a/include/vlc_vout_window.h
> +++ b/include/vlc_vout_window.h
> @@ -43,6 +43,9 @@ typedef struct vout_window_sys_t vout_window_sys_t;
>  struct wl_display;
>  struct wl_surface;
>  
> +struct PPB_Graphics3D_1_0;
> +typedef struct PPB_Graphics3D_1_0 PPB_Graphics3D;
> +
>  /**
>   * Window handle type
>   */
> @@ -53,6 +56,7 @@ enum {
>      VOUT_WINDOW_TYPE_NSOBJECT,
>      VOUT_WINDOW_TYPE_ANDROID_NATIVE,
>      VOUT_WINDOW_TYPE_WAYLAND,
> +    VOUT_WINDOW_TYPE_PPAPI,
>  };
>  
>  /**
> @@ -133,12 +137,17 @@ struct vout_window_t {
>          void     *nsobject;      /* Mac OSX view object */
>          void     *anativewindow; /* Android native window. */
>          struct wl_surface *wl;   /* Wayland surface */
> +        int32_t  pp_context;     /* PPAPI context ID */
>      } handle;
>  
>      /* display server (mandatory) */
>      union {
>          char     *x11; /* X11 display (NULL = use default) */
>          struct wl_display *wl;   /* Wayland struct wl_display pointer */
> +        struct {
> +            int32_t pp_instance;           /* PPAPI instance ID */
> +            PPB_Graphics3D *pp_graphics3d; /* PPAPI graphics3d resource
> pointer */
> +        } ppapi;
>      } display;
>  
>      /* Control on the module (mandatory)
> diff --git a/modules/video_output/Makefile.am
> b/modules/video_output/Makefile.am
> index 483a197053..d85a7958e9 100644
> --- a/modules/video_output/Makefile.am
> +++ b/modules/video_output/Makefile.am
> @@ -337,6 +337,25 @@ endif
>  endif
>  
>  
> +## NaCl/PPAPI ###
> +
> +libppapi_gl_plugin_la_SOURCES = video_output/ppapi/gl.c
> $(OPENGL_COMMONSOURCES)

You don't need $(OPENGL_COMMONSOURCES) for a gl ext module.

> +libppapi_gl_plugin_la_CFLAGS = $(AM_CFLAGS) -DUSE_OPENGL_ES2
> +libppapi_gl_plugin_la_LIBADD = $(LIBS_nacl)
> +
> +libppapi_window_plugin_la_SOURCES = video_output/ppapi/window.c
> +libppapi_window_plugin_la_CFLAGS = $(AM_CFLAGS)
> +libppapi_window_plugin_la_LIBADD = $(LIBS_nacl)
> +
> +libppapi_display_plugin_la_SOURCES = video_output/ppapi/display.c
> $(OPENGL_COMMONSOURCES)
> +libppapi_display_plugin_la_CFLAGS = $(AM_CFLAGS) -DUSE_OPENGL_ES2
> +libppapi_display_plugin_la_LIBADD = $(LIBS_nacl)
> +
> +if HAVE_NACL
> +vout_LTLIBRARIES += libppapi_gl_plugin.la libppapi_window_plugin.la
> libppapi_display_plugin.la
> +endif
> +
> +
>  ### FrameBuffer ###
>  
>  libdirectfb_plugin_la_SOURCES = video_output/directfb.c
> diff --git a/modules/video_output/ppapi/display.c
> b/modules/video_output/ppapi/display.c
> new file mode 100644
> index 0000000000..41d2fc86f0
> --- /dev/null
> +++ b/modules/video_output/ppapi/display.c
> @@ -0,0 +1,324 @@
> +/*****************************************************************************
> + * display.c: Main video_output module for PPAPI/NaCl
> +
> *****************************************************************************
> + * Copyright © 2017 VLC authors and VideoLAN
> + *
> + * Authors: Julian Scheel <julian at jusst.de>
> + *
> + * 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 <vlc_common.h>
> +#include <vlc_plugin.h>
> +#include <vlc_vout_display.h>
> +#include <vlc_opengl.h>
> +
> +#include "../opengl/vout_helper.h"
> +
> +#include <ppapi/c/ppb.h>
> +#include <ppapi/c/ppb_core.h>
> +#include <ppapi/c/ppb_graphics_3d.h>
> +#include <ppapi/c/ppb_instance.h>
> +#include <ppapi/c/ppb_view.h>
> +#include <ppapi/c/pp_errors.h>
> +#include <ppapi/c/pp_instance.h>
> +
> +/*****************************************************************************
> + * Module descriptor
> +
> *****************************************************************************/
> +static int Open(vlc_object_t*);
> +static void Close(vlc_object_t*);
> +
> +vlc_module_begin()
> +    set_shortname("PPAPI Graphics3D")
> +    set_description(N_("PPAPI OpenGL output using Graphics3D
> interface"))
> +    set_category(CAT_VIDEO)
> +    set_subcategory(SUBCAT_VIDEO_VOUT)
> +
> +    set_capability("vout display", 10)
> +    set_callbacks(Open, Close)
> +    add_shortcut("ppapi", "opengl", "gles")
> +vlc_module_end()
> +
> +struct vout_display_sys_t {
> +    PP_Instance instance;
> +    PP_Resource context;
> +    PP_Resource viewport;
> +    PPB_Graphics3D *graphics3d;
> +    PPB_View *view;
> +    PPB_Core *core;
> +
> +    vout_display_opengl_t *vgl;
> +    picture_pool_t *pool;
> +    vlc_gl_t *gl;
> +};
> +
> +static int GetViewSize(vout_display_t *vd, int32_t *width, int32_t
> *height)
> +{
> +    vout_display_sys_t *sys = vd->sys;
> +
> +    struct PP_Rect rect;
> +    if (sys->viewport &&
> +            sys->view->IsView(sys->viewport) &&
> +            sys->view->GetRect(sys->viewport, &rect)) {
> +        *width = rect.size.width;
> +        *height = rect.size.height;
> +        return VLC_SUCCESS;
> +    }
> +
> +    return VLC_EGENERIC;
> +}
> +
> +static picture_pool_t* Pool(vout_display_t *vd, unsigned
> requested_count)
> +{
> +    vout_display_sys_t *sys = vd->sys;
> +
> +    if (sys->pool == NULL) {
> +        if (vlc_gl_MakeCurrent(sys->gl))
> +            return NULL;
> +        sys->pool = vout_display_opengl_GetPool(sys->vgl,
> requested_count);
> +        vlc_gl_ReleaseCurrent(sys->gl);
> +    }
> +
> +    return sys->pool;
> +}
> +
> +static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t
> *subpicture)
> +{
> +    vout_display_sys_t *sys = vd->sys;
> +
> +    /* FIXME: MakeCurrent needed? */
> +    if (vlc_gl_MakeCurrent(sys->gl))
> +        return;
> +    vout_display_opengl_Prepare(sys->vgl, picture, subpicture);
> +    vlc_gl_ReleaseCurrent(sys->gl);
> +}
> +
> +static void Display(vout_display_t *vd, picture_t *picture, subpicture_t
> *subpicture)
> +{
> +    vout_display_sys_t *sys = vd->sys;
> +
> +    if (sys->viewport &&
> +            sys->view->IsView(sys->viewport) &&
> +            !sys->view->IsVisible(sys->viewport))
> +        goto release;
> +
> +    /* FIXME: MakeCurrent needed? */
> +    if (vlc_gl_MakeCurrent(sys->gl))
> +        return;
> +    vout_display_opengl_Display(sys->vgl, &vd->source);
> +    vlc_gl_ReleaseCurrent(sys->gl);
> +
> +release:
> +    picture_Release(picture);
> +    if (subpicture)
> +        subpicture_Delete(subpicture);
> +}
> +
> +static int Control(vout_display_t *vd, int query, va_list ap) {
> +    vout_display_sys_t *sys = vd->sys;
> +
> +    switch (query) {
> +        case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
> +        case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
> +        case VOUT_DISPLAY_CHANGE_ZOOM:
> +        {
> +            const vout_display_cfg_t *cfg = va_arg(ap, const
> vout_display_cfg_t*);
> +            const video_format_t *src = &vd->source;
> +            vout_display_place_t place;
> +
> +            vout_display_PlacePicture(&place, src, cfg, false);
> +            vlc_gl_MakeCurrent(sys->gl);
> +            vlc_gl_Resize(sys->gl, place.width, place.height);
> +            if (sys->graphics3d->ResizeBuffers(sys->context,
> cfg->display.width, cfg->display.height) != PP_OK)
> +                return VLC_EGENERIC;
> +
> +            glViewport(place.x, place.y, place.width, place.height);
> +            vlc_gl_ReleaseCurrent(sys->gl);
> +            return VLC_SUCCESS;
> +        }
> +        case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
> +        case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
> +        {
> +            const vout_display_cfg_t *cfg = vd->cfg;
> +            const video_format_t *src = va_arg(ap, const
> video_format_t*);
> +            vout_display_place_t place;
> +
> +            vout_display_PlacePicture(&place, src, cfg, false);
> +            vlc_gl_MakeCurrent(sys->gl);
> +            glViewport(place.x, place.y, place.width, place.height);
> +            vlc_gl_ReleaseCurrent(sys->gl);
> +            return VLC_SUCCESS;
> +        }
> +        default:
> +            msg_Warn(vd, "Unknown Control request: %d", query);
> +            break;
> +    }
> +
> +    return VLC_EGENERIC;
> +}
> +
> +static void Manage(vout_display_t *vd)
> +{
> +    vout_display_sys_t *sys = vd->sys;
> +
> +    sys->viewport = var_InheritInteger(vd, "ppapi-view");
> +
> +    int32_t width, height;
> +    if (GetViewSize(vd, &width, &height) != VLC_SUCCESS)
> +        return;
> +
> +    if (((unsigned)width != vd->cfg->display.width) ||
> +            ((unsigned)height != vd->cfg->display.height)) {
> +        vout_display_SendEventDisplaySize(vd, width, height);
> +    }
> +}
> +
> +static int Open(vlc_object_t *obj)
> +{
> +    vout_display_t *vd = (vout_display_t*)obj;
> +    vout_display_sys_t *sys;
> +
> +    vd->sys = sys = calloc(1, sizeof(*sys));
> +    if (sys == NULL)
> +        return VLC_ENOMEM;
> +
> +    /* Create surface/window */
> +    vout_window_t *surface = vout_display_NewWindow(vd,
> VOUT_WINDOW_TYPE_PPAPI);
> +    if (surface == NULL) {
> +        msg_Err(vd, "Failed to create window");
> +        goto error;
> +    }
> +
> +    sys->instance = surface->display.ppapi.pp_instance;
> +    if (sys->instance == 0) {
> +        msg_Err(vd, "Invalid Pepper instance");
> +        goto error;
> +    }
> +
> +    PPB_GetInterface ppb_get_interface = var_InheritAddress(obj,
> "ppapi-ppb-get-interface");
> +    if (ppb_get_interface == NULL) {
> +        msg_Err(vd, "Variable ppapi-ppb-get-interface is not set");
> +        goto error;
> +    }
> +
> +    sys->core = (PPB_Core*)ppb_get_interface(PPB_CORE_INTERFACE);
> +    if (sys->core == NULL) {
> +        msg_Err(vd, "Failed to get PPB_CORE_INTERFACE");
> +        goto error;
> +    }
> +
> +    sys->graphics3d =
> (PPB_Graphics3D*)ppb_get_interface(PPB_GRAPHICS_3D_INTERFACE);
> +    if (sys->graphics3d == NULL) {
> +        msg_Err(vd, "Failed to get PPB_GRAPHICS_3D_INTERFACE");
> +        goto error;
> +    }
> +    surface->display.ppapi.pp_graphics3d = sys->graphics3d;
> +
> +    sys->view = (PPB_View*)ppb_get_interface(PPB_VIEW_INTERFACE);
> +    if (sys->view == NULL) {
> +        msg_Err(vd, "Failed to get PPB_VIEW_INTERFACE");
> +        goto error;
> +    }
> +
> +    int32_t attr[] = {
> +        PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 0,
> +        PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8,
> +        PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8,
> +        PP_GRAPHICS3DATTRIB_RED_SIZE, 8,
> +        PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 0,
> +        PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0,
> +        PP_GRAPHICS3DATTRIB_WIDTH, (int32_t)vd->fmt.i_width,
> +        PP_GRAPHICS3DATTRIB_HEIGHT, (int32_t)vd->fmt.i_height,
> +        PP_GRAPHICS3DATTRIB_GPU_PREFERENCE,
> PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER,
> +        PP_GRAPHICS3DATTRIB_NONE
> +    };
> +    sys->context = sys->graphics3d->Create(sys->instance, 0, attr);
> +    if(!sys->context) {
> +        msg_Err(vd, "Failed to create context");
> +        goto error;
> +    }
> +    surface->handle.pp_context = sys->context;
> +
> +    PPB_Instance *instance =
> (PPB_Instance*)ppb_get_interface(PPB_INSTANCE_INTERFACE);
> +    if (instance == NULL) {
> +        msg_Err(vd, "Failed to get PPB_INSTANCE_INTERFACE");
> +        goto error;
> +    }
> +
> +    if (instance->BindGraphics(sys->instance, sys->context) != PP_TRUE)
> {
> +        msg_Err(vd, "Binding PPAPI graphics context to instance
> failed");
> +        goto error;
> +    }

I don't know if it's possible but if you move this code and all ppapi
specific into the ppapi window module, you could get rid of this module
and use the default opengl one (video_output/opengl/display.c).

This is what we do for Android and Linux, but it's not possible on
windows (for now).

> +
> +    /* Create PPAPI GL Context */
> +    sys->gl = vlc_gl_Create(surface, VLC_OPENGL_ES2, "ppapi-gl");
> +    if (sys->gl == NULL) {
> +        msg_Err(vd, "Failed to create VLC GL context");
> +        goto error;
> +    }
> +
> +    /* Initialize video display */
> +    const vlc_fourcc_t *spu_chromas;
> +
> +    if (vlc_gl_MakeCurrent(sys->gl)) {
> +        msg_Err(vd, "Failed to make GL context current");
> +        goto error;
> +    }
> +
> +    sys->vgl = vout_display_opengl_New(&vd->fmt, &spu_chromas, sys->gl,
> +            &vd->cfg->viewpoint);
> +    vlc_gl_ReleaseCurrent(sys->gl);
> +    if (sys->vgl == NULL)
> +        goto error;
> +
> +    /* Set function pointers */
> +    vd->pool = Pool;
> +    vd->prepare = Prepare;
> +    vd->display = Display;
> +    vd->control = Control;
> +    vd->manage = Manage;
> +
> +    return VLC_SUCCESS;
> +
> +error:
> +    Close(obj);
> +    return VLC_EGENERIC;
> +}
> +
> +static void Close(vlc_object_t *obj)
> +{
> +    vout_display_t *vd = (vout_display_t*)obj;
> +    vout_display_sys_t *sys = vd->sys;
> +    vout_window_t *surface = sys->gl->surface;
> +
> +    if (sys->vgl != NULL) {
> +        vlc_gl_MakeCurrent(sys->gl);
> +        vout_display_opengl_Delete(sys->vgl);
> +        vlc_gl_ReleaseCurrent(sys->gl);
> +    }
> +
> +    if (sys->gl != NULL)
> +        vlc_gl_Destroy(sys->gl);
> +    if (sys->context != 0)
> +        sys->core->ReleaseResource(sys->context);
> +    if (surface != NULL)
> +        vout_display_DeleteWindow(vd, surface);
> +
> +    free(sys);
> +}
> diff --git a/modules/video_output/ppapi/gl.c
> b/modules/video_output/ppapi/gl.c
> new file mode 100644
> index 0000000000..b5787d29e1
> --- /dev/null
> +++ b/modules/video_output/ppapi/gl.c
> @@ -0,0 +1,133 @@
> +/*****************************************************************************
> + * gl.c: GL extension for PPAPI/NaCl
> +
> *****************************************************************************
> + * Copyright © 2017 VLC authors and VideoLAN
> + *
> + * Authors: Julian Scheel <julian at jusst.de>
> + *
> + * 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 <vlc_common.h>
> +#include <vlc_plugin.h>
> +#include <vlc_vout_display.h>
> +#include <vlc_opengl.h>
> +
> +#include "../opengl/vout_helper.h"
> +
> +#include <ppapi/gles2/gl2ext_ppapi.h>
> +#include <ppapi/c/ppb_graphics_3d.h>
> +#include <ppapi/c/pp_completion_callback.h>
> +#include <ppapi/c/pp_instance.h>
> +
> +/*****************************************************************************
> + * Module descriptor
> +
> *****************************************************************************/
> +static int Open(vlc_object_t *);
> +static void Close(vlc_object_t *);
> +
> +vlc_module_begin()
> +    set_shortname("PPAPI GL")
> +    set_description(N_("PPAPI extension for OpenGL"))
> +    set_category(CAT_VIDEO)
> +    set_subcategory(SUBCAT_VIDEO_VOUT)
> +
> +    set_capability("opengl es2", 50)
> +    set_callbacks(Open, Close)
> +    add_shortcut("ppapi-gl")
> +vlc_module_end()
> +
> +/*****************************************************************************
> + * Local prototypes.
> +
> *****************************************************************************/
> +
> +struct vout_display_sys_t
> +{
> +    PP_Instance instance;
> +    PP_Resource context;
> +    PPB_Graphics3D *graphics3d;
> +
> +    vlc_gl_t *gl;
> +};
> +
> +static void Swap(vlc_gl_t *gl)
> +{
> +    vout_display_sys_t *sys = gl->sys;
> +
> +    /* FIXME: Allowed to use PP_BlockUntilComplete here? Or do we need
> to use
> +     * a dedicated thread? */
> +    sys->graphics3d->SwapBuffers(sys->context, PP_BlockUntilComplete());
> +}
> +
> +static void *GetProcAddress(vlc_gl_t *gl, const char *name)
> +{
> +    VLC_UNUSED(gl);
> +    VLC_UNUSED(name);
> +    return NULL;
> +}
> +
> +static int MakeCurrent(vlc_gl_t *gl)
> +{
> +    vout_display_sys_t *sys = gl->sys;
> +
> +    glSetCurrentContextPPAPI(sys->context);
> +    return VLC_SUCCESS;
> +}
> +
> +static void ReleaseCurrent(vlc_gl_t *gl)
> +{
> +    VLC_UNUSED(gl);
> +    glSetCurrentContextPPAPI(0);
> +}
> +
> +static int Open(vlc_object_t *object)
> +{
> +    vlc_gl_t *gl = (vlc_gl_t *)object;
> +    vout_display_sys_t *sys;
> +
> +    /* Allocate structure */
> +    gl->sys = sys = calloc(1, sizeof(*sys));
> +    if (!sys)
> +        return VLC_ENOMEM;
> +
> +    vout_window_t *wnd = gl->surface;
> +    if (wnd->type != VOUT_WINDOW_TYPE_PPAPI)
> +        goto error;
> +
> +    sys->graphics3d = wnd->display.ppapi.pp_graphics3d;
> +    sys->instance = wnd->display.ppapi.pp_instance;
> +    sys->context = wnd->handle.pp_context;
> +
> +    gl->makeCurrent = MakeCurrent;
> +    gl->releaseCurrent = ReleaseCurrent;
> +    gl->resize = NULL;
> +    gl->swap = Swap;
> +    gl->getProcAddress = GetProcAddress;
> +
> +    return VLC_SUCCESS;
> +
> +error:
> +    Close(object);
> +    return VLC_EGENERIC;
> +}
> +
> +static void Close(vlc_object_t *object)
> +{
> +    vlc_gl_t *gl = (vlc_gl_t *)object;
> +    free(gl->sys);
> +}
> diff --git a/modules/video_output/ppapi/window.c
> b/modules/video_output/ppapi/window.c
> new file mode 100644
> index 0000000000..4adfd48c71
> --- /dev/null
> +++ b/modules/video_output/ppapi/window.c
> @@ -0,0 +1,96 @@
> +/**
> + * @file window.c
> + * @brief PPAPI native window provider module for VLC media player
> + */
> +/*****************************************************************************
> + * Copyright © 2017 VLC authors and VideoLAN
> + *
> + * Author: Julian Scheel <julian at jusst.de>
> + *
> + * 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 <stdarg.h>
> +
> +#include <vlc_common.h>
> +#include <vlc_plugin.h>
> +#include <vlc_vout_window.h>
> +
> +#include <ppapi/c/ppb.h>
> +#include <ppapi/c/pp_instance.h>
> +
> +static int Open(vout_window_t*, const vout_window_cfg_t*);
> +static void Close(vout_window_t*);
> +static int Control(vout_window_t*, int, va_list ap);
> +
> +/*
> + * Module descriptor
> + */
> +vlc_module_begin()
> +    set_shortname(N_("PPAPI Window"))
> +    set_description(N_("PPAPI drawing area"))
> +    set_category(CAT_VIDEO)
> +    set_subcategory(SUBCAT_VIDEO_VOUT)
> +    set_capability("vout window", 10)
> +    set_callbacks(Open, Close)
> +vlc_module_end()
> +
> +struct vout_window_sys_t {
> +    PP_Instance instance;
> +};
> +
> +static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
> +{
> +    if (cfg->type != VOUT_WINDOW_TYPE_INVALID &&
> +            cfg->type != VOUT_WINDOW_TYPE_PPAPI)
> +        return VLC_EGENERIC;
> +
> +    vout_window_sys_t *p_sys = malloc(sizeof (*p_sys));
> +    if (p_sys == NULL)
> +        return VLC_ENOMEM;
> +
> +    wnd->sys = p_sys;
> +
> +    p_sys->instance = (int)var_InheritInteger(wnd, "ppapi-instance");
> +    if (p_sys->instance == 0)
> +        goto error;
> +
> +    wnd->type = VOUT_WINDOW_TYPE_PPAPI;
> +    wnd->display.ppapi.pp_instance = p_sys->instance;
> +    wnd->control = Control;
> +
> +    return VLC_SUCCESS;
> +
> +error:
> +    return VLC_EGENERIC;
> +}
> +
> +static void Close(vout_window_t *wnd)
> +{
> +    vout_window_sys_t *p_sys = wnd->sys;
> +    free(p_sys);
> +}
> +
> +static int Control(vout_window_t *wnd, int cmd, va_list ap)
> +{
> +    VLC_UNUSED(cmd);
> +    VLC_UNUSED(ap);
> +    msg_Err(wnd, "control requests not supported");
> +    return VLC_EGENERIC;
> +}
> -- 
> 2.12.0
> 
> _______________________________________________
> 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