Skip to content

feat: Implement low-latency MediaCodec H.264 hardware video decoder - #4

Merged
ClausValcaTD merged 1 commit into
mainfrom
feat/h264-hardware-decoder-9026275089647310302
Oct 16, 2026
Merged

ClausValcaTD merged 1 commit into
mainfrom
feat/h264-hardware-decoder-9026275089647310302

Conversation

@ClausValcaTD

Copy link
Copy Markdown
Contributor

Implement an ultra-low-latency H.264 (video/avc) hardware decoder pipeline using Android's native MediaCodec synchronous API (minSdk 19 / KitKat compliant).

Key changes:

  • Created H264Decoder.java managing MediaCodec.createDecoderByType("video/avc") with synchronous API (dequeueInputBuffer / dequeueOutputBuffer with getInputBuffers() / getOutputBuffers()).
  • Added dedicated rendering/draining thread in H264Decoder rendering directly to Surface via releaseOutputBuffer(index, true) with minimal buffering to eliminate queue bloat.
  • Handled SPS/PPS codec config units (BUFFER_FLAG_CODEC_CONFIG) and dynamic format updates (INFO_OUTPUT_FORMAT_CHANGED).
  • Connected WebSocket binary chunks from LibreCastServer.onMessage via ReceiverService to MainActivity / H264Decoder.feedFrame().
  • Added full-screen SurfaceView in activity_main.xml and implemented SurfaceHolder.Callback in MainActivity.java for clean lifecycle management.
  • Automatically hide server status UI when the first frame is rendered, restoring UI on client disconnect.
  • Added unit tests in H264DecoderTest.java.

PR created automatically by Jules for task 9026275089647310302 started by @ClausValcaTD

- Implement H264Decoder using MediaCodec synchronous API compliant with KitKat (API 19).
- Run dedicated rendering/draining thread polling dequeueOutputBuffer and rendering directly to Surface.
- Handle SPS/PPS flags (BUFFER_FLAG_CODEC_CONFIG) and dynamic format changes (INFO_OUTPUT_FORMAT_CHANGED).
- Connect LibreCastServer binary video stream chunks via ReceiverService directly to H264Decoder.
- Add SurfaceView in activity_main.xml and implement SurfaceHolder.Callback in MainActivity to start/stop decoder.
- Auto-hide status overlay on first video frame rendered.
- Add unit tests for H264Decoder state management.

Co-authored-by: ClausValcaTD <193546948+ClausValcaTD@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@ClausValcaTD
ClausValcaTD merged commit 7e881aa into main Oct 16, 2026
1 check passed
@ClausValcaTD
ClausValcaTD deleted the feat/h264-hardware-decoder-9026275089647310302 branch October 16, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant