@100mslive/react-native-hms 1.4.0 → 1.6.0

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.
Files changed (205) hide show
  1. package/android/build.gradle +3 -2
  2. package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +189 -55
  3. package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +1 -0
  4. package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +94 -38
  5. package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +446 -107
  6. package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +5 -0
  7. package/android/src/main/java/com/reactnativehmssdk/HMSView.kt +42 -25
  8. package/android/src/main/res/layout/hms_view.xml +2 -2
  9. package/ios/HMSConstants.swift +33 -0
  10. package/ios/HMSDecoder.swift +372 -157
  11. package/ios/HMSHelper.swift +44 -7
  12. package/ios/HMSManager.m +17 -2
  13. package/ios/HMSManager.swift +177 -75
  14. package/ios/HMSRNSDK.swift +641 -199
  15. package/ios/HMSView.m +1 -0
  16. package/ios/HMSView.swift +21 -19
  17. package/lib/commonjs/classes/HMSAudioTrackSettings.js +14 -0
  18. package/lib/commonjs/classes/HMSAudioTrackSettings.js.map +1 -1
  19. package/lib/commonjs/classes/HMSCameraControl.js +28 -0
  20. package/lib/commonjs/classes/HMSCameraControl.js.map +1 -0
  21. package/lib/commonjs/classes/HMSEncoder.js +97 -14
  22. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  23. package/lib/commonjs/classes/HMSIOSAudioMode.js +13 -0
  24. package/lib/commonjs/classes/HMSIOSAudioMode.js.map +1 -0
  25. package/lib/commonjs/classes/HMSLayer.js +14 -0
  26. package/lib/commonjs/classes/HMSLayer.js.map +1 -0
  27. package/lib/commonjs/classes/HMSLocalVideoStats.js +11 -0
  28. package/lib/commonjs/classes/HMSLocalVideoStats.js.map +1 -1
  29. package/lib/commonjs/classes/HMSPeer.js +1 -1
  30. package/lib/commonjs/classes/HMSPeer.js.map +1 -1
  31. package/lib/commonjs/classes/HMSPublishSettings.js +2 -0
  32. package/lib/commonjs/classes/HMSPublishSettings.js.map +1 -1
  33. package/lib/commonjs/classes/HMSQualityLimitationReason.js +16 -0
  34. package/lib/commonjs/classes/HMSQualityLimitationReason.js.map +1 -0
  35. package/lib/commonjs/classes/HMSQualityLimitationReasons.js +27 -0
  36. package/lib/commonjs/classes/HMSQualityLimitationReasons.js.map +1 -0
  37. package/lib/commonjs/classes/HMSRemotePeer.js.map +1 -1
  38. package/lib/commonjs/classes/HMSRemoteVideoTrack.js +39 -3
  39. package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
  40. package/lib/commonjs/classes/HMSRoom.js +4 -0
  41. package/lib/commonjs/classes/HMSRoom.js.map +1 -1
  42. package/lib/commonjs/classes/HMSRoomUpdate.js +1 -0
  43. package/lib/commonjs/classes/HMSRoomUpdate.js.map +1 -1
  44. package/lib/commonjs/classes/HMSSDK.js +82 -45
  45. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  46. package/lib/commonjs/classes/HMSSessionStore.js +173 -0
  47. package/lib/commonjs/classes/HMSSessionStore.js.map +1 -0
  48. package/lib/commonjs/classes/HMSSimulcastLayerDefinition.js +19 -0
  49. package/lib/commonjs/classes/HMSSimulcastLayerDefinition.js.map +1 -0
  50. package/lib/commonjs/classes/HMSSimulcastLayerSettingsPolicy.js +23 -0
  51. package/lib/commonjs/classes/HMSSimulcastLayerSettingsPolicy.js.map +1 -0
  52. package/lib/commonjs/classes/HMSSimulcastSettings.js +5 -4
  53. package/lib/commonjs/classes/HMSSimulcastSettings.js.map +1 -1
  54. package/lib/commonjs/classes/HMSSimulcastSettingsPolicy.js +17 -0
  55. package/lib/commonjs/classes/HMSSimulcastSettingsPolicy.js.map +1 -0
  56. package/lib/commonjs/classes/HMSSubscribeDegradationPolicy.js +21 -0
  57. package/lib/commonjs/classes/HMSSubscribeDegradationPolicy.js.map +1 -0
  58. package/lib/commonjs/classes/HMSSubscribeSettings.js +2 -0
  59. package/lib/commonjs/classes/HMSSubscribeSettings.js.map +1 -1
  60. package/lib/commonjs/classes/HMSUpdateListenerActions.js +8 -0
  61. package/lib/commonjs/classes/HMSUpdateListenerActions.js.map +1 -1
  62. package/lib/commonjs/classes/HMSVideoResolution.js.map +1 -1
  63. package/lib/commonjs/classes/HMSVideoTrackSettings.js +5 -0
  64. package/lib/commonjs/classes/HMSVideoTrackSettings.js.map +1 -1
  65. package/lib/commonjs/classes/HmsView.js +2 -0
  66. package/lib/commonjs/classes/HmsView.js.map +1 -1
  67. package/lib/commonjs/index.js +72 -0
  68. package/lib/commonjs/index.js.map +1 -1
  69. package/lib/commonjs/utils/emitter/EventEmitter.js +162 -0
  70. package/lib/commonjs/utils/emitter/EventEmitter.js.map +1 -0
  71. package/lib/commonjs/utils/emitter/_EmitterSubscription.js +46 -0
  72. package/lib/commonjs/utils/emitter/_EmitterSubscription.js.map +1 -0
  73. package/lib/commonjs/utils/emitter/_EventSubscription.js +36 -0
  74. package/lib/commonjs/utils/emitter/_EventSubscription.js.map +1 -0
  75. package/lib/commonjs/utils/emitter/_EventSubscriptionVendor.js +90 -0
  76. package/lib/commonjs/utils/emitter/_EventSubscriptionVendor.js.map +1 -0
  77. package/lib/commonjs/utils/index.js +17 -0
  78. package/lib/commonjs/utils/index.js.map +1 -0
  79. package/lib/module/classes/HMSAudioTrackSettings.js +14 -0
  80. package/lib/module/classes/HMSAudioTrackSettings.js.map +1 -1
  81. package/lib/module/classes/HMSCameraControl.js +21 -0
  82. package/lib/module/classes/HMSCameraControl.js.map +1 -0
  83. package/lib/module/classes/HMSEncoder.js +97 -14
  84. package/lib/module/classes/HMSEncoder.js.map +1 -1
  85. package/lib/module/classes/HMSIOSAudioMode.js +6 -0
  86. package/lib/module/classes/HMSIOSAudioMode.js.map +1 -0
  87. package/lib/module/classes/HMSLayer.js +7 -0
  88. package/lib/module/classes/HMSLayer.js.map +1 -0
  89. package/lib/module/classes/HMSLocalVideoStats.js +11 -0
  90. package/lib/module/classes/HMSLocalVideoStats.js.map +1 -1
  91. package/lib/module/classes/HMSPeer.js +1 -1
  92. package/lib/module/classes/HMSPeer.js.map +1 -1
  93. package/lib/module/classes/HMSPublishSettings.js +2 -0
  94. package/lib/module/classes/HMSPublishSettings.js.map +1 -1
  95. package/lib/module/classes/HMSQualityLimitationReason.js +9 -0
  96. package/lib/module/classes/HMSQualityLimitationReason.js.map +1 -0
  97. package/lib/module/classes/HMSQualityLimitationReasons.js +20 -0
  98. package/lib/module/classes/HMSQualityLimitationReasons.js.map +1 -0
  99. package/lib/module/classes/HMSRemotePeer.js.map +1 -1
  100. package/lib/module/classes/HMSRemoteVideoTrack.js +39 -3
  101. package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
  102. package/lib/module/classes/HMSRoom.js +4 -0
  103. package/lib/module/classes/HMSRoom.js.map +1 -1
  104. package/lib/module/classes/HMSRoomUpdate.js +1 -0
  105. package/lib/module/classes/HMSRoomUpdate.js.map +1 -1
  106. package/lib/module/classes/HMSSDK.js +83 -45
  107. package/lib/module/classes/HMSSDK.js.map +1 -1
  108. package/lib/module/classes/HMSSessionStore.js +166 -0
  109. package/lib/module/classes/HMSSessionStore.js.map +1 -0
  110. package/lib/module/classes/HMSSimulcastLayerDefinition.js +12 -0
  111. package/lib/module/classes/HMSSimulcastLayerDefinition.js.map +1 -0
  112. package/lib/module/classes/HMSSimulcastLayerSettingsPolicy.js +16 -0
  113. package/lib/module/classes/HMSSimulcastLayerSettingsPolicy.js.map +1 -0
  114. package/lib/module/classes/HMSSimulcastSettings.js +5 -4
  115. package/lib/module/classes/HMSSimulcastSettings.js.map +1 -1
  116. package/lib/module/classes/HMSSimulcastSettingsPolicy.js +10 -0
  117. package/lib/module/classes/HMSSimulcastSettingsPolicy.js.map +1 -0
  118. package/lib/module/classes/HMSSubscribeDegradationPolicy.js +14 -0
  119. package/lib/module/classes/HMSSubscribeDegradationPolicy.js.map +1 -0
  120. package/lib/module/classes/HMSSubscribeSettings.js +2 -0
  121. package/lib/module/classes/HMSSubscribeSettings.js.map +1 -1
  122. package/lib/module/classes/HMSUpdateListenerActions.js +8 -0
  123. package/lib/module/classes/HMSUpdateListenerActions.js.map +1 -1
  124. package/lib/module/classes/HMSVideoResolution.js.map +1 -1
  125. package/lib/module/classes/HMSVideoTrackSettings.js +5 -0
  126. package/lib/module/classes/HMSVideoTrackSettings.js.map +1 -1
  127. package/lib/module/classes/HmsView.js +2 -0
  128. package/lib/module/classes/HmsView.js.map +1 -1
  129. package/lib/module/index.js +6 -0
  130. package/lib/module/index.js.map +1 -1
  131. package/lib/module/utils/emitter/EventEmitter.js +151 -0
  132. package/lib/module/utils/emitter/EventEmitter.js.map +1 -0
  133. package/lib/module/utils/emitter/_EmitterSubscription.js +39 -0
  134. package/lib/module/utils/emitter/_EmitterSubscription.js.map +1 -0
  135. package/lib/module/utils/emitter/_EventSubscription.js +29 -0
  136. package/lib/module/utils/emitter/_EventSubscription.js.map +1 -0
  137. package/lib/module/utils/emitter/_EventSubscriptionVendor.js +83 -0
  138. package/lib/module/utils/emitter/_EventSubscriptionVendor.js.map +1 -0
  139. package/lib/module/utils/index.js +2 -0
  140. package/lib/module/utils/index.js.map +1 -0
  141. package/lib/typescript/classes/HMSAudioTrackSettings.d.ts +14 -0
  142. package/lib/typescript/classes/HMSCameraControl.d.ts +9 -0
  143. package/lib/typescript/classes/HMSEncoder.d.ts +13 -1
  144. package/lib/typescript/classes/HMSIOSAudioMode.d.ts +4 -0
  145. package/lib/typescript/classes/HMSLayer.d.ts +5 -0
  146. package/lib/typescript/classes/HMSLocalVideoStats.d.ts +6 -0
  147. package/lib/typescript/classes/HMSPeer.d.ts +1 -1
  148. package/lib/typescript/classes/HMSPublishSettings.d.ts +3 -0
  149. package/lib/typescript/classes/HMSQualityLimitationReason.d.ts +7 -0
  150. package/lib/typescript/classes/HMSQualityLimitationReasons.d.ts +17 -0
  151. package/lib/typescript/classes/HMSRemotePeer.d.ts +0 -1
  152. package/lib/typescript/classes/HMSRemoteVideoTrack.d.ts +6 -2
  153. package/lib/typescript/classes/HMSRoomUpdate.d.ts +2 -1
  154. package/lib/typescript/classes/HMSSDK.d.ts +21 -31
  155. package/lib/typescript/classes/HMSSessionStore.d.ts +63 -0
  156. package/lib/typescript/classes/HMSSimulcastLayerDefinition.d.ts +10 -0
  157. package/lib/typescript/classes/HMSSimulcastLayerSettingsPolicy.d.ts +12 -0
  158. package/lib/typescript/classes/HMSSimulcastSettings.d.ts +7 -3
  159. package/lib/typescript/classes/HMSSimulcastSettingsPolicy.d.ts +7 -0
  160. package/lib/typescript/classes/HMSSubscribeDegradationPolicy.d.ts +10 -0
  161. package/lib/typescript/classes/HMSSubscribeSettings.d.ts +5 -2
  162. package/lib/typescript/classes/HMSUpdateListenerActions.d.ts +9 -1
  163. package/lib/typescript/classes/HMSVideoResolution.d.ts +2 -2
  164. package/lib/typescript/classes/HMSVideoTrackSettings.d.ts +5 -0
  165. package/lib/typescript/classes/HmsView.d.ts +2 -2
  166. package/lib/typescript/index.d.ts +7 -0
  167. package/lib/typescript/utils/emitter/EventEmitter.d.ts +91 -0
  168. package/lib/typescript/utils/emitter/_EmitterSubscription.d.ts +29 -0
  169. package/lib/typescript/utils/emitter/_EventSubscription.d.ts +19 -0
  170. package/lib/typescript/utils/emitter/_EventSubscriptionVendor.d.ts +44 -0
  171. package/lib/typescript/utils/index.d.ts +1 -0
  172. package/package.json +21 -2
  173. package/sdk-versions.json +3 -3
  174. package/src/classes/HMSAudioTrackSettings.ts +16 -0
  175. package/src/classes/HMSCameraControl.ts +21 -0
  176. package/src/classes/HMSEncoder.ts +126 -11
  177. package/src/classes/HMSIOSAudioMode.ts +4 -0
  178. package/src/classes/HMSLayer.ts +5 -0
  179. package/src/classes/HMSLocalVideoStats.ts +21 -0
  180. package/src/classes/HMSPeer.ts +1 -1
  181. package/src/classes/HMSPublishSettings.ts +4 -0
  182. package/src/classes/HMSQualityLimitationReason.ts +7 -0
  183. package/src/classes/HMSQualityLimitationReasons.ts +27 -0
  184. package/src/classes/HMSRemotePeer.ts +0 -1
  185. package/src/classes/HMSRemoteVideoTrack.ts +52 -4
  186. package/src/classes/HMSRoom.ts +2 -0
  187. package/src/classes/HMSRoomUpdate.ts +1 -0
  188. package/src/classes/HMSSDK.tsx +124 -52
  189. package/src/classes/HMSSessionStore.ts +209 -0
  190. package/src/classes/HMSSimulcastLayerDefinition.ts +12 -0
  191. package/src/classes/HMSSimulcastLayerSettingsPolicy.ts +18 -0
  192. package/src/classes/HMSSimulcastSettings.ts +12 -3
  193. package/src/classes/HMSSimulcastSettingsPolicy.ts +9 -0
  194. package/src/classes/HMSSubscribeDegradationPolicy.ts +15 -0
  195. package/src/classes/HMSSubscribeSettings.ts +10 -2
  196. package/src/classes/HMSUpdateListenerActions.ts +8 -0
  197. package/src/classes/HMSVideoResolution.ts +1 -1
  198. package/src/classes/HMSVideoTrackSettings.ts +5 -0
  199. package/src/classes/HmsView.tsx +5 -1
  200. package/src/index.ts +10 -0
  201. package/src/utils/emitter/EventEmitter.ts +160 -0
  202. package/src/utils/emitter/_EmitterSubscription.ts +44 -0
  203. package/src/utils/emitter/_EventSubscription.ts +28 -0
  204. package/src/utils/emitter/_EventSubscriptionVendor.ts +89 -0
  205. package/src/utils/index.ts +1 -0
@@ -1,15 +1,11 @@
1
1
  import React from 'react';
2
- import { AppState, NativeModules, Platform, ViewStyle } from 'react-native';
2
+ import { AppState, NativeModules, Platform } from 'react-native';
3
3
  import { HMSEncoder } from './HMSEncoder';
4
4
  import { HMSHelper } from './HMSHelper';
5
- import { HMSLocalAudioStats } from './HMSLocalAudioStats';
6
- import { HMSLocalVideoStats } from './HMSLocalVideoStats';
7
5
  import { getLogger, logger, setLogger } from './HMSLogger';
8
- import { HMSRemoteAudioStats } from './HMSRemoteAudioStats';
9
- import { HMSRemoteVideoStats } from './HMSRemoteVideoStats';
10
6
  import { HMSTrackType } from './HMSTrackType';
11
7
  import { HMSUpdateListenerActions } from './HMSUpdateListenerActions';
12
- import { HmsViewComponent } from './HmsView';
8
+ import { HmsViewComponent, HmsComponentProps } from './HmsView';
13
9
 
14
10
  import type { HMSConfig } from './HMSConfig';
15
11
  import type { HMSLocalPeer } from './HMSLocalPeer';
@@ -29,10 +25,8 @@ import type { HMSAudioMixingMode } from './HMSAudioMixingMode';
29
25
  import type { HMSLogSettings } from './HMSLogSettings';
30
26
  import { HMSMessageType } from './HMSMessageType';
31
27
  import { HMSPIPListenerActions } from './HMSPIPListenerActions';
32
- import {
33
- type HMSEventSubscription,
34
- HMSNativeEventEmitter,
35
- } from './HMSNativeEventEmitter';
28
+ import type { HMSEventSubscription } from './HMSNativeEventEmitter';
29
+ import { HMSNativeEventEmitter } from './HMSNativeEventEmitter';
36
30
  import {
37
31
  clearHmsPeersCache,
38
32
  getHmsPeersCache,
@@ -46,15 +40,11 @@ import {
46
40
  setHmsRoomCache,
47
41
  } from './HMSRoomCache';
48
42
  import { HMSPeerUpdateOrdinals } from './HMSPeerUpdate';
43
+ import { HMSSessionStore } from './HMSSessionStore';
49
44
 
50
- interface HmsViewProps {
51
- trackId: string;
52
- style?: ViewStyle;
53
- mirror?: boolean;
54
- scaleType?: HMSVideoViewMode;
55
- setZOrderMediaOverlay?: boolean;
56
- }
45
+ type HmsViewProps = Omit<HmsComponentProps, 'id'>;
57
46
 
47
+ // TODO: Rename to HMSPIPConfig & to be moved to a separate file
58
48
  interface PIPConfig {
59
49
  aspectRatio?: [number, number];
60
50
  endButton?: boolean;
@@ -98,6 +88,7 @@ export class HMSSDK {
98
88
  private onRemoteAudioStatsDelegate?: any;
99
89
  private onRemoteVideoStatsDelegate?: any;
100
90
  private onAudioDeviceChangedDelegate?: any;
91
+ private onSessionStoreAvailableDelegate?: any;
101
92
  private onPIPRoomLeaveDelegate?: any;
102
93
 
103
94
  private emitterSubscriptions: Partial<
@@ -250,6 +241,7 @@ export class HMSSDK {
250
241
  * - The appearance of tile is completely customizable with style prop.
251
242
  * - Scale type can determine how the incoming video will fit in the canvas check {@link HMSVideoViewMode} for more information.
252
243
  * - Mirror to flip the video vertically.
244
+ * - Auto Simulcast to automatically select the best Streaming Quality of track if feature is enabled in Room.
253
245
  *
254
246
  * checkout {@link https://www.100ms.live/docs/react-native/v2/features/render-video} for more info
255
247
  *
@@ -257,12 +249,20 @@ export class HMSSDK {
257
249
  * @memberof HMSSDK
258
250
  */
259
251
  HmsView = React.forwardRef<any, HmsViewProps>((props, ref) => {
260
- const { trackId, style, mirror, scaleType, setZOrderMediaOverlay } = props;
252
+ const {
253
+ trackId,
254
+ style,
255
+ mirror,
256
+ scaleType,
257
+ setZOrderMediaOverlay,
258
+ autoSimulcast,
259
+ } = props;
261
260
  return (
262
261
  <HmsViewComponent
263
262
  ref={ref}
264
263
  trackId={trackId}
265
264
  style={style}
265
+ autoSimulcast={autoSimulcast}
266
266
  setZOrderMediaOverlay={setZOrderMediaOverlay}
267
267
  mirror={mirror}
268
268
  scaleType={scaleType}
@@ -845,36 +845,6 @@ export class HMSSDK {
845
845
  return await HMSManager.stopScreenshare({ id: this.id });
846
846
  };
847
847
 
848
- /**
849
- * - enableRTCStats sets a boolean in native side which in turn allows several events to be passed
850
- * through the bridge these events are {@link RTCStatsListener}, {@link onRemoteVideoStatsListener},
851
- * {@link onRemoteAudioStatsListener}, {@link onLocalAudioStatsListener} and {@link onLocalVideoStatsListener}
852
- *
853
- * - These listeners get various dataPoints for current peers and their connectivity to the room
854
- * such as jitter, latency etc.
855
- *
856
- * - currently available for iOS only
857
- *
858
- * @memberof HMSSDK
859
- */
860
- enableRTCStats = () => {
861
- logger?.verbose('#Function enableRTCStats', { id: this.id });
862
- HMSManager.enableRTCStats({ id: this.id });
863
- };
864
-
865
- /**
866
- * - disable RTCStats sets the same boolean to false that was set true by enableRTCStats.
867
- * that activates a check which filters out the events acquired in native listeners and don't
868
- * let them pass through bridge
869
- *
870
- * - currently available for iOS only.
871
- * @memberof HMSSDK
872
- */
873
- disableRTCStats = () => {
874
- logger?.verbose('#Function disableRTCStats', { id: this.id });
875
- HMSManager.disableRTCStats({ id: this.id });
876
- };
877
-
878
848
  enableNetworkQualityUpdates = () => {
879
849
  logger?.verbose('#Function enableNetworkQualityUpdates', { id: this.id });
880
850
  HMSManager.enableNetworkQualityUpdates({ id: this.id });
@@ -1088,6 +1058,12 @@ export class HMSSDK {
1088
1058
  }
1089
1059
  };
1090
1060
 
1061
+ /**
1062
+ * @deprecated Older SessionMetaData APIs has been deprecated in favour of newer Session Store APIs.
1063
+ * You can subscribe to `ON_SESSION_STORE_AVAILABLE` event to get notified when the `HMSSessionStore`
1064
+ * is available and use `set` method on `HMSSessionStore` instance
1065
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/}
1066
+ */
1091
1067
  setSessionMetaData = async (sessionMetaData: string | null) => {
1092
1068
  logger?.verbose('#Function setSessionMetaData', {
1093
1069
  id: this.id,
@@ -1099,6 +1075,12 @@ export class HMSSDK {
1099
1075
  });
1100
1076
  };
1101
1077
 
1078
+ /**
1079
+ * @deprecated Older SessionMetaData APIs has been deprecated in favour of newer Session Store APIs.
1080
+ * You can subscribe to `ON_SESSION_STORE_AVAILABLE` event to get notified when the `HMSSessionStore`
1081
+ * is available and use `get` or `addKeyChangeListener` method on `HMSSessionStore` instance
1082
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/}
1083
+ */
1102
1084
  getSessionMetaData = async () => {
1103
1085
  logger?.verbose('#Function getSessionMetaData', {
1104
1086
  id: this.id,
@@ -1106,6 +1088,34 @@ export class HMSSDK {
1106
1088
  return await HMSManager.getSessionMetaData({ id: this.id });
1107
1089
  };
1108
1090
 
1091
+ getRemoteVideoTrackFromTrackId = async (trackId: string) => {
1092
+ logger?.verbose('#Function getRemoteVideoTrackFromTrackId', {
1093
+ id: this.id,
1094
+ trackId,
1095
+ });
1096
+
1097
+ const remoteVideoTrackData =
1098
+ await HMSManager.getRemoteVideoTrackFromTrackId({
1099
+ id: this.id,
1100
+ trackId,
1101
+ });
1102
+ return HMSEncoder.encodeHmsRemoteVideoTrack(remoteVideoTrackData, this.id);
1103
+ };
1104
+
1105
+ getRemoteAudioTrackFromTrackId = async (trackId: string) => {
1106
+ logger?.verbose('#Function getRemoteAudioTrackFromTrackId', {
1107
+ id: this.id,
1108
+ trackId,
1109
+ });
1110
+
1111
+ const remoteAudioTrackData =
1112
+ await HMSManager.getRemoteAudioTrackFromTrackId({
1113
+ id: this.id,
1114
+ trackId,
1115
+ });
1116
+ return HMSEncoder.encodeHmsRemoteAudioTrack(remoteAudioTrackData, this.id);
1117
+ };
1118
+
1109
1119
  /**
1110
1120
  * - This is a prototype event listener that takes action and listens for updates related to that particular action
1111
1121
  *
@@ -1472,6 +1482,27 @@ export class HMSSDK {
1472
1482
  this.onAudioDeviceChangedDelegate = callback;
1473
1483
  break;
1474
1484
  }
1485
+ case HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE: {
1486
+ // Checking if we already have ON_SESSION_STORE_AVAILABLE subscription
1487
+ if (
1488
+ !this.emitterSubscriptions[
1489
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE
1490
+ ]
1491
+ ) {
1492
+ // Adding ON_SESSION_STORE_AVAILABLE native listener
1493
+ const sessionStoreAvailableSubscription = HmsEventEmitter.addListener(
1494
+ this.id,
1495
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE,
1496
+ this.onSessionStoreAvailableListener
1497
+ );
1498
+ this.emitterSubscriptions[
1499
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE
1500
+ ] = sessionStoreAvailableSubscription;
1501
+ }
1502
+ // Adding Session Store Available App Delegate listener
1503
+ this.onSessionStoreAvailableDelegate = callback;
1504
+ break;
1505
+ }
1475
1506
  case HMSPIPListenerActions.ON_PIP_ROOM_LEAVE: {
1476
1507
  if (Platform.OS === 'android') {
1477
1508
  // Checking if we already have ON_PIP_ROOM_LEAVE subscription
@@ -1798,6 +1829,23 @@ export class HMSSDK {
1798
1829
  this.onAudioDeviceChangedDelegate = null;
1799
1830
  break;
1800
1831
  }
1832
+ case HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE: {
1833
+ const subscription =
1834
+ this.emitterSubscriptions[
1835
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE
1836
+ ];
1837
+ // Removing ON_SESSION_STORE_AVAILABLE native listener
1838
+ if (subscription) {
1839
+ subscription.remove();
1840
+
1841
+ this.emitterSubscriptions[
1842
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE
1843
+ ] = undefined;
1844
+ }
1845
+ // Removing App Delegate listener
1846
+ this.onSessionStoreAvailableDelegate = null;
1847
+ break;
1848
+ }
1801
1849
  case HMSPIPListenerActions.ON_PIP_ROOM_LEAVE: {
1802
1850
  if (Platform.OS === 'android') {
1803
1851
  const subscription =
@@ -2105,7 +2153,9 @@ export class HMSSDK {
2105
2153
  return;
2106
2154
  }
2107
2155
 
2108
- let localAudioStats = new HMSLocalAudioStats(data.localAudioStats);
2156
+ let localAudioStats = HMSEncoder.encodeHMSLocalAudioStats(
2157
+ data.localAudioStats
2158
+ );
2109
2159
  let peer = HMSEncoder.encodeHmsPeer(data.peer);
2110
2160
  let track = HMSEncoder.encodeHmsLocalAudioTrack(data.track, this.id);
2111
2161
 
@@ -2125,7 +2175,9 @@ export class HMSSDK {
2125
2175
  return;
2126
2176
  }
2127
2177
 
2128
- let localVideoStats = new HMSLocalVideoStats(data.localVideoStats);
2178
+ let localVideoStats = HMSEncoder.encodeHMSLocalVideoStats(
2179
+ data.localVideoStats
2180
+ );
2129
2181
  let peer = HMSEncoder.encodeHmsPeer(data.peer);
2130
2182
  let track = HMSEncoder.encodeHmsLocalVideoTrack(data.track, this.id);
2131
2183
 
@@ -2145,7 +2197,9 @@ export class HMSSDK {
2145
2197
  return;
2146
2198
  }
2147
2199
 
2148
- let remoteAudioStats = new HMSRemoteAudioStats(data.remoteAudioStats);
2200
+ let remoteAudioStats = HMSEncoder.encodeHMSRemoteAudioStats(
2201
+ data.remoteAudioStats
2202
+ );
2149
2203
  let peer = HMSEncoder.encodeHmsPeer(data.peer);
2150
2204
  let track = HMSEncoder.encodeHmsRemoteAudioTrack(data.track, this.id);
2151
2205
 
@@ -2170,7 +2224,9 @@ export class HMSSDK {
2170
2224
  return;
2171
2225
  }
2172
2226
 
2173
- let remoteVideoStats = new HMSRemoteVideoStats(data.remoteVideoStats);
2227
+ let remoteVideoStats = HMSEncoder.encodeHMSRemoteVideoStats(
2228
+ data.remoteVideoStats
2229
+ );
2174
2230
  let peer = HMSEncoder.encodeHmsPeer(data.peer);
2175
2231
  let track = HMSEncoder.encodeHmsRemoteVideoTrack(data.track, this.id);
2176
2232
 
@@ -2206,6 +2262,22 @@ export class HMSSDK {
2206
2262
  }
2207
2263
  };
2208
2264
 
2265
+ onSessionStoreAvailableListener = (data: { id: string }) => {
2266
+ if (data.id !== this.id) {
2267
+ return;
2268
+ }
2269
+ if (this.onSessionStoreAvailableDelegate) {
2270
+ logger?.verbose(
2271
+ '#Listener ON_SESSION_STORE_AVAILABLE_LISTENER_CALL',
2272
+ data
2273
+ );
2274
+ this.onSessionStoreAvailableDelegate({
2275
+ ...data,
2276
+ sessionStore: new HMSSessionStore(),
2277
+ });
2278
+ }
2279
+ };
2280
+
2209
2281
  onPIPRoomLeaveListener = (data: { id: string }) => {
2210
2282
  if (data.id !== this.id) {
2211
2283
  return;
@@ -0,0 +1,209 @@
1
+ import {
2
+ NativeModules,
3
+ DeviceEventEmitter,
4
+ EmitterSubscription as RNEmitterSubscription,
5
+ } from 'react-native';
6
+ import { HMSConstants } from './HMSConstants';
7
+ import { getLogger } from './HMSLogger';
8
+ import { HMSUpdateListenerActions } from './HMSUpdateListenerActions';
9
+ import { EventEmitter } from '../utils';
10
+ import type { EmitterSubscription } from '../utils';
11
+
12
+ const { HMSManager } = NativeModules;
13
+
14
+ type Nullable<T> = T | null | undefined;
15
+
16
+ export type HMSSessionStoreValue = Nullable<string>;
17
+
18
+ /**
19
+ * Session store is a shared realtime key-value store that is accessible by everyone in the room.
20
+ * It can be utilized to implement features such as pinned text, spotlight (which brings a particular
21
+ * peer to the center stage for everyone in the room) and more.
22
+ *
23
+ * To get an instance of `HMSSessionStore` class, You can add an event listener for `ON_SESSION_STORE_AVAILABLE`
24
+ * event on the `HMSSDK` instance
25
+ *
26
+ * For example:
27
+ * ```
28
+ * hmsInstance.addEventListener(HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE, <your callback function>);
29
+ * ```
30
+ *
31
+ * Checkout Session Store docs fore more details ${@link https://www.100ms.live/docs/react-native/v2/how-to-guides/interact-with-room/room/session-store}
32
+ */
33
+ export class HMSSessionStore {
34
+ private _deviceEventEmitterSubscription?: RNEmitterSubscription;
35
+ private _eventEmitter?: EventEmitter;
36
+ private _addedKeyChangeListenerCount = 0;
37
+
38
+ /**
39
+ * This method sets a value for a specific key on session store.
40
+ * Once a value is assigned, it will be available for other peers in the room
41
+ * who are listening for changes in value for that specific key.
42
+ *
43
+ * @param {HMSSessionStoreValue} value
44
+ * @param {string} key
45
+ * @returns {Promise}
46
+ */
47
+ async set(value: HMSSessionStoreValue, key: string) {
48
+ const data: { success: true; finalValue: HMSSessionStoreValue } =
49
+ await HMSManager.setSessionMetadataForKey({
50
+ id: HMSConstants.DEFAULT_SDK_ID,
51
+ key,
52
+ value,
53
+ });
54
+ return data;
55
+ }
56
+
57
+ /**
58
+ * This method returns the value of any specified key on session store.
59
+ * Note that you will not get updates for any change in value of the specified key,
60
+ * It returns the latest value at the time it was called.
61
+ *
62
+ * To listen to value change updates use `addKeyChangeListener` method instead.
63
+ *
64
+ * @param {string} key
65
+ * @returns {Promise}
66
+ */
67
+ async get(key: string) {
68
+ const data: HMSSessionStoreValue =
69
+ await HMSManager.getSessionMetadataForKey({
70
+ id: HMSConstants.DEFAULT_SDK_ID,
71
+ key,
72
+ });
73
+ return data;
74
+ }
75
+
76
+ /**
77
+ * This method registers a callback function for listening to value changes of a particular key.
78
+ * Registered Callback function will be called initially with latest value and whenever the value updates
79
+ *
80
+ * @param {string[]} forKeys
81
+ * @param {Function} callback
82
+ * @returns {Object} subscription object
83
+ */
84
+ addKeyChangeListener<T extends string[]>(
85
+ forKeys: T,
86
+ callback: (
87
+ error: string | null,
88
+ data: { key: T[number]; value: HMSSessionStoreValue } | null
89
+ ) => void
90
+ ) {
91
+ // Add Native Device Event Emitter if it is not already added
92
+ if (!this._deviceEventEmitterSubscription) {
93
+ this._deviceEventEmitterSubscription = DeviceEventEmitter.addListener(
94
+ HMSUpdateListenerActions.ON_SESSION_STORE_CHANGED,
95
+ this._deviceEventEmitterListener.bind(this)
96
+ );
97
+ }
98
+
99
+ // Create JS side EventEmitter
100
+ if (!this._eventEmitter) {
101
+ this._eventEmitter = new EventEmitter();
102
+ }
103
+
104
+ // Unique Identifier for adding native event listener
105
+ const uniqueId = forKeys.join('') + '_' + Date.now().toString();
106
+
107
+ const eventEmitter = this._eventEmitter;
108
+
109
+ // Add listeners on eventEmitter for each key
110
+ const subscriptions = forKeys.map((key) =>
111
+ eventEmitter.addListener(key, callback, { uniqueId })
112
+ );
113
+
114
+ //
115
+ let cleanupHandler: (() => void) | null = () => {
116
+ this._cleanup(subscriptions);
117
+ };
118
+
119
+ // Adding 'KeyChangeListener' on native side
120
+ HMSManager.addKeyChangeListener({
121
+ id: HMSConstants.DEFAULT_SDK_ID,
122
+ keys: forKeys,
123
+ uniqueId,
124
+ })
125
+ // Adding 'KeyChangeListener' fails on native side
126
+ .catch((err: any) => {
127
+ if (typeof cleanupHandler === 'function') {
128
+ callback(err, null);
129
+ cleanupHandler();
130
+ cleanupHandler = null;
131
+ }
132
+ });
133
+
134
+ this._addedKeyChangeListenerCount += 1;
135
+
136
+ return {
137
+ remove: () => {
138
+ if (typeof cleanupHandler === 'function') {
139
+ cleanupHandler();
140
+ cleanupHandler = null;
141
+ }
142
+ },
143
+ };
144
+ }
145
+
146
+ private _cleanup(subscriptionsToRemove: EmitterSubscription[]) {
147
+ // Extracting `uniqueId` from first subscription (all subscriptions have same uniqueId)
148
+ // this `uniqueId` will be used to remove 'KeyChangeListener' from native side
149
+ const uniqueId =
150
+ subscriptionsToRemove.length > 0
151
+ ? (subscriptionsToRemove[0].context as { uniqueId: string }).uniqueId
152
+ : null;
153
+
154
+ // Removing required subscriptions from 'eventEmitter'
155
+ subscriptionsToRemove.forEach((subscription) => subscription.remove());
156
+
157
+ // Removing 'KeyChangeListener' from native side
158
+ HMSManager.removeKeyChangeListener({
159
+ id: HMSConstants.DEFAULT_SDK_ID,
160
+ uniqueId,
161
+ }).catch((error: any) => {
162
+ const logger = getLogger();
163
+ logger?.verbose(
164
+ "Error while removing key change listener, Listener didn't get registerred at first place or was already removed",
165
+ error
166
+ );
167
+ });
168
+
169
+ this._addedKeyChangeListenerCount -= 1;
170
+
171
+ if (this._addedKeyChangeListenerCount <= 0) {
172
+ this._addedKeyChangeListenerCount = 0;
173
+ if (
174
+ this._deviceEventEmitterSubscription &&
175
+ Object.getOwnPropertyNames(
176
+ this._deviceEventEmitterSubscription
177
+ ).includes('remove') &&
178
+ typeof this._deviceEventEmitterSubscription.remove === 'function'
179
+ ) {
180
+ this._deviceEventEmitterSubscription.remove();
181
+ } else {
182
+ DeviceEventEmitter.removeListener(
183
+ HMSUpdateListenerActions.ON_SESSION_STORE_CHANGED,
184
+ this._deviceEventEmitterListener
185
+ );
186
+ }
187
+
188
+ this._deviceEventEmitterSubscription = undefined;
189
+
190
+ this._eventEmitter = undefined;
191
+ }
192
+ }
193
+
194
+ private _deviceEventEmitterListener(data: {
195
+ id: string;
196
+ key: string;
197
+ value: HMSSessionStoreValue;
198
+ }) {
199
+ // if id is different from default sdk_id, return early
200
+ if (data.id !== HMSConstants.DEFAULT_SDK_ID) {
201
+ return;
202
+ }
203
+
204
+ // emit event for the key
205
+ getLogger()?.verbose('#Listener ON_SESSION_STORE_CHANGED event: ', data);
206
+
207
+ this._eventEmitter?.emit(data.key, null, data);
208
+ }
209
+ }
@@ -0,0 +1,12 @@
1
+ import type { HMSLayer } from './HMSLayer';
2
+ import type { HMSVideoResolution } from './HMSVideoResolution';
3
+
4
+ export class HMSSimulcastLayerDefinition {
5
+ layer: HMSLayer;
6
+ resolution: HMSVideoResolution;
7
+
8
+ constructor(params: { layer: HMSLayer; resolution: HMSVideoResolution }) {
9
+ this.layer = params.layer;
10
+ this.resolution = params.resolution;
11
+ }
12
+ }
@@ -0,0 +1,18 @@
1
+ export class HMSSimulcastLayerSettingsPolicy {
2
+ rid?: string;
3
+ scaleResolutionDownBy?: number;
4
+ maxBitrate?: number;
5
+ maxFramerate?: number;
6
+
7
+ constructor(params: {
8
+ rid?: string;
9
+ scaleResolutionDownBy?: number;
10
+ maxBitrate?: number;
11
+ maxFramerate?: number;
12
+ }) {
13
+ this.rid = params.rid;
14
+ this.scaleResolutionDownBy = params.scaleResolutionDownBy;
15
+ this.maxBitrate = params.maxBitrate;
16
+ this.maxFramerate = params.maxFramerate;
17
+ }
18
+ }
@@ -1,5 +1,14 @@
1
+ import type { HMSSimulcastSettingsPolicy } from './HMSSimulcastSettingsPolicy';
2
+
1
3
  export class HMSSimulcastSettings {
2
- low: any;
3
- med: any;
4
- high: any;
4
+ video?: HMSSimulcastSettingsPolicy;
5
+ screen?: HMSSimulcastSettingsPolicy;
6
+
7
+ constructor(params: {
8
+ video?: HMSSimulcastSettingsPolicy;
9
+ screen?: HMSSimulcastSettingsPolicy;
10
+ }) {
11
+ this.video = params.video;
12
+ this.screen = params.screen;
13
+ }
5
14
  }
@@ -0,0 +1,9 @@
1
+ import type { HMSSimulcastLayerSettingsPolicy } from './HMSSimulcastLayerSettingsPolicy';
2
+
3
+ export class HMSSimulcastSettingsPolicy {
4
+ layers?: HMSSimulcastLayerSettingsPolicy[];
5
+
6
+ constructor(params: { layers?: HMSSimulcastLayerSettingsPolicy[] }) {
7
+ this.layers = params.layers;
8
+ }
9
+ }
@@ -0,0 +1,15 @@
1
+ export class HMSSubscribeDegradationPolicy {
2
+ packetLossThreshold?: number;
3
+ degradeGracePeriodSeconds?: number;
4
+ recoverGracePeriodSeconds?: number;
5
+
6
+ constructor(params: {
7
+ packetLossThreshold?: number;
8
+ degradeGracePeriodSeconds?: number;
9
+ recoverGracePeriodSeconds?: number;
10
+ }) {
11
+ this.packetLossThreshold = params.packetLossThreshold;
12
+ this.degradeGracePeriodSeconds = params.degradeGracePeriodSeconds;
13
+ this.recoverGracePeriodSeconds = params.recoverGracePeriodSeconds;
14
+ }
15
+ }
@@ -1,9 +1,17 @@
1
+ import type { HMSSubscribeDegradationPolicy } from './HMSSubscribeDegradationPolicy';
2
+
1
3
  export class HMSSubscribeSettings {
2
- subscribeTo?: [string];
4
+ subscribeTo?: string[];
3
5
  maxSubsBitRate: number;
6
+ subscribeDegradation?: HMSSubscribeDegradationPolicy;
4
7
 
5
- constructor(params: { subscribeTo?: [string]; maxSubsBitRate: number }) {
8
+ constructor(params: {
9
+ subscribeTo?: string[];
10
+ maxSubsBitRate: number;
11
+ subscribeDegradation?: HMSSubscribeDegradationPolicy;
12
+ }) {
6
13
  this.subscribeTo = params.subscribeTo;
7
14
  this.maxSubsBitRate = params.maxSubsBitRate;
15
+ this.subscribeDegradation = params.subscribeDegradation;
8
16
  }
9
17
  }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * These are the available events emitted by the `HMSSDK`
3
+ *
4
+ * For more info about these events, checkout Event Listener docs
5
+ * {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/listen-to-room-updates/event-listeners}
6
+ */
1
7
  export enum HMSUpdateListenerActions {
2
8
  ON_PREVIEW = 'ON_PREVIEW',
3
9
  ON_JOIN = 'ON_JOIN',
@@ -18,4 +24,6 @@ export enum HMSUpdateListenerActions {
18
24
  ON_REMOTE_AUDIO_STATS = 'ON_REMOTE_AUDIO_STATS',
19
25
  ON_REMOTE_VIDEO_STATS = 'ON_REMOTE_VIDEO_STATS',
20
26
  ON_AUDIO_DEVICE_CHANGED = 'ON_AUDIO_DEVICE_CHANGED',
27
+ ON_SESSION_STORE_AVAILABLE = 'ON_SESSION_STORE_AVAILABLE',
28
+ ON_SESSION_STORE_CHANGED = 'ON_SESSION_STORE_CHANGED',
21
29
  }
@@ -2,7 +2,7 @@ export class HMSVideoResolution {
2
2
  height?: number;
3
3
  width?: number;
4
4
 
5
- constructor(params: { height: number; width: number }) {
5
+ constructor(params: { height?: number; width?: number }) {
6
6
  this.height = params.height;
7
7
  this.width = params.width;
8
8
  }
@@ -2,6 +2,11 @@ import type { HMSSimulcastLayerSettings } from './HMSSimulcastLayerSettings';
2
2
  import type { HMSCameraFacing } from './HMSCameraFacing';
3
3
  import type { HMSTrackSettingsInitState } from './HMSTrackSettingsInitState';
4
4
 
5
+ /**
6
+ * Customize local peer's Video track settings before Joining the Room.
7
+ *
8
+ * Checkout Track Settings docs for more details {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/interact-with-room/track/track-settings}
9
+ */
5
10
  export class HMSVideoTrackSettings {
6
11
  readonly simulcastSettings?: HMSSimulcastLayerSettings[];
7
12
  initialState?: HMSTrackSettingsInitState;
@@ -15,6 +15,7 @@ interface HmsViewProps {
15
15
  id: string;
16
16
  mirror: boolean;
17
17
  };
18
+ autoSimulcast: boolean;
18
19
  setZOrderMediaOverlay: boolean;
19
20
  scaleType: HMSVideoViewMode;
20
21
  style: ViewStyle;
@@ -26,10 +27,11 @@ const HmsView = requireNativeComponent<HmsViewProps>('HMSView');
26
27
  let _nextRequestId = 1;
27
28
  let _requestMap = new Map();
28
29
 
29
- interface HmsComponentProps {
30
+ export interface HmsComponentProps {
30
31
  trackId: string;
31
32
  style?: ViewStyle;
32
33
  mirror?: boolean;
34
+ autoSimulcast?: boolean;
33
35
  scaleType?: HMSVideoViewMode;
34
36
  setZOrderMediaOverlay?: boolean;
35
37
  id: string;
@@ -43,6 +45,7 @@ export const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(
43
45
  id = HMSConstants.DEFAULT_SDK_ID,
44
46
  mirror = false,
45
47
  setZOrderMediaOverlay = false,
48
+ autoSimulcast = true,
46
49
  scaleType = HMSVideoViewMode.ASPECT_FILL,
47
50
  } = props;
48
51
 
@@ -127,6 +130,7 @@ export const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(
127
130
  onChange={onChange}
128
131
  data={data}
129
132
  style={tempVal === 0 ? style : temporaryStyles.customStyle}
133
+ autoSimulcast={autoSimulcast}
130
134
  scaleType={scaleType}
131
135
  setZOrderMediaOverlay={setZOrderMediaOverlay}
132
136
  onDataReturned={_onDataReturned}