@stream-io/video-client 0.2.3 → 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 +11 -0
- package/dist/index.browser.es.js +320 -419
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +320 -419
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +320 -419
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +3 -8
- 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/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 +30 -41
- 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/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.es.js
CHANGED
|
@@ -6523,8 +6523,8 @@ class Publisher {
|
|
|
6523
6523
|
track.removeEventListener('ended', handleTrackEnded);
|
|
6524
6524
|
});
|
|
6525
6525
|
if (!transceiver) {
|
|
6526
|
-
const
|
|
6527
|
-
const targetResolution =
|
|
6526
|
+
const { settings } = this.state;
|
|
6527
|
+
const targetResolution = settings === null || settings === void 0 ? void 0 : settings.video.target_resolution;
|
|
6528
6528
|
const videoEncodings = trackType === TrackType.VIDEO
|
|
6529
6529
|
? findOptimalVideoLayers(track, targetResolution)
|
|
6530
6530
|
: undefined;
|
|
@@ -6802,8 +6802,8 @@ class Publisher {
|
|
|
6802
6802
|
}
|
|
6803
6803
|
return String(media.mid);
|
|
6804
6804
|
};
|
|
6805
|
-
const
|
|
6806
|
-
const targetResolution =
|
|
6805
|
+
const { settings } = this.state;
|
|
6806
|
+
const targetResolution = settings === null || settings === void 0 ? void 0 : settings.video.target_resolution;
|
|
6807
6807
|
return this.pc
|
|
6808
6808
|
.getTransceivers()
|
|
6809
6809
|
.filter((t) => t.direction === 'sendonly' && t.sender.track)
|
|
@@ -6896,7 +6896,6 @@ class Publisher {
|
|
|
6896
6896
|
this.pc = this.createPeerConnection(connectionConfig);
|
|
6897
6897
|
this.sfuClient = sfuClient;
|
|
6898
6898
|
this.state = state;
|
|
6899
|
-
this.dispatcher = dispatcher;
|
|
6900
6899
|
this.isDtxEnabled = isDtxEnabled;
|
|
6901
6900
|
this.isRedEnabled = isRedEnabled;
|
|
6902
6901
|
this.preferredVideoCodec = preferredVideoCodec;
|
|
@@ -7524,17 +7523,6 @@ const retryable = (rpc, logger) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
7524
7523
|
return rpcCallResult;
|
|
7525
7524
|
});
|
|
7526
7525
|
|
|
7527
|
-
/**
|
|
7528
|
-
* Watches for `call.live_started` events.
|
|
7529
|
-
*/
|
|
7530
|
-
const watchCallLiveStarted = (state) => {
|
|
7531
|
-
return function onCallLiveStarted(event) {
|
|
7532
|
-
if (event.type !== 'call.live_started')
|
|
7533
|
-
return;
|
|
7534
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { backstage: false })));
|
|
7535
|
-
};
|
|
7536
|
-
};
|
|
7537
|
-
|
|
7538
7526
|
/**
|
|
7539
7527
|
* Gets the current value of an observable, or undefined if the observable has
|
|
7540
7528
|
* not emitted a value yet.
|
|
@@ -7977,71 +7965,29 @@ class CallState {
|
|
|
7977
7965
|
*
|
|
7978
7966
|
*/
|
|
7979
7967
|
constructor() {
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
this.
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7968
|
+
this.backstageSubject = new BehaviorSubject(false);
|
|
7969
|
+
this.blockedUserIdsSubject = new BehaviorSubject([]);
|
|
7970
|
+
this.createdAtSubject = new BehaviorSubject(new Date());
|
|
7971
|
+
this.endedAtSubject = new BehaviorSubject(undefined);
|
|
7972
|
+
this.startsAtSubject = new BehaviorSubject(undefined);
|
|
7973
|
+
this.updatedAtSubject = new BehaviorSubject(new Date());
|
|
7974
|
+
this.createdBySubject = new BehaviorSubject(undefined);
|
|
7975
|
+
this.customSubject = new BehaviorSubject({});
|
|
7976
|
+
this.egressSubject = new BehaviorSubject(undefined);
|
|
7977
|
+
this.ingressSubject = new BehaviorSubject(undefined);
|
|
7978
|
+
this.recordingSubject = new BehaviorSubject(false);
|
|
7979
|
+
this.sessionSubject = new BehaviorSubject(undefined);
|
|
7980
|
+
this.settingsSubject = new BehaviorSubject(undefined);
|
|
7981
|
+
this.transcribingSubject = new BehaviorSubject(false);
|
|
7982
|
+
this.endedBySubject = new BehaviorSubject(undefined);
|
|
7991
7983
|
this.membersSubject = new BehaviorSubject([]);
|
|
7992
|
-
/**
|
|
7993
|
-
* The list of capabilities of the current user.
|
|
7994
|
-
*
|
|
7995
|
-
* @private
|
|
7996
|
-
*/
|
|
7997
7984
|
this.ownCapabilitiesSubject = new BehaviorSubject([]);
|
|
7998
|
-
/**
|
|
7999
|
-
* The calling state.
|
|
8000
|
-
*
|
|
8001
|
-
* @internal
|
|
8002
|
-
*/
|
|
8003
7985
|
this.callingStateSubject = new BehaviorSubject(CallingState.UNKNOWN);
|
|
8004
|
-
/**
|
|
8005
|
-
* The time the call session actually started.
|
|
8006
|
-
*
|
|
8007
|
-
* @internal
|
|
8008
|
-
*/
|
|
8009
7986
|
this.startedAtSubject = new BehaviorSubject(undefined);
|
|
8010
|
-
/**
|
|
8011
|
-
* The server-side counted number of participants connected to the current call.
|
|
8012
|
-
* This number includes the anonymous participants as well.
|
|
8013
|
-
*
|
|
8014
|
-
* @internal
|
|
8015
|
-
*/
|
|
8016
7987
|
this.participantCountSubject = new BehaviorSubject(0);
|
|
8017
|
-
/**
|
|
8018
|
-
* The server-side counted number of anonymous participants connected to the current call.
|
|
8019
|
-
* This number excludes the regular participants.
|
|
8020
|
-
*
|
|
8021
|
-
* @internal
|
|
8022
|
-
*/
|
|
8023
7988
|
this.anonymousParticipantCountSubject = new BehaviorSubject(0);
|
|
8024
|
-
/**
|
|
8025
|
-
* All participants of the current call (including the logged-in user).
|
|
8026
|
-
*
|
|
8027
|
-
* @internal
|
|
8028
|
-
*/
|
|
8029
7989
|
this.participantsSubject = new BehaviorSubject([]);
|
|
8030
|
-
/**
|
|
8031
|
-
* The latest stats report of the current call.
|
|
8032
|
-
* When stats gathering is enabled, this observable will emit a new value
|
|
8033
|
-
* at a regular (configurable) interval.
|
|
8034
|
-
*
|
|
8035
|
-
* Consumers of this observable can implement their own batching logic
|
|
8036
|
-
* in case they want to show historical stat data.
|
|
8037
|
-
*
|
|
8038
|
-
* @internal
|
|
8039
|
-
*/
|
|
8040
7990
|
this.callStatsReportSubject = new BehaviorSubject(undefined);
|
|
8041
|
-
/**
|
|
8042
|
-
* Emits a list of details about recordings performed for the current call.
|
|
8043
|
-
*/
|
|
8044
|
-
this.callRecordingListSubject = new BehaviorSubject([]);
|
|
8045
7991
|
/**
|
|
8046
7992
|
* A list of comparators that are used to sort the participants.
|
|
8047
7993
|
*
|
|
@@ -8124,15 +8070,6 @@ class CallState {
|
|
|
8124
8070
|
this.setCallingState = (state) => {
|
|
8125
8071
|
return this.setCurrentValue(this.callingStateSubject, state);
|
|
8126
8072
|
};
|
|
8127
|
-
/**
|
|
8128
|
-
* Sets the list of call recordings.
|
|
8129
|
-
*
|
|
8130
|
-
* @internal
|
|
8131
|
-
* @param recordings the list of call recordings.
|
|
8132
|
-
*/
|
|
8133
|
-
this.setCallRecordingsList = (recordings) => {
|
|
8134
|
-
return this.setCurrentValue(this.callRecordingListSubject, recordings);
|
|
8135
|
-
};
|
|
8136
8073
|
/**
|
|
8137
8074
|
* Sets the call stats report.
|
|
8138
8075
|
*
|
|
@@ -8142,16 +8079,6 @@ class CallState {
|
|
|
8142
8079
|
this.setCallStatsReport = (report) => {
|
|
8143
8080
|
return this.setCurrentValue(this.callStatsReportSubject, report);
|
|
8144
8081
|
};
|
|
8145
|
-
/**
|
|
8146
|
-
* Sets the metadata of the current call.
|
|
8147
|
-
*
|
|
8148
|
-
* @internal
|
|
8149
|
-
*
|
|
8150
|
-
* @param metadata the metadata to set.
|
|
8151
|
-
*/
|
|
8152
|
-
this.setMetadata = (metadata) => {
|
|
8153
|
-
return this.setCurrentValue(this.metadataSubject, metadata);
|
|
8154
|
-
};
|
|
8155
8082
|
/**
|
|
8156
8083
|
* Sets the members of the current call.
|
|
8157
8084
|
*
|
|
@@ -8250,6 +8177,19 @@ class CallState {
|
|
|
8250
8177
|
return p;
|
|
8251
8178
|
}));
|
|
8252
8179
|
};
|
|
8180
|
+
/**
|
|
8181
|
+
* Updates the call state with the data received from the server.
|
|
8182
|
+
*
|
|
8183
|
+
* @internal
|
|
8184
|
+
*
|
|
8185
|
+
* @param event the video event that our backend sent us.
|
|
8186
|
+
*/
|
|
8187
|
+
this.updateFromEvent = (event) => {
|
|
8188
|
+
const update = this.eventHandlers[event.type];
|
|
8189
|
+
if (update) {
|
|
8190
|
+
update(event);
|
|
8191
|
+
}
|
|
8192
|
+
};
|
|
8253
8193
|
/**
|
|
8254
8194
|
* Updates the participant pinned state with server side pinning data.
|
|
8255
8195
|
*
|
|
@@ -8278,25 +8218,174 @@ class CallState {
|
|
|
8278
8218
|
return participant;
|
|
8279
8219
|
}));
|
|
8280
8220
|
};
|
|
8281
|
-
|
|
8221
|
+
/**
|
|
8222
|
+
* Updates the call state with the data received from the server.
|
|
8223
|
+
*
|
|
8224
|
+
* @internal
|
|
8225
|
+
*
|
|
8226
|
+
* @param call the call response from the server.
|
|
8227
|
+
*/
|
|
8228
|
+
this.updateFromCallResponse = (call) => {
|
|
8229
|
+
this.setCurrentValue(this.backstageSubject, call.backstage);
|
|
8230
|
+
this.setCurrentValue(this.blockedUserIdsSubject, call.blocked_user_ids);
|
|
8231
|
+
this.setCurrentValue(this.createdAtSubject, new Date(call.created_at));
|
|
8232
|
+
this.setCurrentValue(this.updatedAtSubject, new Date(call.updated_at));
|
|
8233
|
+
this.setCurrentValue(this.startsAtSubject, call.starts_at ? new Date(call.starts_at) : undefined);
|
|
8234
|
+
this.setCurrentValue(this.endedAtSubject, call.ended_at ? new Date(call.ended_at) : undefined);
|
|
8235
|
+
this.setCurrentValue(this.createdBySubject, call.created_by);
|
|
8236
|
+
this.setCurrentValue(this.customSubject, call.custom);
|
|
8237
|
+
this.setCurrentValue(this.egressSubject, call.egress);
|
|
8238
|
+
this.setCurrentValue(this.ingressSubject, call.ingress);
|
|
8239
|
+
this.setCurrentValue(this.recordingSubject, call.recording);
|
|
8240
|
+
this.setCurrentValue(this.sessionSubject, call.session);
|
|
8241
|
+
this.setCurrentValue(this.settingsSubject, call.settings);
|
|
8242
|
+
this.setCurrentValue(this.transcribingSubject, call.transcribing);
|
|
8243
|
+
};
|
|
8244
|
+
this.updateFromMemberRemoved = (event) => {
|
|
8245
|
+
this.setCurrentValue(this.membersSubject, (members) => members.filter((m) => event.members.indexOf(m.user_id) === -1));
|
|
8246
|
+
};
|
|
8247
|
+
this.updateFromMemberAdded = (event) => {
|
|
8248
|
+
this.setCurrentValue(this.membersSubject, (members) => [
|
|
8249
|
+
...members,
|
|
8250
|
+
...event.members,
|
|
8251
|
+
]);
|
|
8252
|
+
};
|
|
8253
|
+
this.updateFromBroadcastStopped = () => {
|
|
8254
|
+
this.setCurrentValue(this.egressSubject, (egress) => (Object.assign(Object.assign({}, egress), { broadcasting: false })));
|
|
8255
|
+
};
|
|
8256
|
+
this.updateFromBroadcastStarted = (event) => {
|
|
8257
|
+
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 }) })));
|
|
8258
|
+
};
|
|
8259
|
+
this.updateFromSessionParticipantLeft = (event) => {
|
|
8260
|
+
this.setCurrentValue(this.sessionSubject, (session) => {
|
|
8261
|
+
if (!session) {
|
|
8262
|
+
this.logger('warn', `Received call.session_participant_left event but no session is available.`, event);
|
|
8263
|
+
return session;
|
|
8264
|
+
}
|
|
8265
|
+
const { participants, participants_count_by_role } = session;
|
|
8266
|
+
const { user, user_session_id } = event.participant;
|
|
8267
|
+
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) }) });
|
|
8268
|
+
});
|
|
8269
|
+
};
|
|
8270
|
+
this.updateFromSessionParticipantJoined = (event) => {
|
|
8271
|
+
this.setCurrentValue(this.sessionSubject, (session) => {
|
|
8272
|
+
if (!session) {
|
|
8273
|
+
this.logger('warn', `Received call.session_participant_joined event but no session is available.`, event);
|
|
8274
|
+
return session;
|
|
8275
|
+
}
|
|
8276
|
+
const { participants, participants_count_by_role } = session;
|
|
8277
|
+
const { user } = event.participant;
|
|
8278
|
+
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 }) });
|
|
8279
|
+
});
|
|
8280
|
+
};
|
|
8281
|
+
this.updateMembers = (event) => {
|
|
8282
|
+
this.setCurrentValue(this.membersSubject, (members) => members.map((member) => {
|
|
8283
|
+
const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
|
|
8284
|
+
return memberUpdate ? memberUpdate : member;
|
|
8285
|
+
}));
|
|
8286
|
+
};
|
|
8287
|
+
this.updateParticipantReaction = (event) => {
|
|
8288
|
+
const { user, custom, type, emoji_code } = event.reaction;
|
|
8289
|
+
this.setParticipants((participants) => {
|
|
8290
|
+
return participants.map((p) => {
|
|
8291
|
+
// skip if the reaction is not for this participant
|
|
8292
|
+
if (p.userId !== user.id)
|
|
8293
|
+
return p;
|
|
8294
|
+
// update the participant with the new reaction
|
|
8295
|
+
return Object.assign(Object.assign({}, p), { reaction: {
|
|
8296
|
+
type,
|
|
8297
|
+
emoji_code,
|
|
8298
|
+
custom,
|
|
8299
|
+
} });
|
|
8300
|
+
});
|
|
8301
|
+
});
|
|
8302
|
+
};
|
|
8303
|
+
this.unblockUser = (event) => {
|
|
8304
|
+
this.setCurrentValue(this.blockedUserIdsSubject, (current) => {
|
|
8305
|
+
if (!current)
|
|
8306
|
+
return current;
|
|
8307
|
+
return current.filter((id) => id !== event.user.id);
|
|
8308
|
+
});
|
|
8309
|
+
};
|
|
8310
|
+
this.blockUser = (event) => {
|
|
8311
|
+
this.setCurrentValue(this.blockedUserIdsSubject, (current) => [
|
|
8312
|
+
...(current || []),
|
|
8313
|
+
event.user.id,
|
|
8314
|
+
]);
|
|
8315
|
+
};
|
|
8316
|
+
this.updateOwnCapabilities = (event) => {
|
|
8317
|
+
var _a;
|
|
8318
|
+
if (event.user.id === ((_a = this.localParticipant) === null || _a === void 0 ? void 0 : _a.userId)) {
|
|
8319
|
+
this.setCurrentValue(this.ownCapabilitiesSubject, event.own_capabilities);
|
|
8320
|
+
}
|
|
8321
|
+
};
|
|
8322
|
+
this.logger = getLogger(['CallState']);
|
|
8282
8323
|
this.participants$ = this.participantsSubject.pipe(map$1((ps) => ps.sort(this.sortParticipantsBy)));
|
|
8283
8324
|
this.localParticipant$ = this.participants$.pipe(map$1((participants) => participants.find(isStreamVideoLocalParticipant)));
|
|
8284
8325
|
this.remoteParticipants$ = this.participants$.pipe(map$1((participants) => participants.filter((p) => !p.isLocalParticipant)));
|
|
8285
8326
|
this.pinnedParticipants$ = this.participants$.pipe(map$1((participants) => participants.filter((p) => !!p.pin)));
|
|
8286
8327
|
this.dominantSpeaker$ = this.participants$.pipe(map$1((participants) => participants.find((p) => p.isDominantSpeaker)));
|
|
8287
|
-
this.hasOngoingScreenShare$ = this.participants$.pipe(map$1((participants) =>
|
|
8288
|
-
return participants.some((p) => p.publishedTracks.includes(TrackType.SCREEN_SHARE));
|
|
8289
|
-
}), distinctUntilChanged());
|
|
8328
|
+
this.hasOngoingScreenShare$ = this.participants$.pipe(map$1((participants) => participants.some((p) => p.publishedTracks.includes(TrackType.SCREEN_SHARE))), distinctUntilChanged());
|
|
8290
8329
|
this.startedAt$ = this.startedAtSubject.asObservable();
|
|
8291
8330
|
this.participantCount$ = this.participantCountSubject.asObservable();
|
|
8292
8331
|
this.anonymousParticipantCount$ =
|
|
8293
8332
|
this.anonymousParticipantCountSubject.asObservable();
|
|
8294
8333
|
this.callStatsReport$ = this.callStatsReportSubject.asObservable();
|
|
8295
|
-
this.callRecordingList$ = this.callRecordingListSubject.asObservable();
|
|
8296
|
-
this.metadata$ = this.metadataSubject.asObservable();
|
|
8297
8334
|
this.members$ = this.membersSubject.asObservable();
|
|
8298
8335
|
this.ownCapabilities$ = this.ownCapabilitiesSubject.asObservable();
|
|
8299
8336
|
this.callingState$ = this.callingStateSubject.asObservable();
|
|
8337
|
+
this.backstage$ = this.backstageSubject.asObservable();
|
|
8338
|
+
this.blockedUserIds$ = this.blockedUserIdsSubject.asObservable();
|
|
8339
|
+
this.createdAt$ = this.createdAtSubject.asObservable();
|
|
8340
|
+
this.endedAt$ = this.endedAtSubject.asObservable();
|
|
8341
|
+
this.startsAt$ = this.startsAtSubject.asObservable();
|
|
8342
|
+
this.updatedAt$ = this.updatedAtSubject.asObservable();
|
|
8343
|
+
this.createdBy$ = this.createdBySubject.asObservable();
|
|
8344
|
+
this.custom$ = this.customSubject.asObservable();
|
|
8345
|
+
this.egress$ = this.egressSubject.asObservable();
|
|
8346
|
+
this.ingress$ = this.ingressSubject.asObservable();
|
|
8347
|
+
this.recording$ = this.recordingSubject.asObservable();
|
|
8348
|
+
this.session$ = this.sessionSubject.asObservable();
|
|
8349
|
+
this.settings$ = this.settingsSubject.asObservable();
|
|
8350
|
+
this.transcribing$ = this.transcribingSubject.asObservable();
|
|
8351
|
+
this.endedBy$ = this.endedBySubject.asObservable();
|
|
8352
|
+
this.eventHandlers = {
|
|
8353
|
+
// these events are not updating the call state:
|
|
8354
|
+
'call.permission_request': undefined,
|
|
8355
|
+
'call.user_muted': undefined,
|
|
8356
|
+
'connection.error': undefined,
|
|
8357
|
+
'connection.ok': undefined,
|
|
8358
|
+
'health.check': undefined,
|
|
8359
|
+
custom: undefined,
|
|
8360
|
+
// events that update call state:
|
|
8361
|
+
'call.accepted': (e) => this.updateFromCallResponse(e.call),
|
|
8362
|
+
'call.created': (e) => this.updateFromCallResponse(e.call),
|
|
8363
|
+
'call.notification': (e) => this.updateFromCallResponse(e.call),
|
|
8364
|
+
'call.rejected': (e) => this.updateFromCallResponse(e.call),
|
|
8365
|
+
'call.ring': (e) => this.updateFromCallResponse(e.call),
|
|
8366
|
+
'call.live_started': (e) => this.updateFromCallResponse(e.call),
|
|
8367
|
+
'call.updated': (e) => this.updateFromCallResponse(e.call),
|
|
8368
|
+
'call.session_started': (e) => this.updateFromCallResponse(e.call),
|
|
8369
|
+
'call.session_ended': (e) => this.updateFromCallResponse(e.call),
|
|
8370
|
+
'call.ended': (e) => {
|
|
8371
|
+
this.updateFromCallResponse(e.call);
|
|
8372
|
+
this.setCurrentValue(this.endedBySubject, e.user);
|
|
8373
|
+
},
|
|
8374
|
+
'call.recording_started': () => this.setCurrentValue(this.recordingSubject, true),
|
|
8375
|
+
'call.recording_stopped': () => this.setCurrentValue(this.recordingSubject, false),
|
|
8376
|
+
'call.broadcasting_started': this.updateFromBroadcastStarted,
|
|
8377
|
+
'call.broadcasting_stopped': this.updateFromBroadcastStopped,
|
|
8378
|
+
'call.session_participant_joined': this.updateFromSessionParticipantJoined,
|
|
8379
|
+
'call.session_participant_left': this.updateFromSessionParticipantLeft,
|
|
8380
|
+
'call.blocked_user': this.blockUser,
|
|
8381
|
+
'call.unblocked_user': this.unblockUser,
|
|
8382
|
+
'call.permissions_updated': this.updateOwnCapabilities,
|
|
8383
|
+
'call.member_added': this.updateFromMemberAdded,
|
|
8384
|
+
'call.member_removed': this.updateFromMemberRemoved,
|
|
8385
|
+
'call.member_updated': this.updateMembers,
|
|
8386
|
+
'call.member_updated_permission': this.updateMembers,
|
|
8387
|
+
'call.reaction_new': this.updateParticipantReaction,
|
|
8388
|
+
};
|
|
8300
8389
|
}
|
|
8301
8390
|
/**
|
|
8302
8391
|
* The server-side counted number of participants connected to the current call.
|
|
@@ -8361,24 +8450,12 @@ class CallState {
|
|
|
8361
8450
|
get callingState() {
|
|
8362
8451
|
return this.getCurrentValue(this.callingState$);
|
|
8363
8452
|
}
|
|
8364
|
-
/**
|
|
8365
|
-
* The list of call recordings.
|
|
8366
|
-
*/
|
|
8367
|
-
get callRecordingsList() {
|
|
8368
|
-
return this.getCurrentValue(this.callRecordingList$);
|
|
8369
|
-
}
|
|
8370
8453
|
/**
|
|
8371
8454
|
* The call stats report.
|
|
8372
8455
|
*/
|
|
8373
8456
|
get callStatsReport() {
|
|
8374
8457
|
return this.getCurrentValue(this.callStatsReport$);
|
|
8375
8458
|
}
|
|
8376
|
-
/**
|
|
8377
|
-
* The metadata of the current call.
|
|
8378
|
-
*/
|
|
8379
|
-
get metadata() {
|
|
8380
|
-
return this.getCurrentValue(this.metadata$);
|
|
8381
|
-
}
|
|
8382
8459
|
/**
|
|
8383
8460
|
* The members of the current call.
|
|
8384
8461
|
*/
|
|
@@ -8391,6 +8468,96 @@ class CallState {
|
|
|
8391
8468
|
get ownCapabilities() {
|
|
8392
8469
|
return this.getCurrentValue(this.ownCapabilities$);
|
|
8393
8470
|
}
|
|
8471
|
+
/**
|
|
8472
|
+
* The backstage state.
|
|
8473
|
+
*/
|
|
8474
|
+
get backstage() {
|
|
8475
|
+
return this.getCurrentValue(this.backstage$);
|
|
8476
|
+
}
|
|
8477
|
+
/**
|
|
8478
|
+
* Will provide the list of blocked user IDs.
|
|
8479
|
+
*/
|
|
8480
|
+
get blockedUserIds() {
|
|
8481
|
+
return this.getCurrentValue(this.blockedUserIds$);
|
|
8482
|
+
}
|
|
8483
|
+
/**
|
|
8484
|
+
* Will provide the time when this call has been created.
|
|
8485
|
+
*/
|
|
8486
|
+
get createdAt() {
|
|
8487
|
+
return this.getCurrentValue(this.createdAt$);
|
|
8488
|
+
}
|
|
8489
|
+
/**
|
|
8490
|
+
* Will provide the time when this call has been ended.
|
|
8491
|
+
*/
|
|
8492
|
+
get endedAt() {
|
|
8493
|
+
return this.getCurrentValue(this.endedAt$);
|
|
8494
|
+
}
|
|
8495
|
+
/**
|
|
8496
|
+
* Will provide the time when this call has been scheduled to start.
|
|
8497
|
+
*/
|
|
8498
|
+
get startsAt() {
|
|
8499
|
+
return this.getCurrentValue(this.startsAt$);
|
|
8500
|
+
}
|
|
8501
|
+
/**
|
|
8502
|
+
* Will provide the time when this call has been updated.
|
|
8503
|
+
*/
|
|
8504
|
+
get updatedAt() {
|
|
8505
|
+
return this.getCurrentValue(this.updatedAt$);
|
|
8506
|
+
}
|
|
8507
|
+
/**
|
|
8508
|
+
* Will provide the user who created this call.
|
|
8509
|
+
*/
|
|
8510
|
+
get createdBy() {
|
|
8511
|
+
return this.getCurrentValue(this.createdBy$);
|
|
8512
|
+
}
|
|
8513
|
+
/**
|
|
8514
|
+
* Will provide the custom data of this call.
|
|
8515
|
+
*/
|
|
8516
|
+
get custom() {
|
|
8517
|
+
return this.getCurrentValue(this.custom$);
|
|
8518
|
+
}
|
|
8519
|
+
/**
|
|
8520
|
+
* Will provide the egress data of this call.
|
|
8521
|
+
*/
|
|
8522
|
+
get egress() {
|
|
8523
|
+
return this.getCurrentValue(this.egress$);
|
|
8524
|
+
}
|
|
8525
|
+
/**
|
|
8526
|
+
* Will provide the ingress data of this call.
|
|
8527
|
+
*/
|
|
8528
|
+
get ingress() {
|
|
8529
|
+
return this.getCurrentValue(this.ingress$);
|
|
8530
|
+
}
|
|
8531
|
+
/**
|
|
8532
|
+
* Will provide the recording state of this call.
|
|
8533
|
+
*/
|
|
8534
|
+
get recording() {
|
|
8535
|
+
return this.getCurrentValue(this.recording$);
|
|
8536
|
+
}
|
|
8537
|
+
/**
|
|
8538
|
+
* Will provide the session data of this call.
|
|
8539
|
+
*/
|
|
8540
|
+
get session() {
|
|
8541
|
+
return this.getCurrentValue(this.session$);
|
|
8542
|
+
}
|
|
8543
|
+
/**
|
|
8544
|
+
* Will provide the settings of this call.
|
|
8545
|
+
*/
|
|
8546
|
+
get settings() {
|
|
8547
|
+
return this.getCurrentValue(this.settings$);
|
|
8548
|
+
}
|
|
8549
|
+
/**
|
|
8550
|
+
* Will provide the transcribing state of this call.
|
|
8551
|
+
*/
|
|
8552
|
+
get transcribing() {
|
|
8553
|
+
return this.getCurrentValue(this.transcribing$);
|
|
8554
|
+
}
|
|
8555
|
+
/**
|
|
8556
|
+
* Will provide the user who ended this call.
|
|
8557
|
+
*/
|
|
8558
|
+
get endedBy() {
|
|
8559
|
+
return this.getCurrentValue(this.endedBy$);
|
|
8560
|
+
}
|
|
8394
8561
|
}
|
|
8395
8562
|
|
|
8396
8563
|
/**
|
|
@@ -8462,40 +8629,16 @@ const watchCallEnded = (call) => {
|
|
|
8462
8629
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8463
8630
|
if (event.type !== 'call.ended')
|
|
8464
8631
|
return;
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8632
|
+
const { callingState } = call.state;
|
|
8633
|
+
if (callingState === CallingState.RINGING ||
|
|
8634
|
+
callingState === CallingState.JOINED ||
|
|
8635
|
+
callingState === CallingState.JOINING) {
|
|
8469
8636
|
yield call.leave();
|
|
8470
8637
|
}
|
|
8471
8638
|
});
|
|
8472
8639
|
};
|
|
8473
8640
|
};
|
|
8474
|
-
/**
|
|
8475
|
-
* An event handler which listens to `call.updated` events
|
|
8476
|
-
* and updates the given call state accordingly.
|
|
8477
|
-
*/
|
|
8478
|
-
const watchCallUpdated = (state) => {
|
|
8479
|
-
return function onCallUpdated(event) {
|
|
8480
|
-
if (event.type !== 'call.updated')
|
|
8481
|
-
return;
|
|
8482
|
-
state.setMetadata(event.call);
|
|
8483
|
-
};
|
|
8484
|
-
};
|
|
8485
8641
|
|
|
8486
|
-
/**
|
|
8487
|
-
* Event handler that watches for `call.permissions_updated` events
|
|
8488
|
-
*/
|
|
8489
|
-
const watchCallPermissionsUpdated = (state) => {
|
|
8490
|
-
return function onCallPermissionsUpdated(event) {
|
|
8491
|
-
if (event.type !== 'call.permissions_updated')
|
|
8492
|
-
return;
|
|
8493
|
-
const { localParticipant } = state;
|
|
8494
|
-
if (event.user.id === (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.userId)) {
|
|
8495
|
-
state.setOwnCapabilities(event.own_capabilities);
|
|
8496
|
-
}
|
|
8497
|
-
};
|
|
8498
|
-
};
|
|
8499
8642
|
/**
|
|
8500
8643
|
* Event handler that watches for `callGrantsUpdated` events.
|
|
8501
8644
|
*
|
|
@@ -8609,57 +8752,6 @@ const watchPinsUpdated = (state) => {
|
|
|
8609
8752
|
};
|
|
8610
8753
|
};
|
|
8611
8754
|
|
|
8612
|
-
/**
|
|
8613
|
-
* Watches for `call.member_added` events.
|
|
8614
|
-
*/
|
|
8615
|
-
const watchCallMemberAdded = (state) => {
|
|
8616
|
-
return function onCallMemberAdded(event) {
|
|
8617
|
-
if (event.type !== 'call.member_added')
|
|
8618
|
-
return;
|
|
8619
|
-
state.setMembers((members) => [...members, ...event.members]);
|
|
8620
|
-
};
|
|
8621
|
-
};
|
|
8622
|
-
/**
|
|
8623
|
-
* Watches for `call.member_removed` events.
|
|
8624
|
-
*/
|
|
8625
|
-
const watchCallMemberRemoved = (state) => {
|
|
8626
|
-
return function onCallMemberRemoved(event) {
|
|
8627
|
-
if (event.type !== 'call.member_removed')
|
|
8628
|
-
return;
|
|
8629
|
-
state.setMembers((members) => members.filter((m) => event.members.indexOf(m.user_id) === -1));
|
|
8630
|
-
};
|
|
8631
|
-
};
|
|
8632
|
-
/**
|
|
8633
|
-
* Watches for `call.member_updated_permission` events.
|
|
8634
|
-
*/
|
|
8635
|
-
const watchCallMemberUpdatedPermission = (state) => {
|
|
8636
|
-
return function onCallMemberUpdated(event) {
|
|
8637
|
-
if (event.type !== 'call.member_updated_permission')
|
|
8638
|
-
return;
|
|
8639
|
-
state.setMembers((members) => members.map((member) => {
|
|
8640
|
-
const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
|
|
8641
|
-
if (memberUpdate) {
|
|
8642
|
-
member.user.role = memberUpdate.role;
|
|
8643
|
-
member = Object.assign({}, member);
|
|
8644
|
-
}
|
|
8645
|
-
return member;
|
|
8646
|
-
}));
|
|
8647
|
-
};
|
|
8648
|
-
};
|
|
8649
|
-
/**
|
|
8650
|
-
* Watches for `call.member_updated` events.
|
|
8651
|
-
*/
|
|
8652
|
-
const watchCallMemberUpdated = (state) => {
|
|
8653
|
-
return function onCallMemberUpdated(event) {
|
|
8654
|
-
if (event.type !== 'call.member_updated')
|
|
8655
|
-
return;
|
|
8656
|
-
state.setMembers((members) => members.map((member) => {
|
|
8657
|
-
const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
|
|
8658
|
-
return memberUpdate ? memberUpdate : member;
|
|
8659
|
-
}));
|
|
8660
|
-
};
|
|
8661
|
-
};
|
|
8662
|
-
|
|
8663
8755
|
/**
|
|
8664
8756
|
* An event responder which handles the `participantJoined` event.
|
|
8665
8757
|
*/
|
|
@@ -8741,74 +8833,6 @@ const watchTrackUnpublished = (state) => {
|
|
|
8741
8833
|
};
|
|
8742
8834
|
const unique = (v, i, arr) => arr.indexOf(v) === i;
|
|
8743
8835
|
|
|
8744
|
-
/**
|
|
8745
|
-
* Watches the delivery of CallReactionEvent.
|
|
8746
|
-
*
|
|
8747
|
-
* @param state the state store to update.
|
|
8748
|
-
*/
|
|
8749
|
-
const watchNewReactions = (state) => {
|
|
8750
|
-
return function onNewReactions(event) {
|
|
8751
|
-
if (event.type !== 'call.reaction_new')
|
|
8752
|
-
return;
|
|
8753
|
-
const { reaction } = event;
|
|
8754
|
-
const { user, custom, type, emoji_code } = reaction;
|
|
8755
|
-
state.setParticipants((participants) => {
|
|
8756
|
-
return participants.map((p) => {
|
|
8757
|
-
// skip if the reaction is not for this participant
|
|
8758
|
-
if (p.userId !== user.id)
|
|
8759
|
-
return p;
|
|
8760
|
-
// update the participant with the new reaction
|
|
8761
|
-
return Object.assign(Object.assign({}, p), { reaction: {
|
|
8762
|
-
type,
|
|
8763
|
-
emoji_code,
|
|
8764
|
-
custom,
|
|
8765
|
-
} });
|
|
8766
|
-
});
|
|
8767
|
-
});
|
|
8768
|
-
};
|
|
8769
|
-
};
|
|
8770
|
-
|
|
8771
|
-
/**
|
|
8772
|
-
* Watches for `call.recording_started` events.
|
|
8773
|
-
*/
|
|
8774
|
-
const watchCallRecordingStarted = (state) => {
|
|
8775
|
-
return function onCallRecordingStarted(event) {
|
|
8776
|
-
if (event.type !== 'call.recording_started')
|
|
8777
|
-
return;
|
|
8778
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { recording: true })));
|
|
8779
|
-
};
|
|
8780
|
-
};
|
|
8781
|
-
/**
|
|
8782
|
-
* Watches for `call.recording_stopped` events.
|
|
8783
|
-
*/
|
|
8784
|
-
const watchCallRecordingStopped = (state) => {
|
|
8785
|
-
return function onCallRecordingStopped(event) {
|
|
8786
|
-
if (event.type !== 'call.recording_stopped')
|
|
8787
|
-
return;
|
|
8788
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { recording: false })));
|
|
8789
|
-
};
|
|
8790
|
-
};
|
|
8791
|
-
/**
|
|
8792
|
-
* Watches for `call.broadcasting_started` events.
|
|
8793
|
-
*/
|
|
8794
|
-
const watchCallBroadcastingStarted = (state) => {
|
|
8795
|
-
return function onCallBroadcastingStarted(event) {
|
|
8796
|
-
if (event.type !== 'call.broadcasting_started')
|
|
8797
|
-
return;
|
|
8798
|
-
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 }) }) })));
|
|
8799
|
-
};
|
|
8800
|
-
};
|
|
8801
|
-
/**
|
|
8802
|
-
* Watches for `call.broadcasting_stopped` events.
|
|
8803
|
-
*/
|
|
8804
|
-
const watchCallBroadcastingStopped = (state) => {
|
|
8805
|
-
return function onCallBroadcastingStopped(event) {
|
|
8806
|
-
if (event.type !== 'call.broadcasting_stopped')
|
|
8807
|
-
return;
|
|
8808
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { egress: Object.assign(Object.assign({}, metadata.egress), { broadcasting: false }) })));
|
|
8809
|
-
};
|
|
8810
|
-
};
|
|
8811
|
-
|
|
8812
8836
|
/**
|
|
8813
8837
|
* Watches for `dominantSpeakerChanged` events.
|
|
8814
8838
|
*/
|
|
@@ -8851,98 +8875,6 @@ const watchAudioLevelChanged = (dispatcher, state) => {
|
|
|
8851
8875
|
});
|
|
8852
8876
|
};
|
|
8853
8877
|
|
|
8854
|
-
/**
|
|
8855
|
-
* Watch for call.session_started events and update the call metadata.
|
|
8856
|
-
*
|
|
8857
|
-
* @param state the call state.
|
|
8858
|
-
*/
|
|
8859
|
-
const watchCallSessionStarted = (state) => {
|
|
8860
|
-
return function onCallSessionStarted(event) {
|
|
8861
|
-
if (event.type !== 'call.session_started')
|
|
8862
|
-
return;
|
|
8863
|
-
state.setMetadata(event.call);
|
|
8864
|
-
};
|
|
8865
|
-
};
|
|
8866
|
-
/**
|
|
8867
|
-
* Watch for call.session_ended events and update the call metadata.
|
|
8868
|
-
*
|
|
8869
|
-
* @param state the call state.
|
|
8870
|
-
*/
|
|
8871
|
-
const watchCallSessionEnded = (state) => {
|
|
8872
|
-
return function onCallSessionEnded(event) {
|
|
8873
|
-
if (event.type !== 'call.session_ended')
|
|
8874
|
-
return;
|
|
8875
|
-
state.setMetadata(event.call);
|
|
8876
|
-
};
|
|
8877
|
-
};
|
|
8878
|
-
/**
|
|
8879
|
-
* Watch for call.session_participant_joined events and update the call metadata.
|
|
8880
|
-
*
|
|
8881
|
-
* @param state the call state.
|
|
8882
|
-
*/
|
|
8883
|
-
const watchCallSessionParticipantJoined = (state) => {
|
|
8884
|
-
return function onCallParticipantJoined(event) {
|
|
8885
|
-
if (event.type !== 'call.session_participant_joined')
|
|
8886
|
-
return;
|
|
8887
|
-
const { participant } = event;
|
|
8888
|
-
state.setMetadata((metadata) => {
|
|
8889
|
-
if (!metadata || !metadata.session) {
|
|
8890
|
-
state.logger('warn', `Received call.session_participant_joined event but the metadata structure is invalid.`, event);
|
|
8891
|
-
return metadata;
|
|
8892
|
-
}
|
|
8893
|
-
const { session } = metadata;
|
|
8894
|
-
const { participants, participants_count_by_role } = session;
|
|
8895
|
-
const { user } = participant;
|
|
8896
|
-
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 }) }) });
|
|
8897
|
-
});
|
|
8898
|
-
};
|
|
8899
|
-
};
|
|
8900
|
-
/**
|
|
8901
|
-
* Watch for call.session_participant_left events and update the call metadata.
|
|
8902
|
-
*
|
|
8903
|
-
* @param state the call state.
|
|
8904
|
-
*/
|
|
8905
|
-
const watchCallSessionParticipantLeft = (state) => {
|
|
8906
|
-
return function onCallParticipantLeft(event) {
|
|
8907
|
-
if (event.type !== 'call.session_participant_left')
|
|
8908
|
-
return;
|
|
8909
|
-
const { user, user_session_id } = event.participant;
|
|
8910
|
-
state.setMetadata((metadata) => {
|
|
8911
|
-
if (!metadata || !metadata.session) {
|
|
8912
|
-
state.logger('warn', `Received call.session_participant_left event but the metadata structure is invalid.`, event);
|
|
8913
|
-
return metadata;
|
|
8914
|
-
}
|
|
8915
|
-
const { session } = metadata;
|
|
8916
|
-
const { participants, participants_count_by_role } = session;
|
|
8917
|
-
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) }) }) });
|
|
8918
|
-
});
|
|
8919
|
-
};
|
|
8920
|
-
};
|
|
8921
|
-
|
|
8922
|
-
/**
|
|
8923
|
-
* Event handler that watches for `call.blocked_user` events,
|
|
8924
|
-
* updates the call store `blocked_user_ids` property by adding
|
|
8925
|
-
* `event.user_id` to the list
|
|
8926
|
-
*/
|
|
8927
|
-
const watchBlockedUser = (state) => (event) => {
|
|
8928
|
-
if (event.type !== 'call.blocked_user')
|
|
8929
|
-
return;
|
|
8930
|
-
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] })));
|
|
8931
|
-
};
|
|
8932
|
-
/**
|
|
8933
|
-
* Event handler that watches for `call.unblocked_user` events,
|
|
8934
|
-
* updates the call store `blocked_user_ids` property by
|
|
8935
|
-
* removing `event.user_id` from the list
|
|
8936
|
-
*/
|
|
8937
|
-
const watchUnblockedUser = (state) => (event) => {
|
|
8938
|
-
if (event.type !== 'call.unblocked_user')
|
|
8939
|
-
return;
|
|
8940
|
-
state.setMetadata((metadata) => {
|
|
8941
|
-
const blocked_user_ids = ((metadata === null || metadata === void 0 ? void 0 : metadata.blocked_user_ids) || []).filter((userId) => event.user.id !== userId);
|
|
8942
|
-
return Object.assign(Object.assign({}, metadata), { blocked_user_ids });
|
|
8943
|
-
});
|
|
8944
|
-
};
|
|
8945
|
-
|
|
8946
8878
|
/**
|
|
8947
8879
|
* Registers the default event handlers for a call during its lifecycle.
|
|
8948
8880
|
*
|
|
@@ -8951,29 +8883,8 @@ const watchUnblockedUser = (state) => (event) => {
|
|
|
8951
8883
|
* @param dispatcher the dispatcher.
|
|
8952
8884
|
*/
|
|
8953
8885
|
const registerEventHandlers = (call, state, dispatcher) => {
|
|
8954
|
-
const coordinatorEvents = {
|
|
8955
|
-
'call.blocked_user': watchBlockedUser(state),
|
|
8956
|
-
'call.broadcasting_started': watchCallBroadcastingStarted(state),
|
|
8957
|
-
'call.broadcasting_stopped': watchCallBroadcastingStopped(state),
|
|
8958
|
-
'call.ended': watchCallEnded(call),
|
|
8959
|
-
'call.live_started': watchCallLiveStarted(state),
|
|
8960
|
-
'call.member_added': watchCallMemberAdded(state),
|
|
8961
|
-
'call.member_removed': watchCallMemberRemoved(state),
|
|
8962
|
-
'call.member_updated': watchCallMemberUpdated(state),
|
|
8963
|
-
'call.member_updated_permission': watchCallMemberUpdatedPermission(state),
|
|
8964
|
-
'call.permissions_updated': watchCallPermissionsUpdated(state),
|
|
8965
|
-
'call.reaction_new': watchNewReactions(state),
|
|
8966
|
-
'call.recording_started': watchCallRecordingStarted(state),
|
|
8967
|
-
'call.recording_stopped': watchCallRecordingStopped(state),
|
|
8968
|
-
'call.session_started': watchCallSessionStarted(state),
|
|
8969
|
-
'call.session_ended': watchCallSessionEnded(state),
|
|
8970
|
-
'call.session_participant_joined': watchCallSessionParticipantJoined(state),
|
|
8971
|
-
'call.session_participant_left': watchCallSessionParticipantLeft(state),
|
|
8972
|
-
'call.unblocked_user': watchUnblockedUser(state),
|
|
8973
|
-
'call.updated': watchCallUpdated(state),
|
|
8974
|
-
'call.user_muted': () => console.log('call.user_muted received'),
|
|
8975
|
-
};
|
|
8976
8886
|
const eventHandlers = [
|
|
8887
|
+
call.on('call.ended', watchCallEnded(call)),
|
|
8977
8888
|
watchLiveEnded(dispatcher, call),
|
|
8978
8889
|
watchSfuErrorReports(dispatcher),
|
|
8979
8890
|
watchChangePublishQuality(dispatcher, call),
|
|
@@ -8988,10 +8899,6 @@ const registerEventHandlers = (call, state, dispatcher) => {
|
|
|
8988
8899
|
call.on('callGrantsUpdated', watchCallGrantsUpdated(state)),
|
|
8989
8900
|
call.on('pinsUpdated', watchPinsUpdated(state)),
|
|
8990
8901
|
];
|
|
8991
|
-
Object.keys(coordinatorEvents).forEach((event) => {
|
|
8992
|
-
const eventName = event;
|
|
8993
|
-
eventHandlers.push(call.on(eventName, coordinatorEvents[eventName]));
|
|
8994
|
-
});
|
|
8995
8902
|
if (call.ringing) {
|
|
8996
8903
|
// these events are only relevant when the call is ringing
|
|
8997
8904
|
eventHandlers.push(registerRingingCallEventHandlers(call));
|
|
@@ -9621,7 +9528,7 @@ class Call {
|
|
|
9621
9528
|
* Use the [`StreamVideoClient.call`](./StreamVideoClient.md/#call)
|
|
9622
9529
|
* method to construct a `Call` instance.
|
|
9623
9530
|
*/
|
|
9624
|
-
constructor({ type, id, streamClient,
|
|
9531
|
+
constructor({ type, id, streamClient, members, ownCapabilities, sortParticipantsBy, clientStore, ringing = false, watching = false, }) {
|
|
9625
9532
|
/**
|
|
9626
9533
|
* ViewportTracker instance
|
|
9627
9534
|
*/
|
|
@@ -9700,7 +9607,7 @@ class Call {
|
|
|
9700
9607
|
if ((params === null || params === void 0 ? void 0 : params.ring) && !this.ringing) {
|
|
9701
9608
|
this.ringingSubject.next(true);
|
|
9702
9609
|
}
|
|
9703
|
-
this.state.
|
|
9610
|
+
this.state.updateFromCallResponse(response.call);
|
|
9704
9611
|
this.state.setMembers(response.members);
|
|
9705
9612
|
this.state.setOwnCapabilities(response.own_capabilities);
|
|
9706
9613
|
if (this.streamClient._hasConnectionID()) {
|
|
@@ -9719,7 +9626,7 @@ class Call {
|
|
|
9719
9626
|
if ((data === null || data === void 0 ? void 0 : data.ring) && !this.ringing) {
|
|
9720
9627
|
this.ringingSubject.next(true);
|
|
9721
9628
|
}
|
|
9722
|
-
this.state.
|
|
9629
|
+
this.state.updateFromCallResponse(response.call);
|
|
9723
9630
|
this.state.setMembers(response.members);
|
|
9724
9631
|
this.state.setOwnCapabilities(response.own_capabilities);
|
|
9725
9632
|
if (this.streamClient._hasConnectionID()) {
|
|
@@ -9800,7 +9707,7 @@ class Call {
|
|
|
9800
9707
|
let connectionConfig;
|
|
9801
9708
|
try {
|
|
9802
9709
|
const call = yield join(this.streamClient, this.type, this.id, data);
|
|
9803
|
-
this.state.
|
|
9710
|
+
this.state.updateFromCallResponse(call.metadata);
|
|
9804
9711
|
this.state.setMembers(call.members);
|
|
9805
9712
|
this.state.setOwnCapabilities(call.ownCapabilities);
|
|
9806
9713
|
connectionConfig = call.connectionConfig;
|
|
@@ -9965,7 +9872,7 @@ class Call {
|
|
|
9965
9872
|
connectionConfig,
|
|
9966
9873
|
});
|
|
9967
9874
|
}
|
|
9968
|
-
const audioSettings = (_f = this.
|
|
9875
|
+
const audioSettings = (_f = this.state.settings) === null || _f === void 0 ? void 0 : _f.audio;
|
|
9969
9876
|
const isDtxEnabled = !!(audioSettings === null || audioSettings === void 0 ? void 0 : audioSettings.opus_dtx_enabled);
|
|
9970
9877
|
const isRedEnabled = !!(audioSettings === null || audioSettings === void 0 ? void 0 : audioSettings.redundant_coding_enabled);
|
|
9971
9878
|
if (!this.publisher) {
|
|
@@ -10512,7 +10419,7 @@ class Call {
|
|
|
10512
10419
|
this.update = (updates) => __awaiter(this, void 0, void 0, function* () {
|
|
10513
10420
|
const response = yield this.streamClient.patch(`${this.streamClientBasePath}`, updates);
|
|
10514
10421
|
const { call, members, own_capabilities } = response;
|
|
10515
|
-
this.state.
|
|
10422
|
+
this.state.updateFromCallResponse(call);
|
|
10516
10423
|
this.state.setMembers(members);
|
|
10517
10424
|
this.state.setOwnCapabilities(own_capabilities);
|
|
10518
10425
|
return response;
|
|
@@ -10585,19 +10492,20 @@ class Call {
|
|
|
10585
10492
|
this.scheduleAutoDrop = () => {
|
|
10586
10493
|
if (this.dropTimeout)
|
|
10587
10494
|
clearTimeout(this.dropTimeout);
|
|
10588
|
-
const subscription = this.state.
|
|
10589
|
-
.pipe(pairwise(), tap(([
|
|
10590
|
-
|
|
10495
|
+
const subscription = this.state.settings$
|
|
10496
|
+
.pipe(pairwise(), tap(([prevSettings, currentSettings]) => {
|
|
10497
|
+
var _a;
|
|
10498
|
+
if (!currentSettings || !this.clientStore.connectedUser)
|
|
10591
10499
|
return;
|
|
10592
|
-
const isOutgoingCall = this.currentUserId ===
|
|
10500
|
+
const isOutgoingCall = this.currentUserId === ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id);
|
|
10593
10501
|
const [prevTimeoutMs, timeoutMs] = isOutgoingCall
|
|
10594
10502
|
? [
|
|
10595
|
-
|
|
10596
|
-
|
|
10503
|
+
prevSettings === null || prevSettings === void 0 ? void 0 : prevSettings.ring.auto_cancel_timeout_ms,
|
|
10504
|
+
currentSettings.ring.auto_cancel_timeout_ms,
|
|
10597
10505
|
]
|
|
10598
10506
|
: [
|
|
10599
|
-
|
|
10600
|
-
|
|
10507
|
+
prevSettings === null || prevSettings === void 0 ? void 0 : prevSettings.ring.incoming_call_timeout_ms,
|
|
10508
|
+
currentSettings.ring.incoming_call_timeout_ms,
|
|
10601
10509
|
];
|
|
10602
10510
|
if (typeof timeoutMs === 'undefined' ||
|
|
10603
10511
|
timeoutMs === prevTimeoutMs ||
|
|
@@ -10614,7 +10522,6 @@ class Call {
|
|
|
10614
10522
|
};
|
|
10615
10523
|
/**
|
|
10616
10524
|
* Retrieves the list of recordings for the current call or call session.
|
|
10617
|
-
* Updates the call state with the returned array of CallRecording objects.
|
|
10618
10525
|
*
|
|
10619
10526
|
* If `callSessionId` is provided, it will return the recordings for that call session.
|
|
10620
10527
|
* Otherwise, all recordings for the current call will be returned.
|
|
@@ -10626,9 +10533,7 @@ class Call {
|
|
|
10626
10533
|
if (callSessionId) {
|
|
10627
10534
|
endpoint = `${endpoint}/${callSessionId}`;
|
|
10628
10535
|
}
|
|
10629
|
-
|
|
10630
|
-
this.state.setCallRecordingsList(response.recordings);
|
|
10631
|
-
return response;
|
|
10536
|
+
return this.streamClient.get(`${endpoint}/recordings`);
|
|
10632
10537
|
});
|
|
10633
10538
|
/**
|
|
10634
10539
|
* Sends a custom event to all call participants.
|
|
@@ -10652,21 +10557,24 @@ class Call {
|
|
|
10652
10557
|
if (participantSorter) {
|
|
10653
10558
|
this.state.setSortParticipantsBy(participantSorter);
|
|
10654
10559
|
}
|
|
10655
|
-
this.state.setMetadata(metadata);
|
|
10656
10560
|
this.state.setMembers(members || []);
|
|
10657
10561
|
this.state.setOwnCapabilities(ownCapabilities || []);
|
|
10658
10562
|
this.state.setCallingState(ringing ? CallingState.RINGING : CallingState.IDLE);
|
|
10563
|
+
this.on('all', (event) => {
|
|
10564
|
+
// update state with the latest event data
|
|
10565
|
+
this.state.updateFromEvent(event);
|
|
10566
|
+
});
|
|
10659
10567
|
this.leaveCallHooks.push(registerEventHandlers(this, this.state, this.dispatcher));
|
|
10660
10568
|
this.registerEffects();
|
|
10661
10569
|
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); }));
|
|
10662
10570
|
}
|
|
10663
10571
|
registerEffects() {
|
|
10664
10572
|
this.leaveCallHooks.push(
|
|
10665
|
-
// handles updating the permissions context when the
|
|
10666
|
-
createSubscription(this.state.
|
|
10667
|
-
if (!
|
|
10573
|
+
// handles updating the permissions context when the settings change.
|
|
10574
|
+
createSubscription(this.state.settings$, (settings) => {
|
|
10575
|
+
if (!settings)
|
|
10668
10576
|
return;
|
|
10669
|
-
this.permissionsContext.setCallSettings(
|
|
10577
|
+
this.permissionsContext.setCallSettings(settings);
|
|
10670
10578
|
}),
|
|
10671
10579
|
// handle the case when the user permissions are modified.
|
|
10672
10580
|
createSubscription(this.state.ownCapabilities$, (ownCapabilities) => {
|
|
@@ -10690,12 +10598,11 @@ class Call {
|
|
|
10690
10598
|
}
|
|
10691
10599
|
}),
|
|
10692
10600
|
// handles the case when the user is blocked by the call owner.
|
|
10693
|
-
createSubscription(this.state.
|
|
10694
|
-
if (!
|
|
10601
|
+
createSubscription(this.state.blockedUserIds$, (blockedUserIds) => __awaiter(this, void 0, void 0, function* () {
|
|
10602
|
+
if (!blockedUserIds)
|
|
10695
10603
|
return;
|
|
10696
10604
|
const currentUserId = this.currentUserId;
|
|
10697
|
-
if (currentUserId &&
|
|
10698
|
-
metadata.blocked_user_ids.includes(currentUserId)) {
|
|
10605
|
+
if (currentUserId && blockedUserIds.includes(currentUserId)) {
|
|
10699
10606
|
this.logger('info', 'Leaving call because of being blocked');
|
|
10700
10607
|
yield this.leave();
|
|
10701
10608
|
}
|
|
@@ -10747,12 +10654,6 @@ class Call {
|
|
|
10747
10654
|
}
|
|
10748
10655
|
}
|
|
10749
10656
|
}
|
|
10750
|
-
/**
|
|
10751
|
-
* A getter for the call metadata.
|
|
10752
|
-
*/
|
|
10753
|
-
get data() {
|
|
10754
|
-
return this.state.metadata;
|
|
10755
|
-
}
|
|
10756
10657
|
/**
|
|
10757
10658
|
* A flag indicating whether the call is "ringing" type of call.
|
|
10758
10659
|
*/
|
|
@@ -10771,7 +10672,7 @@ class Call {
|
|
|
10771
10672
|
*/
|
|
10772
10673
|
get isCreatedByMe() {
|
|
10773
10674
|
var _a;
|
|
10774
|
-
return ((_a = this.state.
|
|
10675
|
+
return ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id) === this.currentUserId;
|
|
10775
10676
|
}
|
|
10776
10677
|
}
|
|
10777
10678
|
|
|
@@ -11884,7 +11785,7 @@ class WSConnectionFallback {
|
|
|
11884
11785
|
}
|
|
11885
11786
|
}
|
|
11886
11787
|
|
|
11887
|
-
const version = '0.
|
|
11788
|
+
const version = '0.3.0';
|
|
11888
11789
|
|
|
11889
11790
|
const logger = getLogger(['location']);
|
|
11890
11791
|
const HINT_URL = `https://hint.stream-io-video.com/`;
|
|
@@ -12578,12 +12479,12 @@ class StreamVideoClient {
|
|
|
12578
12479
|
streamClient: this.streamClient,
|
|
12579
12480
|
id: c.call.id,
|
|
12580
12481
|
type: c.call.type,
|
|
12581
|
-
metadata: c.call,
|
|
12582
12482
|
members: c.members,
|
|
12583
12483
|
ownCapabilities: c.own_capabilities,
|
|
12584
12484
|
watching: data.watch,
|
|
12585
12485
|
clientStore: this.writeableStateStore,
|
|
12586
12486
|
});
|
|
12487
|
+
call.state.updateFromCallResponse(c.call);
|
|
12587
12488
|
if (data.watch) {
|
|
12588
12489
|
this.writeableStateStore.registerCall(call);
|
|
12589
12490
|
}
|
|
@@ -12591,9 +12492,9 @@ class StreamVideoClient {
|
|
|
12591
12492
|
});
|
|
12592
12493
|
return Object.assign(Object.assign({}, response), { calls: calls });
|
|
12593
12494
|
});
|
|
12594
|
-
|
|
12595
|
-
|
|
12596
|
-
|
|
12495
|
+
/**
|
|
12496
|
+
* Returns a list of available data centers available for hosting calls.
|
|
12497
|
+
*/
|
|
12597
12498
|
this.edges = () => __awaiter(this, void 0, void 0, function* () {
|
|
12598
12499
|
return this.streamClient.get(`/edges`);
|
|
12599
12500
|
});
|
|
@@ -12768,14 +12669,15 @@ class StreamVideoClient {
|
|
|
12768
12669
|
return;
|
|
12769
12670
|
}
|
|
12770
12671
|
this.logger('info', `New call created and registered: ${call.cid}`);
|
|
12771
|
-
|
|
12672
|
+
const newCall = new Call({
|
|
12772
12673
|
streamClient: this.streamClient,
|
|
12773
12674
|
type: call.type,
|
|
12774
12675
|
id: call.id,
|
|
12775
|
-
metadata: call,
|
|
12776
12676
|
members,
|
|
12777
12677
|
clientStore: this.writeableStateStore,
|
|
12778
|
-
})
|
|
12678
|
+
});
|
|
12679
|
+
newCall.state.updateFromCallResponse(call);
|
|
12680
|
+
this.writeableStateStore.registerCall(newCall);
|
|
12779
12681
|
}));
|
|
12780
12682
|
this.eventHandlersToUnregister.push(this.on('call.ring', (event) => __awaiter(this, void 0, void 0, function* () {
|
|
12781
12683
|
if (event.type !== 'call.ring')
|
|
@@ -12789,7 +12691,6 @@ class StreamVideoClient {
|
|
|
12789
12691
|
// if `call.created` was received before `call.ring`.
|
|
12790
12692
|
// In that case, we cleanup the already tracked call.
|
|
12791
12693
|
const prevCall = this.writeableStateStore.findCall(call.type, call.id);
|
|
12792
|
-
const prevMetadata = prevCall === null || prevCall === void 0 ? void 0 : prevCall.state.metadata;
|
|
12793
12694
|
yield (prevCall === null || prevCall === void 0 ? void 0 : prevCall.leave());
|
|
12794
12695
|
// we create a new call
|
|
12795
12696
|
const theCall = new Call({
|
|
@@ -12799,8 +12700,8 @@ class StreamVideoClient {
|
|
|
12799
12700
|
members,
|
|
12800
12701
|
clientStore: this.writeableStateStore,
|
|
12801
12702
|
ringing: true,
|
|
12802
|
-
metadata: prevMetadata,
|
|
12803
12703
|
});
|
|
12704
|
+
theCall.state.updateFromCallResponse(call);
|
|
12804
12705
|
// we fetch the latest metadata for the call from the server
|
|
12805
12706
|
yield theCall.get();
|
|
12806
12707
|
this.writeableStateStore.registerCall(theCall);
|