@reactoo/watchtogether-sdk-js 2.6.73 → 2.6.74

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.73",
3
+ "version": "2.6.74",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -209,8 +209,8 @@ class RoomSession {
209
209
  this.isMuted = [];
210
210
  this.isVideoEnabled = false;
211
211
  this.isAudioEnabed = false;
212
- this._statsMaxLength = 21;
213
- this._upStatsLength = 20;
212
+ this._statsMaxLength = 16;
213
+ this._upStatsLength = 15;
214
214
  this._downStatsLength = 5;
215
215
  this._statsTimeoutStopped = true;
216
216
  this._statsTimeoutId = null;
@@ -784,7 +784,7 @@ class RoomSession {
784
784
  let temporal = msg["temporal"];
785
785
 
786
786
  if(substream !== undefined && substream !== null) {
787
- this._log('Substream: ',substream);
787
+ this._log('Substream: ', sender, mid, substream);
788
788
  this._setSelectedSubstream(sender, mid, substream);
789
789
  this._resetStats(sender, mid);
790
790
  }
@@ -1103,13 +1103,17 @@ class RoomSession {
1103
1103
  let config = handle.webrtcStuff;
1104
1104
  config.tracksMap = structuredClone(streams.map(s => {
1105
1105
  let source = null;
1106
+ let simulcastBitrates = null;
1106
1107
  try {
1107
- source = JSON.parse(s.description)?.source;
1108
+ const description = JSON.parse(s.description);
1109
+ source = description?.source;
1110
+ simulcastBitrates = description?.simulcastBitrates;
1108
1111
  } catch(e) {}
1109
1112
  return {
1110
1113
  active: !s.disabled,
1111
1114
  description: s.description,
1112
1115
  source: source,
1116
+ simulcastBitrates: simulcastBitrates,
1113
1117
  display: s.display,
1114
1118
  id: s.id,
1115
1119
  mid: s.mid,
@@ -1566,7 +1570,7 @@ class RoomSession {
1566
1570
  const mids = transceivers?.filter(t => t.receiver.track.kind === "video")?.map(t => t.mid) || [];
1567
1571
  mids.forEach(mid => {
1568
1572
 
1569
- const source = p.webrtcStuff.tracksMap.find(t => t.mid === mid)?.source;
1573
+ const {source, simulcastBitrates} = p.webrtcStuff.tracksMap.find(t => t.mid === mid) || {};
1570
1574
  const manualSelectedSubstream = p.webrtcStuff.simulcastSubstreamManualSelect?.[mid];
1571
1575
  const defaultSelectedSubstream = typeof this.simulcastDefaultManualSubstream === 'object'
1572
1576
  ? (this.simulcastDefaultManualSubstream[source] !== undefined ? this.simulcastDefaultManualSubstream[source] : this.simulcastDefaultManualSubstream['default'])
@@ -1614,11 +1618,11 @@ class RoomSession {
1614
1618
 
1615
1619
  else if(simulcastMode === 'controlled') {
1616
1620
  const currentSubstream = p.webrtcStuff.selectedSubstream[mid];
1617
- const settingsForCurrentSubstream = this.simulcastBitrates?.[this.simulcastBitrates.length - 1 - currentSubstream];
1621
+ const settingsForCurrentSubstream = simulcastBitrates?.[simulcastBitrates.length - 1 - currentSubstream];
1618
1622
  let directionDecision = 0;
1619
1623
  if(p.webrtcStuff?.stats?.[mid]?.length > this._upStatsLength) {
1620
1624
  const upMedianStats = this._calculateMedianStats(p.webrtcStuff.stats[mid].slice(this._upStatsLength * -1));
1621
- if(upMedianStats?.framesPerSecond > Math.floor(settingsForCurrentSubstream.maxFramerate * 0.9) || upMedianStats?.freezeDurationSinceLast < (this._upStatsLength * this._statsInterval * 0.1) / 1000 || this._upStatsLength?.freezeCountSinceLast < 3) {
1625
+ if(upMedianStats?.framesPerSecond >= Math.floor(settingsForCurrentSubstream.maxFramerate * 0.7) && upMedianStats?.freezeDurationSinceLast < (this._upStatsLength * this._statsInterval * 0.33) / 1000 && upMedianStats?.freezeCountSinceLast < 3) {
1622
1626
  directionDecision = 1;
1623
1627
  }
1624
1628
  }
@@ -1631,7 +1635,7 @@ class RoomSession {
1631
1635
  }
1632
1636
 
1633
1637
  if(directionDecision === -1) {
1634
- if(currentSubstream < this.simulcastBitrates.length - 1) {
1638
+ if(currentSubstream < simulcastBitrates.length - 1) {
1635
1639
  this._log('switching to low res', currentSubstream + 1);
1636
1640
  this.selectSubStream(p.handleId, currentSubstream + 1, undefined, mid, false)
1637
1641
  .then(() => {
@@ -2757,7 +2761,7 @@ class RoomSession {
2757
2761
  config.streamMap[source].forEach(trackId => {
2758
2762
  let t = transceivers.find(transceiver => transceiver.sender.track && transceiver.sender.track.id === trackId)
2759
2763
  if(t) {
2760
- descriptions.push({mid: t.mid, description: JSON.stringify({source, intercomGroups: this._talkIntercomChannels})});
2764
+ descriptions.push({mid: t.mid, description: JSON.stringify({source, simulcastBitrates: this.simulcastBitrates, intercomGroups: this._talkIntercomChannels})});
2761
2765
  }
2762
2766
  })
2763
2767
  });
@@ -3050,7 +3054,7 @@ class RoomSession {
3050
3054
  config.streamMap[source].forEach(trackId => {
3051
3055
  let t = transceivers.find(transceiver => transceiver.sender.track && transceiver.sender.track.id === trackId)
3052
3056
  if(t) {
3053
- descriptions.push({mid: t.mid, description: JSON.stringify({intercomGroups: groups, source:source})});
3057
+ descriptions.push({mid: t.mid, description: JSON.stringify({simulcastBitrates: this.simulcastBitrates, intercomGroups: groups, source:source})});
3054
3058
  }
3055
3059
  })
3056
3060
  });