@100mslive/react-native-hms 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +44 -29
  2. package/android/build.gradle +5 -1
  3. package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +23 -23
  4. package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +289 -32
  5. package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +649 -548
  6. package/android/src/main/java/com/reactnativehmssdk/PipActionReceiver.kt +66 -0
  7. package/android/src/main/res/drawable/ic_call_end_24.xml +10 -0
  8. package/android/src/main/res/drawable/ic_camera_toggle_off.xml +11 -0
  9. package/android/src/main/res/drawable/ic_camera_toggle_on.xml +10 -0
  10. package/android/src/main/res/drawable/ic_mic_24.xml +10 -0
  11. package/android/src/main/res/drawable/ic_mic_off_24.xml +10 -0
  12. package/ios/HMSDecoder.swift +3 -5
  13. package/ios/HMSHelper.swift +18 -12
  14. package/ios/HMSManager.m +2 -0
  15. package/ios/HMSManager.swift +15 -0
  16. package/ios/HMSRNSDK.swift +36 -0
  17. package/lib/commonjs/classes/HMSPIPListenerActions.js +12 -0
  18. package/lib/commonjs/classes/HMSPIPListenerActions.js.map +1 -0
  19. package/lib/commonjs/classes/HMSSDK.js +60 -7
  20. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  21. package/lib/commonjs/index.js +12 -0
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/module/classes/HMSPIPListenerActions.js +5 -0
  24. package/lib/module/classes/HMSPIPListenerActions.js.map +1 -0
  25. package/lib/module/classes/HMSSDK.js +60 -7
  26. package/lib/module/classes/HMSSDK.js.map +1 -1
  27. package/lib/module/index.js +1 -0
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/typescript/classes/HMSPIPListenerActions.d.ts +3 -0
  30. package/lib/typescript/classes/HMSSDK.d.ts +41 -2
  31. package/lib/typescript/index.d.ts +1 -0
  32. package/package.json +1 -1
  33. package/react-native-hms.podspec +2 -1
  34. package/src/classes/HMSPIPListenerActions.ts +3 -0
  35. package/src/classes/HMSSDK.tsx +111 -7
  36. package/src/index.ts +1 -0
@@ -0,0 +1,66 @@
1
+ package com.reactnativehmssdk
2
+
3
+ import android.app.Activity
4
+ import android.content.BroadcastReceiver
5
+ import android.content.Context
6
+ import android.content.Intent
7
+ import android.content.IntentFilter
8
+ import android.os.Build
9
+ import androidx.annotation.RequiresApi
10
+
11
+ data class PIPAction(val title: String, val description: String, val requestCode: Int)
12
+
13
+ data class PIPActions(val endMeet: PIPAction, val localAudio: PIPAction, val localVideo: PIPAction)
14
+
15
+ @RequiresApi(Build.VERSION_CODES.O)
16
+ class PipActionReceiver(
17
+ val toggleLocalAudio: () -> Unit,
18
+ val toggleLocalVideo: () -> Unit,
19
+ val endMeeting: () -> Unit
20
+ ) : BroadcastReceiver() {
21
+ companion object {
22
+ var sdkIdForPIP: String? = null
23
+ private var registered = false
24
+ const val PIP_INTENT_ACTION = "PIP_INTENT_ACTION"
25
+ val PIPActions = PIPActions(
26
+ endMeet = PIPAction(title = "End", description = "End Meeting", requestCode = 346),
27
+ localAudio = PIPAction(title = "Mic", description = "Toggle Mic", requestCode = 344),
28
+ localVideo = PIPAction(title = "Camera", description = "Toggle Camera", requestCode = 345)
29
+ )
30
+ }
31
+
32
+ override fun onReceive(context: Context?, intent: Intent?) {
33
+ if (intent !== null) {
34
+ if (intent.hasExtra(PIPActions.endMeet.title)) {
35
+ return endMeeting()
36
+ }
37
+ if (intent.hasExtra(PIPActions.localAudio.title)) {
38
+ return toggleLocalAudio()
39
+ }
40
+ if (intent.hasExtra(PIPActions.localVideo.title)) {
41
+ return toggleLocalVideo()
42
+ }
43
+ }
44
+ }
45
+
46
+ fun register(activity: Activity) {
47
+ if (registered) {
48
+ return
49
+ }
50
+
51
+ IntentFilter().also {
52
+ it.addAction(PIP_INTENT_ACTION)
53
+ activity.registerReceiver(this, it)
54
+ }
55
+ registered = true
56
+ }
57
+
58
+ fun unregister(activity: Activity) {
59
+ if (!registered) {
60
+ return
61
+ }
62
+
63
+ activity.unregisterReceiver(this)
64
+ registered = false
65
+ }
66
+ }
@@ -0,0 +1,10 @@
1
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:width="24dp"
3
+ android:height="24dp"
4
+ android:tint="?attr/colorControlNormal"
5
+ android:viewportWidth="24"
6
+ android:viewportHeight="24">
7
+ <path
8
+ android:fillColor="#D22B2B"
9
+ android:pathData="M12,9c-1.6,0 -3.15,0.25 -4.6,0.72v3.1c0,0.39 -0.23,0.74 -0.56,0.9 -0.98,0.49 -1.87,1.12 -2.66,1.85 -0.18,0.18 -0.43,0.28 -0.7,0.28 -0.28,0 -0.53,-0.11 -0.71,-0.29L0.29,13.08c-0.18,-0.17 -0.29,-0.42 -0.29,-0.7 0,-0.28 0.11,-0.53 0.29,-0.71C3.34,8.78 7.46,7 12,7s8.66,1.78 11.71,4.67c0.18,0.18 0.29,0.43 0.29,0.71 0,0.28 -0.11,0.53 -0.29,0.71l-2.48,2.48c-0.18,0.18 -0.43,0.29 -0.71,0.29 -0.27,0 -0.52,-0.11 -0.7,-0.28 -0.79,-0.74 -1.69,-1.36 -2.67,-1.85 -0.33,-0.16 -0.56,-0.5 -0.56,-0.9v-3.1C15.15,9.25 13.6,9 12,9z" />
10
+ </vector>
@@ -0,0 +1,11 @@
1
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:width="24dp"
3
+ android:height="24dp"
4
+ android:viewportWidth="24"
5
+ android:viewportHeight="24">
6
+ <path
7
+ android:pathData="M4.3515,3.2319C4.0423,2.9227 3.541,2.9227 3.2319,3.2319C2.9227,3.541 2.9227,4.0423 3.2319,4.3515L5.067,6.1866C4.5508,6.2541 4.0678,6.49 3.6956,6.8622C3.2502,7.3076 3,7.9117 3,8.5416V16.4583C3,17.0881 3.2502,17.6922 3.6956,18.1376C4.141,18.583 4.7451,18.8333 5.375,18.8333H14.0833C14.7132,18.8333 15.3173,18.583 15.7627,18.1376C15.9799,17.9204 16.1507,17.6655 16.2687,17.3883L20.6485,21.7681C20.9577,22.0773 21.459,22.0773 21.7681,21.7681C22.0773,21.459 22.0773,20.9577 21.7681,20.6485L16.233,15.1134C16.2308,15.1112 16.2287,15.109 16.2265,15.1068L7.5181,6.3985C7.5159,6.3963 7.5137,6.3941 7.5115,6.3919L4.3515,3.2319ZM6.6303,7.7499L14.875,15.9946V16.4583C14.875,16.6682 14.7916,16.8696 14.6431,17.018C14.4947,17.1665 14.2933,17.2499 14.0833,17.2499H5.375C5.165,17.2499 4.9637,17.1665 4.8152,17.018C4.6667,16.8696 4.5833,16.6682 4.5833,16.4583V8.5416C4.5833,8.3316 4.6667,8.1303 4.8152,7.9818C4.9637,7.8333 5.165,7.7499 5.375,7.7499H6.6303ZM11.4392,7.7499H14.0833C14.2933,7.7499 14.4947,7.8333 14.6431,7.9818C14.7916,8.1303 14.875,8.3316 14.875,8.5416V11.1858C14.875,11.3957 14.9584,11.5971 15.1069,11.7455L15.8985,12.5372C16.1735,12.8121 16.6073,12.8467 16.9223,12.6189L20.4167,10.0913V16.4583C20.4167,16.8955 20.7711,17.2499 21.2083,17.2499C21.6456,17.2499 22,16.8955 22,16.4583V8.5416C22,8.2442 21.8333,7.9719 21.5685,7.8366C21.3036,7.7013 20.9853,7.7258 20.7444,7.9001L16.541,10.9405L16.4583,10.8578V8.5416C16.4583,7.9117 16.2081,7.3076 15.7627,6.8622C15.3173,6.4168 14.7132,6.1666 14.0833,6.1666H11.4392C11.0019,6.1666 10.6475,6.521 10.6475,6.9583C10.6475,7.3955 11.0019,7.7499 11.4392,7.7499Z"
8
+ android:fillColor="#F5F9FF"
9
+ android:fillAlpha="0.95"
10
+ android:fillType="evenOdd"/>
11
+ </vector>
@@ -0,0 +1,10 @@
1
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:width="24dp"
3
+ android:height="24dp"
4
+ android:viewportWidth="24"
5
+ android:viewportHeight="24">
6
+ <path
7
+ android:pathData="M16.4583,10.7951V8.375C16.4583,7.0633 15.395,6 14.0833,6H5.375C4.0633,6 3,7.0633 3,8.375V16.2917C3,17.6033 4.0633,18.6667 5.375,18.6667H14.0833C15.395,18.6667 16.4583,17.6033 16.4583,16.2917V13.8718L20.7482,16.936C20.9895,17.1083 21.3069,17.1314 21.5706,16.9957C21.8343,16.86 22,16.5883 22,16.2917V8.3751C22,8.0785 21.8343,7.8068 21.5706,7.6712C21.3069,7.5355 20.9895,7.5585 20.7482,7.7309L16.4583,10.7951ZM4.5833,8.375C4.5833,7.9378 4.9378,7.5833 5.375,7.5833H14.0833C14.5206,7.5833 14.875,7.9378 14.875,8.375V16.2917C14.875,16.7289 14.5206,17.0833 14.0833,17.0833H5.375C4.9378,17.0833 4.5833,16.7289 4.5833,16.2917V8.375ZM20.4167,14.7534L17.0287,12.3334L20.4167,9.9134V14.7534Z"
8
+ android:fillColor="#ffffff"
9
+ android:fillType="evenOdd"/>
10
+ </vector>
@@ -0,0 +1,10 @@
1
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:width="24dp"
3
+ android:height="24dp"
4
+ android:viewportWidth="24"
5
+ android:viewportHeight="24"
6
+ android:tint="?attr/colorControlNormal">
7
+ <path
8
+ android:fillColor="@android:color/white"
9
+ android:pathData="M12,14c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6c0,1.66 1.34,3 3,3zM17.3,11c0,3 -2.54,5.1 -5.3,5.1S6.7,14 6.7,11L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c3.28,-0.48 6,-3.3 6,-6.72h-1.7z"/>
10
+ </vector>
@@ -0,0 +1,10 @@
1
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:width="24dp"
3
+ android:height="24dp"
4
+ android:viewportWidth="24"
5
+ android:viewportHeight="24"
6
+ android:tint="?attr/colorControlNormal">
7
+ <path
8
+ android:fillColor="@android:color/white"
9
+ android:pathData="M19,11h-1.7c0,0.74 -0.16,1.43 -0.43,2.05l1.23,1.23c0.56,-0.98 0.9,-2.09 0.9,-3.28zM14.98,11.17c0,-0.06 0.02,-0.11 0.02,-0.17L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v0.18l5.98,5.99zM4.27,3L3,4.27l6.01,6.01L9.01,11c0,1.66 1.33,3 2.99,3 0.22,0 0.44,-0.03 0.65,-0.08l1.66,1.66c-0.71,0.33 -1.5,0.52 -2.31,0.52 -2.76,0 -5.3,-2.1 -5.3,-5.1L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c0.91,-0.13 1.77,-0.45 2.54,-0.9L19.73,21 21,19.73 4.27,3z"/>
10
+ </vector>
@@ -344,8 +344,8 @@ class HMSDecoder: NSObject {
344
344
  let audio = getHmsAudioSettings(publishSettings.audio)
345
345
  let video = getHmsVideoSettings(publishSettings.video)
346
346
  let screen = getHmsVideoSettings(publishSettings.screen)
347
- let videoSimulcastLayers = getHmsSimulcastLayers(publishSettings.videoSimulcastLayers)
348
- let screenSimulcastLayers = getHmsSimulcastLayers(publishSettings.screenSimulcastLayers)
347
+ let videoSimulcastLayers = getHmsSimulcastLayers(publishSettings.simulcast?.video)
348
+ let screenSimulcastLayers = getHmsSimulcastLayers(publishSettings.simulcast?.screen)
349
349
  var allowed = publishSettings.allowed ?? []
350
350
  if (publishSettings.allowed) != nil {
351
351
  allowed = getWriteableArray(publishSettings.allowed)
@@ -417,11 +417,9 @@ class HMSDecoder: NSObject {
417
417
 
418
418
  guard let videoLayers = videoSimulcastLayers else { return [:] }
419
419
 
420
- let width = videoLayers.width ?? 0
421
- let height = videoLayers.height ?? 0
422
420
  let layers = getHmsSimulcastLayerSettingsPolicy(videoLayers.layers)
423
421
 
424
- return ["width": width, "height": height, "layers": layers]
422
+ return ["layers": layers]
425
423
  }
426
424
 
427
425
  static func getHmsSimulcastLayerSettingsPolicy(_ layers: [HMSSimulcastLayerSettingsPolicy]?) -> [[String: Any]] {
@@ -177,34 +177,40 @@ class HMSHelper: NSObject {
177
177
  }
178
178
  let initialState = settings?.value(forKey: "initialState") as? String
179
179
  let initialStateEncoded = HMSHelper.getHMSTrackSettingsInitState(initialState)
180
+
180
181
  if #available(iOS 13.0, *) {
181
- var audioMixerSourceMap = [String: HMSAudioNode]()
182
+ var audioMixerSourceMap: [String: HMSAudioNode]?
182
183
  if let playerNode = settings?.value(forKey: "audioSource") as? [String] {
184
+ audioMixerSourceMap = [String: HMSAudioNode]()
183
185
  for node in playerNode {
184
- if audioMixerSourceMap[node] == nil {
186
+ if audioMixerSourceMap?[node] == nil {
185
187
  if node == "mic_node" {
186
- audioMixerSourceMap["mic_node"] = HMSMicNode()
188
+ audioMixerSourceMap?["mic_node"] = HMSMicNode()
187
189
  } else if node == "screen_broadcast_audio_receiver_node" {
188
190
  do {
189
- audioMixerSourceMap["screen_broadcast_audio_receiver_node"] = try hms?.screenBroadcastAudioReceiverNode()
191
+ audioMixerSourceMap?["screen_broadcast_audio_receiver_node"] = try hms?.screenBroadcastAudioReceiverNode()
190
192
  } catch {
191
193
  delegate?.emitEvent("ON_ERROR", ["error": ["code": 6002, "description": error.localizedDescription, "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
192
194
  }
193
195
  } else {
194
- audioMixerSourceMap[node] = HMSAudioFilePlayerNode()
196
+ audioMixerSourceMap?[node] = HMSAudioFilePlayerNode()
195
197
  }
196
198
  }
197
199
  }
198
200
  }
199
- do {
200
- self.audioMixerSourceHashMap = audioMixerSourceMap
201
- let audioMixerSource = try HMSAudioMixerSource(nodes: audioMixerSourceMap.values.map {$0})
202
- return HMSAudioTrackSettings(maxBitrate: 32, trackDescription: "audio track description", initialMuteState: initialStateEncoded, audioSource: audioMixerSource)
203
- } catch {
204
- delegate?.emitEvent("ON_ERROR", ["error": ["code": 6002, "description": error.localizedDescription, "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
205
- return nil
201
+
202
+ if let audioMixerSourceMap = audioMixerSourceMap {
203
+ do {
204
+ self.audioMixerSourceHashMap = audioMixerSourceMap
205
+ let audioMixerSource = try HMSAudioMixerSource(nodes: audioMixerSourceMap.values.map {$0})
206
+ return HMSAudioTrackSettings(maxBitrate: 32, trackDescription: "audio track description", initialMuteState: initialStateEncoded, audioSource: audioMixerSource)
207
+ } catch {
208
+ delegate?.emitEvent("ON_ERROR", ["error": ["code": 6002, "description": error.localizedDescription, "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
209
+ return nil
210
+ }
206
211
  }
207
212
  }
213
+
208
214
  return HMSAudioTrackSettings(maxBitrate: 32, trackDescription: "audio track description", initialMuteState: initialStateEncoded, audioSource: nil)
209
215
  }
210
216
 
package/ios/HMSManager.m CHANGED
@@ -55,4 +55,6 @@ RCT_EXTERN_METHOD(enableNetworkQualityUpdates: (NSDictionary) data)
55
55
  RCT_EXTERN_METHOD(disableNetworkQualityUpdates: (NSDictionary) data)
56
56
  RCT_EXTERN_METHOD(setSessionMetaData: (NSDictionary) data :(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock) reject)
57
57
  RCT_EXTERN_METHOD(getSessionMetaData: (NSDictionary) data :(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock) reject)
58
+ RCT_EXTERN_METHOD(changeRoleOfPeer: (NSDictionary) data :(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock) reject)
59
+ RCT_EXTERN_METHOD(changeRoleOfPeersWithRoles: (NSDictionary) data :(RCTPromiseResolveBlock) resolve :(RCTPromiseRejectBlock) reject)
58
60
  @end
@@ -144,6 +144,7 @@ class HMSManager: RCTEventEmitter {
144
144
  hms?.acceptRoleChange(resolve, reject)
145
145
  }
146
146
 
147
+ @available(*, deprecated, message: "Use changeRoleOfPeer function")
147
148
  @objc
148
149
  func changeRole(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
149
150
  let hms = HMSHelper.getHms(data, hmsCollection)
@@ -151,6 +152,20 @@ class HMSManager: RCTEventEmitter {
151
152
  hms?.changeRole(data, resolve, reject)
152
153
  }
153
154
 
155
+ @objc
156
+ func changeRoleOfPeer(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
157
+ let hms = HMSHelper.getHms(data, hmsCollection)
158
+
159
+ hms?.changeRole(data, resolve, reject)
160
+ }
161
+
162
+ @objc
163
+ func changeRoleOfPeersWithRoles(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
164
+ let hms = HMSHelper.getHms(data, hmsCollection)
165
+
166
+ hms?.changeRolesOfAllPeers(data, resolve, reject)
167
+ }
168
+
154
169
  @objc
155
170
  func changeTrackState(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
156
171
  let hms = HMSHelper.getHms(data, hmsCollection)
@@ -352,6 +352,42 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
352
352
  }
353
353
  }
354
354
 
355
+ func changeRolesOfAllPeers(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
356
+
357
+ guard let toRoleString = data.object(forKey: "toRole") as? String
358
+ else {
359
+ let errorMessage = "changeRolesOfAllPeers: " + HMSHelper.getUnavailableRequiredKey(data, ["toRole"])
360
+ emitRequiredKeysError(errorMessage)
361
+ reject?(errorMessage, errorMessage, nil)
362
+ return
363
+ }
364
+
365
+ DispatchQueue.main.async { [weak self] in
366
+
367
+ guard let toRole = HMSHelper.getRoleFromRoleName(toRoleString, roles: self?.hms?.roles) else {
368
+ let errorMessage = "changeRolesOfAllPeers: " + HMSHelper.getUnavailableRequiredKey(data, ["toRole"])
369
+ self?.emitRequiredKeysError(errorMessage)
370
+ reject?(errorMessage, errorMessage, nil)
371
+ return
372
+ }
373
+
374
+ var limitToRoles: [HMSRole]?
375
+
376
+ if let ofRoleNames = data.object(forKey: "ofRoles") as? [String] {
377
+ limitToRoles = self?.hms?.roles.filter { ofRoleNames.contains($0.name) }
378
+ }
379
+
380
+ self?.hms?.changeRolesOfAllPeers(to: toRole, limitToRoles: limitToRoles) { success, error in
381
+ if success {
382
+ resolve?(["success": success])
383
+ } else {
384
+ self?.delegate?.emitEvent("ON_ERROR", ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
385
+ reject?(error?.localizedDescription, error?.localizedDescription, nil)
386
+ }
387
+ }
388
+ }
389
+ }
390
+
355
391
  func changeTrackState(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
356
392
 
357
393
  guard let trackId = data.value(forKey: "trackId") as? String
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.HMSPIPListenerActions = void 0;
7
+ let HMSPIPListenerActions;
8
+ exports.HMSPIPListenerActions = HMSPIPListenerActions;
9
+ (function (HMSPIPListenerActions) {
10
+ HMSPIPListenerActions["ON_PIP_ROOM_LEAVE"] = "ON_PIP_ROOM_LEAVE";
11
+ })(HMSPIPListenerActions || (exports.HMSPIPListenerActions = HMSPIPListenerActions = {}));
12
+ //# sourceMappingURL=HMSPIPListenerActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["HMSPIPListenerActions"],"sources":["HMSPIPListenerActions.ts"],"sourcesContent":["export enum HMSPIPListenerActions {\n ON_PIP_ROOM_LEAVE = 'ON_PIP_ROOM_LEAVE',\n}\n"],"mappings":";;;;;;IAAYA,qBAAqB;AAAA;AAAA,WAArBA,qBAAqB;EAArBA,qBAAqB;AAAA,GAArBA,qBAAqB,qCAArBA,qBAAqB"}
@@ -17,6 +17,7 @@ var _HMSTrackType = require("./HMSTrackType");
17
17
  var _HMSUpdateListenerActions = require("./HMSUpdateListenerActions");
18
18
  var _HmsView = require("./HmsView");
19
19
  var _HMSMessageType = require("./HMSMessageType");
20
+ var _HMSPIPListenerActions = require("./HMSPIPListenerActions");
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
23
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
@@ -55,6 +56,7 @@ class HMSSDK {
55
56
  _defineProperty(this, "onRemoteAudioStatsDelegate", void 0);
56
57
  _defineProperty(this, "onRemoteVideoStatsDelegate", void 0);
57
58
  _defineProperty(this, "onAudioDeviceChangedDelegate", void 0);
59
+ _defineProperty(this, "onPIPRoomLeaveDelegate", void 0);
58
60
  _defineProperty(this, "setLogger", hmsLogger => {
59
61
  (0, _HMSLogger.setLogger)(this.id, hmsLogger);
60
62
  });
@@ -87,6 +89,9 @@ class HMSSDK {
87
89
  HmsEventEmitter.addListener(_HMSUpdateListenerActions.HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS, this.onRemoteAudioStatsListener);
88
90
  HmsEventEmitter.addListener(_HMSUpdateListenerActions.HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS, this.onRemoteVideoStatsListener);
89
91
  HmsEventEmitter.addListener(_HMSUpdateListenerActions.HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED, this.onAudioDeviceChangedListener);
92
+ if (_reactNative.Platform.OS === 'android') {
93
+ HmsEventEmitter.addListener(_HMSPIPListenerActions.HMSPIPListenerActions.ON_PIP_ROOM_LEAVE, this.onPIPRoomLeaveListener);
94
+ }
90
95
  });
91
96
  _defineProperty(this, "removeListeners", () => {
92
97
  HmsEventEmitter.removeListener(_HMSUpdateListenerActions.HMSUpdateListenerActions.ON_JOIN, this.onJoinListener);
@@ -108,6 +113,9 @@ class HMSSDK {
108
113
  HmsEventEmitter.removeListener(_HMSUpdateListenerActions.HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS, this.onRemoteAudioStatsListener);
109
114
  HmsEventEmitter.removeListener(_HMSUpdateListenerActions.HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS, this.onRemoteVideoStatsListener);
110
115
  HmsEventEmitter.removeListener(_HMSUpdateListenerActions.HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED, this.onAudioDeviceChangedListener);
116
+ if (_reactNative.Platform.OS === 'android') {
117
+ HmsEventEmitter.removeListener(_HMSPIPListenerActions.HMSPIPListenerActions.ON_PIP_ROOM_LEAVE, this.onPIPRoomLeaveListener);
118
+ }
111
119
  });
112
120
  _defineProperty(this, "join", async config => {
113
121
  _HMSLogger.logger === null || _HMSLogger.logger === void 0 ? void 0 : _HMSLogger.logger.verbose('#Function join', {
@@ -274,6 +282,26 @@ class HMSSDK {
274
282
  _HMSLogger.logger === null || _HMSLogger.logger === void 0 ? void 0 : _HMSLogger.logger.verbose('#Function changeRole', data);
275
283
  return await HMSManager.changeRole(data);
276
284
  });
285
+ _defineProperty(this, "changeRoleOfPeer", async function (peer, role) {
286
+ let force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
287
+ const data = {
288
+ peerId: peer.peerID,
289
+ role: role.name,
290
+ force: force,
291
+ id: _this.id
292
+ };
293
+ _HMSLogger.logger === null || _HMSLogger.logger === void 0 ? void 0 : _HMSLogger.logger.verbose('#Function changeRoleOfPeer', data);
294
+ return HMSManager.changeRoleOfPeer(data);
295
+ });
296
+ _defineProperty(this, "changeRoleOfPeersWithRoles", async (ofRoles, toRole) => {
297
+ const data = {
298
+ ofRoles: ofRoles.map(ofRole => ofRole.name).filter(Boolean),
299
+ toRole: toRole.name,
300
+ id: this.id
301
+ };
302
+ _HMSLogger.logger === null || _HMSLogger.logger === void 0 ? void 0 : _HMSLogger.logger.verbose('#Function changeRoleOfPeersWithRoles', data);
303
+ return HMSManager.changeRoleOfPeersWithRoles(data);
304
+ });
277
305
  _defineProperty(this, "changeTrackState", async (track, mute) => {
278
306
  _HMSLogger.logger === null || _HMSLogger.logger === void 0 ? void 0 : _HMSLogger.logger.verbose('#Function changeTrackState', {
279
307
  track,
@@ -719,6 +747,9 @@ class HMSSDK {
719
747
  case _HMSUpdateListenerActions.HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED:
720
748
  this.onAudioDeviceChangedDelegate = callback;
721
749
  break;
750
+ case _HMSPIPListenerActions.HMSPIPListenerActions.ON_PIP_ROOM_LEAVE:
751
+ this.onPIPRoomLeaveDelegate = callback;
752
+ break;
722
753
  default:
723
754
  }
724
755
  });
@@ -785,6 +816,9 @@ class HMSSDK {
785
816
  case _HMSUpdateListenerActions.HMSUpdateListenerActions.ON_AUDIO_DEVICE_CHANGED:
786
817
  this.onAudioDeviceChangedDelegate = null;
787
818
  break;
819
+ case _HMSPIPListenerActions.HMSPIPListenerActions.ON_PIP_ROOM_LEAVE:
820
+ this.onPIPRoomLeaveDelegate = null;
821
+ break;
788
822
  default:
789
823
  }
790
824
  });
@@ -802,6 +836,7 @@ class HMSSDK {
802
836
  this.onRoleChangeRequestDelegate = null;
803
837
  this.onChangeTrackStateRequestDelegate = null;
804
838
  this.onRemovedFromRoomDelegate = null;
839
+ this.onPIPRoomLeaveDelegate = null;
805
840
  _HMSLogger.logger === null || _HMSLogger.logger === void 0 ? void 0 : _HMSLogger.logger.verbose('#Function REMOVE_ALL_LISTENER', {
806
841
  id: this.id
807
842
  });
@@ -1098,6 +1133,20 @@ class HMSSDK {
1098
1133
  });
1099
1134
  }
1100
1135
  });
1136
+ _defineProperty(this, "onPIPRoomLeaveListener", data => {
1137
+ var _this$appStateSubscri2;
1138
+ if (data.id !== this.id) {
1139
+ return;
1140
+ }
1141
+ this.muteStatus = undefined;
1142
+ this === null || this === void 0 ? void 0 : (_this$appStateSubscri2 = this.appStateSubscription) === null || _this$appStateSubscri2 === void 0 ? void 0 : _this$appStateSubscri2.remove();
1143
+ if (this.onPIPRoomLeaveDelegate) {
1144
+ _HMSLogger.logger === null || _HMSLogger.logger === void 0 ? void 0 : _HMSLogger.logger.verbose('#Listener onPIPRoomLeave_CALL', data);
1145
+ this.onPIPRoomLeaveDelegate({
1146
+ ...data
1147
+ });
1148
+ }
1149
+ });
1101
1150
  this.id = id;
1102
1151
  }
1103
1152
 
@@ -1160,17 +1209,21 @@ class HMSSDK {
1160
1209
  */
1161
1210
 
1162
1211
  async isPipModeSupported() {
1163
- return HMSManager.handlePipActions('isPipModeSupported', null);
1212
+ return HMSManager.handlePipActions('isPipModeSupported', {
1213
+ id: this.id
1214
+ });
1164
1215
  }
1165
1216
  async enablePipMode(data) {
1166
- const config = {
1167
- aspectRatio: [16, 9],
1168
- ...(data || {})
1169
- };
1170
- return HMSManager.handlePipActions('enablePipMode', config);
1217
+ return HMSManager.handlePipActions('enablePipMode', {
1218
+ ...data,
1219
+ id: this.id
1220
+ });
1171
1221
  }
1172
1222
  async setPipParams(data) {
1173
- return HMSManager.handlePipActions('setPictureInPictureParams', data || null);
1223
+ return HMSManager.handlePipActions('setPictureInPictureParams', {
1224
+ ...data,
1225
+ id: this.id
1226
+ });
1174
1227
  }
1175
1228
  }
1176
1229
  exports.HMSSDK = HMSSDK;