@100mslive/react-native-hms 0.8.3 → 0.9.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 (186) hide show
  1. package/README.md +16 -8
  2. package/android/.gradle/6.9/executionHistory/executionHistory.lock +0 -0
  3. package/android/.gradle/6.9/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  5. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  6. package/android/.gradle/checksums/checksums.lock +0 -0
  7. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  8. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  9. package/android/.idea/gradle.xml +13 -0
  10. package/android/.idea/misc.xml +9 -0
  11. package/android/.idea/modules/android.iml +18 -0
  12. package/android/.idea/modules.xml +8 -0
  13. package/android/.idea/sonarlint/issuestore/f/0/f07866736216be0ee2aba49e392191aeae700a35 +0 -0
  14. package/android/.idea/sonarlint/issuestore/index.pb +3 -0
  15. package/android/.idea/vcs.xml +6 -0
  16. package/android/build.gradle +4 -2
  17. package/android/local.properties +8 -0
  18. package/android/src/main/java/com/reactnativehmssdk/HmsDecoder.kt +58 -5
  19. package/android/src/main/java/com/reactnativehmssdk/HmsHelper.kt +76 -61
  20. package/android/src/main/java/com/reactnativehmssdk/HmsModule.kt +99 -8
  21. package/android/src/main/java/com/reactnativehmssdk/HmsSDK.kt +299 -128
  22. package/android/src/main/java/com/reactnativehmssdk/HmsScreenshareActivity.kt +66 -0
  23. package/android/src/main/java/com/reactnativehmssdk/HmsView.kt +28 -3
  24. package/android/src/main/java/com/reactnativehmssdk/HmssdkViewManager.kt +10 -1
  25. package/android/src/main/res/layout/hms_view.xml +19 -0
  26. package/ios/HmsDecoder.swift +217 -123
  27. package/ios/HmsHelper.swift +56 -38
  28. package/ios/HmsManager.m +11 -3
  29. package/ios/HmsManager.swift +125 -68
  30. package/ios/HmsSDK.swift +407 -189
  31. package/ios/HmsView.swift +50 -68
  32. package/ios/VideoCollectionViewCell.swift +4 -4
  33. package/lib/commonjs/classes/HMSBrowserRecordingState.js +6 -0
  34. package/lib/commonjs/classes/HMSBrowserRecordingState.js.map +1 -1
  35. package/lib/commonjs/classes/HMSChangeTrackStateRequest.js +3 -0
  36. package/lib/commonjs/classes/HMSChangeTrackStateRequest.js.map +1 -1
  37. package/lib/commonjs/classes/HMSEncoder.js +166 -4
  38. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  39. package/lib/commonjs/classes/HMSHLSConfig.js +20 -0
  40. package/lib/commonjs/classes/HMSHLSConfig.js.map +1 -0
  41. package/lib/commonjs/classes/HMSHLSMeetingURLVariant.js +23 -0
  42. package/lib/commonjs/classes/HMSHLSMeetingURLVariant.js.map +1 -0
  43. package/lib/commonjs/classes/HMSHLSStreamingState.js +23 -0
  44. package/lib/commonjs/classes/HMSHLSStreamingState.js.map +1 -0
  45. package/lib/commonjs/classes/HMSHLSVariant.js +29 -0
  46. package/lib/commonjs/classes/HMSHLSVariant.js.map +1 -0
  47. package/lib/commonjs/classes/HMSLocalAudioStats.js +26 -0
  48. package/lib/commonjs/classes/HMSLocalAudioStats.js.map +1 -0
  49. package/lib/commonjs/classes/HMSLocalVideoStats.js +32 -0
  50. package/lib/commonjs/classes/HMSLocalVideoStats.js.map +1 -0
  51. package/lib/commonjs/classes/HMSLogger.js +27 -0
  52. package/lib/commonjs/classes/HMSLogger.js.map +1 -1
  53. package/lib/commonjs/classes/HMSPeerUpdate.js +2 -0
  54. package/lib/commonjs/classes/HMSPeerUpdate.js.map +1 -1
  55. package/lib/commonjs/classes/HMSPermissions.js +2 -2
  56. package/lib/commonjs/classes/HMSPermissions.js.map +1 -1
  57. package/lib/commonjs/classes/HMSRTCStats.js +38 -0
  58. package/lib/commonjs/classes/HMSRTCStats.js.map +1 -0
  59. package/lib/commonjs/classes/HMSRTCStatsReport.js +26 -0
  60. package/lib/commonjs/classes/HMSRTCStatsReport.js.map +1 -0
  61. package/lib/commonjs/classes/HMSRemoteAudioStats.js +32 -0
  62. package/lib/commonjs/classes/HMSRemoteAudioStats.js.map +1 -0
  63. package/lib/commonjs/classes/HMSRemoteVideoStats.js +38 -0
  64. package/lib/commonjs/classes/HMSRemoteVideoStats.js.map +1 -0
  65. package/lib/commonjs/classes/HMSRoom.js +6 -0
  66. package/lib/commonjs/classes/HMSRoom.js.map +1 -1
  67. package/lib/commonjs/classes/HMSRoomUpdate.js +7 -0
  68. package/lib/commonjs/classes/HMSRoomUpdate.js.map +1 -1
  69. package/lib/commonjs/classes/HMSRtmpStreamingState.js +6 -0
  70. package/lib/commonjs/classes/HMSRtmpStreamingState.js.map +1 -1
  71. package/lib/commonjs/classes/HMSSDK.js +476 -115
  72. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  73. package/lib/commonjs/classes/HMSServerRecordingState.js +3 -0
  74. package/lib/commonjs/classes/HMSServerRecordingState.js.map +1 -1
  75. package/lib/commonjs/classes/HMSUpdateListenerActions.js +5 -0
  76. package/lib/commonjs/classes/HMSUpdateListenerActions.js.map +1 -1
  77. package/lib/commonjs/classes/HmsView.js +26 -4
  78. package/lib/commonjs/classes/HmsView.js.map +1 -1
  79. package/lib/commonjs/index.js +140 -0
  80. package/lib/commonjs/index.js.map +1 -1
  81. package/lib/module/classes/HMSBrowserRecordingState.js +6 -0
  82. package/lib/module/classes/HMSBrowserRecordingState.js.map +1 -1
  83. package/lib/module/classes/HMSChangeTrackStateRequest.js +3 -0
  84. package/lib/module/classes/HMSChangeTrackStateRequest.js.map +1 -1
  85. package/lib/module/classes/HMSEncoder.js +159 -4
  86. package/lib/module/classes/HMSEncoder.js.map +1 -1
  87. package/lib/module/classes/HMSHLSConfig.js +11 -0
  88. package/lib/module/classes/HMSHLSConfig.js.map +1 -0
  89. package/lib/module/classes/HMSHLSMeetingURLVariant.js +14 -0
  90. package/lib/module/classes/HMSHLSMeetingURLVariant.js.map +1 -0
  91. package/lib/module/classes/HMSHLSStreamingState.js +14 -0
  92. package/lib/module/classes/HMSHLSStreamingState.js.map +1 -0
  93. package/lib/module/classes/HMSHLSVariant.js +20 -0
  94. package/lib/module/classes/HMSHLSVariant.js.map +1 -0
  95. package/lib/module/classes/HMSLocalAudioStats.js +17 -0
  96. package/lib/module/classes/HMSLocalAudioStats.js.map +1 -0
  97. package/lib/module/classes/HMSLocalVideoStats.js +23 -0
  98. package/lib/module/classes/HMSLocalVideoStats.js.map +1 -0
  99. package/lib/module/classes/HMSLogger.js +27 -0
  100. package/lib/module/classes/HMSLogger.js.map +1 -1
  101. package/lib/module/classes/HMSPeerUpdate.js +2 -0
  102. package/lib/module/classes/HMSPeerUpdate.js.map +1 -1
  103. package/lib/module/classes/HMSPermissions.js +2 -2
  104. package/lib/module/classes/HMSPermissions.js.map +1 -1
  105. package/lib/module/classes/HMSRTCStats.js +29 -0
  106. package/lib/module/classes/HMSRTCStats.js.map +1 -0
  107. package/lib/module/classes/HMSRTCStatsReport.js +17 -0
  108. package/lib/module/classes/HMSRTCStatsReport.js.map +1 -0
  109. package/lib/module/classes/HMSRemoteAudioStats.js +23 -0
  110. package/lib/module/classes/HMSRemoteAudioStats.js.map +1 -0
  111. package/lib/module/classes/HMSRemoteVideoStats.js +29 -0
  112. package/lib/module/classes/HMSRemoteVideoStats.js.map +1 -0
  113. package/lib/module/classes/HMSRoom.js +6 -0
  114. package/lib/module/classes/HMSRoom.js.map +1 -1
  115. package/lib/module/classes/HMSRoomUpdate.js +7 -0
  116. package/lib/module/classes/HMSRoomUpdate.js.map +1 -1
  117. package/lib/module/classes/HMSRtmpStreamingState.js +6 -0
  118. package/lib/module/classes/HMSRtmpStreamingState.js.map +1 -1
  119. package/lib/module/classes/HMSSDK.js +464 -116
  120. package/lib/module/classes/HMSSDK.js.map +1 -1
  121. package/lib/module/classes/HMSServerRecordingState.js +3 -0
  122. package/lib/module/classes/HMSServerRecordingState.js.map +1 -1
  123. package/lib/module/classes/HMSUpdateListenerActions.js +5 -0
  124. package/lib/module/classes/HMSUpdateListenerActions.js.map +1 -1
  125. package/lib/module/classes/HmsView.js +23 -4
  126. package/lib/module/classes/HmsView.js.map +1 -1
  127. package/lib/module/index.js +10 -0
  128. package/lib/module/index.js.map +1 -1
  129. package/lib/typescript/classes/HMSBrowserRecordingState.d.ts +4 -0
  130. package/lib/typescript/classes/HMSChangeTrackStateRequest.d.ts +2 -0
  131. package/lib/typescript/classes/HMSEncoder.d.ts +21 -0
  132. package/lib/typescript/classes/HMSHLSConfig.d.ts +7 -0
  133. package/lib/typescript/classes/HMSHLSMeetingURLVariant.d.ts +8 -0
  134. package/lib/typescript/classes/HMSHLSStreamingState.d.ts +9 -0
  135. package/lib/typescript/classes/HMSHLSVariant.d.ts +12 -0
  136. package/lib/typescript/classes/HMSLocalAudioStats.d.ts +10 -0
  137. package/lib/typescript/classes/HMSLocalVideoStats.d.ts +15 -0
  138. package/lib/typescript/classes/HMSLogger.d.ts +2 -0
  139. package/lib/typescript/classes/HMSPeerUpdate.d.ts +3 -1
  140. package/lib/typescript/classes/HMSPermissions.d.ts +2 -2
  141. package/lib/typescript/classes/HMSRTCStats.d.ts +18 -0
  142. package/lib/typescript/classes/HMSRTCStatsReport.d.ts +11 -0
  143. package/lib/typescript/classes/HMSRemoteAudioStats.d.ts +14 -0
  144. package/lib/typescript/classes/HMSRemoteVideoStats.d.ts +19 -0
  145. package/lib/typescript/classes/HMSRoom.d.ts +5 -0
  146. package/lib/typescript/classes/HMSRoomUpdate.d.ts +8 -1
  147. package/lib/typescript/classes/HMSRtmpStreamingState.d.ts +4 -0
  148. package/lib/typescript/classes/HMSSDK.d.ts +33 -9
  149. package/lib/typescript/classes/HMSServerRecordingState.d.ts +2 -0
  150. package/lib/typescript/classes/HMSUpdateListenerActions.d.ts +6 -1
  151. package/lib/typescript/index.d.ts +10 -0
  152. package/package.json +1 -1
  153. package/react-native-hms.podspec +1 -1
  154. package/src/classes/HMSBrowserRecordingState.ts +10 -1
  155. package/src/classes/HMSChangeTrackStateRequest.ts +7 -1
  156. package/src/classes/HMSEncoder.ts +163 -3
  157. package/src/classes/HMSHLSConfig.ts +9 -0
  158. package/src/classes/HMSHLSMeetingURLVariant.ts +9 -0
  159. package/src/classes/HMSHLSStreamingState.ts +11 -0
  160. package/src/classes/HMSHLSVariant.ts +18 -0
  161. package/src/classes/HMSLocalAudioStats.ts +15 -0
  162. package/src/classes/HMSLocalVideoStats.ts +23 -0
  163. package/src/classes/HMSLogger.ts +14 -0
  164. package/src/classes/HMSPeerUpdate.ts +2 -0
  165. package/src/classes/HMSPermissions.ts +3 -3
  166. package/src/classes/HMSRTCStats.ts +27 -0
  167. package/src/classes/HMSRTCStatsReport.ts +17 -0
  168. package/src/classes/HMSRemoteAudioStats.ts +21 -0
  169. package/src/classes/HMSRemoteVideoStats.ts +29 -0
  170. package/src/classes/HMSRoom.ts +7 -0
  171. package/src/classes/HMSRoomUpdate.ts +7 -0
  172. package/src/classes/HMSRtmpStreamingState.ts +10 -1
  173. package/src/classes/HMSSDK.tsx +325 -26
  174. package/src/classes/HMSServerRecordingState.ts +7 -1
  175. package/src/classes/HMSUpdateListenerActions.ts +5 -0
  176. package/src/classes/HmsView.tsx +32 -4
  177. package/src/index.ts +10 -0
  178. package/android/.gradle/6.9/executionHistory/executionHistory.bin +0 -0
  179. package/android/.gradle/6.9/fileHashes/fileHashes.bin +0 -0
  180. package/android/.gradle/6.9/fileHashes/resourceHashesCache.bin +0 -0
  181. package/android/.gradle/6.9/javaCompile/classAnalysis.bin +0 -0
  182. package/android/.gradle/6.9/javaCompile/jarAnalysis.bin +0 -0
  183. package/android/.gradle/6.9/javaCompile/javaCompile.lock +0 -0
  184. package/android/.gradle/6.9/javaCompile/taskHistory.bin +0 -0
  185. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  186. package/android/.project +0 -34
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
- import { NativeEventEmitter, NativeModules, ViewStyle } from 'react-native';
2
+ import {
3
+ NativeEventEmitter,
4
+ NativeModules,
5
+ Platform,
6
+ ViewStyle,
7
+ AppState,
8
+ } from 'react-native';
3
9
  import { HMSUpdateListenerActions } from './HMSUpdateListenerActions';
4
10
  import type { HMSConfig } from './HMSConfig';
5
11
  import type { HMSLocalPeer } from './HMSLocalPeer';
@@ -17,6 +23,11 @@ import { HmsView as HMSViewComponent } from './HmsView';
17
23
  import { HMSVideoViewMode } from './HMSVideoViewMode';
18
24
  import type { HMSTrackSettings } from './HMSTrackSettings';
19
25
  import type { HMSRTMPConfig } from './HMSRTMPConfig';
26
+ import type { HMSHLSConfig } from './HMSHLSConfig';
27
+ import { HMSLocalAudioStats } from './HMSLocalAudioStats';
28
+ import { HMSLocalVideoStats } from './HMSLocalVideoStats';
29
+ import { HMSRemoteVideoStats } from './HMSRemoteVideoStats';
30
+ import { HMSRemoteAudioStats } from './HMSRemoteAudioStats';
20
31
 
21
32
  interface HmsComponentProps {
22
33
  trackId: string;
@@ -47,6 +58,7 @@ export class HMSSDK {
47
58
  knownRoles?: HMSRole[];
48
59
  id: string;
49
60
  private muteStatus: boolean | undefined;
61
+ appStateSubscription?: any;
50
62
 
51
63
  onPreviewDelegate?: any;
52
64
  onJoinDelegate?: any;
@@ -61,6 +73,11 @@ export class HMSSDK {
61
73
  onRoleChangeRequestDelegate?: any;
62
74
  onChangeTrackStateRequestDelegate?: any;
63
75
  onRemovedFromRoomDelegate?: any;
76
+ onRtcStatsDelegate?: any;
77
+ onLocalAudioStatsDelegate?: any;
78
+ onLocalVideoStatsDelegate?: any;
79
+ onRemoteAudioStatsDelegate?: any;
80
+ onRemoteVideoStatsDelegate?: any;
64
81
 
65
82
  constructor(id: string) {
66
83
  this.id = id;
@@ -74,7 +91,7 @@ export class HMSSDK {
74
91
  * @returns
75
92
  * @memberof HMSSDK
76
93
  */
77
- static async build(params?: { trackSettings?: HMSTrackSettings }) {
94
+ static async build(params?: { trackSettings: HMSTrackSettings }) {
78
95
  let id = await HmsManager.build(params?.trackSettings || {});
79
96
  HmsSdk = new HMSSDK(id);
80
97
  HmsSdk.attachPreviewListener();
@@ -162,6 +179,31 @@ export class HMSSDK {
162
179
  HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM,
163
180
  this.onRemovedFromRoomListener
164
181
  );
182
+
183
+ HmsEventEmitter.addListener(
184
+ HMSUpdateListenerActions.ON_RTC_STATS,
185
+ this.RTCStatsListener
186
+ );
187
+
188
+ HmsEventEmitter.addListener(
189
+ HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS,
190
+ this.onLocalAudioStatsListener
191
+ );
192
+
193
+ HmsEventEmitter.addListener(
194
+ HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS,
195
+ this.onLocalVideoStatsListener
196
+ );
197
+
198
+ HmsEventEmitter.addListener(
199
+ HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS,
200
+ this.onRemoteAudioStatsListener
201
+ );
202
+
203
+ HmsEventEmitter.addListener(
204
+ HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS,
205
+ this.onRemoteVideoStatsListener
206
+ );
165
207
  };
166
208
 
167
209
  removeListeners = () => {
@@ -224,6 +266,31 @@ export class HMSSDK {
224
266
  HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM,
225
267
  this.onRemovedFromRoomListener
226
268
  );
269
+
270
+ HmsEventEmitter.removeListener(
271
+ HMSUpdateListenerActions.ON_RTC_STATS,
272
+ this.RTCStatsListener
273
+ );
274
+
275
+ HmsEventEmitter.removeListener(
276
+ HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS,
277
+ this.onLocalAudioStatsListener
278
+ );
279
+
280
+ HmsEventEmitter.removeListener(
281
+ HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS,
282
+ this.onLocalVideoStatsListener
283
+ );
284
+
285
+ HmsEventEmitter.removeListener(
286
+ HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS,
287
+ this.onRemoteAudioStatsListener
288
+ );
289
+
290
+ HmsEventEmitter.removeListener(
291
+ HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS,
292
+ this.onRemoteVideoStatsListener
293
+ );
227
294
  };
228
295
 
229
296
  /**
@@ -235,6 +302,7 @@ export class HMSSDK {
235
302
  */
236
303
  join = async (config: HMSConfig) => {
237
304
  logger?.verbose('#Function join', { config, id: this.id });
305
+ this.addAppStateListener();
238
306
  await HmsManager.join({ ...config, id: this.id });
239
307
  };
240
308
 
@@ -243,6 +311,19 @@ export class HMSSDK {
243
311
  HmsManager.preview({ ...config, id: this.id });
244
312
  };
245
313
 
314
+ previewForRole = async (role: HMSRole) => {
315
+ logger?.verbose('#Function previewForRole', {
316
+ role,
317
+ id: this.id,
318
+ });
319
+ if (Platform.OS === 'ios') {
320
+ return await HmsManager.previewForRole({ role: role?.name, id: this.id });
321
+ } else {
322
+ console.log('API currently not available for android');
323
+ return 'API currently not available for android';
324
+ }
325
+ };
326
+
246
327
  HmsView = ({
247
328
  sink,
248
329
  trackId,
@@ -279,10 +360,11 @@ export class HMSSDK {
279
360
  this.remotePeers = undefined;
280
361
  this.room = undefined;
281
362
  this.knownRoles = undefined;
363
+ this?.appStateSubscription?.remove();
282
364
  return op;
283
365
  };
284
366
 
285
- sendBroadcastMessage = async (message: string, type?: string) => {
367
+ sendBroadcastMessage = async (message: string, type: string = 'chat') => {
286
368
  logger?.verbose('#Function sendBroadcastMessage', {
287
369
  message,
288
370
  type: type || null,
@@ -298,7 +380,7 @@ export class HMSSDK {
298
380
  sendGroupMessage = async (
299
381
  message: string,
300
382
  roles: HMSRole[],
301
- type?: string
383
+ type: string = 'chat'
302
384
  ) => {
303
385
  logger?.verbose('#Function sendGroupMessage', {
304
386
  message,
@@ -316,18 +398,18 @@ export class HMSSDK {
316
398
 
317
399
  sendDirectMessage = async (
318
400
  message: string,
319
- peerId: string,
320
- type?: string
401
+ peer: HMSPeer,
402
+ type: string = 'chat'
321
403
  ) => {
322
404
  logger?.verbose('#Function sendDirectMessage', {
323
405
  message,
324
- peerId,
406
+ peerId: peer.peerID,
325
407
  id: this.id,
326
408
  type: type || null,
327
409
  });
328
410
  return await HmsManager.sendDirectMessage({
329
411
  message,
330
- peerId,
412
+ peerId: peer.peerID,
331
413
  id: this.id,
332
414
  type: type || null,
333
415
  });
@@ -354,6 +436,19 @@ export class HMSSDK {
354
436
  return op;
355
437
  };
356
438
 
439
+ startHLSStreaming = async (data: HMSHLSConfig) => {
440
+ logger?.verbose('#Function startHLSStreaming', {
441
+ ...data,
442
+ id: this.id,
443
+ });
444
+ return await HmsManager.startHLSStreaming({ ...data, id: this.id });
445
+ };
446
+
447
+ stopHLSStreaming = async () => {
448
+ logger?.verbose('#Function stopHLSStreaming', {});
449
+ return await HmsManager.stopHLSStreaming({ id: this.id });
450
+ };
451
+
357
452
  changeRole = async (peer: HMSPeer, role: HMSRole, force: boolean = false) => {
358
453
  const data = {
359
454
  peerId: peer?.peerID,
@@ -380,12 +475,16 @@ export class HMSSDK {
380
475
  return await HmsManager.changeTrackState(data);
381
476
  };
382
477
 
383
- changeTrackStateRoles = async (
384
- type: HMSTrackType,
478
+ changeTrackStateForRoles = async (
385
479
  mute: boolean,
386
- source: string,
387
- roles: Array<HMSRole>
480
+ type?: HMSTrackType,
481
+ source?: string,
482
+ roles?: Array<HMSRole>
388
483
  ) => {
484
+ let roleNames = null;
485
+ if (roles) {
486
+ roleNames = HMSHelper.getRoleNames(roles);
487
+ }
389
488
  logger?.verbose('#Function changeTrackStateRoles', {
390
489
  source,
391
490
  mute,
@@ -397,17 +496,21 @@ export class HMSSDK {
397
496
  source,
398
497
  mute,
399
498
  type,
400
- roles: HMSHelper.getRoleNames(roles),
499
+ roles: roleNames,
401
500
  id: this.id,
402
501
  };
403
502
 
404
- return await HmsManager.changeTrackStateRoles(data);
503
+ return await HmsManager.changeTrackStateForRoles(data);
405
504
  };
406
505
 
407
- removePeer = async (peerId: string, reason: string) => {
408
- logger?.verbose('#Function removePeer', { peerId, reason, id: this.id });
506
+ removePeer = async (peer: HMSPeer, reason: string) => {
507
+ logger?.verbose('#Function removePeer', {
508
+ peerId: peer.peerID,
509
+ reason,
510
+ id: this.id,
511
+ });
409
512
  const data = {
410
- peerId,
513
+ peerId: peer.peerID,
411
514
  reason,
412
515
  id: this.id,
413
516
  };
@@ -415,7 +518,7 @@ export class HMSSDK {
415
518
  return await HmsManager.removePeer(data);
416
519
  };
417
520
 
418
- endRoom = async (lock: boolean, reason: string) => {
521
+ endRoom = async (reason: string, lock: boolean = false) => {
419
522
  logger?.verbose('#Function endRoom', { lock, reason, id: this.id });
420
523
  const data = {
421
524
  lock,
@@ -426,15 +529,30 @@ export class HMSSDK {
426
529
  return await HmsManager.endRoom(data);
427
530
  };
428
531
 
429
- acceptRoleChange = () => {
532
+ changeName = async (name: string) => {
533
+ logger?.verbose('#Function changeName', { name, id: this.id });
534
+ const data = {
535
+ name,
536
+ id: this.id,
537
+ };
538
+
539
+ return await HmsManager.changeName(data);
540
+ };
541
+
542
+ acceptRoleChange = async () => {
430
543
  logger?.verbose('#Function acceptRoleChange', { id: this.id });
431
- HmsManager.acceptRoleChange({ id: this.id });
544
+ return await HmsManager.acceptRoleChange({ id: this.id });
432
545
  };
433
546
 
434
- muteAllPeersAudio = (mute: boolean) => {
435
- logger?.verbose('#Function muteAllPeersAudio', { mute, id: this.id });
547
+ setPlaybackForAllAudio = (mute: boolean) => {
548
+ logger?.verbose('#Function setPlaybackForAllAudio', { mute, id: this.id });
436
549
  this.muteStatus = mute;
437
- HmsManager.muteAllPeersAudio({ mute, id: this.id });
550
+ HmsManager.setPlaybackForAllAudio({ mute, id: this.id });
551
+ };
552
+
553
+ remoteMuteAllAudio = () => {
554
+ logger?.verbose('#Function remoteMuteAllAudio', { id: this.id });
555
+ HmsManager.remoteMuteAllAudio({ id: this.id });
438
556
  };
439
557
 
440
558
  getRoom = async () => {
@@ -459,7 +577,70 @@ export class HMSSDK {
459
577
  trackId: track.trackId,
460
578
  volume,
461
579
  });
462
- return;
580
+ };
581
+
582
+ resetVolume = () => {
583
+ logger?.verbose('#Function resetVolume', { id: this.id });
584
+ if (Platform.OS === 'android') HmsManager.resetVolume({ id: this.id });
585
+ };
586
+
587
+ addAppStateListener = () => {
588
+ logger?.verbose('#Function addAppStateListener', { id: this.id });
589
+ this.appStateSubscription = AppState.addEventListener(
590
+ 'change',
591
+ (nextAppState) => {
592
+ if (nextAppState === 'active' && Platform.OS === 'android') {
593
+ this.resetVolume();
594
+ }
595
+ }
596
+ );
597
+ };
598
+
599
+ startScreenshare = () => {
600
+ logger?.verbose('#Function startScreenshare', { id: this.id });
601
+ if (Platform.OS === 'android') {
602
+ HmsManager.startScreenshare({ id: this.id });
603
+ } else {
604
+ console.log('API currently not available for iOS');
605
+ }
606
+ };
607
+
608
+ isScreenShared = async () => {
609
+ logger?.verbose('#Function isScreenShared', { id: this.id });
610
+ if (Platform.OS === 'android') {
611
+ return await HmsManager.isScreenShared({ id: this.id });
612
+ } else {
613
+ console.log('API currently not available for iOS');
614
+ return 'API currently not available for iOS';
615
+ }
616
+ };
617
+
618
+ stopScreenshare = async () => {
619
+ logger?.verbose('#Function stopScreenshare', { id: this.id });
620
+ if (Platform.OS === 'android') {
621
+ return await HmsManager.stopScreenshare({ id: this.id });
622
+ } else {
623
+ console.log('API currently not available for iOS');
624
+ return 'API currently not available for iOS';
625
+ }
626
+ };
627
+
628
+ enableRTCStats = () => {
629
+ logger?.verbose('#Function enableRTCStats', { id: this.id });
630
+ if (Platform.OS === 'ios') {
631
+ HmsManager.enableRTCStats({ id: this.id });
632
+ } else {
633
+ console.log('API currently not avaialble for android');
634
+ }
635
+ };
636
+
637
+ disableRTCStats = () => {
638
+ logger?.verbose('#Function disableRTCStats', { id: this.id });
639
+ if (Platform.OS === 'ios') {
640
+ HmsManager.disableRTCStats({ id: this.id });
641
+ } else {
642
+ console.log('API currently not avaialble for android');
643
+ }
463
644
  };
464
645
 
465
646
  /**
@@ -515,6 +696,21 @@ export class HMSSDK {
515
696
  case HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM:
516
697
  this.onRemovedFromRoomDelegate = callback;
517
698
  break;
699
+ case HMSUpdateListenerActions.ON_RTC_STATS:
700
+ this.onRtcStatsDelegate = callback;
701
+ break;
702
+ case HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS:
703
+ this.onLocalAudioStatsDelegate = callback;
704
+ break;
705
+ case HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS:
706
+ this.onLocalVideoStatsDelegate = callback;
707
+ break;
708
+ case HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS:
709
+ this.onRemoteAudioStatsDelegate = callback;
710
+ break;
711
+ case HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS:
712
+ this.onRemoteVideoStatsDelegate = callback;
713
+ break;
518
714
  default:
519
715
  }
520
716
  };
@@ -569,6 +765,21 @@ export class HMSSDK {
569
765
  case HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM:
570
766
  this.onRemovedFromRoomDelegate = null;
571
767
  break;
768
+ case HMSUpdateListenerActions.ON_RTC_STATS:
769
+ this.onRtcStatsDelegate = null;
770
+ break;
771
+ case HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS:
772
+ this.onLocalAudioStatsDelegate = null;
773
+ break;
774
+ case HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS:
775
+ this.onLocalVideoStatsDelegate = null;
776
+ break;
777
+ case HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS:
778
+ this.onRemoteAudioStatsDelegate = null;
779
+ break;
780
+ case HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS:
781
+ this.onRemoteVideoStatsDelegate = null;
782
+ break;
572
783
  default:
573
784
  }
574
785
  };
@@ -723,7 +934,7 @@ export class HMSSDK {
723
934
  this.id
724
935
  );
725
936
  if (this.muteStatus && data?.type === 'TRACK_ADDED') {
726
- this.muteAllPeersAudio(this.muteStatus);
937
+ this.setPlaybackForAllAudio(this.muteStatus);
727
938
  }
728
939
  this.room = room;
729
940
  this.localPeer = localPeer;
@@ -760,7 +971,7 @@ export class HMSSDK {
760
971
  logger?.verbose('#Listener ON_SPEAKER', data);
761
972
  if (this.onSpeakerDelegate) {
762
973
  logger?.verbose('#Listener ON_SPEAKER_LISTENER_CALL', data);
763
- this.onSpeakerDelegate(data);
974
+ this.onSpeakerDelegate(HMSEncoder.encodeHmsSpeakerUpdate(data, this.id));
764
975
  }
765
976
  };
766
977
 
@@ -853,4 +1064,92 @@ export class HMSSDK {
853
1064
  this.onReconnectedDelegate(data);
854
1065
  }
855
1066
  };
1067
+
1068
+ RTCStatsListener = (data: any) => {
1069
+ if (data.id !== this.id) {
1070
+ return;
1071
+ }
1072
+
1073
+ logger?.verbose('#Listener RTCStatsListener', data);
1074
+
1075
+ let rtcStats = HMSEncoder.encodeRTCStats(data);
1076
+
1077
+ if (this.onRtcStatsDelegate) {
1078
+ this.onRtcStatsDelegate({ rtcStats });
1079
+ }
1080
+ };
1081
+
1082
+ onLocalAudioStatsListener = (data: any) => {
1083
+ if (data.id !== this.id) {
1084
+ return;
1085
+ }
1086
+
1087
+ logger?.verbose('#Listener onLocalAudioStatsListener', data);
1088
+
1089
+ let localAudioStats = new HMSLocalAudioStats(data.localAudioStats);
1090
+ let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1091
+ let track = HMSEncoder.encodeHmsLocalAudioTrack(data.track, this.id);
1092
+
1093
+ if (this.onLocalAudioStatsDelegate) {
1094
+ this.onLocalAudioStatsDelegate({ ...data, localAudioStats, peer, track });
1095
+ }
1096
+ };
1097
+
1098
+ onLocalVideoStatsListener = (data: any) => {
1099
+ if (data.id !== this.id) {
1100
+ return;
1101
+ }
1102
+
1103
+ logger?.verbose('#Listener onLocalVideoStatsListener', data);
1104
+
1105
+ let localVideoStats = new HMSLocalVideoStats(data.localVideoStats);
1106
+ let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1107
+ let track = HMSEncoder.encodeHmsLocalVideoTrack(data.track, this.id);
1108
+
1109
+ if (this.onLocalVideoStatsDelegate) {
1110
+ this.onLocalVideoStatsDelegate({ ...data, localVideoStats, peer, track });
1111
+ }
1112
+ };
1113
+
1114
+ onRemoteAudioStatsListener = (data: any) => {
1115
+ if (data.id !== this.id) {
1116
+ return;
1117
+ }
1118
+
1119
+ logger?.verbose('#Listener onRemoteAudioStatsListener', data);
1120
+
1121
+ let remoteAudioStats = new HMSRemoteAudioStats(data.remoteAudioStats);
1122
+ let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1123
+ let track = HMSEncoder.encodeHmsRemoteAudioTrack(data.track, this.id);
1124
+
1125
+ if (this.onRemoteAudioStatsDelegate) {
1126
+ this.onRemoteAudioStatsDelegate({
1127
+ ...data,
1128
+ remoteAudioStats,
1129
+ peer,
1130
+ track,
1131
+ });
1132
+ }
1133
+ };
1134
+
1135
+ onRemoteVideoStatsListener = (data: any) => {
1136
+ if (data.id !== this.id) {
1137
+ return;
1138
+ }
1139
+
1140
+ logger?.verbose('#Listener onRemoteVideoStatsListener', data);
1141
+
1142
+ let remoteVideoStats = new HMSRemoteVideoStats(data.remoteVideoStats);
1143
+ let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1144
+ let track = HMSEncoder.encodeHmsRemoteVideoTrack(data.track, this.id);
1145
+
1146
+ if (this.onRemoteVideoStatsDelegate) {
1147
+ this.onRemoteVideoStatsDelegate({
1148
+ ...data,
1149
+ remoteVideoStats,
1150
+ peer,
1151
+ track,
1152
+ });
1153
+ }
1154
+ };
856
1155
  }
@@ -3,9 +3,15 @@ import type { HMSException } from './HMSException';
3
3
  export class HMSServerRecordingState {
4
4
  running: string;
5
5
  error: HMSException;
6
+ startedAt: Date;
6
7
 
7
- constructor(params: { running: string; error: HMSException }) {
8
+ constructor(params: {
9
+ running: string;
10
+ error: HMSException;
11
+ startedAt: Date;
12
+ }) {
8
13
  this.running = params.running;
9
14
  this.error = params.error;
15
+ this.startedAt = params.startedAt;
10
16
  }
11
17
  }
@@ -12,4 +12,9 @@ export enum HMSUpdateListenerActions {
12
12
  ON_ROLE_CHANGE_REQUEST = 'ON_ROLE_CHANGE_REQUEST',
13
13
  ON_CHANGE_TRACK_STATE_REQUEST = 'ON_CHANGE_TRACK_STATE_REQUEST',
14
14
  ON_REMOVED_FROM_ROOM = 'ON_REMOVED_FROM_ROOM',
15
+ ON_RTC_STATS = 'ON_RTC_STATS',
16
+ ON_LOCAL_AUDIO_STATS = 'ON_LOCAL_AUDIO_STATS',
17
+ ON_LOCAL_VIDEO_STATS = 'ON_LOCAL_VIDEO_STATS',
18
+ ON_REMOTE_AUDIO_STATS = 'ON_REMOTE_AUDIO_STATS',
19
+ ON_REMOTE_VIDEO_STATS = 'ON_REMOTE_VIDEO_STATS',
15
20
  }
@@ -1,6 +1,7 @@
1
- import React from 'react';
2
- import { requireNativeComponent, ViewStyle } from 'react-native';
1
+ import React, { useState, useEffect } from 'react';
2
+ import { requireNativeComponent, StyleSheet, ViewStyle } from 'react-native';
3
3
  import { HMSVideoViewMode } from '../classes/HMSVideoViewMode';
4
+
4
5
  interface HmsViewProps {
5
6
  data: {
6
7
  trackId: string;
@@ -10,6 +11,7 @@ interface HmsViewProps {
10
11
  };
11
12
  scaleType: HMSVideoViewMode;
12
13
  style: ViewStyle;
14
+ onChange: Function;
13
15
  }
14
16
 
15
17
  const HmsViewComponent = requireNativeComponent<HmsViewProps>('HmsView');
@@ -29,8 +31,9 @@ export const HmsView = ({
29
31
  style,
30
32
  id,
31
33
  mirror,
32
- scaleType = HMSVideoViewMode.ASPECT_FIT,
34
+ scaleType = HMSVideoViewMode.ASPECT_FILL,
33
35
  }: HmsComponentProps) => {
36
+ const [tempVal, setTempVal] = useState(0);
34
37
  const data = {
35
38
  trackId,
36
39
  sink,
@@ -38,5 +41,30 @@ export const HmsView = ({
38
41
  mirror: mirror || false,
39
42
  };
40
43
 
41
- return <HmsViewComponent data={data} style={style} scaleType={scaleType} />;
44
+ const onChange = (values: any) => {
45
+ console.log(values, 'values');
46
+ setTimeout(() => {
47
+ setTempVal(1);
48
+ }, 2000);
49
+ };
50
+
51
+ useEffect(() => {
52
+ setTempVal(0);
53
+ }, [tempVal]);
54
+
55
+ return (
56
+ <HmsViewComponent
57
+ onChange={onChange}
58
+ data={data}
59
+ style={tempVal === 0 ? style : temporaryStyles.customStyle}
60
+ scaleType={scaleType}
61
+ />
62
+ );
42
63
  };
64
+
65
+ const temporaryStyles = StyleSheet.create({
66
+ customStyle: {
67
+ width: '100%',
68
+ height: '50%',
69
+ },
70
+ });
package/src/index.ts CHANGED
@@ -46,7 +46,17 @@ export * from './classes/HMSRtmpStreamingState';
46
46
  export * from './classes/HMSServerRecordingState';
47
47
  export * from './classes/HMSBrowserRecordingState';
48
48
  export * from './classes/HMSRTMPConfig';
49
+ export * from './classes/HMSHLSConfig';
50
+ export * from './classes/HMSHLSMeetingURLVariant';
51
+ export * from './classes/HMSHLSVariant';
52
+ export * from './classes/HMSHLSStreamingState';
49
53
  export * from './classes/HMSVideoResolution';
54
+ export * from './classes/HMSLocalAudioStats';
55
+ export * from './classes/HMSLocalVideoStats';
56
+ export * from './classes/HMSRTCStats';
57
+ export * from './classes/HMSRTCStatsReport';
58
+ export * from './classes/HMSRemoteAudioStats';
59
+ export * from './classes/HMSRemoteVideoStats';
50
60
 
51
61
  import { HMSSDK as HmsManager } from './classes/HMSSDK';
52
62
  export default HmsManager;
package/android/.project DELETED
@@ -1,34 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <projectDescription>
3
- <name>reactnativehmssdk</name>
4
- <comment>Project reactnativehmssdk created by Buildship.</comment>
5
- <projects>
6
- </projects>
7
- <buildSpec>
8
- <buildCommand>
9
- <name>org.eclipse.jdt.core.javabuilder</name>
10
- <arguments>
11
- </arguments>
12
- </buildCommand>
13
- <buildCommand>
14
- <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15
- <arguments>
16
- </arguments>
17
- </buildCommand>
18
- </buildSpec>
19
- <natures>
20
- <nature>org.eclipse.jdt.core.javanature</nature>
21
- <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22
- </natures>
23
- <filteredResources>
24
- <filter>
25
- <id>0</id>
26
- <name></name>
27
- <type>30</type>
28
- <matcher>
29
- <id>org.eclipse.core.resources.regexFilterMatcher</id>
30
- <arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31
- </matcher>
32
- </filter>
33
- </filteredResources>
34
- </projectDescription>