Class EglCore

java.lang.Object
io.agora.rtc2.internal.gdp.EglCore

public final class EglCore extends Object
Core EGL state (display, context, config).

The EGLContext must only be attached to one thread at a time. This class is not thread-safe.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Constructor flag: surface must be recordable.
    static final int
    Constructor flag: ask for GLES3, fall back to GLES2 if not available.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Prepares EGL display and context.
    EglCore(EGLContext sharedContext, int flags)
    Prepares EGL display and context.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Checks for EGL errors.
    EGLSurface
    createOffscreenSurface(int width, int height)
    Creates an EGL surface associated with an offscreen buffer.
    EGLConfig
    getConfig(int flags, int version)
    Finds a suitable EGLConfig.
    void
    makeCurrent(EGLSurface eglSurface)
    Makes our EGL context current, using the supplied surface for both "draw" and "read".
    void
    Discards all resources held by this class, notably the EGL context.
    void
    releaseSurface(EGLSurface eglSurface)
    Destroys the specified surface.
    static void
    setMockNonEGLContext(boolean mock)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FLAG_RECORDABLE

      public static final int FLAG_RECORDABLE
      Constructor flag: surface must be recordable. This discourages EGL from using a pixel format that cannot be converted efficiently to something usable by the video encoder.
      See Also:
    • FLAG_TRY_GLES3

      public static final int FLAG_TRY_GLES3
      Constructor flag: ask for GLES3, fall back to GLES2 if not available. Without this flag, GLES2 is used.
      See Also:
  • Constructor Details

    • EglCore

      public EglCore()
      Prepares EGL display and context.

      Equivalent to EglCore(null, 0).

    • EglCore

      public EglCore(EGLContext sharedContext, int flags)
      Prepares EGL display and context.

      Parameters:
      sharedContext - The context to share, or null if sharing is not desired.
      flags - Configuration bit flags, e.g. FLAG_RECORDABLE.
  • Method Details

    • setMockNonEGLContext

      public static void setMockNonEGLContext(boolean mock)
    • getConfig

      public EGLConfig getConfig(int flags, int version)
      Finds a suitable EGLConfig.
      Parameters:
      flags - Bit flags from constructor.
      version - Must be 2 or 3.
    • release

      public void release()
      Discards all resources held by this class, notably the EGL context. This must be called from the thread where the context was created.

      On completion, no context will be current.

    • releaseSurface

      public void releaseSurface(EGLSurface eglSurface)
      Destroys the specified surface. Note the EGLSurface won't actually be destroyed if it's still current in a context.
    • createOffscreenSurface

      public EGLSurface createOffscreenSurface(int width, int height)
      Creates an EGL surface associated with an offscreen buffer.
    • makeCurrent

      public void makeCurrent(EGLSurface eglSurface)
      Makes our EGL context current, using the supplied surface for both "draw" and "read".
    • checkEglError

      public void checkEglError(String msg)
      Checks for EGL errors. Throws an exception if an error has been raised.