Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

fix(routing): allow host selected ingress in every room

AAAdb4b85ec4eb1
diff --git a/src/server/hybrid-media-router.ts b/src/server/hybrid-media-router.ts
index cefa6c00..79b43d63 100644
--- a/src/server/hybrid-media-router.ts
+++ b/src/server/hybrid-media-router.ts
@@ -1100,8 +1100,8 @@ export class HybridMediaRouter {
}
/**
- * Restricted source-side fallback for the exact room-1 canary. This is a
- * LiveKit publisher ICE override, not an ordinary peer candidate and not a
+ * Source-side fallback for a configured hybrid room. This is a LiveKit
+ * publisher ICE override, not an ordinary peer candidate or a
* participant-wide TURN grant.
*/
private startSelectedSfuIngressTurn(
@@ -1116,7 +1116,6 @@ export class HybridMediaRouter {
const active = controller?.getActiveRoute();
const key = roomId;
if (
- roomId !== "1" ||
!config ||
!fallback ||
!active ||
diff --git a/tests/server-signal.test.ts b/tests/server-signal.test.ts
index ea290347..88ea8019 100644
--- a/tests/server-signal.test.ts
+++ b/tests/server-signal.test.ts
@@ -284,6 +284,7 @@ async function correlateParentEdgeQualityEvidence(
async function startSfuHarness(options: {
tokenIssuer: SfuTokenIssuer;
selectedEdgeTurn?: boolean;
+ persistent?: boolean;
prepareTimeoutMs?: number;
maxRoots?: number;
viewerDisconnectGraceMs?: number;
@@ -294,7 +295,11 @@ async function startSfuHarness(options: {
ttlMs: 14_400_000,
maxRooms: 10,
maxViewersPerRoom: 8,
+ database: options.persistent ? new RoomDatabase(":memory:") : undefined,
});
+ if (options.persistent) {
+ roomStore.createRoom();
+ }
const room = roomStore.createRoom();
const httpServer = createServer((_request, response) => {
response.statusCode = 404;
@@ -3944,6 +3949,34 @@ describe("WebSocket signaling", () => {
).rejects.toThrow("Timed out");
});
+ it("allows selected TURN for Host SFU ingress outside historical room 1", async () => {
+ const harness = await startSfuHarness({
+ persistent: true,
+ tokenIssuer: { async issueToken({ peerId }) { return `token-${peerId}`; } },
+ selectedEdgeTurn: true,
+ });
+ expect(harness.room.roomId).toBe("2");
+ const direct = await activateSingleViewerSfu(
+ harness.webSocketUrl,
+ harness.room,
+ "selected-host-ingress-room-two",
+ );
+
+ direct.host.socket.send(JSON.stringify({
+ type: "route-failed",
+ revision: direct.revision,
+ phase: "active",
+ connectionId: null,
+ }));
+ await expect(direct.host.inbox.next("selected-edge-turn")).resolves.toMatchObject({
+ edgeKind: "host-sfu-ingress",
+ revision: direct.revision,
+ hostPeerId: direct.hostAuth.peerId,
+ publicationGeneration: expect.any(String),
+ iceServer: { urls: ["turn:turn.example.test:3478?transport=udp"] },
+ });
+ });
+
it("authorizes a ViewerRelay parent and clears its grant on share stop", async () => {
const harness = await startSfuHarness({
tokenIssuer: { async issueToken({ peerId }) { return `token-${peerId}`; } },