From 491e2be4a6c549d7621d1f68e03bb6b6bc5eb248 Mon Sep 17 00:00:00 2001 From: liyi Date: Wed, 30 Apr 2025 16:31:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:v1=E7=89=88=E6=9C=AC=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/top/skychip/video_decode_plugin/VideoDecoder.kt | 7 ++++--- lib/video_decode_plugin.dart | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/android/src/main/kotlin/top/skychip/video_decode_plugin/VideoDecoder.kt b/android/src/main/kotlin/top/skychip/video_decode_plugin/VideoDecoder.kt index c6223f6..9565448 100644 --- a/android/src/main/kotlin/top/skychip/video_decode_plugin/VideoDecoder.kt +++ b/android/src/main/kotlin/top/skychip/video_decode_plugin/VideoDecoder.kt @@ -162,6 +162,7 @@ class VideoDecoder( // 启动渲染线程 renderThreadRunning = true renderThread = Thread { + var hasNotifiedFlutter = false var renderedFrameCount = 0 // 渲染帧计数器 while (renderThreadRunning) { // 计算每帧渲染间隔 @@ -172,10 +173,10 @@ class VideoDecoder( val frame = outputFrameQueue.take() frame.codec.releaseOutputBuffer(frame.bufferIndex, true) renderedFrameCount++ - // 每累计renderFps帧回调一次onFrameRendered - if (renderedFrameCount >= renderFps) { - // 回调到Flutter端 通知解码并渲染完81帧了 + // 只在首次渲染时回调Flutter + if (!hasNotifiedFlutter) { mainHandler.post { onFrameRendered() } + hasNotifiedFlutter = true } } catch (e: Exception) { Log.e(TAG, "[RenderThread] Exception", e) diff --git a/lib/video_decode_plugin.dart b/lib/video_decode_plugin.dart index 0b4c2d2..daa8f2c 100644 --- a/lib/video_decode_plugin.dart +++ b/lib/video_decode_plugin.dart @@ -129,6 +129,7 @@ class VideoDecodePlugin { required int timestamp, required int frameSeq, bool splitNalFromIFrame = false, + int? refIFrameSeq, // P帧时可选 }) async { if (splitNalFromIFrame && frameType == 0) { // 优先使用缓存的SPS/PPS