@livedigital/client 2.7.0 → 2.7.2
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/dist/engine/wid/WebRTCIssueDetector.d.ts +1 -0
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/engine/wid/WebRTCIssueDetector.ts +19 -4
- package/src/engine/wid/detectors/NetworkIssueDetector.ts +7 -4
- package/dist/engine/wid/WIDRTCPeerConnection.d.ts +0 -4
- package/src/engine/wid/WIDRTCPeerConnection.ts +0 -13
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { WebRTCStats, WebRTCStatsEventData } from '@peermetrics/webrtc-stats';
|
|
2
|
-
import WIDRTCPeerConnection from './WIDRTCPeerConnection';
|
|
3
2
|
import { WebRTCIssueEmitter } from './WebRTCIssueEmitter';
|
|
4
3
|
import {
|
|
5
4
|
WebRTCIssueDetectorConstructorParams,
|
|
@@ -38,9 +37,7 @@ class WebRTCIssueDetector {
|
|
|
38
37
|
});
|
|
39
38
|
|
|
40
39
|
(window as unknown as WIDWindow).wid = this;
|
|
41
|
-
|
|
42
|
-
window.RTCPeerConnection = WIDRTCPeerConnection;
|
|
43
|
-
}
|
|
40
|
+
this.wrapRTCPeerConnection();
|
|
44
41
|
|
|
45
42
|
this.detectors = [
|
|
46
43
|
new QualityLimitationsIssueDetector(),
|
|
@@ -101,6 +98,24 @@ class WebRTCIssueDetector {
|
|
|
101
98
|
this.emitIssues(issues);
|
|
102
99
|
}
|
|
103
100
|
}
|
|
101
|
+
|
|
102
|
+
private wrapRTCPeerConnection(): void {
|
|
103
|
+
if (!window.RTCPeerConnection) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const OriginalRTCPeerConnection = window.RTCPeerConnection;
|
|
108
|
+
const onConnectionCreated = (pc: RTCPeerConnection) => this.handleNewPeerConnection(pc);
|
|
109
|
+
|
|
110
|
+
function WIDRTCPeerConnection(rtcConfig?: RTCConfiguration) {
|
|
111
|
+
const connection = new OriginalRTCPeerConnection(rtcConfig);
|
|
112
|
+
onConnectionCreated(connection);
|
|
113
|
+
return connection;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
WIDRTCPeerConnection.prototype = OriginalRTCPeerConnection.prototype;
|
|
117
|
+
(window.RTCPeerConnection as unknown) = WIDRTCPeerConnection;
|
|
118
|
+
}
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
export default WebRTCIssueDetector;
|
|
@@ -17,14 +17,17 @@ class NetworkIssueDetector implements IssueDetector {
|
|
|
17
17
|
|
|
18
18
|
private processData(data: WebRTCStatsEventData): IssueDetectorResult {
|
|
19
19
|
const issues: IssueDetectorResult = [];
|
|
20
|
-
const inboundRTPStreamsStats = [...data.audio
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const inboundRTPStreamsStats = [...data.audio?.inbound, ...data.video?.inbound];
|
|
21
|
+
if (!inboundRTPStreamsStats.length) {
|
|
22
|
+
return issues;
|
|
23
|
+
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
const previousStats = this.#lastProcessedStats[data.connection.id];
|
|
26
|
+
if (!previousStats) {
|
|
25
27
|
return issues;
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
const previousInboundStreamStats = [...previousStats.video?.inbound, ...previousStats.audio?.inbound];
|
|
28
31
|
const { packetsReceived } = data.connection;
|
|
29
32
|
const lastPacketsReceived = previousStats.connection.packetsReceived;
|
|
30
33
|
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { WIDWindow } from './types';
|
|
2
|
-
|
|
3
|
-
class WIDRTCPeerConnection extends RTCPeerConnection {
|
|
4
|
-
constructor(configuration?: RTCConfiguration) {
|
|
5
|
-
super(configuration);
|
|
6
|
-
const { wid: webRTCIssueDetector } = (window as unknown as WIDWindow);
|
|
7
|
-
if (webRTCIssueDetector) {
|
|
8
|
-
webRTCIssueDetector.handleNewPeerConnection(this);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default WIDRTCPeerConnection;
|