@reactoo/watchtogether-sdk-js 2.7.85 → 2.7.86-beta.0
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/watchtogether-sdk.min.js +2 -2
- package/package.json +1 -1
- package/src/modules/wt-room.js +147 -63
package/package.json
CHANGED
package/src/modules/wt-room.js
CHANGED
|
@@ -1789,79 +1789,163 @@ class RoomSession {
|
|
|
1789
1789
|
return medianStats;
|
|
1790
1790
|
}
|
|
1791
1791
|
|
|
1792
|
+
|
|
1792
1793
|
_parseVideoStats(participantsStats) {
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
if(participantStats
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1794
|
+
for (const sourceStats of participantsStats) {
|
|
1795
|
+
for (const participantStats of sourceStats) {
|
|
1796
|
+
if (!participantStats?.handle || participantStats.handle.handleId === this.handleId) continue;
|
|
1797
|
+
|
|
1798
|
+
const handle = this._getHandle(participantStats.handle.handleId);
|
|
1799
|
+
if (!handle) continue;
|
|
1800
|
+
|
|
1801
|
+
const mid = participantStats.mid;
|
|
1802
|
+
handle.webrtcStuff.stats[mid] ??= [];
|
|
1803
|
+
|
|
1804
|
+
const lastStats = handle.webrtcStuff.stats[mid][handle.webrtcStuff.stats[mid].length - 1];
|
|
1805
|
+
|
|
1806
|
+
const stats = {
|
|
1807
|
+
framesPerSecond: null,
|
|
1808
|
+
framesDropped: null,
|
|
1809
|
+
totalFreezesDuration: null,
|
|
1810
|
+
freezeDurationSinceLast: null,
|
|
1811
|
+
freezeCount: null,
|
|
1812
|
+
freezeCountSinceLast: null,
|
|
1813
|
+
jitter: null,
|
|
1814
|
+
packetsLost: null,
|
|
1815
|
+
nackCount: null,
|
|
1816
|
+
roundTripTime: null,
|
|
1817
|
+
width: null,
|
|
1818
|
+
height: null,
|
|
1819
|
+
networkType: null,
|
|
1820
|
+
powerEfficientDecoder: null,
|
|
1821
|
+
selectedSubstream: null,
|
|
1822
|
+
desiredSubstream: null,
|
|
1823
|
+
simulcastMode: null
|
|
1824
|
+
};
|
|
1802
1825
|
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
const simulcastMode = handle.webrtcStuff?.overriddenSimulcastMode[participantStats.mid]?.mode ?? simulcastConfigForSource?.mode ;
|
|
1823
|
-
|
|
1824
|
-
if(report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
1825
|
-
stats.framesPerSecond = report.framesPerSecond || 0;
|
|
1826
|
-
stats.framesDropped = report.framesDropped || 0;
|
|
1827
|
-
stats.totalFreezesDuration = report.totalFreezesDuration || 0;
|
|
1828
|
-
stats.freezeDurationSinceLast = (report.totalFreezesDuration || 0) - (handle.webrtcStuff.stats?.[participantStats.mid]?.[handle.webrtcStuff.stats?.[participantStats.mid]?.length - 1]?.totalFreezesDuration || 0);
|
|
1829
|
-
stats.freezeCount = report.freezeCount || 0;
|
|
1830
|
-
stats.freezeCountSinceLast = (report.freezeCount || 0) - (handle.webrtcStuff.stats?.[participantStats.mid]?.[handle.webrtcStuff.stats?.[participantStats.mid]?.length - 1]?.freezeCount || 0);
|
|
1831
|
-
stats.jitter = report.jitter;
|
|
1832
|
-
stats.packetsLost = report.packetsLost;
|
|
1833
|
-
stats.nackCount = report.nackCount;
|
|
1834
|
-
stats.width = report.frameWidth;
|
|
1835
|
-
stats.height = report.frameHeight;
|
|
1836
|
-
stats.powerEfficientDecoder = report.powerEfficientDecoder;
|
|
1837
|
-
}
|
|
1838
|
-
if(report.type === 'candidate-pair') {
|
|
1839
|
-
stats.roundTripTime = report.currentRoundTripTime;
|
|
1840
|
-
}
|
|
1841
|
-
if(report.type === 'local-candidate') {
|
|
1842
|
-
stats.networkType = report.networkType;
|
|
1843
|
-
}
|
|
1826
|
+
const simulcastConfig = this._findSimulcastConfig(participantStats.source, this.simulcastSettings);
|
|
1827
|
+
const defaultSelectedSubstream = handle.webrtcStuff?.overriddenSimulcastMode[mid]?.defaultSubstream ?? simulcastConfig?.defaultSubstream;
|
|
1828
|
+
const simulcastMode = handle.webrtcStuff?.overriddenSimulcastMode[mid]?.mode ?? simulcastConfig?.mode;
|
|
1829
|
+
|
|
1830
|
+
for (const report of participantStats.stats) {
|
|
1831
|
+
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
1832
|
+
stats.framesPerSecond = report.framesPerSecond || 0;
|
|
1833
|
+
stats.framesDropped = report.framesDropped || 0;
|
|
1834
|
+
stats.totalFreezesDuration = report.totalFreezesDuration || 0;
|
|
1835
|
+
stats.freezeDurationSinceLast = (report.totalFreezesDuration || 0) - (lastStats?.totalFreezesDuration || 0);
|
|
1836
|
+
stats.freezeCount = report.freezeCount || 0;
|
|
1837
|
+
stats.freezeCountSinceLast = (report.freezeCount || 0) - (lastStats?.freezeCount || 0);
|
|
1838
|
+
stats.jitter = report.jitter;
|
|
1839
|
+
stats.packetsLost = report.packetsLost;
|
|
1840
|
+
stats.nackCount = report.nackCount;
|
|
1841
|
+
stats.width = report.frameWidth;
|
|
1842
|
+
stats.height = report.frameHeight;
|
|
1843
|
+
stats.powerEfficientDecoder = report.powerEfficientDecoder;
|
|
1844
|
+
}
|
|
1844
1845
|
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1846
|
+
if (report.type === 'candidate-pair') {
|
|
1847
|
+
stats.roundTripTime = report.currentRoundTripTime;
|
|
1848
|
+
}
|
|
1848
1849
|
|
|
1849
|
-
|
|
1850
|
+
if (report.type === 'local-candidate') {
|
|
1851
|
+
stats.networkType = report.networkType;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1850
1854
|
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
handle.webrtcStuff.stats[participantStats.mid].shift();
|
|
1855
|
-
}
|
|
1855
|
+
stats.selectedSubstream = handle.webrtcStuff.selectedSubstream[mid];
|
|
1856
|
+
stats.desiredSubstream = defaultSelectedSubstream;
|
|
1857
|
+
stats.simulcastMode = simulcastMode;
|
|
1856
1858
|
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
+
handle.webrtcStuff.stats[mid].push(stats);
|
|
1860
|
+
|
|
1861
|
+
if (handle.webrtcStuff.stats[mid].length > this._statsMaxLength) {
|
|
1862
|
+
handle.webrtcStuff.stats[mid].shift();
|
|
1859
1863
|
}
|
|
1860
|
-
});
|
|
1861
|
-
})
|
|
1862
1864
|
|
|
1865
|
+
this.emit('rtcStats', {
|
|
1866
|
+
handleId: participantStats.handle.handleId,
|
|
1867
|
+
stats,
|
|
1868
|
+
userId: decodeJanusDisplay(participantStats.handle.userId)?.userId,
|
|
1869
|
+
source: participantStats.source,
|
|
1870
|
+
mid
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1863
1874
|
}
|
|
1864
1875
|
|
|
1876
|
+
// _parseVideoStats(participantsStats) {
|
|
1877
|
+
// participantsStats.forEach(sourceStats => {
|
|
1878
|
+
// sourceStats.forEach(participantStats => {
|
|
1879
|
+
// if(participantStats !== null && participantStats?.handle?.handleId !== this.handleId) {
|
|
1880
|
+
// let handle = this._getHandle(participantStats.handle.handleId);
|
|
1881
|
+
// if(handle) {
|
|
1882
|
+
//
|
|
1883
|
+
// if(!handle.webrtcStuff.stats[participantStats.mid]) {
|
|
1884
|
+
// handle.webrtcStuff.stats[participantStats.mid] = [];
|
|
1885
|
+
// }
|
|
1886
|
+
//
|
|
1887
|
+
// const stats = {
|
|
1888
|
+
// framesPerSecond: null,
|
|
1889
|
+
// framesDropped: null,
|
|
1890
|
+
// totalFreezesDuration: null,
|
|
1891
|
+
// freezeDurationSinceLast: null,
|
|
1892
|
+
// freezeCount: null,
|
|
1893
|
+
// jitter: null,
|
|
1894
|
+
// packetsLost: null,
|
|
1895
|
+
// nackCount: null,
|
|
1896
|
+
// roundTripTime: null,
|
|
1897
|
+
// width: null,
|
|
1898
|
+
// height: null,
|
|
1899
|
+
// networkType: null,
|
|
1900
|
+
// powerEfficientDecoder: null,
|
|
1901
|
+
// };
|
|
1902
|
+
// participantStats.stats.forEach(report => {
|
|
1903
|
+
//
|
|
1904
|
+
// const simulcastConfigForSource = this._findSimulcastConfig(participantStats.source, this.simulcastSettings);
|
|
1905
|
+
// const defaultSelectedSubstream = handle.webrtcStuff?.overriddenSimulcastMode[participantStats.mid]?.defaultSubstream ?? simulcastConfigForSource?.defaultSubstream;
|
|
1906
|
+
// const simulcastMode = handle.webrtcStuff?.overriddenSimulcastMode[participantStats.mid]?.mode ?? simulcastConfigForSource?.mode ;
|
|
1907
|
+
//
|
|
1908
|
+
// if(report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
1909
|
+
// stats.framesPerSecond = report.framesPerSecond || 0;
|
|
1910
|
+
// stats.framesDropped = report.framesDropped || 0;
|
|
1911
|
+
// stats.totalFreezesDuration = report.totalFreezesDuration || 0;
|
|
1912
|
+
// stats.freezeDurationSinceLast = (report.totalFreezesDuration || 0) - (handle.webrtcStuff.stats?.[participantStats.mid]?.[handle.webrtcStuff.stats?.[participantStats.mid]?.length - 1]?.totalFreezesDuration || 0);
|
|
1913
|
+
// stats.freezeCount = report.freezeCount || 0;
|
|
1914
|
+
// stats.freezeCountSinceLast = (report.freezeCount || 0) - (handle.webrtcStuff.stats?.[participantStats.mid]?.[handle.webrtcStuff.stats?.[participantStats.mid]?.length - 1]?.freezeCount || 0);
|
|
1915
|
+
// stats.jitter = report.jitter;
|
|
1916
|
+
// stats.packetsLost = report.packetsLost;
|
|
1917
|
+
// stats.nackCount = report.nackCount;
|
|
1918
|
+
// stats.width = report.frameWidth;
|
|
1919
|
+
// stats.height = report.frameHeight;
|
|
1920
|
+
// stats.powerEfficientDecoder = report.powerEfficientDecoder;
|
|
1921
|
+
// }
|
|
1922
|
+
// if(report.type === 'candidate-pair') {
|
|
1923
|
+
// stats.roundTripTime = report.currentRoundTripTime;
|
|
1924
|
+
// }
|
|
1925
|
+
// if(report.type === 'local-candidate') {
|
|
1926
|
+
// stats.networkType = report.networkType;
|
|
1927
|
+
// }
|
|
1928
|
+
//
|
|
1929
|
+
// stats.selectedSubstream = handle.webrtcStuff.selectedSubstream[participantStats.mid];
|
|
1930
|
+
// stats.desiredSubstream = defaultSelectedSubstream;
|
|
1931
|
+
// stats.simulcastMode = simulcastMode;
|
|
1932
|
+
//
|
|
1933
|
+
// });
|
|
1934
|
+
//
|
|
1935
|
+
// // pushing stats into handle stats array but keeping only 6 last stats
|
|
1936
|
+
// handle.webrtcStuff.stats[participantStats.mid].push(stats);
|
|
1937
|
+
// if(handle.webrtcStuff.stats[participantStats.mid].length > this._statsMaxLength) {
|
|
1938
|
+
// handle.webrtcStuff.stats[participantStats.mid].shift();
|
|
1939
|
+
// }
|
|
1940
|
+
//
|
|
1941
|
+
// this.emit('rtcStats', {handleId: participantStats.handle.handleId, stats, userId: decodeJanusDisplay(participantStats.handle.userId)?.userId, source: participantStats.source, mid: participantStats.mid});
|
|
1942
|
+
// }
|
|
1943
|
+
// }
|
|
1944
|
+
// });
|
|
1945
|
+
// })
|
|
1946
|
+
//
|
|
1947
|
+
// }
|
|
1948
|
+
|
|
1865
1949
|
_getStats(type = null) {
|
|
1866
1950
|
return Promise.all(this._participants.map(participant => {
|
|
1867
1951
|
let mediaTrack = [];
|