Skip to content

Commit

Permalink
media: fix quality-limitation-bw p2p audio-only
Browse files Browse the repository at this point in the history
  • Loading branch information
pnts-se-whereby committed Dec 3, 2024
1 parent 7abe6de commit e7905fe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fifty-queens-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@whereby.com/media": patch
---

Fix quality-limitation-bw issue P2P audio-only mode
6 changes: 6 additions & 0 deletions packages/media/src/webrtc/RtcManagerDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -69,3 +70,8 @@ export default class RtcManagerDispatcher {
}
}
}

let roomMode = "";
export const getRoomMode = () => {
return roomMode;
};
12 changes: 11 additions & 1 deletion packages/media/src/webrtc/stats/IssueMonitor/issueDetectors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getRoomMode } from "../../RtcManagerDispatcher";
import { ssrcStats, TrackStats, ViewStats } from "../StatsMonitor";
import { StatsClient } from "../types";
import { PacketLossAnalyser } from "./packetLossAnalyser";
Expand Down Expand Up @@ -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"),
);
Expand Down

0 comments on commit e7905fe

Please sign in to comment.