@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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@livedigital/client",
3
3
  "author": "vlprojects",
4
4
  "license": "MIT",
5
- "version": "2.7.0",
5
+ "version": "2.7.2",
6
6
  "private": false,
7
7
  "bugs": {
8
8
  "url": "https://github.com/vlprojects/livedigital-sdk/issues"
@@ -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
- if (window.RTCPeerConnection) {
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.inbound, ...data.video.inbound];
21
- const previousStats = this.#lastProcessedStats[data.connection.id];
22
- const previousInboundStreamStats = [...previousStats.video.inbound, ...previousStats.audio.inbound];
20
+ const inboundRTPStreamsStats = [...data.audio?.inbound, ...data.video?.inbound];
21
+ if (!inboundRTPStreamsStats.length) {
22
+ return issues;
23
+ }
23
24
 
24
- if (!inboundRTPStreamsStats.length || !previousStats) {
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,4 +0,0 @@
1
- declare class WIDRTCPeerConnection extends RTCPeerConnection {
2
- constructor(configuration?: RTCConfiguration);
3
- }
4
- export default WIDRTCPeerConnection;
@@ -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;