@osimatic/helpers-js 1.1.30 → 1.1.32

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/web_rtc.js +7 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.1.30",
3
+ "version": "1.1.32",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/web_rtc.js CHANGED
@@ -8,7 +8,7 @@ class WebRTC {
8
8
  this.turnSecret = turnSecret;
9
9
  }
10
10
 
11
- static offer(stream, iceCandidateCallback, iceGatheringStateChangeCallback) {
11
+ static offer(stream, iceCandidateCallback, iceGatheringStateChangeCallback, onIceCandidateErrorCallback) {
12
12
  return new Promise(async (resolve, reject) => {
13
13
  try {
14
14
  let { username, password } = this.getTurnCredentials();
@@ -25,20 +25,9 @@ class WebRTC {
25
25
  }
26
26
  );
27
27
 
28
- /*
29
- Note: While you can determine that ICE candidate gathering is complete
30
- by watching for icegatheringstatechange events and checking for the value of iceGatheringState to become complete,
31
- you can also have your handler for the icecandidate event look to see if its candidate property is null.
32
- This also indicates that collection of candidates is finished.
33
- https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/icegatheringstatechange_event
34
- */
28
+ peerConn.icecandidateerror = ((event) => onIceCandidateErrorCallback(event.url, event.errorText));
35
29
  peerConn.onicegatheringstatechange = ((event) => iceGatheringStateChangeCallback(event));
36
-
37
- peerConn.onicecandidate = ((event) => {
38
- if (event.candidate) {
39
- iceCandidateCallback(event.candidate);
40
- }
41
- });
30
+ peerConn.onicecandidate = ((event) => iceCandidateCallback(event));
42
31
 
43
32
  stream.getTracks().forEach(track => peerConn.addTrack(track, stream));
44
33
 
@@ -52,7 +41,7 @@ class WebRTC {
52
41
  });
53
42
  }
54
43
 
55
- static answer(remoteDescription, onTrackCallback, iceCandidateCallback, iceGatheringStateChangeCallback) {
44
+ static answer(remoteDescription, onTrackCallback, iceCandidateCallback, iceGatheringStateChangeCallback, onIceCandidateErrorCallback) {
56
45
  return new Promise(async (resolve, reject) => {
57
46
  try {
58
47
  let { username, password } = this.getTurnCredentials();
@@ -69,22 +58,10 @@ class WebRTC {
69
58
  }
70
59
  );
71
60
 
72
- /*
73
- Note: While you can determine that ICE candidate gathering is complete
74
- by watching for icegatheringstatechange events and checking for the value of iceGatheringState to become complete,
75
- you can also have your handler for the icecandidate event look to see if its candidate property is null.
76
- This also indicates that collection of candidates is finished.
77
- https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/icegatheringstatechange_event
78
- */
61
+ peerConn.icecandidateerror = ((event) => onIceCandidateErrorCallback(event.url, event.errorText));
79
62
  peerConn.onicegatheringstatechange = ((event) => iceGatheringStateChangeCallback(event));
80
-
81
- peerConn.onicecandidate = ((event) => {
82
- if (event.candidate) {
83
- iceCandidateCallback(event.candidate);
84
- }
85
- });
86
-
87
- peerConn.ontrack = (event) => onTrackCallback(event.streams);
63
+ peerConn.onicecandidate = ((event) => iceCandidateCallback(event));
64
+ peerConn.ontrack = ((event) => onTrackCallback(event.streams));
88
65
 
89
66
  peerConn.setRemoteDescription(new RTCSessionDescription(remoteDescription))
90
67