@100mslive/hms-video-store 0.2.64 → 0.2.65

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,12 @@
1
- import { HMSTrack as SDKHMSTrack, HMSRoleChangeRequest as SDKHMSRoleChangeRequest } from '@100mslive/hms-video';
2
- import { HMSPeer, HMSMessage, HMSTrack, HMSRoom, HMSRoleChangeStoreRequest, HMSException, HMSDeviceChangeEvent, HMSPlaylistItem, HMSPeerID } from '../schema';
1
+ import { HMSRoleChangeRequest as SDKHMSRoleChangeRequest, HMSTrack as SDKHMSTrack } from '@100mslive/hms-video';
2
+ import { HMSDeviceChangeEvent, HMSException, HMSMessage, HMSPeer, HMSPeerID, HMSPlaylistItem, HMSRole, HMSRoleChangeStoreRequest, HMSRoleName, HMSRoom, HMSTrack } from '../schema';
3
3
  import * as sdkTypes from './sdkTypes';
4
- import { HMSRole, HMSRoleName } from '../schema';
5
4
  export declare class SDKToHMS {
6
5
  static convertPeer(sdkPeer: sdkTypes.HMSPeer): Partial<HMSPeer> & Pick<HMSPeer, 'id'>;
7
6
  static convertTrack(sdkTrack: SDKHMSTrack, peerId?: HMSPeerID): HMSTrack;
8
7
  static enrichTrack(track: HMSTrack, sdkTrack: SDKHMSTrack): void;
9
8
  static enrichVideoTrack(track: HMSTrack, sdkTrack: SDKHMSTrack): void;
9
+ static enrichPluginsDetails(track: HMSTrack, sdkTrack: SDKHMSTrack): void;
10
10
  static convertRoom(sdkRoom: sdkTypes.HMSRoom): Partial<HMSRoom>;
11
11
  static convertMessage(sdkMessage: sdkTypes.HMSMessage): Partial<HMSMessage> & Pick<HMSMessage, 'sender'>;
12
12
  static convertRoles(sdkRoles: HMSRole[]): Record<HMSRoleName, HMSRole>;
@@ -1026,6 +1026,7 @@ var mergeNewTracksInDraft = function mergeNewTracksInDraft(draftTracks, newTrack
1026
1026
  var newTrack = newTracks[trackID];
1027
1027
 
1028
1028
  if (isEntityUpdated(oldTrack, newTrack)) {
1029
+ mergeTrackArrayFields(oldTrack, newTrack);
1029
1030
  Object.assign(oldTrack, newTrack);
1030
1031
  } else if (isEntityRemoved(oldTrack, newTrack)) {
1031
1032
  delete draftTracks[trackID];
@@ -1034,6 +1035,19 @@ var mergeNewTracksInDraft = function mergeNewTracksInDraft(draftTracks, newTrack
1034
1035
  }
1035
1036
  }
1036
1037
  };
1038
+ /**
1039
+ * array's are usually created with new reference, avoid that update if both arrays are same
1040
+ */
1041
+
1042
+ var mergeTrackArrayFields = function mergeTrackArrayFields(oldTrack, newTrack) {
1043
+ if (oldTrack.plugins && areArraysEqual(oldTrack.plugins, newTrack.plugins)) {
1044
+ newTrack.plugins = oldTrack.plugins;
1045
+ }
1046
+
1047
+ if (oldTrack.layerDefinitions && areArraysEqual(oldTrack.layerDefinitions, newTrack.layerDefinitions)) {
1048
+ newTrack.layerDefinitions = oldTrack.layerDefinitions;
1049
+ }
1050
+ };
1037
1051
 
1038
1052
  var isEntityUpdated = function isEntityUpdated(oldItem, newItem) {
1039
1053
  return oldItem && newItem;
@@ -1049,7 +1063,7 @@ var isEntityAdded = function isEntityAdded(oldItem, newItem) {
1049
1063
 
1050
1064
 
1051
1065
  var areArraysEqual = function areArraysEqual(arr1, arr2) {
1052
- if (arr1 === arr2) {
1066
+ if (arr1 === arr2 || arr1.length === 0 && (arr2 == null ? void 0 : arr2.length) === 0) {
1053
1067
  // reference check
1054
1068
  return true;
1055
1069
  }
@@ -1147,11 +1161,11 @@ var SDKToHMS = /*#__PURE__*/function () {
1147
1161
  track.deviceID = mediaSettings.deviceId;
1148
1162
 
1149
1163
  if (sdkTrack instanceof sdkTypes.HMSRemoteAudioTrack) {
1150
- var volume = sdkTrack.getVolume() || 0;
1151
- track.volume = volume;
1164
+ track.volume = sdkTrack.getVolume() || 0;
1152
1165
  }
1153
1166
 
1154
1167
  SDKToHMS.enrichVideoTrack(track, sdkTrack);
1168
+ SDKToHMS.enrichPluginsDetails(track, sdkTrack);
1155
1169
  };
1156
1170
 
1157
1171
  SDKToHMS.enrichVideoTrack = function enrichVideoTrack(track, sdkTrack) {
@@ -1163,7 +1177,9 @@ var SDKToHMS = /*#__PURE__*/function () {
1163
1177
  track.layerDefinitions = sdkTrack.getSimulcastDefinitions();
1164
1178
  }
1165
1179
  }
1180
+ };
1166
1181
 
1182
+ SDKToHMS.enrichPluginsDetails = function enrichPluginsDetails(track, sdkTrack) {
1167
1183
  if (sdkTrack instanceof sdkTypes.HMSLocalVideoTrack || sdkTrack instanceof sdkTypes.HMSLocalAudioTrack) {
1168
1184
  if (!areArraysEqual(sdkTrack.getPlugins(), track.plugins)) {
1169
1185
  track.plugins = sdkTrack.getPlugins();
@@ -2670,8 +2686,6 @@ var HMSSDKActions = /*#__PURE__*/function () {
2670
2686
 
2671
2687
 
2672
2688
  this.syncRemoteTrackState = function (action, track, peer) {
2673
- console.time('trackUpdate');
2674
-
2675
2689
  _this.setState(function (draftStore) {
2676
2690
  var draftPeer = draftStore.peers[peer.peerId];
2677
2691
  /**
@@ -4215,8 +4229,8 @@ var HMSSDKActions = /*#__PURE__*/function () {
4215
4229
  };
4216
4230
 
4217
4231
  _proto.onTrackUpdate = function onTrackUpdate(type, track, peer) {
4218
- // this check is needed because for track removed case, the store does not have
4219
- // the track info to be sent as notification
4232
+ // this check is needed because for track removed case, the notification needs to
4233
+ // be send before the track is removed from store
4220
4234
  if (type === sdkTypes.HMSTrackUpdate.TRACK_REMOVED) {
4221
4235
  this.hmsNotifications.sendTrackUpdate(type, track.trackId);
4222
4236
  this.handleTrackRemove(track, peer);