@stream-io/video-client 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.browser.es.js +77 -56
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +77 -56
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +77 -56
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +2 -1
- package/dist/src/coordinator/connection/client.d.ts +9 -4
- package/dist/src/devices/CameraManager.d.ts +3 -9
- package/dist/src/devices/InputMediaDeviceManager.d.ts +11 -5
- package/dist/src/devices/InputMediaDeviceManagerState.d.ts +6 -1
- package/dist/src/devices/MicrophoneManager.d.ts +3 -9
- package/dist/src/devices/MicrophoneManagerState.d.ts +1 -0
- package/dist/src/rtc/Publisher.d.ts +2 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/Call.ts +3 -2
- package/src/StreamVideoClient.ts +1 -10
- package/src/__tests__/StreamVideoClient.test.ts +13 -0
- package/src/coordinator/connection/client.ts +28 -0
- package/src/devices/CameraManager.ts +8 -17
- package/src/devices/CameraManagerState.ts +1 -1
- package/src/devices/InputMediaDeviceManager.ts +39 -17
- package/src/devices/InputMediaDeviceManagerState.ts +12 -2
- package/src/devices/MicrophoneManager.ts +8 -17
- package/src/devices/MicrophoneManagerState.ts +4 -0
- package/src/devices/__tests__/CameraManager.test.ts +4 -14
- package/src/devices/__tests__/InputMediaDeviceManager.test.ts +48 -5
- package/src/devices/__tests__/MicrophoneManager.test.ts +8 -7
- package/src/rtc/Publisher.ts +8 -2
- package/src/rtc/__tests__/Publisher.test.ts +67 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
### [0.3.4](https://github.com/GetStream/stream-video-js/compare/client0.3.3...client0.3.4) (2023-08-21)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* guest auth didn't wait for some API calls ([#965](https://github.com/GetStream/stream-video-js/issues/965)) ([5d9e1c6](https://github.com/GetStream/stream-video-js/commit/5d9e1c6ebb09901a8f3e12c435736e0640af62dc))
|
|
11
|
+
|
|
12
|
+
### [0.3.3](https://github.com/GetStream/stream-video-js/compare/client0.3.2...client0.3.3) (2023-08-18)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* Disable doesn't stop audio tracks ([#950](https://github.com/GetStream/stream-video-js/issues/950)) ([c348f34](https://github.com/GetStream/stream-video-js/commit/c348f34818f0e123e70b9471637ddd64411ebc08))
|
|
18
|
+
|
|
5
19
|
### [0.3.2](https://github.com/GetStream/stream-video-js/compare/client0.3.1...client0.3.2) (2023-08-16)
|
|
6
20
|
|
|
7
21
|
|
package/dist/index.browser.es.js
CHANGED
|
@@ -6614,6 +6614,9 @@ class Publisher {
|
|
|
6614
6614
|
previousTrack.removeEventListener('ended', handleTrackEnded);
|
|
6615
6615
|
track.addEventListener('ended', handleTrackEnded);
|
|
6616
6616
|
}
|
|
6617
|
+
if (!track.enabled) {
|
|
6618
|
+
track.enabled = true;
|
|
6619
|
+
}
|
|
6617
6620
|
yield transceiver.sender.replaceTrack(track);
|
|
6618
6621
|
}
|
|
6619
6622
|
yield this.notifyTrackMuteStateChanged(mediaStream, track, trackType, false);
|
|
@@ -6622,15 +6625,18 @@ class Publisher {
|
|
|
6622
6625
|
* Stops publishing the given track type to the SFU, if it is currently being published.
|
|
6623
6626
|
* Underlying track will be stopped and removed from the publisher.
|
|
6624
6627
|
* @param trackType the track type to unpublish.
|
|
6628
|
+
* @param stopTrack specifies whether track should be stopped or just disabled
|
|
6625
6629
|
*/
|
|
6626
|
-
this.unpublishStream = (trackType) => __awaiter(this, void 0, void 0, function* () {
|
|
6630
|
+
this.unpublishStream = (trackType, stopTrack) => __awaiter(this, void 0, void 0, function* () {
|
|
6627
6631
|
const transceiver = this.pc
|
|
6628
6632
|
.getTransceivers()
|
|
6629
6633
|
.find((t) => t === this.transceiverRegistry[trackType] && t.sender.track);
|
|
6630
6634
|
if (transceiver &&
|
|
6631
6635
|
transceiver.sender.track &&
|
|
6632
6636
|
transceiver.sender.track.readyState === 'live') {
|
|
6633
|
-
|
|
6637
|
+
stopTrack
|
|
6638
|
+
? transceiver.sender.track.stop()
|
|
6639
|
+
: (transceiver.sender.track.enabled = false);
|
|
6634
6640
|
return this.notifyTrackMuteStateChanged(undefined, transceiver.sender.track, trackType, true);
|
|
6635
6641
|
}
|
|
6636
6642
|
});
|
|
@@ -9517,7 +9523,8 @@ const CallTypes = new CallTypesRegistry([
|
|
|
9517
9523
|
]);
|
|
9518
9524
|
|
|
9519
9525
|
class InputMediaDeviceManagerState {
|
|
9520
|
-
constructor() {
|
|
9526
|
+
constructor(disableMode = 'stop-tracks') {
|
|
9527
|
+
this.disableMode = disableMode;
|
|
9521
9528
|
this.statusSubject = new BehaviorSubject(undefined);
|
|
9522
9529
|
this.mediaStreamSubject = new BehaviorSubject(undefined);
|
|
9523
9530
|
this.selectedDeviceSubject = new BehaviorSubject(undefined);
|
|
@@ -9544,7 +9551,9 @@ class InputMediaDeviceManagerState {
|
|
|
9544
9551
|
this.selectedDevice$ = this.selectedDeviceSubject
|
|
9545
9552
|
.asObservable()
|
|
9546
9553
|
.pipe(distinctUntilChanged$1());
|
|
9547
|
-
this.status$ = this.statusSubject
|
|
9554
|
+
this.status$ = this.statusSubject
|
|
9555
|
+
.asObservable()
|
|
9556
|
+
.pipe(distinctUntilChanged$1());
|
|
9548
9557
|
}
|
|
9549
9558
|
/**
|
|
9550
9559
|
* The device status
|
|
@@ -9592,7 +9601,7 @@ class InputMediaDeviceManagerState {
|
|
|
9592
9601
|
|
|
9593
9602
|
class CameraManagerState extends InputMediaDeviceManagerState {
|
|
9594
9603
|
constructor() {
|
|
9595
|
-
super();
|
|
9604
|
+
super('stop-tracks');
|
|
9596
9605
|
this.directionSubject = new BehaviorSubject(undefined);
|
|
9597
9606
|
this.direction$ = this.directionSubject
|
|
9598
9607
|
.asObservable()
|
|
@@ -9905,12 +9914,13 @@ class InputMediaDeviceManager {
|
|
|
9905
9914
|
if (this.state.status === 'enabled') {
|
|
9906
9915
|
return;
|
|
9907
9916
|
}
|
|
9908
|
-
yield this.
|
|
9917
|
+
yield this.unmuteStream();
|
|
9909
9918
|
this.state.setStatus('enabled');
|
|
9910
9919
|
});
|
|
9911
9920
|
}
|
|
9912
9921
|
/**
|
|
9913
9922
|
* Stops camera/microphone
|
|
9923
|
+
*
|
|
9914
9924
|
* @returns
|
|
9915
9925
|
*/
|
|
9916
9926
|
disable() {
|
|
@@ -9918,12 +9928,25 @@ class InputMediaDeviceManager {
|
|
|
9918
9928
|
if (this.state.status === 'disabled') {
|
|
9919
9929
|
return;
|
|
9920
9930
|
}
|
|
9921
|
-
|
|
9931
|
+
this.state.prevStatus = this.state.status;
|
|
9932
|
+
yield this.muteStream(this.state.disableMode === 'stop-tracks');
|
|
9922
9933
|
this.state.setStatus('disabled');
|
|
9923
9934
|
});
|
|
9924
9935
|
}
|
|
9936
|
+
/**
|
|
9937
|
+
* If status was previously enabled, it will reenable the device.
|
|
9938
|
+
*/
|
|
9939
|
+
resume() {
|
|
9940
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9941
|
+
if (this.state.prevStatus === 'enabled' &&
|
|
9942
|
+
this.state.status === 'disabled') {
|
|
9943
|
+
this.enable();
|
|
9944
|
+
}
|
|
9945
|
+
});
|
|
9946
|
+
}
|
|
9925
9947
|
/**
|
|
9926
9948
|
* If current device statis is disabled, it will enable the device, else it will disable it.
|
|
9949
|
+
*
|
|
9927
9950
|
* @returns
|
|
9928
9951
|
*/
|
|
9929
9952
|
toggle() {
|
|
@@ -9958,32 +9981,40 @@ class InputMediaDeviceManager {
|
|
|
9958
9981
|
applySettingsToStream() {
|
|
9959
9982
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9960
9983
|
if (this.state.status === 'enabled') {
|
|
9961
|
-
yield this.
|
|
9962
|
-
yield this.
|
|
9984
|
+
yield this.muteStream();
|
|
9985
|
+
yield this.unmuteStream();
|
|
9963
9986
|
}
|
|
9964
9987
|
});
|
|
9965
9988
|
}
|
|
9966
|
-
|
|
9989
|
+
muteStream(stopTracks = true) {
|
|
9967
9990
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9968
9991
|
if (!this.state.mediaStream) {
|
|
9969
9992
|
return;
|
|
9970
9993
|
}
|
|
9971
9994
|
if (this.call.state.callingState === CallingState.JOINED) {
|
|
9972
|
-
yield this.stopPublishStream();
|
|
9995
|
+
yield this.stopPublishStream(stopTracks);
|
|
9973
9996
|
}
|
|
9974
9997
|
else if (this.state.mediaStream) {
|
|
9975
|
-
|
|
9998
|
+
stopTracks
|
|
9999
|
+
? disposeOfMediaStream(this.state.mediaStream)
|
|
10000
|
+
: this.muteTracks();
|
|
10001
|
+
}
|
|
10002
|
+
if (stopTracks) {
|
|
10003
|
+
this.state.setMediaStream(undefined);
|
|
9976
10004
|
}
|
|
9977
|
-
this.state.setMediaStream(undefined);
|
|
9978
10005
|
});
|
|
9979
10006
|
}
|
|
9980
|
-
|
|
10007
|
+
unmuteStream() {
|
|
9981
10008
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10009
|
+
let stream;
|
|
9982
10010
|
if (this.state.mediaStream) {
|
|
9983
|
-
|
|
10011
|
+
stream = this.state.mediaStream;
|
|
10012
|
+
this.unmuteTracks();
|
|
10013
|
+
}
|
|
10014
|
+
else {
|
|
10015
|
+
const constraints = { deviceId: this.state.selectedDevice };
|
|
10016
|
+
stream = yield this.getStream(constraints);
|
|
9984
10017
|
}
|
|
9985
|
-
const constraints = { deviceId: this.state.selectedDevice };
|
|
9986
|
-
const stream = yield this.getStream(constraints);
|
|
9987
10018
|
if (this.call.state.callingState === CallingState.JOINED) {
|
|
9988
10019
|
yield this.publishStream(stream);
|
|
9989
10020
|
}
|
|
@@ -10035,30 +10066,23 @@ class CameraManager extends InputMediaDeviceManager {
|
|
|
10035
10066
|
publishStream(stream) {
|
|
10036
10067
|
return this.call.publishVideoStream(stream);
|
|
10037
10068
|
}
|
|
10038
|
-
stopPublishStream() {
|
|
10039
|
-
return this.call.stopPublish(TrackType.VIDEO);
|
|
10069
|
+
stopPublishStream(stopTracks) {
|
|
10070
|
+
return this.call.stopPublish(TrackType.VIDEO, stopTracks);
|
|
10040
10071
|
}
|
|
10041
|
-
|
|
10042
|
-
* Disables the video tracks of the camera
|
|
10043
|
-
*/
|
|
10044
|
-
pause() {
|
|
10072
|
+
muteTracks() {
|
|
10045
10073
|
var _a;
|
|
10046
|
-
(_a = this.state.mediaStream) === null || _a === void 0 ? void 0 : _a.getVideoTracks().forEach((
|
|
10047
|
-
track.enabled = false;
|
|
10048
|
-
});
|
|
10074
|
+
(_a = this.state.mediaStream) === null || _a === void 0 ? void 0 : _a.getVideoTracks().forEach((t) => (t.enabled = false));
|
|
10049
10075
|
}
|
|
10050
|
-
|
|
10051
|
-
* (Re)enables the video tracks of the camera
|
|
10052
|
-
*/
|
|
10053
|
-
resume() {
|
|
10076
|
+
unmuteTracks() {
|
|
10054
10077
|
var _a;
|
|
10055
|
-
(_a = this.state.mediaStream) === null || _a === void 0 ? void 0 : _a.getVideoTracks().forEach((
|
|
10056
|
-
track.enabled = true;
|
|
10057
|
-
});
|
|
10078
|
+
(_a = this.state.mediaStream) === null || _a === void 0 ? void 0 : _a.getVideoTracks().forEach((t) => (t.enabled = true));
|
|
10058
10079
|
}
|
|
10059
10080
|
}
|
|
10060
10081
|
|
|
10061
10082
|
class MicrophoneManagerState extends InputMediaDeviceManagerState {
|
|
10083
|
+
constructor() {
|
|
10084
|
+
super('disable-tracks');
|
|
10085
|
+
}
|
|
10062
10086
|
getDeviceIdFromStream(stream) {
|
|
10063
10087
|
var _a;
|
|
10064
10088
|
return (_a = stream.getAudioTracks()[0]) === null || _a === void 0 ? void 0 : _a.getSettings().deviceId;
|
|
@@ -10078,26 +10102,16 @@ class MicrophoneManager extends InputMediaDeviceManager {
|
|
|
10078
10102
|
publishStream(stream) {
|
|
10079
10103
|
return this.call.publishAudioStream(stream);
|
|
10080
10104
|
}
|
|
10081
|
-
stopPublishStream() {
|
|
10082
|
-
return this.call.stopPublish(TrackType.AUDIO);
|
|
10105
|
+
stopPublishStream(stopTracks) {
|
|
10106
|
+
return this.call.stopPublish(TrackType.AUDIO, stopTracks);
|
|
10083
10107
|
}
|
|
10084
|
-
|
|
10085
|
-
* Disables the audio tracks of the microphone
|
|
10086
|
-
*/
|
|
10087
|
-
pause() {
|
|
10108
|
+
muteTracks() {
|
|
10088
10109
|
var _a;
|
|
10089
|
-
(_a = this.state.mediaStream) === null || _a === void 0 ? void 0 : _a.getAudioTracks().forEach((
|
|
10090
|
-
track.enabled = false;
|
|
10091
|
-
});
|
|
10110
|
+
(_a = this.state.mediaStream) === null || _a === void 0 ? void 0 : _a.getAudioTracks().forEach((t) => (t.enabled = false));
|
|
10092
10111
|
}
|
|
10093
|
-
|
|
10094
|
-
* (Re)enables the audio tracks of the microphone
|
|
10095
|
-
*/
|
|
10096
|
-
resume() {
|
|
10112
|
+
unmuteTracks() {
|
|
10097
10113
|
var _a;
|
|
10098
|
-
(_a = this.state.mediaStream) === null || _a === void 0 ? void 0 : _a.getAudioTracks().forEach((
|
|
10099
|
-
track.enabled = true;
|
|
10100
|
-
});
|
|
10114
|
+
(_a = this.state.mediaStream) === null || _a === void 0 ? void 0 : _a.getAudioTracks().forEach((t) => (t.enabled = true));
|
|
10101
10115
|
}
|
|
10102
10116
|
}
|
|
10103
10117
|
|
|
@@ -10661,11 +10675,12 @@ class Call {
|
|
|
10661
10675
|
*
|
|
10662
10676
|
*
|
|
10663
10677
|
* @param trackType the track type to stop publishing.
|
|
10678
|
+
* @param stopTrack if `true` the track will be stopped, else it will be just disabled
|
|
10664
10679
|
*/
|
|
10665
|
-
this.stopPublish = (trackType) => __awaiter(this, void 0, void 0, function* () {
|
|
10680
|
+
this.stopPublish = (trackType, stopTrack = true) => __awaiter(this, void 0, void 0, function* () {
|
|
10666
10681
|
var _j;
|
|
10667
10682
|
this.logger('info', `stopPublish ${TrackType[trackType]}`);
|
|
10668
|
-
yield ((_j = this.publisher) === null || _j === void 0 ? void 0 : _j.unpublishStream(trackType));
|
|
10683
|
+
yield ((_j = this.publisher) === null || _j === void 0 ? void 0 : _j.unpublishStream(trackType, stopTrack));
|
|
10669
10684
|
});
|
|
10670
10685
|
/**
|
|
10671
10686
|
* Update track subscription configuration for one or more participants.
|
|
@@ -12437,7 +12452,7 @@ class WSConnectionFallback {
|
|
|
12437
12452
|
}
|
|
12438
12453
|
}
|
|
12439
12454
|
|
|
12440
|
-
const version = '0.3.
|
|
12455
|
+
const version = '0.3.4';
|
|
12441
12456
|
|
|
12442
12457
|
const logger = getLogger(['location']);
|
|
12443
12458
|
const HINT_URL = `https://hint.stream-io-video.com/`;
|
|
@@ -12637,6 +12652,14 @@ class StreamClient {
|
|
|
12637
12652
|
this.rejectConnectionId = undefined;
|
|
12638
12653
|
this.resolveConnectionId = undefined;
|
|
12639
12654
|
});
|
|
12655
|
+
this.connectGuestUser = (user) => __awaiter(this, void 0, void 0, function* () {
|
|
12656
|
+
this.guestUserCreatePromise = this.doAxiosRequest('post', '/guest', {
|
|
12657
|
+
user: Object.assign(Object.assign({}, user), { role: 'guest' }),
|
|
12658
|
+
}, { publicEndpoint: true });
|
|
12659
|
+
const response = yield this.guestUserCreatePromise;
|
|
12660
|
+
this.guestUserCreatePromise.finally(() => (this.guestUserCreatePromise = undefined));
|
|
12661
|
+
return this.connectUser(response.user, response.access_token);
|
|
12662
|
+
});
|
|
12640
12663
|
/**
|
|
12641
12664
|
* connectAnonymousUser - Set an anonymous user and open a WebSocket connection
|
|
12642
12665
|
*/
|
|
@@ -12716,6 +12739,7 @@ class StreamClient {
|
|
|
12716
12739
|
if (!options.publicEndpoint) {
|
|
12717
12740
|
yield Promise.all([
|
|
12718
12741
|
this.tokenManager.tokenReady(),
|
|
12742
|
+
this.guestUserCreatePromise,
|
|
12719
12743
|
this.connectionIdPromise,
|
|
12720
12744
|
]);
|
|
12721
12745
|
}
|
|
@@ -13277,10 +13301,7 @@ class StreamVideoClient {
|
|
|
13277
13301
|
};
|
|
13278
13302
|
if (user.type === 'guest') {
|
|
13279
13303
|
connectUser = () => __awaiter(this, void 0, void 0, function* () {
|
|
13280
|
-
|
|
13281
|
-
user: Object.assign(Object.assign({}, user), { role: 'guest' }),
|
|
13282
|
-
});
|
|
13283
|
-
return this.streamClient.connectUser(response.user, response.access_token);
|
|
13304
|
+
return this.streamClient.connectGuestUser(user);
|
|
13284
13305
|
});
|
|
13285
13306
|
}
|
|
13286
13307
|
this.connectionPromise = this.disconnectionPromise
|