@reactoo/watchtogether-sdk-js 2.6.92 → 2.6.95

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.6.92",
3
+ "version": "2.6.95",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -364,7 +364,7 @@ let roomSession = function ({roomId, pinHash, role, options = {}}, room, wt) {
364
364
  },
365
365
 
366
366
  selectSubStream: (handleId, substream, source, mid) => {
367
- return room.selectSubStream(handleId, substream, source, mid);
367
+ return room.selectSubStream(handleId, substream, source, mid, true);
368
368
  },
369
369
 
370
370
  setBitrateCap: (bitrate) => {
@@ -968,7 +968,7 @@ class RoomSession {
968
968
  stats: {},
969
969
  selectedSubstream: {},
970
970
  initialSimulcastSubstreamBeenSet: {},
971
- simulcastSwitchFailedAttempts: {},
971
+ forcedAutoMode:{},
972
972
  };
973
973
 
974
974
  if (handleId === this.handleId) {
@@ -1025,7 +1025,7 @@ class RoomSession {
1025
1025
  stats: {},
1026
1026
  selectedSubstream: {},
1027
1027
  initialSimulcastSubstreamBeenSet: {},
1028
- simulcastSwitchFailedAttempts: {},
1028
+ forcedAutoMode:{},
1029
1029
  }
1030
1030
  };
1031
1031
  this._participants.push(handle);
@@ -1579,17 +1579,18 @@ class RoomSession {
1579
1579
  }
1580
1580
 
1581
1581
  const initialSubstreamBeenSet = !!p.webrtcStuff.initialSimulcastSubstreamBeenSet[mid];
1582
+
1582
1583
  const defaultSelectedSubstream = typeof this.simulcastDefaultManualSubstream === 'object'
1583
1584
  ? (this.simulcastDefaultManualSubstream[source] !== undefined
1584
1585
  ? this.simulcastDefaultManualSubstream[source]
1585
1586
  : this.simulcastDefaultManualSubstream['default'])
1586
1587
  : this.simulcastDefaultManualSubstream;
1588
+
1587
1589
  const simulcastMode = typeof this.simulcastMode === 'object'
1588
1590
  ? (this.simulcastMode[source] !== undefined ? this.simulcastMode[source] : this.simulcastMode['default'])
1589
1591
  : this.simulcastMode;
1590
- const failedAttempts = p.webrtcStuff.simulcastSwitchFailedAttempts[mid] || 0;
1591
1592
 
1592
- if((simulcastMode === 'auto') /* || failedAttempts > 3 */) {
1593
+ if((simulcastMode === 'auto' || p.webrtcStuff.forcedAutoMode[mid])) {
1593
1594
  // do nothing
1594
1595
  }
1595
1596
 
@@ -1599,17 +1600,6 @@ class RoomSession {
1599
1600
  if(defaultSelectedSubstream !== undefined && defaultSelectedSubstream !== null && defaultSelectedSubstream !== currentSubstream) {
1600
1601
  this._log('Attempting to force substream quality', defaultSelectedSubstream);
1601
1602
  this.selectSubStream(p.handleId, defaultSelectedSubstream, undefined, mid, false)
1602
- .then(() => {
1603
- p.webrtcStuff.simulcastSwitchFailedAttempts[mid] = 0
1604
- })
1605
- .catch(() => {
1606
- if(!p.webrtcStuff.simulcastSwitchFailedAttempts[mid]) {
1607
- p.webrtcStuff.simulcastSwitchFailedAttempts[mid] = 1;
1608
- }
1609
- else {
1610
- p.webrtcStuff.simulcastSwitchFailedAttempts[mid]++;
1611
- }
1612
- });
1613
1603
  }
1614
1604
  }
1615
1605
 
@@ -1636,18 +1626,6 @@ class RoomSession {
1636
1626
  this._log('Attempting to down the quality', currentSubstream + 1);
1637
1627
  this._resetStats(p.handleId, mid);
1638
1628
  this.selectSubStream(p.handleId, currentSubstream + 1, undefined, mid, false)
1639
- .then(() => {
1640
- p.webrtcStuff.simulcastSwitchFailedAttempts[mid] = 0
1641
- })
1642
- .catch((e) => {
1643
- this._log('switch failed:', e);
1644
- if(!p.webrtcStuff.simulcastSwitchFailedAttempts[mid]) {
1645
- p.webrtcStuff.simulcastSwitchFailedAttempts[mid] = 1;
1646
- }
1647
- else {
1648
- p.webrtcStuff.simulcastSwitchFailedAttempts[mid]++;
1649
- }
1650
- })
1651
1629
  }
1652
1630
  }
1653
1631
  else if (directionDecision === 1) {
@@ -1655,18 +1633,6 @@ class RoomSession {
1655
1633
  this._log('Attempting to up the quality', currentSubstream - 1);
1656
1634
  this._resetStats(p.handleId, mid);
1657
1635
  this.selectSubStream(p.handleId, currentSubstream - 1, undefined, mid, false)
1658
- .then(() => {
1659
- p.webrtcStuff.simulcastSwitchFailedAttempts[mid] = 0
1660
- })
1661
- .catch((e) => {
1662
- this._log('switch failed:', e);
1663
- if(!p.webrtcStuff.simulcastSwitchFailedAttempts[mid]) {
1664
- p.webrtcStuff.simulcastSwitchFailedAttempts[mid] = 1;
1665
- }
1666
- else {
1667
- p.webrtcStuff.simulcastSwitchFailedAttempts[mid]++;
1668
- }
1669
- })
1670
1636
  }
1671
1637
  }
1672
1638
  }
@@ -1754,6 +1720,8 @@ class RoomSession {
1754
1720
  if(report.type === 'local-candidate') {
1755
1721
  stats.networkType = report.networkType;
1756
1722
  }
1723
+
1724
+ stats.selectedSubstream = handle.webrtcStuff.selectedSubstream[participantStats.mid];
1757
1725
  });
1758
1726
 
1759
1727
  // pushing stats into handle stats array but keeping only 6 last stats
@@ -1761,8 +1729,8 @@ class RoomSession {
1761
1729
  if(handle.webrtcStuff.stats[participantStats.mid].length > this._statsMaxLength) {
1762
1730
  handle.webrtcStuff.stats[participantStats.mid].shift();
1763
1731
  }
1764
-
1765
- this.emit('rtcStats', {handleId: participantStats.handle.handleId, stats, source: participantStats.source, mid: participantsStats.mid});
1732
+
1733
+ this.emit('rtcStats', {handleId: participantStats.handle.handleId, stats, userId: decodeJanusDisplay(participantStats.handle.userId)?.userId, source: participantStats.source, mid: participantStats.mid});
1766
1734
  }
1767
1735
  }
1768
1736
  });
@@ -2955,7 +2923,7 @@ class RoomSession {
2955
2923
  }
2956
2924
  }
2957
2925
 
2958
- selectSubStream(handleId, substream = 2, source, mid) {
2926
+ selectSubStream(handleId, substream = 2, source, mid, manual = false) {
2959
2927
  this._log('Select substream called for handle:', handleId, 'Source or mid:', source ? source : mid, 'Substream:', substream);
2960
2928
  let handle = this._getHandle(handleId);
2961
2929
  if(!handle) {
@@ -2998,12 +2966,20 @@ class RoomSession {
2998
2966
  }
2999
2967
  }
3000
2968
  if(mid !== undefined) {
3001
-
3002
2969
  if(substream === null) {
2970
+
2971
+ if(manual) {
2972
+ config.forcedAutoMode[mid] = false
2973
+ }
2974
+
3003
2975
  resolve({substream, sender: handleId});
3004
2976
  return;
3005
2977
  }
3006
2978
 
2979
+ if(manual) {
2980
+ config.forcedAutoMode[mid] = true
2981
+ }
2982
+
3007
2983
  this.ws.addEventListener('message', parseResponse);
3008
2984
  this._abortController.signal.addEventListener('abort', abortResponse);
3009
2985
  messageTimeoutId = setTimeout(() => {