@pexip/peer-connection-stats 17.8.0 → 17.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/index.d.ts +3 -325
- package/dist/index.js +3 -0
- package/dist/statsCollector.d.ts +145 -0
- package/dist/statsCollector.js +497 -0
- package/dist/statsCollector.types.d.ts +160 -0
- package/dist/statsCollector.types.js +7 -0
- package/dist/tests/statsCollector.chrome-inbound-presentation.fixtures.d.ts +2 -0
- package/dist/tests/statsCollector.chrome-inbound-presentation.fixtures.js +972 -0
- package/dist/tests/statsCollector.chrome-multiple.fixtures.d.ts +7 -0
- package/dist/tests/statsCollector.chrome-multiple.fixtures.js +2640 -0
- package/dist/tests/statsCollector.chrome-outbound-presentation.fixtures.d.ts +2 -0
- package/dist/tests/statsCollector.chrome-outbound-presentation.fixtures.js +907 -0
- package/dist/tests/statsCollector.firefox.fixtures.d.ts +2 -0
- package/dist/tests/statsCollector.firefox.fixtures.js +471 -0
- package/dist/utils.d.ts +15 -0
- package/dist/utils.js +30 -0
- package/package.json +5 -5
- package/dist/index.mjs +0 -478
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 17.10.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [bfb8058]
|
|
8
|
+
- @pexip/utils@16.11.0
|
|
9
|
+
- @pexip/signal@16.7.0
|
|
10
|
+
|
|
11
|
+
## 17.9.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 4a1908a: Use tsc to build packages
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [4a1908a]
|
|
20
|
+
- Updated dependencies [ec134d1]
|
|
21
|
+
- Updated dependencies [24fe7e1]
|
|
22
|
+
- @pexip/signal@16.7.0
|
|
23
|
+
- @pexip/utils@16.10.0
|
|
24
|
+
|
|
3
25
|
## 17.8.0
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,325 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
id: string;
|
|
5
|
-
type: string;
|
|
6
|
-
kind?: 'audio' | 'video';
|
|
7
|
-
timestamp?: number;
|
|
8
|
-
[key: string]: unknown;
|
|
9
|
-
}
|
|
10
|
-
interface Remote extends RTCStats {
|
|
11
|
-
type: 'remote-inbound-rtp';
|
|
12
|
-
jitter?: number;
|
|
13
|
-
packetsLost?: number;
|
|
14
|
-
roundTripTime?: number;
|
|
15
|
-
codec?: Codec;
|
|
16
|
-
transport?: Transport;
|
|
17
|
-
}
|
|
18
|
-
interface CandidatePair extends RTCStats {
|
|
19
|
-
type: 'candidate-pair';
|
|
20
|
-
availableIncomingBitrate?: number;
|
|
21
|
-
availableOutgoingBitrate?: number;
|
|
22
|
-
currentRoundTripTime?: number;
|
|
23
|
-
transport?: Transport;
|
|
24
|
-
localCandidate?: CandidatePair;
|
|
25
|
-
remoteCandidate?: CandidatePair;
|
|
26
|
-
}
|
|
27
|
-
interface Transport extends RTCStats {
|
|
28
|
-
type: 'transport';
|
|
29
|
-
selectedCandidatePair?: CandidatePair;
|
|
30
|
-
}
|
|
31
|
-
interface Codec extends RTCStats {
|
|
32
|
-
type: 'codec';
|
|
33
|
-
mimeType?: string;
|
|
34
|
-
}
|
|
35
|
-
interface InboundAudio extends RTCStats {
|
|
36
|
-
type: 'inbound-rtp';
|
|
37
|
-
kind: 'audio';
|
|
38
|
-
jitter?: number;
|
|
39
|
-
packetsReceived?: number;
|
|
40
|
-
packetsLost?: number;
|
|
41
|
-
bytesReceived?: number;
|
|
42
|
-
track?: Track;
|
|
43
|
-
transport?: Transport;
|
|
44
|
-
codec?: Codec;
|
|
45
|
-
}
|
|
46
|
-
interface OutboundAudio extends RTCStats {
|
|
47
|
-
type: 'outbound-rtp';
|
|
48
|
-
kind: 'audio';
|
|
49
|
-
packetsSent?: number;
|
|
50
|
-
bytesSent?: number;
|
|
51
|
-
remote?: Remote;
|
|
52
|
-
transport?: Transport;
|
|
53
|
-
codec?: Codec;
|
|
54
|
-
}
|
|
55
|
-
interface InboundVideo extends RTCStats {
|
|
56
|
-
type: 'inbound-rtp';
|
|
57
|
-
kind: 'video';
|
|
58
|
-
packetsReceived?: number;
|
|
59
|
-
packetsLost?: number;
|
|
60
|
-
bytesReceived?: number;
|
|
61
|
-
transport?: Transport;
|
|
62
|
-
codec?: Codec;
|
|
63
|
-
frameWidth?: number;
|
|
64
|
-
frameHeight?: number;
|
|
65
|
-
framesPerSecond?: number;
|
|
66
|
-
bitrateMean?: number;
|
|
67
|
-
framerateMean?: number;
|
|
68
|
-
}
|
|
69
|
-
interface OutboundVideo extends RTCStats {
|
|
70
|
-
type: 'outbound-rtp';
|
|
71
|
-
kind: 'video';
|
|
72
|
-
packetsSent?: number;
|
|
73
|
-
packetsLost?: number;
|
|
74
|
-
bytesSent?: number;
|
|
75
|
-
totalPacketSendDelay?: number;
|
|
76
|
-
frameWidth?: number;
|
|
77
|
-
frameHeight?: number;
|
|
78
|
-
framesPerSecond?: number;
|
|
79
|
-
codec?: Codec;
|
|
80
|
-
mediaSource?: MediaSource;
|
|
81
|
-
remote?: Remote;
|
|
82
|
-
track?: Track;
|
|
83
|
-
transport?: Transport;
|
|
84
|
-
bitrateMean?: number;
|
|
85
|
-
framerateMean?: number;
|
|
86
|
-
}
|
|
87
|
-
interface MediaSource extends RTCStats {
|
|
88
|
-
type: 'media-source';
|
|
89
|
-
kind: 'audio' | 'video';
|
|
90
|
-
}
|
|
91
|
-
interface Track extends RTCStats {
|
|
92
|
-
type: 'track';
|
|
93
|
-
kind: 'audio' | 'video';
|
|
94
|
-
mediaSource?: MediaSource;
|
|
95
|
-
}
|
|
96
|
-
interface Stream extends RTCStats {
|
|
97
|
-
type: 'stream';
|
|
98
|
-
tracks?: Track[];
|
|
99
|
-
}
|
|
100
|
-
type AnyStats = CandidatePair | Codec | InboundAudio | InboundVideo | OutboundAudio | OutboundVideo | RTCStats | Remote | Stream | Track | Transport;
|
|
101
|
-
interface Metrics {
|
|
102
|
-
type: 'inbound-rtp' | 'outbound-rtp';
|
|
103
|
-
kind: 'audio' | 'video';
|
|
104
|
-
bitrate?: number;
|
|
105
|
-
bytesTransmitted?: number;
|
|
106
|
-
codec?: string;
|
|
107
|
-
jitter?: number;
|
|
108
|
-
packetsLost: number;
|
|
109
|
-
packetsTransmitted: number;
|
|
110
|
-
recentPercentageLost?: number;
|
|
111
|
-
roundTripTime?: number;
|
|
112
|
-
timestamp?: number;
|
|
113
|
-
totalPercentageLost?: number;
|
|
114
|
-
}
|
|
115
|
-
interface VideoMetrics extends Metrics {
|
|
116
|
-
framesPerSecond?: number;
|
|
117
|
-
resolution?: string;
|
|
118
|
-
resolutionHeight?: number;
|
|
119
|
-
resolutionWidth?: number;
|
|
120
|
-
}
|
|
121
|
-
type InboundAudioMetrics = Metrics;
|
|
122
|
-
type InboundVideoMetrics = VideoMetrics;
|
|
123
|
-
type OutboundAudioMetrics = Metrics;
|
|
124
|
-
type OutboundVideoMetrics = VideoMetrics & {
|
|
125
|
-
totalPacketSendDelay?: number;
|
|
126
|
-
averagePacketSendDelay?: number;
|
|
127
|
-
};
|
|
128
|
-
type NormalizedRTCStats = InboundAudioMetrics | InboundVideoMetrics | OutboundAudioMetrics | OutboundVideoMetrics;
|
|
129
|
-
type PacketsStats = Array<[number, number]>;
|
|
130
|
-
type AudioQualityStats = Array<[number, number]>;
|
|
131
|
-
type VideoQualityStats = number[];
|
|
132
|
-
type CallQualityStats = AudioQualityStats | VideoQualityStats;
|
|
133
|
-
type CallPacketsStats = PacketsStats;
|
|
134
|
-
interface CacheStats {
|
|
135
|
-
previous?: NormalizedRTCStats;
|
|
136
|
-
callPacketsStats: CallPacketsStats;
|
|
137
|
-
callQuality: Quality;
|
|
138
|
-
callQualityStats: CallQualityStats;
|
|
139
|
-
}
|
|
140
|
-
declare enum Quality {
|
|
141
|
-
GOOD = 0,
|
|
142
|
-
OK = 1,
|
|
143
|
-
BAD = 2,
|
|
144
|
-
TERRIBLE = 3
|
|
145
|
-
}
|
|
146
|
-
interface StatsSignals {
|
|
147
|
-
onRtcStats: Signal<NormalizedRTCStats>;
|
|
148
|
-
onCallQuality: Signal<Quality>;
|
|
149
|
-
onCallQualityStats: Signal<CallQualityStats>;
|
|
150
|
-
}
|
|
151
|
-
interface StatsCollectorOptions {
|
|
152
|
-
input: {
|
|
153
|
-
getStats: (selector?: MediaStreamTrack | null) => Promise<RTCStatsReport>;
|
|
154
|
-
};
|
|
155
|
-
signals: StatsSignals;
|
|
156
|
-
interval?: number;
|
|
157
|
-
}
|
|
158
|
-
interface StatsCollector {
|
|
159
|
-
resetStats: () => () => void;
|
|
160
|
-
cleanup: () => void;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
declare const STATS_SIZE = 60;
|
|
164
|
-
/**
|
|
165
|
-
* The WebRTC stats are given to us as a flat structure (an array of objects
|
|
166
|
-
* that contain id-fields pointing to other objects in the same array).
|
|
167
|
-
*
|
|
168
|
-
* This class takes such an array as input and can expand an entry so that
|
|
169
|
-
* references become nested objects.
|
|
170
|
-
*
|
|
171
|
-
* https://www.w3.org/TR/webrtc-stats/#summary
|
|
172
|
-
* https://www.w3.org/TR/webrtc-stats/#rtctatstype-*
|
|
173
|
-
*/
|
|
174
|
-
declare const createResolver: (statsReport: AnyStats[]) => {
|
|
175
|
-
expand: {
|
|
176
|
-
(audioIn: InboundAudio): InboundAudio;
|
|
177
|
-
(audioOut: OutboundAudio): OutboundAudio;
|
|
178
|
-
(videoIn: InboundVideo): InboundVideo;
|
|
179
|
-
(videoOut: OutboundVideo): OutboundVideo;
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* Normalize inbound audio stats
|
|
184
|
-
*
|
|
185
|
-
* @param statsData - Raw inbound audio stats @see InboundAudio
|
|
186
|
-
*
|
|
187
|
-
* @returns normalized stats for inbound audio from PeerConnection
|
|
188
|
-
*/
|
|
189
|
-
declare const inboundAudio: (statsData: InboundAudio) => InboundAudioMetrics;
|
|
190
|
-
/**
|
|
191
|
-
* Normalize outbound audio stats
|
|
192
|
-
*
|
|
193
|
-
* @param statsData - Raw outbound audio stats @see OutboundAudio
|
|
194
|
-
*
|
|
195
|
-
* @returns normalized stats for outbound audio from PeerConnection
|
|
196
|
-
*/
|
|
197
|
-
declare const outboundAudio: (statsData: OutboundAudio) => OutboundAudioMetrics;
|
|
198
|
-
/**
|
|
199
|
-
* Normalize inbound video stats
|
|
200
|
-
*
|
|
201
|
-
* @param statsData - Raw inbound video stats @see InboundVideo
|
|
202
|
-
*
|
|
203
|
-
* @returns normalized stats for inbound video from PeerConnection
|
|
204
|
-
*/
|
|
205
|
-
declare const inboundVideo: (statsData: InboundVideo) => InboundVideoMetrics;
|
|
206
|
-
/**
|
|
207
|
-
* Normalize outbound video stats
|
|
208
|
-
*
|
|
209
|
-
* @param statsData - Raw outbound video stats @see OutboundVideo
|
|
210
|
-
*
|
|
211
|
-
* @returns normalized stats for outbound video from PeerConnection
|
|
212
|
-
*/
|
|
213
|
-
declare const outboundVideo: (statsData: OutboundVideo) => OutboundVideoMetrics;
|
|
214
|
-
/**
|
|
215
|
-
* Normalize stats into inbound and outbound video and audio stats
|
|
216
|
-
*
|
|
217
|
-
* @param statsReports - reports to for mapping
|
|
218
|
-
*
|
|
219
|
-
* @returns normalized stats for inbound, outbound audio and video
|
|
220
|
-
*/
|
|
221
|
-
declare const statsFrom: (statsReports: AnyStats[]) => Metrics | undefined;
|
|
222
|
-
/**
|
|
223
|
-
* Gets raw stats from peerConnection and normalized them
|
|
224
|
-
*
|
|
225
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_Statistics_API
|
|
226
|
-
*
|
|
227
|
-
* A RTCPeerConnection has getStats()
|
|
228
|
-
* - getStats() returns promise which resolve to a RTCStatsReport
|
|
229
|
-
* - RTCStatsReport behaves like an array of RTCStats objects, or more
|
|
230
|
-
* specific RTCRtpStreamStats objects
|
|
231
|
-
*
|
|
232
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/RTCStatsReport
|
|
233
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/RTCStats
|
|
234
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpStreamStats
|
|
235
|
-
*
|
|
236
|
-
*/
|
|
237
|
-
declare const statsFromRTCPeer: (rtcPeer: {
|
|
238
|
-
getStats: (selector?: MediaStreamTrack | null) => Promise<RTCStatsReport>;
|
|
239
|
-
}) => Promise<NormalizedRTCStats>;
|
|
240
|
-
declare const getQuality: (stats: CallQualityStats) => {
|
|
241
|
-
quality: Quality;
|
|
242
|
-
goodOrOkQuality: number;
|
|
243
|
-
qualityOverTime: Quality[];
|
|
244
|
-
};
|
|
245
|
-
declare const addDeltaStats: (newStats: NormalizedRTCStats, cache: CacheStats) => readonly [{
|
|
246
|
-
type: "inbound-rtp" | "outbound-rtp";
|
|
247
|
-
kind: "audio" | "video";
|
|
248
|
-
bitrate?: number | undefined;
|
|
249
|
-
bytesTransmitted?: number | undefined;
|
|
250
|
-
codec?: string | undefined;
|
|
251
|
-
jitter?: number | undefined;
|
|
252
|
-
packetsLost: number;
|
|
253
|
-
packetsTransmitted: number;
|
|
254
|
-
recentPercentageLost?: number | undefined;
|
|
255
|
-
roundTripTime?: number | undefined;
|
|
256
|
-
timestamp?: number | undefined;
|
|
257
|
-
totalPercentageLost?: number | undefined;
|
|
258
|
-
} | {
|
|
259
|
-
framesPerSecond?: number | undefined;
|
|
260
|
-
resolution?: string | undefined;
|
|
261
|
-
resolutionHeight?: number | undefined;
|
|
262
|
-
resolutionWidth?: number | undefined;
|
|
263
|
-
type: "inbound-rtp" | "outbound-rtp";
|
|
264
|
-
kind: "audio" | "video";
|
|
265
|
-
bitrate?: number | undefined;
|
|
266
|
-
bytesTransmitted?: number | undefined;
|
|
267
|
-
codec?: string | undefined;
|
|
268
|
-
jitter?: number | undefined;
|
|
269
|
-
packetsLost: number;
|
|
270
|
-
packetsTransmitted: number;
|
|
271
|
-
recentPercentageLost?: number | undefined;
|
|
272
|
-
roundTripTime?: number | undefined;
|
|
273
|
-
timestamp?: number | undefined;
|
|
274
|
-
totalPercentageLost?: number | undefined;
|
|
275
|
-
} | {
|
|
276
|
-
framesPerSecond?: number | undefined;
|
|
277
|
-
resolution?: string | undefined;
|
|
278
|
-
resolutionHeight?: number | undefined;
|
|
279
|
-
resolutionWidth?: number | undefined;
|
|
280
|
-
type: "inbound-rtp" | "outbound-rtp";
|
|
281
|
-
kind: "audio" | "video";
|
|
282
|
-
bitrate?: number | undefined;
|
|
283
|
-
bytesTransmitted?: number | undefined;
|
|
284
|
-
codec?: string | undefined;
|
|
285
|
-
jitter?: number | undefined;
|
|
286
|
-
packetsLost: number;
|
|
287
|
-
packetsTransmitted: number;
|
|
288
|
-
recentPercentageLost?: number | undefined;
|
|
289
|
-
roundTripTime?: number | undefined;
|
|
290
|
-
timestamp?: number | undefined;
|
|
291
|
-
totalPercentageLost?: number | undefined;
|
|
292
|
-
totalPacketSendDelay?: number | undefined;
|
|
293
|
-
averagePacketSendDelay?: number | undefined;
|
|
294
|
-
}, Quality, CallQualityStats];
|
|
295
|
-
declare const calculateQuality: (stats: number | [
|
|
296
|
-
number,
|
|
297
|
-
number
|
|
298
|
-
]) => Quality;
|
|
299
|
-
/**
|
|
300
|
-
* Creates stats collector
|
|
301
|
-
*
|
|
302
|
-
* @param input - input to get stats from
|
|
303
|
-
* @param signal - Signal which distributes stats
|
|
304
|
-
* @param interval - how often signal with fire with new stats
|
|
305
|
-
*
|
|
306
|
-
* @returns \{function to reset stats window, cleanup func\}
|
|
307
|
-
*/
|
|
308
|
-
declare const createStatsCollector: ({ input, signals: { onCallQuality, onCallQualityStats, onRtcStats }, interval, }: StatsCollectorOptions) => StatsCollector;
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Create and return all required and optional (if specified with `more`),
|
|
312
|
-
* signals for infinity client to work
|
|
313
|
-
*
|
|
314
|
-
* @param scope - any scope prefix for the generated signal name, @see Signal
|
|
315
|
-
* @param more - Keys from `InfinitySignalsOptional`, @see InfinitySignalsOptional
|
|
316
|
-
*
|
|
317
|
-
* The following signals created by default
|
|
318
|
-
* - 'onConnected',
|
|
319
|
-
* - 'onAnswer',
|
|
320
|
-
*
|
|
321
|
-
* @see REQUIRED_STATS_SIGNAL_KEYS
|
|
322
|
-
*/
|
|
323
|
-
declare const createStatsSignals: (scope?: string) => StatsSignals;
|
|
324
|
-
|
|
325
|
-
export { AnyStats, AudioQualityStats, CacheStats, CallPacketsStats, CallQualityStats, CandidatePair, Codec, InboundAudio, InboundAudioMetrics, InboundVideo, InboundVideoMetrics, MediaSource, Metrics, NormalizedRTCStats, OutboundAudio, OutboundAudioMetrics, OutboundVideo, OutboundVideoMetrics, PacketsStats, Quality, RTCStats, Remote, STATS_SIZE, StatsCollector, StatsCollectorOptions, StatsSignals, Stream, Track, Transport, VideoMetrics, VideoQualityStats, addDeltaStats, calculateQuality, createResolver, createStatsCollector, createStatsSignals, getQuality, inboundAudio, inboundVideo, outboundAudio, outboundVideo, statsFrom, statsFromRTCPeer };
|
|
1
|
+
export * from './statsCollector.types';
|
|
2
|
+
export * from './statsCollector';
|
|
3
|
+
export * from './utils';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { AnyStats, CacheStats, CallQualityStats, InboundAudio, InboundAudioMetrics, InboundVideo, InboundVideoMetrics, Metrics, NormalizedRTCStats, OutboundAudio, OutboundAudioMetrics, OutboundVideo, OutboundVideoMetrics, StatsCollector, StatsCollectorOptions } from './statsCollector.types';
|
|
2
|
+
import { Quality } from './statsCollector.types';
|
|
3
|
+
export declare const STATS_SIZE = 60;
|
|
4
|
+
/**
|
|
5
|
+
* The WebRTC stats are given to us as a flat structure (an array of objects
|
|
6
|
+
* that contain id-fields pointing to other objects in the same array).
|
|
7
|
+
*
|
|
8
|
+
* This class takes such an array as input and can expand an entry so that
|
|
9
|
+
* references become nested objects.
|
|
10
|
+
*
|
|
11
|
+
* https://www.w3.org/TR/webrtc-stats/#summary
|
|
12
|
+
* https://www.w3.org/TR/webrtc-stats/#rtctatstype-*
|
|
13
|
+
*/
|
|
14
|
+
export declare const createResolver: (statsReport: AnyStats[]) => {
|
|
15
|
+
expand: {
|
|
16
|
+
(audioIn: InboundAudio): InboundAudio;
|
|
17
|
+
(audioOut: OutboundAudio): OutboundAudio;
|
|
18
|
+
(videoIn: InboundVideo): InboundVideo;
|
|
19
|
+
(videoOut: OutboundVideo): OutboundVideo;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Normalize inbound audio stats
|
|
24
|
+
*
|
|
25
|
+
* @param statsData - Raw inbound audio stats @see InboundAudio
|
|
26
|
+
*
|
|
27
|
+
* @returns normalized stats for inbound audio from PeerConnection
|
|
28
|
+
*/
|
|
29
|
+
export declare const inboundAudio: (statsData: InboundAudio) => InboundAudioMetrics;
|
|
30
|
+
/**
|
|
31
|
+
* Normalize outbound audio stats
|
|
32
|
+
*
|
|
33
|
+
* @param statsData - Raw outbound audio stats @see OutboundAudio
|
|
34
|
+
*
|
|
35
|
+
* @returns normalized stats for outbound audio from PeerConnection
|
|
36
|
+
*/
|
|
37
|
+
export declare const outboundAudio: (statsData: OutboundAudio) => OutboundAudioMetrics;
|
|
38
|
+
/**
|
|
39
|
+
* Normalize inbound video stats
|
|
40
|
+
*
|
|
41
|
+
* @param statsData - Raw inbound video stats @see InboundVideo
|
|
42
|
+
*
|
|
43
|
+
* @returns normalized stats for inbound video from PeerConnection
|
|
44
|
+
*/
|
|
45
|
+
export declare const inboundVideo: (statsData: InboundVideo) => InboundVideoMetrics;
|
|
46
|
+
/**
|
|
47
|
+
* Normalize outbound video stats
|
|
48
|
+
*
|
|
49
|
+
* @param statsData - Raw outbound video stats @see OutboundVideo
|
|
50
|
+
*
|
|
51
|
+
* @returns normalized stats for outbound video from PeerConnection
|
|
52
|
+
*/
|
|
53
|
+
export declare const outboundVideo: (statsData: OutboundVideo) => OutboundVideoMetrics;
|
|
54
|
+
/**
|
|
55
|
+
* Normalize stats into inbound and outbound video and audio stats
|
|
56
|
+
*
|
|
57
|
+
* @param statsReports - reports to for mapping
|
|
58
|
+
*
|
|
59
|
+
* @returns normalized stats for inbound, outbound audio and video
|
|
60
|
+
*/
|
|
61
|
+
export declare const statsFrom: (statsReports: AnyStats[]) => Metrics | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Gets raw stats from peerConnection and normalized them
|
|
64
|
+
*
|
|
65
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_Statistics_API
|
|
66
|
+
*
|
|
67
|
+
* A RTCPeerConnection has getStats()
|
|
68
|
+
* - getStats() returns promise which resolve to a RTCStatsReport
|
|
69
|
+
* - RTCStatsReport behaves like an array of RTCStats objects, or more
|
|
70
|
+
* specific RTCRtpStreamStats objects
|
|
71
|
+
*
|
|
72
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/RTCStatsReport
|
|
73
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/RTCStats
|
|
74
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpStreamStats
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
export declare const statsFromRTCPeer: (rtcPeer: {
|
|
78
|
+
getStats: (selector?: MediaStreamTrack | null) => Promise<RTCStatsReport>;
|
|
79
|
+
}) => Promise<NormalizedRTCStats>;
|
|
80
|
+
export declare const getQuality: (stats: CallQualityStats) => {
|
|
81
|
+
quality: Quality;
|
|
82
|
+
goodOrOkQuality: number;
|
|
83
|
+
qualityOverTime: Quality[];
|
|
84
|
+
};
|
|
85
|
+
export declare const addDeltaStats: (newStats: NormalizedRTCStats, cache: CacheStats) => readonly [{
|
|
86
|
+
type: "inbound-rtp" | "outbound-rtp";
|
|
87
|
+
kind: "audio" | "video";
|
|
88
|
+
bitrate?: number | undefined;
|
|
89
|
+
bytesTransmitted?: number | undefined;
|
|
90
|
+
codec?: string | undefined;
|
|
91
|
+
jitter?: number | undefined;
|
|
92
|
+
packetsLost: number;
|
|
93
|
+
packetsTransmitted: number;
|
|
94
|
+
recentPercentageLost?: number | undefined;
|
|
95
|
+
roundTripTime?: number | undefined;
|
|
96
|
+
timestamp?: number | undefined;
|
|
97
|
+
totalPercentageLost?: number | undefined;
|
|
98
|
+
} | {
|
|
99
|
+
framesPerSecond?: number | undefined;
|
|
100
|
+
resolution?: string | undefined;
|
|
101
|
+
resolutionHeight?: number | undefined;
|
|
102
|
+
resolutionWidth?: number | undefined;
|
|
103
|
+
type: "inbound-rtp" | "outbound-rtp";
|
|
104
|
+
kind: "audio" | "video";
|
|
105
|
+
bitrate?: number | undefined;
|
|
106
|
+
bytesTransmitted?: number | undefined;
|
|
107
|
+
codec?: string | undefined;
|
|
108
|
+
jitter?: number | undefined;
|
|
109
|
+
packetsLost: number;
|
|
110
|
+
packetsTransmitted: number;
|
|
111
|
+
recentPercentageLost?: number | undefined;
|
|
112
|
+
roundTripTime?: number | undefined;
|
|
113
|
+
timestamp?: number | undefined;
|
|
114
|
+
totalPercentageLost?: number | undefined;
|
|
115
|
+
} | {
|
|
116
|
+
framesPerSecond?: number | undefined;
|
|
117
|
+
resolution?: string | undefined;
|
|
118
|
+
resolutionHeight?: number | undefined;
|
|
119
|
+
resolutionWidth?: number | undefined;
|
|
120
|
+
type: "inbound-rtp" | "outbound-rtp";
|
|
121
|
+
kind: "audio" | "video";
|
|
122
|
+
bitrate?: number | undefined;
|
|
123
|
+
bytesTransmitted?: number | undefined;
|
|
124
|
+
codec?: string | undefined;
|
|
125
|
+
jitter?: number | undefined;
|
|
126
|
+
packetsLost: number;
|
|
127
|
+
packetsTransmitted: number;
|
|
128
|
+
recentPercentageLost?: number | undefined;
|
|
129
|
+
roundTripTime?: number | undefined;
|
|
130
|
+
timestamp?: number | undefined;
|
|
131
|
+
totalPercentageLost?: number | undefined;
|
|
132
|
+
totalPacketSendDelay?: number | undefined;
|
|
133
|
+
averagePacketSendDelay?: number | undefined;
|
|
134
|
+
}, Quality, CallQualityStats];
|
|
135
|
+
export declare const calculateQuality: (stats: number | [number, number]) => Quality;
|
|
136
|
+
/**
|
|
137
|
+
* Creates stats collector
|
|
138
|
+
*
|
|
139
|
+
* @param input - input to get stats from
|
|
140
|
+
* @param signal - Signal which distributes stats
|
|
141
|
+
* @param interval - how often signal with fire with new stats
|
|
142
|
+
*
|
|
143
|
+
* @returns \{function to reset stats window, cleanup func\}
|
|
144
|
+
*/
|
|
145
|
+
export declare const createStatsCollector: ({ input, signals: { onCallQuality, onCallQualityStats, onRtcStats }, interval, }: StatsCollectorOptions) => StatsCollector;
|