@stream-io/video-client 0.0.1-alpha.88 → 0.0.1-alpha.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.es.js +383 -141
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +383 -141
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +383 -141
- package/dist/index.es.js.map +1 -1
- package/dist/src/CallDropScheduler.d.ts +0 -2
- package/dist/src/events/internal.d.ts +1 -1
- package/dist/src/events/participant.d.ts +4 -4
- package/dist/src/events/speaker.d.ts +2 -2
- package/dist/src/stats/state-store-stats-reporter.d.ts +2 -2
- package/dist/src/store/CallState.d.ts +124 -18
- package/dist/src/store/rxUtils.d.ts +3 -0
- package/dist/src/store/stateStore.d.ts +83 -4
- package/package.json +1 -1
- package/src/CallDropScheduler.ts +2 -9
- package/src/StreamVideoClient.ts +2 -8
- package/src/events/call-permissions.ts +5 -6
- package/src/events/call.ts +23 -24
- package/src/events/internal.ts +2 -2
- package/src/events/moderation.ts +5 -11
- package/src/events/participant.ts +9 -11
- package/src/events/reactions.ts +3 -3
- package/src/events/recording.ts +4 -4
- package/src/events/speaker.ts +6 -6
- package/src/rtc/Call.ts +54 -111
- package/src/stats/state-store-stats-reporter.ts +5 -9
- package/src/store/CallState.ts +198 -36
- package/src/store/__tests__/CallState.test.ts +16 -17
- package/src/store/rxUtils.ts +5 -3
- package/src/store/stateStore.ts +132 -9
package/dist/index.browser.es.js
CHANGED
|
@@ -4680,7 +4680,7 @@ const watchChangePublishQuality = (dispatcher, call) => {
|
|
|
4680
4680
|
});
|
|
4681
4681
|
});
|
|
4682
4682
|
};
|
|
4683
|
-
const watchConnectionQualityChanged = (dispatcher,
|
|
4683
|
+
const watchConnectionQualityChanged = (dispatcher, state) => {
|
|
4684
4684
|
return dispatcher.on('connectionQualityChanged', (e) => {
|
|
4685
4685
|
if (e.eventPayload.oneofKind !== 'connectionQualityChanged')
|
|
4686
4686
|
return;
|
|
@@ -4688,7 +4688,7 @@ const watchConnectionQualityChanged = (dispatcher, store) => {
|
|
|
4688
4688
|
const { connectionQualityUpdates } = connectionQualityChanged;
|
|
4689
4689
|
if (!connectionQualityUpdates)
|
|
4690
4690
|
return;
|
|
4691
|
-
|
|
4691
|
+
state.updateParticipants(connectionQualityUpdates.reduce((patches, update) => {
|
|
4692
4692
|
const { sessionId, connectionQuality } = update;
|
|
4693
4693
|
patches[sessionId] = {
|
|
4694
4694
|
connectionQuality,
|
|
@@ -4701,15 +4701,15 @@ const watchConnectionQualityChanged = (dispatcher, store) => {
|
|
|
4701
4701
|
/**
|
|
4702
4702
|
* An event responder which handles the `participantJoined` event.
|
|
4703
4703
|
*/
|
|
4704
|
-
const watchParticipantJoined = (dispatcher,
|
|
4704
|
+
const watchParticipantJoined = (dispatcher, state) => {
|
|
4705
4705
|
return dispatcher.on('participantJoined', (e) => {
|
|
4706
4706
|
if (e.eventPayload.oneofKind !== 'participantJoined')
|
|
4707
4707
|
return;
|
|
4708
4708
|
const { participant } = e.eventPayload.participantJoined;
|
|
4709
4709
|
if (!participant)
|
|
4710
4710
|
return;
|
|
4711
|
-
|
|
4712
|
-
...
|
|
4711
|
+
state.setParticipants((participants) => [
|
|
4712
|
+
...participants,
|
|
4713
4713
|
Object.assign(Object.assign({}, participant), { viewportVisibilityState: VisibilityState.UNKNOWN }),
|
|
4714
4714
|
]);
|
|
4715
4715
|
});
|
|
@@ -4717,7 +4717,7 @@ const watchParticipantJoined = (dispatcher, store) => {
|
|
|
4717
4717
|
/**
|
|
4718
4718
|
* An event responder which handles the `participantLeft` event.
|
|
4719
4719
|
*/
|
|
4720
|
-
const watchParticipantLeft = (dispatcher,
|
|
4720
|
+
const watchParticipantLeft = (dispatcher, state) => {
|
|
4721
4721
|
return dispatcher.on('participantLeft', (e) => {
|
|
4722
4722
|
if (e.eventPayload.oneofKind !== 'participantLeft')
|
|
4723
4723
|
return;
|
|
@@ -4730,19 +4730,19 @@ const watchParticipantLeft = (dispatcher, store) => {
|
|
|
4730
4730
|
// console.warn('Received participantLeft notification for a unknown call');
|
|
4731
4731
|
// return;
|
|
4732
4732
|
// }
|
|
4733
|
-
|
|
4733
|
+
state.setParticipants((participants) => participants.filter((p) => p.sessionId !== participant.sessionId));
|
|
4734
4734
|
});
|
|
4735
4735
|
};
|
|
4736
4736
|
/**
|
|
4737
4737
|
* An event responder which handles the `trackPublished` event.
|
|
4738
4738
|
* The SFU will send this event when a participant publishes a track.
|
|
4739
4739
|
*/
|
|
4740
|
-
const watchTrackPublished = (dispatcher,
|
|
4740
|
+
const watchTrackPublished = (dispatcher, state) => {
|
|
4741
4741
|
return dispatcher.on('trackPublished', (e) => {
|
|
4742
4742
|
if (e.eventPayload.oneofKind !== 'trackPublished')
|
|
4743
4743
|
return;
|
|
4744
4744
|
const { trackPublished: { type, sessionId }, } = e.eventPayload;
|
|
4745
|
-
|
|
4745
|
+
state.updateParticipant(sessionId, (p) => ({
|
|
4746
4746
|
publishedTracks: [...p.publishedTracks, type].filter(unique),
|
|
4747
4747
|
}));
|
|
4748
4748
|
});
|
|
@@ -4751,12 +4751,12 @@ const watchTrackPublished = (dispatcher, store) => {
|
|
|
4751
4751
|
* An event responder which handles the `trackUnpublished` event.
|
|
4752
4752
|
* The SFU will send this event when a participant unpublishes a track.
|
|
4753
4753
|
*/
|
|
4754
|
-
const watchTrackUnpublished = (dispatcher,
|
|
4754
|
+
const watchTrackUnpublished = (dispatcher, state) => {
|
|
4755
4755
|
return dispatcher.on('trackUnpublished', (e) => {
|
|
4756
4756
|
if (e.eventPayload.oneofKind !== 'trackUnpublished')
|
|
4757
4757
|
return;
|
|
4758
4758
|
const { trackUnpublished: { type, sessionId }, } = e.eventPayload;
|
|
4759
|
-
|
|
4759
|
+
state.updateParticipant(sessionId, (p) => ({
|
|
4760
4760
|
publishedTracks: p.publishedTracks.filter((t) => t !== type),
|
|
4761
4761
|
}));
|
|
4762
4762
|
});
|
|
@@ -4766,15 +4766,15 @@ const unique = (v, i, arr) => arr.indexOf(v) === i;
|
|
|
4766
4766
|
/**
|
|
4767
4767
|
* Watches for `dominantSpeakerChanged` events.
|
|
4768
4768
|
*/
|
|
4769
|
-
const watchDominantSpeakerChanged = (dispatcher,
|
|
4769
|
+
const watchDominantSpeakerChanged = (dispatcher, state) => {
|
|
4770
4770
|
return dispatcher.on('dominantSpeakerChanged', (e) => {
|
|
4771
|
+
var _a;
|
|
4771
4772
|
if (e.eventPayload.oneofKind !== 'dominantSpeakerChanged')
|
|
4772
4773
|
return;
|
|
4773
4774
|
const { dominantSpeakerChanged: { sessionId }, } = e.eventPayload;
|
|
4774
|
-
|
|
4775
|
-
if (sessionId === (dominantSpeaker === null || dominantSpeaker === void 0 ? void 0 : dominantSpeaker.sessionId))
|
|
4775
|
+
if (sessionId === ((_a = state.dominantSpeaker) === null || _a === void 0 ? void 0 : _a.sessionId))
|
|
4776
4776
|
return;
|
|
4777
|
-
|
|
4777
|
+
state.setParticipants((participants) => participants.map((participant) => {
|
|
4778
4778
|
// mark the new dominant speaker
|
|
4779
4779
|
if (participant.sessionId === sessionId) {
|
|
4780
4780
|
return Object.assign(Object.assign({}, participant), { isDominantSpeaker: true });
|
|
@@ -4790,12 +4790,12 @@ const watchDominantSpeakerChanged = (dispatcher, store) => {
|
|
|
4790
4790
|
/**
|
|
4791
4791
|
* Watches for `audioLevelChanged` events.
|
|
4792
4792
|
*/
|
|
4793
|
-
const watchAudioLevelChanged = (dispatcher,
|
|
4793
|
+
const watchAudioLevelChanged = (dispatcher, state) => {
|
|
4794
4794
|
return dispatcher.on('audioLevelChanged', (e) => {
|
|
4795
4795
|
if (e.eventPayload.oneofKind !== 'audioLevelChanged')
|
|
4796
4796
|
return;
|
|
4797
4797
|
const { audioLevels } = e.eventPayload.audioLevelChanged;
|
|
4798
|
-
|
|
4798
|
+
state.updateParticipants(audioLevels.reduce((patches, current) => {
|
|
4799
4799
|
patches[current.sessionId] = {
|
|
4800
4800
|
audioLevel: current.level,
|
|
4801
4801
|
isSpeaking: current.isSpeaking,
|
|
@@ -4900,14 +4900,13 @@ const getCurrentValue = (observable$) => {
|
|
|
4900
4900
|
* @return the updated value.
|
|
4901
4901
|
*/
|
|
4902
4902
|
const setCurrentValue = (subject, update) => {
|
|
4903
|
-
const currentValue = getCurrentValue(subject);
|
|
4904
4903
|
const next =
|
|
4905
4904
|
// TypeScript needs more context to infer the type of update
|
|
4906
4905
|
typeof update === 'function' && update instanceof Function
|
|
4907
|
-
? update(
|
|
4906
|
+
? update(getCurrentValue(subject))
|
|
4908
4907
|
: update;
|
|
4909
4908
|
subject.next(next);
|
|
4910
|
-
return
|
|
4909
|
+
return next;
|
|
4911
4910
|
};
|
|
4912
4911
|
|
|
4913
4912
|
var rxUtils = /*#__PURE__*/Object.freeze({
|
|
@@ -4953,13 +4952,41 @@ class StreamVideoWriteableStateStore {
|
|
|
4953
4952
|
* @return the updated value.
|
|
4954
4953
|
*/
|
|
4955
4954
|
this.setCurrentValue = setCurrentValue;
|
|
4955
|
+
/**
|
|
4956
|
+
* Sets the currently connected user.
|
|
4957
|
+
*
|
|
4958
|
+
* @internal
|
|
4959
|
+
* @param user the user to set as connected.
|
|
4960
|
+
*/
|
|
4961
|
+
this.setConnectedUser = (user) => {
|
|
4962
|
+
return this.setCurrentValue(this.connectedUserSubject, user);
|
|
4963
|
+
};
|
|
4964
|
+
/**
|
|
4965
|
+
* Sets the list of objects describing all created calls that
|
|
4966
|
+
* have not been yet accepted, rejected nor cancelled.
|
|
4967
|
+
*
|
|
4968
|
+
* @internal
|
|
4969
|
+
* @param calls the calls to set as pending.
|
|
4970
|
+
*/
|
|
4971
|
+
this.setPendingCalls = (calls) => {
|
|
4972
|
+
return this.setCurrentValue(this.pendingCallsSubject, calls);
|
|
4973
|
+
};
|
|
4974
|
+
/**
|
|
4975
|
+
* Sets a call controller instance.
|
|
4976
|
+
*
|
|
4977
|
+
* @internal
|
|
4978
|
+
* @param call the call instance.
|
|
4979
|
+
*/
|
|
4980
|
+
this.setActiveCall = (call) => {
|
|
4981
|
+
return this.setCurrentValue(this.activeCallSubject, call);
|
|
4982
|
+
};
|
|
4956
4983
|
this.incomingCalls$ = this.pendingCallsSubject.pipe(combineLatestWith(this.connectedUserSubject), map$1(([pendingCalls, connectedUser]) => pendingCalls.filter((call) => {
|
|
4957
|
-
|
|
4958
|
-
return (
|
|
4984
|
+
var _a;
|
|
4985
|
+
return ((_a = call.state.metadata) === null || _a === void 0 ? void 0 : _a.created_by.id) !== (connectedUser === null || connectedUser === void 0 ? void 0 : connectedUser.id);
|
|
4959
4986
|
})));
|
|
4960
4987
|
this.outgoingCalls$ = this.pendingCallsSubject.pipe(combineLatestWith(this.connectedUserSubject), map$1(([pendingCalls, connectedUser]) => pendingCalls.filter((call) => {
|
|
4961
|
-
|
|
4962
|
-
return (
|
|
4988
|
+
var _a;
|
|
4989
|
+
return ((_a = call.state.metadata) === null || _a === void 0 ? void 0 : _a.created_by.id) === (connectedUser === null || connectedUser === void 0 ? void 0 : connectedUser.id);
|
|
4963
4990
|
})));
|
|
4964
4991
|
this.activeCallSubject.subscribe((activeCall) => {
|
|
4965
4992
|
if (activeCall) {
|
|
@@ -4969,6 +4996,52 @@ class StreamVideoWriteableStateStore {
|
|
|
4969
4996
|
}
|
|
4970
4997
|
});
|
|
4971
4998
|
}
|
|
4999
|
+
/**
|
|
5000
|
+
* The currently connected user.
|
|
5001
|
+
*/
|
|
5002
|
+
get connectedUser() {
|
|
5003
|
+
return this.getCurrentValue(this.connectedUserSubject);
|
|
5004
|
+
}
|
|
5005
|
+
/**
|
|
5006
|
+
* A list of objects describing all created calls that
|
|
5007
|
+
* have not been yet accepted, rejected nor cancelled.
|
|
5008
|
+
*/
|
|
5009
|
+
get pendingCalls() {
|
|
5010
|
+
return this.getCurrentValue(this.pendingCallsSubject);
|
|
5011
|
+
}
|
|
5012
|
+
/**
|
|
5013
|
+
* A list of objects describing incoming calls.
|
|
5014
|
+
*/
|
|
5015
|
+
get incomingCalls() {
|
|
5016
|
+
return this.getCurrentValue(this.incomingCalls$);
|
|
5017
|
+
}
|
|
5018
|
+
/**
|
|
5019
|
+
* A list of objects describing calls initiated by the current user.
|
|
5020
|
+
*/
|
|
5021
|
+
get outgoingCalls() {
|
|
5022
|
+
return this.getCurrentValue(this.outgoingCalls$);
|
|
5023
|
+
}
|
|
5024
|
+
/**
|
|
5025
|
+
* A notification describing accepted call.
|
|
5026
|
+
*/
|
|
5027
|
+
get acceptedCall() {
|
|
5028
|
+
return this.getCurrentValue(this.acceptedCallSubject);
|
|
5029
|
+
}
|
|
5030
|
+
/**
|
|
5031
|
+
* Sets a notification describing accepted call.
|
|
5032
|
+
*
|
|
5033
|
+
* @internal
|
|
5034
|
+
* @param call the call event.
|
|
5035
|
+
*/
|
|
5036
|
+
setAcceptedCall(call) {
|
|
5037
|
+
return this.setCurrentValue(this.acceptedCallSubject, call);
|
|
5038
|
+
}
|
|
5039
|
+
/**
|
|
5040
|
+
* A call controller instance.
|
|
5041
|
+
*/
|
|
5042
|
+
get activeCall() {
|
|
5043
|
+
return this.getCurrentValue(this.activeCallSubject);
|
|
5044
|
+
}
|
|
4972
5045
|
}
|
|
4973
5046
|
/**
|
|
4974
5047
|
* A reactive store that exposes state variables in a reactive manner.
|
|
@@ -4977,6 +5050,13 @@ class StreamVideoWriteableStateStore {
|
|
|
4977
5050
|
*/
|
|
4978
5051
|
class StreamVideoReadOnlyStateStore {
|
|
4979
5052
|
constructor(store) {
|
|
5053
|
+
/**
|
|
5054
|
+
* This method allows you the get the current value of a state variable.
|
|
5055
|
+
*
|
|
5056
|
+
* @param observable the observable to get the current value of.
|
|
5057
|
+
* @returns the current value of the observable.
|
|
5058
|
+
*/
|
|
5059
|
+
this.getCurrentValue = getCurrentValue;
|
|
4980
5060
|
// convert and expose subjects as observables
|
|
4981
5061
|
this.connectedUser$ = store.connectedUserSubject.asObservable();
|
|
4982
5062
|
this.pendingCalls$ = store.pendingCallsSubject.asObservable();
|
|
@@ -4985,8 +5065,43 @@ class StreamVideoReadOnlyStateStore {
|
|
|
4985
5065
|
// re-expose observables
|
|
4986
5066
|
this.incomingCalls$ = store.incomingCalls$;
|
|
4987
5067
|
this.outgoingCalls$ = store.outgoingCalls$;
|
|
4988
|
-
|
|
4989
|
-
|
|
5068
|
+
}
|
|
5069
|
+
/**
|
|
5070
|
+
* The current user connected over WS to the backend.
|
|
5071
|
+
*/
|
|
5072
|
+
get connectedUser() {
|
|
5073
|
+
return getCurrentValue(this.connectedUser$);
|
|
5074
|
+
}
|
|
5075
|
+
/**
|
|
5076
|
+
* A list of objects describing all created calls that
|
|
5077
|
+
* have not been yet accepted, rejected nor cancelled.
|
|
5078
|
+
*/
|
|
5079
|
+
get pendingCalls() {
|
|
5080
|
+
return getCurrentValue(this.pendingCalls$);
|
|
5081
|
+
}
|
|
5082
|
+
/**
|
|
5083
|
+
* A list of objects describing incoming calls.
|
|
5084
|
+
*/
|
|
5085
|
+
get incomingCalls() {
|
|
5086
|
+
return getCurrentValue(this.incomingCalls$);
|
|
5087
|
+
}
|
|
5088
|
+
/**
|
|
5089
|
+
* A list of objects describing calls initiated by the current user.
|
|
5090
|
+
*/
|
|
5091
|
+
get outgoingCalls() {
|
|
5092
|
+
return getCurrentValue(this.outgoingCalls$);
|
|
5093
|
+
}
|
|
5094
|
+
/**
|
|
5095
|
+
* The call data describing an incoming call accepted by the current user.
|
|
5096
|
+
*/
|
|
5097
|
+
get acceptedCall() {
|
|
5098
|
+
return getCurrentValue(this.acceptedCall$);
|
|
5099
|
+
}
|
|
5100
|
+
/**
|
|
5101
|
+
* The currenlty active call.
|
|
5102
|
+
*/
|
|
5103
|
+
get activeCall() {
|
|
5104
|
+
return getCurrentValue(this.activeCall$);
|
|
4990
5105
|
}
|
|
4991
5106
|
}
|
|
4992
5107
|
|
|
@@ -5317,6 +5432,79 @@ class CallState {
|
|
|
5317
5432
|
* @return the updated value.
|
|
5318
5433
|
*/
|
|
5319
5434
|
this.setCurrentValue = setCurrentValue;
|
|
5435
|
+
/**
|
|
5436
|
+
* Sets the list of participants in the current call.
|
|
5437
|
+
*
|
|
5438
|
+
* @internal
|
|
5439
|
+
*
|
|
5440
|
+
* @param participants the list of participants.
|
|
5441
|
+
*/
|
|
5442
|
+
this.setParticipants = (participants) => {
|
|
5443
|
+
return this.setCurrentValue(this.participantsSubject, participants);
|
|
5444
|
+
};
|
|
5445
|
+
/**
|
|
5446
|
+
* Sets the calling state.
|
|
5447
|
+
*
|
|
5448
|
+
* @internal
|
|
5449
|
+
* @param state the new calling state.
|
|
5450
|
+
*/
|
|
5451
|
+
this.setCallingState = (state) => {
|
|
5452
|
+
return this.setCurrentValue(this.callingStateSubject, state);
|
|
5453
|
+
};
|
|
5454
|
+
/**
|
|
5455
|
+
* Sets the list of call recordings.
|
|
5456
|
+
*
|
|
5457
|
+
* @internal
|
|
5458
|
+
* @param recordings the list of call recordings.
|
|
5459
|
+
*/
|
|
5460
|
+
this.setCallRecordingsList = (recordings) => {
|
|
5461
|
+
return this.setCurrentValue(this.callRecordingListSubject, recordings);
|
|
5462
|
+
};
|
|
5463
|
+
/**
|
|
5464
|
+
* Sets whether a call recording is in progress.
|
|
5465
|
+
*
|
|
5466
|
+
* @param inProgress whether a call recording is in progress.
|
|
5467
|
+
*/
|
|
5468
|
+
this.setCallRecordingInProgress = (inProgress) => {
|
|
5469
|
+
return this.setCurrentValue(this.callRecordingInProgressSubject, inProgress);
|
|
5470
|
+
};
|
|
5471
|
+
/**
|
|
5472
|
+
* Sets the last call permission request.
|
|
5473
|
+
*
|
|
5474
|
+
* @internal
|
|
5475
|
+
* @param request the last call permission request.
|
|
5476
|
+
*/
|
|
5477
|
+
this.setCallPermissionRequest = (request) => {
|
|
5478
|
+
return this.setCurrentValue(this.callPermissionRequestSubject, request);
|
|
5479
|
+
};
|
|
5480
|
+
/**
|
|
5481
|
+
* Sets the call stats report.
|
|
5482
|
+
*
|
|
5483
|
+
* @internal
|
|
5484
|
+
* @param report the report to set.
|
|
5485
|
+
*/
|
|
5486
|
+
this.setCallStatsReport = (report) => {
|
|
5487
|
+
return this.setCurrentValue(this.callStatsReportSubject, report);
|
|
5488
|
+
};
|
|
5489
|
+
/**
|
|
5490
|
+
* Sets the metadata of the current call.
|
|
5491
|
+
*
|
|
5492
|
+
* @internal
|
|
5493
|
+
*
|
|
5494
|
+
* @param metadata the metadata to set.
|
|
5495
|
+
*/
|
|
5496
|
+
this.setMetadata = (metadata) => {
|
|
5497
|
+
return this.setCurrentValue(this.metadataSubject, metadata);
|
|
5498
|
+
};
|
|
5499
|
+
/**
|
|
5500
|
+
* Sets the members of the current call.
|
|
5501
|
+
*
|
|
5502
|
+
* @internal
|
|
5503
|
+
* @param members the members to set.
|
|
5504
|
+
*/
|
|
5505
|
+
this.setMembers = (members) => {
|
|
5506
|
+
this.setCurrentValue(this.membersSubject, members);
|
|
5507
|
+
};
|
|
5320
5508
|
/**
|
|
5321
5509
|
* Will try to find the participant with the given sessionId in the active call.
|
|
5322
5510
|
*
|
|
@@ -5324,8 +5512,7 @@ class CallState {
|
|
|
5324
5512
|
* @returns the participant with the given sessionId or undefined if not found.
|
|
5325
5513
|
*/
|
|
5326
5514
|
this.findParticipantBySessionId = (sessionId) => {
|
|
5327
|
-
|
|
5328
|
-
return participants.find((p) => p.sessionId === sessionId);
|
|
5515
|
+
return this.participants.find((p) => p.sessionId === sessionId);
|
|
5329
5516
|
};
|
|
5330
5517
|
/**
|
|
5331
5518
|
* Updates a participant in the active call identified by the given `sessionId`.
|
|
@@ -5345,7 +5532,7 @@ class CallState {
|
|
|
5345
5532
|
}
|
|
5346
5533
|
const thePatch = typeof patch === 'function' ? patch(participant) : patch;
|
|
5347
5534
|
const updatedParticipant = Object.assign(Object.assign({}, participant), thePatch);
|
|
5348
|
-
return this.
|
|
5535
|
+
return this.setParticipants((participants) => participants.map((p) => p.sessionId === sessionId ? updatedParticipant : p));
|
|
5349
5536
|
};
|
|
5350
5537
|
/**
|
|
5351
5538
|
* Updates all participants in the active call whose session ID is in the given `sessionIds`.
|
|
@@ -5357,10 +5544,9 @@ class CallState {
|
|
|
5357
5544
|
* @returns all participants, with all patch applied.
|
|
5358
5545
|
*/
|
|
5359
5546
|
this.updateParticipants = (patch) => {
|
|
5360
|
-
if (Object.keys(patch).length === 0)
|
|
5547
|
+
if (Object.keys(patch).length === 0)
|
|
5361
5548
|
return;
|
|
5362
|
-
|
|
5363
|
-
return this.setCurrentValue(this.participantsSubject, (participants) => participants.map((p) => {
|
|
5549
|
+
return this.setParticipants((participants) => participants.map((p) => {
|
|
5364
5550
|
const thePatch = patch[p.sessionId];
|
|
5365
5551
|
if (thePatch) {
|
|
5366
5552
|
return Object.assign(Object.assign({}, p), thePatch);
|
|
@@ -5384,16 +5570,87 @@ class CallState {
|
|
|
5384
5570
|
this.callPermissionRequestSubject.asObservable();
|
|
5385
5571
|
this.callRecordingList$ = this.callRecordingListSubject.asObservable();
|
|
5386
5572
|
this.metadata$ = this.metadataSubject.asObservable();
|
|
5387
|
-
|
|
5388
|
-
this.members$ = this.membersSubject.pipe(map$1((members) => {
|
|
5389
|
-
return members.reduce((acc, member) => {
|
|
5390
|
-
const user = member.user;
|
|
5391
|
-
acc[user.id] = user;
|
|
5392
|
-
return acc;
|
|
5393
|
-
}, {});
|
|
5394
|
-
}));
|
|
5573
|
+
this.members$ = this.membersSubject.asObservable();
|
|
5395
5574
|
this.callingState$ = this.callingStateSubject.asObservable();
|
|
5396
5575
|
}
|
|
5576
|
+
/**
|
|
5577
|
+
* The list of participants in the current call.
|
|
5578
|
+
*/
|
|
5579
|
+
get participants() {
|
|
5580
|
+
return this.getCurrentValue(this.participants$);
|
|
5581
|
+
}
|
|
5582
|
+
/**
|
|
5583
|
+
* The local participant in the current call.
|
|
5584
|
+
*/
|
|
5585
|
+
get localParticipant() {
|
|
5586
|
+
return this.getCurrentValue(this.localParticipant$);
|
|
5587
|
+
}
|
|
5588
|
+
/**
|
|
5589
|
+
* The list of remote participants in the current call.
|
|
5590
|
+
*/
|
|
5591
|
+
get remoteParticipants() {
|
|
5592
|
+
return this.getCurrentValue(this.remoteParticipants$);
|
|
5593
|
+
}
|
|
5594
|
+
/**
|
|
5595
|
+
* The dominant speaker in the current call.
|
|
5596
|
+
*/
|
|
5597
|
+
get dominantSpeaker() {
|
|
5598
|
+
return this.getCurrentValue(this.dominantSpeaker$);
|
|
5599
|
+
}
|
|
5600
|
+
/**
|
|
5601
|
+
* The list of pinned participants in the current call.
|
|
5602
|
+
*/
|
|
5603
|
+
get pinnedParticipants() {
|
|
5604
|
+
return this.getCurrentValue(this.pinnedParticipants$);
|
|
5605
|
+
}
|
|
5606
|
+
/**
|
|
5607
|
+
* Tell if there is an ongoing screen share in this call.
|
|
5608
|
+
*/
|
|
5609
|
+
get hasOngoingScreenShare() {
|
|
5610
|
+
return this.getCurrentValue(this.hasOngoingScreenShare$);
|
|
5611
|
+
}
|
|
5612
|
+
/**
|
|
5613
|
+
* The calling state.
|
|
5614
|
+
*/
|
|
5615
|
+
get callingState() {
|
|
5616
|
+
return this.getCurrentValue(this.callingState$);
|
|
5617
|
+
}
|
|
5618
|
+
/**
|
|
5619
|
+
* The list of call recordings.
|
|
5620
|
+
*/
|
|
5621
|
+
get callRecordingsList() {
|
|
5622
|
+
return this.getCurrentValue(this.callRecordingList$);
|
|
5623
|
+
}
|
|
5624
|
+
/**
|
|
5625
|
+
* Tells whether a call recording is in progress.
|
|
5626
|
+
*/
|
|
5627
|
+
get callRecordingInProgress() {
|
|
5628
|
+
return this.getCurrentValue(this.callRecordingInProgress$);
|
|
5629
|
+
}
|
|
5630
|
+
/**
|
|
5631
|
+
* The last call permission request.
|
|
5632
|
+
*/
|
|
5633
|
+
get callPermissionRequest() {
|
|
5634
|
+
return this.getCurrentValue(this.callPermissionRequest$);
|
|
5635
|
+
}
|
|
5636
|
+
/**
|
|
5637
|
+
* The call stats report.
|
|
5638
|
+
*/
|
|
5639
|
+
get callStatsReport() {
|
|
5640
|
+
return this.getCurrentValue(this.callStatsReport$);
|
|
5641
|
+
}
|
|
5642
|
+
/**
|
|
5643
|
+
* The metadata of the current call.
|
|
5644
|
+
*/
|
|
5645
|
+
get metadata() {
|
|
5646
|
+
return this.getCurrentValue(this.metadata$);
|
|
5647
|
+
}
|
|
5648
|
+
/**
|
|
5649
|
+
* The members of the current call.
|
|
5650
|
+
*/
|
|
5651
|
+
get members() {
|
|
5652
|
+
return this.getCurrentValue(this.members$);
|
|
5653
|
+
}
|
|
5397
5654
|
}
|
|
5398
5655
|
|
|
5399
5656
|
const trackTypeToParticipantStreamKey = (trackType) => {
|
|
@@ -5497,7 +5754,7 @@ const toRtcConfiguration = (config) => {
|
|
|
5497
5754
|
/**
|
|
5498
5755
|
* Creates a new StatsReporter instance that collects metrics about the ongoing call and reports them to the state store
|
|
5499
5756
|
*/
|
|
5500
|
-
const createStatsReporter = ({ subscriber, publisher,
|
|
5757
|
+
const createStatsReporter = ({ subscriber, publisher, state, edgeName, pollingIntervalInMs = 2000, }) => {
|
|
5501
5758
|
const getRawStatsForTrack = (kind, selector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5502
5759
|
if (kind === 'subscriber' && subscriber) {
|
|
5503
5760
|
return subscriber.getStats(selector);
|
|
@@ -5538,11 +5795,10 @@ const createStatsReporter = ({ subscriber, publisher, store, edgeName, pollingIn
|
|
|
5538
5795
|
*/
|
|
5539
5796
|
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5540
5797
|
var _a, _b;
|
|
5541
|
-
const participants = store.getCurrentValue(store.participantsSubject);
|
|
5542
5798
|
const participantStats = {};
|
|
5543
5799
|
const sessionIds = new Set(sessionIdsToTrack);
|
|
5544
5800
|
if (sessionIds.size > 0) {
|
|
5545
|
-
for (let participant of participants) {
|
|
5801
|
+
for (let participant of state.participants) {
|
|
5546
5802
|
if (!sessionIds.has(participant.sessionId))
|
|
5547
5803
|
continue;
|
|
5548
5804
|
const kind = participant.isLoggedInUser ? 'publisher' : 'subscriber';
|
|
@@ -5581,7 +5837,7 @@ const createStatsReporter = ({ subscriber, publisher, store, edgeName, pollingIn
|
|
|
5581
5837
|
getRawStatsForTrack('subscriber'),
|
|
5582
5838
|
getRawStatsForTrack('publisher'),
|
|
5583
5839
|
]);
|
|
5584
|
-
|
|
5840
|
+
state.setCallStatsReport({
|
|
5585
5841
|
datacenter: edgeName || 'N/A',
|
|
5586
5842
|
publisherStats,
|
|
5587
5843
|
subscriberStats,
|
|
@@ -5589,8 +5845,7 @@ const createStatsReporter = ({ subscriber, publisher, store, edgeName, pollingIn
|
|
|
5589
5845
|
publisherRawStats,
|
|
5590
5846
|
participants: participantStats,
|
|
5591
5847
|
timestamp: Date.now(),
|
|
5592
|
-
};
|
|
5593
|
-
store.setCurrentValue(store.callStatsReportSubject, statsReport);
|
|
5848
|
+
});
|
|
5594
5849
|
});
|
|
5595
5850
|
let timeoutId;
|
|
5596
5851
|
if (pollingIntervalInMs > 0) {
|
|
@@ -5948,7 +6203,7 @@ class Call {
|
|
|
5948
6203
|
*/
|
|
5949
6204
|
this.leave = () => {
|
|
5950
6205
|
var _a, _b, _c, _d;
|
|
5951
|
-
if (this.state.
|
|
6206
|
+
if (this.state.callingState === CallingState.LEFT) {
|
|
5952
6207
|
throw new Error('Cannot leave call that has already been left.');
|
|
5953
6208
|
}
|
|
5954
6209
|
(_a = this.statsReporter) === null || _a === void 0 ? void 0 : _a.stop();
|
|
@@ -5962,8 +6217,8 @@ class Call {
|
|
|
5962
6217
|
this.dispatcher.offAll();
|
|
5963
6218
|
// Call all leave call hooks, e.g. to clean up global event handlers
|
|
5964
6219
|
this.leaveCallHooks.forEach((hook) => hook());
|
|
5965
|
-
this.clientStore.
|
|
5966
|
-
this.state.
|
|
6220
|
+
this.clientStore.setActiveCall(undefined);
|
|
6221
|
+
this.state.setCallingState(CallingState.LEFT);
|
|
5967
6222
|
};
|
|
5968
6223
|
this.waitForJoinResponse = (timeout = 5000) => new Promise((resolve, reject) => {
|
|
5969
6224
|
const unsubscribe = this.on('joinResponse', (event) => {
|
|
@@ -5985,8 +6240,8 @@ class Call {
|
|
|
5985
6240
|
*/
|
|
5986
6241
|
this.watch = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
5987
6242
|
const response = yield watch(this.streamClient, this.type, this.id, data);
|
|
5988
|
-
this.state.
|
|
5989
|
-
this.state.
|
|
6243
|
+
this.state.setMetadata(response.call);
|
|
6244
|
+
this.state.setMembers(response.members);
|
|
5990
6245
|
return response;
|
|
5991
6246
|
});
|
|
5992
6247
|
/**
|
|
@@ -5996,15 +6251,15 @@ class Call {
|
|
|
5996
6251
|
*/
|
|
5997
6252
|
this.join = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
5998
6253
|
var _a;
|
|
5999
|
-
if ([CallingState.JOINED, CallingState.JOINING].includes(this.state.
|
|
6254
|
+
if ([CallingState.JOINED, CallingState.JOINING].includes(this.state.callingState)) {
|
|
6000
6255
|
throw new Error(`Illegal State: Already joined.`);
|
|
6001
6256
|
}
|
|
6002
|
-
this.state.
|
|
6257
|
+
this.state.setCallingState(CallingState.JOINING);
|
|
6003
6258
|
const call = yield join(this.streamClient, this.type, this.id, data);
|
|
6004
|
-
this.state.
|
|
6005
|
-
this.state.
|
|
6259
|
+
this.state.setMetadata(call.metadata);
|
|
6260
|
+
this.state.setMembers(call.members);
|
|
6006
6261
|
// FIXME OL: convert to a derived state
|
|
6007
|
-
this.state.
|
|
6262
|
+
this.state.setCallRecordingInProgress(call.metadata.recording);
|
|
6008
6263
|
// FIXME OL: remove once cascading is implemented
|
|
6009
6264
|
let sfuUrl = call.sfuServer.url;
|
|
6010
6265
|
if (typeof window !== 'undefined' &&
|
|
@@ -6022,10 +6277,10 @@ class Call {
|
|
|
6022
6277
|
var _b, _c, _d;
|
|
6023
6278
|
console.log(`Rejoining call ${this.cid} (${this.reconnectAttempts})...`);
|
|
6024
6279
|
this.reconnectAttempts++;
|
|
6025
|
-
this.state.
|
|
6280
|
+
this.state.setCallingState(CallingState.RECONNECTING);
|
|
6026
6281
|
// take a snapshot of the current "local participant" state
|
|
6027
6282
|
// we'll need it for restoring the previous publishing state later
|
|
6028
|
-
const localParticipant = this.state.
|
|
6283
|
+
const localParticipant = this.state.localParticipant;
|
|
6029
6284
|
(_b = this.subscriber) === null || _b === void 0 ? void 0 : _b.close();
|
|
6030
6285
|
(_c = this.publisher) === null || _c === void 0 ? void 0 : _c.stopPublishing({ stopTracks: false });
|
|
6031
6286
|
(_d = this.statsReporter) === null || _d === void 0 ? void 0 : _d.stop();
|
|
@@ -6056,12 +6311,12 @@ class Call {
|
|
|
6056
6311
|
if (this.reconnectAttempts < this.maxReconnectAttempts) {
|
|
6057
6312
|
rejoin().catch(() => {
|
|
6058
6313
|
console.log(`Rejoin failed for ${this.reconnectAttempts} times. Giving up.`);
|
|
6059
|
-
this.state.
|
|
6314
|
+
this.state.setCallingState(CallingState.RECONNECTING_FAILED);
|
|
6060
6315
|
});
|
|
6061
6316
|
}
|
|
6062
6317
|
else {
|
|
6063
6318
|
console.log('Reconnect attempts exceeded. Giving up...');
|
|
6064
|
-
this.state.
|
|
6319
|
+
this.state.setCallingState(CallingState.RECONNECTING_FAILED);
|
|
6065
6320
|
}
|
|
6066
6321
|
});
|
|
6067
6322
|
});
|
|
@@ -6071,16 +6326,15 @@ class Call {
|
|
|
6071
6326
|
const handleOnOffline = () => {
|
|
6072
6327
|
window.removeEventListener('offline', handleOnOffline);
|
|
6073
6328
|
console.log('Join: Going offline...');
|
|
6074
|
-
this.state.
|
|
6329
|
+
this.state.setCallingState(CallingState.OFFLINE);
|
|
6075
6330
|
};
|
|
6076
6331
|
const handleOnOnline = () => {
|
|
6077
6332
|
window.removeEventListener('online', handleOnOnline);
|
|
6078
|
-
if (this.state.
|
|
6079
|
-
CallingState.OFFLINE) {
|
|
6333
|
+
if (this.state.callingState === CallingState.OFFLINE) {
|
|
6080
6334
|
console.log('Join: Going online...');
|
|
6081
6335
|
rejoin().catch(() => {
|
|
6082
6336
|
console.log(`Rejoin failed for ${this.reconnectAttempts} times. Giving up.`);
|
|
6083
|
-
this.state.
|
|
6337
|
+
this.state.setCallingState(CallingState.RECONNECTING_FAILED);
|
|
6084
6338
|
});
|
|
6085
6339
|
}
|
|
6086
6340
|
};
|
|
@@ -6115,7 +6369,7 @@ class Call {
|
|
|
6115
6369
|
this.statsReporter = createStatsReporter({
|
|
6116
6370
|
subscriber: this.subscriber,
|
|
6117
6371
|
publisher: this.publisher,
|
|
6118
|
-
|
|
6372
|
+
state: this.state,
|
|
6119
6373
|
edgeName: call.sfuServer.edge_name,
|
|
6120
6374
|
});
|
|
6121
6375
|
try {
|
|
@@ -6135,12 +6389,12 @@ class Call {
|
|
|
6135
6389
|
const ownCapabilities = {
|
|
6136
6390
|
ownCapabilities: call.metadata.own_capabilities,
|
|
6137
6391
|
};
|
|
6138
|
-
this.state.
|
|
6392
|
+
this.state.setParticipants(currentParticipants.map((participant) => (Object.assign(Object.assign(Object.assign({}, participant), { isLoggedInUser: participant.sessionId === sfuClient.sessionId, viewportVisibilityState: VisibilityState.UNKNOWN }), (participant.sessionId === sfuClient.sessionId
|
|
6139
6393
|
? ownCapabilities
|
|
6140
6394
|
: {})))));
|
|
6141
|
-
this.clientStore.
|
|
6395
|
+
this.clientStore.setActiveCall(this);
|
|
6142
6396
|
this.reconnectAttempts = 0; // reset the reconnect attempts counter
|
|
6143
|
-
this.state.
|
|
6397
|
+
this.state.setCallingState(CallingState.JOINED);
|
|
6144
6398
|
console.log(`Joined call ${this.cid}`);
|
|
6145
6399
|
}
|
|
6146
6400
|
catch (err) {
|
|
@@ -6151,7 +6405,7 @@ class Call {
|
|
|
6151
6405
|
}
|
|
6152
6406
|
else {
|
|
6153
6407
|
console.log(`Rejoin failed for ${this.reconnectAttempts} times. Giving up.`);
|
|
6154
|
-
this.state.
|
|
6408
|
+
this.state.setCallingState(CallingState.RECONNECTING_FAILED);
|
|
6155
6409
|
throw new Error('Join failed');
|
|
6156
6410
|
}
|
|
6157
6411
|
}
|
|
@@ -6468,9 +6722,7 @@ class Call {
|
|
|
6468
6722
|
// example: `e3f6aaf8-b03d-4911-be36-83f47d37a76a:TRACK_TYPE_VIDEO`
|
|
6469
6723
|
const [trackId, trackType] = primaryStream.id.split(':');
|
|
6470
6724
|
console.log(`Got remote ${trackType} track:`, e.track);
|
|
6471
|
-
const participantToUpdate = this.state
|
|
6472
|
-
.getCurrentValue(this.state.participantsSubject)
|
|
6473
|
-
.find((p) => p.trackLookupPrefix === trackId);
|
|
6725
|
+
const participantToUpdate = this.state.participants.find((p) => p.trackLookupPrefix === trackId);
|
|
6474
6726
|
if (!participantToUpdate) {
|
|
6475
6727
|
console.error('Received track for unknown participant', trackId, e);
|
|
6476
6728
|
return;
|
|
@@ -6540,18 +6792,20 @@ class Call {
|
|
|
6540
6792
|
};
|
|
6541
6793
|
this.get = () => __awaiter(this, void 0, void 0, function* () {
|
|
6542
6794
|
const response = yield this.streamClient.get(this.streamClientBasePath);
|
|
6543
|
-
this.state.
|
|
6544
|
-
this.state.
|
|
6795
|
+
this.state.setMetadata(response.call);
|
|
6796
|
+
this.state.setMembers(response.members);
|
|
6545
6797
|
return response;
|
|
6546
6798
|
});
|
|
6547
6799
|
this.getOrCreate = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
6548
6800
|
const response = yield this.streamClient.post(this.streamClientBasePath, data);
|
|
6549
|
-
this.state.
|
|
6550
|
-
this.state.
|
|
6551
|
-
const
|
|
6552
|
-
const callAlreadyRegistered = currentPendingCalls.find((pendingCall) => pendingCall.id === this.id);
|
|
6801
|
+
this.state.setMetadata(response.call);
|
|
6802
|
+
this.state.setMembers(response.members);
|
|
6803
|
+
const callAlreadyRegistered = this.clientStore.pendingCalls.find((pendingCall) => pendingCall.id === this.id);
|
|
6553
6804
|
if (!callAlreadyRegistered) {
|
|
6554
|
-
this.clientStore.
|
|
6805
|
+
this.clientStore.setPendingCalls((pendingCalls) => [
|
|
6806
|
+
...pendingCalls,
|
|
6807
|
+
this,
|
|
6808
|
+
]);
|
|
6555
6809
|
}
|
|
6556
6810
|
return response;
|
|
6557
6811
|
});
|
|
@@ -6629,17 +6883,16 @@ class Call {
|
|
|
6629
6883
|
* @returns
|
|
6630
6884
|
*/
|
|
6631
6885
|
this.accept = () => __awaiter(this, void 0, void 0, function* () {
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
.find((c) => c.id === this.id && c.type === this.type);
|
|
6886
|
+
// FIXME OL: this method should be merged with the join method.
|
|
6887
|
+
const callToAccept = this.clientStore.pendingCalls.find((c) => c.id === this.id && c.type === this.type);
|
|
6635
6888
|
if (callToAccept) {
|
|
6636
6889
|
yield this.streamClient.post(`${this.streamClientBasePath}/event`, {
|
|
6637
6890
|
type: 'call.accepted',
|
|
6638
6891
|
});
|
|
6639
6892
|
// remove the accepted call from the "pending calls" list.
|
|
6640
|
-
this.clientStore.
|
|
6893
|
+
this.clientStore.setPendingCalls((pendingCalls) => pendingCalls.filter((c) => c !== callToAccept));
|
|
6641
6894
|
yield this.join();
|
|
6642
|
-
this.clientStore.
|
|
6895
|
+
this.clientStore.setActiveCall(callToAccept);
|
|
6643
6896
|
}
|
|
6644
6897
|
});
|
|
6645
6898
|
/**
|
|
@@ -6648,7 +6901,7 @@ class Call {
|
|
|
6648
6901
|
* @returns
|
|
6649
6902
|
*/
|
|
6650
6903
|
this.reject = () => __awaiter(this, void 0, void 0, function* () {
|
|
6651
|
-
this.clientStore.
|
|
6904
|
+
this.clientStore.setPendingCalls((pendingCalls) => pendingCalls.filter((c) => c.cid !== this.cid));
|
|
6652
6905
|
yield this.streamClient.post(`${this.streamClientBasePath}/event`, {
|
|
6653
6906
|
type: 'call.rejected',
|
|
6654
6907
|
});
|
|
@@ -6662,18 +6915,19 @@ class Call {
|
|
|
6662
6915
|
*/
|
|
6663
6916
|
this.cancel = () => __awaiter(this, void 0, void 0, function* () {
|
|
6664
6917
|
console.log('call cancelled');
|
|
6918
|
+
// FIXME OL: this method should be merged with the leave method.
|
|
6665
6919
|
const store = this.clientStore;
|
|
6666
|
-
const activeCall = store.
|
|
6667
|
-
const leavingActiveCall = (activeCall === null || activeCall === void 0 ? void 0 : activeCall.
|
|
6920
|
+
const activeCall = store.activeCall;
|
|
6921
|
+
const leavingActiveCall = (activeCall === null || activeCall === void 0 ? void 0 : activeCall.cid) === this.cid;
|
|
6668
6922
|
if (leavingActiveCall) {
|
|
6669
6923
|
activeCall.leave();
|
|
6670
6924
|
}
|
|
6671
6925
|
else {
|
|
6672
|
-
store.
|
|
6926
|
+
store.setPendingCalls((pendingCalls) => pendingCalls.filter((c) => c.cid !== this.cid));
|
|
6673
6927
|
}
|
|
6674
6928
|
if (activeCall) {
|
|
6675
6929
|
const state = activeCall.state;
|
|
6676
|
-
const remoteParticipants = state.
|
|
6930
|
+
const remoteParticipants = state.remoteParticipants;
|
|
6677
6931
|
if (!remoteParticipants.length && !leavingActiveCall) {
|
|
6678
6932
|
yield this.endCall();
|
|
6679
6933
|
}
|
|
@@ -6687,7 +6941,7 @@ class Call {
|
|
|
6687
6941
|
// FIXME: this is a temporary setting to take call ID as session ID
|
|
6688
6942
|
const sessionId = this.id;
|
|
6689
6943
|
const response = yield this.streamClient.get(`${this.streamClientBasePath}/${sessionId}/recordings`);
|
|
6690
|
-
this.state.
|
|
6944
|
+
this.state.setCallRecordingsList(response.recordings);
|
|
6691
6945
|
return response;
|
|
6692
6946
|
});
|
|
6693
6947
|
this.getEdgeServer = (data) => {
|
|
@@ -6704,8 +6958,8 @@ class Call {
|
|
|
6704
6958
|
this.streamClientBasePath = `/call/${this.type}/${this.id}`;
|
|
6705
6959
|
const callTypeConfig = CallTypes.get(type);
|
|
6706
6960
|
this.state = new CallState(sortParticipantsBy || callTypeConfig.options.sortParticipantsBy);
|
|
6707
|
-
this.state.
|
|
6708
|
-
this.state.
|
|
6961
|
+
this.state.setMetadata(metadata);
|
|
6962
|
+
this.state.setMembers(members || []);
|
|
6709
6963
|
registerEventHandlers(this, this.state, this.dispatcher);
|
|
6710
6964
|
this.trackSubscriptionsSubject
|
|
6711
6965
|
.pipe(debounceTime(UPDATE_SUBSCRIPTIONS_DEBOUNCE_DURATION))
|
|
@@ -6728,7 +6982,7 @@ class Call {
|
|
|
6728
6982
|
}
|
|
6729
6983
|
}
|
|
6730
6984
|
get data() {
|
|
6731
|
-
return this.state.
|
|
6985
|
+
return this.state.metadata;
|
|
6732
6986
|
}
|
|
6733
6987
|
}
|
|
6734
6988
|
|
|
@@ -6747,12 +7001,12 @@ const watchCallCreated = (store, streamClient) => {
|
|
|
6747
7001
|
console.warn("Can't find call in CallCreatedEvent");
|
|
6748
7002
|
return;
|
|
6749
7003
|
}
|
|
6750
|
-
const currentUser = store.
|
|
7004
|
+
const currentUser = store.connectedUser;
|
|
6751
7005
|
if ((currentUser === null || currentUser === void 0 ? void 0 : currentUser.id) === call.created_by.id) {
|
|
6752
7006
|
console.warn('Received CallCreatedEvent sent by the current user');
|
|
6753
7007
|
return;
|
|
6754
7008
|
}
|
|
6755
|
-
store.
|
|
7009
|
+
store.setPendingCalls((pendingCalls) => [
|
|
6756
7010
|
...pendingCalls,
|
|
6757
7011
|
new Call({
|
|
6758
7012
|
streamClient,
|
|
@@ -6780,17 +7034,13 @@ const watchCallAccepted = (store) => {
|
|
|
6780
7034
|
console.warn("Can't find call_cid in CallAcceptedEvent");
|
|
6781
7035
|
return;
|
|
6782
7036
|
}
|
|
6783
|
-
const acceptedIncomingCall = store
|
|
6784
|
-
.getCurrentValue(store.incomingCalls$)
|
|
6785
|
-
.find((incomingCall) => incomingCall.cid === call_cid);
|
|
7037
|
+
const acceptedIncomingCall = store.incomingCalls.find((incomingCall) => incomingCall.cid === call_cid);
|
|
6786
7038
|
if (acceptedIncomingCall) {
|
|
6787
7039
|
console.warn('Received CallAcceptedEvent for an incoming call');
|
|
6788
7040
|
return;
|
|
6789
7041
|
}
|
|
6790
|
-
const acceptedOutgoingCall = store
|
|
6791
|
-
|
|
6792
|
-
.find((outgoingCall) => outgoingCall.cid === call_cid);
|
|
6793
|
-
const activeCall = store.getCurrentValue(store.activeCallSubject);
|
|
7042
|
+
const acceptedOutgoingCall = store.outgoingCalls.find((outgoingCall) => outgoingCall.cid === call_cid);
|
|
7043
|
+
const activeCall = store.activeCall;
|
|
6794
7044
|
// FIXME OL: we should revisit this logic, it is hard to follow
|
|
6795
7045
|
const acceptedActiveCall = (activeCall === null || activeCall === void 0 ? void 0 : activeCall.cid) !== undefined && activeCall.cid === call_cid
|
|
6796
7046
|
? activeCall
|
|
@@ -6803,7 +7053,7 @@ const watchCallAccepted = (store) => {
|
|
|
6803
7053
|
if (call_cid === (acceptedActiveCall === null || acceptedActiveCall === void 0 ? void 0 : acceptedActiveCall.cid)) {
|
|
6804
7054
|
return;
|
|
6805
7055
|
}
|
|
6806
|
-
store.
|
|
7056
|
+
store.setAcceptedCall(event);
|
|
6807
7057
|
};
|
|
6808
7058
|
};
|
|
6809
7059
|
/**
|
|
@@ -6821,17 +7071,13 @@ const watchCallRejected = (store) => {
|
|
|
6821
7071
|
console.warn("Can't find call_cid in CallRejectedEvent");
|
|
6822
7072
|
return;
|
|
6823
7073
|
}
|
|
6824
|
-
const rejectedIncomingCall = store
|
|
6825
|
-
.getCurrentValue(store.incomingCalls$)
|
|
6826
|
-
.find((incomingCall) => incomingCall.cid === call_cid);
|
|
7074
|
+
const rejectedIncomingCall = store.incomingCalls.find((incomingCall) => incomingCall.cid === call_cid);
|
|
6827
7075
|
if (rejectedIncomingCall) {
|
|
6828
7076
|
console.warn('Received CallRejectedEvent for an incoming call');
|
|
6829
7077
|
return;
|
|
6830
7078
|
}
|
|
6831
|
-
const rejectedOutgoingCall = store
|
|
6832
|
-
|
|
6833
|
-
.find((outgoingCall) => outgoingCall.cid === call_cid);
|
|
6834
|
-
const activeCall = store.getCurrentValue(store.activeCallSubject);
|
|
7079
|
+
const rejectedOutgoingCall = store.outgoingCalls.find((outgoingCall) => outgoingCall.cid === call_cid);
|
|
7080
|
+
const activeCall = store.activeCall;
|
|
6835
7081
|
const rejectedActiveCall = (activeCall === null || activeCall === void 0 ? void 0 : activeCall.cid) !== undefined && activeCall.cid === call_cid
|
|
6836
7082
|
? activeCall
|
|
6837
7083
|
: undefined;
|
|
@@ -6839,7 +7085,7 @@ const watchCallRejected = (store) => {
|
|
|
6839
7085
|
console.warn(`CallRejectedEvent received for a non-existent outgoing call (CID: ${call_cid}`);
|
|
6840
7086
|
return;
|
|
6841
7087
|
}
|
|
6842
|
-
store.
|
|
7088
|
+
store.setPendingCalls((pendingCalls) => pendingCalls.filter((pendingCall) => pendingCall.cid !== call_cid));
|
|
6843
7089
|
};
|
|
6844
7090
|
};
|
|
6845
7091
|
/**
|
|
@@ -6857,10 +7103,8 @@ const watchCallCancelled = (store) => {
|
|
|
6857
7103
|
console.log("Can't find call in CallEndedEvent");
|
|
6858
7104
|
return;
|
|
6859
7105
|
}
|
|
6860
|
-
const cancelledIncomingCall = store
|
|
6861
|
-
|
|
6862
|
-
.find((incomingCall) => incomingCall.cid === call_cid);
|
|
6863
|
-
const activeCall = store.getCurrentValue(store.activeCallSubject);
|
|
7106
|
+
const cancelledIncomingCall = store.incomingCalls.find((incomingCall) => incomingCall.cid === call_cid);
|
|
7107
|
+
const activeCall = store.activeCall;
|
|
6864
7108
|
const cancelledActiveCall = (activeCall === null || activeCall === void 0 ? void 0 : activeCall.cid) !== undefined && activeCall.cid === call_cid
|
|
6865
7109
|
? activeCall
|
|
6866
7110
|
: undefined;
|
|
@@ -6868,7 +7112,7 @@ const watchCallCancelled = (store) => {
|
|
|
6868
7112
|
console.warn(`CallEndedEvent received for a non-existent incoming call (CID: ${call_cid}`);
|
|
6869
7113
|
return;
|
|
6870
7114
|
}
|
|
6871
|
-
store.
|
|
7115
|
+
store.setPendingCalls((pendingCalls) => pendingCalls.filter((pendingCall) => pendingCall.cid !== call_cid));
|
|
6872
7116
|
};
|
|
6873
7117
|
};
|
|
6874
7118
|
|
|
@@ -6881,7 +7125,7 @@ const watchCallPermissionRequest = (store) => {
|
|
|
6881
7125
|
if (event.type !== 'call.permission_request') {
|
|
6882
7126
|
return;
|
|
6883
7127
|
}
|
|
6884
|
-
const activeCall = store.
|
|
7128
|
+
const activeCall = store.activeCall;
|
|
6885
7129
|
if (!activeCall) {
|
|
6886
7130
|
console.warn(`Ignoring "call.permission_request" as there is no active call`, event);
|
|
6887
7131
|
return;
|
|
@@ -6891,12 +7135,12 @@ const watchCallPermissionRequest = (store) => {
|
|
|
6891
7135
|
return;
|
|
6892
7136
|
}
|
|
6893
7137
|
const state = activeCall.state;
|
|
6894
|
-
const localParticipant = state.
|
|
7138
|
+
const localParticipant = state.localParticipant;
|
|
6895
7139
|
if (!(localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.ownCapabilities.includes('update-call-permissions'))) {
|
|
6896
7140
|
console.warn(`Ignoring "call.permission_request" as the user doesn't have permission to handle it`);
|
|
6897
7141
|
return;
|
|
6898
7142
|
}
|
|
6899
|
-
state.
|
|
7143
|
+
state.setCallPermissionRequest(event);
|
|
6900
7144
|
};
|
|
6901
7145
|
};
|
|
6902
7146
|
/**
|
|
@@ -6908,7 +7152,7 @@ const watchCallPermissionsUpdated = (store) => {
|
|
|
6908
7152
|
if (event.type !== 'call.permissions_updated') {
|
|
6909
7153
|
return;
|
|
6910
7154
|
}
|
|
6911
|
-
const activeCall = store.
|
|
7155
|
+
const activeCall = store.activeCall;
|
|
6912
7156
|
if (!activeCall) {
|
|
6913
7157
|
console.warn(`Ignoring "call.permissions_updated" as there is no active call`, event);
|
|
6914
7158
|
return;
|
|
@@ -6918,7 +7162,7 @@ const watchCallPermissionsUpdated = (store) => {
|
|
|
6918
7162
|
return;
|
|
6919
7163
|
}
|
|
6920
7164
|
const state = activeCall.state;
|
|
6921
|
-
const localParticipant = state.
|
|
7165
|
+
const localParticipant = state.localParticipant;
|
|
6922
7166
|
if (event.user.id === (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.userId)) {
|
|
6923
7167
|
state.updateParticipant(localParticipant.sessionId, {
|
|
6924
7168
|
ownCapabilities: event.own_capabilities,
|
|
@@ -6939,14 +7183,14 @@ const watchNewReactions = (store) => {
|
|
|
6939
7183
|
return;
|
|
6940
7184
|
}
|
|
6941
7185
|
const { call_cid, reaction } = event;
|
|
6942
|
-
const activeCall = store.
|
|
7186
|
+
const activeCall = store.activeCall;
|
|
6943
7187
|
if (!activeCall || activeCall.cid !== call_cid) {
|
|
6944
7188
|
console.warn('Received CallReactionEvent for an inactive or unknown call');
|
|
6945
7189
|
return;
|
|
6946
7190
|
}
|
|
6947
7191
|
const state = activeCall.state;
|
|
6948
|
-
|
|
6949
|
-
|
|
7192
|
+
const { user, custom, type, emoji_code } = reaction;
|
|
7193
|
+
state.setParticipants((participants) => {
|
|
6950
7194
|
return participants.map((p) => {
|
|
6951
7195
|
// skip if the reaction is not for this participant
|
|
6952
7196
|
if (p.userId !== user.id)
|
|
@@ -6974,13 +7218,13 @@ const watchCallRecordingStarted = (store) => {
|
|
|
6974
7218
|
return;
|
|
6975
7219
|
}
|
|
6976
7220
|
const { call_cid } = event;
|
|
6977
|
-
const activeCall = store.
|
|
7221
|
+
const activeCall = store.activeCall;
|
|
6978
7222
|
if (!activeCall || activeCall.cid !== call_cid) {
|
|
6979
7223
|
console.warn('Received CallRecordingStartedEvent for a non-active call');
|
|
6980
7224
|
return;
|
|
6981
7225
|
}
|
|
6982
7226
|
const state = activeCall.state;
|
|
6983
|
-
state.
|
|
7227
|
+
state.setCallRecordingInProgress(true);
|
|
6984
7228
|
};
|
|
6985
7229
|
};
|
|
6986
7230
|
/**
|
|
@@ -6992,13 +7236,13 @@ const watchCallRecordingStopped = (store) => {
|
|
|
6992
7236
|
return;
|
|
6993
7237
|
}
|
|
6994
7238
|
const { call_cid } = event;
|
|
6995
|
-
const activeCall = store.
|
|
7239
|
+
const activeCall = store.activeCall;
|
|
6996
7240
|
if (!activeCall || activeCall.cid !== call_cid) {
|
|
6997
7241
|
console.warn('Received CallRecordingStoppedEvent for a non-active call');
|
|
6998
7242
|
return;
|
|
6999
7243
|
}
|
|
7000
7244
|
const state = activeCall.state;
|
|
7001
|
-
state.
|
|
7245
|
+
state.setCallRecordingInProgress(false);
|
|
7002
7246
|
};
|
|
7003
7247
|
};
|
|
7004
7248
|
|
|
@@ -7008,21 +7252,21 @@ const watchCallRecordingStopped = (store) => {
|
|
|
7008
7252
|
* `event.user_id` to the list
|
|
7009
7253
|
*/
|
|
7010
7254
|
const watchBlockedUser = (store) => (event) => {
|
|
7255
|
+
var _a;
|
|
7011
7256
|
if (event.type !== 'call.blocked_user') {
|
|
7012
7257
|
return;
|
|
7013
7258
|
}
|
|
7014
|
-
const activeCall = store.
|
|
7259
|
+
const activeCall = store.activeCall;
|
|
7015
7260
|
if (!activeCall || activeCall.cid !== event.call_cid) {
|
|
7016
7261
|
console.warn(`Received "call.blocked_user" for an inactive or unknown call`, event);
|
|
7017
7262
|
return;
|
|
7018
7263
|
}
|
|
7019
7264
|
const state = activeCall.state;
|
|
7020
|
-
const localParticipant = state.getCurrentValue(state.localParticipant$);
|
|
7021
7265
|
// FIXME: end call
|
|
7022
|
-
if ((localParticipant === null ||
|
|
7266
|
+
if (((_a = state.localParticipant) === null || _a === void 0 ? void 0 : _a.userId) === event.user.id) {
|
|
7023
7267
|
activeCall.leave();
|
|
7024
7268
|
}
|
|
7025
|
-
state.
|
|
7269
|
+
state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { blocked_user_ids: [...metadata.blocked_user_ids, event.user.id] })));
|
|
7026
7270
|
};
|
|
7027
7271
|
/**
|
|
7028
7272
|
* Event handler that watches for `call.unblocked_user` events,
|
|
@@ -7033,13 +7277,13 @@ const watchUnblockedUser = (store) => (event) => {
|
|
|
7033
7277
|
if (event.type !== 'call.unblocked_user') {
|
|
7034
7278
|
return;
|
|
7035
7279
|
}
|
|
7036
|
-
const activeCall = store.
|
|
7280
|
+
const activeCall = store.activeCall;
|
|
7037
7281
|
if (!activeCall || activeCall.cid !== event.call_cid) {
|
|
7038
7282
|
console.warn(`Received "call.unblocked_user" for an inactive or unknown call`, event);
|
|
7039
7283
|
return;
|
|
7040
7284
|
}
|
|
7041
7285
|
const state = activeCall.state;
|
|
7042
|
-
state.
|
|
7286
|
+
state.setMetadata((metadata) => {
|
|
7043
7287
|
const blocked_user_ids = metadata.blocked_user_ids.filter((userId) => event.user.id !== userId);
|
|
7044
7288
|
return Object.assign(Object.assign({}, metadata), { blocked_user_ids });
|
|
7045
7289
|
});
|
|
@@ -7057,7 +7301,7 @@ class CallDropScheduler {
|
|
|
7057
7301
|
const newIncomingCall = CallDropScheduler.getLatestCall(currentCalls, prevCalls);
|
|
7058
7302
|
if (!newIncomingCall)
|
|
7059
7303
|
return;
|
|
7060
|
-
const activeCall = this.store.
|
|
7304
|
+
const activeCall = this.store.activeCall;
|
|
7061
7305
|
if (activeCall) {
|
|
7062
7306
|
yield newIncomingCall.reject();
|
|
7063
7307
|
}
|
|
@@ -7072,7 +7316,7 @@ class CallDropScheduler {
|
|
|
7072
7316
|
const newIncomingCall = CallDropScheduler.getLatestCall(currentCalls, prevCalls);
|
|
7073
7317
|
if (!newIncomingCall)
|
|
7074
7318
|
return;
|
|
7075
|
-
const activeCall = this.store.
|
|
7319
|
+
const activeCall = this.store.activeCall;
|
|
7076
7320
|
const incomingCallRejectedImmediately = activeCall && this.callConfig.autoRejectWhenInCall;
|
|
7077
7321
|
if (incomingCallRejectedImmediately)
|
|
7078
7322
|
return;
|
|
@@ -7123,8 +7367,6 @@ class CallDropScheduler {
|
|
|
7123
7367
|
};
|
|
7124
7368
|
/**
|
|
7125
7369
|
* Schedules automatic call rejection.
|
|
7126
|
-
* @param {string} callId
|
|
7127
|
-
* @param {string} callType
|
|
7128
7370
|
*/
|
|
7129
7371
|
this.scheduleReject = (call) => {
|
|
7130
7372
|
const timeout = this.callConfig.autoRejectTimeoutInMs;
|
|
@@ -8783,7 +9025,7 @@ class StreamClient {
|
|
|
8783
9025
|
}
|
|
8784
9026
|
getUserAgent() {
|
|
8785
9027
|
return (this.userAgent ||
|
|
8786
|
-
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.1-alpha.
|
|
9028
|
+
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.1-alpha.88"}`);
|
|
8787
9029
|
}
|
|
8788
9030
|
setUserAgent(userAgent) {
|
|
8789
9031
|
this.userAgent = userAgent;
|
|
@@ -8855,7 +9097,7 @@ class StreamVideoClient {
|
|
|
8855
9097
|
this.on('call.recording_started', watchCallRecordingStarted(this.writeableStateStore));
|
|
8856
9098
|
this.on('call.recording_stopped', watchCallRecordingStopped(this.writeableStateStore));
|
|
8857
9099
|
this.on('call.reaction_new', watchNewReactions(this.writeableStateStore));
|
|
8858
|
-
this.writeableStateStore.
|
|
9100
|
+
this.writeableStateStore.setConnectedUser(user);
|
|
8859
9101
|
});
|
|
8860
9102
|
/**
|
|
8861
9103
|
* Disconnects the currently connected user from the client.
|
|
@@ -8869,7 +9111,7 @@ class StreamVideoClient {
|
|
|
8869
9111
|
var _a;
|
|
8870
9112
|
yield this.streamClient.disconnectUser(timeout);
|
|
8871
9113
|
(_a = this.callDropScheduler) === null || _a === void 0 ? void 0 : _a.cleanUp();
|
|
8872
|
-
this.writeableStateStore.
|
|
9114
|
+
this.writeableStateStore.setConnectedUser(undefined);
|
|
8873
9115
|
});
|
|
8874
9116
|
/**
|
|
8875
9117
|
* You can subscribe to WebSocket events provided by the API.
|