SharedEglContext

Singleton holder for the shared EGL context used across the WebRTC stack.

The EGL context needs to be shared between:

  1. Video decoders (which output TextureBuffer frames)

  2. Video renderers (SurfaceViewRenderer)

If these use different EGL contexts, TextureBuffer frames from the decoder will appear as black when rendered, because the texture IDs are only valid within the EGL context where they were created.

Functions

Link copied to clipboard
fun clear()

Clears the shared EGL base reference. Should be called when AndroidWebRtcDevice is closed.

Link copied to clipboard
fun getEglBase(): EglBase?

Gets the shared EGL base. Returns null if not yet initialized.

Link copied to clipboard
fun getEglBaseContext(): EglBase.Context?

Gets the shared EGL base context. Returns null if not yet initialized. Renderers should use this to share textures with decoders.

Link copied to clipboard
fun setEglBase(eglBase: EglBase)

Sets the shared EGL base. Should be called by AndroidWebRtcDevice during initialization. The EglBase is expected to live for the duration of the WebRTC session.