@100mslive/hms-video-store 0.2.55 → 0.2.58

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.55",
2
+ "version": "0.2.58",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -55,11 +55,11 @@
55
55
  "zustand": "3.5.7"
56
56
  },
57
57
  "peerDependencies": {
58
- "@100mslive/hms-video": "0.0.203",
58
+ "@100mslive/hms-video": "0.0.204",
59
59
  "events": "^3.3.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@100mslive/hms-video": "0.0.203",
62
+ "@100mslive/hms-video": "0.0.204",
63
63
  "@size-limit/file": "^5.0.3",
64
64
  "events": "^3.3.0",
65
65
  "husky": "^6.0.0",
@@ -7,7 +7,14 @@ import {
7
7
  HMSVideoPlugin,
8
8
  HMSAudioPlugin,
9
9
  } from '@100mslive/hms-video';
10
- import { HMSPeerID, HMSRoleName, HMSTrackSource, IHMSPlaylistActions } from './schema';
10
+ import {
11
+ HMSMessageID,
12
+ HMSPeerID,
13
+ HMSRoleName,
14
+ HMSTrackID,
15
+ HMSTrackSource,
16
+ IHMSPlaylistActions,
17
+ } from './schema';
11
18
  import { HMSRoleChangeRequest } from './selectors';
12
19
  import { RTMPRecordingConfig } from './hmsSDKStore/sdkTypes';
13
20
 
@@ -68,7 +75,7 @@ export interface IHMSActions {
68
75
  * This method removes the track from the local peer's list of auxiliary tracks and unpublishes it.
69
76
  * @param trackId string - ID of the track to be removed
70
77
  */
71
- removeTrack(trackId: string): Promise<void>;
78
+ removeTrack(trackId: HMSTrackID): Promise<void>;
72
79
 
73
80
  /**
74
81
  * @deprecated The method should not be used
@@ -109,16 +116,17 @@ export interface IHMSActions {
109
116
  * @param readStatus boolean value which you want to set as read flag for message/messages.
110
117
  * @param messageId message id whose read falg you want to set.
111
118
  */
112
- setMessageRead(readStatus: boolean, messageId?: string): void;
119
+ setMessageRead(readStatus: boolean, messageId?: HMSMessageID): void;
113
120
 
114
121
  /**
115
- * These functions can be used to mute/unmute the local peer's audio and video
116
- * @param enabled boolean
122
+ * This function can be used to enable/disable(unmute/mute) local audio track
123
+ * @param enabled boolean - true to unmute, false to mute
117
124
  */
118
125
  setLocalAudioEnabled(enabled: boolean): Promise<void>;
119
126
 
120
127
  /**
121
- * @see setLocalAudioEnabled
128
+ * This function can be used to enable/disable(unmute/mute) local video track
129
+ * @param enabled boolean - true to unmute, false to mute
122
130
  */
123
131
  setLocalVideoEnabled(enabled: boolean): Promise<void>;
124
132
 
@@ -126,7 +134,7 @@ export interface IHMSActions {
126
134
  * @param trackId string - ID of the track whose mute status needs to be set
127
135
  * @param enabled boolean - true when we want to unmute the track and false when we want to unmute it
128
136
  */
129
- setEnabledTrack(trackId: string, enabled: boolean): Promise<void>;
137
+ setEnabledTrack(trackId: HMSTrackID, enabled: boolean): Promise<void>;
130
138
 
131
139
  /**
132
140
  * Change settings of the local peer's audio track
@@ -142,19 +150,19 @@ export interface IHMSActions {
142
150
  setVideoSettings(settings: Partial<HMSVideoTrackSettings>): Promise<void>;
143
151
 
144
152
  /**
145
- * If you're not using our Video Component you can use the below functions directly
153
+ * You can use the attach and detach video function
146
154
  * to add/remove video from an element for a track ID. The benefit of using this
147
155
  * instead of removing the video yourself is that it'll also auto unsubscribe to
148
156
  * the stream coming from server saving significant bandwidth for the user.
149
- * @param trackID trackID as stored in the store for the peer
157
+ * @param localTrackID trackID as stored in the store for the peer
150
158
  * @param videoElement HTML native element where the video has to be shown
151
159
  */
152
- attachVideo(trackID: string, videoElement: HTMLVideoElement): Promise<void>;
160
+ attachVideo(localTrackID: HMSTrackID, videoElement: HTMLVideoElement): Promise<void>;
153
161
 
154
162
  /**
155
163
  * @see attachVideo
156
164
  */
157
- detachVideo(trackID: string, videoElement: HTMLVideoElement): Promise<void>;
165
+ detachVideo(localTrackID: HMSTrackID, videoElement: HTMLVideoElement): Promise<void>;
158
166
 
159
167
  /**
160
168
  * Set the output volume of audio tracks(overall/particular audio track)
@@ -162,7 +170,7 @@ export interface IHMSActions {
162
170
  * @param trackId string If undefined sets the overall volume(of every audio track in the room); If valid - set the volume of particular audio track
163
171
  *
164
172
  */
165
- setVolume(value: number, trackId?: string): void;
173
+ setVolume(value: number, trackId?: HMSTrackID): void;
166
174
 
167
175
  /**
168
176
  * Set the audio output(speaker) device
@@ -175,7 +183,7 @@ export interface IHMSActions {
175
183
  * @param trackId
176
184
  * @param layer
177
185
  */
178
- setPreferredLayer(trackId: string, layer: HMSSimulcastLayer): void;
186
+ setPreferredLayer(trackId: HMSTrackID, layer: HMSSimulcastLayer): void;
179
187
 
180
188
  /**
181
189
  * Add or remove a video plugin from/to the local peer video track. Eg. Virtual Background, Face Filters etc.
@@ -202,7 +210,7 @@ export interface IHMSActions {
202
210
  * @param toRole The name of the new role.
203
211
  * @param [force] this being true would mean that user won't get a request to accept role change
204
212
  */
205
- changeRole(forPeerId: string, toRole: string, force?: boolean): Promise<void>;
213
+ changeRole(forPeerId: HMSPeerID, toRole: HMSRoleName, force?: boolean): Promise<void>;
206
214
 
207
215
  /**
208
216
  * Accept the role change request received
@@ -222,10 +230,15 @@ export interface IHMSActions {
222
230
  * @param forRemoteTrackID The track ID or array of track IDs for which you want to change the state
223
231
  * @param enabled `true` if you wish to enable(unmute permission is required) the track, `false` if you wish to disable(mute permission is required) the track
224
232
  */
225
- setRemoteTrackEnabled(forRemoteTrackID: string | string[], enabled: boolean): Promise<void>;
233
+ setRemoteTrackEnabled(
234
+ forRemoteTrackID: HMSTrackID | HMSTrackID[],
235
+ enabled: boolean,
236
+ ): Promise<void>;
226
237
 
227
238
  /**
228
- * Method to be called with some UI interaction after autoplay error is received
239
+ * Most browsers have limitations where an audio can not be played if there was no user interaction.
240
+ * SDK throws an autoplay error in this case, this method can be called after an UI interaction
241
+ * to resolve the autoplay error
229
242
  */
230
243
  unblockAudio: () => Promise<void>;
231
244
 
@@ -237,12 +250,12 @@ export interface IHMSActions {
237
250
 
238
251
  /**
239
252
  * If you have **removeOthers** permission, you can remove a peer from the room.
240
- * @param peerID peerID of the peer to be removed from the remove
253
+ * @param peerID peerID of the peer to be removed from the room
241
254
  * @param reason a string explaining why the peer is removed from the room.
242
255
  * This string could be used to notify the user before they're removed from the room
243
256
  * using the `REMOVED_FROM_ROOM` type of notification
244
257
  */
245
- removePeer(peerID: string, reason: string): Promise<void>;
258
+ removePeer(peerID: HMSPeerID, reason: string): Promise<void>;
246
259
 
247
260
  /**
248
261
  * If you want to start RTMP streaming or recording.
@@ -713,7 +713,7 @@ export class HMSSDKActions implements IHMSActions {
713
713
  } else {
714
714
  const actionName =
715
715
  type === sdkTypes.HMSTrackUpdate.TRACK_ADDED ? 'trackAdded' : 'trackUpdate';
716
- this.syncTrackState(actionName, track, peer);
716
+ this.syncRemoteTrackState(actionName, track, peer);
717
717
  this.hmsNotifications.sendTrackUpdate(type, track.trackId);
718
718
  }
719
719
  }
@@ -1056,7 +1056,13 @@ export class HMSSDKActions implements IHMSActions {
1056
1056
  }, action);
1057
1057
  };
1058
1058
 
1059
- private syncTrackState = (
1059
+ /**
1060
+ * Handle store update on remote track changes
1061
+ * @param {string} action - 'trackAdded' | 'trackUpdate'
1062
+ * @param {SDKHMSTrack} track - track added/updated
1063
+ * @param {sdkTypes.HMSPeer}peer - peer on which track is added/updated
1064
+ */
1065
+ private syncRemoteTrackState = (
1060
1066
  action: 'trackAdded' | 'trackUpdate',
1061
1067
  track: SDKHMSTrack,
1062
1068
  peer: sdkTypes.HMSPeer,
@@ -1067,17 +1073,19 @@ export class HMSSDKActions implements IHMSActions {
1067
1073
  const hmsTrack = SDKToHMS.convertTrack(track);
1068
1074
  if (action === 'trackAdded') {
1069
1075
  draftStore.tracks[track.trackId] = hmsTrack;
1070
- if (hmsTrack.source === 'regular') {
1071
- if (hmsTrack.type === 'audio') {
1072
- draftPeer.audioTrack = hmsTrack.id;
1073
- } else {
1074
- draftPeer.videoTrack = hmsTrack.id;
1075
- }
1076
+ if (peer.audioTrack?.trackId === track.trackId) {
1077
+ draftPeer.audioTrack = hmsTrack.id;
1078
+ } else if (peer.videoTrack?.trackId === track.trackId) {
1079
+ draftPeer.videoTrack = hmsTrack.id;
1076
1080
  } else if (!draftPeer.auxiliaryTracks.includes(hmsTrack.id)) {
1077
1081
  draftPeer.auxiliaryTracks.push(hmsTrack.id);
1078
1082
  }
1079
1083
  } else {
1080
- Object.assign(draftStore.tracks[hmsTrack.id], hmsTrack);
1084
+ if (draftStore.tracks[hmsTrack.id]) {
1085
+ Object.assign(draftStore.tracks[hmsTrack.id], hmsTrack);
1086
+ } else {
1087
+ this.logPossibleInconsistency(`track ${hmsTrack.id} not present, unable to update track`);
1088
+ }
1081
1089
  }
1082
1090
  this.hmsSDKTracks[hmsTrack.id] = track;
1083
1091
  }, action);
@@ -200,11 +200,11 @@ export class SDKToHMS {
200
200
  static convertRecordingRTMPState(
201
201
  recording: sdkTypes.HMSRecording | undefined,
202
202
  rtmp: sdkTypes.HMSRTMP | undefined,
203
- ) {
203
+ ): { recording: sdkTypes.HMSRecording; rtmp: sdkTypes.HMSRTMP } {
204
204
  return {
205
205
  recording: {
206
206
  browser: {
207
- running: !!recording?.browser.running,
207
+ running: !!recording?.browser?.running,
208
208
  },
209
209
  server: { running: !!recording?.server?.running },
210
210
  },
package/src/core/index.ts CHANGED
@@ -13,4 +13,6 @@ export {
13
13
  DeviceMap,
14
14
  HMSLogLevel,
15
15
  RTMPRecordingConfig,
16
+ HMSRecording,
17
+ HMSRTMP,
16
18
  } from './hmsSDKStore/sdkTypes';
@@ -3,7 +3,6 @@ export * from './room';
3
3
  export * from './peer';
4
4
  export * from './message';
5
5
  export * from './settings';
6
- export * from './ui';
7
6
  export * from './notification';
8
7
  export * from './role';
9
8
  export * from './error';
@@ -1,4 +1,5 @@
1
1
  import { HMSPeerID } from './peer';
2
+ import { HMSRecording, HMSRTMP } from '@100mslive/hms-video';
2
3
 
3
4
  export type HMSRoomID = string;
4
5
 
@@ -20,15 +21,6 @@ export interface HMSRoom {
20
21
  shareableLink: string;
21
22
  hasWaitingRoom: boolean;
22
23
  roomState: HMSRoomState;
23
- recording: {
24
- browser: {
25
- running: boolean;
26
- };
27
- server: {
28
- running: boolean;
29
- };
30
- };
31
- rtmp: {
32
- running: boolean;
33
- };
24
+ recording: HMSRecording;
25
+ rtmp: HMSRTMP;
34
26
  }
@@ -1,11 +0,0 @@
1
- export interface HMSComponentsStyle {
2
- videoTile: {
3
- showAudioLevel?: boolean;
4
- };
5
- chatBox: {
6
- autoScroll: false;
7
- };
8
- videoList: {
9
- maxTiles?: number;
10
- };
11
- }
@@ -1,11 +0,0 @@
1
- export interface HMSComponentsStyle {
2
- videoTile: {
3
- showAudioLevel?: boolean;
4
- };
5
- chatBox: {
6
- autoScroll: false;
7
- };
8
- videoList: {
9
- maxTiles?: number;
10
- };
11
- }