@unwanted/matrix-sdk-mini 34.12.0-1 → 34.12.0-2
Sign up to get free protection for your applications and to get access to all the features.
- package/git-revision.txt +1 -1
- package/lib/@types/event.d.ts +0 -19
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js.map +1 -1
- package/lib/client.d.ts +2 -50
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +391 -501
- package/lib/client.js.map +1 -1
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +0 -1
- package/lib/embedded.js.map +1 -1
- package/lib/matrix.d.ts +0 -6
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -5
- package/lib/matrix.js.map +1 -1
- package/package.json +1 -1
- package/src/@types/event.ts +2 -36
- package/src/client.ts +1 -150
- package/src/embedded.ts +0 -2
- package/src/matrix.ts +0 -13
- package/lib/matrixrtc/CallMembership.d.ts +0 -66
- package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
- package/lib/matrixrtc/CallMembership.js +0 -197
- package/lib/matrixrtc/CallMembership.js.map +0 -1
- package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
- package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
- package/lib/matrixrtc/LivekitFocus.js +0 -20
- package/lib/matrixrtc/LivekitFocus.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
- package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
- package/lib/matrixrtc/focus.d.ts +0 -10
- package/lib/matrixrtc/focus.d.ts.map +0 -1
- package/lib/matrixrtc/focus.js +0 -1
- package/lib/matrixrtc/focus.js.map +0 -1
- package/lib/matrixrtc/index.d.ts +0 -7
- package/lib/matrixrtc/index.d.ts.map +0 -1
- package/lib/matrixrtc/index.js +0 -21
- package/lib/matrixrtc/index.js.map +0 -1
- package/lib/matrixrtc/types.d.ts +0 -19
- package/lib/matrixrtc/types.d.ts.map +0 -1
- package/lib/matrixrtc/types.js +0 -1
- package/lib/matrixrtc/types.js.map +0 -1
- package/lib/webrtc/audioContext.d.ts +0 -15
- package/lib/webrtc/audioContext.d.ts.map +0 -1
- package/lib/webrtc/audioContext.js +0 -46
- package/lib/webrtc/audioContext.js.map +0 -1
- package/lib/webrtc/call.d.ts +0 -560
- package/lib/webrtc/call.d.ts.map +0 -1
- package/lib/webrtc/call.js +0 -2541
- package/lib/webrtc/call.js.map +0 -1
- package/lib/webrtc/callEventHandler.d.ts +0 -37
- package/lib/webrtc/callEventHandler.d.ts.map +0 -1
- package/lib/webrtc/callEventHandler.js +0 -344
- package/lib/webrtc/callEventHandler.js.map +0 -1
- package/lib/webrtc/callEventTypes.d.ts +0 -73
- package/lib/webrtc/callEventTypes.d.ts.map +0 -1
- package/lib/webrtc/callEventTypes.js +0 -13
- package/lib/webrtc/callEventTypes.js.map +0 -1
- package/lib/webrtc/callFeed.d.ts +0 -128
- package/lib/webrtc/callFeed.d.ts.map +0 -1
- package/lib/webrtc/callFeed.js +0 -289
- package/lib/webrtc/callFeed.js.map +0 -1
- package/lib/webrtc/groupCall.d.ts +0 -323
- package/lib/webrtc/groupCall.d.ts.map +0 -1
- package/lib/webrtc/groupCall.js +0 -1337
- package/lib/webrtc/groupCall.js.map +0 -1
- package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
- package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
- package/lib/webrtc/groupCallEventHandler.js +0 -178
- package/lib/webrtc/groupCallEventHandler.js.map +0 -1
- package/lib/webrtc/mediaHandler.d.ts +0 -89
- package/lib/webrtc/mediaHandler.d.ts.map +0 -1
- package/lib/webrtc/mediaHandler.js +0 -437
- package/lib/webrtc/mediaHandler.js.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
- package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
- package/lib/webrtc/stats/connectionStats.d.ts +0 -28
- package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStats.js +0 -26
- package/lib/webrtc/stats/connectionStats.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
- package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
- package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
- package/lib/webrtc/stats/groupCallStats.js +0 -78
- package/lib/webrtc/stats/groupCallStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
- package/lib/webrtc/stats/statsReport.d.ts +0 -99
- package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReport.js +0 -32
- package/lib/webrtc/stats/statsReport.js.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
- package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.js +0 -33
- package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
- package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
- package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/transportStats.d.ts +0 -11
- package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStats.js +0 -1
- package/lib/webrtc/stats/transportStats.js.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
- package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
- package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
- package/lib/webrtc/stats/valueFormatter.js +0 -25
- package/lib/webrtc/stats/valueFormatter.js.map +0 -1
- package/src/matrixrtc/CallMembership.ts +0 -247
- package/src/matrixrtc/LivekitFocus.ts +0 -39
- package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
- package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
- package/src/matrixrtc/focus.ts +0 -25
- package/src/matrixrtc/index.ts +0 -22
- package/src/matrixrtc/types.ts +0 -36
- package/src/webrtc/audioContext.ts +0 -44
- package/src/webrtc/call.ts +0 -3074
- package/src/webrtc/callEventHandler.ts +0 -425
- package/src/webrtc/callEventTypes.ts +0 -93
- package/src/webrtc/callFeed.ts +0 -364
- package/src/webrtc/groupCall.ts +0 -1735
- package/src/webrtc/groupCallEventHandler.ts +0 -234
- package/src/webrtc/mediaHandler.ts +0 -484
- package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
- package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
- package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
- package/src/webrtc/stats/connectionStats.ts +0 -47
- package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
- package/src/webrtc/stats/groupCallStats.ts +0 -93
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
- package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
- package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
- package/src/webrtc/stats/statsReport.ts +0 -133
- package/src/webrtc/stats/statsReportEmitter.ts +0 -49
- package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
- package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
- package/src/webrtc/stats/transportStats.ts +0 -26
- package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
- package/src/webrtc/stats/valueFormatter.ts +0 -27
@@ -1,207 +0,0 @@
|
|
1
|
-
import { MediaTrackStats } from "./media/mediaTrackStats.ts";
|
2
|
-
import { ValueFormatter } from "./valueFormatter.ts";
|
3
|
-
import { TrackSummary } from "./callStatsReportSummary.ts";
|
4
|
-
|
5
|
-
export class TrackStatsBuilder {
|
6
|
-
public static buildFramerateResolution(trackStats: MediaTrackStats, now: any): void {
|
7
|
-
const resolution = {
|
8
|
-
height: now.frameHeight,
|
9
|
-
width: now.frameWidth,
|
10
|
-
};
|
11
|
-
const frameRate = now.framesPerSecond;
|
12
|
-
|
13
|
-
if (resolution.height && resolution.width) {
|
14
|
-
trackStats.setResolution(resolution);
|
15
|
-
}
|
16
|
-
trackStats.setFramerate(Math.round(frameRate || 0));
|
17
|
-
}
|
18
|
-
|
19
|
-
public static calculateSimulcastFramerate(trackStats: MediaTrackStats, now: any, before: any, layer: number): void {
|
20
|
-
let frameRate = trackStats.getFramerate();
|
21
|
-
if (!frameRate) {
|
22
|
-
if (before) {
|
23
|
-
const timeMs = now.timestamp - before.timestamp;
|
24
|
-
|
25
|
-
if (timeMs > 0 && now.framesSent) {
|
26
|
-
const numberOfFramesSinceBefore = now.framesSent - before.framesSent;
|
27
|
-
|
28
|
-
frameRate = (numberOfFramesSinceBefore / timeMs) * 1000;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
if (!frameRate) {
|
33
|
-
return;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
// Reset frame rate to 0 when video is suspended as a result of endpoint falling out of last-n.
|
38
|
-
frameRate = layer ? Math.round(frameRate / layer) : 0;
|
39
|
-
trackStats.setFramerate(frameRate);
|
40
|
-
}
|
41
|
-
|
42
|
-
public static buildCodec(report: RTCStatsReport | undefined, trackStats: MediaTrackStats, now: any): void {
|
43
|
-
const codec = report?.get(now.codecId);
|
44
|
-
|
45
|
-
if (codec) {
|
46
|
-
/**
|
47
|
-
* The mime type has the following form: video/VP8 or audio/ISAC,
|
48
|
-
* so we what to keep just the type after the '/', audio and video
|
49
|
-
* keys will be added on the processing side.
|
50
|
-
*/
|
51
|
-
const codecShortType = codec.mimeType.split("/")[1];
|
52
|
-
|
53
|
-
if (codecShortType) trackStats.setCodec(codecShortType);
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
public static buildBitrateReceived(trackStats: MediaTrackStats, now: any, before: any): void {
|
58
|
-
trackStats.setBitrate({
|
59
|
-
download: TrackStatsBuilder.calculateBitrate(
|
60
|
-
now.bytesReceived,
|
61
|
-
before.bytesReceived,
|
62
|
-
now.timestamp,
|
63
|
-
before.timestamp,
|
64
|
-
),
|
65
|
-
upload: 0,
|
66
|
-
});
|
67
|
-
}
|
68
|
-
|
69
|
-
public static buildBitrateSend(trackStats: MediaTrackStats, now: any, before: any): void {
|
70
|
-
trackStats.setBitrate({
|
71
|
-
download: 0,
|
72
|
-
upload: this.calculateBitrate(now.bytesSent, before.bytesSent, now.timestamp, before.timestamp),
|
73
|
-
});
|
74
|
-
}
|
75
|
-
|
76
|
-
public static buildPacketsLost(trackStats: MediaTrackStats, now: any, before: any): void {
|
77
|
-
const key = now.type === "outbound-rtp" ? "packetsSent" : "packetsReceived";
|
78
|
-
|
79
|
-
let packetsNow = now[key];
|
80
|
-
if (!packetsNow || packetsNow < 0) {
|
81
|
-
packetsNow = 0;
|
82
|
-
}
|
83
|
-
|
84
|
-
const packetsBefore = ValueFormatter.getNonNegativeValue(before[key]);
|
85
|
-
const packetsDiff = Math.max(0, packetsNow - packetsBefore);
|
86
|
-
|
87
|
-
const packetsLostNow = ValueFormatter.getNonNegativeValue(now.packetsLost);
|
88
|
-
const packetsLostBefore = ValueFormatter.getNonNegativeValue(before.packetsLost);
|
89
|
-
const packetsLostDiff = Math.max(0, packetsLostNow - packetsLostBefore);
|
90
|
-
|
91
|
-
trackStats.setLoss({
|
92
|
-
packetsTotal: packetsDiff + packetsLostDiff,
|
93
|
-
packetsLost: packetsLostDiff,
|
94
|
-
isDownloadStream: now.type !== "outbound-rtp",
|
95
|
-
});
|
96
|
-
}
|
97
|
-
|
98
|
-
private static calculateBitrate(
|
99
|
-
bytesNowAny: any,
|
100
|
-
bytesBeforeAny: any,
|
101
|
-
nowTimestamp: number,
|
102
|
-
beforeTimestamp: number,
|
103
|
-
): number {
|
104
|
-
const bytesNow = ValueFormatter.getNonNegativeValue(bytesNowAny);
|
105
|
-
const bytesBefore = ValueFormatter.getNonNegativeValue(bytesBeforeAny);
|
106
|
-
const bytesProcessed = Math.max(0, bytesNow - bytesBefore);
|
107
|
-
|
108
|
-
const timeMs = nowTimestamp - beforeTimestamp;
|
109
|
-
let bitrateKbps = 0;
|
110
|
-
|
111
|
-
if (timeMs > 0) {
|
112
|
-
bitrateKbps = Math.round((bytesProcessed * 8) / timeMs);
|
113
|
-
}
|
114
|
-
|
115
|
-
return bitrateKbps;
|
116
|
-
}
|
117
|
-
|
118
|
-
public static setTrackStatsState(trackStats: MediaTrackStats, transceiver: RTCRtpTransceiver | undefined): void {
|
119
|
-
if (transceiver === undefined) {
|
120
|
-
trackStats.alive = false;
|
121
|
-
return;
|
122
|
-
}
|
123
|
-
|
124
|
-
const track = trackStats.getType() === "remote" ? transceiver.receiver.track : transceiver?.sender?.track;
|
125
|
-
if (track === undefined || track === null) {
|
126
|
-
trackStats.alive = false;
|
127
|
-
return;
|
128
|
-
}
|
129
|
-
|
130
|
-
if (track.readyState === "ended") {
|
131
|
-
trackStats.alive = false;
|
132
|
-
return;
|
133
|
-
}
|
134
|
-
trackStats.muted = track.muted;
|
135
|
-
trackStats.enabled = track.enabled;
|
136
|
-
trackStats.alive = true;
|
137
|
-
}
|
138
|
-
|
139
|
-
public static buildTrackSummary(trackStatsList: MediaTrackStats[]): {
|
140
|
-
audioTrackSummary: TrackSummary;
|
141
|
-
videoTrackSummary: TrackSummary;
|
142
|
-
} {
|
143
|
-
const videoTrackSummary: TrackSummary = {
|
144
|
-
count: 0,
|
145
|
-
muted: 0,
|
146
|
-
maxJitter: 0,
|
147
|
-
maxPacketLoss: 0,
|
148
|
-
concealedAudio: 0,
|
149
|
-
totalAudio: 0,
|
150
|
-
};
|
151
|
-
const audioTrackSummary: TrackSummary = {
|
152
|
-
count: 0,
|
153
|
-
muted: 0,
|
154
|
-
maxJitter: 0,
|
155
|
-
maxPacketLoss: 0,
|
156
|
-
concealedAudio: 0,
|
157
|
-
totalAudio: 0,
|
158
|
-
};
|
159
|
-
|
160
|
-
const remoteTrackList = trackStatsList.filter((t) => t.getType() === "remote");
|
161
|
-
const audioTrackList = remoteTrackList.filter((t) => t.kind === "audio");
|
162
|
-
|
163
|
-
remoteTrackList.forEach((stats) => {
|
164
|
-
const trackSummary = stats.kind === "video" ? videoTrackSummary : audioTrackSummary;
|
165
|
-
trackSummary.count++;
|
166
|
-
if (stats.alive && stats.muted) {
|
167
|
-
trackSummary.muted++;
|
168
|
-
}
|
169
|
-
if (trackSummary.maxJitter < stats.getJitter()) {
|
170
|
-
trackSummary.maxJitter = stats.getJitter();
|
171
|
-
}
|
172
|
-
if (trackSummary.maxPacketLoss < stats.getLoss().packetsLost) {
|
173
|
-
trackSummary.maxPacketLoss = stats.getLoss().packetsLost;
|
174
|
-
}
|
175
|
-
if (audioTrackList.length > 0) {
|
176
|
-
trackSummary.concealedAudio += stats.getAudioConcealment()?.concealedAudio;
|
177
|
-
trackSummary.totalAudio += stats.getAudioConcealment()?.totalAudioDuration;
|
178
|
-
}
|
179
|
-
});
|
180
|
-
|
181
|
-
return { audioTrackSummary, videoTrackSummary };
|
182
|
-
}
|
183
|
-
|
184
|
-
public static buildJitter(trackStats: MediaTrackStats, statsReport: any): void {
|
185
|
-
if (statsReport.type !== "inbound-rtp") {
|
186
|
-
return;
|
187
|
-
}
|
188
|
-
|
189
|
-
const jitterStr = statsReport?.jitter;
|
190
|
-
if (jitterStr !== undefined) {
|
191
|
-
const jitter = ValueFormatter.getNonNegativeValue(jitterStr);
|
192
|
-
trackStats.setJitter(Math.round(jitter * 1000));
|
193
|
-
} else {
|
194
|
-
trackStats.setJitter(-1);
|
195
|
-
}
|
196
|
-
}
|
197
|
-
|
198
|
-
public static buildAudioConcealment(trackStats: MediaTrackStats, statsReport: any): void {
|
199
|
-
if (statsReport.type !== "inbound-rtp") {
|
200
|
-
return;
|
201
|
-
}
|
202
|
-
const msPerSample = (1000 * statsReport?.totalSamplesDuration) / statsReport?.totalSamplesReceived;
|
203
|
-
const concealedAudioDuration = msPerSample * statsReport?.concealedSamples;
|
204
|
-
const totalAudioDuration = 1000 * statsReport?.totalSamplesDuration;
|
205
|
-
trackStats.setAudioConcealment(concealedAudioDuration, totalAudioDuration);
|
206
|
-
}
|
207
|
-
}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Copyright 2023 The Matrix.org Foundation C.I.C.
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
*/
|
16
|
-
|
17
|
-
export interface TransportStats {
|
18
|
-
ip: string;
|
19
|
-
type: string;
|
20
|
-
localIp: string;
|
21
|
-
isFocus: boolean;
|
22
|
-
localCandidateType: string;
|
23
|
-
remoteCandidateType: string;
|
24
|
-
networkType: string;
|
25
|
-
rtt: number;
|
26
|
-
}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import { TransportStats } from "./transportStats.ts";
|
2
|
-
|
3
|
-
export class TransportStatsBuilder {
|
4
|
-
public static buildReport(
|
5
|
-
report: RTCStatsReport | undefined,
|
6
|
-
now: RTCIceCandidatePairStats,
|
7
|
-
conferenceStatsTransport: TransportStats[],
|
8
|
-
isFocus: boolean,
|
9
|
-
): TransportStats[] {
|
10
|
-
const localUsedCandidate = report?.get(now.localCandidateId);
|
11
|
-
const remoteUsedCandidate = report?.get(now.remoteCandidateId);
|
12
|
-
|
13
|
-
// RTCIceCandidateStats
|
14
|
-
// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
|
15
|
-
if (remoteUsedCandidate && localUsedCandidate) {
|
16
|
-
const remoteIpAddress =
|
17
|
-
remoteUsedCandidate.ip !== undefined ? remoteUsedCandidate.ip : remoteUsedCandidate.address;
|
18
|
-
const remotePort = remoteUsedCandidate.port;
|
19
|
-
const ip = `${remoteIpAddress}:${remotePort}`;
|
20
|
-
|
21
|
-
const localIpAddress =
|
22
|
-
localUsedCandidate.ip !== undefined ? localUsedCandidate.ip : localUsedCandidate.address;
|
23
|
-
const localPort = localUsedCandidate.port;
|
24
|
-
const localIp = `${localIpAddress}:${localPort}`;
|
25
|
-
|
26
|
-
const type = remoteUsedCandidate.protocol;
|
27
|
-
|
28
|
-
// Save the address unless it has been saved already.
|
29
|
-
if (
|
30
|
-
!conferenceStatsTransport.some(
|
31
|
-
(t: TransportStats) => t.ip === ip && t.type === type && t.localIp === localIp,
|
32
|
-
)
|
33
|
-
) {
|
34
|
-
conferenceStatsTransport.push({
|
35
|
-
ip,
|
36
|
-
type,
|
37
|
-
localIp,
|
38
|
-
isFocus,
|
39
|
-
localCandidateType: localUsedCandidate.candidateType,
|
40
|
-
remoteCandidateType: remoteUsedCandidate.candidateType,
|
41
|
-
networkType: localUsedCandidate.networkType,
|
42
|
-
rtt: now.currentRoundTripTime ? now.currentRoundTripTime * 1000 : NaN,
|
43
|
-
} as TransportStats);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
return conferenceStatsTransport;
|
47
|
-
}
|
48
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Copyright 2023 The Matrix.org Foundation C.I.C.
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
you may not use this file except in compliance with the License.
|
5
|
-
You may obtain a copy of the License at
|
6
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
7
|
-
Unless required by applicable law or agreed to in writing, software
|
8
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
-
See the License for the specific language governing permissions and
|
11
|
-
limitations under the License.
|
12
|
-
*/
|
13
|
-
export class ValueFormatter {
|
14
|
-
public static getNonNegativeValue(imput: any): number {
|
15
|
-
let value = imput;
|
16
|
-
|
17
|
-
if (typeof value !== "number") {
|
18
|
-
value = Number(value);
|
19
|
-
}
|
20
|
-
|
21
|
-
if (isNaN(value)) {
|
22
|
-
return 0;
|
23
|
-
}
|
24
|
-
|
25
|
-
return Math.max(0, value);
|
26
|
-
}
|
27
|
-
}
|