@100mslive/hms-video-store 0.2.48 → 0.2.51

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,12 +1,14 @@
1
1
  import { HMSPlaylistItem, HMSPlaylistType, IHMSPlaylistActions } from '../schema';
2
2
  import { HMSPlaylistManager } from './sdkTypes';
3
+ import { IHMSStore } from '../IHMSStore';
3
4
  export declare class HMSPlaylist implements IHMSPlaylistActions {
4
5
  private playlistManager;
5
6
  private syncPlaylistState;
7
+ private store;
6
8
  private type;
7
- constructor(playlistManager: HMSPlaylistManager, type: HMSPlaylistType, syncPlaylistState: (action: string) => void);
9
+ constructor(playlistManager: HMSPlaylistManager, type: HMSPlaylistType, syncPlaylistState: (action: string) => void, store: IHMSStore);
8
10
  play(id: string): Promise<void>;
9
- pause(id: string): Promise<void>;
11
+ pause(): Promise<void>;
10
12
  playNext(): Promise<void>;
11
13
  playPrevious(): Promise<void>;
12
14
  seek(seekValue: number): void;
@@ -1,11 +1,10 @@
1
- import { HMSMessage, HMSTrackID, HMSTrackSource } from '../schema';
1
+ import { HMSMessage, HMSTrackID, HMSTrackSource, IHMSPlaylistActions } from '../schema';
2
2
  import { IHMSActions } from '../IHMSActions';
3
3
  import * as sdkTypes from './sdkTypes';
4
4
  import { HMSRoleChangeRequest } from '../selectors';
5
- import { HMSSdk, HMSVideoPlugin, HMSAudioPlugin, HMSTrack as SDKHMSTrack, HMSException as SDKHMSException, HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest, HMSSimulcastLayer, HMSLogLevel } from '@100mslive/hms-video';
5
+ import { HMSAudioPlugin, HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest, HMSException as SDKHMSException, HMSLogLevel, HMSSdk, HMSSimulcastLayer, HMSTrack as SDKHMSTrack, HMSVideoPlugin } from '@100mslive/hms-video';
6
6
  import { IHMSStore } from '../IHMSStore';
7
7
  import { HMSNotifications } from './HMSNotifications';
8
- import { IHMSPlaylistActions } from '../schema';
9
8
  /**
10
9
  * This class implements the IHMSActions interface for 100ms SDK. It connects with SDK
11
10
  * and takes control of data management by letting every action pass through it. The
@@ -110,6 +109,11 @@ export declare class HMSSDKActions implements IHMSActions {
110
109
  protected onReconnected(): void;
111
110
  protected onReconnecting(sdkError: SDKHMSException): void;
112
111
  protected onError(sdkException: SDKHMSException): void;
112
+ /**
113
+ * the layer gets updated on addsink/removesink/preferlayer calls, for simulcast there
114
+ * can be multiple layers, while for non simulcast there will be None and High.
115
+ */
116
+ private updateVideoLayer;
113
117
  private handleTrackRemove;
114
118
  private setEnabledSDKTrack;
115
119
  private setSDKLocalVideoTrackSettings;
@@ -38,4 +38,17 @@ export declare class SDKToHMS {
38
38
  };
39
39
  };
40
40
  private static getConvertedPlaylistType;
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
+ };
53
+ };
41
54
  }
@@ -1,2 +1,2 @@
1
- import { HMSException, HMSSimulcastLayer, HMSPeerUpdate, HMSRoomUpdate, HMSTrackUpdate, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSPeer, HMSRoom, HMSMessage, HMSConfig, HMSSpeaker, HMSRole, HMSLocalPeer, HMSRemotePeer, SimulcastLayerDefinition, DeviceMap, HMSLogLevel, HMSDeviceChangeEvent, HMSPlaylistItem, HMSPlaylistManager, HMSPlaylistProgressEvent, RTMPRecordingConfig } from '@100mslive/hms-video';
2
- export { HMSPeer, HMSRoom, HMSMessage, HMSSpeaker, HMSConfig, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSException, HMSSimulcastLayer, HMSRoomUpdate, HMSPeerUpdate, HMSTrackUpdate, HMSRole, HMSLocalPeer, HMSRemotePeer, HMSLogLevel, SimulcastLayerDefinition, DeviceMap, HMSDeviceChangeEvent, HMSPlaylistItem, HMSPlaylistManager, HMSPlaylistProgressEvent, RTMPRecordingConfig, };
1
+ import { HMSException, HMSSimulcastLayer, HMSPeerUpdate, HMSRoomUpdate, HMSTrackUpdate, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSPeer, HMSRoom, HMSMessage, HMSConfig, HMSSpeaker, HMSRole, HMSLocalPeer, HMSRemotePeer, SimulcastLayerDefinition, DeviceMap, HMSLogLevel, HMSDeviceChangeEvent, HMSPlaylistItem, HMSPlaylistManager, HMSPlaylistProgressEvent, RTMPRecordingConfig, HMSRecording, HMSRTMP } from '@100mslive/hms-video';
2
+ export { HMSPeer, HMSRoom, HMSMessage, HMSSpeaker, HMSConfig, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSException, HMSSimulcastLayer, HMSRoomUpdate, HMSPeerUpdate, HMSTrackUpdate, HMSRole, HMSLocalPeer, HMSRemotePeer, HMSLogLevel, SimulcastLayerDefinition, DeviceMap, HMSDeviceChangeEvent, HMSPlaylistItem, HMSPlaylistManager, HMSPlaylistProgressEvent, RTMPRecordingConfig, HMSRecording, HMSRTMP, };
@@ -36,40 +36,39 @@ export interface HMSPlaylist<T> {
36
36
  }
37
37
  export interface IHMSPlaylistActions {
38
38
  /**
39
- * Play audio/video passing url and type
39
+ * Pass the id of the item to be played
40
40
  * @param {string} id - id of playlist item
41
41
  */
42
42
  play(id: string): Promise<void>;
43
43
  /**
44
- * Pause audio/video passing url and type
45
- * @param {string} id - id of playlist item
44
+ * Pauses current playing item
46
45
  */
47
- pause(id: string): Promise<void>;
46
+ pause(): Promise<void>;
48
47
  /**
49
- * PlayNext audio/video passing type
48
+ * PlayNext
50
49
  */
51
50
  playNext(): Promise<void>;
52
51
  /**
53
- * PlayPrevious audio/video passing type
52
+ * PlayPrevious
54
53
  */
55
54
  playPrevious(): Promise<void>;
56
55
  /**
57
- * seek audio/video passing seekValue and type - this is relative to current position
56
+ * seek passing seekValue - this is relative to current position
58
57
  * @param {number} seekValue - number in seconds to move forwards(pass negative values to move backwards)
59
58
  */
60
59
  seek(seekValue: number): void;
61
60
  /**
62
- * seek audio/video passing seekValue and type - seekValue will be absolute
61
+ * seek passing seekValue - seekValue will be absolute
63
62
  * @param {number} seekValue - value in seconds of absolute position in the playlist item duration
64
63
  */
65
64
  seekTo(seekValue: number): void;
66
65
  /**
67
- * set audio/video volume passing volume and type
66
+ * set volume passing volume
68
67
  * @param {number} volume - number between 0-100
69
68
  */
70
69
  setVolume(volume: number): void;
71
70
  /**
72
- * pass list and type to set audio/video playlist
71
+ * pass list to set playlist
73
72
  * @param {HMSPlaylistItem[]} - list of playlist items
74
73
  */
75
74
  setList<T>(list: HMSPlaylistItem<T>[]): void;
@@ -16,4 +16,15 @@ export interface HMSRoom {
16
16
  shareableLink: string;
17
17
  hasWaitingRoom: boolean;
18
18
  roomState: HMSRoomState;
19
+ recording: {
20
+ browser: {
21
+ running: boolean;
22
+ };
23
+ server: {
24
+ running: boolean;
25
+ };
26
+ };
27
+ rtmp: {
28
+ running: boolean;
29
+ };
19
30
  }
@@ -179,3 +179,23 @@ 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
+ }>;
@@ -885,7 +885,18 @@ var createDefaultStoreState = function createDefaultStoreState() {
885
885
  peers: [],
886
886
  shareableLink: '',
887
887
  hasWaitingRoom: false,
888
- roomState: exports.HMSRoomState.Disconnected
888
+ roomState: exports.HMSRoomState.Disconnected,
889
+ recording: {
890
+ browser: {
891
+ running: false
892
+ },
893
+ server: {
894
+ running: false
895
+ }
896
+ },
897
+ rtmp: {
898
+ running: false
899
+ }
889
900
  },
890
901
  peers: {},
891
902
  tracks: {},
@@ -1268,6 +1279,24 @@ var SDKToHMS = /*#__PURE__*/function () {
1268
1279
  };
1269
1280
  };
1270
1281
 
1282
+ SDKToHMS.convertRecordingRTMPState = function convertRecordingRTMPState(recording, rtmp) {
1283
+ var _recording$server;
1284
+
1285
+ return {
1286
+ recording: {
1287
+ browser: {
1288
+ running: !!(recording != null && recording.browser.running)
1289
+ },
1290
+ server: {
1291
+ running: !!(recording != null && (_recording$server = recording.server) != null && _recording$server.running)
1292
+ }
1293
+ },
1294
+ rtmp: {
1295
+ running: !!(rtmp != null && rtmp.running)
1296
+ }
1297
+ };
1298
+ };
1299
+
1271
1300
  return SDKToHMS;
1272
1301
  }();
1273
1302
 
@@ -1722,6 +1751,12 @@ var selectIsAllowedToSubscribe = /*#__PURE__*/reselect.createSelector([selectLoc
1722
1751
  var selectPermissions = /*#__PURE__*/reselect.createSelector(selectLocalPeerRole, function (role) {
1723
1752
  return role == null ? void 0 : role.permissions;
1724
1753
  });
1754
+ var selectRecordingState = /*#__PURE__*/reselect.createSelector(selectRoom, function (room) {
1755
+ return room.recording;
1756
+ });
1757
+ var selectRTMPState = /*#__PURE__*/reselect.createSelector(selectRoom, function (room) {
1758
+ return room.rtmp;
1759
+ });
1725
1760
 
1726
1761
  /**
1727
1762
  * @internal
@@ -2380,9 +2415,10 @@ function isRemoteTrack(track) {
2380
2415
  }
2381
2416
 
2382
2417
  var HMSPlaylist = /*#__PURE__*/function () {
2383
- function HMSPlaylist(playlistManager, type, syncPlaylistState) {
2418
+ function HMSPlaylist(playlistManager, type, syncPlaylistState, store) {
2384
2419
  this.playlistManager = playlistManager;
2385
2420
  this.syncPlaylistState = syncPlaylistState;
2421
+ this.store = store;
2386
2422
  this.type = type;
2387
2423
  }
2388
2424
 
@@ -2399,7 +2435,7 @@ var HMSPlaylist = /*#__PURE__*/function () {
2399
2435
  break;
2400
2436
  }
2401
2437
 
2402
- HMSLogger.w('Please pass id and type to pause');
2438
+ HMSLogger.w('Please pass id to play');
2403
2439
  return _context.abrupt("return");
2404
2440
 
2405
2441
  case 3:
@@ -2425,27 +2461,31 @@ var HMSPlaylist = /*#__PURE__*/function () {
2425
2461
  }();
2426
2462
 
2427
2463
  _proto.pause = /*#__PURE__*/function () {
2428
- var _pause = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(id) {
2464
+ var _pause = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
2465
+ var selector, selection;
2429
2466
  return runtime_1.wrap(function _callee2$(_context2) {
2430
2467
  while (1) {
2431
2468
  switch (_context2.prev = _context2.next) {
2432
2469
  case 0:
2433
- if (id) {
2434
- _context2.next = 3;
2470
+ selector = this.type === exports.HMSPlaylistType.audio ? selectAudioPlaylist : selectVideoPlaylist;
2471
+ selection = this.store.getState(selector.selection);
2472
+
2473
+ if (selection.id) {
2474
+ _context2.next = 5;
2435
2475
  break;
2436
2476
  }
2437
2477
 
2438
- HMSLogger.w('Please pass id and type to pause');
2478
+ HMSLogger.w('No item is currently playing to pause');
2439
2479
  return _context2.abrupt("return");
2440
2480
 
2441
- case 3:
2442
- _context2.next = 5;
2481
+ case 5:
2482
+ _context2.next = 7;
2443
2483
  return this.playlistManager.setEnabled(false, {
2444
- id: id,
2484
+ id: selection.id,
2445
2485
  type: this.type
2446
2486
  });
2447
2487
 
2448
- case 5:
2488
+ case 7:
2449
2489
  case "end":
2450
2490
  return _context2.stop();
2451
2491
  }
@@ -2453,7 +2493,7 @@ var HMSPlaylist = /*#__PURE__*/function () {
2453
2493
  }, _callee2, this);
2454
2494
  }));
2455
2495
 
2456
- function pause(_x2) {
2496
+ function pause() {
2457
2497
  return _pause.apply(this, arguments);
2458
2498
  }
2459
2499
 
@@ -2664,7 +2704,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
2664
2704
  if (track) {
2665
2705
  if (track instanceof sdkTypes.HMSRemoteVideoTrack) {
2666
2706
  track.preferLayer(layer);
2667
- this.syncRoomState('setPreferredLayer');
2707
+ this.updateVideoLayer(trackId, 'setPreferredLayer');
2668
2708
  } else {
2669
2709
  HMSLogger.w("track " + trackId + " is not an video track");
2670
2710
  }
@@ -3307,7 +3347,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
3307
3347
  sdkTrack = this.hmsSDKTracks[trackID];
3308
3348
 
3309
3349
  if (!(sdkTrack && sdkTrack.type === 'video')) {
3310
- _context17.next = 6;
3350
+ _context17.next = 7;
3311
3351
  break;
3312
3352
  }
3313
3353
 
@@ -3315,13 +3355,14 @@ var HMSSDKActions = /*#__PURE__*/function () {
3315
3355
  return sdkTrack.removeSink(videoElement);
3316
3356
 
3317
3357
  case 4:
3318
- _context17.next = 7;
3358
+ this.updateVideoLayer(trackID, 'detachVideo');
3359
+ _context17.next = 8;
3319
3360
  break;
3320
3361
 
3321
- case 6:
3362
+ case 7:
3322
3363
  this.logPossibleInconsistency('no video track found to remove sink');
3323
3364
 
3324
- case 7:
3365
+ case 8:
3325
3366
  case "end":
3326
3367
  return _context17.stop();
3327
3368
  }
@@ -3920,14 +3961,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
3920
3961
  return sdkTrack.addSink(videoElement);
3921
3962
 
3922
3963
  case 4:
3923
- // Update layer as it is updated in addSink
3924
- if (sdkTrack instanceof sdkTypes.HMSRemoteVideoTrack && sdkTrack.getSimulcastDefinitions().length > 0) {
3925
- this.setState(function (draft) {
3926
- var layer = sdkTrack.getSimulcastLayer();
3927
- draft.tracks[trackID].layer = layer;
3928
- }, 'updateLayerOnAttach');
3929
- }
3930
-
3964
+ this.updateVideoLayer(trackID, 'attachVideo');
3931
3965
  _context32.next = 8;
3932
3966
  break;
3933
3967
 
@@ -3996,11 +4030,13 @@ var HMSSDKActions = /*#__PURE__*/function () {
3996
4030
  if (hmsPeer.isLocal) {
3997
4031
  Object.assign(newMediaSettings, this.getMediaSettings(sdkPeer));
3998
4032
  }
3999
- } // then merge them carefully with our store so if something hasn't changed
4033
+ }
4034
+
4035
+ var recording = this.sdk.getRecordingState();
4036
+ var rtmp = this.sdk.getRTMPState(); // then merge them carefully with our store so if something hasn't changed
4000
4037
  // the reference shouldn't change. Note that the draftStore is an immer draft
4001
4038
  // object.
4002
4039
 
4003
-
4004
4040
  this.setState(function (draftStore) {
4005
4041
  draftStore.room.peers = newHmsPeerIDs;
4006
4042
  var draftPeers = draftStore.peers;
@@ -4012,6 +4048,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
4012
4048
  _this8.hmsSDKTracks = newHmsSDkTracks;
4013
4049
  Object.assign(draftStore.roles, SDKToHMS.convertRoles(_this8.sdk.getRoles()));
4014
4050
  Object.assign(draftStore.playlist, SDKToHMS.convertPlaylist(_this8.sdk.getPlaylistManager()));
4051
+ Object.assign(draftStore.room, SDKToHMS.convertRecordingRTMPState(recording, rtmp));
4015
4052
  }, action);
4016
4053
  };
4017
4054
 
@@ -4026,8 +4063,8 @@ var HMSSDKActions = /*#__PURE__*/function () {
4026
4063
  _proto.onJoin = function onJoin(sdkRoom) {
4027
4064
  var _this9 = this;
4028
4065
 
4029
- this.audioPlaylist = new HMSPlaylist(this.sdk.getPlaylistManager(), exports.HMSPlaylistType.audio, this.syncPlaylistState.bind(this));
4030
- this.videoPlaylist = new HMSPlaylist(this.sdk.getPlaylistManager(), exports.HMSPlaylistType.video, this.syncRoomState.bind(this));
4066
+ this.audioPlaylist = new HMSPlaylist(this.sdk.getPlaylistManager(), exports.HMSPlaylistType.audio, this.syncPlaylistState.bind(this), this.store);
4067
+ this.videoPlaylist = new HMSPlaylist(this.sdk.getPlaylistManager(), exports.HMSPlaylistType.video, this.syncRoomState.bind(this), this.store);
4031
4068
  this.syncRoomState('joinSync');
4032
4069
  this.setState(function (store) {
4033
4070
  Object.assign(store.room, SDKToHMS.convertRoom(sdkRoom));
@@ -4207,6 +4244,21 @@ var HMSSDKActions = /*#__PURE__*/function () {
4207
4244
 
4208
4245
  this.hmsNotifications.sendError(error);
4209
4246
  HMSLogger.e('received error from sdk', error);
4247
+ }
4248
+ /**
4249
+ * the layer gets updated on addsink/removesink/preferlayer calls, for simulcast there
4250
+ * can be multiple layers, while for non simulcast there will be None and High.
4251
+ */
4252
+ ;
4253
+
4254
+ _proto.updateVideoLayer = function updateVideoLayer(trackID, action) {
4255
+ var sdkTrack = this.hmsSDKTracks[trackID];
4256
+
4257
+ if (sdkTrack && sdkTrack instanceof sdkTypes.HMSRemoteVideoTrack) {
4258
+ this.setState(function (draft) {
4259
+ draft.tracks[trackID].layer = sdkTrack.getSimulcastLayer();
4260
+ }, action);
4261
+ }
4210
4262
  };
4211
4263
 
4212
4264
  _proto.handleTrackRemove = function handleTrackRemove(sdkTrack, sdkPeer) {
@@ -5023,6 +5075,8 @@ exports.selectPeersMap = selectPeersMap;
5023
5075
  exports.selectPeersScreenSharing = selectPeersScreenSharing;
5024
5076
  exports.selectPeersWithAudioStatus = selectPeersWithAudioStatus;
5025
5077
  exports.selectPermissions = selectPermissions;
5078
+ exports.selectRTMPState = selectRTMPState;
5079
+ exports.selectRecordingState = selectRecordingState;
5026
5080
  exports.selectRemotePeers = selectRemotePeers;
5027
5081
  exports.selectRoleByRoleName = selectRoleByRoleName;
5028
5082
  exports.selectRoleChangeRequest = selectRoleChangeRequest;