Package tvi.webrtc

Class SurfaceEglRenderer

All Implemented Interfaces:
android.view.SurfaceHolder.Callback, VideoSink

public class SurfaceEglRenderer extends EglRenderer implements android.view.SurfaceHolder.Callback
Display the video stream on a Surface. renderFrame() is asynchronous to avoid blocking the calling thread. This class is thread safe and handles access from potentially three different threads: Interaction from the main app in init, release and setMirror. Interaction from C++ rtc::VideoSinkInterface in renderFrame. Interaction from SurfaceHolder lifecycle in surfaceCreated, surfaceChanged, and surfaceDestroyed.
  • Constructor Details

    • SurfaceEglRenderer

      public SurfaceEglRenderer(String name)
      In order to render something, you must first call init().
  • Method Details

    • init

      public void init(EglBase.Context sharedContext, RendererCommon.RendererEvents rendererEvents, int[] configAttributes, RendererCommon.GlDrawer drawer)
      Initialize this class, sharing resources with `sharedContext`. The custom `drawer` will be used for drawing frames on the EGLSurface. This class is responsible for calling release() on `drawer`. It is allowed to call init() to reinitialize the renderer after a previous init()/release() cycle.
    • init

      public void init(EglBase.Context sharedContext, int[] configAttributes, RendererCommon.GlDrawer drawer)
      Description copied from class: EglRenderer
      Same as above with usePresentationTimeStamp set to false.
      init in class EglRenderer
      See Also:
    • setFpsReduction

      public void setFpsReduction(float fps)
      Limit render framerate.
      setFpsReduction in class EglRenderer
      fps - Limit render framerate to this value, or use Float.POSITIVE_INFINITY to disable fps reduction.
    • disableFpsReduction

      public void disableFpsReduction()
      disableFpsReduction in class EglRenderer
    • pauseVideo

      public void pauseVideo()
      pauseVideo in class EglRenderer
    • onFrame

      public void onFrame(VideoFrame frame)
      Description copied from interface: VideoSink
      Implementations should call frame.retain() if they need to hold a reference to the frame after this function returns. Each call to retain() should be followed by a call to frame.release() when the reference is no longer needed.
      Specified by:
      onFrame in interface VideoSink
      onFrame in class EglRenderer
    • surfaceCreated

      public void surfaceCreated(android.view.SurfaceHolder holder)
      Specified by:
      surfaceCreated in interface android.view.SurfaceHolder.Callback
    • surfaceDestroyed

      public void surfaceDestroyed(android.view.SurfaceHolder holder)
      Specified by:
      surfaceDestroyed in interface android.view.SurfaceHolder.Callback
    • surfaceChanged

      public void surfaceChanged(android.view.SurfaceHolder holder, int format, int width, int height)
      Specified by:
      surfaceChanged in interface android.view.SurfaceHolder.Callback