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 7db41e1..3c0bdbf 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 @@ -64,7 +64,7 @@ class VideoDecoder( private val frameSeqSet = Collections.newSetFromMap(ConcurrentHashMap()) // 防止重复帧入队 // 解码输出缓冲区,容量为100帧 - private val outputFrameQueue = LinkedBlockingQueue(30) + private val outputFrameQueue = LinkedBlockingQueue(17) // 渲染线程控制 @Volatile private var renderThreadRunning = true @@ -74,7 +74,7 @@ class VideoDecoder( private val mainHandler = Handler(Looper.getMainLooper()) // 渲染帧率(fps),可由外部控制,默认18 - @Volatile var renderFps: Int = 18 + @Volatile var renderFps: Int = 15 // 兜底:记录最近一次I帧的frameSeq,P/B帧依赖校验 @Volatile private var lastIFrameSeq: Int? = null @@ -84,7 +84,7 @@ class VideoDecoder( private val decodeTimestampLock = ReentrantLock() // 线程安全保护 // EMA平滑参数 - @Volatile private var smoothedFps: Double = 18.0 // 平滑后的渲染帧率 + @Volatile private var smoothedFps: Double = 15.0 // 平滑后的渲染帧率 private val alpha = 0.2 // EMA平滑系数,越大响应越快 private val minFps = 8 // 渲染帧率下限,防止过低 private val maxFps = 30 // 渲染帧率上限,防止过高 @@ -92,7 +92,7 @@ class VideoDecoder( // 1. 新增成员变量 @Volatile private var latestRenderedTimestampMs: Long? = null - private val MAX_ALLOWED_DELAY_MS = 60 // 最大允许延迟,单位毫秒 + private val MAX_ALLOWED_DELAY_MS = 350 // 最大允许延迟,单位毫秒 @Volatile private var timestampBaseMs: Long? = null @Volatile private var firstFrameRelativeTimestamp: Long? = null