Agora Java API Reference for Android
Classes | Public Member Functions | List of all members
io.agora.rtc.gl.EglRenderer Class Reference

Classes

interface  FrameListener
 

Public Member Functions

 EglRenderer (String name)
 
void init (final EglBase.Context sharedContext, final int[] configAttributes, RendererCommon.GlDrawer drawer)
 
EglBase.Context getEglContext ()
 
void createEglSurface (Surface surface)
 
void createEglSurface (SurfaceTexture surfaceTexture)
 
void release ()
 
void printStackTrace ()
 
void setMirror (final boolean mirror)
 
void setLayoutAspectRatio (float layoutAspectRatio)
 
void setFpsReduction (float fps)
 
void disableFpsReduction ()
 
void pauseVideo ()
 
void addFrameListener (final FrameListener listener, final float scale)
 
void addFrameListener (final FrameListener listener, final float scale, final RendererCommon.GlDrawer drawerParam)
 
void addFrameListener (final FrameListener listener, final float scale, final RendererCommon.GlDrawer drawerParam, final boolean applyFpsReduction)
 
void removeFrameListener (final FrameListener listener)
 
void renderFrame (VideoFrame frame)
 
void onFrame (VideoFrame frame)
 
void releaseEglSurface (final Runnable completionCallback)
 
void clearImage ()
 
void clearImage (final float r, final float g, final float b, final float a)
 

Detailed Description

Implements org.webrtc.VideoRenderer.Callbacks by displaying the video stream on an EGL Surface. This class is used as a helper class for rendering on SurfaceViews and TextureViews.

Constructor & Destructor Documentation

◆ EglRenderer()

io.agora.rtc.gl.EglRenderer.EglRenderer ( String  name)

Standard constructor. The name will be used for the render thread name and included when logging. In order to render something, you must first call init() and createEglSurface.

Member Function Documentation

◆ init()

void io.agora.rtc.gl.EglRenderer.init ( final EglBase.Context  sharedContext,
final 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.

◆ release()

void io.agora.rtc.gl.EglRenderer.release ( )

Block until any pending frame is returned and all GL resources released, even if an interrupt occurs. If an interrupt occurs during release(), the interrupt flag will be set. This function should be called before the Activity is destroyed and the EGLContext is still valid. If you don't call this function, the GL resources might leak.

◆ setMirror()

void io.agora.rtc.gl.EglRenderer.setMirror ( final boolean  mirror)

Set if the video stream should be mirrored or not.

◆ setLayoutAspectRatio()

void io.agora.rtc.gl.EglRenderer.setLayoutAspectRatio ( float  layoutAspectRatio)

Set layout aspect ratio. This is used to crop frames when rendering to avoid stretched video. Set this to 0 to disable cropping.

◆ setFpsReduction()

void io.agora.rtc.gl.EglRenderer.setFpsReduction ( float  fps)

Limit render framerate.

Parameters
fpsLimit render framerate to this value, or use Float.POSITIVE_INFINITY to disable fps reduction.

◆ addFrameListener() [1/3]

void io.agora.rtc.gl.EglRenderer.addFrameListener ( final FrameListener  listener,
final float  scale 
)

Registers a callback to invoke when a new video frame is received. This version uses the drawer of the EglRenderer passed in init.

Parameters
listenerThe callback to invoke. The callback will be invoked on the render thread. It should be lightweight and must not call removeFrameListener.
scaleThe scale of the Bitmap passed to the callback, or 0 if no Bitmap is required.

◆ addFrameListener() [2/3]

void io.agora.rtc.gl.EglRenderer.addFrameListener ( final FrameListener  listener,
final float  scale,
final RendererCommon.GlDrawer  drawerParam 
)

Registers a callback to invoke when a new video frame has been received.

Parameters
listenerThe callback to invoke. The callback will be invoked on the render thread. It should be lightweight and must not call removeFrameListener.
scaleThe scale of the Bitmap passed to the callback, or 0 if no Bitmap is required.
drawerParamCustom drawer to use for this frame listener or null to use the default one.

◆ addFrameListener() [3/3]

void io.agora.rtc.gl.EglRenderer.addFrameListener ( final FrameListener  listener,
final float  scale,
final RendererCommon.GlDrawer  drawerParam,
final boolean  applyFpsReduction 
)

Registers a callback to invoke when a new video frame has been received.

Parameters
listenerThe callback to invoke. The callback will be invoked on the render thread. It should be lightweight and must not call removeFrameListener.
scaleThe scale of the Bitmap passed to the callback, or 0 if no Bitmap is required.
drawerParamCustom drawer to use for this frame listener or null to use the default one.
applyFpsReductionThis callback will not be called for frames that have been dropped by FPS reduction.

◆ removeFrameListener()

void io.agora.rtc.gl.EglRenderer.removeFrameListener ( final FrameListener  listener)

Remove any pending callback that was added with addFrameListener. If the callback is not in the queue, nothing happens. It is ensured that callback won't be called after this method returns.

Parameters
listenerThe callback to remove.

◆ releaseEglSurface()

void io.agora.rtc.gl.EglRenderer.releaseEglSurface ( final Runnable  completionCallback)

Release EGL surface. This function will block until the EGL surface is released.

◆ clearImage() [1/2]

void io.agora.rtc.gl.EglRenderer.clearImage ( )

Post a task to clear the surface to a transparent uniform color.

◆ clearImage() [2/2]

void io.agora.rtc.gl.EglRenderer.clearImage ( final float  r,
final float  g,
final float  b,
final float  a 
)

Post a task to clear the surface to a specific color.