@100mslive/hms-video-store 0.2.66 → 0.2.70
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/common/ui-logger.d.ts +3 -0
- package/dist/core/IHMSActions.d.ts +3 -3
- package/dist/core/hmsSDKStore/HMSNotifications.d.ts +3 -2
- package/dist/core/hmsSDKStore/HMSSDKActions.d.ts +1 -9
- package/dist/core/hmsSDKStore/sdkUtils/storeMergeUtils.d.ts +1 -2
- package/dist/core/schema/notification.d.ts +1 -0
- package/dist/hms-video-store.cjs.development.js +87 -123
- package/dist/hms-video-store.cjs.development.js.map +1 -1
- package/dist/hms-video-store.cjs.production.min.js +1 -1
- package/dist/hms-video-store.cjs.production.min.js.map +1 -1
- package/dist/hms-video-store.esm.js +87 -123
- package/dist/hms-video-store.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/common/ui-logger.ts +31 -0
- package/src/core/IHMSActions.ts +3 -3
- package/src/core/hmsSDKStore/HMSNotifications.ts +12 -1
- package/src/core/hmsSDKStore/HMSSDKActions.ts +30 -82
- package/src/core/hmsSDKStore/adapter.ts +1 -1
- package/src/core/hmsSDKStore/sdkUtils/storeMergeUtils.ts +0 -30
- package/src/core/schema/notification.ts +1 -0
- package/src/test/unit/storeMergeUtils.test.ts +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HMSConfig, HMSSimulcastLayer, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSLogLevel, HMSVideoPlugin, HMSAudioPlugin } from '@100mslive/hms-video';
|
|
2
|
-
import { HMSMessageID, HMSPeerID, HMSRoleName, HMSTrackID, HMSTrackSource, IHMSPlaylistActions,
|
|
2
|
+
import { HMSMessageID, HMSPeerID, HMSRoleName, HMSTrackID, HMSTrackSource, IHMSPlaylistActions, HMSChangeMultiTrackStateParams } from './schema';
|
|
3
3
|
import { HMSRoleChangeRequest } from './selectors';
|
|
4
4
|
import { RTMPRecordingConfig } from './hmsSDKStore/sdkTypes';
|
|
5
5
|
/**
|
|
@@ -193,9 +193,9 @@ export interface IHMSActions {
|
|
|
193
193
|
setRemoteTrackEnabled(forRemoteTrackID: HMSTrackID | HMSTrackID[], enabled: boolean): Promise<void>;
|
|
194
194
|
/**
|
|
195
195
|
* Use this to mute/unmute multipe tracks by source, role or type
|
|
196
|
-
* @param {
|
|
196
|
+
* @param {HMSChangeMultiTrackStateParams} params
|
|
197
197
|
*/
|
|
198
|
-
setRemoteTracksEnabled(params:
|
|
198
|
+
setRemoteTracksEnabled(params: HMSChangeMultiTrackStateParams): Promise<void>;
|
|
199
199
|
/**
|
|
200
200
|
* Method to be called with some UI interaction after autoplay error is received
|
|
201
201
|
* Most browsers have limitations where an audio can not be played if there was no user interaction.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IHMSNotifications } from '../IHMSNotifications';
|
|
2
2
|
import { IHMSStore } from '../IHMSStore';
|
|
3
3
|
import * as sdkTypes from './sdkTypes';
|
|
4
|
-
import { HMSNotification, HMSPeer, HMSException, HMSMessage, HMSChangeTrackStateRequest, HMSChangeMultiTrackStateRequest, HMSLeaveRoomRequest, HMSDeviceChangeEvent } from '../schema';
|
|
4
|
+
import { HMSNotification, HMSPeer, HMSException, HMSMessage, HMSTrackID, HMSChangeTrackStateRequest, HMSChangeMultiTrackStateRequest, HMSLeaveRoomRequest, HMSDeviceChangeEvent } from '../schema';
|
|
5
5
|
export declare class HMSNotifications implements IHMSNotifications {
|
|
6
6
|
private id;
|
|
7
7
|
private eventEmitter;
|
|
@@ -10,8 +10,9 @@ export declare class HMSNotifications implements IHMSNotifications {
|
|
|
10
10
|
onNotification: (cb: (notification: HMSNotification) => void) => (() => void);
|
|
11
11
|
sendDeviceChange(request: HMSDeviceChangeEvent): void;
|
|
12
12
|
sendLeaveRoom(request: HMSLeaveRoomRequest): void;
|
|
13
|
+
sendPeerList(peers: HMSPeer[]): void;
|
|
13
14
|
sendPeerUpdate(type: sdkTypes.HMSPeerUpdate, peer: HMSPeer | null): void;
|
|
14
|
-
sendTrackUpdate(type: sdkTypes.HMSTrackUpdate, trackID:
|
|
15
|
+
sendTrackUpdate(type: sdkTypes.HMSTrackUpdate, trackID: HMSTrackID): void;
|
|
15
16
|
sendMessageReceived(message: HMSMessage): void;
|
|
16
17
|
sendError(error: HMSException): void;
|
|
17
18
|
sendReconnecting(error: HMSException): void;
|
|
@@ -145,15 +145,7 @@ export declare class HMSSDKActions implements IHMSActions {
|
|
|
145
145
|
private getStoreLocalTrackIDfromSDKTrack;
|
|
146
146
|
private setProgress;
|
|
147
147
|
private syncPlaylistState;
|
|
148
|
-
|
|
149
|
-
* Handle store update on remote track changes
|
|
150
|
-
* @param {string} action - 'trackAdded' | 'trackUpdate'
|
|
151
|
-
* @param {SDKHMSTrack} track - track added/updated
|
|
152
|
-
* @param {sdkTypes.HMSPeer}peer - peer on which track is added/updated
|
|
153
|
-
*/
|
|
154
|
-
private syncRemoteTrackState;
|
|
155
|
-
private peerUpdateInternal;
|
|
156
|
-
private updateTracksInPeer;
|
|
148
|
+
private sendPeerUpdateNotification;
|
|
157
149
|
/**
|
|
158
150
|
* setState is separate so any future changes to how state change can be done from one place.
|
|
159
151
|
* @param fn
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { HMSPeer, HMSPeerID, HMSTrack, HMSTrackID } from '../../schema';
|
|
2
|
-
import { HMSTrack as SDKHMSTrack } from '@100mslive/hms-video';
|
|
3
2
|
/**
|
|
4
3
|
* updates draftPeers with newPeers ensuring minimal reference changes
|
|
5
4
|
* @remarks
|
|
@@ -10,6 +9,6 @@ import { HMSTrack as SDKHMSTrack } from '@100mslive/hms-video';
|
|
|
10
9
|
* @param newHmsTracks this will be update if required
|
|
11
10
|
* @param newHmsSDkTracks this is future value of local hms tacks map
|
|
12
11
|
*/
|
|
13
|
-
export declare const mergeNewPeersInDraft: (draftPeers: Record<HMSPeerID, HMSPeer>, newPeers: Record<HMSPeerID, Partial<HMSPeer
|
|
12
|
+
export declare const mergeNewPeersInDraft: (draftPeers: Record<HMSPeerID, HMSPeer>, newPeers: Record<HMSPeerID, Partial<HMSPeer>>) => void;
|
|
14
13
|
export declare const mergeNewTracksInDraft: (draftTracks: Record<HMSTrackID, HMSTrack>, newTracks: Record<HMSTrackID, Partial<HMSTrack>>) => void;
|
|
15
14
|
export declare const areArraysEqual: <T>(arr1: T[], arr2?: T[] | undefined) => boolean;
|
|
@@ -16,6 +16,7 @@ export declare enum HMSNotificationSeverity {
|
|
|
16
16
|
export declare enum HMSNotificationTypes {
|
|
17
17
|
PEER_JOINED = "PEER_JOINED",
|
|
18
18
|
PEER_LEFT = "PEER_LEFT",
|
|
19
|
+
PEER_LIST = "PEER_LIST",
|
|
19
20
|
NEW_MESSAGE = "NEW_MESSAGE",
|
|
20
21
|
ERROR = "ERROR",
|
|
21
22
|
RECONNECTING = "RECONNECTING",
|
|
@@ -963,6 +963,7 @@ var createDefaultStoreState = function createDefaultStoreState() {
|
|
|
963
963
|
(function (HMSNotificationTypes) {
|
|
964
964
|
HMSNotificationTypes["PEER_JOINED"] = "PEER_JOINED";
|
|
965
965
|
HMSNotificationTypes["PEER_LEFT"] = "PEER_LEFT";
|
|
966
|
+
HMSNotificationTypes["PEER_LIST"] = "PEER_LIST";
|
|
966
967
|
HMSNotificationTypes["NEW_MESSAGE"] = "NEW_MESSAGE";
|
|
967
968
|
HMSNotificationTypes["ERROR"] = "ERROR";
|
|
968
969
|
HMSNotificationTypes["RECONNECTING"] = "RECONNECTING";
|
|
@@ -995,7 +996,7 @@ var createDefaultStoreState = function createDefaultStoreState() {
|
|
|
995
996
|
* @param newHmsTracks this will be update if required
|
|
996
997
|
* @param newHmsSDkTracks this is future value of local hms tacks map
|
|
997
998
|
*/
|
|
998
|
-
var mergeNewPeersInDraft = function mergeNewPeersInDraft(draftPeers, newPeers
|
|
999
|
+
var mergeNewPeersInDraft = function mergeNewPeersInDraft(draftPeers, newPeers) {
|
|
999
1000
|
var peerIDs = union(Object.keys(draftPeers), Object.keys(newPeers));
|
|
1000
1001
|
|
|
1001
1002
|
for (var _iterator = _createForOfIteratorHelperLoose(peerIDs), _step; !(_step = _iterator()).done;) {
|
|
@@ -1008,7 +1009,6 @@ var mergeNewPeersInDraft = function mergeNewPeersInDraft(draftPeers, newPeers, n
|
|
|
1008
1009
|
newPeer.auxiliaryTracks = oldPeer.auxiliaryTracks;
|
|
1009
1010
|
}
|
|
1010
1011
|
|
|
1011
|
-
handleLocalVideoReplaceTrack(oldPeer, newPeer, newHmsTracks, newHmsSDkTracks);
|
|
1012
1012
|
Object.assign(oldPeer, newPeer);
|
|
1013
1013
|
} else if (isEntityRemoved(oldPeer, newPeer)) {
|
|
1014
1014
|
delete draftPeers[peerID];
|
|
@@ -1096,23 +1096,6 @@ var union = function union(arr1, arr2) {
|
|
|
1096
1096
|
|
|
1097
1097
|
return Array.from(set);
|
|
1098
1098
|
};
|
|
1099
|
-
/**
|
|
1100
|
-
* on replace track, use prev video track id in peer object, this is because we
|
|
1101
|
-
* don't want the peer or peers object reference to change, the fact that the video
|
|
1102
|
-
* track is changed on mute/unmute because of replace track is abstracted
|
|
1103
|
-
*/
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
function handleLocalVideoReplaceTrack(oldPeer, newPeer, newHmsTracks, newHmsSDkTracks) {
|
|
1107
|
-
if (oldPeer.isLocal && oldPeer.videoTrack && newPeer.videoTrack && oldPeer.videoTrack !== newPeer.videoTrack) {
|
|
1108
|
-
newHmsSDkTracks[oldPeer.videoTrack] = newHmsSDkTracks[newPeer.videoTrack];
|
|
1109
|
-
delete newHmsSDkTracks[newPeer.videoTrack];
|
|
1110
|
-
newHmsTracks[oldPeer.videoTrack] = newHmsTracks[newPeer.videoTrack];
|
|
1111
|
-
newHmsTracks[oldPeer.videoTrack].id = oldPeer.videoTrack;
|
|
1112
|
-
delete newHmsTracks[newPeer.videoTrack];
|
|
1113
|
-
newPeer.videoTrack = oldPeer.videoTrack;
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
1099
|
|
|
1117
1100
|
var SDKToHMS = /*#__PURE__*/function () {
|
|
1118
1101
|
function SDKToHMS() {}
|
|
@@ -1127,8 +1110,8 @@ var SDKToHMS = /*#__PURE__*/function () {
|
|
|
1127
1110
|
isLocal: sdkPeer.isLocal,
|
|
1128
1111
|
videoTrack: (_sdkPeer$videoTrack = sdkPeer.videoTrack) == null ? void 0 : _sdkPeer$videoTrack.trackId,
|
|
1129
1112
|
audioTrack: (_sdkPeer$audioTrack = sdkPeer.audioTrack) == null ? void 0 : _sdkPeer$audioTrack.trackId,
|
|
1130
|
-
auxiliaryTracks: sdkPeer.auxiliaryTracks.map(function (
|
|
1131
|
-
return
|
|
1113
|
+
auxiliaryTracks: sdkPeer.auxiliaryTracks.map(function (track) {
|
|
1114
|
+
return track.trackId;
|
|
1132
1115
|
}),
|
|
1133
1116
|
customerUserId: sdkPeer.customerUserId,
|
|
1134
1117
|
customerDescription: sdkPeer.customerDescription
|
|
@@ -1934,6 +1917,19 @@ var HMSLogger = /*#__PURE__*/function () {
|
|
|
1934
1917
|
}
|
|
1935
1918
|
|
|
1936
1919
|
this.log.apply(this, [sdkTypes.HMSLogLevel.ERROR].concat(data));
|
|
1920
|
+
};
|
|
1921
|
+
|
|
1922
|
+
HMSLogger.time = function time(mark) {
|
|
1923
|
+
this.log(sdkTypes.HMSLogLevel.TIME, '[HMSPerformanceTiming]', mark);
|
|
1924
|
+
};
|
|
1925
|
+
|
|
1926
|
+
HMSLogger.timeEnd = function timeEnd(mark) {
|
|
1927
|
+
this.log(sdkTypes.HMSLogLevel.TIMEEND, '[HMSPerformanceTiming]', mark, mark);
|
|
1928
|
+
};
|
|
1929
|
+
|
|
1930
|
+
HMSLogger.cleanUp = function cleanUp() {
|
|
1931
|
+
performance.clearMarks();
|
|
1932
|
+
performance.clearMeasures();
|
|
1937
1933
|
}
|
|
1938
1934
|
/* eslint-disable */
|
|
1939
1935
|
;
|
|
@@ -1990,6 +1986,30 @@ var HMSLogger = /*#__PURE__*/function () {
|
|
|
1990
1986
|
|
|
1991
1987
|
(_console5 = console).error.apply(_console5, [HMS_STORE_TAG].concat(data));
|
|
1992
1988
|
|
|
1989
|
+
break;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
case sdkTypes.HMSLogLevel.TIME:
|
|
1993
|
+
{
|
|
1994
|
+
performance.mark(data[1]);
|
|
1995
|
+
break;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
case sdkTypes.HMSLogLevel.TIMEEND:
|
|
1999
|
+
{
|
|
2000
|
+
var tag = data[0];
|
|
2001
|
+
var mark = data[1];
|
|
2002
|
+
|
|
2003
|
+
try {
|
|
2004
|
+
var entry = performance.measure(mark, mark); //@ts-ignore
|
|
2005
|
+
|
|
2006
|
+
this.log(sdkTypes.HMSLogLevel.DEBUG, tag, mark, entry == null ? void 0 : entry.duration);
|
|
2007
|
+
performance.clearMarks(mark);
|
|
2008
|
+
performance.clearMeasures(mark);
|
|
2009
|
+
} catch (error) {
|
|
2010
|
+
this.log(sdkTypes.HMSLogLevel.DEBUG, tag, mark, error);
|
|
2011
|
+
}
|
|
2012
|
+
|
|
1993
2013
|
break;
|
|
1994
2014
|
}
|
|
1995
2015
|
}
|
|
@@ -2677,42 +2697,26 @@ var HMSSDKActions = /*#__PURE__*/function () {
|
|
|
2677
2697
|
Object.assign(draftStore.playlist, SDKToHMS.convertPlaylist(_this.sdk.getPlaylistManager()));
|
|
2678
2698
|
}, action);
|
|
2679
2699
|
};
|
|
2680
|
-
/**
|
|
2681
|
-
* Handle store update on remote track changes
|
|
2682
|
-
* @param {string} action - 'trackAdded' | 'trackUpdate'
|
|
2683
|
-
* @param {SDKHMSTrack} track - track added/updated
|
|
2684
|
-
* @param {sdkTypes.HMSPeer}peer - peer on which track is added/updated
|
|
2685
|
-
*/
|
|
2686
2700
|
|
|
2701
|
+
this.sendPeerUpdateNotification = function (type, sdkPeer) {
|
|
2702
|
+
var peer = _this.store.getState(selectPeerByID(sdkPeer.peerId));
|
|
2687
2703
|
|
|
2688
|
-
|
|
2689
|
-
_this.setState(function (draftStore) {
|
|
2690
|
-
var draftPeer = draftStore.peers[peer.peerId];
|
|
2691
|
-
/**
|
|
2692
|
-
* in preview -> leave -> join flow or join -> leave -> join flow,
|
|
2693
|
-
* since peer will be cleared by leave, set peer again in the store
|
|
2694
|
-
**/
|
|
2695
|
-
|
|
2696
|
-
if (!draftPeer) {
|
|
2697
|
-
var hmsPeer = SDKToHMS.convertPeer(peer);
|
|
2698
|
-
draftStore.peers[peer.peerId] = hmsPeer;
|
|
2699
|
-
draftPeer = hmsPeer;
|
|
2700
|
-
}
|
|
2704
|
+
var actionName = 'peerUpdate';
|
|
2701
2705
|
|
|
2702
|
-
|
|
2706
|
+
if (type === sdkTypes.HMSPeerUpdate.PEER_JOINED) {
|
|
2707
|
+
actionName = 'peerJoined';
|
|
2708
|
+
} else if (type === sdkTypes.HMSPeerUpdate.PEER_LEFT) {
|
|
2709
|
+
actionName = 'peerLeft';
|
|
2710
|
+
}
|
|
2703
2711
|
|
|
2704
|
-
|
|
2705
|
-
draftStore.tracks[hmsTrack.id] = hmsTrack;
|
|
2712
|
+
_this.syncRoomState(actionName); // if peer wasn't available before sync(will happen if event is peer join)
|
|
2706
2713
|
|
|
2707
|
-
_this.updateTracksInPeer(peer, draftPeer, hmsTrack);
|
|
2708
|
-
} else if (draftStore.tracks[hmsTrack.id]) {
|
|
2709
|
-
Object.assign(draftStore.tracks[hmsTrack.id], hmsTrack);
|
|
2710
|
-
} else {
|
|
2711
|
-
_this.logPossibleInconsistency("track " + hmsTrack.id + " not present, unable to update track");
|
|
2712
|
-
}
|
|
2713
2714
|
|
|
2714
|
-
|
|
2715
|
-
|
|
2715
|
+
if (!peer) {
|
|
2716
|
+
peer = _this.store.getState(selectPeerByID(sdkPeer.peerId));
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
_this.hmsNotifications.sendPeerUpdate(type, peer);
|
|
2716
2720
|
};
|
|
2717
2721
|
/**
|
|
2718
2722
|
* setState is separate so any future changes to how state change can be done from one place.
|
|
@@ -3874,6 +3878,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
|
|
|
3874
3878
|
}, reason);
|
|
3875
3879
|
this.isRoomJoinCalled = false;
|
|
3876
3880
|
this.hmsSDKTracks = {};
|
|
3881
|
+
HMSLogger.cleanUp();
|
|
3877
3882
|
};
|
|
3878
3883
|
|
|
3879
3884
|
_proto.sdkJoinWithListeners = function sdkJoinWithListeners(config) {
|
|
@@ -4122,7 +4127,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
|
|
|
4122
4127
|
_proto.syncRoomState = function syncRoomState(action) {
|
|
4123
4128
|
var _this9 = this;
|
|
4124
4129
|
|
|
4125
|
-
|
|
4130
|
+
HMSLogger.time("store-sync-" + action);
|
|
4126
4131
|
var newHmsPeers = {};
|
|
4127
4132
|
var newHmsPeerIDs = []; // to add in room.peers
|
|
4128
4133
|
|
|
@@ -4166,7 +4171,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
|
|
|
4166
4171
|
var draftPeers = draftStore.peers;
|
|
4167
4172
|
var draftTracks = draftStore.tracks; // the order of below statements are important as merge functions are mutating
|
|
4168
4173
|
|
|
4169
|
-
mergeNewPeersInDraft(draftPeers, newHmsPeers
|
|
4174
|
+
mergeNewPeersInDraft(draftPeers, newHmsPeers);
|
|
4170
4175
|
mergeNewTracksInDraft(draftTracks, newHmsTracks);
|
|
4171
4176
|
Object.assign(draftStore.settings, newMediaSettings);
|
|
4172
4177
|
_this9.hmsSDKTracks = newHmsSDkTracks;
|
|
@@ -4174,7 +4179,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
|
|
|
4174
4179
|
Object.assign(draftStore.playlist, SDKToHMS.convertPlaylist(_this9.sdk.getPlaylistManager()));
|
|
4175
4180
|
Object.assign(draftStore.room, SDKToHMS.convertRecordingRTMPState(recording, rtmp));
|
|
4176
4181
|
}, action);
|
|
4177
|
-
|
|
4182
|
+
HMSLogger.timeEnd("store-sync-" + action);
|
|
4178
4183
|
};
|
|
4179
4184
|
|
|
4180
4185
|
_proto.onPreview = function onPreview(sdkRoom) {
|
|
@@ -4213,19 +4218,28 @@ var HMSSDKActions = /*#__PURE__*/function () {
|
|
|
4213
4218
|
};
|
|
4214
4219
|
|
|
4215
4220
|
_proto.onPeerUpdate = function onPeerUpdate(type, sdkPeer) {
|
|
4216
|
-
if (
|
|
4221
|
+
if ([sdkTypes.HMSPeerUpdate.BECAME_DOMINANT_SPEAKER, sdkTypes.HMSPeerUpdate.RESIGNED_DOMINANT_SPEAKER].includes(type)) {
|
|
4217
4222
|
return; // ignore, high frequency update so no point of syncing peers
|
|
4218
|
-
}
|
|
4223
|
+
}
|
|
4224
|
+
|
|
4225
|
+
if (Array.isArray(sdkPeer)) {
|
|
4219
4226
|
this.syncRoomState('peersJoined');
|
|
4227
|
+
var hmsPeers = [];
|
|
4220
4228
|
|
|
4221
4229
|
for (var _iterator3 = _createForOfIteratorHelperLoose(sdkPeer), _step3; !(_step3 = _iterator3()).done;) {
|
|
4222
4230
|
var peer = _step3.value;
|
|
4223
4231
|
var hmsPeer = this.store.getState(selectPeerByID(peer.peerId));
|
|
4224
|
-
|
|
4232
|
+
|
|
4233
|
+
if (hmsPeer) {
|
|
4234
|
+
hmsPeers.push(hmsPeer);
|
|
4235
|
+
}
|
|
4225
4236
|
}
|
|
4226
|
-
|
|
4227
|
-
this.
|
|
4237
|
+
|
|
4238
|
+
this.hmsNotifications.sendPeerList(hmsPeers);
|
|
4239
|
+
return;
|
|
4228
4240
|
}
|
|
4241
|
+
|
|
4242
|
+
this.sendPeerUpdateNotification(type, sdkPeer);
|
|
4229
4243
|
};
|
|
4230
4244
|
|
|
4231
4245
|
_proto.onTrackUpdate = function onTrackUpdate(type, track, peer) {
|
|
@@ -4236,7 +4250,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
|
|
|
4236
4250
|
this.handleTrackRemove(track, peer);
|
|
4237
4251
|
} else {
|
|
4238
4252
|
var actionName = type === sdkTypes.HMSTrackUpdate.TRACK_ADDED ? 'trackAdded' : 'trackUpdate';
|
|
4239
|
-
this.
|
|
4253
|
+
this.syncRoomState(actionName);
|
|
4240
4254
|
this.hmsNotifications.sendTrackUpdate(type, track.trackId);
|
|
4241
4255
|
}
|
|
4242
4256
|
};
|
|
@@ -4418,22 +4432,23 @@ var HMSSDKActions = /*#__PURE__*/function () {
|
|
|
4418
4432
|
|
|
4419
4433
|
this.setState(function (draftStore) {
|
|
4420
4434
|
var hmsPeer = draftStore.peers[sdkPeer.peerId];
|
|
4421
|
-
var draftTracks = draftStore.tracks;
|
|
4435
|
+
var draftTracks = draftStore.tracks;
|
|
4436
|
+
var trackId = sdkTrack.trackId; // find and remove the exact track from hmsPeer
|
|
4422
4437
|
|
|
4423
|
-
if (_this12.isSameStoreSDKTrack(
|
|
4438
|
+
if (_this12.isSameStoreSDKTrack(trackId, hmsPeer == null ? void 0 : hmsPeer.audioTrack)) {
|
|
4424
4439
|
hmsPeer == null ? true : delete hmsPeer.audioTrack;
|
|
4425
|
-
} else if (_this12.isSameStoreSDKTrack(
|
|
4440
|
+
} else if (_this12.isSameStoreSDKTrack(trackId, hmsPeer == null ? void 0 : hmsPeer.videoTrack)) {
|
|
4426
4441
|
hmsPeer == null ? true : delete hmsPeer.videoTrack;
|
|
4427
4442
|
} else {
|
|
4428
|
-
var auxiliaryIndex = hmsPeer == null ? void 0 : hmsPeer.auxiliaryTracks.indexOf(
|
|
4443
|
+
var auxiliaryIndex = hmsPeer == null ? void 0 : hmsPeer.auxiliaryTracks.indexOf(trackId);
|
|
4429
4444
|
|
|
4430
|
-
if (auxiliaryIndex > -1 && _this12.isSameStoreSDKTrack(
|
|
4445
|
+
if (auxiliaryIndex > -1 && _this12.isSameStoreSDKTrack(trackId, hmsPeer == null ? void 0 : hmsPeer.auxiliaryTracks[auxiliaryIndex])) {
|
|
4431
4446
|
hmsPeer == null ? void 0 : hmsPeer.auxiliaryTracks.splice(auxiliaryIndex, 1);
|
|
4432
4447
|
}
|
|
4433
4448
|
}
|
|
4434
4449
|
|
|
4435
|
-
delete draftTracks[
|
|
4436
|
-
delete _this12.hmsSDKTracks[
|
|
4450
|
+
delete draftTracks[trackId];
|
|
4451
|
+
delete _this12.hmsSDKTracks[trackId];
|
|
4437
4452
|
}, 'trackRemoved');
|
|
4438
4453
|
};
|
|
4439
4454
|
|
|
@@ -4810,62 +4825,6 @@ var HMSSDKActions = /*#__PURE__*/function () {
|
|
|
4810
4825
|
});
|
|
4811
4826
|
};
|
|
4812
4827
|
|
|
4813
|
-
_proto.peerUpdateInternal = function peerUpdateInternal(type, sdkPeer) {
|
|
4814
|
-
var _this14 = this;
|
|
4815
|
-
|
|
4816
|
-
// store peer in case it doesn't exist later(will happen if event is peer leave)
|
|
4817
|
-
var peer = this.store.getState(selectPeerByID(sdkPeer.peerId));
|
|
4818
|
-
var actionName = 'peerUpdate';
|
|
4819
|
-
|
|
4820
|
-
if (type === sdkTypes.HMSPeerUpdate.PEER_JOINED) {
|
|
4821
|
-
actionName = 'peerJoined';
|
|
4822
|
-
} else if (type === sdkTypes.HMSPeerUpdate.PEER_LEFT) {
|
|
4823
|
-
actionName = 'peerLeft';
|
|
4824
|
-
}
|
|
4825
|
-
|
|
4826
|
-
this.setState(function (draftStore) {
|
|
4827
|
-
if (actionName === 'peerLeft') {
|
|
4828
|
-
var index = draftStore.room.peers.indexOf(sdkPeer.peerId);
|
|
4829
|
-
|
|
4830
|
-
if (index > -1) {
|
|
4831
|
-
draftStore.room.peers.splice(index, 1);
|
|
4832
|
-
}
|
|
4833
|
-
|
|
4834
|
-
delete draftStore.peers[sdkPeer.peerId];
|
|
4835
|
-
delete _this14.hmsSDKPeers[sdkPeer.peerId];
|
|
4836
|
-
} else {
|
|
4837
|
-
var hmsPeer = SDKToHMS.convertPeer(sdkPeer);
|
|
4838
|
-
|
|
4839
|
-
if (draftStore.peers[hmsPeer.id]) {
|
|
4840
|
-
Object.assign(draftStore.peers[hmsPeer.id], hmsPeer);
|
|
4841
|
-
} else {
|
|
4842
|
-
draftStore.peers[hmsPeer.id] = hmsPeer;
|
|
4843
|
-
draftStore.room.peers.push(hmsPeer.id);
|
|
4844
|
-
}
|
|
4845
|
-
|
|
4846
|
-
_this14.hmsSDKPeers[sdkPeer.peerId] = sdkPeer;
|
|
4847
|
-
}
|
|
4848
|
-
}, actionName); // if peer wasn't available before sync(will happen if event is peer join)
|
|
4849
|
-
|
|
4850
|
-
if (!peer) {
|
|
4851
|
-
peer = this.store.getState(selectPeerByID(sdkPeer.peerId));
|
|
4852
|
-
}
|
|
4853
|
-
|
|
4854
|
-
this.hmsNotifications.sendPeerUpdate(type, peer);
|
|
4855
|
-
};
|
|
4856
|
-
|
|
4857
|
-
_proto.updateTracksInPeer = function updateTracksInPeer(peer, draftPeer, hmsTrack) {
|
|
4858
|
-
var _peer$audioTrack, _peer$videoTrack;
|
|
4859
|
-
|
|
4860
|
-
if (((_peer$audioTrack = peer.audioTrack) == null ? void 0 : _peer$audioTrack.trackId) === hmsTrack.id) {
|
|
4861
|
-
draftPeer.audioTrack = hmsTrack.id;
|
|
4862
|
-
} else if (((_peer$videoTrack = peer.videoTrack) == null ? void 0 : _peer$videoTrack.trackId) === hmsTrack.id) {
|
|
4863
|
-
draftPeer.videoTrack = hmsTrack.id;
|
|
4864
|
-
} else if (!draftPeer.auxiliaryTracks.includes(hmsTrack.id)) {
|
|
4865
|
-
draftPeer.auxiliaryTracks.push(hmsTrack.id);
|
|
4866
|
-
}
|
|
4867
|
-
};
|
|
4868
|
-
|
|
4869
4828
|
return HMSSDKActions;
|
|
4870
4829
|
}();
|
|
4871
4830
|
|
|
@@ -4906,6 +4865,11 @@ var HMSNotifications = /*#__PURE__*/function () {
|
|
|
4906
4865
|
this.emitEvent(notification);
|
|
4907
4866
|
};
|
|
4908
4867
|
|
|
4868
|
+
_proto.sendPeerList = function sendPeerList(peers) {
|
|
4869
|
+
var notification = this.createNotification(exports.HMSNotificationTypes.PEER_LIST, peers, exports.HMSNotificationSeverity.INFO);
|
|
4870
|
+
this.emitEvent(notification);
|
|
4871
|
+
};
|
|
4872
|
+
|
|
4909
4873
|
_proto.sendPeerUpdate = function sendPeerUpdate(type, peer) {
|
|
4910
4874
|
var hmsPeer = this.store.getState(selectPeerByID(peer == null ? void 0 : peer.id)) || peer;
|
|
4911
4875
|
var notificationType = PEER_NOTIFICATION_TYPES[type];
|