feat(webrtc): 新增解码耗时统计并修复黑屏问题

1. 新增自编码与全托管模式的解码耗时探针(VideoSink),统计帧率与解码耗时。
2. 修复 SPS 与 PPS 作为独立 CONFIG 单元发送时被误丢弃导致 H.264 永久黑屏的问题。
3. 优化分片重组缓冲,丢弃过期单元并限制缓冲堆积以防内存泄漏。
This commit is contained in:
TongTongStudio
2026-07-25 01:50:00 +08:00
parent cebb1e484e
commit 4a33f3db0d
3 changed files with 408 additions and 13 deletions

View File

@@ -100,6 +100,22 @@ class SelfCodecDecoder {
}
}
/// 读取解码耗时统计。返回包含以下键的 Map毫秒失败返回 null
/// - lastMs最近一帧解码耗时
/// - avgMs最近窗口内的平均解码耗时
/// - maxMs峰值解码耗时
/// - count累计已解码帧数。
Future<Map<String, dynamic>?> getStats() async {
if (_disposed || _textureId == null) return null;
try {
final res = await _channel.invokeMethod<dynamic>('getStats');
if (res is Map) return res.cast<String, dynamic>();
} catch (_) {
// 解码未就绪或被释放时忽略。
}
return null;
}
/// 释放原生解码资源。重复调用安全。
Future<void> dispose() async {
if (_disposed) return;