@100mslive/react-native-hms 1.7.0 → 1.7.1

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 (168) hide show
  1. package/README.md +30 -39
  2. package/android/.gradle/6.7.1/executionHistory/executionHistory.lock +0 -0
  3. package/android/.gradle/6.7.1/fileChanges/last-build.bin +0 -0
  4. package/android/.gradle/6.7.1/fileHashes/fileHashes.lock +0 -0
  5. package/android/.gradle/6.7.1/gc.properties +0 -0
  6. package/android/.gradle/6.9/executionHistory/executionHistory.bin +0 -0
  7. package/android/.gradle/6.9/executionHistory/executionHistory.lock +0 -0
  8. package/android/.gradle/6.9/fileChanges/last-build.bin +0 -0
  9. package/android/.gradle/6.9/fileHashes/fileHashes.bin +0 -0
  10. package/android/.gradle/6.9/fileHashes/fileHashes.lock +0 -0
  11. package/android/.gradle/6.9/gc.properties +0 -0
  12. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  13. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  14. package/android/.gradle/checksums/checksums.lock +0 -0
  15. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  16. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  17. package/android/.gradle/configuration-cache/gc.properties +0 -0
  18. package/android/.gradle/vcs-1/gc.properties +0 -0
  19. package/android/build.gradle +16 -9
  20. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  21. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  22. package/android/gradlew +103 -104
  23. package/android/gradlew.bat +3 -18
  24. package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +27 -3
  25. package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +2 -1
  26. package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +7 -0
  27. package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +39 -10
  28. package/ios/HMSDecoder.swift +4 -3
  29. package/ios/HMSHelper.swift +6 -2
  30. package/ios/HMSManager.m +4 -0
  31. package/ios/HMSManager.swift +8 -0
  32. package/ios/HMSRNSDK.swift +54 -24
  33. package/lib/commonjs/classes/HMSAudioTrack.js.map +1 -1
  34. package/lib/commonjs/classes/HMSBrowserRecordingState.js +2 -0
  35. package/lib/commonjs/classes/HMSBrowserRecordingState.js.map +1 -1
  36. package/lib/commonjs/classes/HMSCameraControl.js +3 -5
  37. package/lib/commonjs/classes/HMSCameraControl.js.map +1 -1
  38. package/lib/commonjs/classes/HMSEncoder.js +33 -34
  39. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  40. package/lib/commonjs/classes/HMSEventEmitter.js +10 -0
  41. package/lib/commonjs/classes/HMSEventEmitter.js.map +1 -0
  42. package/lib/commonjs/classes/HMSLocalAudioTrack.js.map +1 -1
  43. package/lib/commonjs/classes/HMSLocalPeer.js.map +1 -1
  44. package/lib/commonjs/classes/HMSLocalVideoTrack.js.map +1 -1
  45. package/lib/commonjs/classes/HMSManagerModule.js +18 -0
  46. package/lib/commonjs/classes/HMSManagerModule.js.map +1 -0
  47. package/lib/commonjs/classes/HMSNativeEventEmitter.js.map +1 -1
  48. package/lib/commonjs/classes/HMSNativeEventListener.js +13 -0
  49. package/lib/commonjs/classes/HMSNativeEventListener.js.map +1 -0
  50. package/lib/commonjs/classes/HMSPeersCache.js +3 -5
  51. package/lib/commonjs/classes/HMSPeersCache.js.map +1 -1
  52. package/lib/commonjs/classes/HMSRemoteAudioTrack.js.map +1 -1
  53. package/lib/commonjs/classes/HMSRemotePeer.js.map +1 -1
  54. package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
  55. package/lib/commonjs/classes/HMSRoom.js.map +1 -1
  56. package/lib/commonjs/classes/HMSRoomCache.js +10 -5
  57. package/lib/commonjs/classes/HMSRoomCache.js.map +1 -1
  58. package/lib/commonjs/classes/HMSSDK.js +79 -84
  59. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  60. package/lib/commonjs/classes/HMSSessionStore.js +6 -7
  61. package/lib/commonjs/classes/HMSSessionStore.js.map +1 -1
  62. package/lib/commonjs/classes/HMSTrack.js.map +1 -1
  63. package/lib/commonjs/classes/HMSVideoTrack.js.map +1 -1
  64. package/lib/commonjs/classes/HmsView.js +4 -1
  65. package/lib/commonjs/classes/HmsView.js.map +1 -1
  66. package/lib/commonjs/components/HMSHLSPlayer/HMSHLSPlayer.js +8 -8
  67. package/lib/commonjs/components/HMSHLSPlayer/HMSHLSPlayer.js.map +1 -1
  68. package/lib/commonjs/components/HMSHLSPlayer/RCTHMSHLSPlayer.js.map +1 -1
  69. package/lib/commonjs/components/HMSHLSPlayer/hooks.js.map +1 -1
  70. package/lib/commonjs/hooks/useHMSPeerUpdates.js +77 -0
  71. package/lib/commonjs/hooks/useHMSPeerUpdates.js.map +1 -0
  72. package/lib/commonjs/index.js +25 -1
  73. package/lib/commonjs/index.js.map +1 -1
  74. package/lib/module/classes/HMSAudioTrack.js.map +1 -1
  75. package/lib/module/classes/HMSBrowserRecordingState.js +2 -0
  76. package/lib/module/classes/HMSBrowserRecordingState.js.map +1 -1
  77. package/lib/module/classes/HMSCameraControl.js +1 -4
  78. package/lib/module/classes/HMSCameraControl.js.map +1 -1
  79. package/lib/module/classes/HMSEncoder.js +31 -33
  80. package/lib/module/classes/HMSEncoder.js.map +1 -1
  81. package/lib/module/classes/HMSEventEmitter.js +3 -0
  82. package/lib/module/classes/HMSEventEmitter.js.map +1 -0
  83. package/lib/module/classes/HMSLocalAudioTrack.js.map +1 -1
  84. package/lib/module/classes/HMSLocalPeer.js.map +1 -1
  85. package/lib/module/classes/HMSLocalVideoTrack.js.map +1 -1
  86. package/lib/module/classes/HMSManagerModule.js +11 -0
  87. package/lib/module/classes/HMSManagerModule.js.map +1 -0
  88. package/lib/module/classes/HMSNativeEventEmitter.js.map +1 -1
  89. package/lib/module/classes/HMSNativeEventListener.js +5 -0
  90. package/lib/module/classes/HMSNativeEventListener.js.map +1 -0
  91. package/lib/module/classes/HMSPeersCache.js +1 -4
  92. package/lib/module/classes/HMSPeersCache.js.map +1 -1
  93. package/lib/module/classes/HMSRemoteAudioTrack.js.map +1 -1
  94. package/lib/module/classes/HMSRemotePeer.js.map +1 -1
  95. package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
  96. package/lib/module/classes/HMSRoom.js.map +1 -1
  97. package/lib/module/classes/HMSRoomCache.js +8 -4
  98. package/lib/module/classes/HMSRoomCache.js.map +1 -1
  99. package/lib/module/classes/HMSSDK.js +27 -32
  100. package/lib/module/classes/HMSSDK.js.map +1 -1
  101. package/lib/module/classes/HMSSessionStore.js +2 -4
  102. package/lib/module/classes/HMSSessionStore.js.map +1 -1
  103. package/lib/module/classes/HMSTrack.js.map +1 -1
  104. package/lib/module/classes/HMSVideoTrack.js.map +1 -1
  105. package/lib/module/classes/HmsView.js +4 -1
  106. package/lib/module/classes/HmsView.js.map +1 -1
  107. package/lib/module/components/HMSHLSPlayer/HMSHLSPlayer.js +8 -8
  108. package/lib/module/components/HMSHLSPlayer/HMSHLSPlayer.js.map +1 -1
  109. package/lib/module/components/HMSHLSPlayer/RCTHMSHLSPlayer.js.map +1 -1
  110. package/lib/module/components/HMSHLSPlayer/hooks.js.map +1 -1
  111. package/lib/module/hooks/useHMSPeerUpdates.js +67 -0
  112. package/lib/module/hooks/useHMSPeerUpdates.js.map +1 -0
  113. package/lib/module/index.js +6 -0
  114. package/lib/module/index.js.map +1 -1
  115. package/lib/typescript/classes/HMSAudioTrack.d.ts +2 -1
  116. package/lib/typescript/classes/HMSBrowserRecordingState.d.ts +2 -0
  117. package/lib/typescript/classes/HMSEventEmitter.d.ts +2 -0
  118. package/lib/typescript/classes/HMSLocalAudioTrack.d.ts +2 -1
  119. package/lib/typescript/classes/HMSLocalPeer.d.ts +3 -2
  120. package/lib/typescript/classes/HMSLocalVideoTrack.d.ts +2 -1
  121. package/lib/typescript/classes/HMSManagerModule.d.ts +3 -0
  122. package/lib/typescript/classes/HMSNativeEventListener.d.ts +4 -0
  123. package/lib/typescript/classes/HMSRemoteAudioTrack.d.ts +2 -1
  124. package/lib/typescript/classes/HMSRemotePeer.d.ts +3 -2
  125. package/lib/typescript/classes/HMSRemoteVideoTrack.d.ts +2 -1
  126. package/lib/typescript/classes/HMSRoom.d.ts +1 -1
  127. package/lib/typescript/classes/HMSSDK.d.ts +2 -1
  128. package/lib/typescript/classes/HMSTrack.d.ts +3 -2
  129. package/lib/typescript/classes/HMSVideoTrack.d.ts +2 -1
  130. package/lib/typescript/classes/HmsView.d.ts +1 -1
  131. package/lib/typescript/components/HMSHLSPlayer/RCTHMSHLSPlayer.d.ts +1 -1
  132. package/lib/typescript/components/HMSHLSPlayer/hooks.d.ts +1 -1
  133. package/lib/typescript/hooks/useHMSPeerUpdates.d.ts +7 -0
  134. package/lib/typescript/index.d.ts +2 -0
  135. package/package.json +1 -1
  136. package/sdk-versions.json +2 -2
  137. package/src/classes/HMSAudioTrack.ts +2 -1
  138. package/src/classes/HMSBrowserRecordingState.ts +3 -0
  139. package/src/classes/HMSCameraControl.ts +1 -2
  140. package/src/classes/HMSEncoder.ts +4 -5
  141. package/src/classes/HMSEventEmitter.ts +3 -0
  142. package/src/classes/HMSLocalAudioTrack.ts +2 -1
  143. package/src/classes/HMSLocalPeer.ts +3 -2
  144. package/src/classes/HMSLocalVideoTrack.ts +2 -1
  145. package/src/classes/HMSManagerModule.ts +18 -0
  146. package/src/classes/HMSNativeEventEmitter.ts +2 -1
  147. package/src/classes/HMSNativeEventListener.ts +8 -0
  148. package/src/classes/HMSPeersCache.ts +2 -3
  149. package/src/classes/HMSRemoteAudioTrack.ts +2 -1
  150. package/src/classes/HMSRemotePeer.ts +3 -2
  151. package/src/classes/HMSRemoteVideoTrack.ts +2 -1
  152. package/src/classes/HMSRoom.ts +1 -1
  153. package/src/classes/HMSRoomCache.ts +11 -3
  154. package/src/classes/HMSSDK.tsx +41 -43
  155. package/src/classes/HMSSessionStore.ts +6 -8
  156. package/src/classes/HMSTrack.ts +3 -2
  157. package/src/classes/HMSVideoTrack.ts +2 -1
  158. package/src/classes/HmsView.tsx +8 -2
  159. package/src/components/HMSHLSPlayer/HMSHLSPlayer.tsx +36 -10
  160. package/src/components/HMSHLSPlayer/RCTHMSHLSPlayer.ts +2 -3
  161. package/src/components/HMSHLSPlayer/hooks.ts +3 -2
  162. package/src/hooks/useHMSPeerUpdates.ts +85 -0
  163. package/src/index.ts +6 -0
  164. package/android/local.properties +0 -8
  165. package/ios/Hmssdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  166. package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  167. package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcuserdata/yogesh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  168. package/ios/Hmssdk.xcodeproj/xcuserdata/yogesh.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -1,11 +1,14 @@
1
1
  import React from 'react';
2
- import { AppState, NativeModules, Platform } from 'react-native';
2
+ import { AppState, Platform } from 'react-native';
3
3
  import { HMSEncoder } from './HMSEncoder';
4
4
  import { HMSHelper } from './HMSHelper';
5
5
  import { getLogger, logger, setLogger } from './HMSLogger';
6
6
  import { HMSTrackType } from './HMSTrackType';
7
7
  import { HMSUpdateListenerActions } from './HMSUpdateListenerActions';
8
- import { HmsViewComponent, HmsComponentProps } from './HmsView';
8
+ import { HmsViewComponent } from './HmsView';
9
+ import type { HmsComponentProps } from './HmsView';
10
+
11
+ import HMSManager from './HMSManagerModule';
9
12
 
10
13
  import type { HMSConfig } from './HMSConfig';
11
14
  import type { HMSLocalPeer } from './HMSLocalPeer';
@@ -25,8 +28,8 @@ import type { HMSAudioMixingMode } from './HMSAudioMixingMode';
25
28
  import type { HMSLogSettings } from './HMSLogSettings';
26
29
  import { HMSMessageType } from './HMSMessageType';
27
30
  import { HMSPIPListenerActions } from './HMSPIPListenerActions';
28
- import type { HMSEventSubscription } from './HMSNativeEventEmitter';
29
- import { HMSNativeEventEmitter } from './HMSNativeEventEmitter';
31
+ import HMSNativeEventListener from './HMSNativeEventListener';
32
+ import type { HMSNativeEventSubscription } from './HMSNativeEventListener';
30
33
  import {
31
34
  clearHmsPeersCache,
32
35
  getHmsPeersCache,
@@ -52,17 +55,8 @@ interface PIPConfig {
52
55
  videoButton?: boolean;
53
56
  }
54
57
 
55
- const {
56
- /**
57
- * @ignore
58
- */
59
- HMSManager,
60
- } = NativeModules;
61
-
62
58
  const ReactNativeVersion = require('react-native/Libraries/Core/ReactNativeVersion');
63
59
 
64
- const HmsEventEmitter = new HMSNativeEventEmitter(HMSManager);
65
-
66
60
  let HmsSdk: HMSSDK | undefined;
67
61
 
68
62
  export class HMSSDK {
@@ -94,7 +88,7 @@ export class HMSSDK {
94
88
  private emitterSubscriptions: Partial<
95
89
  Record<
96
90
  HMSUpdateListenerActions | HMSPIPListenerActions,
97
- HMSEventSubscription
91
+ HMSNativeEventSubscription
98
92
  >
99
93
  > = {};
100
94
 
@@ -124,6 +118,7 @@ export class HMSSDK {
124
118
  appGroup?: String;
125
119
  preferredExtension?: String;
126
120
  logSettings?: HMSLogSettings;
121
+ isPrebuilt?: boolean;
127
122
  }) {
128
123
  const { version } = require('../../package.json');
129
124
  const { major, minor, patch } = ReactNativeVersion.version;
@@ -134,6 +129,7 @@ export class HMSSDK {
134
129
  frameworkInfo: {
135
130
  version: major + '.' + minor + '.' + patch,
136
131
  sdkVersion: version,
132
+ isPrebuilt: params?.isPrebuilt || false,
137
133
  },
138
134
  logSettings: params?.logSettings,
139
135
  });
@@ -1148,7 +1144,7 @@ export class HMSSDK {
1148
1144
  // Checking if we already have ON_PREVIEW subscription
1149
1145
  if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_PREVIEW]) {
1150
1146
  // Adding ON_PREVIEW native listener
1151
- const previewSubscription = HmsEventEmitter.addListener(
1147
+ const previewSubscription = HMSNativeEventListener.addListener(
1152
1148
  this.id,
1153
1149
  HMSUpdateListenerActions.ON_PREVIEW,
1154
1150
  this.onPreviewListener
@@ -1164,7 +1160,7 @@ export class HMSSDK {
1164
1160
  // Checking if we already have ON_JOIN subscription
1165
1161
  if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_JOIN]) {
1166
1162
  // Adding ON_JOIN native listener
1167
- const joinSubscription = HmsEventEmitter.addListener(
1163
+ const joinSubscription = HMSNativeEventListener.addListener(
1168
1164
  this.id,
1169
1165
  HMSUpdateListenerActions.ON_JOIN,
1170
1166
  this.onJoinListener
@@ -1182,7 +1178,7 @@ export class HMSSDK {
1182
1178
  !this.emitterSubscriptions[HMSUpdateListenerActions.ON_ROOM_UPDATE]
1183
1179
  ) {
1184
1180
  // Adding ON_ROOM_UPDATE native listener
1185
- const roomSubscription = HmsEventEmitter.addListener(
1181
+ const roomSubscription = HMSNativeEventListener.addListener(
1186
1182
  this.id,
1187
1183
  HMSUpdateListenerActions.ON_ROOM_UPDATE,
1188
1184
  this.onRoomListener
@@ -1200,7 +1196,7 @@ export class HMSSDK {
1200
1196
  !this.emitterSubscriptions[HMSUpdateListenerActions.ON_PEER_UPDATE]
1201
1197
  ) {
1202
1198
  // Adding ON_PEER_UPDATE native listener
1203
- const peerSubscription = HmsEventEmitter.addListener(
1199
+ const peerSubscription = HMSNativeEventListener.addListener(
1204
1200
  this.id,
1205
1201
  HMSUpdateListenerActions.ON_PEER_UPDATE,
1206
1202
  this.onPeerListener
@@ -1218,7 +1214,7 @@ export class HMSSDK {
1218
1214
  !this.emitterSubscriptions[HMSUpdateListenerActions.ON_TRACK_UPDATE]
1219
1215
  ) {
1220
1216
  // Adding ON_TRACK_UPDATE native listener
1221
- const trackSubscription = HmsEventEmitter.addListener(
1217
+ const trackSubscription = HMSNativeEventListener.addListener(
1222
1218
  this.id,
1223
1219
  HMSUpdateListenerActions.ON_TRACK_UPDATE,
1224
1220
  this.onTrackListener
@@ -1234,7 +1230,7 @@ export class HMSSDK {
1234
1230
  // Checking if we already have ON_ERROR subscription
1235
1231
  if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_ERROR]) {
1236
1232
  // Adding ON_ERROR native listener
1237
- const errorSubscription = HmsEventEmitter.addListener(
1233
+ const errorSubscription = HMSNativeEventListener.addListener(
1238
1234
  this.id,
1239
1235
  HMSUpdateListenerActions.ON_ERROR,
1240
1236
  this.onErrorListener
@@ -1250,7 +1246,7 @@ export class HMSSDK {
1250
1246
  // Checking if we already have ON_MESSAGE subscription
1251
1247
  if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_MESSAGE]) {
1252
1248
  // Adding ON_MESSAGE native listener
1253
- const messageSubscription = HmsEventEmitter.addListener(
1249
+ const messageSubscription = HMSNativeEventListener.addListener(
1254
1250
  this.id,
1255
1251
  HMSUpdateListenerActions.ON_MESSAGE,
1256
1252
  this.onMessageListener
@@ -1266,7 +1262,7 @@ export class HMSSDK {
1266
1262
  // Checking if we already have ON_SPEAKER subscription
1267
1263
  if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_SPEAKER]) {
1268
1264
  // Adding ON_SPEAKER native listener
1269
- const speakerSubscription = HmsEventEmitter.addListener(
1265
+ const speakerSubscription = HMSNativeEventListener.addListener(
1270
1266
  this.id,
1271
1267
  HMSUpdateListenerActions.ON_SPEAKER,
1272
1268
  this.onSpeakerListener
@@ -1282,7 +1278,7 @@ export class HMSSDK {
1282
1278
  // Checking if we already have RECONNECTING subscription
1283
1279
  if (!this.emitterSubscriptions[HMSUpdateListenerActions.RECONNECTING]) {
1284
1280
  // Adding RECONNECTING native listener
1285
- const reconnectingSubscription = HmsEventEmitter.addListener(
1281
+ const reconnectingSubscription = HMSNativeEventListener.addListener(
1286
1282
  this.id,
1287
1283
  HMSUpdateListenerActions.RECONNECTING,
1288
1284
  this.reconnectingListener
@@ -1298,7 +1294,7 @@ export class HMSSDK {
1298
1294
  // Checking if we already have RECONNECTED subscription
1299
1295
  if (!this.emitterSubscriptions[HMSUpdateListenerActions.RECONNECTED]) {
1300
1296
  // Adding RECONNECTED native listener
1301
- const reconnectedSubscription = HmsEventEmitter.addListener(
1297
+ const reconnectedSubscription = HMSNativeEventListener.addListener(
1302
1298
  this.id,
1303
1299
  HMSUpdateListenerActions.RECONNECTED,
1304
1300
  this.reconnectedListener
@@ -1318,7 +1314,7 @@ export class HMSSDK {
1318
1314
  ]
1319
1315
  ) {
1320
1316
  // Adding ON_ROLE_CHANGE_REQUEST native listener
1321
- const roleChangeReqSubscription = HmsEventEmitter.addListener(
1317
+ const roleChangeReqSubscription = HMSNativeEventListener.addListener(
1322
1318
  this.id,
1323
1319
  HMSUpdateListenerActions.ON_ROLE_CHANGE_REQUEST,
1324
1320
  this.onRoleChangeRequestListener
@@ -1339,7 +1335,7 @@ export class HMSSDK {
1339
1335
  ]
1340
1336
  ) {
1341
1337
  // Adding ON_CHANGE_TRACK_STATE_REQUEST native listener
1342
- const changeTrackReqSubscription = HmsEventEmitter.addListener(
1338
+ const changeTrackReqSubscription = HMSNativeEventListener.addListener(
1343
1339
  this.id,
1344
1340
  HMSUpdateListenerActions.ON_CHANGE_TRACK_STATE_REQUEST,
1345
1341
  this.onChangeTrackStateRequestListener
@@ -1360,11 +1356,12 @@ export class HMSSDK {
1360
1356
  ]
1361
1357
  ) {
1362
1358
  // Adding ON_REMOVED_FROM_ROOM native listener
1363
- const removedFromRoomSubscription = HmsEventEmitter.addListener(
1364
- this.id,
1365
- HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM,
1366
- this.onRemovedFromRoomListener
1367
- );
1359
+ const removedFromRoomSubscription =
1360
+ HMSNativeEventListener.addListener(
1361
+ this.id,
1362
+ HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM,
1363
+ this.onRemovedFromRoomListener
1364
+ );
1368
1365
  this.emitterSubscriptions[
1369
1366
  HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM
1370
1367
  ] = removedFromRoomSubscription;
@@ -1377,7 +1374,7 @@ export class HMSSDK {
1377
1374
  // Checking if we already have ON_RTC_STATS subscription
1378
1375
  if (!this.emitterSubscriptions[HMSUpdateListenerActions.ON_RTC_STATS]) {
1379
1376
  // Adding ON_RTC_STATS native listener
1380
- const rtcStatsSubscription = HmsEventEmitter.addListener(
1377
+ const rtcStatsSubscription = HMSNativeEventListener.addListener(
1381
1378
  this.id,
1382
1379
  HMSUpdateListenerActions.ON_RTC_STATS,
1383
1380
  this.RTCStatsListener
@@ -1397,7 +1394,7 @@ export class HMSSDK {
1397
1394
  ]
1398
1395
  ) {
1399
1396
  // Adding ON_LOCAL_AUDIO_STATS native listener
1400
- const lclAudioStatsSubscription = HmsEventEmitter.addListener(
1397
+ const lclAudioStatsSubscription = HMSNativeEventListener.addListener(
1401
1398
  this.id,
1402
1399
  HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS,
1403
1400
  this.onLocalAudioStatsListener
@@ -1418,7 +1415,7 @@ export class HMSSDK {
1418
1415
  ]
1419
1416
  ) {
1420
1417
  // Adding ON_LOCAL_VIDEO_STATS native listener
1421
- const lclVideoStatsSubscription = HmsEventEmitter.addListener(
1418
+ const lclVideoStatsSubscription = HMSNativeEventListener.addListener(
1422
1419
  this.id,
1423
1420
  HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS,
1424
1421
  this.onLocalVideoStatsListener
@@ -1439,7 +1436,7 @@ export class HMSSDK {
1439
1436
  ]
1440
1437
  ) {
1441
1438
  // Adding ON_REMOTE_AUDIO_STATS native listener
1442
- const rmAudioStatsSubscription = HmsEventEmitter.addListener(
1439
+ const rmAudioStatsSubscription = HMSNativeEventListener.addListener(
1443
1440
  this.id,
1444
1441
  HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS,
1445
1442
  this.onRemoteAudioStatsListener
@@ -1460,7 +1457,7 @@ export class HMSSDK {
1460
1457
  ]
1461
1458
  ) {
1462
1459
  // Adding ON_REMOTE_VIDEO_STATS native listener
1463
- const rmVideoStatsSubscription = HmsEventEmitter.addListener(
1460
+ const rmVideoStatsSubscription = HMSNativeEventListener.addListener(
1464
1461
  this.id,
1465
1462
  HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS,
1466
1463
  this.onRemoteVideoStatsListener
@@ -1481,7 +1478,7 @@ export class HMSSDK {
1481
1478
  ]
1482
1479
  ) {
1483
1480
  // Adding ON_AUDIO_DEVICE_CHANGED native listener
1484
- const audDeviceChgSubscription = HmsEventEmitter.addListener(
1481
+ const audDeviceChgSubscription = HMSNativeEventListener.addListener(
1485
1482
  this.id,
1486
1483
  HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED,
1487
1484
  this.onAudioDeviceChangedListener
@@ -1502,11 +1499,12 @@ export class HMSSDK {
1502
1499
  ]
1503
1500
  ) {
1504
1501
  // Adding ON_SESSION_STORE_AVAILABLE native listener
1505
- const sessionStoreAvailableSubscription = HmsEventEmitter.addListener(
1506
- this.id,
1507
- HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE,
1508
- this.onSessionStoreAvailableListener
1509
- );
1502
+ const sessionStoreAvailableSubscription =
1503
+ HMSNativeEventListener.addListener(
1504
+ this.id,
1505
+ HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE,
1506
+ this.onSessionStoreAvailableListener
1507
+ );
1510
1508
  this.emitterSubscriptions[
1511
1509
  HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE
1512
1510
  ] = sessionStoreAvailableSubscription;
@@ -1522,7 +1520,7 @@ export class HMSSDK {
1522
1520
  !this.emitterSubscriptions[HMSPIPListenerActions.ON_PIP_ROOM_LEAVE]
1523
1521
  ) {
1524
1522
  // Adding ON_PIP_ROOM_LEAVE native listener
1525
- const pipRoomLeaveSubscription = HmsEventEmitter.addListener(
1523
+ const pipRoomLeaveSubscription = HMSNativeEventListener.addListener(
1526
1524
  this.id,
1527
1525
  HMSPIPListenerActions.ON_PIP_ROOM_LEAVE,
1528
1526
  this.onPIPRoomLeaveListener
@@ -1,16 +1,14 @@
1
- import {
2
- NativeModules,
3
- DeviceEventEmitter,
4
- EmitterSubscription as RNEmitterSubscription,
5
- } from 'react-native';
1
+ import { DeviceEventEmitter } from 'react-native';
2
+ import type { EmitterSubscription as RNEmitterSubscription } from 'react-native';
3
+
4
+ import HMSManager from './HMSManagerModule';
5
+
6
6
  import { HMSConstants } from './HMSConstants';
7
7
  import { getLogger } from './HMSLogger';
8
8
  import { HMSUpdateListenerActions } from './HMSUpdateListenerActions';
9
9
  import { EventEmitter } from '../utils';
10
10
  import type { EmitterSubscription } from '../utils';
11
11
 
12
- const { HMSManager } = NativeModules;
13
-
14
12
  type Nullable<T> = T | null | undefined;
15
13
 
16
14
  export type HMSSessionStoreValue = Nullable<string>;
@@ -148,7 +146,7 @@ export class HMSSessionStore {
148
146
  // this `uniqueId` will be used to remove 'KeyChangeListener' from native side
149
147
  const uniqueId =
150
148
  subscriptionsToRemove.length > 0
151
- ? (subscriptionsToRemove[0].context as { uniqueId: string }).uniqueId
149
+ ? (subscriptionsToRemove[0]!.context as { uniqueId: string }).uniqueId
152
150
  : null;
153
151
 
154
152
  // Removing required subscriptions from 'eventEmitter'
@@ -1,8 +1,9 @@
1
+ import type { HMSTrackSource } from './HMSTrackSource';
1
2
  import type { HMSTrackType } from './HMSTrackType';
2
3
 
3
4
  export class HMSTrack {
4
5
  trackId: string;
5
- source?: number | string;
6
+ source?: HMSTrackSource;
6
7
  trackDescription?: string;
7
8
  mute?: boolean;
8
9
  id: string;
@@ -14,7 +15,7 @@ export class HMSTrack {
14
15
 
15
16
  constructor(params: {
16
17
  trackId: string;
17
- source?: number | string;
18
+ source?: HMSTrackSource;
18
19
  trackDescription?: string;
19
20
  isMute?: boolean;
20
21
  id: string;
@@ -1,4 +1,5 @@
1
1
  import { HMSTrack } from './HMSTrack';
2
+ import type { HMSTrackSource } from './HMSTrackSource';
2
3
  import type { HMSTrackType } from './HMSTrackType';
3
4
 
4
5
  export class HMSVideoTrack extends HMSTrack {
@@ -6,7 +7,7 @@ export class HMSVideoTrack extends HMSTrack {
6
7
 
7
8
  constructor(params: {
8
9
  trackId: string;
9
- source?: number | string;
10
+ source?: HMSTrackSource;
10
11
  trackDescription?: string;
11
12
  isMute?: boolean;
12
13
  id: string;
@@ -4,9 +4,9 @@ import {
4
4
  requireNativeComponent,
5
5
  StyleSheet,
6
6
  UIManager,
7
- ViewStyle,
8
7
  Platform,
9
8
  } from 'react-native';
9
+ import type { ViewStyle } from 'react-native';
10
10
  import { HMSConstants } from './HMSConstants';
11
11
  import { HMSVideoViewMode } from './HMSVideoViewMode';
12
12
 
@@ -89,6 +89,12 @@ export const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(
89
89
  };
90
90
 
91
91
  const capture = async () => {
92
+ const viewManagerConfig = UIManager.getViewManagerConfig('HMSView');
93
+
94
+ if (!viewManagerConfig.Commands.capture) {
95
+ return Promise.reject('Capture command not available on HMSView');
96
+ }
97
+
92
98
  let requestId = _nextRequestId++;
93
99
  let requestMap = _requestMap;
94
100
 
@@ -97,7 +103,7 @@ export const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(
97
103
  let promise = new Promise(function (resolve, reject) {
98
104
  requestMap.set(requestId, { resolve, reject });
99
105
  });
100
- const viewManagerConfig = UIManager.getViewManagerConfig('HMSView');
106
+
101
107
  UIManager.dispatchViewManagerCommand(
102
108
  findNodeHandle(hmsViewRef.current),
103
109
  viewManagerConfig.Commands.capture,
@@ -10,11 +10,13 @@ import {
10
10
  setHMSHLSPlayerStatsError,
11
11
  } from './hooks';
12
12
  import {
13
+ RCTHMSHLSPlayer,
14
+ RCTHMSHLSPlayerViewManagerConfig,
15
+ } from './RCTHMSHLSPlayer';
16
+ import type {
13
17
  HmsHlsPlaybackEventHandler,
14
18
  HmsHlsStatsEventHandler,
15
- RCTHMSHLSPlayer,
16
19
  RCTHMSHLSPlayerRef,
17
- RCTHMSHLSPlayerViewManagerConfig,
18
20
  } from './RCTHMSHLSPlayer';
19
21
  import {
20
22
  HMSHLSPlayerPlaybackEventTypes,
@@ -64,7 +66,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
64
66
  ref,
65
67
  () => ({
66
68
  play: (url?: string) => {
67
- if (hmsHlsPlayerRef.current) {
69
+ if (
70
+ hmsHlsPlayerRef.current &&
71
+ RCTHMSHLSPlayerViewManagerConfig.Commands.play
72
+ ) {
68
73
  UIManager.dispatchViewManagerCommand(
69
74
  findNodeHandle(hmsHlsPlayerRef.current),
70
75
  RCTHMSHLSPlayerViewManagerConfig.Commands.play,
@@ -73,7 +78,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
73
78
  }
74
79
  },
75
80
  stop: () => {
76
- if (hmsHlsPlayerRef.current) {
81
+ if (
82
+ hmsHlsPlayerRef.current &&
83
+ RCTHMSHLSPlayerViewManagerConfig.Commands.stop
84
+ ) {
77
85
  UIManager.dispatchViewManagerCommand(
78
86
  findNodeHandle(hmsHlsPlayerRef.current),
79
87
  RCTHMSHLSPlayerViewManagerConfig.Commands.stop,
@@ -82,7 +90,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
82
90
  }
83
91
  },
84
92
  pause: () => {
85
- if (hmsHlsPlayerRef.current) {
93
+ if (
94
+ hmsHlsPlayerRef.current &&
95
+ RCTHMSHLSPlayerViewManagerConfig.Commands.pause
96
+ ) {
86
97
  UIManager.dispatchViewManagerCommand(
87
98
  findNodeHandle(hmsHlsPlayerRef.current),
88
99
  RCTHMSHLSPlayerViewManagerConfig.Commands.pause,
@@ -91,7 +102,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
91
102
  }
92
103
  },
93
104
  resume: () => {
94
- if (hmsHlsPlayerRef.current) {
105
+ if (
106
+ hmsHlsPlayerRef.current &&
107
+ RCTHMSHLSPlayerViewManagerConfig.Commands.resume
108
+ ) {
95
109
  UIManager.dispatchViewManagerCommand(
96
110
  findNodeHandle(hmsHlsPlayerRef.current),
97
111
  RCTHMSHLSPlayerViewManagerConfig.Commands.resume,
@@ -108,7 +122,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
108
122
  );
109
123
  }
110
124
 
111
- if (hmsHlsPlayerRef.current) {
125
+ if (
126
+ hmsHlsPlayerRef.current &&
127
+ RCTHMSHLSPlayerViewManagerConfig.Commands.seekForward
128
+ ) {
112
129
  UIManager.dispatchViewManagerCommand(
113
130
  findNodeHandle(hmsHlsPlayerRef.current),
114
131
  RCTHMSHLSPlayerViewManagerConfig.Commands.seekForward,
@@ -125,7 +142,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
125
142
  );
126
143
  }
127
144
 
128
- if (hmsHlsPlayerRef.current) {
145
+ if (
146
+ hmsHlsPlayerRef.current &&
147
+ RCTHMSHLSPlayerViewManagerConfig.Commands.seekBackward
148
+ ) {
129
149
  UIManager.dispatchViewManagerCommand(
130
150
  findNodeHandle(hmsHlsPlayerRef.current),
131
151
  RCTHMSHLSPlayerViewManagerConfig.Commands.seekBackward,
@@ -134,7 +154,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
134
154
  }
135
155
  },
136
156
  seekToLivePosition: () => {
137
- if (hmsHlsPlayerRef.current) {
157
+ if (
158
+ hmsHlsPlayerRef.current &&
159
+ RCTHMSHLSPlayerViewManagerConfig.Commands.seekToLivePosition
160
+ ) {
138
161
  UIManager.dispatchViewManagerCommand(
139
162
  findNodeHandle(hmsHlsPlayerRef.current),
140
163
  RCTHMSHLSPlayerViewManagerConfig.Commands.seekToLivePosition,
@@ -149,7 +172,10 @@ const _HMSHLSPlayer: React.ForwardRefRenderFunction<
149
172
  );
150
173
  }
151
174
 
152
- if (hmsHlsPlayerRef.current) {
175
+ if (
176
+ hmsHlsPlayerRef.current &&
177
+ RCTHMSHLSPlayerViewManagerConfig.Commands.setVolume
178
+ ) {
153
179
  UIManager.dispatchViewManagerCommand(
154
180
  findNodeHandle(hmsHlsPlayerRef.current),
155
181
  RCTHMSHLSPlayerViewManagerConfig.Commands.setVolume,
@@ -1,9 +1,8 @@
1
- import {
2
- requireNativeComponent,
1
+ import { requireNativeComponent, UIManager } from 'react-native';
2
+ import type {
3
3
  StyleProp,
4
4
  NativeSyntheticEvent,
5
5
  ViewStyle,
6
- UIManager,
7
6
  NativeMethods,
8
7
  } from 'react-native';
9
8
  import type {
@@ -1,4 +1,5 @@
1
- import { DependencyList, useEffect } from 'react';
1
+ import { useEffect } from 'react';
2
+ import type { DependencyList } from 'react';
2
3
  import { shallow } from 'zustand/shallow';
3
4
 
4
5
  import { useHMSHLSPlayerStatsStore } from '../../stores/hls-player-stats-store';
@@ -27,7 +28,7 @@ export const useHMSHLSPlayerStats = () => {
27
28
  };
28
29
 
29
30
  export const useHMSHLSPlayerStat = <
30
- T extends keyof HMSHLSPlayerStatsUpdateEventData
31
+ T extends keyof HMSHLSPlayerStatsUpdateEventData,
31
32
  >(
32
33
  stat: T
33
34
  ) => {
@@ -0,0 +1,85 @@
1
+ import * as React from 'react';
2
+
3
+ import { HMSConstants } from '../classes/HMSConstants';
4
+ import { HMSEncoder } from '../classes/HMSEncoder';
5
+ import { HMSEventEmitter } from '../classes/HMSEventEmitter';
6
+ import { getLogger } from '../classes/HMSLogger';
7
+ import HMSNativeEventListener from '../classes/HMSNativeEventListener';
8
+ import type { HMSNativeEventSubscription } from '../classes/HMSNativeEventListener';
9
+ import type { HMSPeer } from '../classes/HMSPeer';
10
+ import { HMSPeerUpdate, HMSPeerUpdateOrdinals } from '../classes/HMSPeerUpdate';
11
+ import { getHmsPeersCache } from '../classes/HMSPeersCache';
12
+ import { HMSUpdateListenerActions } from '../classes/HMSUpdateListenerActions';
13
+
14
+ const eventType = HMSUpdateListenerActions.ON_PEER_UPDATE;
15
+
16
+ // TODO: How to handle events which have already been received?
17
+ // TODO(DOUBT): add HMSInstance as dependency because of actions enabling/disabling events on HMSInstance?
18
+ export const useHMSPeerUpdates = (
19
+ effect: (data: { peer: HMSPeer; type: HMSPeerUpdate }) => void,
20
+ deps: React.DependencyList | undefined = []
21
+ ) => {
22
+ React.useEffect(() => {
23
+ if (HMSEventEmitter.listenerCount(eventType) <= 0) {
24
+ addPeerUpdateSubscription();
25
+ }
26
+
27
+ const subscription = HMSEventEmitter.addListener(eventType, effect, null);
28
+
29
+ return () => {
30
+ subscription.remove();
31
+
32
+ if (HMSEventEmitter.listenerCount(eventType) <= 0) {
33
+ removePeerUpdateSubscription();
34
+ }
35
+ };
36
+ }, deps);
37
+ };
38
+
39
+ let peerUpdateSubscription: HMSNativeEventSubscription | null = null;
40
+
41
+ function addPeerUpdateSubscription() {
42
+ if (peerUpdateSubscription !== null) {
43
+ return;
44
+ }
45
+
46
+ peerUpdateSubscription = HMSNativeEventListener.addListener(
47
+ HMSConstants.DEFAULT_SDK_ID,
48
+ HMSUpdateListenerActions.ON_PEER_UPDATE,
49
+ (peerData: any) => {
50
+ const data: { peer: any; type: any } = {
51
+ peer: peerData,
52
+ type: null,
53
+ };
54
+
55
+ for (const ordinal of HMSPeerUpdateOrdinals.keys()) {
56
+ if (ordinal in peerData) {
57
+ data.peer.peerID = peerData[ordinal];
58
+ data.type = ordinal;
59
+ break;
60
+ }
61
+ }
62
+
63
+ const peer: HMSPeer = HMSEncoder.encodeHmsPeer(data.peer);
64
+ const type = HMSEncoder.encodeHmsPeerUpdate(data.type) || data.type;
65
+
66
+ getHmsPeersCache()?.updatePeerCache(data.peer.peerID, data.peer, type);
67
+
68
+ getLogger()?.verbose('#Listener ON_PEER_LISTENER_CALL', {
69
+ peer,
70
+ type,
71
+ });
72
+
73
+ HMSEventEmitter.emit(eventType, { peer, type });
74
+ }
75
+ );
76
+ }
77
+
78
+ function removePeerUpdateSubscription() {
79
+ if (peerUpdateSubscription === null) {
80
+ return;
81
+ }
82
+
83
+ peerUpdateSubscription.remove();
84
+ peerUpdateSubscription = null;
85
+ }
package/src/index.ts CHANGED
@@ -89,9 +89,15 @@ export type { HmsViewComponent as HMSView } from './classes/HmsView';
89
89
 
90
90
  import { HMSSDK as HmsManager } from './classes/HMSSDK';
91
91
 
92
+ // 100ms React Native Native Module
93
+ export { default as HMSManagerModule } from './classes/HMSManagerModule';
94
+
92
95
  // 100ms Components
93
96
  export * from './components/HMSHLSPlayer';
94
97
 
98
+ // 100ms Hooks
99
+ export * from './hooks/useHMSPeerUpdates';
100
+
95
101
  // 100ms types
96
102
  export * from './types';
97
103
  export * from './stores/types';
@@ -1,8 +0,0 @@
1
- ## This file must *NOT* be checked into Version Control Systems,
2
- # as it contains information specific to your local configuration.
3
- #
4
- # Location of the SDK. This is only used by Gradle.
5
- # For customization when using a Version Control System, please read the
6
- # header note.
7
- #Tue Mar 01 18:12:03 IST 2022
8
- sdk.dir=/Users/yogesh/Library/Android/sdk
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- <FileRef
5
- location = "self:">
6
- </FileRef>
7
- </Workspace>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>IDEDidComputeMac32BitWarning</key>
6
- <true/>
7
- </dict>
8
- </plist>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>Hmssdk.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>0</integer>
11
- </dict>
12
- </dict>
13
- </dict>
14
- </plist>