Search code examples
androidwebrtcscreenshot

WebRTC for Android : VideoRendererGUI take a screenshot in the video call


The demand is that saving a video frame in the video call. I have made a demo that take a screenshot through the GLSurfaceView's method "onDrawFrame". But when I use the webrtc, it have its own renderer "VideoRendererGUI" .And then when I want to override it, I find it can't be overrided. the main part code :

   vsv = (GLSurfaceView) findViewById(R.id.glviewchild_call);
    vsv.setPreserveEGLContextOnPause(true);
    vsv.setKeepScreenOn(true);

    VideoRendererGui.setView(vsv, new Runnable() {
        @Override
        public void run() {
            init();
        }
    });

And If you have another way to take a screenshot, you can also share with me. Thanks a lot!


Solution

  • If you use a SurfaceViewRenderer to display the stream, you can use the solution in this answer to capture a frame on the call.

    Basically, using surfaceViewRenderer.AddFrameListener with a class that implements EGLRenderer.FrameListener