视频会议

This commit is contained in:
duoaohui
2026-05-18 23:13:59 +08:00
parent c2bcfdbbac
commit b8c2bf2dc4
4 changed files with 90 additions and 6 deletions

View File

@@ -120,7 +120,24 @@ export async function resumeConsumer(consumerId: string): Promise<void> {
throw notFound('consumer', consumerId);
}
await entry.consumer.resume();
log.info({ consumerId }, 'consumer resumed');
// 屏幕共享/低运动视频的"花屏拖影"根因consumer 从 paused 切到 active 后,第一时间
// 到达的可能是 P 帧delta需要等 producer 自然出 I 帧(屏幕场景常 5~10s+)。
// 主动调 requestKeyFrame() 让 mediasoup 立刻向上游 producer 发 PLII 帧到达后画面恢复正常。
// 音频 consumer 调用此 API 是 no-op但 mediasoup 仍会触发不必要的工作,故按 kind 过滤。
if (entry.consumer.kind === 'video') {
try {
await entry.consumer.requestKeyFrame();
} catch (err) {
// requestKeyFrame 在 codec 不支持时会抛错(极少见),仅记日志不阻塞 resume 主路径
log.warn(
{ consumerId, err: err instanceof Error ? err.message : String(err) },
'requestKeyFrame after resume failed (ignored)',
);
}
}
log.info({ consumerId, kind: entry.consumer.kind }, 'consumer resumed');
}
export async function closeConsumer(consumerId: string): Promise<void> {