diff --git a/.changeset/fifty-queens-serve.md b/.changeset/fifty-queens-serve.md new file mode 100644 index 000000000..49982756e --- /dev/null +++ b/.changeset/fifty-queens-serve.md @@ -0,0 +1,5 @@ +--- +"@whereby.com/media": patch +--- + +Fix quality-limitation-bw issue P2P audio-only mode diff --git a/packages/media/src/webrtc/RtcManagerDispatcher.ts b/packages/media/src/webrtc/RtcManagerDispatcher.ts index f2ea030c4..13e363b87 100644 --- a/packages/media/src/webrtc/RtcManagerDispatcher.ts +++ b/packages/media/src/webrtc/RtcManagerDispatcher.ts @@ -37,6 +37,7 @@ export default class RtcManagerDispatcher { deviceHandlerFactory: features?.deviceHandlerFactory, }; const isSfu = !!room.sfuServer; + roomMode = isSfu ? "group" : "normal"; if (this.currentManager) { if (this.currentManager.isInitializedWith({ selfId, roomName: room.name, isSfu })) { if (this.currentManager.setEventClaim && eventClaim) { @@ -69,3 +70,8 @@ export default class RtcManagerDispatcher { } } } + +let roomMode = ""; +export const getRoomMode = () => { + return roomMode; +}; diff --git a/packages/media/src/webrtc/stats/IssueMonitor/issueDetectors.ts b/packages/media/src/webrtc/stats/IssueMonitor/issueDetectors.ts index 65ce0f6f8..f35ab1e85 100644 --- a/packages/media/src/webrtc/stats/IssueMonitor/issueDetectors.ts +++ b/packages/media/src/webrtc/stats/IssueMonitor/issueDetectors.ts @@ -1,3 +1,4 @@ +import { getRoomMode } from "../../RtcManagerDispatcher"; import { ssrcStats, TrackStats, ViewStats } from "../StatsMonitor"; import { StatsClient } from "../types"; import { PacketLossAnalyser } from "./packetLossAnalyser"; @@ -193,8 +194,17 @@ export const issueDetectors: IssueDetector[] = [ id: "quality-limitation-bw", enabled: ({ hasLiveTrack, stats, client, kind }) => hasLiveTrack && client.isLocalClient && kind === "video" && !!stats, - check: ({ stats }) => { + check: ({ stats, clients }) => { if (!stats) return false; + + // This issue will be stuck active forever in P2P with a remote audio-only participant. + const roomMode = getRoomMode(); + if (roomMode === "normal") { + const remoteClients = clients.filter((c) => !c.isLocalClient); + + if (remoteClients.some((c) => c.isAudioOnlyModeEnabled)) return false; + } + return !!Object.values(stats.tracks).find((track) => Object.values(track.ssrcs).find((ssrc) => ssrc.qualityLimitationReason === "bandwidth"), );