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

Julian Scheel julian at jusst.de
Fri Mar 10 12:54:37 CET 2017


Hi Thomas,

On 09.03.2017 11:29, Thomas Guillem wrote:
>
>
> On Wed, Mar 8, 2017, at 15:55, Julian Scheel wrote:
>> +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).

For Android there is a dedicated display implementation!?
Anyway, yes, that works. Good hint, thanks :)
I've reworked this, so that all ppapi specific stuff is handled in 
gl.c/window.c. There's only one minor feature regression: We can not 
skip rendering if the viewport is not visible (ie scrolled out of 
visible area on a webpage), but I think this is acceptable for now.
If we really want it, we could implement a generic mechanism for 
display.c to query visibility in window.c.

-Julian


More information about the vlc-devel mailing list