@100mslive/hms-video-store 0.2.50 → 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,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;
@@ -2704,7 +2704,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
2704
2704
  if (track) {
2705
2705
  if (track instanceof sdkTypes.HMSRemoteVideoTrack) {
2706
2706
  track.preferLayer(layer);
2707
- this.syncRoomState('setPreferredLayer');
2707
+ this.updateVideoLayer(trackId, 'setPreferredLayer');
2708
2708
  } else {
2709
2709
  HMSLogger.w("track " + trackId + " is not an video track");
2710
2710
  }
@@ -3347,7 +3347,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
3347
3347
  sdkTrack = this.hmsSDKTracks[trackID];
3348
3348
 
3349
3349
  if (!(sdkTrack && sdkTrack.type === 'video')) {
3350
- _context17.next = 6;
3350
+ _context17.next = 7;
3351
3351
  break;
3352
3352
  }
3353
3353
 
@@ -3355,13 +3355,14 @@ var HMSSDKActions = /*#__PURE__*/function () {
3355
3355
  return sdkTrack.removeSink(videoElement);
3356
3356
 
3357
3357
  case 4:
3358
- _context17.next = 7;
3358
+ this.updateVideoLayer(trackID, 'detachVideo');
3359
+ _context17.next = 8;
3359
3360
  break;
3360
3361
 
3361
- case 6:
3362
+ case 7:
3362
3363
  this.logPossibleInconsistency('no video track found to remove sink');
3363
3364
 
3364
- case 7:
3365
+ case 8:
3365
3366
  case "end":
3366
3367
  return _context17.stop();
3367
3368
  }
@@ -3960,14 +3961,7 @@ var HMSSDKActions = /*#__PURE__*/function () {
3960
3961
  return sdkTrack.addSink(videoElement);
3961
3962
 
3962
3963
  case 4:
3963
- // Update layer as it is updated in addSink
3964
- if (sdkTrack instanceof sdkTypes.HMSRemoteVideoTrack && sdkTrack.getSimulcastDefinitions().length > 0) {
3965
- this.setState(function (draft) {
3966
- var layer = sdkTrack.getSimulcastLayer();
3967
- draft.tracks[trackID].layer = layer;
3968
- }, 'updateLayerOnAttach');
3969
- }
3970
-
3964
+ this.updateVideoLayer(trackID, 'attachVideo');
3971
3965
  _context32.next = 8;
3972
3966
  break;
3973
3967
 
@@ -4250,6 +4244,21 @@ var HMSSDKActions = /*#__PURE__*/function () {
4250
4244
 
4251
4245
  this.hmsNotifications.sendError(error);
4252
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
+ }
4253
4262
  };
4254
4263
 
4255
4264
  _proto.handleTrackRemove = function handleTrackRemove(sdkTrack, sdkPeer) {