@100mslive/hms-video-store 0.2.56 → 0.2.59

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.56",
2
+ "version": "0.2.59",
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.205",
59
59
  "events": "^3.3.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@100mslive/hms-video": "0.0.203",
62
+ "@100mslive/hms-video": "0.0.205",
63
63
  "@size-limit/file": "^5.0.3",
64
64
  "events": "^3.3.0",
65
65
  "husky": "^6.0.0",
@@ -7,7 +7,15 @@ 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
+ HMSChangeMultiTrackStateRequest,
18
+ } from './schema';
11
19
  import { HMSRoleChangeRequest } from './selectors';
12
20
  import { RTMPRecordingConfig } from './hmsSDKStore/sdkTypes';
13
21
 
@@ -68,7 +76,7 @@ export interface IHMSActions {
68
76
  * This method removes the track from the local peer's list of auxiliary tracks and unpublishes it.
69
77
  * @param trackId string - ID of the track to be removed
70
78
  */
71
- removeTrack(trackId: string): Promise<void>;
79
+ removeTrack(trackId: HMSTrackID): Promise<void>;
72
80
 
73
81
  /**
74
82
  * @deprecated The method should not be used
@@ -109,16 +117,17 @@ export interface IHMSActions {
109
117
  * @param readStatus boolean value which you want to set as read flag for message/messages.
110
118
  * @param messageId message id whose read falg you want to set.
111
119
  */
112
- setMessageRead(readStatus: boolean, messageId?: string): void;
120
+ setMessageRead(readStatus: boolean, messageId?: HMSMessageID): void;
113
121
 
114
122
  /**
115
- * These functions can be used to mute/unmute the local peer's audio and video
116
- * @param enabled boolean
123
+ * This function can be used to enable/disable(unmute/mute) local audio track
124
+ * @param enabled boolean - true to unmute, false to mute
117
125
  */
118
126
  setLocalAudioEnabled(enabled: boolean): Promise<void>;
119
127
 
120
128
  /**
121
- * @see setLocalAudioEnabled
129
+ * This function can be used to enable/disable(unmute/mute) local video track
130
+ * @param enabled boolean - true to unmute, false to mute
122
131
  */
123
132
  setLocalVideoEnabled(enabled: boolean): Promise<void>;
124
133
 
@@ -126,7 +135,7 @@ export interface IHMSActions {
126
135
  * @param trackId string - ID of the track whose mute status needs to be set
127
136
  * @param enabled boolean - true when we want to unmute the track and false when we want to unmute it
128
137
  */
129
- setEnabledTrack(trackId: string, enabled: boolean): Promise<void>;
138
+ setEnabledTrack(trackId: HMSTrackID, enabled: boolean): Promise<void>;
130
139
 
131
140
  /**
132
141
  * Change settings of the local peer's audio track
@@ -142,19 +151,19 @@ export interface IHMSActions {
142
151
  setVideoSettings(settings: Partial<HMSVideoTrackSettings>): Promise<void>;
143
152
 
144
153
  /**
145
- * If you're not using our Video Component you can use the below functions directly
154
+ * You can use the attach and detach video function
146
155
  * to add/remove video from an element for a track ID. The benefit of using this
147
156
  * instead of removing the video yourself is that it'll also auto unsubscribe to
148
157
  * the stream coming from server saving significant bandwidth for the user.
149
- * @param trackID trackID as stored in the store for the peer
158
+ * @param localTrackID trackID as stored in the store for the peer
150
159
  * @param videoElement HTML native element where the video has to be shown
151
160
  */
152
- attachVideo(trackID: string, videoElement: HTMLVideoElement): Promise<void>;
161
+ attachVideo(localTrackID: HMSTrackID, videoElement: HTMLVideoElement): Promise<void>;
153
162
 
154
163
  /**
155
164
  * @see attachVideo
156
165
  */
157
- detachVideo(trackID: string, videoElement: HTMLVideoElement): Promise<void>;
166
+ detachVideo(localTrackID: HMSTrackID, videoElement: HTMLVideoElement): Promise<void>;
158
167
 
159
168
  /**
160
169
  * Set the output volume of audio tracks(overall/particular audio track)
@@ -162,7 +171,7 @@ export interface IHMSActions {
162
171
  * @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
172
  *
164
173
  */
165
- setVolume(value: number, trackId?: string): void;
174
+ setVolume(value: number, trackId?: HMSTrackID): void;
166
175
 
167
176
  /**
168
177
  * Set the audio output(speaker) device
@@ -175,7 +184,7 @@ export interface IHMSActions {
175
184
  * @param trackId
176
185
  * @param layer
177
186
  */
178
- setPreferredLayer(trackId: string, layer: HMSSimulcastLayer): void;
187
+ setPreferredLayer(trackId: HMSTrackID, layer: HMSSimulcastLayer): void;
179
188
 
180
189
  /**
181
190
  * Add or remove a video plugin from/to the local peer video track. Eg. Virtual Background, Face Filters etc.
@@ -202,7 +211,7 @@ export interface IHMSActions {
202
211
  * @param toRole The name of the new role.
203
212
  * @param [force] this being true would mean that user won't get a request to accept role change
204
213
  */
205
- changeRole(forPeerId: string, toRole: string, force?: boolean): Promise<void>;
214
+ changeRole(forPeerId: HMSPeerID, toRole: HMSRoleName, force?: boolean): Promise<void>;
206
215
 
207
216
  /**
208
217
  * Accept the role change request received
@@ -222,10 +231,22 @@ export interface IHMSActions {
222
231
  * @param forRemoteTrackID The track ID or array of track IDs for which you want to change the state
223
232
  * @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
233
  */
225
- setRemoteTrackEnabled(forRemoteTrackID: string | string[], enabled: boolean): Promise<void>;
234
+ setRemoteTrackEnabled(
235
+ forRemoteTrackID: HMSTrackID | HMSTrackID[],
236
+ enabled: boolean,
237
+ ): Promise<void>;
238
+
239
+ /**
240
+ * Use this to mute/unmute multipe tracks by source, role or type
241
+ * @param {HMSChangeMultiTrackStateRequest} params
242
+ */
243
+ setRemoteTracksEnabled(params: HMSChangeMultiTrackStateRequest): Promise<void>;
226
244
 
227
245
  /**
228
246
  * Method to be called with some UI interaction after autoplay error is received
247
+ * Most browsers have limitations where an audio can not be played if there was no user interaction.
248
+ * SDK throws an autoplay error in this case, this method can be called after an UI interaction
249
+ * to resolve the autoplay error
229
250
  */
230
251
  unblockAudio: () => Promise<void>;
231
252
 
@@ -237,12 +258,12 @@ export interface IHMSActions {
237
258
 
238
259
  /**
239
260
  * 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
261
+ * @param peerID peerID of the peer to be removed from the room
241
262
  * @param reason a string explaining why the peer is removed from the room.
242
263
  * This string could be used to notify the user before they're removed from the room
243
264
  * using the `REMOVED_FROM_ROOM` type of notification
244
265
  */
245
- removePeer(peerID: string, reason: string): Promise<void>;
266
+ removePeer(peerID: HMSPeerID, reason: string): Promise<void>;
246
267
 
247
268
  /**
248
269
  * If you want to start RTMP streaming or recording.
@@ -13,6 +13,7 @@ import {
13
13
  HMSMessage,
14
14
  HMSTrack,
15
15
  HMSChangeTrackStateRequest,
16
+ HMSChangeMultiTrackStateRequest,
16
17
  HMSLeaveRoomRequest,
17
18
  HMSDeviceChangeEvent,
18
19
  } from '../schema';
@@ -126,6 +127,15 @@ export class HMSNotifications implements IHMSNotifications {
126
127
  this.emitEvent(notification);
127
128
  }
128
129
 
130
+ sendChangeMultiTrackStateRequest(request: HMSChangeMultiTrackStateRequest) {
131
+ const notification = this.createNotification(
132
+ HMSNotificationTypes.CHANGE_MULTI_TRACK_STATE_REQUEST,
133
+ request,
134
+ HMSNotificationSeverity.INFO,
135
+ );
136
+ this.emitEvent(notification);
137
+ }
138
+
129
139
  private emitEvent(notification: HMSNotification) {
130
140
  this.eventEmitter.emit(HMS_NOTIFICATION_EVENT, notification);
131
141
  }
@@ -138,6 +148,7 @@ export class HMSNotifications implements IHMSNotifications {
138
148
  | HMSMessage
139
149
  | HMSException
140
150
  | HMSChangeTrackStateRequest
151
+ | HMSChangeMultiTrackStateRequest
141
152
  | HMSLeaveRoomRequest
142
153
  | HMSDeviceChangeEvent
143
154
  | null,
@@ -11,6 +11,7 @@ import {
11
11
  HMSTrack,
12
12
  HMSTrackID,
13
13
  HMSTrackSource,
14
+ HMSChangeMultiTrackStateParams,
14
15
  IHMSPlaylistActions,
15
16
  } from '../schema';
16
17
  import { IHMSActions } from '../IHMSActions';
@@ -33,12 +34,12 @@ import {
33
34
  selectRoomState,
34
35
  selectLocalMediaSettings,
35
36
  selectTrackByID,
37
+ selectTracksMap,
36
38
  } from '../selectors';
37
39
  import { HMSLogger } from '../../common/ui-logger';
38
40
  import {
39
41
  HMSAudioPlugin,
40
42
  HMSAudioTrack as SDKHMSAudioTrack,
41
- HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest,
42
43
  HMSException as SDKHMSException,
43
44
  HMSLeaveRoomRequest as SDKHMSLeaveRoomRequest,
44
45
  HMSLocalAudioTrack as SDKHMSLocalAudioTrack,
@@ -48,6 +49,9 @@ import {
48
49
  HMSRemoteTrack as SDKHMSRemoteTrack,
49
50
  HMSRemoteVideoTrack as SDKHMSRemoteVideoTrack,
50
51
  HMSRoleChangeRequest as SDKHMSRoleChangeRequest,
52
+ HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest,
53
+ HMSChangeMultiTrackStateParams as SDKHMSChangeMultiTrackStateParams,
54
+ HMSChangeMultiTrackStateRequest as SDKHMSChangeMultiTrackStateRequest,
51
55
  HMSSdk,
52
56
  HMSSimulcastLayer,
53
57
  HMSTrack as SDKHMSTrack,
@@ -452,6 +456,19 @@ export class HMSSDKActions implements IHMSActions {
452
456
  }
453
457
  }
454
458
 
459
+ async setRemoteTracksEnabled(params: HMSChangeMultiTrackStateParams) {
460
+ const sdkRequest: SDKHMSChangeMultiTrackStateParams = {
461
+ enabled: params.enabled,
462
+ type: params.type,
463
+ source: params.source,
464
+ };
465
+ if (params.roles) {
466
+ const rolesMap = this.store.getState(selectRolesMap);
467
+ sdkRequest.roles = params.roles.map(role => rolesMap[role]);
468
+ }
469
+ await this.sdk.changeMultiTrackState(sdkRequest);
470
+ }
471
+
455
472
  setLogLevel(level: HMSLogLevel) {
456
473
  HMSLogger.level = level;
457
474
  this.sdk.setLogLevel(level);
@@ -479,6 +496,7 @@ export class HMSSDKActions implements IHMSActions {
479
496
  onRoleUpdate: this.onRoleUpdate.bind(this),
480
497
  onDeviceChange: this.onDeviceChange.bind(this),
481
498
  onChangeTrackStateRequest: this.onChangeTrackStateRequest.bind(this),
499
+ onChangeMultiTrackStateRequest: this.onChangeMultiTrackStateRequest.bind(this),
482
500
  onRemovedFromRoom: this.onRemovedFromRoom.bind(this),
483
501
  });
484
502
  this.sdk.addAudioListener({
@@ -791,6 +809,37 @@ export class HMSSDKActions implements IHMSActions {
791
809
  });
792
810
  }
793
811
 
812
+ protected onChangeMultiTrackStateRequest(request: SDKHMSChangeMultiTrackStateRequest) {
813
+ const requestedBy = this.store.getState(selectPeerByID(request.requestedBy.peerId));
814
+
815
+ if (!requestedBy) {
816
+ return this.logPossibleInconsistency(
817
+ `Not found peer who requested track state change, ${request.requestedBy}`,
818
+ );
819
+ }
820
+
821
+ if (!request.enabled) {
822
+ this.syncRoomState('changeMultiTrackStateRequest');
823
+ }
824
+
825
+ const tracks: HMSTrack[] = [];
826
+ const tracksMap = this.store.getState(selectTracksMap);
827
+ for (const track of request.tracks) {
828
+ const storeTrackID = this.getStoreLocalTrackIDfromSDKTrack(track);
829
+ if (storeTrackID && tracksMap[storeTrackID]) {
830
+ tracks.push(tracksMap[storeTrackID]);
831
+ }
832
+ }
833
+
834
+ this.hmsNotifications.sendChangeMultiTrackStateRequest({
835
+ requestedBy,
836
+ tracks,
837
+ enabled: request.enabled,
838
+ type: request.type,
839
+ source: request.source,
840
+ });
841
+ }
842
+
794
843
  protected onReconnected() {
795
844
  this.syncRoomState('reconnectedSync');
796
845
  this.hmsNotifications.sendReconnected();
@@ -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';
@@ -28,6 +28,7 @@ export enum HMSNotificationTypes {
28
28
  ROLE_CHANGE_REQUEST = 'ROLE_CHANGE_REQUEST',
29
29
  ROLE_UPDATED = 'ROLE_UPDATED',
30
30
  CHANGE_TRACK_STATE_REQUEST = 'CHANGE_TRACK_STATE_REQUEST',
31
+ CHANGE_MULTI_TRACK_STATE_REQUEST = 'CHANGE_MULTI_TRACK_STATE_REQUEST',
31
32
  ROOM_ENDED = 'ROOM_ENDED',
32
33
  REMOVED_FROM_ROOM = 'REMOVED_FROM_ROOM',
33
34
  DEVICE_CHANGE_UPDATE = 'DEVICE_CHANGE_UPDATE',
@@ -1,3 +1,4 @@
1
+ import { HMSTrackSource } from '.';
1
2
  import { HMSPeer, HMSPeerID, HMSTrack } from './peer';
2
3
  import { HMSRoleName } from './role';
3
4
 
@@ -13,6 +14,21 @@ export interface HMSChangeTrackStateRequest {
13
14
  enabled: boolean;
14
15
  }
15
16
 
17
+ export interface HMSChangeMultiTrackStateRequest {
18
+ requestedBy: HMSPeer;
19
+ tracks: HMSTrack[];
20
+ enabled: boolean;
21
+ type?: 'audio' | 'video';
22
+ source?: HMSTrackSource;
23
+ }
24
+
25
+ export interface HMSChangeMultiTrackStateParams {
26
+ enabled: boolean;
27
+ roles?: HMSRoleName[];
28
+ type?: 'audio' | 'video';
29
+ source?: HMSTrackSource;
30
+ }
31
+
16
32
  export interface HMSLeaveRoomRequest {
17
33
  requestedBy: HMSPeer;
18
34
  reason: string;
@@ -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
  }
@@ -379,6 +379,5 @@ export const selectIsAllowedToSubscribe = createSelector([selectLocalPeerRole],
379
379
  * Select the permissions which determine what actions the local peer can do.
380
380
  */
381
381
  export const selectPermissions = createSelector(selectLocalPeerRole, role => role?.permissions);
382
-
383
382
  export const selectRecordingState = createSelector(selectRoom, room => room.recording);
384
383
  export const selectRTMPState = createSelector(selectRoom, room => room.rtmp);
@@ -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
- }