@100mslive/hms-video-store 0.6.1-alpha.0 → 0.6.1-alpha.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.
@@ -1,13 +1,13 @@
1
1
  import { HMSPeer, HMSSpeaker, HMSStore, HMSTrack } from '../../core';
2
- import { HMSPlaylist, HMSRole } from '../../core/schema';
2
+ import { HMSAudioTrack, HMSPlaylist, HMSRole, HMSScreenVideoTrack, HMSVideoTrack } from '../../core/schema';
3
3
  export declare let localPeer: HMSPeer;
4
4
  export declare let remotePeerOne: HMSPeer;
5
5
  export declare let remotePeerTwo: HMSPeer;
6
6
  export declare let peerScreenSharing: HMSPeer;
7
- export declare let localVideo: HMSTrack;
8
- export declare let localAudio: HMSTrack;
9
- export declare let remoteVideo: HMSTrack;
10
- export declare let screenShare: HMSTrack;
7
+ export declare let localVideo: HMSVideoTrack;
8
+ export declare let localAudio: HMSAudioTrack;
9
+ export declare let remoteVideo: HMSVideoTrack;
10
+ export declare let screenShare: HMSScreenVideoTrack;
11
11
  export declare let auxiliaryAudio: HMSTrack;
12
12
  export declare let localSpeaker: HMSSpeaker;
13
13
  export declare let screenshareAudio: HMSTrack;
@@ -1,3 +1,5 @@
1
- import { HMSPeer, HMSTrack, HMSTrackType } from '../core';
2
- export declare const makeFakeTrack: (type?: HMSTrackType) => HMSTrack;
1
+ import { HMSAudioTrack, HMSPeer, HMSVideoTrack, HMSTrackType } from '../core';
2
+ declare type HMSObjectType<T> = T extends 'audio' ? HMSAudioTrack : T extends 'video' ? HMSVideoTrack : HMSVideoTrack;
3
+ export declare const makeFakeTrack: <T extends HMSTrackType>(type?: T | undefined) => HMSObjectType<T>;
3
4
  export declare const makeFakePeer: () => HMSPeer;
5
+ export {};
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.6.1-alpha.0",
2
+ "version": "0.6.1-alpha.2",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.js",
@@ -41,7 +41,7 @@
41
41
  "author": "100ms",
42
42
  "sideEffects": false,
43
43
  "dependencies": {
44
- "@100mslive/hms-video": "0.5.1-alpha.0",
44
+ "@100mslive/hms-video": "0.5.1-alpha.2",
45
45
  "eventemitter2": "^6.4.7",
46
46
  "immer": "^9.0.6",
47
47
  "reselect": "4.0.0",
@@ -66,5 +66,5 @@
66
66
  "url": "https://github.com/100mslive/hms-video-store/issues"
67
67
  },
68
68
  "homepage": "https://github.com/100mslive/hms-video-store#readme",
69
- "gitHead": "1a0835104005a471d7b813a1f1d14268a77379ca"
69
+ "gitHead": "7450dfa08f3ccf63a603a62c70eafbbeea26ab1e"
70
70
  }
@@ -348,6 +348,24 @@ export interface IHMSActions {
348
348
  */
349
349
  changeMetadata(metadata: string | any): Promise<void>;
350
350
 
351
+ /**
352
+ * If you want to update the metadata of the session. If an object is passed, it should be serializable using
353
+ * JSON.stringify.
354
+ *
355
+ * Session metadata is available to every peer in the room and is persisted throughout a session
356
+ * till the last peer leaves a room
357
+ *
358
+ * @alpha - the API is not stable and might have breaking changes later
359
+ */
360
+ setSessionMetadata(metadata: any, options?: { localOnly: boolean }): Promise<void>;
361
+
362
+ /**
363
+ * Fetch the current room metadata from the server and populate it in store
364
+ *
365
+ * @alpha - the API is not stable and might have breaking changes later
366
+ */
367
+ populateSessionMetadata(): Promise<void>;
368
+
351
369
  /**
352
370
  * Set the type of logs from the SDK you want to be logged in the browser console.
353
371
  *
@@ -34,7 +34,7 @@ export class HMSNotifications implements IHMSNotifications {
34
34
 
35
35
  constructor(store: IHMSStore) {
36
36
  this.store = store;
37
- this.eventEmitter = new EventEmitter();
37
+ this.eventEmitter = new EventEmitter({ maxListeners: Object.keys(HMSNotificationTypes).length });
38
38
  }
39
39
  onNotification = <T extends HMSNotificationTypeParam>(cb: HMSNotificationCallback<T>, type?: T) => {
40
40
  const eventCallback = (notification: HMSNotificationInCallback<T>) => {
@@ -12,6 +12,7 @@ import {
12
12
  HMSTrack,
13
13
  HMSTrackID,
14
14
  HMSTrackSource,
15
+ HMSVideoTrack,
15
16
  IHMSPlaylistActions,
16
17
  } from '../schema';
17
18
  import { IHMSActions } from '../IHMSActions';
@@ -34,6 +35,7 @@ import {
34
35
  selectRoomStarted,
35
36
  selectRoomState,
36
37
  selectTrackByID,
38
+ selectVideoTrackByID,
37
39
  selectTracksMap,
38
40
  } from '../selectors';
39
41
  import { HMSLogger } from '../../common/ui-logger';
@@ -573,6 +575,22 @@ export class HMSSDKActions implements IHMSActions {
573
575
  await this.sdk.changeMetadata(metadata);
574
576
  }
575
577
 
578
+ async setSessionMetadata(metadata: any, options = { localOnly: false }) {
579
+ if (!options.localOnly) {
580
+ await this.sdk.setSessionMetadata(metadata);
581
+ }
582
+ this.setState(draftStore => {
583
+ draftStore.sessionMetadata = metadata;
584
+ }, `setSessionMetadata${options.localOnly ? 'LocalOnly' : ''}`);
585
+ }
586
+
587
+ async populateSessionMetadata(): Promise<void> {
588
+ const metadata = await this.sdk.getSessionMetadata();
589
+ this.setState(draftStore => {
590
+ draftStore.sessionMetadata = metadata;
591
+ }, 'populateSessionMetadata');
592
+ }
593
+
576
594
  async setRemoteTrackEnabled(trackID: HMSTrackID | HMSTrackID[], enabled: boolean) {
577
595
  if (typeof trackID === 'string') {
578
596
  const track = this.hmsSDKTracks[trackID];
@@ -1071,13 +1089,14 @@ export class HMSSDKActions implements IHMSActions {
1071
1089
  private updateVideoLayer(trackID: string, action: string) {
1072
1090
  const sdkTrack = this.hmsSDKTracks[trackID];
1073
1091
  if (sdkTrack && sdkTrack instanceof SDKHMSRemoteVideoTrack) {
1074
- const storeTrack = this.store.getState(selectTrackByID(trackID));
1092
+ const storeTrack = this.store.getState(selectVideoTrackByID(trackID));
1075
1093
  const hasFieldChanged =
1076
1094
  storeTrack?.layer !== sdkTrack.getSimulcastLayer() || storeTrack?.degraded !== sdkTrack.degraded;
1077
1095
  if (hasFieldChanged) {
1078
1096
  this.setState(draft => {
1079
- draft.tracks[trackID].layer = sdkTrack.getSimulcastLayer();
1080
- draft.tracks[trackID].degraded = sdkTrack.degraded;
1097
+ const track = draft.tracks[trackID] as HMSVideoTrack;
1098
+ track.layer = sdkTrack.getSimulcastLayer();
1099
+ track.degraded = sdkTrack.degraded;
1081
1100
  }, action);
1082
1101
  }
1083
1102
  }
@@ -1149,7 +1168,7 @@ export class HMSSDKActions implements IHMSActions {
1149
1168
  track.setVolume(value);
1150
1169
  this.setState(draftStore => {
1151
1170
  const track = draftStore.tracks[trackId];
1152
- if (track) {
1171
+ if (track && track.type === 'audio') {
1153
1172
  track.volume = value;
1154
1173
  }
1155
1174
  }, 'trackVolume');
@@ -7,6 +7,7 @@ import {
7
7
  HMSTrack as SDKHMSTrack,
8
8
  } from '@100mslive/hms-video';
9
9
  import {
10
+ HMSAudioTrack,
10
11
  HMSDeviceChangeEvent,
11
12
  HMSException,
12
13
  HMSMessage,
@@ -20,6 +21,7 @@ import {
20
21
  HMSRoom,
21
22
  HMSTrack,
22
23
  HMSTrackFacingMode,
24
+ HMSVideoTrack,
23
25
  } from '../schema';
24
26
 
25
27
  import * as sdkTypes from './sdkTypes';
@@ -58,27 +60,29 @@ export class SDKToHMS {
58
60
  enabled: sdkTrack.enabled,
59
61
  displayEnabled: sdkTrack.enabled,
60
62
  peerId: sdkTrack.peerId || peerId,
61
- };
63
+ } as HMSTrack;
62
64
  this.enrichTrack(track, sdkTrack);
63
65
  return track;
64
66
  }
65
67
 
66
68
  static enrichTrack(track: HMSTrack, sdkTrack: SDKHMSTrack) {
67
69
  const mediaSettings = sdkTrack.getMediaTrackSettings();
68
- if (track.source === 'screen' && track.type === 'video') {
69
- // @ts-ignore
70
- track.displaySurface = mediaSettings.displaySurface;
71
- }
72
- if (track.type === 'video') {
73
- track.facingMode = mediaSettings.facingMode as HMSTrackFacingMode;
74
- }
75
- track.height = mediaSettings.height;
76
- track.width = mediaSettings.width;
70
+
77
71
  if (sdkTrack instanceof SDKHMSRemoteAudioTrack) {
78
- track.volume = sdkTrack.getVolume() || 0;
72
+ (track as HMSAudioTrack).volume = sdkTrack.getVolume() || 0;
79
73
  }
80
74
  SDKToHMS.updateDeviceID(track, sdkTrack);
81
- SDKToHMS.enrichVideoTrack(track, sdkTrack);
75
+ if (track.type === 'video') {
76
+ if (track.source === 'screen') {
77
+ // @ts-ignore
78
+ track.displaySurface = mediaSettings.displaySurface;
79
+ } else if (track.source === 'regular') {
80
+ (track as HMSVideoTrack).facingMode = mediaSettings.facingMode as HMSTrackFacingMode;
81
+ }
82
+ track.height = mediaSettings.height;
83
+ track.width = mediaSettings.width;
84
+ SDKToHMS.enrichVideoTrack(track as HMSVideoTrack, sdkTrack);
85
+ }
82
86
  SDKToHMS.enrichPluginsDetails(track, sdkTrack);
83
87
  }
84
88
 
@@ -90,7 +94,7 @@ export class SDKToHMS {
90
94
  }
91
95
  }
92
96
 
93
- static enrichVideoTrack(track: HMSTrack, sdkTrack: SDKHMSTrack) {
97
+ static enrichVideoTrack(track: HMSVideoTrack, sdkTrack: SDKHMSTrack) {
94
98
  if (sdkTrack instanceof SDKHMSRemoteVideoTrack) {
95
99
  track.layer = sdkTrack.getSimulcastLayer();
96
100
  track.degraded = sdkTrack.degraded;
@@ -1,4 +1,4 @@
1
- import { HMSPeer, HMSPeerID, HMSTrack, HMSTrackID } from '../../schema';
1
+ import { HMSPeer, HMSPeerID, HMSScreenVideoTrack, HMSTrack, HMSTrackID, HMSVideoTrack } from '../../schema';
2
2
  import { HMSPeerStats, HMSTrackStats } from '../sdkTypes';
3
3
 
4
4
  /**
@@ -76,8 +76,12 @@ const mergeTrackArrayFields = (oldTrack: HMSTrack, newTrack: Partial<HMSTrack>)
76
76
  if (oldTrack.plugins && areArraysEqual(oldTrack.plugins, newTrack.plugins)) {
77
77
  newTrack.plugins = oldTrack.plugins;
78
78
  }
79
- if (oldTrack.layerDefinitions && areArraysEqual(oldTrack.layerDefinitions, newTrack.layerDefinitions)) {
80
- newTrack.layerDefinitions = oldTrack.layerDefinitions;
79
+ if (
80
+ oldTrack.type === 'video' &&
81
+ oldTrack.layerDefinitions &&
82
+ areArraysEqual(oldTrack.layerDefinitions, (newTrack as HMSVideoTrack | HMSScreenVideoTrack).layerDefinitions)
83
+ ) {
84
+ (newTrack as HMSVideoTrack | HMSScreenVideoTrack).layerDefinitions = oldTrack.layerDefinitions;
81
85
  }
82
86
  };
83
87
 
@@ -81,6 +81,7 @@ export type HMSNotification =
81
81
  | HMSChangeMultiTrackStateRequestNotification
82
82
  | HMSLeaveRoomRequestNotification
83
83
  | HMSDeviceChangeEventNotification
84
+ | HMSReconnectionNotification
84
85
  | HMSPlaylistItemNotification<any>;
85
86
 
86
87
  export enum HMSNotificationSeverity {
@@ -133,7 +134,7 @@ export type HMSNotificationMapping<T extends HMSNotificationTypes, C = any> = {
133
134
  [HMSNotificationTypes.ROOM_ENDED]: HMSLeaveRoomRequestNotification;
134
135
  [HMSNotificationTypes.REMOVED_FROM_ROOM]: HMSLeaveRoomRequestNotification;
135
136
  [HMSNotificationTypes.DEVICE_CHANGE_UPDATE]: HMSDeviceChangeEventNotification;
136
- [HMSNotificationTypes.PLAYLIST_TRACK_ENDED]: HMSPlaylistItem<C>;
137
+ [HMSNotificationTypes.PLAYLIST_TRACK_ENDED]: HMSPlaylistItemNotification<C>;
137
138
  [HMSNotificationTypes.ERROR]: HMSExceptionNotification;
138
139
  [HMSNotificationTypes.CHANGE_TRACK_STATE_REQUEST]: HMSChangeTrackStateRequestNotification;
139
140
  [HMSNotificationTypes.CHANGE_MULTI_TRACK_STATE_REQUEST]: HMSChangeMultiTrackStateRequestNotification;
@@ -40,25 +40,45 @@ export interface HMSPeer {
40
40
  * deviceID - this is the ID of the source device for the track. This can be a dummy ID when track is on mute.
41
41
  * degraded - tells whether the track has been degraded(receiving lower video quality/no video) due to bad network locally
42
42
  */
43
- export interface HMSTrack {
43
+
44
+ interface BaseTrack {
44
45
  id: HMSTrackID;
45
46
  source?: HMSTrackSource;
46
47
  type: HMSTrackType;
47
48
  enabled: boolean;
48
- height?: number;
49
- width?: number;
49
+ displayEnabled?: boolean;
50
50
  peerId?: string;
51
51
  deviceID?: string;
52
52
  plugins?: string[];
53
- displayEnabled?: boolean;
53
+ }
54
+
55
+ export interface HMSAudioTrack extends BaseTrack {
56
+ source: 'regular' | 'audioplaylist' | string;
57
+ type: 'audio';
54
58
  volume?: number;
59
+ }
60
+ export interface HMSScreenAudioTrack extends HMSAudioTrack {
61
+ source: 'screen';
62
+ type: 'audio';
63
+ }
64
+ export interface HMSVideoTrack extends BaseTrack {
65
+ source: 'regular' | 'videoplaylist' | string;
66
+ type: 'video';
67
+ facingMode?: HMSTrackFacingMode;
55
68
  layer?: HMSSimulcastLayer;
56
69
  layerDefinitions?: SimulcastLayerDefinition[];
70
+ height?: number;
71
+ width?: number;
57
72
  degraded?: boolean;
73
+ }
74
+
75
+ export interface HMSScreenVideoTrack extends Omit<HMSVideoTrack, 'facingMode'> {
76
+ source: 'screen';
58
77
  displaySurface?: HMSTrackDisplaySurface;
59
- facingMode?: HMSTrackFacingMode;
60
78
  }
61
79
 
80
+ export type HMSTrack = HMSVideoTrack | HMSAudioTrack | HMSScreenVideoTrack | HMSScreenAudioTrack;
81
+
62
82
  /**
63
83
  * HMS Speaker stores the details of peers speaking at any point of time along with
64
84
  * their audio levels. This can be used to current speakers or highlight videotiles.
@@ -28,6 +28,7 @@ export interface HMSStore {
28
28
  roles: Record<string, HMSRole>;
29
29
  appData?: Record<string, any>;
30
30
  roleChangeRequests: HMSRoleChangeStoreRequest[];
31
+ sessionMetadata?: any;
31
32
  errors: HMSException[]; // for the convenience of debugging and seeing any error in devtools
32
33
  }
33
34
 
@@ -1,4 +1,4 @@
1
- import { HMSPeer, HMSStore, HMSTrack, HMSTrackID } from '../schema';
1
+ import { HMSPeer, HMSStore, HMSTrack, HMSTrackID, HMSVideoTrack } from '../schema';
2
2
 
3
3
  type trackCheck = (track: HMSTrack | undefined) => boolean | undefined;
4
4
 
@@ -41,8 +41,11 @@ export function isVideoPlaylist(track: HMSTrack | undefined) {
41
41
  return track && track.source === 'videoplaylist';
42
42
  }
43
43
 
44
- export function isDegraded(track: HMSTrack | undefined) {
45
- return Boolean(track?.degraded);
44
+ export function isDegraded(track: HMSVideoTrack) {
45
+ if (track) {
46
+ return Boolean(track?.degraded);
47
+ }
48
+ return false;
46
49
  }
47
50
 
48
51
  export function isTrackEnabled(store: HMSStore, trackID?: string) {
@@ -1,4 +1,4 @@
1
- import { HMSMessage, HMSPeer, HMSPeerID, HMSRoom, HMSRoomState, HMSStore } from '../schema';
1
+ import { HMSMessage, HMSPeer, HMSPeerID, HMSRoom, HMSRoomState, HMSStore, HMSVideoTrack } from '../schema';
2
2
  import { createSelector } from 'reselect';
3
3
  // noinspection ES6PreferShortImport
4
4
  import { HMSRole } from '../hmsSDKStore/sdkTypes';
@@ -317,7 +317,9 @@ export const selectPeerSharingAudioPlaylist = createSelector(selectPeersMap, sel
317
317
  /**
318
318
  * Select an array of tracks that have been degraded(receiving lower video quality/no video) due to bad network locally.
319
319
  */
320
- export const selectDegradedTracks = createSelector(selectTracks, tracks => tracks.filter(isDegraded));
320
+ export const selectDegradedTracks = createSelector(selectTracks, tracks =>
321
+ (tracks as HMSVideoTrack[]).filter(isDegraded),
322
+ );
321
323
 
322
324
  /**
323
325
  * Select the number of messages(sent and received).
@@ -392,3 +394,5 @@ export const selectRTMPState = createSelector(selectRoom, room => room.rtmp);
392
394
  export const selectHLSState = createSelector(selectRoom, room => room.hls);
393
395
  export const selectSessionId = createSelector(selectRoom, room => room.sessionId);
394
396
  export const selectRoomStartTime = createSelector(selectRoom, room => room.startedAt);
397
+ /** @alpha */
398
+ export const selectSessionMetadata = (store: HMSStore) => store.sessionMetadata;
@@ -7,7 +7,16 @@ import {
7
7
  selectPeersMap,
8
8
  selectTracksMap,
9
9
  } from './selectors';
10
- import { HMSPeerID, HMSRoleName, HMSStore, HMSTrack, HMSTrackID } from '../schema';
10
+ import {
11
+ HMSPeerID,
12
+ HMSRoleName,
13
+ HMSStore,
14
+ HMSTrack,
15
+ HMSTrackID,
16
+ HMSAudioTrack,
17
+ HMSVideoTrack,
18
+ HMSScreenVideoTrack,
19
+ } from '../schema';
11
20
  import {
12
21
  getPeerTracksByCondition,
13
22
  isAudio,
@@ -32,6 +41,49 @@ const selectTrackByIDBare = createSelector([selectTracksMap, selectTrackID], (st
32
41
  trackID ? storeTracks[trackID] : null,
33
42
  );
34
43
 
44
+ const selectVideoTrackByIDBare = createSelector([selectTracksMap, selectTrackID], (storeTracks, trackID) => {
45
+ if (!trackID) {
46
+ return null;
47
+ }
48
+ const track = storeTracks[trackID] as HMSVideoTrack;
49
+ if (track.type === 'video') {
50
+ return track;
51
+ }
52
+ return null;
53
+ });
54
+
55
+ const selectAudioTrackByIDBare = createSelector([selectTracksMap, selectTrackID], (storeTracks, trackID) => {
56
+ if (!trackID) {
57
+ return null;
58
+ }
59
+ const track = storeTracks[trackID] as HMSAudioTrack;
60
+ if (track.type === 'audio') {
61
+ return track;
62
+ }
63
+ return null;
64
+ });
65
+
66
+ const selectScreenAudioTrackByIDBare = createSelector([selectTracksMap, selectTrackID], (storeTracks, trackID) => {
67
+ if (!trackID) {
68
+ return null;
69
+ }
70
+ const track = storeTracks[trackID] as HMSAudioTrack;
71
+ if (track.type === 'audio' && track.source === 'screen') {
72
+ return track;
73
+ }
74
+ return null;
75
+ });
76
+ const selectScreenVideoTrackByIDBare = createSelector([selectTracksMap, selectTrackID], (storeTracks, trackID) => {
77
+ if (!trackID) {
78
+ return null;
79
+ }
80
+ const track = storeTracks[trackID] as HMSScreenVideoTrack;
81
+ if (track.type === 'video' && track.source === 'screen') {
82
+ return track;
83
+ }
84
+ return null;
85
+ });
86
+
35
87
  /**
36
88
  * Select the {@link HMSPeer} object given a peer ID.
37
89
  */
@@ -81,13 +133,33 @@ export const selectPeerNameByID = byIDCurry(createSelector(selectPeerByIDBare, p
81
133
  */
82
134
  export const selectTrackByID = byIDCurry(selectTrackByIDBare);
83
135
 
136
+ /**
137
+ * Select the {@link HMSVideoTrack} object given a track ID.
138
+ */
139
+ export const selectVideoTrackByID = byIDCurry(selectVideoTrackByIDBare);
140
+
141
+ /**
142
+ * Select the {@link HMSAudioTrack} object given a track ID.
143
+ */
144
+ export const selectAudioTrackByID = byIDCurry(selectAudioTrackByIDBare);
145
+
146
+ /**
147
+ * Select the {@link HMSScreenAudioTrack} object given a track ID.
148
+ */
149
+ export const selectScreenAudioTrackByID = byIDCurry(selectScreenAudioTrackByIDBare);
150
+
151
+ /**
152
+ * Select the {@link HMSScreenVideoTrack} object given a track ID.
153
+ */
154
+ export const selectScreenVideoTrackByID = byIDCurry(selectScreenVideoTrackByIDBare);
155
+
84
156
  /**
85
157
  * Select the primary video track of a peer given a peer ID.
86
158
  */
87
- export const selectVideoTrackByPeerID = byIDCurry((store: HMSStore, peerID?: HMSPeerID): HMSTrack | undefined => {
159
+ export const selectVideoTrackByPeerID = byIDCurry((store: HMSStore, peerID?: HMSPeerID): HMSVideoTrack | undefined => {
88
160
  const peer = selectPeerByIDBare(store, peerID);
89
161
  if (peer && peer.videoTrack && peer.videoTrack !== '') {
90
- return store.tracks[peer.videoTrack];
162
+ return store.tracks[peer.videoTrack] as HMSVideoTrack;
91
163
  }
92
164
  return undefined;
93
165
  });
@@ -95,10 +167,10 @@ export const selectVideoTrackByPeerID = byIDCurry((store: HMSStore, peerID?: HMS
95
167
  /**
96
168
  * Select the primary audio track of a peer given a peer ID.
97
169
  */
98
- export const selectAudioTrackByPeerID = byIDCurry((store: HMSStore, peerID?: HMSPeerID): HMSTrack | undefined => {
170
+ export const selectAudioTrackByPeerID = byIDCurry((store: HMSStore, peerID?: HMSPeerID): HMSAudioTrack | undefined => {
99
171
  const peer = selectPeerByIDBare(store, peerID);
100
172
  if (peer && peer.audioTrack && peer.audioTrack !== '') {
101
- return store.tracks[peer.audioTrack];
173
+ return store.tracks[peer.audioTrack] as HMSAudioTrack;
102
174
  }
103
175
  return undefined;
104
176
  });
@@ -235,7 +307,7 @@ export const selectIsPeerVideoEnabled = byIDCurry((store: HMSStore, peerID?: str
235
307
  */
236
308
  export const selectIsAudioLocallyMuted = byIDCurry((store: HMSStore, trackID?: string) => {
237
309
  if (trackID && store.tracks[trackID]) {
238
- return store.tracks[trackID].volume === 0;
310
+ return (store.tracks[trackID] as HMSAudioTrack).volume === 0;
239
311
  }
240
312
  return undefined;
241
313
  });
@@ -10,7 +10,14 @@ import {
10
10
  HMSTrackType,
11
11
  } from '../../core';
12
12
  import { HMSSimulcastLayer } from '../../core/hmsSDKStore/sdkTypes';
13
- import { HMSPlaylist, HMSPlaylistType, HMSRole } from '../../core/schema';
13
+ import {
14
+ HMSAudioTrack,
15
+ HMSPlaylist,
16
+ HMSPlaylistType,
17
+ HMSRole,
18
+ HMSScreenVideoTrack,
19
+ HMSVideoTrack,
20
+ } from '../../core/schema';
14
21
 
15
22
  function makeTrack(
16
23
  id: HMSTrackID,
@@ -35,10 +42,10 @@ export let localPeer: HMSPeer;
35
42
  export let remotePeerOne: HMSPeer;
36
43
  export let remotePeerTwo: HMSPeer;
37
44
  export let peerScreenSharing: HMSPeer;
38
- export let localVideo: HMSTrack;
39
- export let localAudio: HMSTrack;
40
- export let remoteVideo: HMSTrack;
41
- export let screenShare: HMSTrack;
45
+ export let localVideo: HMSVideoTrack;
46
+ export let localAudio: HMSAudioTrack;
47
+ export let remoteVideo: HMSVideoTrack;
48
+ export let screenShare: HMSScreenVideoTrack;
42
49
  export let auxiliaryAudio: HMSTrack;
43
50
  export let localSpeaker: HMSSpeaker;
44
51
  export let screenshareAudio: HMSTrack;
@@ -282,10 +289,10 @@ export const makeFakeStore = (): HMSStore => {
282
289
  remotePeerOne = fakeStore.peers['2'];
283
290
  remotePeerTwo = fakeStore.peers['3'];
284
291
  peerScreenSharing = fakeStore.peers['2'];
285
- localVideo = fakeStore.tracks['101'];
286
- localAudio = fakeStore.tracks['102'];
287
- remoteVideo = fakeStore.tracks['103'];
288
- screenShare = fakeStore.tracks['105'];
292
+ localVideo = fakeStore.tracks['101'] as HMSVideoTrack;
293
+ localAudio = fakeStore.tracks['102'] as HMSAudioTrack;
294
+ remoteVideo = fakeStore.tracks['103'] as HMSVideoTrack;
295
+ screenShare = fakeStore.tracks['105'] as HMSScreenVideoTrack;
289
296
  auxiliaryAudio = fakeStore.tracks['106'];
290
297
  screenshareAudio = fakeStore.tracks['107'];
291
298
  localSpeaker = fakeStore.speakers[localPeer.audioTrack!];
@@ -1,13 +1,13 @@
1
- import { HMSPeer, HMSTrack, HMSTrackType } from '../core';
1
+ import { HMSAudioTrack, HMSPeer, HMSVideoTrack, HMSTrackType } from '../core';
2
2
 
3
3
  let counter = 100;
4
-
5
- export const makeFakeTrack = (type?: HMSTrackType): HMSTrack => {
4
+ type HMSObjectType<T> = T extends 'audio' ? HMSAudioTrack : T extends 'video' ? HMSVideoTrack : HMSVideoTrack;
5
+ export const makeFakeTrack = <T extends HMSTrackType>(type?: T): HMSObjectType<T> => {
6
6
  return {
7
7
  enabled: false,
8
8
  id: String(counter++),
9
9
  type: type || 'video',
10
- };
10
+ } as HMSObjectType<T>;
11
11
  };
12
12
 
13
13
  export const makeFakePeer = (): HMSPeer => {
@@ -1,5 +1,5 @@
1
1
  import { HMSTrack as SDKTrack } from '@100mslive/hms-video';
2
- import { HMSPeer, HMSPeerID, HMSTrack, HMSTrackID } from '../../core';
2
+ import { HMSPeer, HMSPeerID, HMSTrack, HMSTrackID, HMSVideoTrack } from '../../core';
3
3
  import { mergeNewPeersInDraft, mergeNewTracksInDraft } from '../../core/hmsSDKStore/sdkUtils/storeMergeUtils';
4
4
  import { makeFakePeer, makeFakeTrack } from '../fixtures';
5
5
 
@@ -8,14 +8,14 @@ type peerMap = Record<HMSTrackID, HMSPeer>;
8
8
  let newTracks: Record<HMSTrackID, Partial<HMSTrack>>;
9
9
 
10
10
  describe('tracks merge is happening properly', () => {
11
- let fakeTrack: HMSTrack;
11
+ let fakeTrack: HMSVideoTrack;
12
12
  let draftTracksCopy: Record<HMSTrackID, Partial<HMSTrack>>;
13
13
  let draftTracks: Record<HMSTrackID, Partial<HMSTrack>>;
14
14
  beforeEach(() => {
15
15
  draftTracks = {};
16
16
  newTracks = {};
17
17
  draftTracksCopy = draftTracks;
18
- fakeTrack = makeFakeTrack();
18
+ fakeTrack = makeFakeTrack('video');
19
19
  });
20
20
 
21
21
  const expectNoReferenceChange = () => {