@stream-io/video-client 0.0.2-alpha.9 → 0.0.4
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 +7 -43
- package/dist/index.browser.es.js +99 -65
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +99 -65
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +99 -65
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +2 -9
- package/dist/src/StreamSfuClient.d.ts +25 -1
- package/dist/src/gen/coordinator/index.d.ts +48 -64
- package/dist/src/helpers/sound-detector.d.ts +10 -1
- package/dist/src/rtc/flows/join.d.ts +1 -0
- package/dist/src/store/CallState.d.ts +22 -1
- package/dist/src/types.d.ts +7 -1
- package/package.json +1 -1
- package/src/Call.ts +41 -40
- package/src/StreamSfuClient.ts +37 -7
- package/src/StreamVideoClient.ts +1 -0
- package/src/events/__tests__/call-permissions.test.ts +40 -8
- package/src/events/__tests__/sessions.test.ts +0 -2
- package/src/events/call-permissions.ts +7 -12
- package/src/events/sessions.ts +2 -12
- package/src/gen/coordinator/index.ts +48 -62
- package/src/helpers/sdp-munging.ts +7 -11
- package/src/helpers/sound-detector.ts +13 -9
- package/src/rtc/__tests__/publisher.test.ts +5 -5
- package/src/rtc/flows/join.ts +7 -1
- package/src/rtc/publisher.ts +8 -7
- package/src/rtc/videoLayers.ts +4 -1
- package/src/store/CallState.ts +31 -0
- package/src/types.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,54 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### [0.0.4](https://github.com/GetStream/stream-video-js/compare/client0.0.3...client0.0.4) (2023-06-06)
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
### Bug Fixes
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
* use and save toggled dtx to sdp and remove empty lines when munging ([#597](https://github.com/GetStream/stream-video-js/issues/597)) ([3971276](https://github.com/GetStream/stream-video-js/commit/39712764ce7ac30557ef36ef7f736f2a0a5728b5))
|
|
10
11
|
|
|
12
|
+
### [0.0.3](https://github.com/GetStream/stream-video-js/compare/client0.0.2...client0.0.3) (2023-06-05)
|
|
11
13
|
|
|
12
|
-
### Features
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
### Bug Fixes
|
|
15
16
|
|
|
17
|
+
* preserve last used session-id when reconnecting ([#592](https://github.com/GetStream/stream-video-js/issues/592)) ([25cc9ce](https://github.com/GetStream/stream-video-js/commit/25cc9cef16bcbc505fd0dcc0971ddeab3f07ae50))
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
## [0.0.2-alpha.7](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.6...client0.0.2-alpha.7) (2023-05-30)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## [0.0.2-alpha.6](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.5...client0.0.2-alpha.6) (2023-05-30)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## [0.0.2-alpha.5](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.4...client0.0.2-alpha.5) (2023-05-30)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## [0.0.2-alpha.4](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.3...client0.0.2-alpha.4) (2023-05-30)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
## [0.0.2-alpha.3](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.2...client0.0.2-alpha.3) (2023-05-30)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
### Features
|
|
38
|
-
|
|
39
|
-
* optional callSessionId in queryRecordings ([#563](https://github.com/GetStream/stream-video-js/issues/563)) ([e2dac22](https://github.com/GetStream/stream-video-js/commit/e2dac2298372d94db867195aa52336d51270c502))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## [0.0.2-alpha.2](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.1...client0.0.2-alpha.2) (2023-05-27)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
## [0.0.2-alpha.1](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.0...client0.0.2-alpha.1) (2023-05-27)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
## [0.0.2-alpha.0](https://github.com/GetStream/stream-video-js/compare/client0.0.1...client0.0.2-alpha.0) (2023-05-27)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
## [0.0.1](https://github.com/GetStream/stream-video-js/compare/client0.0.1-alpha.194...client0.0.1) (2023-05-26)
|
|
19
|
+
### [0.0.2](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.25...client0.0.2) (2023-06-02)
|
package/dist/index.browser.es.js
CHANGED
|
@@ -5239,8 +5239,8 @@ const removeCodec = (sdp, mediaType, codecToRemove) => {
|
|
|
5239
5239
|
const fmtp = section === null || section === void 0 ? void 0 : section.fmtp.find((f) => f.payload === codecId);
|
|
5240
5240
|
return sdp
|
|
5241
5241
|
.replace(mediaSection.original, `${mediaSection.mediaWithPorts} ${newCodecOrder}`)
|
|
5242
|
-
.replace(new RegExp(`${rtpMap.original}[\r\n
|
|
5243
|
-
.replace((fmtp === null || fmtp === void 0 ? void 0 : fmtp.original) ? new RegExp(`${fmtp === null || fmtp === void 0 ? void 0 : fmtp.original}[\r\n
|
|
5242
|
+
.replace(new RegExp(`${rtpMap.original}[\r\n]+`), '') // remove the corresponding rtpmap line
|
|
5243
|
+
.replace((fmtp === null || fmtp === void 0 ? void 0 : fmtp.original) ? new RegExp(`${fmtp === null || fmtp === void 0 ? void 0 : fmtp.original}[\r\n]+`) : '', ''); // remove the corresponding fmtp line
|
|
5244
5244
|
};
|
|
5245
5245
|
/**
|
|
5246
5246
|
* Gets the fmtp line corresponding to opus
|
|
@@ -5250,8 +5250,7 @@ const getOpusFmtp = (sdp) => {
|
|
|
5250
5250
|
const rtpMap = section === null || section === void 0 ? void 0 : section.rtpMap.find((r) => r.codec.toLowerCase() === 'opus');
|
|
5251
5251
|
const codecId = rtpMap === null || rtpMap === void 0 ? void 0 : rtpMap.payload;
|
|
5252
5252
|
if (codecId) {
|
|
5253
|
-
|
|
5254
|
-
return fmtp;
|
|
5253
|
+
return section === null || section === void 0 ? void 0 : section.fmtp.find((f) => f.payload === codecId);
|
|
5255
5254
|
}
|
|
5256
5255
|
};
|
|
5257
5256
|
/**
|
|
@@ -5465,7 +5464,7 @@ const defaultTargetResolution = {
|
|
|
5465
5464
|
const findOptimalVideoLayers = (videoTrack, targetResolution = defaultTargetResolution) => {
|
|
5466
5465
|
const optimalVideoLayers = [];
|
|
5467
5466
|
const settings = videoTrack.getSettings();
|
|
5468
|
-
const { width: w =
|
|
5467
|
+
const { width: w = targetResolution.width, height: h = targetResolution.height, } = settings;
|
|
5469
5468
|
const maxBitrate = getComputedMaxBitrate(targetResolution, w, h);
|
|
5470
5469
|
let downscaleFactor = 1;
|
|
5471
5470
|
['f', 'h', 'q'].forEach((rid) => {
|
|
@@ -5733,14 +5732,13 @@ class Publisher {
|
|
|
5733
5732
|
};
|
|
5734
5733
|
this.updateVideoPublishQuality = (enabledRids) => __awaiter(this, void 0, void 0, function* () {
|
|
5735
5734
|
var _a;
|
|
5736
|
-
console.log('
|
|
5735
|
+
console.log('Update publish quality, requested rids by SFU:', enabledRids);
|
|
5737
5736
|
const videoSender = (_a = this.transceiverRegistry[TrackType.VIDEO]) === null || _a === void 0 ? void 0 : _a.sender;
|
|
5738
5737
|
if (!videoSender)
|
|
5739
5738
|
return;
|
|
5740
5739
|
const params = videoSender.getParameters();
|
|
5741
5740
|
let changed = false;
|
|
5742
5741
|
params.encodings.forEach((enc) => {
|
|
5743
|
-
console.log(enc.rid, enc.active);
|
|
5744
5742
|
// flip 'active' flag only when necessary
|
|
5745
5743
|
const shouldEnable = enabledRids.includes(enc.rid);
|
|
5746
5744
|
if (shouldEnable !== enc.active) {
|
|
@@ -5753,6 +5751,10 @@ class Publisher {
|
|
|
5753
5751
|
console.warn('No suitable video encoding quality found');
|
|
5754
5752
|
}
|
|
5755
5753
|
yield videoSender.setParameters(params);
|
|
5754
|
+
console.log(`Update publish quality, enabled rids: ${params.encodings
|
|
5755
|
+
.filter((e) => e.active)
|
|
5756
|
+
.map((e) => e.rid)
|
|
5757
|
+
.join(', ')}`);
|
|
5756
5758
|
}
|
|
5757
5759
|
});
|
|
5758
5760
|
this.getCodecPreferences = (trackType, preferredCodec) => {
|
|
@@ -5781,7 +5783,7 @@ class Publisher {
|
|
|
5781
5783
|
const offer = yield this.publisher.createOffer();
|
|
5782
5784
|
let sdp = offer.sdp;
|
|
5783
5785
|
if (sdp) {
|
|
5784
|
-
toggleDtx(sdp, this.isDtxEnabled);
|
|
5786
|
+
sdp = toggleDtx(sdp, this.isDtxEnabled);
|
|
5785
5787
|
if (isReactNative()) {
|
|
5786
5788
|
if (this.preferredVideoCodec) {
|
|
5787
5789
|
sdp = setPreferredCodec(sdp, 'video', this.preferredVideoCodec);
|
|
@@ -6128,8 +6130,9 @@ class StreamSfuClient {
|
|
|
6128
6130
|
* @param url the URL of the SFU.
|
|
6129
6131
|
* @param wsEndpoint the WebSocket endpoint of the SFU.
|
|
6130
6132
|
* @param token the JWT token to use for authentication.
|
|
6133
|
+
* @param sessionId the `sessionId` of the currently connected participant.
|
|
6131
6134
|
*/
|
|
6132
|
-
constructor(dispatcher, url, wsEndpoint, token) {
|
|
6135
|
+
constructor({ dispatcher, url, wsEndpoint, token, sessionId, }) {
|
|
6133
6136
|
/**
|
|
6134
6137
|
* A buffer for ICE Candidates that are received before
|
|
6135
6138
|
* the PeerConnections are ready to handle them.
|
|
@@ -6214,7 +6217,7 @@ class StreamSfuClient {
|
|
|
6214
6217
|
}
|
|
6215
6218
|
}, this.unhealthyTimeoutInMs);
|
|
6216
6219
|
};
|
|
6217
|
-
this.sessionId = generateUUIDv4();
|
|
6220
|
+
this.sessionId = sessionId || generateUUIDv4();
|
|
6218
6221
|
this.token = token;
|
|
6219
6222
|
this.rpc = createSignalClient({
|
|
6220
6223
|
baseUrl: url,
|
|
@@ -6615,6 +6618,12 @@ class CallState {
|
|
|
6615
6618
|
* @internal
|
|
6616
6619
|
*/
|
|
6617
6620
|
this.membersSubject = new BehaviorSubject([]);
|
|
6621
|
+
/**
|
|
6622
|
+
* The list of capabilities of the current user.
|
|
6623
|
+
*
|
|
6624
|
+
* @private
|
|
6625
|
+
*/
|
|
6626
|
+
this.ownCapabilitiesSubject = new BehaviorSubject([]);
|
|
6618
6627
|
/**
|
|
6619
6628
|
* The calling state.
|
|
6620
6629
|
*
|
|
@@ -6797,6 +6806,15 @@ class CallState {
|
|
|
6797
6806
|
this.setMembers = (members) => {
|
|
6798
6807
|
this.setCurrentValue(this.membersSubject, members);
|
|
6799
6808
|
};
|
|
6809
|
+
/**
|
|
6810
|
+
* Sets the own capabilities.
|
|
6811
|
+
*
|
|
6812
|
+
* @internal
|
|
6813
|
+
* @param capabilities the capabilities to set.
|
|
6814
|
+
*/
|
|
6815
|
+
this.setOwnCapabilities = (capabilities) => {
|
|
6816
|
+
return this.setCurrentValue(this.ownCapabilitiesSubject, capabilities);
|
|
6817
|
+
};
|
|
6800
6818
|
/**
|
|
6801
6819
|
* Will try to find the participant with the given sessionId in the current call.
|
|
6802
6820
|
*
|
|
@@ -6886,6 +6904,7 @@ class CallState {
|
|
|
6886
6904
|
this.callRecordingList$ = this.callRecordingListSubject.asObservable();
|
|
6887
6905
|
this.metadata$ = this.metadataSubject.asObservable();
|
|
6888
6906
|
this.members$ = this.membersSubject.asObservable();
|
|
6907
|
+
this.ownCapabilities$ = this.ownCapabilitiesSubject.asObservable();
|
|
6889
6908
|
this.callingState$ = this.callingStateSubject.asObservable();
|
|
6890
6909
|
}
|
|
6891
6910
|
/**
|
|
@@ -6981,6 +7000,12 @@ class CallState {
|
|
|
6981
7000
|
get members() {
|
|
6982
7001
|
return this.getCurrentValue(this.members$);
|
|
6983
7002
|
}
|
|
7003
|
+
/**
|
|
7004
|
+
* The capabilities of the current user for the current call.
|
|
7005
|
+
*/
|
|
7006
|
+
get ownCapabilities() {
|
|
7007
|
+
return this.getCurrentValue(this.ownCapabilities$);
|
|
7008
|
+
}
|
|
6984
7009
|
}
|
|
6985
7010
|
|
|
6986
7011
|
class StreamVideoWriteableStateStore {
|
|
@@ -7245,7 +7270,10 @@ const watchCallPermissionRequest = (state) => {
|
|
|
7245
7270
|
return function onCallPermissionRequest(event) {
|
|
7246
7271
|
if (event.type !== 'call.permission_request')
|
|
7247
7272
|
return;
|
|
7248
|
-
state
|
|
7273
|
+
const { localParticipant } = state;
|
|
7274
|
+
if (event.user.id !== (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.userId)) {
|
|
7275
|
+
state.setCallPermissionRequest(event);
|
|
7276
|
+
}
|
|
7249
7277
|
};
|
|
7250
7278
|
};
|
|
7251
7279
|
/**
|
|
@@ -7257,7 +7285,7 @@ const watchCallPermissionsUpdated = (state) => {
|
|
|
7257
7285
|
return;
|
|
7258
7286
|
const { localParticipant } = state;
|
|
7259
7287
|
if (event.user.id === (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.userId)) {
|
|
7260
|
-
state.
|
|
7288
|
+
state.setOwnCapabilities(event.own_capabilities);
|
|
7261
7289
|
}
|
|
7262
7290
|
};
|
|
7263
7291
|
};
|
|
@@ -7268,7 +7296,6 @@ const watchCallPermissionsUpdated = (state) => {
|
|
|
7268
7296
|
*/
|
|
7269
7297
|
const watchCallGrantsUpdated = (state) => {
|
|
7270
7298
|
return function onCallGrantsUpdated(event) {
|
|
7271
|
-
var _a;
|
|
7272
7299
|
if (event.eventPayload.oneofKind !== 'callGrantsUpdated')
|
|
7273
7300
|
return;
|
|
7274
7301
|
const { currentGrants } = event.eventPayload.callGrantsUpdated;
|
|
@@ -7279,15 +7306,13 @@ const watchCallGrantsUpdated = (state) => {
|
|
|
7279
7306
|
[OwnCapability.SEND_VIDEO]: canPublishVideo,
|
|
7280
7307
|
[OwnCapability.SCREENSHARE]: canScreenshare,
|
|
7281
7308
|
};
|
|
7282
|
-
const nextCapabilities =
|
|
7309
|
+
const nextCapabilities = state.ownCapabilities.filter((capability) => update[capability] !== false);
|
|
7283
7310
|
Object.entries(update).forEach(([capability, value]) => {
|
|
7284
7311
|
if (value && !nextCapabilities.includes(capability)) {
|
|
7285
7312
|
nextCapabilities.push(capability);
|
|
7286
7313
|
}
|
|
7287
7314
|
});
|
|
7288
|
-
state.
|
|
7289
|
-
return Object.assign(Object.assign({}, metadata), { own_capabilities: nextCapabilities });
|
|
7290
|
-
});
|
|
7315
|
+
state.setOwnCapabilities(nextCapabilities);
|
|
7291
7316
|
}
|
|
7292
7317
|
};
|
|
7293
7318
|
};
|
|
@@ -7580,10 +7605,7 @@ const watchCallSessionStarted = (state) => {
|
|
|
7580
7605
|
return function onCallSessionStarted(event) {
|
|
7581
7606
|
if (event.type !== 'call.session_started')
|
|
7582
7607
|
return;
|
|
7583
|
-
|
|
7584
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, call), {
|
|
7585
|
-
// FIXME OL: temporary, until the backend sends the own_capabilities
|
|
7586
|
-
own_capabilities: (metadata === null || metadata === void 0 ? void 0 : metadata.own_capabilities) || [] })));
|
|
7608
|
+
state.setMetadata(event.call);
|
|
7587
7609
|
};
|
|
7588
7610
|
};
|
|
7589
7611
|
/**
|
|
@@ -7595,10 +7617,7 @@ const watchCallSessionEnded = (state) => {
|
|
|
7595
7617
|
return function onCallSessionEnded(event) {
|
|
7596
7618
|
if (event.type !== 'call.session_ended')
|
|
7597
7619
|
return;
|
|
7598
|
-
|
|
7599
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, call), {
|
|
7600
|
-
// FIXME OL: temporary, until the backend sends the own_capabilities
|
|
7601
|
-
own_capabilities: (metadata === null || metadata === void 0 ? void 0 : metadata.own_capabilities) || [] })));
|
|
7620
|
+
state.setMetadata(event.call);
|
|
7602
7621
|
};
|
|
7603
7622
|
};
|
|
7604
7623
|
/**
|
|
@@ -7760,13 +7779,14 @@ const registerRingingCallEventHandlers = (call) => {
|
|
|
7760
7779
|
const join = (httpClient, type, id, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7761
7780
|
yield httpClient.connectionIdPromise;
|
|
7762
7781
|
const joinCallResponse = yield doJoin(httpClient, type, id, data);
|
|
7763
|
-
const { call, credentials, members } = joinCallResponse;
|
|
7782
|
+
const { call, credentials, members, own_capabilities } = joinCallResponse;
|
|
7764
7783
|
return {
|
|
7765
7784
|
connectionConfig: toRtcConfiguration(credentials.ice_servers),
|
|
7766
7785
|
sfuServer: credentials.server,
|
|
7767
7786
|
token: credentials.token,
|
|
7768
7787
|
metadata: call,
|
|
7769
7788
|
members,
|
|
7789
|
+
ownCapabilities: own_capabilities,
|
|
7770
7790
|
};
|
|
7771
7791
|
});
|
|
7772
7792
|
const doJoin = (httpClient, type, id, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -7783,9 +7803,12 @@ const doJoin = (httpClient, type, id, data) => __awaiter(void 0, void 0, void 0,
|
|
|
7783
7803
|
});
|
|
7784
7804
|
const getLocationHint = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
7785
7805
|
const hintURL = `https://hint.stream-io-video.com/`;
|
|
7806
|
+
const abortController = new AbortController();
|
|
7807
|
+
const timeoutId = setTimeout(() => abortController.abort(), 1000);
|
|
7786
7808
|
try {
|
|
7787
7809
|
const response = yield fetch(hintURL, {
|
|
7788
7810
|
method: 'HEAD',
|
|
7811
|
+
signal: abortController.signal,
|
|
7789
7812
|
});
|
|
7790
7813
|
const awsPop = response.headers.get('x-amz-cf-pop') || 'ERR';
|
|
7791
7814
|
return awsPop.substring(0, 3); // AMS1-P2 -> AMS
|
|
@@ -7794,6 +7817,9 @@ const getLocationHint = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
7794
7817
|
console.error(`Failed to get location hint from ${hintURL}`, e);
|
|
7795
7818
|
return 'ERR';
|
|
7796
7819
|
}
|
|
7820
|
+
finally {
|
|
7821
|
+
clearTimeout(timeoutId);
|
|
7822
|
+
}
|
|
7797
7823
|
});
|
|
7798
7824
|
const toRtcConfiguration = (config) => {
|
|
7799
7825
|
if (!config || config.length === 0)
|
|
@@ -8296,7 +8322,7 @@ class Call {
|
|
|
8296
8322
|
* Use the [`StreamVideoClient.call`](./StreamVideoClient.md/#call)
|
|
8297
8323
|
* method to construct a `Call` instance.
|
|
8298
8324
|
*/
|
|
8299
|
-
constructor({ type, id, streamClient, metadata, members, sortParticipantsBy, clientStore, ringing = false, watching = false, }) {
|
|
8325
|
+
constructor({ type, id, streamClient, metadata, members, ownCapabilities, sortParticipantsBy, clientStore, ringing = false, watching = false, }) {
|
|
8300
8326
|
/**
|
|
8301
8327
|
* ViewportTracker instance
|
|
8302
8328
|
*/
|
|
@@ -8388,6 +8414,7 @@ class Call {
|
|
|
8388
8414
|
}
|
|
8389
8415
|
this.state.setMetadata(response.call);
|
|
8390
8416
|
this.state.setMembers(response.members);
|
|
8417
|
+
this.state.setOwnCapabilities(response.own_capabilities);
|
|
8391
8418
|
if (this.streamClient._hasConnectionID()) {
|
|
8392
8419
|
this.watching = true;
|
|
8393
8420
|
this.clientStore.registerCall(this);
|
|
@@ -8406,6 +8433,7 @@ class Call {
|
|
|
8406
8433
|
}
|
|
8407
8434
|
this.state.setMetadata(response.call);
|
|
8408
8435
|
this.state.setMembers(response.members);
|
|
8436
|
+
this.state.setOwnCapabilities(response.own_capabilities);
|
|
8409
8437
|
if (this.streamClient._hasConnectionID()) {
|
|
8410
8438
|
this.watching = true;
|
|
8411
8439
|
this.clientStore.registerCall(this);
|
|
@@ -8452,7 +8480,7 @@ class Call {
|
|
|
8452
8480
|
* @returns a promise which resolves once the call join-flow has finished.
|
|
8453
8481
|
*/
|
|
8454
8482
|
this.join = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
8455
|
-
var _e;
|
|
8483
|
+
var _e, _f;
|
|
8456
8484
|
if ([CallingState.JOINED, CallingState.JOINING].includes(this.state.callingState)) {
|
|
8457
8485
|
throw new Error(`Illegal State: Already joined.`);
|
|
8458
8486
|
}
|
|
@@ -8472,6 +8500,7 @@ class Call {
|
|
|
8472
8500
|
const call = yield join(this.streamClient, this.type, this.id, data);
|
|
8473
8501
|
this.state.setMetadata(call.metadata);
|
|
8474
8502
|
this.state.setMembers(call.members);
|
|
8503
|
+
this.state.setOwnCapabilities(call.ownCapabilities);
|
|
8475
8504
|
connectionConfig = call.connectionConfig;
|
|
8476
8505
|
sfuServer = call.sfuServer;
|
|
8477
8506
|
sfuToken = call.token;
|
|
@@ -8497,21 +8526,28 @@ class Call {
|
|
|
8497
8526
|
const sfuWsUrlParam = params.get('sfuWsUrl');
|
|
8498
8527
|
sfuWsUrl = sfuWsUrlParam || sfuServer.ws_endpoint;
|
|
8499
8528
|
}
|
|
8500
|
-
const
|
|
8529
|
+
const previousSessionId = (_e = this.sfuClient) === null || _e === void 0 ? void 0 : _e.sessionId;
|
|
8530
|
+
const sfuClient = (this.sfuClient = new StreamSfuClient({
|
|
8531
|
+
dispatcher: this.dispatcher,
|
|
8532
|
+
url: sfuUrl,
|
|
8533
|
+
wsEndpoint: sfuWsUrl,
|
|
8534
|
+
token: sfuToken,
|
|
8535
|
+
sessionId: previousSessionId,
|
|
8536
|
+
}));
|
|
8501
8537
|
/**
|
|
8502
8538
|
* A closure which hides away the re-connection logic.
|
|
8503
8539
|
*/
|
|
8504
8540
|
const rejoin = () => __awaiter(this, void 0, void 0, function* () {
|
|
8505
|
-
var
|
|
8541
|
+
var _g, _h, _j;
|
|
8506
8542
|
console.log(`Rejoining call ${this.cid} (${this.reconnectAttempts})...`);
|
|
8507
8543
|
this.reconnectAttempts++;
|
|
8508
8544
|
this.state.setCallingState(CallingState.RECONNECTING);
|
|
8509
8545
|
// take a snapshot of the current "local participant" state
|
|
8510
8546
|
// we'll need it for restoring the previous publishing state later
|
|
8511
8547
|
const localParticipant = this.state.localParticipant;
|
|
8512
|
-
(
|
|
8513
|
-
(
|
|
8514
|
-
(
|
|
8548
|
+
(_g = this.subscriber) === null || _g === void 0 ? void 0 : _g.close();
|
|
8549
|
+
(_h = this.publisher) === null || _h === void 0 ? void 0 : _h.stopPublishing({ stopTracks: false });
|
|
8550
|
+
(_j = this.statsReporter) === null || _j === void 0 ? void 0 : _j.stop();
|
|
8515
8551
|
sfuClient.close(); // clean up previous connection
|
|
8516
8552
|
yield sleep(retryInterval(this.reconnectAttempts));
|
|
8517
8553
|
yield this.join(data);
|
|
@@ -8581,7 +8617,7 @@ class Call {
|
|
|
8581
8617
|
connectionConfig,
|
|
8582
8618
|
onTrack: this.handleOnTrack,
|
|
8583
8619
|
});
|
|
8584
|
-
const audioSettings = (
|
|
8620
|
+
const audioSettings = (_f = this.data) === null || _f === void 0 ? void 0 : _f.settings.audio;
|
|
8585
8621
|
const isDtxEnabled = !!(audioSettings === null || audioSettings === void 0 ? void 0 : audioSettings.opus_dtx_enabled);
|
|
8586
8622
|
const isRedEnabled = !!(audioSettings === null || audioSettings === void 0 ? void 0 : audioSettings.redundant_coding_enabled);
|
|
8587
8623
|
this.publisher = new Publisher({
|
|
@@ -8739,9 +8775,9 @@ class Call {
|
|
|
8739
8775
|
* @param trackType the track type to stop publishing.
|
|
8740
8776
|
*/
|
|
8741
8777
|
this.stopPublish = (trackType) => __awaiter(this, void 0, void 0, function* () {
|
|
8742
|
-
var
|
|
8778
|
+
var _k;
|
|
8743
8779
|
console.log(`stopPublish`, TrackType[trackType]);
|
|
8744
|
-
yield ((
|
|
8780
|
+
yield ((_k = this.publisher) === null || _k === void 0 ? void 0 : _k.unpublishStream(trackType));
|
|
8745
8781
|
});
|
|
8746
8782
|
/**
|
|
8747
8783
|
* Update track subscription configuration for one or more participants.
|
|
@@ -8882,8 +8918,8 @@ class Call {
|
|
|
8882
8918
|
* @returns
|
|
8883
8919
|
*/
|
|
8884
8920
|
this.updatePublishQuality = (enabledRids) => __awaiter(this, void 0, void 0, function* () {
|
|
8885
|
-
var
|
|
8886
|
-
return (
|
|
8921
|
+
var _l;
|
|
8922
|
+
return (_l = this.publisher) === null || _l === void 0 ? void 0 : _l.updateVideoPublishQuality(enabledRids);
|
|
8887
8923
|
});
|
|
8888
8924
|
this.handleOnTrack = (e) => {
|
|
8889
8925
|
const [primaryStream] = e.streams;
|
|
@@ -9113,7 +9149,12 @@ class Call {
|
|
|
9113
9149
|
* @param updates the updates to apply to the call.
|
|
9114
9150
|
*/
|
|
9115
9151
|
this.update = (updates) => __awaiter(this, void 0, void 0, function* () {
|
|
9116
|
-
|
|
9152
|
+
const response = yield this.streamClient.patch(`${this.streamClientBasePath}`, updates);
|
|
9153
|
+
const { call, members, own_capabilities } = response;
|
|
9154
|
+
this.state.setMetadata(call);
|
|
9155
|
+
this.state.setMembers(members);
|
|
9156
|
+
this.state.setOwnCapabilities(own_capabilities);
|
|
9157
|
+
return response;
|
|
9117
9158
|
});
|
|
9118
9159
|
/**
|
|
9119
9160
|
* Ends the call. Once the call is ended, it cannot be re-joined.
|
|
@@ -9194,15 +9235,6 @@ class Call {
|
|
|
9194
9235
|
this.state.setCallRecordingsList(response.recordings);
|
|
9195
9236
|
return response;
|
|
9196
9237
|
});
|
|
9197
|
-
/**
|
|
9198
|
-
* Returns a list of Edge Serves for current call.
|
|
9199
|
-
*
|
|
9200
|
-
* @deprecated merged with `call.join`.
|
|
9201
|
-
* @param data the data.
|
|
9202
|
-
*/
|
|
9203
|
-
this.getEdgeServer = (data) => {
|
|
9204
|
-
return this.streamClient.post(`${this.streamClientBasePath}/get_edge_server`, data);
|
|
9205
|
-
};
|
|
9206
9238
|
/**
|
|
9207
9239
|
* Sends an event to all call participants.
|
|
9208
9240
|
*
|
|
@@ -9226,6 +9258,7 @@ class Call {
|
|
|
9226
9258
|
}
|
|
9227
9259
|
this.state.setMetadata(metadata);
|
|
9228
9260
|
this.state.setMembers(members || []);
|
|
9261
|
+
this.state.setOwnCapabilities(ownCapabilities || []);
|
|
9229
9262
|
this.state.setCallingState(ringing ? CallingState.RINGING : CallingState.IDLE);
|
|
9230
9263
|
this.leaveCallHooks.push(registerEventHandlers(this, this.state, this.dispatcher));
|
|
9231
9264
|
this.registerEffects();
|
|
@@ -9237,23 +9270,13 @@ class Call {
|
|
|
9237
9270
|
createSubscription(this.state.metadata$, (metadata) => {
|
|
9238
9271
|
if (!metadata)
|
|
9239
9272
|
return;
|
|
9240
|
-
this.permissionsContext.setPermissions(metadata.own_capabilities);
|
|
9241
9273
|
this.permissionsContext.setCallSettings(metadata.settings);
|
|
9242
9274
|
}),
|
|
9243
|
-
//
|
|
9244
|
-
createSubscription(this.state.
|
|
9245
|
-
|
|
9246
|
-
|
|
9247
|
-
|
|
9248
|
-
if (currentUserId &&
|
|
9249
|
-
metadata.blocked_user_ids.includes(currentUserId)) {
|
|
9250
|
-
yield this.leave();
|
|
9251
|
-
}
|
|
9252
|
-
})),
|
|
9253
|
-
// handle the case when the user permissions are revoked.
|
|
9254
|
-
createSubscription(this.state.metadata$, (metadata) => {
|
|
9255
|
-
if (!metadata)
|
|
9256
|
-
return;
|
|
9275
|
+
// handle the case when the user permissions are modified.
|
|
9276
|
+
createSubscription(this.state.ownCapabilities$, (ownCapabilities) => {
|
|
9277
|
+
// update the permission context.
|
|
9278
|
+
this.permissionsContext.setPermissions(ownCapabilities);
|
|
9279
|
+
// check if the user still has publishing permissions and stop publishing if not.
|
|
9257
9280
|
const permissionToTrackType = {
|
|
9258
9281
|
[OwnCapability.SEND_AUDIO]: TrackType.AUDIO,
|
|
9259
9282
|
[OwnCapability.SEND_VIDEO]: TrackType.VIDEO,
|
|
@@ -9268,6 +9291,16 @@ class Call {
|
|
|
9268
9291
|
}
|
|
9269
9292
|
});
|
|
9270
9293
|
}),
|
|
9294
|
+
// handles the case when the user is blocked by the call owner.
|
|
9295
|
+
createSubscription(this.state.metadata$, (metadata) => __awaiter(this, void 0, void 0, function* () {
|
|
9296
|
+
if (!metadata)
|
|
9297
|
+
return;
|
|
9298
|
+
const currentUserId = this.currentUserId;
|
|
9299
|
+
if (currentUserId &&
|
|
9300
|
+
metadata.blocked_user_ids.includes(currentUserId)) {
|
|
9301
|
+
yield this.leave();
|
|
9302
|
+
}
|
|
9303
|
+
})),
|
|
9271
9304
|
// watch for auto drop cancellation
|
|
9272
9305
|
createSubscription(this.state.callingState$, (callingState) => {
|
|
9273
9306
|
if (!this.ringing)
|
|
@@ -10957,7 +10990,7 @@ class StreamClient {
|
|
|
10957
10990
|
}
|
|
10958
10991
|
getUserAgent() {
|
|
10959
10992
|
return (this.userAgent ||
|
|
10960
|
-
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.
|
|
10993
|
+
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.3"}`);
|
|
10961
10994
|
}
|
|
10962
10995
|
setUserAgent(userAgent) {
|
|
10963
10996
|
this.userAgent = userAgent;
|
|
@@ -11165,6 +11198,7 @@ class StreamVideoClient {
|
|
|
11165
11198
|
type: c.call.type,
|
|
11166
11199
|
metadata: c.call,
|
|
11167
11200
|
members: c.members,
|
|
11201
|
+
ownCapabilities: c.own_capabilities,
|
|
11168
11202
|
watching: data.watch,
|
|
11169
11203
|
clientStore: this.writeableStateStore,
|
|
11170
11204
|
});
|
|
@@ -11514,7 +11548,7 @@ const createSoundDetector = (audioStream, onSoundDetectedStateChanged, options =
|
|
|
11514
11548
|
const percentage = averagedDataValue > audioLevelThreshold
|
|
11515
11549
|
? 100
|
|
11516
11550
|
: Math.round((averagedDataValue / audioLevelThreshold) * 100);
|
|
11517
|
-
onSoundDetectedStateChanged(isSoundDetected, percentage);
|
|
11551
|
+
onSoundDetectedStateChanged({ isSoundDetected, audioLevel: percentage });
|
|
11518
11552
|
}, detectionFrequencyInMs);
|
|
11519
11553
|
return function stop() {
|
|
11520
11554
|
return __awaiter(this, void 0, void 0, function* () {
|