fix(room): preserve Viewer capacity across sharing generations (#307)

This commit is contained in:
AAA authored and GitHub committed 2026-08-28 01:46:32 +08:00
1 parent a39b597396
commit 42e756e00a
7 files changed
+60 -16

No files matched your search

-10
View File
@@ -821,15 +821,6 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
commitViewerQualityEvidence(peerId, null);
}
function clearAllViewerQualityEvidence(): void {
viewerQualityEvidenceTimersRef.current.forEach((timer) =>
window.clearTimeout(timer),
);
viewerQualityEvidenceTimersRef.current.clear();
viewerQualityEvidenceRef.current = new Map();
setViewerQualityEvidence(new Map());
}
function acceptViewerQualityEvidence(evidence: ViewerQualityEvidence): void {
const peer = peersRef.current.get(evidence.viewerPeerId);
const directSnapshot = peer?.getSnapshot() ?? null;
@@ -1395,7 +1386,6 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
setViewerPasswordEnabled(message.viewerPasswordEnabled);
setViewerPasswordDraft(authenticatedProfile.roomPassword ?? "");
setViewerPasswordVisible(false);
clearAllViewerQualityEvidence();
setSfuStandbyUrl(
"sfuStandbyUrl" in message ? message.sfuStandbyUrl : null,
);
+2 -2
View File
@@ -682,9 +682,9 @@ export class HostPeer {
}
switch (this.limitationReason) {
case "bandwidth":
return "此发送连接持续按带宽估计降低分辨率或帧率";
return "当前连接带宽受限,画质已自动降低";
case "cpu":
return "此发送连接持续因编码性能降低分辨率或帧率";
return "编码性能受限,画质已自动降低";
case "other":
return "浏览器持续报告其他画质限制";
default:
+11
View File
@@ -918,11 +918,22 @@ export class HybridMediaRouter {
this.options.deleteConnectionId(roomId, peerId);
if (room?.controller?.confirmDeparture(peerId, this.now())) {
this.requestPump(roomId);
} else if (room && !room.controller && room.advertisedCapacityByViewer.size === 0) {
this.rooms.delete(roomId);
}
}
stopRoom(roomId: string): void {
const capacities = new Map(
this.rooms.get(roomId)?.advertisedCapacityByViewer ?? [],
);
this.clearRoom(roomId);
if (capacities.size > 0) {
const room = this.room(roomId);
for (const [peerId, capacity] of capacities) {
room.advertisedCapacityByViewer.set(peerId, capacity);
}
}
}
deleteRoom(roomId: string): void {