@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.
@@ -1,5 +1,5 @@
1
1
  import { HMSConfig, HMSSimulcastLayer, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSLogLevel, HMSVideoPlugin, HMSAudioPlugin } from '@100mslive/hms-video';
2
- import { HMSPeerID, HMSRoleName, HMSTrackSource, IHMSPlaylistActions } from './schema';
2
+ import { HMSMessageID, HMSPeerID, HMSRoleName, HMSTrackID, HMSTrackSource, IHMSPlaylistActions } from './schema';
3
3
  import { HMSRoleChangeRequest } from './selectors';
4
4
  import { RTMPRecordingConfig } from './hmsSDKStore/sdkTypes';
5
5
  /**
@@ -55,7 +55,7 @@ export interface IHMSActions {
55
55
  * This method removes the track from the local peer's list of auxiliary tracks and unpublishes it.
56
56
  * @param trackId string - ID of the track to be removed
57
57
  */
58
- removeTrack(trackId: string): Promise<void>;
58
+ removeTrack(trackId: HMSTrackID): Promise<void>;
59
59
  /**
60
60
  * @deprecated The method should not be used
61
61
  * @see sendBroadcastMessage
@@ -93,21 +93,22 @@ export interface IHMSActions {
93
93
  * @param readStatus boolean value which you want to set as read flag for message/messages.
94
94
  * @param messageId message id whose read falg you want to set.
95
95
  */
96
- setMessageRead(readStatus: boolean, messageId?: string): void;
96
+ setMessageRead(readStatus: boolean, messageId?: HMSMessageID): void;
97
97
  /**
98
- * These functions can be used to mute/unmute the local peer's audio and video
99
- * @param enabled boolean
98
+ * This function can be used to enable/disable(unmute/mute) local audio track
99
+ * @param enabled boolean - true to unmute, false to mute
100
100
  */
101
101
  setLocalAudioEnabled(enabled: boolean): Promise<void>;
102
102
  /**
103
- * @see setLocalAudioEnabled
103
+ * This function can be used to enable/disable(unmute/mute) local video track
104
+ * @param enabled boolean - true to unmute, false to mute
104
105
  */
105
106
  setLocalVideoEnabled(enabled: boolean): Promise<void>;
106
107
  /**
107
108
  * @param trackId string - ID of the track whose mute status needs to be set
108
109
  * @param enabled boolean - true when we want to unmute the track and false when we want to unmute it
109
110
  */
110
- setEnabledTrack(trackId: string, enabled: boolean): Promise<void>;
111
+ setEnabledTrack(trackId: HMSTrackID, enabled: boolean): Promise<void>;
111
112
  /**
112
113
  * Change settings of the local peer's audio track
113
114
  * @param settings HMSAudioTrackSettings
@@ -121,25 +122,25 @@ export interface IHMSActions {
121
122
  */
122
123
  setVideoSettings(settings: Partial<HMSVideoTrackSettings>): Promise<void>;
123
124
  /**
124
- * If you're not using our Video Component you can use the below functions directly
125
+ * You can use the attach and detach video function
125
126
  * to add/remove video from an element for a track ID. The benefit of using this
126
127
  * instead of removing the video yourself is that it'll also auto unsubscribe to
127
128
  * the stream coming from server saving significant bandwidth for the user.
128
- * @param trackID trackID as stored in the store for the peer
129
+ * @param localTrackID trackID as stored in the store for the peer
129
130
  * @param videoElement HTML native element where the video has to be shown
130
131
  */
131
- attachVideo(trackID: string, videoElement: HTMLVideoElement): Promise<void>;
132
+ attachVideo(localTrackID: HMSTrackID, videoElement: HTMLVideoElement): Promise<void>;
132
133
  /**
133
134
  * @see attachVideo
134
135
  */
135
- detachVideo(trackID: string, videoElement: HTMLVideoElement): Promise<void>;
136
+ detachVideo(localTrackID: HMSTrackID, videoElement: HTMLVideoElement): Promise<void>;
136
137
  /**
137
138
  * Set the output volume of audio tracks(overall/particular audio track)
138
139
  * @param value number between 0-100
139
140
  * @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
140
141
  *
141
142
  */
142
- setVolume(value: number, trackId?: string): void;
143
+ setVolume(value: number, trackId?: HMSTrackID): void;
143
144
  /**
144
145
  * Set the audio output(speaker) device
145
146
  * @param deviceId string deviceId of the audio output device
@@ -150,7 +151,7 @@ export interface IHMSActions {
150
151
  * @param trackId
151
152
  * @param layer
152
153
  */
153
- setPreferredLayer(trackId: string, layer: HMSSimulcastLayer): void;
154
+ setPreferredLayer(trackId: HMSTrackID, layer: HMSSimulcastLayer): void;
154
155
  /**
155
156
  * Add or remove a video plugin from/to the local peer video track. Eg. Virtual Background, Face Filters etc.
156
157
  * Video plugins can be added/removed at any time after the join is successful.
@@ -172,7 +173,7 @@ export interface IHMSActions {
172
173
  * @param toRole The name of the new role.
173
174
  * @param [force] this being true would mean that user won't get a request to accept role change
174
175
  */
175
- changeRole(forPeerId: string, toRole: string, force?: boolean): Promise<void>;
176
+ changeRole(forPeerId: HMSPeerID, toRole: HMSRoleName, force?: boolean): Promise<void>;
176
177
  /**
177
178
  * Accept the role change request received
178
179
  * @param {HMSRoleChangeRequest} request The original request that was received
@@ -189,9 +190,11 @@ export interface IHMSActions {
189
190
  * @param forRemoteTrackID The track ID or array of track IDs for which you want to change the state
190
191
  * @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
191
192
  */
192
- setRemoteTrackEnabled(forRemoteTrackID: string | string[], enabled: boolean): Promise<void>;
193
+ setRemoteTrackEnabled(forRemoteTrackID: HMSTrackID | HMSTrackID[], enabled: boolean): Promise<void>;
193
194
  /**
194
- * Method to be called with some UI interaction after autoplay error is received
195
+ * Most browsers have limitations where an audio can not be played if there was no user interaction.
196
+ * SDK throws an autoplay error in this case, this method can be called after an UI interaction
197
+ * to resolve the autoplay error
195
198
  */
196
199
  unblockAudio: () => Promise<void>;
197
200
  /**
@@ -201,12 +204,12 @@ export interface IHMSActions {
201
204
  endRoom: (lock: boolean, reason: string) => Promise<void>;
202
205
  /**
203
206
  * If you have **removeOthers** permission, you can remove a peer from the room.
204
- * @param peerID peerID of the peer to be removed from the remove
207
+ * @param peerID peerID of the peer to be removed from the room
205
208
  * @param reason a string explaining why the peer is removed from the room.
206
209
  * This string could be used to notify the user before they're removed from the room
207
210
  * using the `REMOVED_FROM_ROOM` type of notification
208
211
  */
209
- removePeer(peerID: string, reason: string): Promise<void>;
212
+ removePeer(peerID: HMSPeerID, reason: string): Promise<void>;
210
213
  /**
211
214
  * If you want to start RTMP streaming or recording.
212
215
  * @param params.meetingURL This is the meeting url which is opened in a headless chrome instance for streaming and recording.
@@ -143,7 +143,13 @@ export declare class HMSSDKActions implements IHMSActions {
143
143
  private getStoreLocalTrackIDfromSDKTrack;
144
144
  private setProgress;
145
145
  private syncPlaylistState;
146
- private syncTrackState;
146
+ /**
147
+ * Handle store update on remote track changes
148
+ * @param {string} action - 'trackAdded' | 'trackUpdate'
149
+ * @param {SDKHMSTrack} track - track added/updated
150
+ * @param {sdkTypes.HMSPeer}peer - peer on which track is added/updated
151
+ */
152
+ private syncRemoteTrackState;
147
153
  private peerUpdateInternal;
148
154
  /**
149
155
  * setState is separate so any future changes to how state change can be done from one place.
@@ -39,16 +39,7 @@ export declare class SDKToHMS {
39
39
  };
40
40
  private static getConvertedPlaylistType;
41
41
  static convertRecordingRTMPState(recording: sdkTypes.HMSRecording | undefined, rtmp: sdkTypes.HMSRTMP | undefined): {
42
- recording: {
43
- browser: {
44
- running: boolean;
45
- };
46
- server: {
47
- running: boolean;
48
- };
49
- };
50
- rtmp: {
51
- running: boolean;
52
- };
42
+ recording: sdkTypes.HMSRecording;
43
+ rtmp: sdkTypes.HMSRTMP;
53
44
  };
54
45
  }
@@ -4,4 +4,4 @@ export { IHMSNotifications as HMSNotifications } from './IHMSNotifications';
4
4
  export { HMSReactiveStore } from './hmsSDKStore/HMSReactiveStore';
5
5
  export * from './schema';
6
6
  export * from './selectors';
7
- export { HMSConfig, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSSimulcastLayer, SimulcastLayerDefinition, DeviceMap, HMSLogLevel, RTMPRecordingConfig, } from './hmsSDKStore/sdkTypes';
7
+ export { HMSConfig, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSSimulcastLayer, SimulcastLayerDefinition, DeviceMap, HMSLogLevel, RTMPRecordingConfig, HMSRecording, HMSRTMP, } 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
  export declare type HMSRoomID = string;
3
4
  export declare enum HMSRoomState {
4
5
  Disconnected = "Disconnected",
@@ -17,15 +18,6 @@ export interface HMSRoom {
17
18
  shareableLink: string;
18
19
  hasWaitingRoom: boolean;
19
20
  roomState: HMSRoomState;
20
- recording: {
21
- browser: {
22
- running: boolean;
23
- };
24
- server: {
25
- running: boolean;
26
- };
27
- };
28
- rtmp: {
29
- running: boolean;
30
- };
21
+ recording: HMSRecording;
22
+ rtmp: HMSRTMP;
31
23
  }
@@ -179,23 +179,5 @@ export declare const selectPermissions: import("reselect").OutputSelector<HMSSto
179
179
  mute: boolean;
180
180
  changeRole: boolean;
181
181
  } | undefined>;
182
- export declare const selectRecordingState: import("reselect").OutputSelector<HMSStore, {
183
- browser: {
184
- running: boolean;
185
- };
186
- server: {
187
- running: boolean;
188
- };
189
- }, (res: HMSRoom) => {
190
- browser: {
191
- running: boolean;
192
- };
193
- server: {
194
- running: boolean;
195
- };
196
- }>;
197
- export declare const selectRTMPState: import("reselect").OutputSelector<HMSStore, {
198
- running: boolean;
199
- }, (res: HMSRoom) => {
200
- running: boolean;
201
- }>;
182
+ export declare const selectRecordingState: import("reselect").OutputSelector<HMSStore, import("@100mslive/hms-video/dist/interfaces/room").HMSRecording, (res: HMSRoom) => import("@100mslive/hms-video/dist/interfaces/room").HMSRecording>;
183
+ export declare const selectRTMPState: import("reselect").OutputSelector<HMSStore, import("@100mslive/hms-video/dist/interfaces/room").HMSRTMP, (res: HMSRoom) => import("@100mslive/hms-video/dist/interfaces/room").HMSRTMP>;
@@ -1295,12 +1295,12 @@ var SDKToHMS = /*#__PURE__*/function () {
1295
1295
  };
1296
1296
 
1297
1297
  SDKToHMS.convertRecordingRTMPState = function convertRecordingRTMPState(recording, rtmp) {
1298
- var _recording$server;
1298
+ var _recording$browser, _recording$server;
1299
1299
 
1300
1300
  return {
1301
1301
  recording: {
1302
1302
  browser: {
1303
- running: !!(recording != null && recording.browser.running)
1303
+ running: !!(recording != null && (_recording$browser = recording.browser) != null && _recording$browser.running)
1304
1304
  },
1305
1305
  server: {
1306
1306
  running: !!(recording != null && (_recording$server = recording.server) != null && _recording$server.running)
@@ -2655,8 +2655,15 @@ var HMSSDKActions = /*#__PURE__*/function () {
2655
2655
  Object.assign(draftStore.playlist, SDKToHMS.convertPlaylist(_this.sdk.getPlaylistManager()));
2656
2656
  }, action);
2657
2657
  };
2658
+ /**
2659
+ * Handle store update on remote track changes
2660
+ * @param {string} action - 'trackAdded' | 'trackUpdate'
2661
+ * @param {SDKHMSTrack} track - track added/updated
2662
+ * @param {sdkTypes.HMSPeer}peer - peer on which track is added/updated
2663
+ */
2658
2664
 
2659
- this.syncTrackState = function (action, track, peer) {
2665
+
2666
+ this.syncRemoteTrackState = function (action, track, peer) {
2660
2667
  console.time('trackUpdate');
2661
2668
 
2662
2669
  _this.setState(function (draftStore) {
@@ -2664,19 +2671,23 @@ var HMSSDKActions = /*#__PURE__*/function () {
2664
2671
  var hmsTrack = SDKToHMS.convertTrack(track);
2665
2672
 
2666
2673
  if (action === 'trackAdded') {
2674
+ var _peer$audioTrack, _peer$videoTrack;
2675
+
2667
2676
  draftStore.tracks[track.trackId] = hmsTrack;
2668
2677
 
2669
- if (hmsTrack.source === 'regular') {
2670
- if (hmsTrack.type === 'audio') {
2671
- draftPeer.audioTrack = hmsTrack.id;
2672
- } else {
2673
- draftPeer.videoTrack = hmsTrack.id;
2674
- }
2678
+ if (((_peer$audioTrack = peer.audioTrack) == null ? void 0 : _peer$audioTrack.trackId) === track.trackId) {
2679
+ draftPeer.audioTrack = hmsTrack.id;
2680
+ } else if (((_peer$videoTrack = peer.videoTrack) == null ? void 0 : _peer$videoTrack.trackId) === track.trackId) {
2681
+ draftPeer.videoTrack = hmsTrack.id;
2675
2682
  } else if (!draftPeer.auxiliaryTracks.includes(hmsTrack.id)) {
2676
2683
  draftPeer.auxiliaryTracks.push(hmsTrack.id);
2677
2684
  }
2678
2685
  } else {
2679
- Object.assign(draftStore.tracks[hmsTrack.id], hmsTrack);
2686
+ if (draftStore.tracks[hmsTrack.id]) {
2687
+ Object.assign(draftStore.tracks[hmsTrack.id], hmsTrack);
2688
+ } else {
2689
+ _this.logPossibleInconsistency("track " + hmsTrack.id + " not present, unable to update track");
2690
+ }
2680
2691
  }
2681
2692
 
2682
2693
  _this.hmsSDKTracks[hmsTrack.id] = track;
@@ -4161,7 +4172,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
4161
4172
  this.handleTrackRemove(track, peer);
4162
4173
  } else {
4163
4174
  var actionName = type === sdkTypes.HMSTrackUpdate.TRACK_ADDED ? 'trackAdded' : 'trackUpdate';
4164
- this.syncTrackState(actionName, track, peer);
4175
+ this.syncRemoteTrackState(actionName, track, peer);
4165
4176
  this.hmsNotifications.sendTrackUpdate(type, track.trackId);
4166
4177
  }
4167
4178
  };