diff --git a/spec/unit/webrtc/stats/callStatsReportGatherer.spec.ts b/spec/unit/webrtc/stats/callStatsReportGatherer.spec.ts index 8f81cc17a..e6a364d6a 100644 --- a/spec/unit/webrtc/stats/callStatsReportGatherer.spec.ts +++ b/spec/unit/webrtc/stats/callStatsReportGatherer.spec.ts @@ -158,7 +158,7 @@ describe("CallStatsReportGatherer", () => { collector = new CallStatsReportGatherer(CALL_ID, USER_ID, rtcSpy, emitter); }); - it("in case of stable, parse remote and local description", async () => { + it("in case of stable, parse remote and local description", () => { // @ts-ignore const mediaSsrcHandler = { parse: jest.fn(), diff --git a/src/webrtc/call.ts b/src/webrtc/call.ts index 1e42c3143..875dd2699 100644 --- a/src/webrtc/call.ts +++ b/src/webrtc/call.ts @@ -2848,7 +2848,9 @@ export class MatrixCall extends TypedEventEmitter { diff --git a/src/webrtc/stats/callStatsReportGatherer.ts b/src/webrtc/stats/callStatsReportGatherer.ts index ad1e079c3..fb3e50e69 100644 --- a/src/webrtc/stats/callStatsReportGatherer.ts +++ b/src/webrtc/stats/callStatsReportGatherer.ts @@ -37,7 +37,7 @@ export class CallStatsReportGatherer { public constructor( public readonly callId: string, - public readonly remoteUserId: string, + private opponentMemberId: string, private readonly pc: RTCPeerConnection, private readonly emitter: StatsReportEmitter, private readonly isFocus = true, @@ -93,7 +93,9 @@ export class CallStatsReportGatherer { } private processStatsReport(groupCallId: string, localUserId: string): void { - const byteSentStatsReport: ByteSentStatsReport = new Map(); + const byteSentStatsReport: ByteSentStatsReport = new Map() as ByteSentStatsReport; + byteSentStatsReport.callId = this.callId; + byteSentStatsReport.opponentMemberId = this.opponentMemberId; this.currentStatsReport?.forEach((now) => { const before = this.previousStatsReport ? this.previousStatsReport.get(now.id) : null; @@ -176,6 +178,8 @@ export class CallStatsReportGatherer { private processAndEmitConnectionStatsReport(): void { const report = ConnectionStatsReportBuilder.build(this.trackStats.getTrack2stats()); + report.callId = this.callId; + report.opponentMemberId = this.opponentMemberId; this.connectionStats.bandwidth = report.bandwidth; this.connectionStats.bitrate = report.bitrate; @@ -201,4 +205,8 @@ export class CallStatsReportGatherer { } } } + + public setOpponentMemberId(id: string): void { + this.opponentMemberId = id; + } } diff --git a/src/webrtc/stats/groupCallStats.ts b/src/webrtc/stats/groupCallStats.ts index 054d51f81..40ee9797a 100644 --- a/src/webrtc/stats/groupCallStats.ts +++ b/src/webrtc/stats/groupCallStats.ts @@ -45,11 +45,15 @@ export class GroupCallStats { return this.gatherers.has(callId); } - public addStatsReportGatherer(callId: string, userId: string, peerConnection: RTCPeerConnection): boolean { + public addStatsReportGatherer( + callId: string, + opponentMemberId: string, + peerConnection: RTCPeerConnection, + ): boolean { if (this.hasStatsReportGatherer(callId)) { return false; } - this.gatherers.set(callId, new CallStatsReportGatherer(callId, userId, peerConnection, this.reports)); + this.gatherers.set(callId, new CallStatsReportGatherer(callId, opponentMemberId, peerConnection, this.reports)); return true; } @@ -61,6 +65,10 @@ export class GroupCallStats { return this.hasStatsReportGatherer(callId) ? this.gatherers.get(callId) : undefined; } + public updateOpponentMember(callId: string, opponentMember: string): void { + this.getStatsReportGatherer(callId)?.setOpponentMemberId(opponentMember); + } + private processStats(): void { const summary: Promise[] = []; this.gatherers.forEach((c) => { diff --git a/src/webrtc/stats/statsReport.ts b/src/webrtc/stats/statsReport.ts index cdfa751f4..750c26051 100644 --- a/src/webrtc/stats/statsReport.ts +++ b/src/webrtc/stats/statsReport.ts @@ -28,10 +28,14 @@ export type TrackID = string; export type ByteSend = number; export interface ByteSentStatsReport extends Map { + callId?: string; + opponentMemberId?: string; // is a map: `local trackID` => byte send } export interface ConnectionStatsReport { + callId?: string; + opponentMemberId?: string; bandwidth: ConnectionStatsBandwidth; bitrate: ConnectionStatsBitrate; packetLoss: PacketLoss;