@100mslive/react-native-hms 0.9.1 → 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 (90) hide show
  1. package/README.md +239 -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/build.gradle +1 -1
  10. package/android/src/main/java/com/reactnativehmssdk/HmsDecoder.kt +10 -0
  11. package/android/src/main/java/com/reactnativehmssdk/HmsHelper.kt +27 -1
  12. package/android/src/main/java/com/reactnativehmssdk/HmsModule.kt +2 -2
  13. package/android/src/main/java/com/reactnativehmssdk/HmsSDK.kt +34 -5
  14. package/android/src/main/java/com/reactnativehmssdk/HmsScreenshareActivity.kt +11 -0
  15. package/ios/HmsDecoder.swift +35 -2
  16. package/ios/HmsHelper.swift +14 -0
  17. package/ios/HmsSDK.swift +4 -3
  18. package/lib/commonjs/classes/HMSEncoder.js +17 -1
  19. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  20. package/lib/commonjs/classes/HMSHLSConfig.js +3 -0
  21. package/lib/commonjs/classes/HMSHLSConfig.js.map +1 -1
  22. package/lib/commonjs/classes/HMSHLSRecordingConfig.js +23 -0
  23. package/lib/commonjs/classes/HMSHLSRecordingConfig.js.map +1 -0
  24. package/lib/commonjs/classes/HMSHLSRecordingState.js +29 -0
  25. package/lib/commonjs/classes/HMSHLSRecordingState.js.map +1 -0
  26. package/lib/commonjs/classes/HMSLogger.js +21 -21
  27. package/lib/commonjs/classes/HMSLogger.js.map +1 -1
  28. package/lib/commonjs/classes/HMSMessage.js +4 -1
  29. package/lib/commonjs/classes/HMSMessage.js.map +1 -1
  30. package/lib/commonjs/classes/HMSMessageRecipient.js +26 -0
  31. package/lib/commonjs/classes/HMSMessageRecipient.js.map +1 -0
  32. package/lib/commonjs/classes/HMSMessageRecipientType.js +15 -0
  33. package/lib/commonjs/classes/HMSMessageRecipientType.js.map +1 -0
  34. package/lib/commonjs/classes/HMSPeerUpdate.js +0 -8
  35. package/lib/commonjs/classes/HMSPeerUpdate.js.map +1 -1
  36. package/lib/commonjs/classes/HMSRoom.js +3 -0
  37. package/lib/commonjs/classes/HMSRoom.js.map +1 -1
  38. package/lib/commonjs/classes/HMSSDK.js +16 -3
  39. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  40. package/lib/commonjs/index.js +56 -0
  41. package/lib/commonjs/index.js.map +1 -1
  42. package/lib/module/classes/HMSEncoder.js +16 -1
  43. package/lib/module/classes/HMSEncoder.js.map +1 -1
  44. package/lib/module/classes/HMSHLSConfig.js +3 -0
  45. package/lib/module/classes/HMSHLSConfig.js.map +1 -1
  46. package/lib/module/classes/HMSHLSRecordingConfig.js +14 -0
  47. package/lib/module/classes/HMSHLSRecordingConfig.js.map +1 -0
  48. package/lib/module/classes/HMSHLSRecordingState.js +20 -0
  49. package/lib/module/classes/HMSHLSRecordingState.js.map +1 -0
  50. package/lib/module/classes/HMSLogger.js +21 -21
  51. package/lib/module/classes/HMSLogger.js.map +1 -1
  52. package/lib/module/classes/HMSMessage.js +4 -1
  53. package/lib/module/classes/HMSMessage.js.map +1 -1
  54. package/lib/module/classes/HMSMessageRecipient.js +17 -0
  55. package/lib/module/classes/HMSMessageRecipient.js.map +1 -0
  56. package/lib/module/classes/HMSMessageRecipientType.js +8 -0
  57. package/lib/module/classes/HMSMessageRecipientType.js.map +1 -0
  58. package/lib/module/classes/HMSPeerUpdate.js +0 -8
  59. package/lib/module/classes/HMSPeerUpdate.js.map +1 -1
  60. package/lib/module/classes/HMSRoom.js +3 -0
  61. package/lib/module/classes/HMSRoom.js.map +1 -1
  62. package/lib/module/classes/HMSSDK.js +16 -3
  63. package/lib/module/classes/HMSSDK.js.map +1 -1
  64. package/lib/module/index.js +4 -0
  65. package/lib/module/index.js.map +1 -1
  66. package/lib/typescript/classes/HMSEncoder.d.ts +2 -0
  67. package/lib/typescript/classes/HMSHLSConfig.d.ts +5 -2
  68. package/lib/typescript/classes/HMSHLSRecordingConfig.d.ts +8 -0
  69. package/lib/typescript/classes/HMSHLSRecordingState.d.ts +12 -0
  70. package/lib/typescript/classes/HMSMessage.d.ts +8 -4
  71. package/lib/typescript/classes/HMSMessageRecipient.d.ts +13 -0
  72. package/lib/typescript/classes/HMSMessageRecipientType.d.ts +5 -0
  73. package/lib/typescript/classes/HMSPeerUpdate.d.ts +1 -9
  74. package/lib/typescript/classes/HMSRoom.d.ts +3 -0
  75. package/lib/typescript/classes/HMSSDK.d.ts +294 -7
  76. package/lib/typescript/index.d.ts +4 -0
  77. package/package.json +1 -1
  78. package/react-native-hms.podspec +1 -1
  79. package/src/classes/HMSEncoder.ts +47 -16
  80. package/src/classes/HMSHLSConfig.ts +8 -2
  81. package/src/classes/HMSHLSRecordingConfig.ts +9 -0
  82. package/src/classes/HMSHLSRecordingState.ts +18 -0
  83. package/src/classes/HMSLogger.ts +3 -3
  84. package/src/classes/HMSMessage.ts +11 -5
  85. package/src/classes/HMSMessageRecipient.ts +19 -0
  86. package/src/classes/HMSMessageRecipientType.ts +5 -0
  87. package/src/classes/HMSPeerUpdate.ts +0 -8
  88. package/src/classes/HMSRoom.ts +4 -0
  89. package/src/classes/HMSSDK.tsx +297 -8
  90. package/src/index.ts +4 -0
package/README.md CHANGED
@@ -19,6 +19,16 @@
19
19
 
20
20
  React native wrapper for 100ms SDK
21
21
 
22
+ ## Run Example App
23
+
24
+ To run the example app on your system, follow these steps -
25
+
26
+ 1. In the project root, run `npm install`
27
+ 2. Go to the example folder, `cd example`
28
+ 3. In the example folder, run `npm install`
29
+ 4. To run on Android, run `npx react-native run-android`
30
+ 5. To run on iOS, first install the pods in iOS folder, `cd ios; pod install`. Then, in example folder, run `npx react-native run-ios`
31
+
22
32
  ## Installation
23
33
 
24
34
  ```bash
@@ -62,7 +72,7 @@ We suggest using [react-native-permission](https://www.npmjs.com/package/react-n
62
72
 
63
73
  The package exports all the classes and a HMSSDK class that manages everything.
64
74
 
65
- # Setting up the HMS Instance:
75
+ ## Setting up the HMS Instance
66
76
 
67
77
  first we'll have to call build method, that method returns an instance of HMSSDK class and the same is used to perform all the operations
68
78
 
@@ -76,7 +86,7 @@ const hmsInstance = await HMSSDK.build();
76
86
  ...
77
87
  ```
78
88
 
79
- # Add event listeners
89
+ ## Add event listeners
80
90
 
81
91
  add event listeners for all the events such as onPreview, onJoin, onPeerUpdate etc. the actions can be found in HMSUpdateListenerActions class
82
92
 
@@ -95,7 +105,16 @@ hmsInstance.addEventListener(
95
105
 
96
106
  The event handlers are the way of handling any update happening in hms all events can be found in HMSUpdateListenerActions class
97
107
 
98
- # Join the room
108
+ ## Error handling
109
+
110
+ ```js
111
+ import { HMSUpdateListenerActions } from '@100mslive/react-native-hms';
112
+
113
+ // add an error event listener
114
+ hmsInstance.addEventListener(HMSUpdateListenerActions.ON_ERROR, onError);
115
+ ```
116
+
117
+ ## Join the room
99
118
 
100
119
  Joining the room connects you to the remote peer and broadcasts your stream to other peers, we need instance of HMSConfig in order to pass the details of room and user to join function
101
120
 
@@ -115,7 +134,23 @@ hmsInstance.join(HmsConfig); // to join a room
115
134
 
116
135
  don't forget to add ON_JOIN listener before calling join to receive an event callback
117
136
 
118
- # Viewing the video of a peer
137
+ ## Calling various functions of HMS
138
+
139
+ ```js
140
+ // Mute Audio
141
+ hmsInstance?.localPeer?.localAudioTrack()?.setMute(true);
142
+
143
+ // Stop Video
144
+ hmsInstance?.localPeer?.localVideoTrack()?.setMute(true);
145
+
146
+ // Switch Camera
147
+ hmsInstance?.localPeer?.localVideoTrack()?.switchCamera();
148
+
149
+ // Leave the call (async function)
150
+ await hmsInstance?.leave();
151
+ ```
152
+
153
+ ## Viewing the video of a peer
119
154
 
120
155
  To display a video on screen the package provide a UI component named HmsView that takes the video track ID and displays the video in that component, this component requires on _width_ and _height_ in _style_ prop to set bounds of the tile that will show the video stream
121
156
 
@@ -141,7 +176,7 @@ remotePeers.map((remotePeer: HMSRemotePeer) => {
141
176
  ...
142
177
  ```
143
178
 
144
- # Display a video in HmsView
179
+ ## Display a video in HmsView
145
180
 
146
181
  ```js
147
182
  import { HMSVideoViewMode } from '@100mslive/react-native-hms';
@@ -165,23 +200,44 @@ const styles = StyleSheet.create({
165
200
  ...
166
201
  ```
167
202
 
168
- # Calling various functions of HMS
203
+ ## Mute/Unmute others
169
204
 
170
205
  ```js
171
- // Mute Audio
172
- hmsInstance?.localPeer?.localAudioTrack()?.setMute(true);
206
+ const mute: boolean = true;
173
207
 
174
- // Stop Video
175
- hmsInstance?.localPeer?.localVideoTrack()?.setMute(true);
208
+ // hms instance acquired by build methodhmsInstance?.changeTrackState(audioTrack as HMSTrack, mute);
209
+ hmsInstance?.changeTrackState(videoTrack as HMSTrack, mute);
176
210
 
177
- // Switch Camera
178
- hmsInstance?.localPeer?.localVideoTrack()?.switchCamera();
211
+ const unmute: boolean = false;
179
212
 
180
- // Leave the call (async function)
181
- await hmsInstance?.leave();
213
+ hmsInstance?.changeTrackState(audioTrack as HMSTrack, unmute);
214
+ hmsInstance?.changeTrackState(videoTrack as HMSTrack, unmute);
182
215
  ```
183
216
 
184
- # Sending messages
217
+ ## End Room for all
218
+
219
+ ```js
220
+ const reason = 'Host ended the room';
221
+ const lock = false; // optional parameter
222
+
223
+ // hms instance acquired by build method
224
+ hmsInstance.endRoom(reason, lock);
225
+ ```
226
+
227
+ ## Remove Peer
228
+
229
+ ```js
230
+ import { HMSPeer } from '@100mslive/react-native-hms';
231
+
232
+ const reason = 'removed from room';
233
+
234
+ // hms instance acquired by build method
235
+ const peer: HMSPeer = hmsInstance?.remotePeers[0];
236
+
237
+ hmsInstance.removePeer(peer, reason);
238
+ ```
239
+
240
+ ## Sending messages
185
241
 
186
242
  ```js
187
243
  import { HMSRole, HMSPeer } from '@100mslive/react-native-hms';
@@ -197,20 +253,177 @@ hmsInstance?.sendGroupMessage(message, [role[0]);
197
253
  hmsInstance?.sendDirectMessage(message, peer);
198
254
  ```
199
255
 
200
- # Error handling
256
+ ## Role Change
201
257
 
202
258
  ```js
203
- import { HMSUpdateListenerActions } from '@100mslive/react-native-hms';
259
+ import { HMSRole, HMSRemotePeer } from '@100mslive/react-native-hms';
260
+ // hms instance acquired by build method
261
+ const roles: HMSRole[] = hmsInstance?.knownRoles;
262
+ const newRole: HMSRole = roles[0];
204
263
 
205
- // add an error event listener
206
- hmsInstance.addEventListener(HMSUpdateListenerActions.ON_ERROR, onError);
264
+ // can any remote peer
265
+ const peer: HMSRemotePeer = hmsInstance?.remotePeers[0];
266
+
267
+ const force = false;
268
+
269
+ hmsInstance.changeRole(peer, newRole, force); // request role change
270
+ hmsInstance.changeRole(peer, newRole, !force); // force role change
207
271
  ```
208
272
 
209
- # Run Example App
210
- To run the example app on your system, follow these steps -
211
- 1. In the project root, run `npm install`
212
- 2. Go to the example folder, `cd example`
213
- 3. In the example folder, run `npm install`
214
- 4. To run on Android, run `npx react-native run-android`
215
- 5. To run on iOS, first install the pods in iOS folder, `cd ios; pod install`. Then, in example folder, run `npx react-native run-ios`
273
+ ## Raise Hand & BRB
274
+
275
+ ```js
276
+ const parsedMetadata = JSON.parse(hmsInstance?.localPeer?.metadata);
277
+
278
+ // Raise Hand
279
+ // hms instance acquired by build method
280
+ hmsInstance?.changeMetadata(
281
+ JSON.stringify({
282
+ ...parsedMetadata,
283
+ isHandRaised: true,
284
+ })
285
+ );
286
+
287
+ // BRB
288
+ // hms instance acquired by build method
289
+ hmsInstance?.changeMetadata(
290
+ JSON.stringify({
291
+ ...parsedMetadata,
292
+ isBRBOn: true,
293
+ })
294
+ );
295
+ ```
296
+
297
+ ## HLS Streaming
298
+
299
+ ```js
300
+ import {
301
+ HMSHLSMeetingURLVariant,
302
+ HMSHLSConfig,
303
+ } from '@100mslive/react-native-hms';
304
+
305
+ const startHLSStreaming = () => {
306
+ const hmsHLSMeetingURLVariant = new HMSHLSMeetingURLVariant({
307
+ meetingUrl:
308
+ 'https://yogi.app.100ms.live/preview/nih-bkn-vek?token=beam_recording',
309
+ metadata: '',
310
+ });
311
+
312
+ const hmsHLSConfig = new HMSHLSConfig({
313
+ meetingURLVariants: [hlsStreamingDetails],
314
+ });
315
+
316
+ // hms instance acquired by build method
317
+ hmsInstance
318
+ .startHLSStreaming(hmsHLSConfig)
319
+ .then((r) => console.log(r))
320
+ .catch((e) => console.log(e));
321
+ };
322
+ ```
323
+
324
+ ## Start Streaming / Recording
325
+
326
+ ```js
327
+ import { HMSRTMPConfig } from '@100mslive/react-native-hms';
328
+
329
+ const recordingDetails = HMSRTMPConfig({
330
+ record: true,
331
+ meetingURL: roomID + '/viewer?token=beam_recording',
332
+ rtmpURLs: [],
333
+ });
334
+
335
+ // hms instance acquired by build method
336
+ const result = await hmsInstance?.startRTMPOrRecording(recordingDetails);
337
+ ```
338
+
339
+ ## Get RTC Stats
340
+
341
+ ```js
342
+ // hms instance acquired by build method
343
+ hmsInstance?.enableRTCStats();
344
+ ```
345
+
346
+ ## Screenshare
347
+
348
+ ```js
349
+ // hms instance acquired by build method
350
+ hmsInstance?.startScreenshare();
351
+ ```
352
+
353
+ ## Getting Audio Levels for all speaking peers
354
+
355
+ ```js
356
+ import {
357
+ HMSUpdateListenerActions,
358
+ HMSSpeakerUpdate,
359
+ HMSSpeaker,
360
+ } from '@100mslive/react-native-hms';
361
+
362
+ // hms instance acquired by build method
363
+ hmsInstance?.addEventListener(HMSUpdateListenerActions.ON_SPEAKER, onSpeaker);
364
+
365
+ const onSpeaker = (data: HMSSpeakerUpdate) => {
366
+ data?.peers?.map((speaker: HMSSpeaker) =>
367
+ console.log('speaker audio level: ', speaker?.level)
368
+ );
369
+ };
370
+ ```
371
+
372
+ ## Local mute others
373
+
374
+ ```js
375
+ const remotePeer: HMSRemotePeer;
376
+ const isAudioPlaybackAllowed = remotePeer.remoteAudioTrack().setPlaybackAllowed(false);
377
+ const isVideoPlaybackAllowed = remotePeer.remoteVideoTrack().setPlaybackAllowed(true);
378
+
379
+ // hms instance acquired by build method
380
+ hmsInstance.muteAllPeersAudio(true) // mute
381
+ hmsInstance.muteAllPeersAudio(false) // unmute
382
+ ```
216
383
 
384
+ ## Locally Set Volume
385
+
386
+ ```js
387
+ const volume: Float = 1.0;
388
+ const track: HMSTrack = remotePeer.audioTrack as HMSTrack;
389
+
390
+ // hms instance acquired by build method
391
+ hmsInstance?.setVolume(track, volume);
392
+ ```
393
+
394
+ ## Change name
395
+
396
+ ```js
397
+ const newName: string = 'new name';
398
+
399
+ // hms instance acquired by build method
400
+ hmsInstance.changeName(newName);
401
+ ```
402
+
403
+ ## Join with specific Track Settings
404
+
405
+ ```js
406
+ const getTrackSettings = () => {
407
+ let audioSettings = new HMSAudioTrackSettings({
408
+ maxBitrate: 32,
409
+ trackDescription: 'Simple Audio Track',
410
+ });
411
+ let videoSettings = new HMSVideoTrackSettings({
412
+ codec: HMSVideoCodec.vp8,
413
+ maxBitrate: 512,
414
+ maxFrameRate: 25,
415
+ cameraFacing: HMSCameraFacing.FRONT,
416
+ trackDescription: 'Simple Video Track',
417
+ resolution: new HMSVideoResolution({ height: 180, width: 320 }),
418
+ });
419
+
420
+ return new HMSTrackSettings({ video: videoSettings, audio: audioSettings });
421
+ };
422
+
423
+ const setupBuild = async () => {
424
+ const trackSettings = getTrackSettings();
425
+ const build = await HmsManager.build({ trackSettings });
426
+ setInstance(build);
427
+ updateHms({ hmsInstance: build });
428
+ };
429
+ ```
@@ -63,7 +63,7 @@ dependencies {
63
63
  //noinspection GradleDynamicVersion
64
64
  implementation "com.facebook.react:react-native:+"
65
65
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // From node_modules
66
- implementation 'com.github.100mslive.android-sdk:lib:2.3.1'
66
+ implementation 'com.github.100mslive.android-sdk:lib:2.3.4'
67
67
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
68
68
  implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
69
69
  implementation 'androidx.appcompat:appcompat:1.3.1'
@@ -498,4 +498,14 @@ object HmsDecoder {
498
498
  }
499
499
  return decodedTracks
500
500
  }
501
+
502
+ fun getHmsMessageRecipient(recipient: HMSMessageRecipient?): WritableMap {
503
+ val hmsRecipient: WritableMap = Arguments.createMap()
504
+ if (recipient != null) {
505
+ hmsRecipient.putMap("recipientPeer", this.getHmsPeer(recipient.recipientPeer))
506
+ hmsRecipient.putArray("recipientRoles", this.getAllRoles(recipient.recipientRoles))
507
+ hmsRecipient.putString("recipientType", recipient.recipientType.name)
508
+ }
509
+ return hmsRecipient
510
+ }
501
511
  }
@@ -107,7 +107,7 @@ object HmsHelper {
107
107
 
108
108
  fun getTrackFromTrackId(trackId: String?, room: HMSRoom?): HMSTrack? {
109
109
  if (trackId != null && room != null) {
110
- HmsUtilities.getTrack(trackId, room)
110
+ return HmsUtilities.getTrack(trackId, room)
111
111
  }
112
112
  return null
113
113
  }
@@ -270,6 +270,32 @@ object HmsHelper {
270
270
  return meetingURLVariants
271
271
  }
272
272
 
273
+ fun getHlsRecordingConfig(data: ReadableMap): HMSHlsRecordingConfig? {
274
+ if (areAllRequiredKeysAvailable(data, arrayOf(Pair("hlsRecordingConfig", "Map")))) {
275
+ val hmsHlsRecordingConfig = data.getMap("hlsRecordingConfig")
276
+ if (hmsHlsRecordingConfig != null) {
277
+ var singleFilePerLayer = false
278
+ var videoOnDemand = false
279
+ if (areAllRequiredKeysAvailable(
280
+ hmsHlsRecordingConfig,
281
+ arrayOf(Pair("singleFilePerLayer", "Boolean"))
282
+ )
283
+ ) {
284
+ singleFilePerLayer = hmsHlsRecordingConfig.getBoolean("singleFilePerLayer")
285
+ }
286
+ if (areAllRequiredKeysAvailable(
287
+ hmsHlsRecordingConfig,
288
+ arrayOf(Pair("videoOnDemand", "Boolean"))
289
+ )
290
+ ) {
291
+ videoOnDemand = hmsHlsRecordingConfig.getBoolean("videoOnDemand")
292
+ }
293
+ return HMSHlsRecordingConfig(singleFilePerLayer, videoOnDemand)
294
+ }
295
+ }
296
+ return null
297
+ }
298
+
273
299
  private fun getHMSHLSMeetingURLVariant(
274
300
  hmsMeetingURLVariant: HashMap<String, String>?
275
301
  ): HMSHLSMeetingURLVariant {
@@ -216,11 +216,11 @@ class HmsModule(reactContext: ReactApplicationContext) :
216
216
  }
217
217
 
218
218
  @ReactMethod
219
- fun startScreenshare(data: ReadableMap) {
219
+ fun startScreenshare(data: ReadableMap, callback: Promise?) {
220
220
  currentActivity?.application?.registerActivityLifecycleCallbacks(this)
221
221
  val hms = HmsHelper.getHms(data, hmsCollection)
222
222
 
223
- hms?.startScreenshare()
223
+ hms?.startScreenshare(callback)
224
224
  }
225
225
 
226
226
  @ReactMethod
@@ -26,8 +26,9 @@ class HmsSDK(
26
26
  reactApplicationContext: ReactApplicationContext
27
27
  ) {
28
28
  var hmsSDK: HMSSDK? = null
29
- private var recentRoleChangeRequest: HMSRoleChangeRequest? = null
29
+ var screenshareCallback: Promise? = null
30
30
  var delegate: HmsModule = HmsDelegate
31
+ private var recentRoleChangeRequest: HMSRoleChangeRequest? = null
31
32
  private var context: ReactApplicationContext = reactApplicationContext
32
33
  private var previewInProgress: Boolean = false
33
34
  private var id: String = sdkId
@@ -142,6 +143,16 @@ class HmsSDK(
142
143
  }
143
144
 
144
145
  override fun onPeerUpdate(type: HMSPeerUpdate, peer: HMSPeer) {
146
+ if (type === HMSPeerUpdate.AUDIO_TOGGLED ||
147
+ type === HMSPeerUpdate.VIDEO_TOGGLED ||
148
+ type === HMSPeerUpdate.BECAME_DOMINANT_SPEAKER ||
149
+ type === HMSPeerUpdate.NO_DOMINANT_SPEAKER ||
150
+ type === HMSPeerUpdate.RESIGNED_DOMINANT_SPEAKER ||
151
+ type === HMSPeerUpdate.STARTED_SPEAKING ||
152
+ type === HMSPeerUpdate.STOPPED_SPEAKING
153
+ ) {
154
+ return
155
+ }
145
156
  val updateType = type.name
146
157
  val roomData = HmsDecoder.getHmsRoom(hmsSDK?.getRoom())
147
158
  val localPeerData = HmsDecoder.getHmsLocalPeer(hmsSDK?.getLocalPeer())
@@ -295,6 +306,16 @@ class HmsSDK(
295
306
  }
296
307
 
297
308
  override fun onPeerUpdate(type: HMSPeerUpdate, peer: HMSPeer) {
309
+ if (type === HMSPeerUpdate.AUDIO_TOGGLED ||
310
+ type === HMSPeerUpdate.VIDEO_TOGGLED ||
311
+ type === HMSPeerUpdate.BECAME_DOMINANT_SPEAKER ||
312
+ type === HMSPeerUpdate.NO_DOMINANT_SPEAKER ||
313
+ type === HMSPeerUpdate.RESIGNED_DOMINANT_SPEAKER ||
314
+ type === HMSPeerUpdate.STARTED_SPEAKING ||
315
+ type === HMSPeerUpdate.STOPPED_SPEAKING
316
+ ) {
317
+ return
318
+ }
298
319
  val updateType = type.name
299
320
  val roomData = HmsDecoder.getHmsRoom(hmsSDK?.getRoom())
300
321
  val localPeerData = HmsDecoder.getHmsLocalPeer(hmsSDK?.getLocalPeer())
@@ -351,12 +372,12 @@ class HmsSDK(
351
372
  override fun onMessageReceived(message: HMSMessage) {
352
373
  val data: WritableMap = Arguments.createMap()
353
374
 
354
- data.putString("sender", message.sender.name)
375
+ data.putMap("sender", HmsDecoder.getHmsPeer(message.sender))
355
376
  data.putString("message", message.message)
356
377
  data.putString("type", message.type)
357
378
  data.putString("time", message.serverReceiveTime.toString())
358
379
  data.putString("id", id)
359
- data.putString("event", "ON_MESSAGE")
380
+ data.putMap("recipient", HmsDecoder.getHmsMessageRecipient(message.recipient))
360
381
 
361
382
  delegate.emitEvent("ON_MESSAGE", data)
362
383
  }
@@ -433,6 +454,7 @@ class HmsSDK(
433
454
  hmsSDK?.leave(
434
455
  object : HMSActionResultListener {
435
456
  override fun onSuccess() {
457
+ screenshareCallback = null
436
458
  callback?.resolve(emitHMSSuccess())
437
459
  }
438
460
 
@@ -891,6 +913,9 @@ class HmsSDK(
891
913
  }
892
914
  }
893
915
  }
916
+ this.emitCustomError("TRACKID_NOT_MATCHED")
917
+ } else {
918
+ this.emitCustomError("REMOTE_PEERS_NOT_FOUND")
894
919
  }
895
920
  } else {
896
921
  this.emitRequiredKeysError()
@@ -991,7 +1016,8 @@ class HmsSDK(
991
1016
  )
992
1017
  }
993
1018
 
994
- fun startScreenshare() {
1019
+ fun startScreenshare(callback: Promise?) {
1020
+ screenshareCallback = callback
995
1021
  runOnUiThread {
996
1022
  val intent = Intent(context, HmsScreenshareActivity::class.java)
997
1023
  intent.flags = FLAG_ACTIVITY_NEW_TASK
@@ -1008,10 +1034,12 @@ class HmsSDK(
1008
1034
  hmsSDK?.stopScreenshare(
1009
1035
  object : HMSActionResultListener {
1010
1036
  override fun onError(error: HMSException) {
1037
+ screenshareCallback = null
1011
1038
  callback?.reject(error.code.toString(), error.message)
1012
1039
  self.emitHMSError(error)
1013
1040
  }
1014
1041
  override fun onSuccess() {
1042
+ screenshareCallback = null
1015
1043
  callback?.resolve(emitHMSSuccess())
1016
1044
  }
1017
1045
  }
@@ -1025,7 +1053,8 @@ class HmsSDK(
1025
1053
  val meetingURLVariants =
1026
1054
  data.getArray("meetingURLVariants")?.toArrayList() as? ArrayList<HashMap<String, String>>
1027
1055
  val hlsMeetingUrlVariant = HmsHelper.getHMSHLSMeetingURLVariants(meetingURLVariants)
1028
- val config = HMSHLSConfig(hlsMeetingUrlVariant)
1056
+ val hlsRecordingConfig = HmsHelper.getHlsRecordingConfig(data)
1057
+ val config = HMSHLSConfig(hlsMeetingUrlVariant, hlsRecordingConfig)
1029
1058
 
1030
1059
  hmsSDK?.startHLSStreaming(
1031
1060
  config,
@@ -8,6 +8,8 @@ import android.os.Bundle
8
8
  import androidx.activity.ComponentActivity
9
9
  import androidx.activity.result.ActivityResultLauncher
10
10
  import androidx.activity.result.contract.ActivityResultContracts
11
+ import com.facebook.react.bridge.Arguments
12
+ import com.facebook.react.bridge.WritableMap
11
13
  import live.hms.video.error.HMSException
12
14
  import live.hms.video.sdk.HMSActionResultListener
13
15
 
@@ -21,15 +23,24 @@ class HmsScreenshareActivity : ComponentActivity() {
21
23
  object : HMSActionResultListener {
22
24
  override fun onError(error: HMSException) {
23
25
  finish()
26
+ HmsModule.hmsCollection[id]?.screenshareCallback?.reject(error)
24
27
  HmsModule.hmsCollection[id]?.emitHMSError(error)
25
28
  }
26
29
  override fun onSuccess() {
30
+ HmsModule.hmsCollection[id]?.screenshareCallback?.resolve(
31
+ HmsModule.hmsCollection[id]?.emitHMSSuccess()
32
+ )
27
33
  finish()
28
34
  }
29
35
  },
30
36
  mediaProjectionPermissionResultData
31
37
  )
32
38
  } else {
39
+ val id = intent.getStringExtra("id")
40
+ val data: WritableMap = Arguments.createMap()
41
+ data.putBoolean("success", true)
42
+ data.putString("message", "RESULT_CANCELED")
43
+ HmsModule.hmsCollection[id]?.screenshareCallback?.resolve(data)
33
44
  finish()
34
45
  }
35
46
  }
@@ -14,16 +14,19 @@ class HmsDecoder: NSObject {
14
14
  let rtmpStreamingState = HmsDecoder.getHMSRtmpStreamingState(hmsRoom?.rtmpStreamingState)
15
15
  let serverRecordingState = HmsDecoder.getHMSServerRecordingState(hmsRoom?.serverRecordingState)
16
16
  let hlsStreamingState = HmsDecoder.getHlsStreamingState(hmsRoom?.hlsStreamingState)
17
+ let hlsRecordingState = HmsDecoder.getHlsRecordingState(hmsRoom?.hlsRecordingState)
17
18
  var peers = [[String: Any]]()
18
19
 
19
20
  for peer in room.peers {
20
21
  peers.append(getHmsPeer(peer))
21
22
  }
22
23
 
23
- return ["id": id, "name": name, "metaData": metaData, "peers": peers, "browserRecordingState": browserRecordingState, "rtmpHMSRtmpStreamingState": rtmpStreamingState, "serverRecordingState": serverRecordingState, "hlsStreamingState": hlsStreamingState, "peerCount": count]
24
+ return ["id": id, "name": name, "metaData": metaData, "peers": peers, "browserRecordingState": browserRecordingState, "rtmpHMSRtmpStreamingState": rtmpStreamingState, "serverRecordingState": serverRecordingState, "hlsRecordingState": hlsRecordingState, "hlsStreamingState": hlsStreamingState, "peerCount": count]
24
25
  }
25
26
 
26
- static func getHmsPeer (_ peer: HMSPeer) -> [String: Any] {
27
+ static func getHmsPeer (_ hmsPeer: HMSPeer?) -> [String: Any] {
28
+
29
+ guard let peer = hmsPeer else { return [:] }
27
30
 
28
31
  let peerID = peer.peerID
29
32
  let name = peer.name
@@ -531,6 +534,19 @@ class HmsDecoder: NSObject {
531
534
  return [:]
532
535
  }
533
536
  }
537
+
538
+ static func getHlsRecordingState(_ data: HMSHLSRecordingState?) -> [String: Any] {
539
+ if let recordingState = data {
540
+ let running = recordingState.running
541
+ let startedAt = recordingState.startedAt?.timeIntervalSince1970 ?? 0
542
+ let singleFilePerLayer = recordingState.singleFilePerLayer
543
+ let enableVOD = recordingState.enableVOD
544
+
545
+ return ["running": running, "startedAt": startedAt * 1000, "singleFilePerLayer": singleFilePerLayer, "videoOnDemand": enableVOD]
546
+ } else {
547
+ return [:]
548
+ }
549
+ }
534
550
 
535
551
  static func getHMSHlsVariant(_ data: [HMSHLSVariant]?) -> [[String: Any]] {
536
552
  var variants = [[String: Any]]()
@@ -568,4 +584,21 @@ class HmsDecoder: NSObject {
568
584
  static func getRemoteVideoStats(_ data: HMSRemoteVideoStats) -> [String: Any] {
569
585
  return ["bitrate": data.bitrate, "packetsReceived": data.packetsReceived, "packetsLost": data.packetsLost, "bytesReceived": data.bytesReceived, "jitter": data.jitter, "resolution": HmsDecoder.getHmsVideoResolution(data.resolution), "frameRate": data.frameRate]
570
586
  }
587
+
588
+ static func getHmsMessageRecipient(_ recipient: HMSMessageRecipient) -> [String: Any] {
589
+ return ["recipientPeer": getHmsPeer(recipient.peerRecipient), "recipientRoles": getAllRoles(recipient.rolesRecipient), "type": self.getRecipientType(from: recipient.type)]
590
+ }
591
+
592
+ static private func getRecipientType(from recipientType: HMSMessageRecipientType) -> String {
593
+ switch recipientType {
594
+ case .broadcast:
595
+ return "BROADCAST"
596
+ case .peer:
597
+ return "PEER"
598
+ case .roles:
599
+ return "ROLES"
600
+ default:
601
+ return ""
602
+ }
603
+ }
571
604
  }
@@ -208,6 +208,20 @@ class HmsHelper: NSObject {
208
208
  }
209
209
  return hlsVariants
210
210
  }
211
+
212
+ static func getHlsRecordingConfig(_ data: NSDictionary) -> HMSHLSRecordingConfig? {
213
+ guard let meetingURLVariants = data.value(forKey: "hlsRecordingConfig") as? NSDictionary
214
+ else {
215
+ return nil
216
+ }
217
+ guard let singleFilePerLayer = meetingURLVariants.value(forKey: "singleFilePerLayer") as? Bool ,
218
+ let videoOnDemand = meetingURLVariants.value(forKey: "videoOnDemand") as? Bool
219
+ else {
220
+ return nil
221
+ }
222
+
223
+ return HMSHLSRecordingConfig(singleFilePerLayer: singleFilePerLayer, enableVOD: videoOnDemand)
224
+ }
211
225
 
212
226
  static func getHMSHLSMeetingURLVariant(_ variant: [String: Any]) -> HMSHLSMeetingURLVariant? {
213
227
  let meetingUrl = variant["meetingUrl"] as? String
package/ios/HmsSDK.swift CHANGED
@@ -643,9 +643,10 @@ class HmsSDK: HMSUpdateListener, HMSPreviewListener {
643
643
  delegate?.emitEvent(ON_ERROR, ["event": ON_ERROR, "error": HmsDecoder.getError(error), "id": id])
644
644
  return
645
645
  }
646
-
646
+
647
+ let recordConfig = HmsHelper.getHlsRecordingConfig(data)
647
648
  let hlsMeetingUrlVariant = HmsHelper.getHMSHLSMeetingURLVariants(meetingURLVariants)
648
- let config = HMSHLSConfig(variants: hlsMeetingUrlVariant)
649
+ let config = HMSHLSConfig(variants: hlsMeetingUrlVariant, recording: recordConfig)
649
650
 
650
651
  hms?.startHLSStreaming(config: config, completion: { success, error in
651
652
  if success {
@@ -801,7 +802,7 @@ class HmsSDK: HMSUpdateListener, HMSPreviewListener {
801
802
  }
802
803
 
803
804
  func on(message: HMSMessage) {
804
- self.delegate?.emitEvent(ON_MESSAGE, ["event": ON_MESSAGE, "id": self.id, "sender": message.sender?.name ?? "", "time": message.time, "message": message.message, "type": message.type])
805
+ self.delegate?.emitEvent(ON_MESSAGE, ["event": ON_MESSAGE, "id": self.id, "sender": HmsDecoder.getHmsPeer(message.sender), "recipient": HmsDecoder.getHmsMessageRecipient(message.recipient), "time": message.time.timeIntervalSince1970 * 1000, "message": message.message, "type": message.type])
805
806
  }
806
807
 
807
808
  func on(updated speakers: [HMSSpeaker]) {