@100mslive/react-native-hms 0.8.4 → 0.9.2

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 (201) hide show
  1. package/README.md +247 -26
  2. package/android/.gradle/6.9/fileHashes/fileHashes.bin +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/outputFiles.bin +0 -0
  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 +67 -5
  19. package/android/src/main/java/com/reactnativehmssdk/HmsHelper.kt +67 -64
  20. package/android/src/main/java/com/reactnativehmssdk/HmsModule.kt +97 -6
  21. package/android/src/main/java/com/reactnativehmssdk/HmsSDK.kt +302 -118
  22. package/android/src/main/java/com/reactnativehmssdk/HmsScreenshareActivity.kt +77 -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 +250 -123
  27. package/ios/HmsHelper.swift +70 -38
  28. package/ios/HmsManager.m +11 -3
  29. package/ios/HmsManager.swift +123 -66
  30. package/ios/HmsSDK.swift +384 -195
  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/HMSEncoder.js +180 -3
  36. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  37. package/lib/commonjs/classes/HMSHLSConfig.js +23 -0
  38. package/lib/commonjs/classes/HMSHLSConfig.js.map +1 -0
  39. package/lib/commonjs/classes/HMSHLSMeetingURLVariant.js +23 -0
  40. package/lib/commonjs/classes/HMSHLSMeetingURLVariant.js.map +1 -0
  41. package/lib/commonjs/classes/HMSHLSRecordingConfig.js +23 -0
  42. package/lib/commonjs/classes/HMSHLSRecordingConfig.js.map +1 -0
  43. package/lib/commonjs/classes/HMSHLSRecordingState.js +29 -0
  44. package/lib/commonjs/classes/HMSHLSRecordingState.js.map +1 -0
  45. package/lib/commonjs/classes/HMSHLSStreamingState.js +23 -0
  46. package/lib/commonjs/classes/HMSHLSStreamingState.js.map +1 -0
  47. package/lib/commonjs/classes/HMSHLSVariant.js +29 -0
  48. package/lib/commonjs/classes/HMSHLSVariant.js.map +1 -0
  49. package/lib/commonjs/classes/HMSLocalAudioStats.js +26 -0
  50. package/lib/commonjs/classes/HMSLocalAudioStats.js.map +1 -0
  51. package/lib/commonjs/classes/HMSLocalVideoStats.js +32 -0
  52. package/lib/commonjs/classes/HMSLocalVideoStats.js.map +1 -0
  53. package/lib/commonjs/classes/HMSLogger.js +48 -21
  54. package/lib/commonjs/classes/HMSLogger.js.map +1 -1
  55. package/lib/commonjs/classes/HMSMessage.js +4 -1
  56. package/lib/commonjs/classes/HMSMessage.js.map +1 -1
  57. package/lib/commonjs/classes/HMSMessageRecipient.js +26 -0
  58. package/lib/commonjs/classes/HMSMessageRecipient.js.map +1 -0
  59. package/lib/commonjs/classes/HMSMessageRecipientType.js +15 -0
  60. package/lib/commonjs/classes/HMSMessageRecipientType.js.map +1 -0
  61. package/lib/commonjs/classes/HMSPeerUpdate.js +1 -7
  62. package/lib/commonjs/classes/HMSPeerUpdate.js.map +1 -1
  63. package/lib/commonjs/classes/HMSPermissions.js +2 -2
  64. package/lib/commonjs/classes/HMSPermissions.js.map +1 -1
  65. package/lib/commonjs/classes/HMSRTCStats.js +38 -0
  66. package/lib/commonjs/classes/HMSRTCStats.js.map +1 -0
  67. package/lib/commonjs/classes/HMSRTCStatsReport.js +26 -0
  68. package/lib/commonjs/classes/HMSRTCStatsReport.js.map +1 -0
  69. package/lib/commonjs/classes/HMSRemoteAudioStats.js +32 -0
  70. package/lib/commonjs/classes/HMSRemoteAudioStats.js.map +1 -0
  71. package/lib/commonjs/classes/HMSRemoteVideoStats.js +38 -0
  72. package/lib/commonjs/classes/HMSRemoteVideoStats.js.map +1 -0
  73. package/lib/commonjs/classes/HMSRoom.js +9 -0
  74. package/lib/commonjs/classes/HMSRoom.js.map +1 -1
  75. package/lib/commonjs/classes/HMSRoomUpdate.js +7 -0
  76. package/lib/commonjs/classes/HMSRoomUpdate.js.map +1 -1
  77. package/lib/commonjs/classes/HMSRtmpStreamingState.js +6 -0
  78. package/lib/commonjs/classes/HMSRtmpStreamingState.js.map +1 -1
  79. package/lib/commonjs/classes/HMSSDK.js +488 -114
  80. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  81. package/lib/commonjs/classes/HMSServerRecordingState.js +3 -0
  82. package/lib/commonjs/classes/HMSServerRecordingState.js.map +1 -1
  83. package/lib/commonjs/classes/HMSUpdateListenerActions.js +5 -0
  84. package/lib/commonjs/classes/HMSUpdateListenerActions.js.map +1 -1
  85. package/lib/commonjs/classes/HmsView.js +26 -4
  86. package/lib/commonjs/classes/HmsView.js.map +1 -1
  87. package/lib/commonjs/index.js +196 -0
  88. package/lib/commonjs/index.js.map +1 -1
  89. package/lib/module/classes/HMSBrowserRecordingState.js +6 -0
  90. package/lib/module/classes/HMSBrowserRecordingState.js.map +1 -1
  91. package/lib/module/classes/HMSEncoder.js +172 -3
  92. package/lib/module/classes/HMSEncoder.js.map +1 -1
  93. package/lib/module/classes/HMSHLSConfig.js +14 -0
  94. package/lib/module/classes/HMSHLSConfig.js.map +1 -0
  95. package/lib/module/classes/HMSHLSMeetingURLVariant.js +14 -0
  96. package/lib/module/classes/HMSHLSMeetingURLVariant.js.map +1 -0
  97. package/lib/module/classes/HMSHLSRecordingConfig.js +14 -0
  98. package/lib/module/classes/HMSHLSRecordingConfig.js.map +1 -0
  99. package/lib/module/classes/HMSHLSRecordingState.js +20 -0
  100. package/lib/module/classes/HMSHLSRecordingState.js.map +1 -0
  101. package/lib/module/classes/HMSHLSStreamingState.js +14 -0
  102. package/lib/module/classes/HMSHLSStreamingState.js.map +1 -0
  103. package/lib/module/classes/HMSHLSVariant.js +20 -0
  104. package/lib/module/classes/HMSHLSVariant.js.map +1 -0
  105. package/lib/module/classes/HMSLocalAudioStats.js +17 -0
  106. package/lib/module/classes/HMSLocalAudioStats.js.map +1 -0
  107. package/lib/module/classes/HMSLocalVideoStats.js +23 -0
  108. package/lib/module/classes/HMSLocalVideoStats.js.map +1 -0
  109. package/lib/module/classes/HMSLogger.js +48 -21
  110. package/lib/module/classes/HMSLogger.js.map +1 -1
  111. package/lib/module/classes/HMSMessage.js +4 -1
  112. package/lib/module/classes/HMSMessage.js.map +1 -1
  113. package/lib/module/classes/HMSMessageRecipient.js +17 -0
  114. package/lib/module/classes/HMSMessageRecipient.js.map +1 -0
  115. package/lib/module/classes/HMSMessageRecipientType.js +8 -0
  116. package/lib/module/classes/HMSMessageRecipientType.js.map +1 -0
  117. package/lib/module/classes/HMSPeerUpdate.js +1 -7
  118. package/lib/module/classes/HMSPeerUpdate.js.map +1 -1
  119. package/lib/module/classes/HMSPermissions.js +2 -2
  120. package/lib/module/classes/HMSPermissions.js.map +1 -1
  121. package/lib/module/classes/HMSRTCStats.js +29 -0
  122. package/lib/module/classes/HMSRTCStats.js.map +1 -0
  123. package/lib/module/classes/HMSRTCStatsReport.js +17 -0
  124. package/lib/module/classes/HMSRTCStatsReport.js.map +1 -0
  125. package/lib/module/classes/HMSRemoteAudioStats.js +23 -0
  126. package/lib/module/classes/HMSRemoteAudioStats.js.map +1 -0
  127. package/lib/module/classes/HMSRemoteVideoStats.js +29 -0
  128. package/lib/module/classes/HMSRemoteVideoStats.js.map +1 -0
  129. package/lib/module/classes/HMSRoom.js +9 -0
  130. package/lib/module/classes/HMSRoom.js.map +1 -1
  131. package/lib/module/classes/HMSRoomUpdate.js +7 -0
  132. package/lib/module/classes/HMSRoomUpdate.js.map +1 -1
  133. package/lib/module/classes/HMSRtmpStreamingState.js +6 -0
  134. package/lib/module/classes/HMSRtmpStreamingState.js.map +1 -1
  135. package/lib/module/classes/HMSSDK.js +476 -115
  136. package/lib/module/classes/HMSSDK.js.map +1 -1
  137. package/lib/module/classes/HMSServerRecordingState.js +3 -0
  138. package/lib/module/classes/HMSServerRecordingState.js.map +1 -1
  139. package/lib/module/classes/HMSUpdateListenerActions.js +5 -0
  140. package/lib/module/classes/HMSUpdateListenerActions.js.map +1 -1
  141. package/lib/module/classes/HmsView.js +23 -4
  142. package/lib/module/classes/HmsView.js.map +1 -1
  143. package/lib/module/index.js +14 -0
  144. package/lib/module/index.js.map +1 -1
  145. package/lib/typescript/classes/HMSBrowserRecordingState.d.ts +4 -0
  146. package/lib/typescript/classes/HMSEncoder.d.ts +23 -0
  147. package/lib/typescript/classes/HMSHLSConfig.d.ts +10 -0
  148. package/lib/typescript/classes/HMSHLSMeetingURLVariant.d.ts +8 -0
  149. package/lib/typescript/classes/HMSHLSRecordingConfig.d.ts +8 -0
  150. package/lib/typescript/classes/HMSHLSRecordingState.d.ts +12 -0
  151. package/lib/typescript/classes/HMSHLSStreamingState.d.ts +9 -0
  152. package/lib/typescript/classes/HMSHLSVariant.d.ts +12 -0
  153. package/lib/typescript/classes/HMSLocalAudioStats.d.ts +10 -0
  154. package/lib/typescript/classes/HMSLocalVideoStats.d.ts +15 -0
  155. package/lib/typescript/classes/HMSLogger.d.ts +2 -0
  156. package/lib/typescript/classes/HMSMessage.d.ts +8 -4
  157. package/lib/typescript/classes/HMSMessageRecipient.d.ts +13 -0
  158. package/lib/typescript/classes/HMSMessageRecipientType.d.ts +5 -0
  159. package/lib/typescript/classes/HMSPeerUpdate.d.ts +2 -8
  160. package/lib/typescript/classes/HMSPermissions.d.ts +2 -2
  161. package/lib/typescript/classes/HMSRTCStats.d.ts +18 -0
  162. package/lib/typescript/classes/HMSRTCStatsReport.d.ts +11 -0
  163. package/lib/typescript/classes/HMSRemoteAudioStats.d.ts +14 -0
  164. package/lib/typescript/classes/HMSRemoteVideoStats.d.ts +19 -0
  165. package/lib/typescript/classes/HMSRoom.d.ts +8 -0
  166. package/lib/typescript/classes/HMSRoomUpdate.d.ts +8 -1
  167. package/lib/typescript/classes/HMSRtmpStreamingState.d.ts +4 -0
  168. package/lib/typescript/classes/HMSSDK.d.ts +325 -14
  169. package/lib/typescript/classes/HMSServerRecordingState.d.ts +2 -0
  170. package/lib/typescript/classes/HMSUpdateListenerActions.d.ts +6 -1
  171. package/lib/typescript/index.d.ts +14 -0
  172. package/package.json +1 -2
  173. package/react-native-hms.podspec +1 -1
  174. package/src/classes/HMSBrowserRecordingState.ts +10 -1
  175. package/src/classes/HMSEncoder.ts +193 -3
  176. package/src/classes/HMSHLSConfig.ts +15 -0
  177. package/src/classes/HMSHLSMeetingURLVariant.ts +9 -0
  178. package/src/classes/HMSHLSRecordingConfig.ts +9 -0
  179. package/src/classes/HMSHLSRecordingState.ts +18 -0
  180. package/src/classes/HMSHLSStreamingState.ts +11 -0
  181. package/src/classes/HMSHLSVariant.ts +18 -0
  182. package/src/classes/HMSLocalAudioStats.ts +15 -0
  183. package/src/classes/HMSLocalVideoStats.ts +23 -0
  184. package/src/classes/HMSLogger.ts +17 -3
  185. package/src/classes/HMSMessage.ts +11 -5
  186. package/src/classes/HMSMessageRecipient.ts +19 -0
  187. package/src/classes/HMSMessageRecipientType.ts +5 -0
  188. package/src/classes/HMSPeerUpdate.ts +1 -7
  189. package/src/classes/HMSPermissions.ts +3 -3
  190. package/src/classes/HMSRTCStats.ts +27 -0
  191. package/src/classes/HMSRTCStatsReport.ts +17 -0
  192. package/src/classes/HMSRemoteAudioStats.ts +21 -0
  193. package/src/classes/HMSRemoteVideoStats.ts +29 -0
  194. package/src/classes/HMSRoom.ts +11 -0
  195. package/src/classes/HMSRoomUpdate.ts +7 -0
  196. package/src/classes/HMSRtmpStreamingState.ts +10 -1
  197. package/src/classes/HMSSDK.tsx +618 -30
  198. package/src/classes/HMSServerRecordingState.ts +7 -1
  199. package/src/classes/HMSUpdateListenerActions.ts +5 -0
  200. package/src/classes/HmsView.tsx +32 -4
  201. package/src/index.ts +14 -0
@@ -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;
@@ -68,13 +85,13 @@ export class HMSSDK {
68
85
 
69
86
  /**
70
87
  * - Returns an instance of [HMSSDK]{@link HMSSDK}
71
- * - This function must be called to get an instance of HMSSDK class and only then user can interact with its methods
88
+ * - This function must be called to get an instance of HMSSDK class and only then user can interact with its methods.
72
89
  *
73
90
  * @static
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();
@@ -82,19 +99,40 @@ export class HMSSDK {
82
99
  return HmsSdk;
83
100
  }
84
101
 
102
+ /**
103
+ * - Returns the instance of logger which can be used to manipulate log levels.
104
+ * @returns @instance HMSLogger
105
+ * @memberof HMSSDK
106
+ */
85
107
  static getLogger() {
86
108
  return logger;
87
109
  }
88
110
 
111
+ /**
112
+ * - Updates the logger for this instance of HMSSDK
113
+ * @param {HMSLogger} hmsLogger
114
+ * @memberof HMSSDK
115
+ */
89
116
  setLogger = (hmsLogger: HMSLogger) => {
90
117
  logger = hmsLogger;
91
118
  hmsLogger.verbose('#Function setLogger', { id: this.id });
92
119
  };
93
120
 
121
+ /**
122
+ * - Calls removeListeners that in turn breaks all connections with native listeners.
123
+ *
124
+ * @memberof HMSSDK
125
+ */
94
126
  destroy = () => {
95
127
  this.removeListeners();
96
128
  };
97
129
 
130
+ /**
131
+ * - Attaches preview listener for native callbacks.
132
+ * Note:this function connects sdk to native side and not app to sdk.
133
+ *
134
+ * @memberof HMSSDK
135
+ */
98
136
  attachPreviewListener = () => {
99
137
  HmsEventEmitter.addListener(
100
138
  HMSUpdateListenerActions.ON_PREVIEW,
@@ -102,6 +140,11 @@ export class HMSSDK {
102
140
  );
103
141
  };
104
142
 
143
+ /**
144
+ * - Attaches all the listeners to native callbacks.
145
+ * Note: this function connects sdk to native side and not app to sdk.
146
+ * @memberof HMSSDK
147
+ */
105
148
  attachListeners = () => {
106
149
  HmsEventEmitter.addListener(
107
150
  HMSUpdateListenerActions.ON_JOIN,
@@ -162,8 +205,38 @@ export class HMSSDK {
162
205
  HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM,
163
206
  this.onRemovedFromRoomListener
164
207
  );
208
+
209
+ HmsEventEmitter.addListener(
210
+ HMSUpdateListenerActions.ON_RTC_STATS,
211
+ this.RTCStatsListener
212
+ );
213
+
214
+ HmsEventEmitter.addListener(
215
+ HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS,
216
+ this.onLocalAudioStatsListener
217
+ );
218
+
219
+ HmsEventEmitter.addListener(
220
+ HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS,
221
+ this.onLocalVideoStatsListener
222
+ );
223
+
224
+ HmsEventEmitter.addListener(
225
+ HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS,
226
+ this.onRemoteAudioStatsListener
227
+ );
228
+
229
+ HmsEventEmitter.addListener(
230
+ HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS,
231
+ this.onRemoteVideoStatsListener
232
+ );
165
233
  };
166
234
 
235
+ /**
236
+ * Disconnects all the listeners of this sdk from native listeners.
237
+ * Note: this function is only called from destroy function and should only be called when the current instance of {@link HMSSDK} is not required anymore.
238
+ * @memberof HMSSDK
239
+ */
167
240
  removeListeners = () => {
168
241
  HmsEventEmitter.removeListener(
169
242
  HMSUpdateListenerActions.ON_JOIN,
@@ -224,25 +297,97 @@ export class HMSSDK {
224
297
  HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM,
225
298
  this.onRemovedFromRoomListener
226
299
  );
300
+
301
+ HmsEventEmitter.removeListener(
302
+ HMSUpdateListenerActions.ON_RTC_STATS,
303
+ this.RTCStatsListener
304
+ );
305
+
306
+ HmsEventEmitter.removeListener(
307
+ HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS,
308
+ this.onLocalAudioStatsListener
309
+ );
310
+
311
+ HmsEventEmitter.removeListener(
312
+ HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS,
313
+ this.onLocalVideoStatsListener
314
+ );
315
+
316
+ HmsEventEmitter.removeListener(
317
+ HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS,
318
+ this.onRemoteAudioStatsListener
319
+ );
320
+
321
+ HmsEventEmitter.removeListener(
322
+ HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS,
323
+ this.onRemoteVideoStatsListener
324
+ );
227
325
  };
228
326
 
229
327
  /**
230
- * takes an instance of [HMSConfig]{@link HMSConfig} and joins the room
231
- * after joining the room user will start receiving the events and updates of the room
328
+ * takes an instance of [HMSConfig]{@link HMSConfig} and joins the room.
329
+ * after joining the room user will start receiving the events and updates of the room.
330
+ *
331
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/join} for more info
232
332
  *
233
333
  * @param {HMSConfig} config
234
334
  * @memberof HMSSDK
235
335
  */
236
336
  join = async (config: HMSConfig) => {
237
337
  logger?.verbose('#Function join', { config, id: this.id });
338
+ this.addAppStateListener();
238
339
  await HmsManager.join({ ...config, id: this.id });
239
340
  };
240
341
 
342
+ /**
343
+ * - preview function is used to initiate a preview for the localPeer.
344
+ * - We can call this function and wait for a response in previewListener, the response will contain previewTracks for local peer.
345
+ *
346
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/preview} for more info
347
+ *
348
+ * @param {HMSConfig} config
349
+ * @memberof HMSSDK
350
+ */
241
351
  preview = (config: HMSConfig) => {
242
352
  logger?.verbose('#Function preview', { config, id: this.id });
243
353
  HmsManager.preview({ ...config, id: this.id });
244
354
  };
245
355
 
356
+ /**
357
+ * - previewForRole can be used when there is role change request for current localPeer and we want
358
+ * to show the localPeer how the tracks look before publishing them to room.
359
+ *
360
+ * - It requires a role of type [HMSRole]{@link HMSRole} for which we want to preview the tracks.
361
+ *
362
+ * checkout {@link https://www.100ms.live/docs/react-native} for more info
363
+ *
364
+ * @param {HMSRole}
365
+ * @memberof HMSSDK
366
+ */
367
+ previewForRole = async (role: HMSRole) => {
368
+ logger?.verbose('#Function previewForRole', {
369
+ role,
370
+ id: this.id,
371
+ });
372
+ if (Platform.OS === 'ios') {
373
+ return await HmsManager.previewForRole({ role: role?.name, id: this.id });
374
+ } else {
375
+ console.log('API currently not available for android');
376
+ return 'API currently not available for android';
377
+ }
378
+ };
379
+
380
+ /**
381
+ * - HmsView is react component that takes one track and starts showing that track on a tile.
382
+ * - The appearance of tile is completely customizable with style prop.
383
+ * - setting sink true or false for a video tile will add or remove sink for a video.
384
+ * - scale type can determine how the incoming video will fit in the canvas check {@link HMSVideoViewMode} for more information.
385
+ *
386
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/render-video} for more info
387
+ *
388
+ * @param {HmsComponentProps}
389
+ * @memberof HMSSDK
390
+ */
246
391
  HmsView = ({
247
392
  sink,
248
393
  trackId,
@@ -263,7 +408,9 @@ export class HMSSDK {
263
408
  };
264
409
 
265
410
  /**
266
- * Calls leave function of native sdk and session of current user is invalidated
411
+ * Calls leave function of native sdk and session of current user is invalidated.
412
+ *
413
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/leave} for more info
267
414
  *
268
415
  * @memberof HMSSDK
269
416
  */
@@ -279,10 +426,19 @@ export class HMSSDK {
279
426
  this.remotePeers = undefined;
280
427
  this.room = undefined;
281
428
  this.knownRoles = undefined;
429
+ this?.appStateSubscription?.remove();
282
430
  return op;
283
431
  };
284
432
 
285
- sendBroadcastMessage = async (message: string, type?: string) => {
433
+ /**
434
+ * - This function sends message to all the peers in the room, the get the message in onMessage listener.
435
+ *
436
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/chat} for more info
437
+ *
438
+ * @param {message: string} and @param {type: string}
439
+ * @memberof HMSSDK
440
+ */
441
+ sendBroadcastMessage = async (message: string, type: string = 'chat') => {
286
442
  logger?.verbose('#Function sendBroadcastMessage', {
287
443
  message,
288
444
  type: type || null,
@@ -295,10 +451,18 @@ export class HMSSDK {
295
451
  });
296
452
  };
297
453
 
454
+ /**
455
+ * - sendGroupMessage sends a message to specific set of roles, whoever has any of those role in room
456
+ * will get the message in onMessage listener.
457
+ *
458
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/chat} for more info
459
+ *
460
+ * @memberof HMSSDK
461
+ */
298
462
  sendGroupMessage = async (
299
463
  message: string,
300
464
  roles: HMSRole[],
301
- type?: string
465
+ type: string = 'chat'
302
466
  ) => {
303
467
  logger?.verbose('#Function sendGroupMessage', {
304
468
  message,
@@ -314,30 +478,59 @@ export class HMSSDK {
314
478
  });
315
479
  };
316
480
 
481
+ /**
482
+ * - sendDirectMessage sends a private message to a single peer, only that peer will get the message
483
+ * in onMessage Listener.
484
+ *
485
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/chat} for more info
486
+ *
487
+ * @memberof HMSSDK
488
+ */
317
489
  sendDirectMessage = async (
318
490
  message: string,
319
- peerId: string,
320
- type?: string
491
+ peer: HMSPeer,
492
+ type: string = 'chat'
321
493
  ) => {
322
494
  logger?.verbose('#Function sendDirectMessage', {
323
495
  message,
324
- peerId,
496
+ peerId: peer.peerID,
325
497
  id: this.id,
326
498
  type: type || null,
327
499
  });
328
500
  return await HmsManager.sendDirectMessage({
329
501
  message,
330
- peerId,
502
+ peerId: peer.peerID,
331
503
  id: this.id,
332
504
  type: type || null,
333
505
  });
334
506
  };
335
507
 
508
+ /**
509
+ * - changeMetadata changes a specific field in localPeer which is [metadata] it is a string that can
510
+ * be used for various functionalities like raiseHand, beRightBack and many more that explains the
511
+ * current status of the peer.
512
+ *
513
+ * - it is advised to use a json object in string format to store multiple dataPoints in metadata.
514
+ *
515
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/change-metadata} for more info
516
+ *
517
+ * @param {string}
518
+ * @memberof HMSSDK
519
+ */
336
520
  changeMetadata = (metadata: string) => {
337
521
  logger?.verbose('#Function changeMetadata', { metadata, id: this.id });
338
522
  HmsManager.changeMetadata({ metadata, id: this.id });
339
523
  };
340
524
 
525
+ /**
526
+ * - startRTMPOrRecording takes a configuration object {@link HMSRTMPConfig} and stats the RTMP recording
527
+ * - this object of {@link HMSRTMPConfig} sets the urls for streaming and weather to set recording on or not
528
+ * - we get the response of this function in onRoomUpdate as RTMP_STREAMING_STATE_UPDATED.
529
+ *
530
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/recording} for more info
531
+ *
532
+ * @memberof HMSSDK
533
+ */
341
534
  startRTMPOrRecording = async (data: HMSRTMPConfig) => {
342
535
  logger?.verbose('#Function startRTMPOrRecording', {
343
536
  ...data,
@@ -348,12 +541,64 @@ export class HMSSDK {
348
541
  return op;
349
542
  };
350
543
 
544
+ /**
545
+ * - this function stops all the ongoing RTMP streaming and recording.
546
+ * - we get the response of this function in onRoomUpdate as RTMP_STREAMING_STATE_UPDATED.
547
+ *
548
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/recording} for more info
549
+ *
550
+ * @memberof HMSSDK
551
+ */
351
552
  stopRtmpAndRecording = async () => {
352
553
  logger?.verbose('#Function stopRtmpAndRecording', {});
353
554
  const op = await HmsManager.stopRtmpAndRecording({ id: this.id });
354
555
  return op;
355
556
  };
356
557
 
558
+ /**
559
+ * - This function starts HLSStreaming.
560
+ * - we get the response of this function in onRoomUpdate as HLS_STREAMING_STATE_UPDATED.
561
+ *
562
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/hls-streaming} for more info
563
+ *
564
+ * @param {HMSHLSConfig}
565
+ * @memberof HMSSDK
566
+ */
567
+ startHLSStreaming = async (data: HMSHLSConfig) => {
568
+ logger?.verbose('#Function startHLSStreaming', {
569
+ ...data,
570
+ id: this.id,
571
+ });
572
+ return await HmsManager.startHLSStreaming({ ...data, id: this.id });
573
+ };
574
+
575
+ /**
576
+ * - stopHLSStreaming function stops the ongoing HLSStreams.
577
+ * - we get the response of this function in onRoomUpdate as HLS_STREAMING_STATE_UPDATED.
578
+ *
579
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/hls-streaming} for more info
580
+ *
581
+ * @memberof HMSSDK
582
+ */
583
+ stopHLSStreaming = async () => {
584
+ logger?.verbose('#Function stopHLSStreaming', {});
585
+ return await HmsManager.stopHLSStreaming({ id: this.id });
586
+ };
587
+
588
+ /**
589
+ * - This function can be used in a situation when we want to change role hence manipulate their
590
+ * access and rights in the current room, it takes the peer {@link HMSPeer} whom role we want to change,
591
+ * role {@link HMSRole} which will be the new role for that peer and weather to forcefully change
592
+ * the role or ask the to accept the role change request using a boolean force.
593
+ *
594
+ * - if we change the role forcefully the peer's role will be updated without asking the peer
595
+ * otherwise the user will get the roleChangeRequest in roleChangeRequest listener.
596
+ * for more information on this checkout {@link onRoleChangeRequestListener}
597
+ *
598
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/change-role} for more info
599
+ *
600
+ * @memberof HMSSDK
601
+ */
357
602
  changeRole = async (peer: HMSPeer, role: HMSRole, force: boolean = false) => {
358
603
  const data = {
359
604
  peerId: peer?.peerID,
@@ -365,6 +610,15 @@ export class HMSSDK {
365
610
  return await HmsManager.changeRole(data);
366
611
  };
367
612
 
613
+ /**
614
+ * - This function can be used to manipulate mute status of any track.
615
+ * - Targeted peer affected by this action will get a callback in {@link onChangeTrackStateRequestListener}.
616
+ *
617
+ * * checkout {@link https://www.100ms.live/docs/react-native/v2/features/change-track-state} for more info
618
+ *
619
+ * @param {HMSTrack}
620
+ * @memberof HMSSDK
621
+ */
368
622
  changeTrackState = async (track: HMSTrack, mute: boolean) => {
369
623
  logger?.verbose('#Function changeTrackState', {
370
624
  track,
@@ -380,12 +634,24 @@ export class HMSSDK {
380
634
  return await HmsManager.changeTrackState(data);
381
635
  };
382
636
 
383
- changeTrackStateRoles = async (
384
- type: HMSTrackType,
637
+ /**
638
+ * - changeTrackStateForRoles is an enhancement on the functionality of {@link changeTrackState}.
639
+ * - We can change mute status for all the tracks of peers having a particular role.
640
+ * - @param source determines the source of the track ex. video, audio etc.
641
+ * - The peers affected by this action will get a callback in {@link onChangeTrackStateRequestListener}.
642
+ *
643
+ * @memberof HMSSDK
644
+ */
645
+ changeTrackStateForRoles = async (
385
646
  mute: boolean,
386
- source: string,
387
- roles: Array<HMSRole>
647
+ type?: HMSTrackType,
648
+ source?: string,
649
+ roles?: Array<HMSRole>
388
650
  ) => {
651
+ let roleNames = null;
652
+ if (roles) {
653
+ roleNames = HMSHelper.getRoleNames(roles);
654
+ }
389
655
  logger?.verbose('#Function changeTrackStateRoles', {
390
656
  source,
391
657
  mute,
@@ -397,17 +663,29 @@ export class HMSSDK {
397
663
  source,
398
664
  mute,
399
665
  type,
400
- roles: HMSHelper.getRoleNames(roles),
666
+ roles: roleNames,
401
667
  id: this.id,
402
668
  };
403
669
 
404
- return await HmsManager.changeTrackStateRoles(data);
670
+ return await HmsManager.changeTrackStateForRoles(data);
405
671
  };
406
672
 
407
- removePeer = async (peerId: string, reason: string) => {
408
- logger?.verbose('#Function removePeer', { peerId, reason, id: this.id });
673
+ /**
674
+ * - removePeer can forcefully disconnect a Peer from the room.
675
+ * - the user who's removed from this action will get a callback in {@link onRemovedFromRoomListener}.
676
+ *
677
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/remove-peer} for more info
678
+ *
679
+ * @memberof HMSSDK
680
+ */
681
+ removePeer = async (peer: HMSPeer, reason: string) => {
682
+ logger?.verbose('#Function removePeer', {
683
+ peerId: peer.peerID,
684
+ reason,
685
+ id: this.id,
686
+ });
409
687
  const data = {
410
- peerId,
688
+ peerId: peer.peerID,
411
689
  reason,
412
690
  id: this.id,
413
691
  };
@@ -415,7 +693,16 @@ export class HMSSDK {
415
693
  return await HmsManager.removePeer(data);
416
694
  };
417
695
 
418
- endRoom = async (lock: boolean, reason: string) => {
696
+ /**
697
+ * - endRoom can be used in a situation where we want to disconnect all the peers from current room
698
+ * and end the call.
699
+ * - everyone in the room will get an update of this action in {@link onRemovedFromRoomListener}.
700
+ *
701
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/end-room} for more info
702
+ *
703
+ * @memberof HMSSDK
704
+ */
705
+ endRoom = async (reason: string, lock: boolean = false) => {
419
706
  logger?.verbose('#Function endRoom', { lock, reason, id: this.id });
420
707
  const data = {
421
708
  lock,
@@ -426,17 +713,68 @@ export class HMSSDK {
426
713
  return await HmsManager.endRoom(data);
427
714
  };
428
715
 
716
+ /**
717
+ * - This function can be used to change name of localPeer.
718
+ *
719
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/change-name} for more info
720
+ *
721
+ * @memberof HMSSDK
722
+ */
723
+ changeName = async (name: string) => {
724
+ logger?.verbose('#Function changeName', { name, id: this.id });
725
+ const data = {
726
+ name,
727
+ id: this.id,
728
+ };
729
+
730
+ return await HmsManager.changeName(data);
731
+ };
732
+
733
+ /**
734
+ * - Calling this function will accept the most recent roleChange request made by anyone in the room
735
+ *
736
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/change-role} for more info
737
+ *
738
+ * @memberof HMSSDK
739
+ */
429
740
  acceptRoleChange = async () => {
430
741
  logger?.verbose('#Function acceptRoleChange', { id: this.id });
431
742
  return await HmsManager.acceptRoleChange({ id: this.id });
432
743
  };
433
744
 
434
- muteAllPeersAudio = (mute: boolean) => {
435
- logger?.verbose('#Function muteAllPeersAudio', { mute, id: this.id });
745
+ /**
746
+ * - setPlaybackForAllAudio is an extension of the abilities of {@link setPlaybackAllowed} in
747
+ * {@link HMSRemoteAudioTrack}, it sets mute status for all peers in the room
748
+ *
749
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/playback-allowed} for more info
750
+ *
751
+ * @memberof HMSSDK
752
+ */
753
+ setPlaybackForAllAudio = (mute: boolean) => {
754
+ logger?.verbose('#Function setPlaybackForAllAudio', { mute, id: this.id });
436
755
  this.muteStatus = mute;
437
- HmsManager.muteAllPeersAudio({ mute, id: this.id });
756
+ HmsManager.setPlaybackForAllAudio({ mute, id: this.id });
438
757
  };
439
758
 
759
+ /**
760
+ * - This function mutes audio for all peers in the room.
761
+ *
762
+ * @memberof HMSSDK
763
+ */
764
+ remoteMuteAllAudio = () => {
765
+ logger?.verbose('#Function remoteMuteAllAudio', { id: this.id });
766
+ HmsManager.remoteMuteAllAudio({ id: this.id });
767
+ };
768
+
769
+ /**
770
+ * - getRoom is a wrapper function on an existing native function also known as getRoom the returns
771
+ * current room object which is of type {@link HMSRoom}
772
+ *
773
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/room} for more info
774
+ *
775
+ * @memberof HMSSDK
776
+ * @return HMSRoom
777
+ */
440
778
  getRoom = async () => {
441
779
  logger?.verbose('#Function getRoom', {
442
780
  roomID: this.room?.id,
@@ -448,6 +786,13 @@ export class HMSSDK {
448
786
  return encodedHmsRoom;
449
787
  };
450
788
 
789
+ /**
790
+ * - This function sets the volume of any peer in the room
791
+ *
792
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/set-volume} for more info
793
+ *
794
+ * @memberof HMSSDK
795
+ */
451
796
  setVolume = (track: HMSTrack, volume: number) => {
452
797
  logger?.verbose('#Function setVolume', {
453
798
  track,
@@ -459,12 +804,123 @@ export class HMSSDK {
459
804
  trackId: track.trackId,
460
805
  volume,
461
806
  });
462
- return;
807
+ };
808
+
809
+ resetVolume = () => {
810
+ logger?.verbose('#Function resetVolume', { id: this.id });
811
+ if (Platform.OS === 'android') HmsManager.resetVolume({ id: this.id });
812
+ };
813
+
814
+ /**
815
+ * - This is a temporary solution for the situation when mic access is taken from the app and
816
+ * user returns to the app with no mic access. It will re-acquire the mic by setting the volume
817
+ * from native side
818
+ *
819
+ * @memberof HMSSDK
820
+ */
821
+ addAppStateListener = () => {
822
+ logger?.verbose('#Function addAppStateListener', { id: this.id });
823
+ this.appStateSubscription = AppState.addEventListener(
824
+ 'change',
825
+ (nextAppState) => {
826
+ if (nextAppState === 'active' && Platform.OS === 'android') {
827
+ this.resetVolume();
828
+ }
829
+ }
830
+ );
831
+ };
832
+
833
+ /**
834
+ * - This function is used to start screenshare, currently available only for android
835
+ *
836
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/screenshare} for more info
837
+ *
838
+ * @memberof HMSSDK
839
+ */
840
+ startScreenshare = async () => {
841
+ logger?.verbose('#Function startScreenshare', { id: this.id });
842
+ if (Platform.OS === 'android') {
843
+ return await HmsManager.startScreenshare({ id: this.id });
844
+ } else {
845
+ console.log('API currently not available for iOS');
846
+ return 'API currently not available for iOS';
847
+ }
848
+ };
849
+
850
+ /**
851
+ * - Returns a boolean stating if the screen is currently shared or not
852
+ *
853
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/screenshare} for more info
854
+ *
855
+ * @memberof HMSSDK
856
+ */
857
+ isScreenShared = async () => {
858
+ logger?.verbose('#Function isScreenShared', { id: this.id });
859
+ if (Platform.OS === 'android') {
860
+ return await HmsManager.isScreenShared({ id: this.id });
861
+ } else {
862
+ console.log('API currently not available for iOS');
863
+ return 'API currently not available for iOS';
864
+ }
865
+ };
866
+
867
+ /**
868
+ * - stops the screenShare, currently available for android only.
869
+ *
870
+ * checkout {@link https://www.100ms.live/docs/react-native/v2/features/screenshare} for more info
871
+ *
872
+ * @memberof HMSSDK
873
+ */
874
+ stopScreenshare = async () => {
875
+ logger?.verbose('#Function stopScreenshare', { id: this.id });
876
+ if (Platform.OS === 'android') {
877
+ return await HmsManager.stopScreenshare({ id: this.id });
878
+ } else {
879
+ console.log('API currently not available for iOS');
880
+ return 'API currently not available for iOS';
881
+ }
882
+ };
883
+
884
+ /**
885
+ * - enableRTCStats sets a boolean in native side which in turn allows several events to be passed
886
+ * through the bridge these events are {@link RTCStatsListener}, {@link onRemoteVideoStatsListener},
887
+ * {@link onRemoteAudioStatsListener}, {@link onLocalAudioStatsListener} and {@link onLocalVideoStatsListener}
888
+ *
889
+ * - These listeners get various dataPoints for current peers and their connectivity to the room
890
+ * such as jitter, latency etc.
891
+ *
892
+ * - currently available for iOS only
893
+ *
894
+ * @memberof HMSSDK
895
+ */
896
+ enableRTCStats = () => {
897
+ logger?.verbose('#Function enableRTCStats', { id: this.id });
898
+ if (Platform.OS === 'ios') {
899
+ HmsManager.enableRTCStats({ id: this.id });
900
+ } else {
901
+ console.log('API currently not avaialble for android');
902
+ }
903
+ };
904
+
905
+ /**
906
+ * - disable RTCStats sets the same boolean to false that was set true by enableRTCStats.
907
+ * that activates a check which filters out the events acquired in native listeners and don't
908
+ * let them pass through bridge
909
+ *
910
+ * - currently available for iOS only.
911
+ * @memberof HMSSDK
912
+ */
913
+ disableRTCStats = () => {
914
+ logger?.verbose('#Function disableRTCStats', { id: this.id });
915
+ if (Platform.OS === 'ios') {
916
+ HmsManager.disableRTCStats({ id: this.id });
917
+ } else {
918
+ console.log('API currently not avaialble for android');
919
+ }
463
920
  };
464
921
 
465
922
  /**
466
923
  * - This is a prototype event listener that takes action and listens for updates related to that particular action
467
- * - This method will be @deprecated in future and event listener will be passed in join method
468
924
  *
469
925
  * @param {string} action
470
926
  * @param {*} callback
@@ -515,13 +971,27 @@ export class HMSSDK {
515
971
  case HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM:
516
972
  this.onRemovedFromRoomDelegate = callback;
517
973
  break;
974
+ case HMSUpdateListenerActions.ON_RTC_STATS:
975
+ this.onRtcStatsDelegate = callback;
976
+ break;
977
+ case HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS:
978
+ this.onLocalAudioStatsDelegate = callback;
979
+ break;
980
+ case HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS:
981
+ this.onLocalVideoStatsDelegate = callback;
982
+ break;
983
+ case HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS:
984
+ this.onRemoteAudioStatsDelegate = callback;
985
+ break;
986
+ case HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS:
987
+ this.onRemoteVideoStatsDelegate = callback;
988
+ break;
518
989
  default:
519
990
  }
520
991
  };
521
992
 
522
993
  /**
523
994
  * - This is a prototype event listener that takes action and listens for updates related to that particular action
524
- * - This method will be @deprecated in future and event listener will be passed in join method
525
995
  *
526
996
  * @param {string} action
527
997
  * @param {*} callback
@@ -569,6 +1039,21 @@ export class HMSSDK {
569
1039
  case HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM:
570
1040
  this.onRemovedFromRoomDelegate = null;
571
1041
  break;
1042
+ case HMSUpdateListenerActions.ON_RTC_STATS:
1043
+ this.onRtcStatsDelegate = null;
1044
+ break;
1045
+ case HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS:
1046
+ this.onLocalAudioStatsDelegate = null;
1047
+ break;
1048
+ case HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS:
1049
+ this.onLocalVideoStatsDelegate = null;
1050
+ break;
1051
+ case HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS:
1052
+ this.onRemoteAudioStatsDelegate = null;
1053
+ break;
1054
+ case HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS:
1055
+ this.onRemoteVideoStatsDelegate = null;
1056
+ break;
572
1057
  default:
573
1058
  }
574
1059
  };
@@ -596,6 +1081,21 @@ export class HMSSDK {
596
1081
  logger?.verbose('#Function REMOVE_ALL_LISTENER', { id: this.id });
597
1082
  };
598
1083
 
1084
+ /**
1085
+ * - Below are all the listeners that are connected to native side.
1086
+ *
1087
+ * - All of the are connected when build function is called, we can connect them to the app by
1088
+ * calling {@link addEventListener} with corresponding event type.
1089
+ *
1090
+ * - Before passing the data to the eventListener of the app these listeners encode the data in
1091
+ * ts classes for a proper structuring of the data.
1092
+ *
1093
+ * - Even When event listeners of the app are disconnected using {@link removeEventListener} or
1094
+ * {@link removeAllListeners} or not even connected in first place, these functions still run to
1095
+ * maintain the current state of the instance of {@link HMSSDK}.
1096
+ *
1097
+ */
1098
+
599
1099
  onPreviewListener = (data: any) => {
600
1100
  if (data.id !== this.id) {
601
1101
  return;
@@ -723,7 +1223,7 @@ export class HMSSDK {
723
1223
  this.id
724
1224
  );
725
1225
  if (this.muteStatus && data?.type === 'TRACK_ADDED') {
726
- this.muteAllPeersAudio(this.muteStatus);
1226
+ this.setPlaybackForAllAudio(this.muteStatus);
727
1227
  }
728
1228
  this.room = room;
729
1229
  this.localPeer = localPeer;
@@ -760,7 +1260,7 @@ export class HMSSDK {
760
1260
  logger?.verbose('#Listener ON_SPEAKER', data);
761
1261
  if (this.onSpeakerDelegate) {
762
1262
  logger?.verbose('#Listener ON_SPEAKER_LISTENER_CALL', data);
763
- this.onSpeakerDelegate(data);
1263
+ this.onSpeakerDelegate(HMSEncoder.encodeHmsSpeakerUpdate(data, this.id));
764
1264
  }
765
1265
  };
766
1266
 
@@ -853,4 +1353,92 @@ export class HMSSDK {
853
1353
  this.onReconnectedDelegate(data);
854
1354
  }
855
1355
  };
1356
+
1357
+ RTCStatsListener = (data: any) => {
1358
+ if (data.id !== this.id) {
1359
+ return;
1360
+ }
1361
+
1362
+ logger?.verbose('#Listener RTCStatsListener', data);
1363
+
1364
+ let rtcStats = HMSEncoder.encodeRTCStats(data);
1365
+
1366
+ if (this.onRtcStatsDelegate) {
1367
+ this.onRtcStatsDelegate({ rtcStats });
1368
+ }
1369
+ };
1370
+
1371
+ onLocalAudioStatsListener = (data: any) => {
1372
+ if (data.id !== this.id) {
1373
+ return;
1374
+ }
1375
+
1376
+ logger?.verbose('#Listener onLocalAudioStatsListener', data);
1377
+
1378
+ let localAudioStats = new HMSLocalAudioStats(data.localAudioStats);
1379
+ let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1380
+ let track = HMSEncoder.encodeHmsLocalAudioTrack(data.track, this.id);
1381
+
1382
+ if (this.onLocalAudioStatsDelegate) {
1383
+ this.onLocalAudioStatsDelegate({ ...data, localAudioStats, peer, track });
1384
+ }
1385
+ };
1386
+
1387
+ onLocalVideoStatsListener = (data: any) => {
1388
+ if (data.id !== this.id) {
1389
+ return;
1390
+ }
1391
+
1392
+ logger?.verbose('#Listener onLocalVideoStatsListener', data);
1393
+
1394
+ let localVideoStats = new HMSLocalVideoStats(data.localVideoStats);
1395
+ let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1396
+ let track = HMSEncoder.encodeHmsLocalVideoTrack(data.track, this.id);
1397
+
1398
+ if (this.onLocalVideoStatsDelegate) {
1399
+ this.onLocalVideoStatsDelegate({ ...data, localVideoStats, peer, track });
1400
+ }
1401
+ };
1402
+
1403
+ onRemoteAudioStatsListener = (data: any) => {
1404
+ if (data.id !== this.id) {
1405
+ return;
1406
+ }
1407
+
1408
+ logger?.verbose('#Listener onRemoteAudioStatsListener', data);
1409
+
1410
+ let remoteAudioStats = new HMSRemoteAudioStats(data.remoteAudioStats);
1411
+ let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1412
+ let track = HMSEncoder.encodeHmsRemoteAudioTrack(data.track, this.id);
1413
+
1414
+ if (this.onRemoteAudioStatsDelegate) {
1415
+ this.onRemoteAudioStatsDelegate({
1416
+ ...data,
1417
+ remoteAudioStats,
1418
+ peer,
1419
+ track,
1420
+ });
1421
+ }
1422
+ };
1423
+
1424
+ onRemoteVideoStatsListener = (data: any) => {
1425
+ if (data.id !== this.id) {
1426
+ return;
1427
+ }
1428
+
1429
+ logger?.verbose('#Listener onRemoteVideoStatsListener', data);
1430
+
1431
+ let remoteVideoStats = new HMSRemoteVideoStats(data.remoteVideoStats);
1432
+ let peer = HMSEncoder.encodeHmsPeer(data.peer, this.id);
1433
+ let track = HMSEncoder.encodeHmsRemoteVideoTrack(data.track, this.id);
1434
+
1435
+ if (this.onRemoteVideoStatsDelegate) {
1436
+ this.onRemoteVideoStatsDelegate({
1437
+ ...data,
1438
+ remoteVideoStats,
1439
+ peer,
1440
+ track,
1441
+ });
1442
+ }
1443
+ };
856
1444
  }