diff --git a/.agents/MEMORY.md b/.agents/MEMORY.md index 7237efe..334ff78 100644 --- a/.agents/MEMORY.md +++ b/.agents/MEMORY.md @@ -330,6 +330,18 @@ list the phone at 192.168.178.29:5005; a 25s `--send --target monitor Note: with both the Pi and the phone on the LAN, plain `--send` refuses (two receivers found) — target the phone with `--peer`. +Follow-up from the same on-device session — startup squish eliminated: +`H264Decoder.outputSize()` previously reported the 320x240 configure() +placeholder until the codec parsed the SPS, so `fitVideo` sized the +TextureView 1488x1116 (1.33 aspect) and the first rendered frame(s) of +2.4 content were visibly squished. It now returns null until +`INFO_OUTPUT_FORMAT_CHANGED` fires; the first frame renders into the +fullscreen surface and the correct letterbox (2484x1035) follows within +~40ms. Validated live: no placeholder "video size" line in logcat. + +Commits: 9a24933 (PROTOCOL_DNS_SD discovery fix + docs), plus the +outputSize fix (see git log). + Still open (accepted, needs a device or a new test dep): - Untested on device: `setOutputSurface` mid-session (surface switch) and diff --git a/android/app/src/main/kotlin/screen_cast/decode/H264Decoder.kt b/android/app/src/main/kotlin/screen_cast/decode/H264Decoder.kt index bb443c9..fafd8d2 100644 --- a/android/app/src/main/kotlin/screen_cast/decode/H264Decoder.kt +++ b/android/app/src/main/kotlin/screen_cast/decode/H264Decoder.kt @@ -18,6 +18,11 @@ class H264Decoder { private var codec: MediaCodec? = null private var configured = false + // True once the codec parsed the in-band SPS (INFO_OUTPUT_FORMAT_CHANGED). + // Before that, outputFormat still carries the configure() placeholder and + // must not drive layout — sizing the view to it squishes the first frame(s). + @Volatile + private var realFormatSeen = false @Volatile private var renderSurface: Surface? = null @@ -57,6 +62,7 @@ class H264Decoder { throw e } configured = true + realFormatSeen = false } /** Points the decoder at a (possibly new) render surface. */ @@ -117,6 +123,7 @@ class H264Decoder { } index == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED -> { // The codec parsed the SPS size; outputFormat is ready. + realFormatSeen = true android.util.Log.i( "H264Decoder", "output format: " + c.outputFormat.getInteger(MediaFormat.KEY_WIDTH) + @@ -141,10 +148,11 @@ class H264Decoder { } } - /** The decoded resolution once the first keyframe has configured the codec. */ + /** The decoded resolution, once the first keyframe configured the codec. */ @Synchronized fun outputSize(): Pair? { val c = codec ?: return null + if (!realFormatSeen) return null // still the configure() placeholder return try { val format = c.outputFormat val width = format.getInteger(MediaFormat.KEY_WIDTH)