AndroidGpuImageVideoRenderer

Turns direct MediaCodec output into immutable RGBA hardware Bitmap frames for a GPU client.

MediaCodec writes vendor YUV into an external-OES SurfaceTexture. One GLES2 shader pass writes RGBA_8888 into an ImageReader, and Bitmap.wrapHardwareBuffer gives the client a Skia-readable hardware image. No video pixels enter Kotlin or CPU memory.

The composited target preserves Android's exact SDR RGB spaces. Android 12+ decoders may feed it 10-bit/HDR sources by performing the platform's hardware HDR-to-SDR tone map first. The decoder must accept that request, and any recognized contradictory output metadata is rejected before a frame is exposed. The client callback may run on the renderer's GL thread and must return promptly. Subtitle composition remains the client's job.

Constructors

Link copied to clipboard
constructor(onImage: (AndroidGpuImageFrame) -> Unit)

Properties

Link copied to clipboard
open override val events: Flow<RendererEvent>
Link copied to clipboard

Frames rejected or released without reaching the bridge Surface.

Link copied to clipboard
Link copied to clipboard

Frames whose completed RGBA hardware image reached onImage.

Link copied to clipboard
open override val redrawsHeldPicture: Boolean

False: the blit runs at each latch only, so a held picture shows a change from a redraw (#463).

Link copied to clipboard
open val showsHdr: Boolean
Link copied to clipboard

Frames coalesced by SurfaceTexture or skipped while no Compose viewport is active.

Functions

Link copied to clipboard
open fun accepts(shape: FrameShape): Boolean
Link copied to clipboard
open override fun clearPicture()

Lets no frame accepted so far reach onImage (#530): the bridge drops the frames still on their way through it, and returns once none of them can be published any more. The image already handed to onImage is the client's to take off the screen, as the subtitles are.

Link copied to clipboard
open override fun close()
Link copied to clipboard
open suspend override fun present(frame: VideoFrame, targetNanos: Long): Boolean
Link copied to clipboard
open override fun setAdjustments(adjustments: VideoAdjustments)
Link copied to clipboard
Link copied to clipboard
open fun setHdrPolicy(policy: HdrPolicy)
Link copied to clipboard
open suspend override fun setOverlay(overlay: SubtitleOverlay?)
Link copied to clipboard
open override fun setRenderQuality(quality: RenderQuality)

The render-quality passes. This tier blits OES to an RGBA8 image, so eight bits is what the dither spreads across; anything it cannot do it ignores, as the SPI allows.

Link copied to clipboard
open fun setScaleMode(mode: VideoScale)
Link copied to clipboard
open override fun setTransform(transform: VideoTransform)

The viewer's turn reaches the picture where Compose draws it; here it only sizes the buffer (#428).

Link copied to clipboard
open override fun setViewport(width: Int, height: Int, scale: Float)
Link copied to clipboard
Link copied to clipboard
open override fun supports(format: PlayerPixelFormat): Boolean
Link copied to clipboard
Link copied to clipboard
open override fun vsyncIntervalNanos(): Long?