Media Surface Texture
Android-specific OesExternalTexture that bridges a SurfaceTexture / Surface consumer (typically MediaPlayer, MediaCodec, or Camera2) to the WorldWind GL pipeline. The lifecycle is GL-thread-driven:
Caller constructs MediaSurfaceTexture from the main thread and assigns it to a earth.worldwind.shape.ProjectedMediaSurface.texture (or any consumer that calls bindTexture).
On the first render frame,
super.bindTexture(dc)allocates the GL texture name; we wrap it in aSurfaceTexture+Surfaceand fire onSurfaceReady so the caller can hand the surface to its media producer.Each subsequent bindTexture call invokes
surfaceTexture.updateTexImage()to pull the latest frame from the producer into the bound OES texture.
Context-loss recovery. When the host activity goes through pause/resume the GLSurfaceView's GL context is destroyed and rebuilt with a fresh GL name. The decoder keeps writing into the old Surface (whose backing SurfaceTexture is bound to the dead GL name), and frames silently disappear. Two recovery signals: the GL name id changing across a bind, or updateTexImage throwing because its captured EGLContext is no longer current. Either causes the wrap to be dropped; the next bind allocates a fresh SurfaceTexture + Surface and re-fires onSurfaceReady so the caller can rebind the player.
setOnFrameAvailableListener fires on the listener's caller thread by default; producer frames typically arrive on a binder / decoder thread. The listener requests a redraw (so the GL thread picks up the new frame) and then invokes the user-supplied onFrameAvailable hook for any extra wiring. Do not touch GL state from the listener — it does not run on the GL thread.
Properties
Caller opt-out for mipmap generation.
Optional hook invoked after WorldWind.requestRedraw whenever the producer reports a new frame. Fires on whatever thread the producer chooses — usually a binder / decoder thread, NOT the GL thread; do not touch GL state here.
Invoked on the GL thread after surface becomes available — the first time when the GL name is initially allocated, and again after a GL context loss when the name is regenerated. The caller must hand surface to its media producer (e.g. MediaPlayer.setSurface(surface)) on each invocation; the previous Surface is no longer valid.
Surface wrapping the underlying SurfaceTexture. Null until onSurfaceReady fires.