@stream-io/video-client 1.0.3 → 1.0.5
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/CHANGELOG.md +14 -0
- package/dist/index.browser.es.js +54 -43
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +54 -43
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +54 -43
- package/dist/index.es.js.map +1 -1
- package/dist/src/gen/coordinator/index.d.ts +214 -0
- package/dist/src/stats/SfuStatsReporter.d.ts +2 -2
- package/dist/src/stats/stateStoreStatsReporter.d.ts +3 -2
- package/dist/src/stats/utils.d.ts +3 -0
- package/package.json +1 -1
- package/src/Call.ts +12 -5
- package/src/devices/InputMediaDeviceManager.ts +1 -0
- package/src/gen/coordinator/index.ts +214 -0
- package/src/stats/SfuStatsReporter.ts +6 -15
- package/src/stats/stateStoreStatsReporter.ts +29 -21
- package/src/stats/utils.ts +15 -11
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
### [1.0.5](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.0.4...@stream-io/video-client-1.0.5) (2024-05-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* correctly handle pending state reset ([4ea47da](https://github.com/GetStream/stream-video-js/commit/4ea47da969f00925e1df144ec2f33cd07ac2f63f))
|
|
11
|
+
|
|
12
|
+
### [1.0.4](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.0.3...@stream-io/video-client-1.0.4) (2024-05-14)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* don't create publisher PC for anonymous users ([#1353](https://github.com/GetStream/stream-video-js/issues/1353)) ([7331767](https://github.com/GetStream/stream-video-js/commit/7331767bd9254082517b1f36895796032b7af149))
|
|
18
|
+
|
|
5
19
|
### [1.0.3](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.0.2...@stream-io/video-client-1.0.3) (2024-05-13)
|
|
6
20
|
|
|
7
21
|
|
package/dist/index.browser.es.js
CHANGED
|
@@ -9788,25 +9788,29 @@ const flatten = (report) => {
|
|
|
9788
9788
|
};
|
|
9789
9789
|
const getSdkSignature = (clientDetails) => {
|
|
9790
9790
|
const { sdk, ...platform } = clientDetails;
|
|
9791
|
-
const sdkName = sdk
|
|
9792
|
-
|
|
9793
|
-
: sdk && sdk.type === SdkType.REACT_NATIVE
|
|
9794
|
-
? 'stream-react-native'
|
|
9795
|
-
: 'stream-js';
|
|
9796
|
-
const sdkVersion = sdk
|
|
9797
|
-
? `${sdk.major}.${sdk.minor}.${sdk.patch}`
|
|
9798
|
-
: '0.0.0-development';
|
|
9791
|
+
const sdkName = getSdkName(sdk);
|
|
9792
|
+
const sdkVersion = getSdkVersion(sdk);
|
|
9799
9793
|
return {
|
|
9800
9794
|
sdkName,
|
|
9801
9795
|
sdkVersion,
|
|
9802
9796
|
...platform,
|
|
9803
9797
|
};
|
|
9804
9798
|
};
|
|
9799
|
+
const getSdkName = (sdk) => {
|
|
9800
|
+
return sdk && sdk.type === SdkType.REACT
|
|
9801
|
+
? 'stream-react'
|
|
9802
|
+
: sdk && sdk.type === SdkType.REACT_NATIVE
|
|
9803
|
+
? 'stream-react-native'
|
|
9804
|
+
: 'stream-js';
|
|
9805
|
+
};
|
|
9806
|
+
const getSdkVersion = (sdk) => {
|
|
9807
|
+
return sdk ? `${sdk.major}.${sdk.minor}.${sdk.patch}` : '0.0.0-development';
|
|
9808
|
+
};
|
|
9805
9809
|
|
|
9806
9810
|
/**
|
|
9807
9811
|
* Creates a new StatsReporter instance that collects metrics about the ongoing call and reports them to the state store
|
|
9808
9812
|
*/
|
|
9809
|
-
const createStatsReporter = ({ subscriber, publisher, state, pollingIntervalInMs = 2000, }) => {
|
|
9813
|
+
const createStatsReporter = ({ subscriber, publisher, state, datacenter, pollingIntervalInMs = 2000, }) => {
|
|
9810
9814
|
const logger = getLogger(['stats']);
|
|
9811
9815
|
const getRawStatsForTrack = async (kind, selector) => {
|
|
9812
9816
|
if (kind === 'subscriber' && subscriber) {
|
|
@@ -9816,12 +9820,13 @@ const createStatsReporter = ({ subscriber, publisher, state, pollingIntervalInMs
|
|
|
9816
9820
|
return publisher.getStats(selector);
|
|
9817
9821
|
}
|
|
9818
9822
|
else {
|
|
9819
|
-
logger('warn', `Can't retrieve RTC stats for ${kind}`);
|
|
9820
9823
|
return undefined;
|
|
9821
9824
|
}
|
|
9822
9825
|
};
|
|
9823
9826
|
const getStatsForStream = async (kind, mediaStream) => {
|
|
9824
9827
|
const pc = kind === 'subscriber' ? subscriber : publisher;
|
|
9828
|
+
if (!pc)
|
|
9829
|
+
return [];
|
|
9825
9830
|
const statsForStream = [];
|
|
9826
9831
|
for (let track of mediaStream.getTracks()) {
|
|
9827
9832
|
const report = await pc.getStats(track);
|
|
@@ -9867,7 +9872,7 @@ const createStatsReporter = ({ subscriber, publisher, state, pollingIntervalInMs
|
|
|
9867
9872
|
});
|
|
9868
9873
|
}
|
|
9869
9874
|
catch (e) {
|
|
9870
|
-
logger('error', `Failed to collect stats for ${kind}
|
|
9875
|
+
logger('error', `Failed to collect stats for ${kind} of ${participant.userId}`, e);
|
|
9871
9876
|
}
|
|
9872
9877
|
}
|
|
9873
9878
|
}
|
|
@@ -9880,19 +9885,21 @@ const createStatsReporter = ({ subscriber, publisher, state, pollingIntervalInMs
|
|
|
9880
9885
|
}))
|
|
9881
9886
|
.then(aggregate),
|
|
9882
9887
|
publisher
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9888
|
+
? publisher
|
|
9889
|
+
.getStats()
|
|
9890
|
+
.then((report) => transform(report, {
|
|
9891
|
+
kind: 'publisher',
|
|
9892
|
+
trackKind: 'video',
|
|
9893
|
+
}))
|
|
9894
|
+
.then(aggregate)
|
|
9895
|
+
: getEmptyStats(),
|
|
9889
9896
|
]);
|
|
9890
9897
|
const [subscriberRawStats, publisherRawStats] = await Promise.all([
|
|
9891
9898
|
getRawStatsForTrack('subscriber'),
|
|
9892
|
-
getRawStatsForTrack('publisher'),
|
|
9899
|
+
publisher ? getRawStatsForTrack('publisher') : undefined,
|
|
9893
9900
|
]);
|
|
9894
9901
|
state.setCallStatsReport({
|
|
9895
|
-
datacenter
|
|
9902
|
+
datacenter,
|
|
9896
9903
|
publisherStats,
|
|
9897
9904
|
subscriberStats,
|
|
9898
9905
|
subscriberRawStats,
|
|
@@ -9969,14 +9976,9 @@ const transform = (report, opts) => {
|
|
|
9969
9976
|
timestamp: Date.now(),
|
|
9970
9977
|
};
|
|
9971
9978
|
};
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
* @param stats the stats to aggregate.
|
|
9976
|
-
*/
|
|
9977
|
-
const aggregate = (stats) => {
|
|
9978
|
-
const aggregatedStats = {
|
|
9979
|
-
rawReport: stats,
|
|
9979
|
+
const getEmptyStats = (stats) => {
|
|
9980
|
+
return {
|
|
9981
|
+
rawReport: stats ?? { streams: [], timestamp: Date.now() },
|
|
9980
9982
|
totalBytesSent: 0,
|
|
9981
9983
|
totalBytesReceived: 0,
|
|
9982
9984
|
averageJitterInMs: 0,
|
|
@@ -9987,6 +9989,14 @@ const aggregate = (stats) => {
|
|
|
9987
9989
|
highestFramesPerSecond: 0,
|
|
9988
9990
|
timestamp: Date.now(),
|
|
9989
9991
|
};
|
|
9992
|
+
};
|
|
9993
|
+
/**
|
|
9994
|
+
* Aggregates generic stats.
|
|
9995
|
+
*
|
|
9996
|
+
* @param stats the stats to aggregate.
|
|
9997
|
+
*/
|
|
9998
|
+
const aggregate = (stats) => {
|
|
9999
|
+
const aggregatedStats = getEmptyStats(stats);
|
|
9990
10000
|
let maxArea = -1;
|
|
9991
10001
|
const area = (w, h) => w * h;
|
|
9992
10002
|
const qualityLimitationReasons = new Set();
|
|
@@ -10030,7 +10040,7 @@ class SfuStatsReporter {
|
|
|
10030
10040
|
this.run = async () => {
|
|
10031
10041
|
const [subscriberStats, publisherStats] = await Promise.all([
|
|
10032
10042
|
this.subscriber.getStats().then(flatten).then(JSON.stringify),
|
|
10033
|
-
this.publisher
|
|
10043
|
+
this.publisher?.getStats().then(flatten).then(JSON.stringify) ?? '[]',
|
|
10034
10044
|
]);
|
|
10035
10045
|
await this.sfuClient.sendStats({
|
|
10036
10046
|
sdk: this.sdkName,
|
|
@@ -10059,15 +10069,8 @@ class SfuStatsReporter {
|
|
|
10059
10069
|
this.publisher = publisher;
|
|
10060
10070
|
const webRTCInfo = getWebRTCInfo();
|
|
10061
10071
|
const { sdk, browser } = clientDetails;
|
|
10062
|
-
this.sdkName =
|
|
10063
|
-
|
|
10064
|
-
? 'stream-react'
|
|
10065
|
-
: sdk && sdk.type === SdkType.REACT_NATIVE
|
|
10066
|
-
? 'stream-react-native'
|
|
10067
|
-
: 'stream-js';
|
|
10068
|
-
this.sdkVersion = sdk
|
|
10069
|
-
? `${sdk.major}.${sdk.minor}.${sdk.patch}`
|
|
10070
|
-
: '0.0.0-development';
|
|
10072
|
+
this.sdkName = getSdkName(sdk);
|
|
10073
|
+
this.sdkVersion = getSdkVersion(sdk);
|
|
10071
10074
|
// The WebRTC version if passed from the SDK, it is taken else the browser info is sent.
|
|
10072
10075
|
this.webRTCVersion =
|
|
10073
10076
|
webRTCInfo?.version ||
|
|
@@ -11210,6 +11213,7 @@ class InputMediaDeviceManager {
|
|
|
11210
11213
|
resetStatusChangeRequest() {
|
|
11211
11214
|
this.statusChangePromise = undefined;
|
|
11212
11215
|
this.statusChangeAbortController = undefined;
|
|
11216
|
+
this.state.setPendingStatus(this.state.status);
|
|
11213
11217
|
}
|
|
11214
11218
|
}
|
|
11215
11219
|
|
|
@@ -12623,7 +12627,10 @@ class Call {
|
|
|
12623
12627
|
connectionConfig,
|
|
12624
12628
|
});
|
|
12625
12629
|
}
|
|
12626
|
-
|
|
12630
|
+
// anonymous users can't publish anything hence, there is no need
|
|
12631
|
+
// to create Publisher Peer Connection for them
|
|
12632
|
+
const isAnonymous = this.streamClient.user?.type === 'anonymous';
|
|
12633
|
+
if (!this.publisher && !isAnonymous) {
|
|
12627
12634
|
const audioSettings = this.state.settings?.audio;
|
|
12628
12635
|
const isDtxEnabled = !!audioSettings?.opus_dtx_enabled;
|
|
12629
12636
|
const isRedEnabled = !!audioSettings?.redundant_coding_enabled;
|
|
@@ -12641,6 +12648,7 @@ class Call {
|
|
|
12641
12648
|
subscriber: this.subscriber,
|
|
12642
12649
|
publisher: this.publisher,
|
|
12643
12650
|
state: this.state,
|
|
12651
|
+
datacenter: this.sfuClient.edgeName,
|
|
12644
12652
|
});
|
|
12645
12653
|
}
|
|
12646
12654
|
const clientDetails = getClientDetails();
|
|
@@ -12686,15 +12694,18 @@ class Call {
|
|
|
12686
12694
|
}
|
|
12687
12695
|
if (isMigrating) {
|
|
12688
12696
|
await this.subscriber.migrateTo(sfuClient, connectionConfig);
|
|
12689
|
-
await this.publisher
|
|
12697
|
+
await this.publisher?.migrateTo(sfuClient, connectionConfig);
|
|
12690
12698
|
}
|
|
12691
12699
|
else if (isReconnecting) {
|
|
12692
12700
|
if (reconnected) {
|
|
12693
12701
|
// update the SFU client instance on the subscriber and publisher
|
|
12694
12702
|
this.subscriber.setSfuClient(sfuClient);
|
|
12695
|
-
|
|
12696
|
-
|
|
12697
|
-
|
|
12703
|
+
// publisher might not be there (anonymous users)
|
|
12704
|
+
if (this.publisher) {
|
|
12705
|
+
this.publisher.setSfuClient(sfuClient);
|
|
12706
|
+
// and perform a full ICE restart on the publisher
|
|
12707
|
+
await this.publisher.restartIce();
|
|
12708
|
+
}
|
|
12698
12709
|
}
|
|
12699
12710
|
else if (previousSfuClient?.isFastReconnecting) {
|
|
12700
12711
|
// reconnection wasn't possible, so we need to do a full rejoin
|
|
@@ -15193,7 +15204,7 @@ class StreamClient {
|
|
|
15193
15204
|
});
|
|
15194
15205
|
};
|
|
15195
15206
|
this.getUserAgent = () => {
|
|
15196
|
-
const version = "1.0.
|
|
15207
|
+
const version = "1.0.5" ;
|
|
15197
15208
|
return (this.userAgent ||
|
|
15198
15209
|
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
|
|
15199
15210
|
};
|