@stream-io/video-client 0.2.2 → 0.3.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/CHANGELOG.md +18 -0
- package/dist/index.browser.es.js +325 -421
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +325 -421
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +325 -421
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +8 -10
- package/dist/src/StreamVideoClient.d.ts +3 -1
- package/dist/src/events/call-permissions.d.ts +0 -5
- package/dist/src/events/call.d.ts +0 -6
- package/dist/src/events/index.d.ts +0 -6
- package/dist/src/gen/coordinator/index.d.ts +25 -0
- package/dist/src/rtc/Dispatcher.d.ts +2 -2
- package/dist/src/rtc/Publisher.d.ts +0 -1
- package/dist/src/store/CallState.d.ts +164 -89
- package/dist/src/types.d.ts +1 -7
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/Call.ts +37 -44
- package/src/StreamVideoClient.ts +14 -17
- package/src/events/__tests__/call-permissions.test.ts +1 -61
- package/src/events/__tests__/call.test.ts +5 -50
- package/src/events/call-permissions.ts +0 -14
- package/src/events/call.ts +5 -16
- package/src/events/callEventHandlers.ts +2 -57
- package/src/events/index.ts +0 -6
- package/src/gen/coordinator/index.ts +25 -0
- package/src/rtc/Dispatcher.ts +2 -2
- package/src/rtc/Publisher.ts +4 -6
- package/src/store/CallState.ts +475 -119
- package/src/store/__tests__/CallState.test.ts +447 -1
- package/src/types.ts +0 -8
- package/dist/src/events/__tests__/backstage.test.d.ts +0 -1
- package/dist/src/events/__tests__/members.test.d.ts +0 -1
- package/dist/src/events/__tests__/recording.test.d.ts +0 -1
- package/dist/src/events/__tests__/sessions.test.d.ts +0 -1
- package/dist/src/events/backstage.d.ts +0 -6
- package/dist/src/events/members.d.ts +0 -18
- package/dist/src/events/moderation.d.ts +0 -14
- package/dist/src/events/reactions.d.ts +0 -8
- package/dist/src/events/recording.d.ts +0 -18
- package/dist/src/events/sessions.d.ts +0 -26
- package/src/events/__tests__/backstage.test.ts +0 -15
- package/src/events/__tests__/members.test.ts +0 -135
- package/src/events/__tests__/recording.test.ts +0 -65
- package/src/events/__tests__/sessions.test.ts +0 -135
- package/src/events/backstage.ts +0 -15
- package/src/events/members.ts +0 -62
- package/src/events/moderation.ts +0 -35
- package/src/events/reactions.ts +0 -30
- package/src/events/recording.ts +0 -64
- package/src/events/sessions.ts +0 -102
package/dist/index.browser.es.js
CHANGED
|
@@ -6520,8 +6520,8 @@ class Publisher {
|
|
|
6520
6520
|
track.removeEventListener('ended', handleTrackEnded);
|
|
6521
6521
|
});
|
|
6522
6522
|
if (!transceiver) {
|
|
6523
|
-
const
|
|
6524
|
-
const targetResolution =
|
|
6523
|
+
const { settings } = this.state;
|
|
6524
|
+
const targetResolution = settings === null || settings === void 0 ? void 0 : settings.video.target_resolution;
|
|
6525
6525
|
const videoEncodings = trackType === TrackType.VIDEO
|
|
6526
6526
|
? findOptimalVideoLayers(track, targetResolution)
|
|
6527
6527
|
: undefined;
|
|
@@ -6799,8 +6799,8 @@ class Publisher {
|
|
|
6799
6799
|
}
|
|
6800
6800
|
return String(media.mid);
|
|
6801
6801
|
};
|
|
6802
|
-
const
|
|
6803
|
-
const targetResolution =
|
|
6802
|
+
const { settings } = this.state;
|
|
6803
|
+
const targetResolution = settings === null || settings === void 0 ? void 0 : settings.video.target_resolution;
|
|
6804
6804
|
return this.pc
|
|
6805
6805
|
.getTransceivers()
|
|
6806
6806
|
.filter((t) => t.direction === 'sendonly' && t.sender.track)
|
|
@@ -6893,7 +6893,6 @@ class Publisher {
|
|
|
6893
6893
|
this.pc = this.createPeerConnection(connectionConfig);
|
|
6894
6894
|
this.sfuClient = sfuClient;
|
|
6895
6895
|
this.state = state;
|
|
6896
|
-
this.dispatcher = dispatcher;
|
|
6897
6896
|
this.isDtxEnabled = isDtxEnabled;
|
|
6898
6897
|
this.isRedEnabled = isRedEnabled;
|
|
6899
6898
|
this.preferredVideoCodec = preferredVideoCodec;
|
|
@@ -7521,17 +7520,6 @@ const retryable = (rpc, logger) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
7521
7520
|
return rpcCallResult;
|
|
7522
7521
|
});
|
|
7523
7522
|
|
|
7524
|
-
/**
|
|
7525
|
-
* Watches for `call.live_started` events.
|
|
7526
|
-
*/
|
|
7527
|
-
const watchCallLiveStarted = (state) => {
|
|
7528
|
-
return function onCallLiveStarted(event) {
|
|
7529
|
-
if (event.type !== 'call.live_started')
|
|
7530
|
-
return;
|
|
7531
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { backstage: false })));
|
|
7532
|
-
};
|
|
7533
|
-
};
|
|
7534
|
-
|
|
7535
7523
|
/**
|
|
7536
7524
|
* Gets the current value of an observable, or undefined if the observable has
|
|
7537
7525
|
* not emitted a value yet.
|
|
@@ -7974,71 +7962,29 @@ class CallState {
|
|
|
7974
7962
|
*
|
|
7975
7963
|
*/
|
|
7976
7964
|
constructor() {
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
this.
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7965
|
+
this.backstageSubject = new BehaviorSubject(false);
|
|
7966
|
+
this.blockedUserIdsSubject = new BehaviorSubject([]);
|
|
7967
|
+
this.createdAtSubject = new BehaviorSubject(new Date());
|
|
7968
|
+
this.endedAtSubject = new BehaviorSubject(undefined);
|
|
7969
|
+
this.startsAtSubject = new BehaviorSubject(undefined);
|
|
7970
|
+
this.updatedAtSubject = new BehaviorSubject(new Date());
|
|
7971
|
+
this.createdBySubject = new BehaviorSubject(undefined);
|
|
7972
|
+
this.customSubject = new BehaviorSubject({});
|
|
7973
|
+
this.egressSubject = new BehaviorSubject(undefined);
|
|
7974
|
+
this.ingressSubject = new BehaviorSubject(undefined);
|
|
7975
|
+
this.recordingSubject = new BehaviorSubject(false);
|
|
7976
|
+
this.sessionSubject = new BehaviorSubject(undefined);
|
|
7977
|
+
this.settingsSubject = new BehaviorSubject(undefined);
|
|
7978
|
+
this.transcribingSubject = new BehaviorSubject(false);
|
|
7979
|
+
this.endedBySubject = new BehaviorSubject(undefined);
|
|
7988
7980
|
this.membersSubject = new BehaviorSubject([]);
|
|
7989
|
-
/**
|
|
7990
|
-
* The list of capabilities of the current user.
|
|
7991
|
-
*
|
|
7992
|
-
* @private
|
|
7993
|
-
*/
|
|
7994
7981
|
this.ownCapabilitiesSubject = new BehaviorSubject([]);
|
|
7995
|
-
/**
|
|
7996
|
-
* The calling state.
|
|
7997
|
-
*
|
|
7998
|
-
* @internal
|
|
7999
|
-
*/
|
|
8000
7982
|
this.callingStateSubject = new BehaviorSubject(CallingState.UNKNOWN);
|
|
8001
|
-
/**
|
|
8002
|
-
* The time the call session actually started.
|
|
8003
|
-
*
|
|
8004
|
-
* @internal
|
|
8005
|
-
*/
|
|
8006
7983
|
this.startedAtSubject = new BehaviorSubject(undefined);
|
|
8007
|
-
/**
|
|
8008
|
-
* The server-side counted number of participants connected to the current call.
|
|
8009
|
-
* This number includes the anonymous participants as well.
|
|
8010
|
-
*
|
|
8011
|
-
* @internal
|
|
8012
|
-
*/
|
|
8013
7984
|
this.participantCountSubject = new BehaviorSubject(0);
|
|
8014
|
-
/**
|
|
8015
|
-
* The server-side counted number of anonymous participants connected to the current call.
|
|
8016
|
-
* This number excludes the regular participants.
|
|
8017
|
-
*
|
|
8018
|
-
* @internal
|
|
8019
|
-
*/
|
|
8020
7985
|
this.anonymousParticipantCountSubject = new BehaviorSubject(0);
|
|
8021
|
-
/**
|
|
8022
|
-
* All participants of the current call (including the logged-in user).
|
|
8023
|
-
*
|
|
8024
|
-
* @internal
|
|
8025
|
-
*/
|
|
8026
7986
|
this.participantsSubject = new BehaviorSubject([]);
|
|
8027
|
-
/**
|
|
8028
|
-
* The latest stats report of the current call.
|
|
8029
|
-
* When stats gathering is enabled, this observable will emit a new value
|
|
8030
|
-
* at a regular (configurable) interval.
|
|
8031
|
-
*
|
|
8032
|
-
* Consumers of this observable can implement their own batching logic
|
|
8033
|
-
* in case they want to show historical stat data.
|
|
8034
|
-
*
|
|
8035
|
-
* @internal
|
|
8036
|
-
*/
|
|
8037
7987
|
this.callStatsReportSubject = new BehaviorSubject(undefined);
|
|
8038
|
-
/**
|
|
8039
|
-
* Emits a list of details about recordings performed for the current call.
|
|
8040
|
-
*/
|
|
8041
|
-
this.callRecordingListSubject = new BehaviorSubject([]);
|
|
8042
7988
|
/**
|
|
8043
7989
|
* A list of comparators that are used to sort the participants.
|
|
8044
7990
|
*
|
|
@@ -8121,15 +8067,6 @@ class CallState {
|
|
|
8121
8067
|
this.setCallingState = (state) => {
|
|
8122
8068
|
return this.setCurrentValue(this.callingStateSubject, state);
|
|
8123
8069
|
};
|
|
8124
|
-
/**
|
|
8125
|
-
* Sets the list of call recordings.
|
|
8126
|
-
*
|
|
8127
|
-
* @internal
|
|
8128
|
-
* @param recordings the list of call recordings.
|
|
8129
|
-
*/
|
|
8130
|
-
this.setCallRecordingsList = (recordings) => {
|
|
8131
|
-
return this.setCurrentValue(this.callRecordingListSubject, recordings);
|
|
8132
|
-
};
|
|
8133
8070
|
/**
|
|
8134
8071
|
* Sets the call stats report.
|
|
8135
8072
|
*
|
|
@@ -8139,16 +8076,6 @@ class CallState {
|
|
|
8139
8076
|
this.setCallStatsReport = (report) => {
|
|
8140
8077
|
return this.setCurrentValue(this.callStatsReportSubject, report);
|
|
8141
8078
|
};
|
|
8142
|
-
/**
|
|
8143
|
-
* Sets the metadata of the current call.
|
|
8144
|
-
*
|
|
8145
|
-
* @internal
|
|
8146
|
-
*
|
|
8147
|
-
* @param metadata the metadata to set.
|
|
8148
|
-
*/
|
|
8149
|
-
this.setMetadata = (metadata) => {
|
|
8150
|
-
return this.setCurrentValue(this.metadataSubject, metadata);
|
|
8151
|
-
};
|
|
8152
8079
|
/**
|
|
8153
8080
|
* Sets the members of the current call.
|
|
8154
8081
|
*
|
|
@@ -8247,6 +8174,19 @@ class CallState {
|
|
|
8247
8174
|
return p;
|
|
8248
8175
|
}));
|
|
8249
8176
|
};
|
|
8177
|
+
/**
|
|
8178
|
+
* Updates the call state with the data received from the server.
|
|
8179
|
+
*
|
|
8180
|
+
* @internal
|
|
8181
|
+
*
|
|
8182
|
+
* @param event the video event that our backend sent us.
|
|
8183
|
+
*/
|
|
8184
|
+
this.updateFromEvent = (event) => {
|
|
8185
|
+
const update = this.eventHandlers[event.type];
|
|
8186
|
+
if (update) {
|
|
8187
|
+
update(event);
|
|
8188
|
+
}
|
|
8189
|
+
};
|
|
8250
8190
|
/**
|
|
8251
8191
|
* Updates the participant pinned state with server side pinning data.
|
|
8252
8192
|
*
|
|
@@ -8275,25 +8215,174 @@ class CallState {
|
|
|
8275
8215
|
return participant;
|
|
8276
8216
|
}));
|
|
8277
8217
|
};
|
|
8278
|
-
|
|
8218
|
+
/**
|
|
8219
|
+
* Updates the call state with the data received from the server.
|
|
8220
|
+
*
|
|
8221
|
+
* @internal
|
|
8222
|
+
*
|
|
8223
|
+
* @param call the call response from the server.
|
|
8224
|
+
*/
|
|
8225
|
+
this.updateFromCallResponse = (call) => {
|
|
8226
|
+
this.setCurrentValue(this.backstageSubject, call.backstage);
|
|
8227
|
+
this.setCurrentValue(this.blockedUserIdsSubject, call.blocked_user_ids);
|
|
8228
|
+
this.setCurrentValue(this.createdAtSubject, new Date(call.created_at));
|
|
8229
|
+
this.setCurrentValue(this.updatedAtSubject, new Date(call.updated_at));
|
|
8230
|
+
this.setCurrentValue(this.startsAtSubject, call.starts_at ? new Date(call.starts_at) : undefined);
|
|
8231
|
+
this.setCurrentValue(this.endedAtSubject, call.ended_at ? new Date(call.ended_at) : undefined);
|
|
8232
|
+
this.setCurrentValue(this.createdBySubject, call.created_by);
|
|
8233
|
+
this.setCurrentValue(this.customSubject, call.custom);
|
|
8234
|
+
this.setCurrentValue(this.egressSubject, call.egress);
|
|
8235
|
+
this.setCurrentValue(this.ingressSubject, call.ingress);
|
|
8236
|
+
this.setCurrentValue(this.recordingSubject, call.recording);
|
|
8237
|
+
this.setCurrentValue(this.sessionSubject, call.session);
|
|
8238
|
+
this.setCurrentValue(this.settingsSubject, call.settings);
|
|
8239
|
+
this.setCurrentValue(this.transcribingSubject, call.transcribing);
|
|
8240
|
+
};
|
|
8241
|
+
this.updateFromMemberRemoved = (event) => {
|
|
8242
|
+
this.setCurrentValue(this.membersSubject, (members) => members.filter((m) => event.members.indexOf(m.user_id) === -1));
|
|
8243
|
+
};
|
|
8244
|
+
this.updateFromMemberAdded = (event) => {
|
|
8245
|
+
this.setCurrentValue(this.membersSubject, (members) => [
|
|
8246
|
+
...members,
|
|
8247
|
+
...event.members,
|
|
8248
|
+
]);
|
|
8249
|
+
};
|
|
8250
|
+
this.updateFromBroadcastStopped = () => {
|
|
8251
|
+
this.setCurrentValue(this.egressSubject, (egress) => (Object.assign(Object.assign({}, egress), { broadcasting: false })));
|
|
8252
|
+
};
|
|
8253
|
+
this.updateFromBroadcastStarted = (event) => {
|
|
8254
|
+
this.setCurrentValue(this.egressSubject, (egress) => (Object.assign(Object.assign({}, egress), { broadcasting: true, hls: Object.assign(Object.assign({}, egress.hls), { playlist_url: event.hls_playlist_url }) })));
|
|
8255
|
+
};
|
|
8256
|
+
this.updateFromSessionParticipantLeft = (event) => {
|
|
8257
|
+
this.setCurrentValue(this.sessionSubject, (session) => {
|
|
8258
|
+
if (!session) {
|
|
8259
|
+
this.logger('warn', `Received call.session_participant_left event but no session is available.`, event);
|
|
8260
|
+
return session;
|
|
8261
|
+
}
|
|
8262
|
+
const { participants, participants_count_by_role } = session;
|
|
8263
|
+
const { user, user_session_id } = event.participant;
|
|
8264
|
+
return Object.assign(Object.assign({}, session), { participants: participants.filter((p) => p.user_session_id !== user_session_id), participants_count_by_role: Object.assign(Object.assign({}, participants_count_by_role), { [user.role]: Math.max(0, (participants_count_by_role[user.role] || 0) - 1) }) });
|
|
8265
|
+
});
|
|
8266
|
+
};
|
|
8267
|
+
this.updateFromSessionParticipantJoined = (event) => {
|
|
8268
|
+
this.setCurrentValue(this.sessionSubject, (session) => {
|
|
8269
|
+
if (!session) {
|
|
8270
|
+
this.logger('warn', `Received call.session_participant_joined event but no session is available.`, event);
|
|
8271
|
+
return session;
|
|
8272
|
+
}
|
|
8273
|
+
const { participants, participants_count_by_role } = session;
|
|
8274
|
+
const { user } = event.participant;
|
|
8275
|
+
return Object.assign(Object.assign({}, session), { participants: [...participants, event.participant], participants_count_by_role: Object.assign(Object.assign({}, participants_count_by_role), { [user.role]: (participants_count_by_role[user.role] || 0) + 1 }) });
|
|
8276
|
+
});
|
|
8277
|
+
};
|
|
8278
|
+
this.updateMembers = (event) => {
|
|
8279
|
+
this.setCurrentValue(this.membersSubject, (members) => members.map((member) => {
|
|
8280
|
+
const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
|
|
8281
|
+
return memberUpdate ? memberUpdate : member;
|
|
8282
|
+
}));
|
|
8283
|
+
};
|
|
8284
|
+
this.updateParticipantReaction = (event) => {
|
|
8285
|
+
const { user, custom, type, emoji_code } = event.reaction;
|
|
8286
|
+
this.setParticipants((participants) => {
|
|
8287
|
+
return participants.map((p) => {
|
|
8288
|
+
// skip if the reaction is not for this participant
|
|
8289
|
+
if (p.userId !== user.id)
|
|
8290
|
+
return p;
|
|
8291
|
+
// update the participant with the new reaction
|
|
8292
|
+
return Object.assign(Object.assign({}, p), { reaction: {
|
|
8293
|
+
type,
|
|
8294
|
+
emoji_code,
|
|
8295
|
+
custom,
|
|
8296
|
+
} });
|
|
8297
|
+
});
|
|
8298
|
+
});
|
|
8299
|
+
};
|
|
8300
|
+
this.unblockUser = (event) => {
|
|
8301
|
+
this.setCurrentValue(this.blockedUserIdsSubject, (current) => {
|
|
8302
|
+
if (!current)
|
|
8303
|
+
return current;
|
|
8304
|
+
return current.filter((id) => id !== event.user.id);
|
|
8305
|
+
});
|
|
8306
|
+
};
|
|
8307
|
+
this.blockUser = (event) => {
|
|
8308
|
+
this.setCurrentValue(this.blockedUserIdsSubject, (current) => [
|
|
8309
|
+
...(current || []),
|
|
8310
|
+
event.user.id,
|
|
8311
|
+
]);
|
|
8312
|
+
};
|
|
8313
|
+
this.updateOwnCapabilities = (event) => {
|
|
8314
|
+
var _a;
|
|
8315
|
+
if (event.user.id === ((_a = this.localParticipant) === null || _a === void 0 ? void 0 : _a.userId)) {
|
|
8316
|
+
this.setCurrentValue(this.ownCapabilitiesSubject, event.own_capabilities);
|
|
8317
|
+
}
|
|
8318
|
+
};
|
|
8319
|
+
this.logger = getLogger(['CallState']);
|
|
8279
8320
|
this.participants$ = this.participantsSubject.pipe(map$1((ps) => ps.sort(this.sortParticipantsBy)));
|
|
8280
8321
|
this.localParticipant$ = this.participants$.pipe(map$1((participants) => participants.find(isStreamVideoLocalParticipant)));
|
|
8281
8322
|
this.remoteParticipants$ = this.participants$.pipe(map$1((participants) => participants.filter((p) => !p.isLocalParticipant)));
|
|
8282
8323
|
this.pinnedParticipants$ = this.participants$.pipe(map$1((participants) => participants.filter((p) => !!p.pin)));
|
|
8283
8324
|
this.dominantSpeaker$ = this.participants$.pipe(map$1((participants) => participants.find((p) => p.isDominantSpeaker)));
|
|
8284
|
-
this.hasOngoingScreenShare$ = this.participants$.pipe(map$1((participants) =>
|
|
8285
|
-
return participants.some((p) => p.publishedTracks.includes(TrackType.SCREEN_SHARE));
|
|
8286
|
-
}), distinctUntilChanged());
|
|
8325
|
+
this.hasOngoingScreenShare$ = this.participants$.pipe(map$1((participants) => participants.some((p) => p.publishedTracks.includes(TrackType.SCREEN_SHARE))), distinctUntilChanged());
|
|
8287
8326
|
this.startedAt$ = this.startedAtSubject.asObservable();
|
|
8288
8327
|
this.participantCount$ = this.participantCountSubject.asObservable();
|
|
8289
8328
|
this.anonymousParticipantCount$ =
|
|
8290
8329
|
this.anonymousParticipantCountSubject.asObservable();
|
|
8291
8330
|
this.callStatsReport$ = this.callStatsReportSubject.asObservable();
|
|
8292
|
-
this.callRecordingList$ = this.callRecordingListSubject.asObservable();
|
|
8293
|
-
this.metadata$ = this.metadataSubject.asObservable();
|
|
8294
8331
|
this.members$ = this.membersSubject.asObservable();
|
|
8295
8332
|
this.ownCapabilities$ = this.ownCapabilitiesSubject.asObservable();
|
|
8296
8333
|
this.callingState$ = this.callingStateSubject.asObservable();
|
|
8334
|
+
this.backstage$ = this.backstageSubject.asObservable();
|
|
8335
|
+
this.blockedUserIds$ = this.blockedUserIdsSubject.asObservable();
|
|
8336
|
+
this.createdAt$ = this.createdAtSubject.asObservable();
|
|
8337
|
+
this.endedAt$ = this.endedAtSubject.asObservable();
|
|
8338
|
+
this.startsAt$ = this.startsAtSubject.asObservable();
|
|
8339
|
+
this.updatedAt$ = this.updatedAtSubject.asObservable();
|
|
8340
|
+
this.createdBy$ = this.createdBySubject.asObservable();
|
|
8341
|
+
this.custom$ = this.customSubject.asObservable();
|
|
8342
|
+
this.egress$ = this.egressSubject.asObservable();
|
|
8343
|
+
this.ingress$ = this.ingressSubject.asObservable();
|
|
8344
|
+
this.recording$ = this.recordingSubject.asObservable();
|
|
8345
|
+
this.session$ = this.sessionSubject.asObservable();
|
|
8346
|
+
this.settings$ = this.settingsSubject.asObservable();
|
|
8347
|
+
this.transcribing$ = this.transcribingSubject.asObservable();
|
|
8348
|
+
this.endedBy$ = this.endedBySubject.asObservable();
|
|
8349
|
+
this.eventHandlers = {
|
|
8350
|
+
// these events are not updating the call state:
|
|
8351
|
+
'call.permission_request': undefined,
|
|
8352
|
+
'call.user_muted': undefined,
|
|
8353
|
+
'connection.error': undefined,
|
|
8354
|
+
'connection.ok': undefined,
|
|
8355
|
+
'health.check': undefined,
|
|
8356
|
+
custom: undefined,
|
|
8357
|
+
// events that update call state:
|
|
8358
|
+
'call.accepted': (e) => this.updateFromCallResponse(e.call),
|
|
8359
|
+
'call.created': (e) => this.updateFromCallResponse(e.call),
|
|
8360
|
+
'call.notification': (e) => this.updateFromCallResponse(e.call),
|
|
8361
|
+
'call.rejected': (e) => this.updateFromCallResponse(e.call),
|
|
8362
|
+
'call.ring': (e) => this.updateFromCallResponse(e.call),
|
|
8363
|
+
'call.live_started': (e) => this.updateFromCallResponse(e.call),
|
|
8364
|
+
'call.updated': (e) => this.updateFromCallResponse(e.call),
|
|
8365
|
+
'call.session_started': (e) => this.updateFromCallResponse(e.call),
|
|
8366
|
+
'call.session_ended': (e) => this.updateFromCallResponse(e.call),
|
|
8367
|
+
'call.ended': (e) => {
|
|
8368
|
+
this.updateFromCallResponse(e.call);
|
|
8369
|
+
this.setCurrentValue(this.endedBySubject, e.user);
|
|
8370
|
+
},
|
|
8371
|
+
'call.recording_started': () => this.setCurrentValue(this.recordingSubject, true),
|
|
8372
|
+
'call.recording_stopped': () => this.setCurrentValue(this.recordingSubject, false),
|
|
8373
|
+
'call.broadcasting_started': this.updateFromBroadcastStarted,
|
|
8374
|
+
'call.broadcasting_stopped': this.updateFromBroadcastStopped,
|
|
8375
|
+
'call.session_participant_joined': this.updateFromSessionParticipantJoined,
|
|
8376
|
+
'call.session_participant_left': this.updateFromSessionParticipantLeft,
|
|
8377
|
+
'call.blocked_user': this.blockUser,
|
|
8378
|
+
'call.unblocked_user': this.unblockUser,
|
|
8379
|
+
'call.permissions_updated': this.updateOwnCapabilities,
|
|
8380
|
+
'call.member_added': this.updateFromMemberAdded,
|
|
8381
|
+
'call.member_removed': this.updateFromMemberRemoved,
|
|
8382
|
+
'call.member_updated': this.updateMembers,
|
|
8383
|
+
'call.member_updated_permission': this.updateMembers,
|
|
8384
|
+
'call.reaction_new': this.updateParticipantReaction,
|
|
8385
|
+
};
|
|
8297
8386
|
}
|
|
8298
8387
|
/**
|
|
8299
8388
|
* The server-side counted number of participants connected to the current call.
|
|
@@ -8358,24 +8447,12 @@ class CallState {
|
|
|
8358
8447
|
get callingState() {
|
|
8359
8448
|
return this.getCurrentValue(this.callingState$);
|
|
8360
8449
|
}
|
|
8361
|
-
/**
|
|
8362
|
-
* The list of call recordings.
|
|
8363
|
-
*/
|
|
8364
|
-
get callRecordingsList() {
|
|
8365
|
-
return this.getCurrentValue(this.callRecordingList$);
|
|
8366
|
-
}
|
|
8367
8450
|
/**
|
|
8368
8451
|
* The call stats report.
|
|
8369
8452
|
*/
|
|
8370
8453
|
get callStatsReport() {
|
|
8371
8454
|
return this.getCurrentValue(this.callStatsReport$);
|
|
8372
8455
|
}
|
|
8373
|
-
/**
|
|
8374
|
-
* The metadata of the current call.
|
|
8375
|
-
*/
|
|
8376
|
-
get metadata() {
|
|
8377
|
-
return this.getCurrentValue(this.metadata$);
|
|
8378
|
-
}
|
|
8379
8456
|
/**
|
|
8380
8457
|
* The members of the current call.
|
|
8381
8458
|
*/
|
|
@@ -8388,6 +8465,96 @@ class CallState {
|
|
|
8388
8465
|
get ownCapabilities() {
|
|
8389
8466
|
return this.getCurrentValue(this.ownCapabilities$);
|
|
8390
8467
|
}
|
|
8468
|
+
/**
|
|
8469
|
+
* The backstage state.
|
|
8470
|
+
*/
|
|
8471
|
+
get backstage() {
|
|
8472
|
+
return this.getCurrentValue(this.backstage$);
|
|
8473
|
+
}
|
|
8474
|
+
/**
|
|
8475
|
+
* Will provide the list of blocked user IDs.
|
|
8476
|
+
*/
|
|
8477
|
+
get blockedUserIds() {
|
|
8478
|
+
return this.getCurrentValue(this.blockedUserIds$);
|
|
8479
|
+
}
|
|
8480
|
+
/**
|
|
8481
|
+
* Will provide the time when this call has been created.
|
|
8482
|
+
*/
|
|
8483
|
+
get createdAt() {
|
|
8484
|
+
return this.getCurrentValue(this.createdAt$);
|
|
8485
|
+
}
|
|
8486
|
+
/**
|
|
8487
|
+
* Will provide the time when this call has been ended.
|
|
8488
|
+
*/
|
|
8489
|
+
get endedAt() {
|
|
8490
|
+
return this.getCurrentValue(this.endedAt$);
|
|
8491
|
+
}
|
|
8492
|
+
/**
|
|
8493
|
+
* Will provide the time when this call has been scheduled to start.
|
|
8494
|
+
*/
|
|
8495
|
+
get startsAt() {
|
|
8496
|
+
return this.getCurrentValue(this.startsAt$);
|
|
8497
|
+
}
|
|
8498
|
+
/**
|
|
8499
|
+
* Will provide the time when this call has been updated.
|
|
8500
|
+
*/
|
|
8501
|
+
get updatedAt() {
|
|
8502
|
+
return this.getCurrentValue(this.updatedAt$);
|
|
8503
|
+
}
|
|
8504
|
+
/**
|
|
8505
|
+
* Will provide the user who created this call.
|
|
8506
|
+
*/
|
|
8507
|
+
get createdBy() {
|
|
8508
|
+
return this.getCurrentValue(this.createdBy$);
|
|
8509
|
+
}
|
|
8510
|
+
/**
|
|
8511
|
+
* Will provide the custom data of this call.
|
|
8512
|
+
*/
|
|
8513
|
+
get custom() {
|
|
8514
|
+
return this.getCurrentValue(this.custom$);
|
|
8515
|
+
}
|
|
8516
|
+
/**
|
|
8517
|
+
* Will provide the egress data of this call.
|
|
8518
|
+
*/
|
|
8519
|
+
get egress() {
|
|
8520
|
+
return this.getCurrentValue(this.egress$);
|
|
8521
|
+
}
|
|
8522
|
+
/**
|
|
8523
|
+
* Will provide the ingress data of this call.
|
|
8524
|
+
*/
|
|
8525
|
+
get ingress() {
|
|
8526
|
+
return this.getCurrentValue(this.ingress$);
|
|
8527
|
+
}
|
|
8528
|
+
/**
|
|
8529
|
+
* Will provide the recording state of this call.
|
|
8530
|
+
*/
|
|
8531
|
+
get recording() {
|
|
8532
|
+
return this.getCurrentValue(this.recording$);
|
|
8533
|
+
}
|
|
8534
|
+
/**
|
|
8535
|
+
* Will provide the session data of this call.
|
|
8536
|
+
*/
|
|
8537
|
+
get session() {
|
|
8538
|
+
return this.getCurrentValue(this.session$);
|
|
8539
|
+
}
|
|
8540
|
+
/**
|
|
8541
|
+
* Will provide the settings of this call.
|
|
8542
|
+
*/
|
|
8543
|
+
get settings() {
|
|
8544
|
+
return this.getCurrentValue(this.settings$);
|
|
8545
|
+
}
|
|
8546
|
+
/**
|
|
8547
|
+
* Will provide the transcribing state of this call.
|
|
8548
|
+
*/
|
|
8549
|
+
get transcribing() {
|
|
8550
|
+
return this.getCurrentValue(this.transcribing$);
|
|
8551
|
+
}
|
|
8552
|
+
/**
|
|
8553
|
+
* Will provide the user who ended this call.
|
|
8554
|
+
*/
|
|
8555
|
+
get endedBy() {
|
|
8556
|
+
return this.getCurrentValue(this.endedBy$);
|
|
8557
|
+
}
|
|
8391
8558
|
}
|
|
8392
8559
|
|
|
8393
8560
|
/**
|
|
@@ -8459,40 +8626,16 @@ const watchCallEnded = (call) => {
|
|
|
8459
8626
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8460
8627
|
if (event.type !== 'call.ended')
|
|
8461
8628
|
return;
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8629
|
+
const { callingState } = call.state;
|
|
8630
|
+
if (callingState === CallingState.RINGING ||
|
|
8631
|
+
callingState === CallingState.JOINED ||
|
|
8632
|
+
callingState === CallingState.JOINING) {
|
|
8466
8633
|
yield call.leave();
|
|
8467
8634
|
}
|
|
8468
8635
|
});
|
|
8469
8636
|
};
|
|
8470
8637
|
};
|
|
8471
|
-
/**
|
|
8472
|
-
* An event handler which listens to `call.updated` events
|
|
8473
|
-
* and updates the given call state accordingly.
|
|
8474
|
-
*/
|
|
8475
|
-
const watchCallUpdated = (state) => {
|
|
8476
|
-
return function onCallUpdated(event) {
|
|
8477
|
-
if (event.type !== 'call.updated')
|
|
8478
|
-
return;
|
|
8479
|
-
state.setMetadata(event.call);
|
|
8480
|
-
};
|
|
8481
|
-
};
|
|
8482
8638
|
|
|
8483
|
-
/**
|
|
8484
|
-
* Event handler that watches for `call.permissions_updated` events
|
|
8485
|
-
*/
|
|
8486
|
-
const watchCallPermissionsUpdated = (state) => {
|
|
8487
|
-
return function onCallPermissionsUpdated(event) {
|
|
8488
|
-
if (event.type !== 'call.permissions_updated')
|
|
8489
|
-
return;
|
|
8490
|
-
const { localParticipant } = state;
|
|
8491
|
-
if (event.user.id === (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.userId)) {
|
|
8492
|
-
state.setOwnCapabilities(event.own_capabilities);
|
|
8493
|
-
}
|
|
8494
|
-
};
|
|
8495
|
-
};
|
|
8496
8639
|
/**
|
|
8497
8640
|
* Event handler that watches for `callGrantsUpdated` events.
|
|
8498
8641
|
*
|
|
@@ -8606,57 +8749,6 @@ const watchPinsUpdated = (state) => {
|
|
|
8606
8749
|
};
|
|
8607
8750
|
};
|
|
8608
8751
|
|
|
8609
|
-
/**
|
|
8610
|
-
* Watches for `call.member_added` events.
|
|
8611
|
-
*/
|
|
8612
|
-
const watchCallMemberAdded = (state) => {
|
|
8613
|
-
return function onCallMemberAdded(event) {
|
|
8614
|
-
if (event.type !== 'call.member_added')
|
|
8615
|
-
return;
|
|
8616
|
-
state.setMembers((members) => [...members, ...event.members]);
|
|
8617
|
-
};
|
|
8618
|
-
};
|
|
8619
|
-
/**
|
|
8620
|
-
* Watches for `call.member_removed` events.
|
|
8621
|
-
*/
|
|
8622
|
-
const watchCallMemberRemoved = (state) => {
|
|
8623
|
-
return function onCallMemberRemoved(event) {
|
|
8624
|
-
if (event.type !== 'call.member_removed')
|
|
8625
|
-
return;
|
|
8626
|
-
state.setMembers((members) => members.filter((m) => event.members.indexOf(m.user_id) === -1));
|
|
8627
|
-
};
|
|
8628
|
-
};
|
|
8629
|
-
/**
|
|
8630
|
-
* Watches for `call.member_updated_permission` events.
|
|
8631
|
-
*/
|
|
8632
|
-
const watchCallMemberUpdatedPermission = (state) => {
|
|
8633
|
-
return function onCallMemberUpdated(event) {
|
|
8634
|
-
if (event.type !== 'call.member_updated_permission')
|
|
8635
|
-
return;
|
|
8636
|
-
state.setMembers((members) => members.map((member) => {
|
|
8637
|
-
const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
|
|
8638
|
-
if (memberUpdate) {
|
|
8639
|
-
member.user.role = memberUpdate.role;
|
|
8640
|
-
member = Object.assign({}, member);
|
|
8641
|
-
}
|
|
8642
|
-
return member;
|
|
8643
|
-
}));
|
|
8644
|
-
};
|
|
8645
|
-
};
|
|
8646
|
-
/**
|
|
8647
|
-
* Watches for `call.member_updated` events.
|
|
8648
|
-
*/
|
|
8649
|
-
const watchCallMemberUpdated = (state) => {
|
|
8650
|
-
return function onCallMemberUpdated(event) {
|
|
8651
|
-
if (event.type !== 'call.member_updated')
|
|
8652
|
-
return;
|
|
8653
|
-
state.setMembers((members) => members.map((member) => {
|
|
8654
|
-
const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
|
|
8655
|
-
return memberUpdate ? memberUpdate : member;
|
|
8656
|
-
}));
|
|
8657
|
-
};
|
|
8658
|
-
};
|
|
8659
|
-
|
|
8660
8752
|
/**
|
|
8661
8753
|
* An event responder which handles the `participantJoined` event.
|
|
8662
8754
|
*/
|
|
@@ -8738,74 +8830,6 @@ const watchTrackUnpublished = (state) => {
|
|
|
8738
8830
|
};
|
|
8739
8831
|
const unique = (v, i, arr) => arr.indexOf(v) === i;
|
|
8740
8832
|
|
|
8741
|
-
/**
|
|
8742
|
-
* Watches the delivery of CallReactionEvent.
|
|
8743
|
-
*
|
|
8744
|
-
* @param state the state store to update.
|
|
8745
|
-
*/
|
|
8746
|
-
const watchNewReactions = (state) => {
|
|
8747
|
-
return function onNewReactions(event) {
|
|
8748
|
-
if (event.type !== 'call.reaction_new')
|
|
8749
|
-
return;
|
|
8750
|
-
const { reaction } = event;
|
|
8751
|
-
const { user, custom, type, emoji_code } = reaction;
|
|
8752
|
-
state.setParticipants((participants) => {
|
|
8753
|
-
return participants.map((p) => {
|
|
8754
|
-
// skip if the reaction is not for this participant
|
|
8755
|
-
if (p.userId !== user.id)
|
|
8756
|
-
return p;
|
|
8757
|
-
// update the participant with the new reaction
|
|
8758
|
-
return Object.assign(Object.assign({}, p), { reaction: {
|
|
8759
|
-
type,
|
|
8760
|
-
emoji_code,
|
|
8761
|
-
custom,
|
|
8762
|
-
} });
|
|
8763
|
-
});
|
|
8764
|
-
});
|
|
8765
|
-
};
|
|
8766
|
-
};
|
|
8767
|
-
|
|
8768
|
-
/**
|
|
8769
|
-
* Watches for `call.recording_started` events.
|
|
8770
|
-
*/
|
|
8771
|
-
const watchCallRecordingStarted = (state) => {
|
|
8772
|
-
return function onCallRecordingStarted(event) {
|
|
8773
|
-
if (event.type !== 'call.recording_started')
|
|
8774
|
-
return;
|
|
8775
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { recording: true })));
|
|
8776
|
-
};
|
|
8777
|
-
};
|
|
8778
|
-
/**
|
|
8779
|
-
* Watches for `call.recording_stopped` events.
|
|
8780
|
-
*/
|
|
8781
|
-
const watchCallRecordingStopped = (state) => {
|
|
8782
|
-
return function onCallRecordingStopped(event) {
|
|
8783
|
-
if (event.type !== 'call.recording_stopped')
|
|
8784
|
-
return;
|
|
8785
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { recording: false })));
|
|
8786
|
-
};
|
|
8787
|
-
};
|
|
8788
|
-
/**
|
|
8789
|
-
* Watches for `call.broadcasting_started` events.
|
|
8790
|
-
*/
|
|
8791
|
-
const watchCallBroadcastingStarted = (state) => {
|
|
8792
|
-
return function onCallBroadcastingStarted(event) {
|
|
8793
|
-
if (event.type !== 'call.broadcasting_started')
|
|
8794
|
-
return;
|
|
8795
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { egress: Object.assign(Object.assign({}, metadata.egress), { broadcasting: true, hls: Object.assign(Object.assign({}, metadata.egress.hls), { playlist_url: event.hls_playlist_url }) }) })));
|
|
8796
|
-
};
|
|
8797
|
-
};
|
|
8798
|
-
/**
|
|
8799
|
-
* Watches for `call.broadcasting_stopped` events.
|
|
8800
|
-
*/
|
|
8801
|
-
const watchCallBroadcastingStopped = (state) => {
|
|
8802
|
-
return function onCallBroadcastingStopped(event) {
|
|
8803
|
-
if (event.type !== 'call.broadcasting_stopped')
|
|
8804
|
-
return;
|
|
8805
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { egress: Object.assign(Object.assign({}, metadata.egress), { broadcasting: false }) })));
|
|
8806
|
-
};
|
|
8807
|
-
};
|
|
8808
|
-
|
|
8809
8833
|
/**
|
|
8810
8834
|
* Watches for `dominantSpeakerChanged` events.
|
|
8811
8835
|
*/
|
|
@@ -8848,98 +8872,6 @@ const watchAudioLevelChanged = (dispatcher, state) => {
|
|
|
8848
8872
|
});
|
|
8849
8873
|
};
|
|
8850
8874
|
|
|
8851
|
-
/**
|
|
8852
|
-
* Watch for call.session_started events and update the call metadata.
|
|
8853
|
-
*
|
|
8854
|
-
* @param state the call state.
|
|
8855
|
-
*/
|
|
8856
|
-
const watchCallSessionStarted = (state) => {
|
|
8857
|
-
return function onCallSessionStarted(event) {
|
|
8858
|
-
if (event.type !== 'call.session_started')
|
|
8859
|
-
return;
|
|
8860
|
-
state.setMetadata(event.call);
|
|
8861
|
-
};
|
|
8862
|
-
};
|
|
8863
|
-
/**
|
|
8864
|
-
* Watch for call.session_ended events and update the call metadata.
|
|
8865
|
-
*
|
|
8866
|
-
* @param state the call state.
|
|
8867
|
-
*/
|
|
8868
|
-
const watchCallSessionEnded = (state) => {
|
|
8869
|
-
return function onCallSessionEnded(event) {
|
|
8870
|
-
if (event.type !== 'call.session_ended')
|
|
8871
|
-
return;
|
|
8872
|
-
state.setMetadata(event.call);
|
|
8873
|
-
};
|
|
8874
|
-
};
|
|
8875
|
-
/**
|
|
8876
|
-
* Watch for call.session_participant_joined events and update the call metadata.
|
|
8877
|
-
*
|
|
8878
|
-
* @param state the call state.
|
|
8879
|
-
*/
|
|
8880
|
-
const watchCallSessionParticipantJoined = (state) => {
|
|
8881
|
-
return function onCallParticipantJoined(event) {
|
|
8882
|
-
if (event.type !== 'call.session_participant_joined')
|
|
8883
|
-
return;
|
|
8884
|
-
const { participant } = event;
|
|
8885
|
-
state.setMetadata((metadata) => {
|
|
8886
|
-
if (!metadata || !metadata.session) {
|
|
8887
|
-
state.logger('warn', `Received call.session_participant_joined event but the metadata structure is invalid.`, event);
|
|
8888
|
-
return metadata;
|
|
8889
|
-
}
|
|
8890
|
-
const { session } = metadata;
|
|
8891
|
-
const { participants, participants_count_by_role } = session;
|
|
8892
|
-
const { user } = participant;
|
|
8893
|
-
return Object.assign(Object.assign({}, metadata), { session: Object.assign(Object.assign({}, session), { participants: [...participants, participant], participants_count_by_role: Object.assign(Object.assign({}, participants_count_by_role), { [user.role]: (participants_count_by_role[user.role] || 0) + 1 }) }) });
|
|
8894
|
-
});
|
|
8895
|
-
};
|
|
8896
|
-
};
|
|
8897
|
-
/**
|
|
8898
|
-
* Watch for call.session_participant_left events and update the call metadata.
|
|
8899
|
-
*
|
|
8900
|
-
* @param state the call state.
|
|
8901
|
-
*/
|
|
8902
|
-
const watchCallSessionParticipantLeft = (state) => {
|
|
8903
|
-
return function onCallParticipantLeft(event) {
|
|
8904
|
-
if (event.type !== 'call.session_participant_left')
|
|
8905
|
-
return;
|
|
8906
|
-
const { user, user_session_id } = event.participant;
|
|
8907
|
-
state.setMetadata((metadata) => {
|
|
8908
|
-
if (!metadata || !metadata.session) {
|
|
8909
|
-
state.logger('warn', `Received call.session_participant_left event but the metadata structure is invalid.`, event);
|
|
8910
|
-
return metadata;
|
|
8911
|
-
}
|
|
8912
|
-
const { session } = metadata;
|
|
8913
|
-
const { participants, participants_count_by_role } = session;
|
|
8914
|
-
return Object.assign(Object.assign({}, metadata), { session: Object.assign(Object.assign({}, session), { participants: participants.filter((p) => p.user_session_id !== user_session_id), participants_count_by_role: Object.assign(Object.assign({}, participants_count_by_role), { [user.role]: Math.max(0, (participants_count_by_role[user.role] || 0) - 1) }) }) });
|
|
8915
|
-
});
|
|
8916
|
-
};
|
|
8917
|
-
};
|
|
8918
|
-
|
|
8919
|
-
/**
|
|
8920
|
-
* Event handler that watches for `call.blocked_user` events,
|
|
8921
|
-
* updates the call store `blocked_user_ids` property by adding
|
|
8922
|
-
* `event.user_id` to the list
|
|
8923
|
-
*/
|
|
8924
|
-
const watchBlockedUser = (state) => (event) => {
|
|
8925
|
-
if (event.type !== 'call.blocked_user')
|
|
8926
|
-
return;
|
|
8927
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { blocked_user_ids: [...((metadata === null || metadata === void 0 ? void 0 : metadata.blocked_user_ids) || []), event.user.id] })));
|
|
8928
|
-
};
|
|
8929
|
-
/**
|
|
8930
|
-
* Event handler that watches for `call.unblocked_user` events,
|
|
8931
|
-
* updates the call store `blocked_user_ids` property by
|
|
8932
|
-
* removing `event.user_id` from the list
|
|
8933
|
-
*/
|
|
8934
|
-
const watchUnblockedUser = (state) => (event) => {
|
|
8935
|
-
if (event.type !== 'call.unblocked_user')
|
|
8936
|
-
return;
|
|
8937
|
-
state.setMetadata((metadata) => {
|
|
8938
|
-
const blocked_user_ids = ((metadata === null || metadata === void 0 ? void 0 : metadata.blocked_user_ids) || []).filter((userId) => event.user.id !== userId);
|
|
8939
|
-
return Object.assign(Object.assign({}, metadata), { blocked_user_ids });
|
|
8940
|
-
});
|
|
8941
|
-
};
|
|
8942
|
-
|
|
8943
8875
|
/**
|
|
8944
8876
|
* Registers the default event handlers for a call during its lifecycle.
|
|
8945
8877
|
*
|
|
@@ -8948,29 +8880,8 @@ const watchUnblockedUser = (state) => (event) => {
|
|
|
8948
8880
|
* @param dispatcher the dispatcher.
|
|
8949
8881
|
*/
|
|
8950
8882
|
const registerEventHandlers = (call, state, dispatcher) => {
|
|
8951
|
-
const coordinatorEvents = {
|
|
8952
|
-
'call.blocked_user': watchBlockedUser(state),
|
|
8953
|
-
'call.broadcasting_started': watchCallBroadcastingStarted(state),
|
|
8954
|
-
'call.broadcasting_stopped': watchCallBroadcastingStopped(state),
|
|
8955
|
-
'call.ended': watchCallEnded(call),
|
|
8956
|
-
'call.live_started': watchCallLiveStarted(state),
|
|
8957
|
-
'call.member_added': watchCallMemberAdded(state),
|
|
8958
|
-
'call.member_removed': watchCallMemberRemoved(state),
|
|
8959
|
-
'call.member_updated': watchCallMemberUpdated(state),
|
|
8960
|
-
'call.member_updated_permission': watchCallMemberUpdatedPermission(state),
|
|
8961
|
-
'call.permissions_updated': watchCallPermissionsUpdated(state),
|
|
8962
|
-
'call.reaction_new': watchNewReactions(state),
|
|
8963
|
-
'call.recording_started': watchCallRecordingStarted(state),
|
|
8964
|
-
'call.recording_stopped': watchCallRecordingStopped(state),
|
|
8965
|
-
'call.session_started': watchCallSessionStarted(state),
|
|
8966
|
-
'call.session_ended': watchCallSessionEnded(state),
|
|
8967
|
-
'call.session_participant_joined': watchCallSessionParticipantJoined(state),
|
|
8968
|
-
'call.session_participant_left': watchCallSessionParticipantLeft(state),
|
|
8969
|
-
'call.unblocked_user': watchUnblockedUser(state),
|
|
8970
|
-
'call.updated': watchCallUpdated(state),
|
|
8971
|
-
'call.user_muted': () => console.log('call.user_muted received'),
|
|
8972
|
-
};
|
|
8973
8883
|
const eventHandlers = [
|
|
8884
|
+
call.on('call.ended', watchCallEnded(call)),
|
|
8974
8885
|
watchLiveEnded(dispatcher, call),
|
|
8975
8886
|
watchSfuErrorReports(dispatcher),
|
|
8976
8887
|
watchChangePublishQuality(dispatcher, call),
|
|
@@ -8985,10 +8896,6 @@ const registerEventHandlers = (call, state, dispatcher) => {
|
|
|
8985
8896
|
call.on('callGrantsUpdated', watchCallGrantsUpdated(state)),
|
|
8986
8897
|
call.on('pinsUpdated', watchPinsUpdated(state)),
|
|
8987
8898
|
];
|
|
8988
|
-
Object.keys(coordinatorEvents).forEach((event) => {
|
|
8989
|
-
const eventName = event;
|
|
8990
|
-
eventHandlers.push(call.on(eventName, coordinatorEvents[eventName]));
|
|
8991
|
-
});
|
|
8992
8899
|
if (call.ringing) {
|
|
8993
8900
|
// these events are only relevant when the call is ringing
|
|
8994
8901
|
eventHandlers.push(registerRingingCallEventHandlers(call));
|
|
@@ -9618,7 +9525,7 @@ class Call {
|
|
|
9618
9525
|
* Use the [`StreamVideoClient.call`](./StreamVideoClient.md/#call)
|
|
9619
9526
|
* method to construct a `Call` instance.
|
|
9620
9527
|
*/
|
|
9621
|
-
constructor({ type, id, streamClient,
|
|
9528
|
+
constructor({ type, id, streamClient, members, ownCapabilities, sortParticipantsBy, clientStore, ringing = false, watching = false, }) {
|
|
9622
9529
|
/**
|
|
9623
9530
|
* ViewportTracker instance
|
|
9624
9531
|
*/
|
|
@@ -9697,7 +9604,7 @@ class Call {
|
|
|
9697
9604
|
if ((params === null || params === void 0 ? void 0 : params.ring) && !this.ringing) {
|
|
9698
9605
|
this.ringingSubject.next(true);
|
|
9699
9606
|
}
|
|
9700
|
-
this.state.
|
|
9607
|
+
this.state.updateFromCallResponse(response.call);
|
|
9701
9608
|
this.state.setMembers(response.members);
|
|
9702
9609
|
this.state.setOwnCapabilities(response.own_capabilities);
|
|
9703
9610
|
if (this.streamClient._hasConnectionID()) {
|
|
@@ -9716,7 +9623,7 @@ class Call {
|
|
|
9716
9623
|
if ((data === null || data === void 0 ? void 0 : data.ring) && !this.ringing) {
|
|
9717
9624
|
this.ringingSubject.next(true);
|
|
9718
9625
|
}
|
|
9719
|
-
this.state.
|
|
9626
|
+
this.state.updateFromCallResponse(response.call);
|
|
9720
9627
|
this.state.setMembers(response.members);
|
|
9721
9628
|
this.state.setOwnCapabilities(response.own_capabilities);
|
|
9722
9629
|
if (this.streamClient._hasConnectionID()) {
|
|
@@ -9797,7 +9704,7 @@ class Call {
|
|
|
9797
9704
|
let connectionConfig;
|
|
9798
9705
|
try {
|
|
9799
9706
|
const call = yield join(this.streamClient, this.type, this.id, data);
|
|
9800
|
-
this.state.
|
|
9707
|
+
this.state.updateFromCallResponse(call.metadata);
|
|
9801
9708
|
this.state.setMembers(call.members);
|
|
9802
9709
|
this.state.setOwnCapabilities(call.ownCapabilities);
|
|
9803
9710
|
connectionConfig = call.connectionConfig;
|
|
@@ -9962,7 +9869,7 @@ class Call {
|
|
|
9962
9869
|
connectionConfig,
|
|
9963
9870
|
});
|
|
9964
9871
|
}
|
|
9965
|
-
const audioSettings = (_f = this.
|
|
9872
|
+
const audioSettings = (_f = this.state.settings) === null || _f === void 0 ? void 0 : _f.audio;
|
|
9966
9873
|
const isDtxEnabled = !!(audioSettings === null || audioSettings === void 0 ? void 0 : audioSettings.opus_dtx_enabled);
|
|
9967
9874
|
const isRedEnabled = !!(audioSettings === null || audioSettings === void 0 ? void 0 : audioSettings.redundant_coding_enabled);
|
|
9968
9875
|
if (!this.publisher) {
|
|
@@ -10476,9 +10383,12 @@ class Call {
|
|
|
10476
10383
|
});
|
|
10477
10384
|
/**
|
|
10478
10385
|
* Starts the livestreaming of the call.
|
|
10386
|
+
*
|
|
10387
|
+
* @param data the request data.
|
|
10388
|
+
* @param params the request params.
|
|
10479
10389
|
*/
|
|
10480
|
-
this.goLive = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
10481
|
-
return this.streamClient.post(`${this.streamClientBasePath}/go_live`,
|
|
10390
|
+
this.goLive = (data = {}, params) => __awaiter(this, void 0, void 0, function* () {
|
|
10391
|
+
return this.streamClient.post(`${this.streamClientBasePath}/go_live`, data, params);
|
|
10482
10392
|
});
|
|
10483
10393
|
/**
|
|
10484
10394
|
* Stops the livestreaming of the call.
|
|
@@ -10506,7 +10416,7 @@ class Call {
|
|
|
10506
10416
|
this.update = (updates) => __awaiter(this, void 0, void 0, function* () {
|
|
10507
10417
|
const response = yield this.streamClient.patch(`${this.streamClientBasePath}`, updates);
|
|
10508
10418
|
const { call, members, own_capabilities } = response;
|
|
10509
|
-
this.state.
|
|
10419
|
+
this.state.updateFromCallResponse(call);
|
|
10510
10420
|
this.state.setMembers(members);
|
|
10511
10421
|
this.state.setOwnCapabilities(own_capabilities);
|
|
10512
10422
|
return response;
|
|
@@ -10579,19 +10489,20 @@ class Call {
|
|
|
10579
10489
|
this.scheduleAutoDrop = () => {
|
|
10580
10490
|
if (this.dropTimeout)
|
|
10581
10491
|
clearTimeout(this.dropTimeout);
|
|
10582
|
-
const subscription = this.state.
|
|
10583
|
-
.pipe(pairwise(), tap(([
|
|
10584
|
-
|
|
10492
|
+
const subscription = this.state.settings$
|
|
10493
|
+
.pipe(pairwise(), tap(([prevSettings, currentSettings]) => {
|
|
10494
|
+
var _a;
|
|
10495
|
+
if (!currentSettings || !this.clientStore.connectedUser)
|
|
10585
10496
|
return;
|
|
10586
|
-
const isOutgoingCall = this.currentUserId ===
|
|
10497
|
+
const isOutgoingCall = this.currentUserId === ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id);
|
|
10587
10498
|
const [prevTimeoutMs, timeoutMs] = isOutgoingCall
|
|
10588
10499
|
? [
|
|
10589
|
-
|
|
10590
|
-
|
|
10500
|
+
prevSettings === null || prevSettings === void 0 ? void 0 : prevSettings.ring.auto_cancel_timeout_ms,
|
|
10501
|
+
currentSettings.ring.auto_cancel_timeout_ms,
|
|
10591
10502
|
]
|
|
10592
10503
|
: [
|
|
10593
|
-
|
|
10594
|
-
|
|
10504
|
+
prevSettings === null || prevSettings === void 0 ? void 0 : prevSettings.ring.incoming_call_timeout_ms,
|
|
10505
|
+
currentSettings.ring.incoming_call_timeout_ms,
|
|
10595
10506
|
];
|
|
10596
10507
|
if (typeof timeoutMs === 'undefined' ||
|
|
10597
10508
|
timeoutMs === prevTimeoutMs ||
|
|
@@ -10608,7 +10519,6 @@ class Call {
|
|
|
10608
10519
|
};
|
|
10609
10520
|
/**
|
|
10610
10521
|
* Retrieves the list of recordings for the current call or call session.
|
|
10611
|
-
* Updates the call state with the returned array of CallRecording objects.
|
|
10612
10522
|
*
|
|
10613
10523
|
* If `callSessionId` is provided, it will return the recordings for that call session.
|
|
10614
10524
|
* Otherwise, all recordings for the current call will be returned.
|
|
@@ -10620,9 +10530,7 @@ class Call {
|
|
|
10620
10530
|
if (callSessionId) {
|
|
10621
10531
|
endpoint = `${endpoint}/${callSessionId}`;
|
|
10622
10532
|
}
|
|
10623
|
-
|
|
10624
|
-
this.state.setCallRecordingsList(response.recordings);
|
|
10625
|
-
return response;
|
|
10533
|
+
return this.streamClient.get(`${endpoint}/recordings`);
|
|
10626
10534
|
});
|
|
10627
10535
|
/**
|
|
10628
10536
|
* Sends a custom event to all call participants.
|
|
@@ -10646,21 +10554,24 @@ class Call {
|
|
|
10646
10554
|
if (participantSorter) {
|
|
10647
10555
|
this.state.setSortParticipantsBy(participantSorter);
|
|
10648
10556
|
}
|
|
10649
|
-
this.state.setMetadata(metadata);
|
|
10650
10557
|
this.state.setMembers(members || []);
|
|
10651
10558
|
this.state.setOwnCapabilities(ownCapabilities || []);
|
|
10652
10559
|
this.state.setCallingState(ringing ? CallingState.RINGING : CallingState.IDLE);
|
|
10560
|
+
this.on('all', (event) => {
|
|
10561
|
+
// update state with the latest event data
|
|
10562
|
+
this.state.updateFromEvent(event);
|
|
10563
|
+
});
|
|
10653
10564
|
this.leaveCallHooks.push(registerEventHandlers(this, this.state, this.dispatcher));
|
|
10654
10565
|
this.registerEffects();
|
|
10655
10566
|
this.leaveCallHooks.push(createSubscription(this.trackSubscriptionsSubject.pipe(debounce((v) => timer(v.type)), map$2((v) => v.data)), (subscriptions) => { var _a; return (_a = this.sfuClient) === null || _a === void 0 ? void 0 : _a.updateSubscriptions(subscriptions); }));
|
|
10656
10567
|
}
|
|
10657
10568
|
registerEffects() {
|
|
10658
10569
|
this.leaveCallHooks.push(
|
|
10659
|
-
// handles updating the permissions context when the
|
|
10660
|
-
createSubscription(this.state.
|
|
10661
|
-
if (!
|
|
10570
|
+
// handles updating the permissions context when the settings change.
|
|
10571
|
+
createSubscription(this.state.settings$, (settings) => {
|
|
10572
|
+
if (!settings)
|
|
10662
10573
|
return;
|
|
10663
|
-
this.permissionsContext.setCallSettings(
|
|
10574
|
+
this.permissionsContext.setCallSettings(settings);
|
|
10664
10575
|
}),
|
|
10665
10576
|
// handle the case when the user permissions are modified.
|
|
10666
10577
|
createSubscription(this.state.ownCapabilities$, (ownCapabilities) => {
|
|
@@ -10684,12 +10595,11 @@ class Call {
|
|
|
10684
10595
|
}
|
|
10685
10596
|
}),
|
|
10686
10597
|
// handles the case when the user is blocked by the call owner.
|
|
10687
|
-
createSubscription(this.state.
|
|
10688
|
-
if (!
|
|
10598
|
+
createSubscription(this.state.blockedUserIds$, (blockedUserIds) => __awaiter(this, void 0, void 0, function* () {
|
|
10599
|
+
if (!blockedUserIds)
|
|
10689
10600
|
return;
|
|
10690
10601
|
const currentUserId = this.currentUserId;
|
|
10691
|
-
if (currentUserId &&
|
|
10692
|
-
metadata.blocked_user_ids.includes(currentUserId)) {
|
|
10602
|
+
if (currentUserId && blockedUserIds.includes(currentUserId)) {
|
|
10693
10603
|
this.logger('info', 'Leaving call because of being blocked');
|
|
10694
10604
|
yield this.leave();
|
|
10695
10605
|
}
|
|
@@ -10741,12 +10651,6 @@ class Call {
|
|
|
10741
10651
|
}
|
|
10742
10652
|
}
|
|
10743
10653
|
}
|
|
10744
|
-
/**
|
|
10745
|
-
* A getter for the call metadata.
|
|
10746
|
-
*/
|
|
10747
|
-
get data() {
|
|
10748
|
-
return this.state.metadata;
|
|
10749
|
-
}
|
|
10750
10654
|
/**
|
|
10751
10655
|
* A flag indicating whether the call is "ringing" type of call.
|
|
10752
10656
|
*/
|
|
@@ -10765,7 +10669,7 @@ class Call {
|
|
|
10765
10669
|
*/
|
|
10766
10670
|
get isCreatedByMe() {
|
|
10767
10671
|
var _a;
|
|
10768
|
-
return ((_a = this.state.
|
|
10672
|
+
return ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id) === this.currentUserId;
|
|
10769
10673
|
}
|
|
10770
10674
|
}
|
|
10771
10675
|
|
|
@@ -11877,7 +11781,7 @@ class WSConnectionFallback {
|
|
|
11877
11781
|
}
|
|
11878
11782
|
}
|
|
11879
11783
|
|
|
11880
|
-
const version = '0.
|
|
11784
|
+
const version = '0.3.0';
|
|
11881
11785
|
|
|
11882
11786
|
const logger = getLogger(['location']);
|
|
11883
11787
|
const HINT_URL = `https://hint.stream-io-video.com/`;
|
|
@@ -12571,12 +12475,12 @@ class StreamVideoClient {
|
|
|
12571
12475
|
streamClient: this.streamClient,
|
|
12572
12476
|
id: c.call.id,
|
|
12573
12477
|
type: c.call.type,
|
|
12574
|
-
metadata: c.call,
|
|
12575
12478
|
members: c.members,
|
|
12576
12479
|
ownCapabilities: c.own_capabilities,
|
|
12577
12480
|
watching: data.watch,
|
|
12578
12481
|
clientStore: this.writeableStateStore,
|
|
12579
12482
|
});
|
|
12483
|
+
call.state.updateFromCallResponse(c.call);
|
|
12580
12484
|
if (data.watch) {
|
|
12581
12485
|
this.writeableStateStore.registerCall(call);
|
|
12582
12486
|
}
|
|
@@ -12584,9 +12488,9 @@ class StreamVideoClient {
|
|
|
12584
12488
|
});
|
|
12585
12489
|
return Object.assign(Object.assign({}, response), { calls: calls });
|
|
12586
12490
|
});
|
|
12587
|
-
|
|
12588
|
-
|
|
12589
|
-
|
|
12491
|
+
/**
|
|
12492
|
+
* Returns a list of available data centers available for hosting calls.
|
|
12493
|
+
*/
|
|
12590
12494
|
this.edges = () => __awaiter(this, void 0, void 0, function* () {
|
|
12591
12495
|
return this.streamClient.get(`/edges`);
|
|
12592
12496
|
});
|
|
@@ -12761,14 +12665,15 @@ class StreamVideoClient {
|
|
|
12761
12665
|
return;
|
|
12762
12666
|
}
|
|
12763
12667
|
this.logger('info', `New call created and registered: ${call.cid}`);
|
|
12764
|
-
|
|
12668
|
+
const newCall = new Call({
|
|
12765
12669
|
streamClient: this.streamClient,
|
|
12766
12670
|
type: call.type,
|
|
12767
12671
|
id: call.id,
|
|
12768
|
-
metadata: call,
|
|
12769
12672
|
members,
|
|
12770
12673
|
clientStore: this.writeableStateStore,
|
|
12771
|
-
})
|
|
12674
|
+
});
|
|
12675
|
+
newCall.state.updateFromCallResponse(call);
|
|
12676
|
+
this.writeableStateStore.registerCall(newCall);
|
|
12772
12677
|
}));
|
|
12773
12678
|
this.eventHandlersToUnregister.push(this.on('call.ring', (event) => __awaiter(this, void 0, void 0, function* () {
|
|
12774
12679
|
if (event.type !== 'call.ring')
|
|
@@ -12782,7 +12687,6 @@ class StreamVideoClient {
|
|
|
12782
12687
|
// if `call.created` was received before `call.ring`.
|
|
12783
12688
|
// In that case, we cleanup the already tracked call.
|
|
12784
12689
|
const prevCall = this.writeableStateStore.findCall(call.type, call.id);
|
|
12785
|
-
const prevMetadata = prevCall === null || prevCall === void 0 ? void 0 : prevCall.state.metadata;
|
|
12786
12690
|
yield (prevCall === null || prevCall === void 0 ? void 0 : prevCall.leave());
|
|
12787
12691
|
// we create a new call
|
|
12788
12692
|
const theCall = new Call({
|
|
@@ -12792,8 +12696,8 @@ class StreamVideoClient {
|
|
|
12792
12696
|
members,
|
|
12793
12697
|
clientStore: this.writeableStateStore,
|
|
12794
12698
|
ringing: true,
|
|
12795
|
-
metadata: prevMetadata,
|
|
12796
12699
|
});
|
|
12700
|
+
theCall.state.updateFromCallResponse(call);
|
|
12797
12701
|
// we fetch the latest metadata for the call from the server
|
|
12798
12702
|
yield theCall.get();
|
|
12799
12703
|
this.writeableStateStore.registerCall(theCall);
|