@stream-io/video-client 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.browser.es.js +159 -159
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +158 -158
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +159 -159
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +7 -2
- package/dist/src/store/stateStore.d.ts +1 -1
- package/package.json +1 -1
- package/src/Call.ts +25 -41
- package/src/__tests__/server-side/call.test.ts +5 -1
- package/src/rtc/Publisher.ts +3 -19
- package/src/store/stateStore.ts +9 -6
package/dist/index.cjs.js
CHANGED
|
@@ -6515,7 +6515,7 @@ class Publisher {
|
|
|
6515
6515
|
*/
|
|
6516
6516
|
const handleTrackEnded = async () => {
|
|
6517
6517
|
logger$3('info', `Track ${TrackType[trackType]} has ended, notifying the SFU`);
|
|
6518
|
-
await this.notifyTrackMuteStateChanged(mediaStream,
|
|
6518
|
+
await this.notifyTrackMuteStateChanged(mediaStream, trackType, true);
|
|
6519
6519
|
// clean-up, this event listener needs to run only once.
|
|
6520
6520
|
track.removeEventListener('ended', handleTrackEnded);
|
|
6521
6521
|
};
|
|
@@ -6571,7 +6571,7 @@ class Publisher {
|
|
|
6571
6571
|
}
|
|
6572
6572
|
await transceiver.sender.replaceTrack(track);
|
|
6573
6573
|
}
|
|
6574
|
-
await this.notifyTrackMuteStateChanged(mediaStream,
|
|
6574
|
+
await this.notifyTrackMuteStateChanged(mediaStream, trackType, false);
|
|
6575
6575
|
};
|
|
6576
6576
|
/**
|
|
6577
6577
|
* Stops publishing the given track type to the SFU, if it is currently being published.
|
|
@@ -6593,7 +6593,7 @@ class Publisher {
|
|
|
6593
6593
|
: (transceiver.sender.track.enabled = false);
|
|
6594
6594
|
// We don't need to notify SFU if unpublishing in response to remote soft mute
|
|
6595
6595
|
if (this.state.localParticipant?.publishedTracks.includes(trackType)) {
|
|
6596
|
-
await this.notifyTrackMuteStateChanged(undefined,
|
|
6596
|
+
await this.notifyTrackMuteStateChanged(undefined, trackType, true);
|
|
6597
6597
|
}
|
|
6598
6598
|
}
|
|
6599
6599
|
};
|
|
@@ -6625,7 +6625,7 @@ class Publisher {
|
|
|
6625
6625
|
}
|
|
6626
6626
|
return false;
|
|
6627
6627
|
};
|
|
6628
|
-
this.notifyTrackMuteStateChanged = async (mediaStream,
|
|
6628
|
+
this.notifyTrackMuteStateChanged = async (mediaStream, trackType, isMuted) => {
|
|
6629
6629
|
await this.sfuClient.updateMuteState(trackType, isMuted);
|
|
6630
6630
|
const audioOrVideoOrScreenShareStream = trackTypeToParticipantStreamKey(trackType);
|
|
6631
6631
|
if (isMuted) {
|
|
@@ -7669,131 +7669,6 @@ var rxUtils = /*#__PURE__*/Object.freeze({
|
|
|
7669
7669
|
setCurrentValue: setCurrentValue
|
|
7670
7670
|
});
|
|
7671
7671
|
|
|
7672
|
-
class StreamVideoWriteableStateStore {
|
|
7673
|
-
constructor() {
|
|
7674
|
-
/**
|
|
7675
|
-
* A store keeping data of a successfully connected user over WS to the coordinator server.
|
|
7676
|
-
*/
|
|
7677
|
-
this.connectedUserSubject = new rxjs.BehaviorSubject(undefined);
|
|
7678
|
-
/**
|
|
7679
|
-
* A list of {@link Call} objects created/tracked by this client.
|
|
7680
|
-
*/
|
|
7681
|
-
this.callsSubject = new rxjs.BehaviorSubject([]);
|
|
7682
|
-
/**
|
|
7683
|
-
* Gets the current value of an observable, or undefined if the observable has
|
|
7684
|
-
* not emitted a value yet.
|
|
7685
|
-
*
|
|
7686
|
-
* @param observable$ the observable to get the value from.
|
|
7687
|
-
*/
|
|
7688
|
-
this.getCurrentValue = getCurrentValue;
|
|
7689
|
-
/**
|
|
7690
|
-
* Updates the value of the provided Subject.
|
|
7691
|
-
* An `update` can either be a new value or a function which takes
|
|
7692
|
-
* the current value and returns a new value.
|
|
7693
|
-
*
|
|
7694
|
-
* @param subject the subject to update.
|
|
7695
|
-
* @param update the update to apply to the subject.
|
|
7696
|
-
* @return the updated value.
|
|
7697
|
-
*/
|
|
7698
|
-
this.setCurrentValue = setCurrentValue;
|
|
7699
|
-
/**
|
|
7700
|
-
* Sets the currently connected user.
|
|
7701
|
-
*
|
|
7702
|
-
* @internal
|
|
7703
|
-
* @param user the user to set as connected.
|
|
7704
|
-
*/
|
|
7705
|
-
this.setConnectedUser = (user) => {
|
|
7706
|
-
return this.setCurrentValue(this.connectedUserSubject, user);
|
|
7707
|
-
};
|
|
7708
|
-
/**
|
|
7709
|
-
* Sets the list of {@link Call} objects created/tracked by this client.
|
|
7710
|
-
* @param calls
|
|
7711
|
-
*/
|
|
7712
|
-
this.setCalls = (calls) => {
|
|
7713
|
-
return this.setCurrentValue(this.callsSubject, calls);
|
|
7714
|
-
};
|
|
7715
|
-
/**
|
|
7716
|
-
* Adds a {@link Call} object to the list of {@link Call} objects created/tracked by this client.
|
|
7717
|
-
*
|
|
7718
|
-
* @param call the call to add.
|
|
7719
|
-
*/
|
|
7720
|
-
this.registerCall = (call) => {
|
|
7721
|
-
if (!this.calls.find((c) => c.cid === call.cid)) {
|
|
7722
|
-
this.setCalls((calls) => [...calls, call]);
|
|
7723
|
-
}
|
|
7724
|
-
};
|
|
7725
|
-
/**
|
|
7726
|
-
* Removes a {@link Call} object from the list of {@link Call} objects created/tracked by this client.
|
|
7727
|
-
*
|
|
7728
|
-
* @param call the call to remove
|
|
7729
|
-
*/
|
|
7730
|
-
this.unregisterCall = (call) => {
|
|
7731
|
-
return this.setCalls((calls) => calls.filter((c) => c !== call));
|
|
7732
|
-
};
|
|
7733
|
-
/**
|
|
7734
|
-
* Finds a {@link Call} object in the list of {@link Call} objects created/tracked by this client.
|
|
7735
|
-
*
|
|
7736
|
-
* @param type the type of call to find.
|
|
7737
|
-
* @param id the id of the call to find.
|
|
7738
|
-
*/
|
|
7739
|
-
this.findCall = (type, id) => {
|
|
7740
|
-
return this.calls.find((c) => c.type === type && c.id === id);
|
|
7741
|
-
};
|
|
7742
|
-
this.connectedUserSubject.subscribe(async (user) => {
|
|
7743
|
-
// leave all calls when the user disconnects.
|
|
7744
|
-
if (!user) {
|
|
7745
|
-
for (const call of this.calls) {
|
|
7746
|
-
getLogger(['client-state'])('info', `User disconnected, leaving call: ${call.cid}`);
|
|
7747
|
-
await call.leave();
|
|
7748
|
-
}
|
|
7749
|
-
}
|
|
7750
|
-
});
|
|
7751
|
-
}
|
|
7752
|
-
/**
|
|
7753
|
-
* The currently connected user.
|
|
7754
|
-
*/
|
|
7755
|
-
get connectedUser() {
|
|
7756
|
-
return this.getCurrentValue(this.connectedUserSubject);
|
|
7757
|
-
}
|
|
7758
|
-
/**
|
|
7759
|
-
* A list of {@link Call} objects created/tracked by this client.
|
|
7760
|
-
*/
|
|
7761
|
-
get calls() {
|
|
7762
|
-
return this.getCurrentValue(this.callsSubject);
|
|
7763
|
-
}
|
|
7764
|
-
}
|
|
7765
|
-
/**
|
|
7766
|
-
* A reactive store that exposes state variables in a reactive manner.
|
|
7767
|
-
* You can subscribe to changes of the different state variables.
|
|
7768
|
-
* This central store contains all the state variables related to [`StreamVideoClient`](./StreamVideClient.md) and [`Call`](./Call.md).
|
|
7769
|
-
*/
|
|
7770
|
-
class StreamVideoReadOnlyStateStore {
|
|
7771
|
-
constructor(store) {
|
|
7772
|
-
/**
|
|
7773
|
-
* This method allows you the get the current value of a state variable.
|
|
7774
|
-
*
|
|
7775
|
-
* @param observable the observable to get the current value of.
|
|
7776
|
-
* @returns the current value of the observable.
|
|
7777
|
-
*/
|
|
7778
|
-
this.getCurrentValue = getCurrentValue;
|
|
7779
|
-
// convert and expose subjects as observables
|
|
7780
|
-
this.connectedUser$ = store.connectedUserSubject.asObservable();
|
|
7781
|
-
this.calls$ = store.callsSubject.asObservable();
|
|
7782
|
-
}
|
|
7783
|
-
/**
|
|
7784
|
-
* The current user connected over WS to the backend.
|
|
7785
|
-
*/
|
|
7786
|
-
get connectedUser() {
|
|
7787
|
-
return getCurrentValue(this.connectedUser$);
|
|
7788
|
-
}
|
|
7789
|
-
/**
|
|
7790
|
-
* A list of {@link Call} objects created/tracked by this client.
|
|
7791
|
-
*/
|
|
7792
|
-
get calls() {
|
|
7793
|
-
return getCurrentValue(this.calls$);
|
|
7794
|
-
}
|
|
7795
|
-
}
|
|
7796
|
-
|
|
7797
7672
|
/**
|
|
7798
7673
|
* Creates a new combined {@link Comparator<T>} which sorts items by the given comparators.
|
|
7799
7674
|
* The comparators are applied in the order they are given (left -> right).
|
|
@@ -8752,6 +8627,136 @@ class CallState {
|
|
|
8752
8627
|
}
|
|
8753
8628
|
}
|
|
8754
8629
|
|
|
8630
|
+
class StreamVideoWriteableStateStore {
|
|
8631
|
+
constructor() {
|
|
8632
|
+
/**
|
|
8633
|
+
* A store keeping data of a successfully connected user over WS to the coordinator server.
|
|
8634
|
+
*/
|
|
8635
|
+
this.connectedUserSubject = new rxjs.BehaviorSubject(undefined);
|
|
8636
|
+
/**
|
|
8637
|
+
* A list of {@link Call} objects created/tracked by this client.
|
|
8638
|
+
*/
|
|
8639
|
+
this.callsSubject = new rxjs.BehaviorSubject([]);
|
|
8640
|
+
/**
|
|
8641
|
+
* Gets the current value of an observable, or undefined if the observable has
|
|
8642
|
+
* not emitted a value yet.
|
|
8643
|
+
*
|
|
8644
|
+
* @param observable$ the observable to get the value from.
|
|
8645
|
+
*/
|
|
8646
|
+
this.getCurrentValue = getCurrentValue;
|
|
8647
|
+
/**
|
|
8648
|
+
* Updates the value of the provided Subject.
|
|
8649
|
+
* An `update` can either be a new value or a function which takes
|
|
8650
|
+
* the current value and returns a new value.
|
|
8651
|
+
*
|
|
8652
|
+
* @param subject the subject to update.
|
|
8653
|
+
* @param update the update to apply to the subject.
|
|
8654
|
+
* @return the updated value.
|
|
8655
|
+
*/
|
|
8656
|
+
this.setCurrentValue = setCurrentValue;
|
|
8657
|
+
/**
|
|
8658
|
+
* Sets the currently connected user.
|
|
8659
|
+
*
|
|
8660
|
+
* @internal
|
|
8661
|
+
* @param user the user to set as connected.
|
|
8662
|
+
*/
|
|
8663
|
+
this.setConnectedUser = (user) => {
|
|
8664
|
+
return this.setCurrentValue(this.connectedUserSubject, user);
|
|
8665
|
+
};
|
|
8666
|
+
/**
|
|
8667
|
+
* Sets the list of {@link Call} objects created/tracked by this client.
|
|
8668
|
+
* @param calls
|
|
8669
|
+
*/
|
|
8670
|
+
this.setCalls = (calls) => {
|
|
8671
|
+
return this.setCurrentValue(this.callsSubject, calls);
|
|
8672
|
+
};
|
|
8673
|
+
/**
|
|
8674
|
+
* Adds a {@link Call} object to the list of {@link Call} objects created/tracked by this client.
|
|
8675
|
+
*
|
|
8676
|
+
* @param call the call to add.
|
|
8677
|
+
*/
|
|
8678
|
+
this.registerCall = (call) => {
|
|
8679
|
+
if (!this.calls.find((c) => c.cid === call.cid)) {
|
|
8680
|
+
this.setCalls((calls) => [...calls, call]);
|
|
8681
|
+
}
|
|
8682
|
+
};
|
|
8683
|
+
/**
|
|
8684
|
+
* Removes a {@link Call} object from the list of {@link Call} objects created/tracked by this client.
|
|
8685
|
+
*
|
|
8686
|
+
* @param call the call to remove
|
|
8687
|
+
*/
|
|
8688
|
+
this.unregisterCall = (call) => {
|
|
8689
|
+
return this.setCalls((calls) => calls.filter((c) => c !== call));
|
|
8690
|
+
};
|
|
8691
|
+
/**
|
|
8692
|
+
* Finds a {@link Call} object in the list of {@link Call} objects created/tracked by this client.
|
|
8693
|
+
*
|
|
8694
|
+
* @param type the type of call to find.
|
|
8695
|
+
* @param id the id of the call to find.
|
|
8696
|
+
*/
|
|
8697
|
+
this.findCall = (type, id) => {
|
|
8698
|
+
return this.calls.find((c) => c.type === type && c.id === id);
|
|
8699
|
+
};
|
|
8700
|
+
this.connectedUserSubject.subscribe(async (user) => {
|
|
8701
|
+
// leave all calls when the user disconnects.
|
|
8702
|
+
if (!user) {
|
|
8703
|
+
const logger = getLogger(['client-state']);
|
|
8704
|
+
for (const call of this.calls) {
|
|
8705
|
+
if (call.state.callingState === exports.CallingState.LEFT)
|
|
8706
|
+
continue;
|
|
8707
|
+
logger('info', `User disconnected, leaving call: ${call.cid}`);
|
|
8708
|
+
await call.leave().catch((err) => {
|
|
8709
|
+
logger('error', `Error leaving call: ${call.cid}`, err);
|
|
8710
|
+
});
|
|
8711
|
+
}
|
|
8712
|
+
}
|
|
8713
|
+
});
|
|
8714
|
+
}
|
|
8715
|
+
/**
|
|
8716
|
+
* The currently connected user.
|
|
8717
|
+
*/
|
|
8718
|
+
get connectedUser() {
|
|
8719
|
+
return this.getCurrentValue(this.connectedUserSubject);
|
|
8720
|
+
}
|
|
8721
|
+
/**
|
|
8722
|
+
* A list of {@link Call} objects created/tracked by this client.
|
|
8723
|
+
*/
|
|
8724
|
+
get calls() {
|
|
8725
|
+
return this.getCurrentValue(this.callsSubject);
|
|
8726
|
+
}
|
|
8727
|
+
}
|
|
8728
|
+
/**
|
|
8729
|
+
* A reactive store that exposes state variables in a reactive manner.
|
|
8730
|
+
* You can subscribe to changes of the different state variables.
|
|
8731
|
+
* This central store contains all the state variables related to [`StreamVideoClient`](./StreamVideClient.md) and [`Call`](./Call.md).
|
|
8732
|
+
*/
|
|
8733
|
+
class StreamVideoReadOnlyStateStore {
|
|
8734
|
+
constructor(store) {
|
|
8735
|
+
/**
|
|
8736
|
+
* This method allows you the get the current value of a state variable.
|
|
8737
|
+
*
|
|
8738
|
+
* @param observable the observable to get the current value of.
|
|
8739
|
+
* @returns the current value of the observable.
|
|
8740
|
+
*/
|
|
8741
|
+
this.getCurrentValue = getCurrentValue;
|
|
8742
|
+
// convert and expose subjects as observables
|
|
8743
|
+
this.connectedUser$ = store.connectedUserSubject.asObservable();
|
|
8744
|
+
this.calls$ = store.callsSubject.asObservable();
|
|
8745
|
+
}
|
|
8746
|
+
/**
|
|
8747
|
+
* The current user connected over WS to the backend.
|
|
8748
|
+
*/
|
|
8749
|
+
get connectedUser() {
|
|
8750
|
+
return getCurrentValue(this.connectedUser$);
|
|
8751
|
+
}
|
|
8752
|
+
/**
|
|
8753
|
+
* A list of {@link Call} objects created/tracked by this client.
|
|
8754
|
+
*/
|
|
8755
|
+
get calls() {
|
|
8756
|
+
return getCurrentValue(this.calls$);
|
|
8757
|
+
}
|
|
8758
|
+
}
|
|
8759
|
+
|
|
8755
8760
|
/**
|
|
8756
8761
|
* Event handler that watched the delivery of `call.accepted`.
|
|
8757
8762
|
* Once the event is received, the call is joined.
|
|
@@ -11938,9 +11943,10 @@ class Call {
|
|
|
11938
11943
|
return this.state.setSortParticipantsBy(criteria);
|
|
11939
11944
|
};
|
|
11940
11945
|
/**
|
|
11946
|
+
* Updates the list of video layers to publish.
|
|
11947
|
+
*
|
|
11941
11948
|
* @internal
|
|
11942
|
-
* @param
|
|
11943
|
-
* @returns
|
|
11949
|
+
* @param enabledLayers the list of layers to enable.
|
|
11944
11950
|
*/
|
|
11945
11951
|
this.updatePublishQuality = async (enabledLayers) => {
|
|
11946
11952
|
return this.publisher?.updateVideoPublishQuality(enabledLayers);
|
|
@@ -12212,35 +12218,29 @@ class Call {
|
|
|
12212
12218
|
this.updateCallMembers = async (data) => {
|
|
12213
12219
|
return this.streamClient.post(`${this.streamClientBasePath}/members`, data);
|
|
12214
12220
|
};
|
|
12221
|
+
/**
|
|
12222
|
+
* Schedules an auto-drop timeout based on the call settings.
|
|
12223
|
+
* Applicable only for ringing calls.
|
|
12224
|
+
*/
|
|
12215
12225
|
this.scheduleAutoDrop = () => {
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
|
|
12219
|
-
.pipe(rxjs.pairwise(), rxjs.tap(([prevSettings, currentSettings]) => {
|
|
12220
|
-
if (!currentSettings || !this.clientStore.connectedUser)
|
|
12226
|
+
clearTimeout(this.dropTimeout);
|
|
12227
|
+
this.leaveCallHooks.add(createSubscription(this.state.settings$, (settings) => {
|
|
12228
|
+
if (!settings)
|
|
12221
12229
|
return;
|
|
12222
|
-
|
|
12223
|
-
|
|
12224
|
-
? [
|
|
12225
|
-
prevSettings?.ring.auto_cancel_timeout_ms,
|
|
12226
|
-
currentSettings.ring.auto_cancel_timeout_ms,
|
|
12227
|
-
]
|
|
12228
|
-
: [
|
|
12229
|
-
prevSettings?.ring.incoming_call_timeout_ms,
|
|
12230
|
-
currentSettings.ring.incoming_call_timeout_ms,
|
|
12231
|
-
];
|
|
12232
|
-
if (typeof timeoutMs === 'undefined' ||
|
|
12233
|
-
timeoutMs === prevTimeoutMs ||
|
|
12234
|
-
timeoutMs === 0)
|
|
12230
|
+
// ignore if the call is not ringing
|
|
12231
|
+
if (this.state.callingState !== exports.CallingState.RINGING)
|
|
12235
12232
|
return;
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
.
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12233
|
+
const timeoutInMs = settings.ring.auto_cancel_timeout_ms;
|
|
12234
|
+
// 0 means no auto-drop
|
|
12235
|
+
if (timeoutInMs <= 0)
|
|
12236
|
+
return;
|
|
12237
|
+
clearTimeout(this.dropTimeout);
|
|
12238
|
+
this.dropTimeout = setTimeout(() => {
|
|
12239
|
+
this.leave().catch((err) => {
|
|
12240
|
+
this.logger('error', 'Failed to drop call', err);
|
|
12241
|
+
});
|
|
12242
|
+
}, timeoutInMs);
|
|
12243
|
+
}));
|
|
12244
12244
|
};
|
|
12245
12245
|
/**
|
|
12246
12246
|
* Retrieves the list of recordings for the current call or call session.
|
|
@@ -14165,7 +14165,7 @@ class StreamClient {
|
|
|
14165
14165
|
});
|
|
14166
14166
|
};
|
|
14167
14167
|
this.getUserAgent = () => {
|
|
14168
|
-
const version = "0.5.
|
|
14168
|
+
const version = "0.5.2" ;
|
|
14169
14169
|
return (this.userAgent ||
|
|
14170
14170
|
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
|
|
14171
14171
|
};
|