public void setVideoRenderer(VideoProcessor processor, boolean requireSecureContext) {
        setEGLContextClientVersion(2);
        setEGLConfigChooser(
                /* redSize= */ 8,
                /* greenSize= */ 8,
                /* blueSize= */ 8,
                /* alphaSize= */ 8,
                /* depthSize= */ 0,
                /* stencilSize= */ 0);
        setEGLContextFactory(
                new EGLContextFactory() {
                    @Override
                    public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
                        int[] glAttributes;
                        if (requireSecureContext) {
                            glAttributes =
                                    new int[]{
                                            EGL14.EGL_CONTEXT_CLIENT_VERSION,
                                            2,
                                            EGL_PROTECTED_CONTENT_EXT,
                                            EGL14.EGL_TRUE,
                                            EGL14.EGL_NONE
                                    };
                        } else {
                            glAttributes = new int[]{EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
                        }
                        return egl.eglCreateContext(
                                display, eglConfig, /* share_context= */ EGL10.EGL_NO_CONTEXT, glAttributes);
                    }

                    @Override
                    public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
                        egl.eglDestroyContext(display, context);
                    }
                });
        setEGLWindowSurfaceFactory(
                new EGLWindowSurfaceFactory() {
                    @Override
                    public EGLSurface createWindowSurface(
                            EGL10 egl, EGLDisplay display, EGLConfig config, Object nativeWindow) {
                        int[] attribsList =
                                requireSecureContext
                                        ? new int[]{EGL_PROTECTED_CONTENT_EXT, EGL14.EGL_TRUE, EGL10.EGL_NONE}
                                        : new int[]{EGL10.EGL_NONE};
                        return egl.eglCreateWindowSurface(display, config, nativeWindow, attribsList);
                    }

                    @Override
                    public void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface) {
                        egl.eglDestroySurface(display, surface);
                    }
                });
        setRenderer(new VideoRenderer(processor));
        setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    }
@param processor            Processor that draws to the view.
@param requireSecureContext Whether a GL context supporting protected content should be
                            created, if supported by the device.
dkplayer-sample/src/main/java/xyz/doikki/dkplayer/widget/render/gl/GLSurfaceRenderView.java