@100mslive/react-native-hms 1.4.0 → 1.5.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.
- package/android/build.gradle +3 -2
- package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +189 -55
- package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +1 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +42 -14
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +202 -46
- package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +5 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSView.kt +29 -21
- package/android/src/main/res/layout/hms_view.xml +2 -2
- package/ios/HMSConstants.swift +31 -0
- package/ios/HMSDecoder.swift +371 -156
- package/ios/HMSManager.m +9 -2
- package/ios/HMSManager.swift +142 -74
- package/ios/HMSRNSDK.swift +393 -181
- package/ios/HMSView.m +1 -0
- package/ios/HMSView.swift +21 -19
- package/lib/commonjs/classes/HMSCameraControl.js +28 -0
- package/lib/commonjs/classes/HMSCameraControl.js.map +1 -0
- package/lib/commonjs/classes/HMSEncoder.js +95 -13
- package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSLayer.js +14 -0
- package/lib/commonjs/classes/HMSLayer.js.map +1 -0
- package/lib/commonjs/classes/HMSLocalVideoStats.js +11 -0
- package/lib/commonjs/classes/HMSLocalVideoStats.js.map +1 -1
- package/lib/commonjs/classes/HMSPeer.js +1 -1
- package/lib/commonjs/classes/HMSPeer.js.map +1 -1
- package/lib/commonjs/classes/HMSPublishSettings.js +2 -0
- package/lib/commonjs/classes/HMSPublishSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSQualityLimitationReason.js +16 -0
- package/lib/commonjs/classes/HMSQualityLimitationReason.js.map +1 -0
- package/lib/commonjs/classes/HMSQualityLimitationReasons.js +27 -0
- package/lib/commonjs/classes/HMSQualityLimitationReasons.js.map +1 -0
- package/lib/commonjs/classes/HMSRemotePeer.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js +39 -3
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRoom.js +4 -0
- package/lib/commonjs/classes/HMSRoom.js.map +1 -1
- package/lib/commonjs/classes/HMSRoomUpdate.js +1 -0
- package/lib/commonjs/classes/HMSRoomUpdate.js.map +1 -1
- package/lib/commonjs/classes/HMSSDK.js +32 -45
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/HMSSimulcastLayerDefinition.js +19 -0
- package/lib/commonjs/classes/HMSSimulcastLayerDefinition.js.map +1 -0
- package/lib/commonjs/classes/HMSSimulcastLayerSettingsPolicy.js +23 -0
- package/lib/commonjs/classes/HMSSimulcastLayerSettingsPolicy.js.map +1 -0
- package/lib/commonjs/classes/HMSSimulcastSettings.js +5 -4
- package/lib/commonjs/classes/HMSSimulcastSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSSimulcastSettingsPolicy.js +17 -0
- package/lib/commonjs/classes/HMSSimulcastSettingsPolicy.js.map +1 -0
- package/lib/commonjs/classes/HMSSubscribeDegradationPolicy.js +21 -0
- package/lib/commonjs/classes/HMSSubscribeDegradationPolicy.js.map +1 -0
- package/lib/commonjs/classes/HMSSubscribeSettings.js +2 -0
- package/lib/commonjs/classes/HMSSubscribeSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoResolution.js.map +1 -1
- package/lib/commonjs/classes/HmsView.js +2 -0
- package/lib/commonjs/classes/HmsView.js.map +1 -1
- package/lib/commonjs/index.js +60 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/classes/HMSCameraControl.js +21 -0
- package/lib/module/classes/HMSCameraControl.js.map +1 -0
- package/lib/module/classes/HMSEncoder.js +95 -13
- package/lib/module/classes/HMSEncoder.js.map +1 -1
- package/lib/module/classes/HMSLayer.js +7 -0
- package/lib/module/classes/HMSLayer.js.map +1 -0
- package/lib/module/classes/HMSLocalVideoStats.js +11 -0
- package/lib/module/classes/HMSLocalVideoStats.js.map +1 -1
- package/lib/module/classes/HMSPeer.js +1 -1
- package/lib/module/classes/HMSPeer.js.map +1 -1
- package/lib/module/classes/HMSPublishSettings.js +2 -0
- package/lib/module/classes/HMSPublishSettings.js.map +1 -1
- package/lib/module/classes/HMSQualityLimitationReason.js +9 -0
- package/lib/module/classes/HMSQualityLimitationReason.js.map +1 -0
- package/lib/module/classes/HMSQualityLimitationReasons.js +20 -0
- package/lib/module/classes/HMSQualityLimitationReasons.js.map +1 -0
- package/lib/module/classes/HMSRemotePeer.js.map +1 -1
- package/lib/module/classes/HMSRemoteVideoTrack.js +39 -3
- package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSRoom.js +4 -0
- package/lib/module/classes/HMSRoom.js.map +1 -1
- package/lib/module/classes/HMSRoomUpdate.js +1 -0
- package/lib/module/classes/HMSRoomUpdate.js.map +1 -1
- package/lib/module/classes/HMSSDK.js +33 -45
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/HMSSimulcastLayerDefinition.js +12 -0
- package/lib/module/classes/HMSSimulcastLayerDefinition.js.map +1 -0
- package/lib/module/classes/HMSSimulcastLayerSettingsPolicy.js +16 -0
- package/lib/module/classes/HMSSimulcastLayerSettingsPolicy.js.map +1 -0
- package/lib/module/classes/HMSSimulcastSettings.js +5 -4
- package/lib/module/classes/HMSSimulcastSettings.js.map +1 -1
- package/lib/module/classes/HMSSimulcastSettingsPolicy.js +10 -0
- package/lib/module/classes/HMSSimulcastSettingsPolicy.js.map +1 -0
- package/lib/module/classes/HMSSubscribeDegradationPolicy.js +14 -0
- package/lib/module/classes/HMSSubscribeDegradationPolicy.js.map +1 -0
- package/lib/module/classes/HMSSubscribeSettings.js +2 -0
- package/lib/module/classes/HMSSubscribeSettings.js.map +1 -1
- package/lib/module/classes/HMSVideoResolution.js.map +1 -1
- package/lib/module/classes/HmsView.js +2 -0
- package/lib/module/classes/HmsView.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/classes/HMSCameraControl.d.ts +9 -0
- package/lib/typescript/classes/HMSEncoder.d.ts +13 -1
- package/lib/typescript/classes/HMSLayer.d.ts +5 -0
- package/lib/typescript/classes/HMSLocalVideoStats.d.ts +6 -0
- package/lib/typescript/classes/HMSPeer.d.ts +1 -1
- package/lib/typescript/classes/HMSPublishSettings.d.ts +3 -0
- package/lib/typescript/classes/HMSQualityLimitationReason.d.ts +7 -0
- package/lib/typescript/classes/HMSQualityLimitationReasons.d.ts +17 -0
- package/lib/typescript/classes/HMSRemotePeer.d.ts +0 -1
- package/lib/typescript/classes/HMSRemoteVideoTrack.d.ts +6 -2
- package/lib/typescript/classes/HMSRoomUpdate.d.ts +2 -1
- package/lib/typescript/classes/HMSSDK.d.ts +5 -31
- package/lib/typescript/classes/HMSSimulcastLayerDefinition.d.ts +10 -0
- package/lib/typescript/classes/HMSSimulcastLayerSettingsPolicy.d.ts +12 -0
- package/lib/typescript/classes/HMSSimulcastSettings.d.ts +7 -3
- package/lib/typescript/classes/HMSSimulcastSettingsPolicy.d.ts +7 -0
- package/lib/typescript/classes/HMSSubscribeDegradationPolicy.d.ts +10 -0
- package/lib/typescript/classes/HMSSubscribeSettings.d.ts +5 -2
- package/lib/typescript/classes/HMSVideoResolution.d.ts +2 -2
- package/lib/typescript/classes/HmsView.d.ts +2 -2
- package/lib/typescript/index.d.ts +5 -0
- package/package.json +1 -1
- package/sdk-versions.json +3 -3
- package/src/classes/HMSCameraControl.ts +21 -0
- package/src/classes/HMSEncoder.ts +125 -11
- package/src/classes/HMSLayer.ts +5 -0
- package/src/classes/HMSLocalVideoStats.ts +21 -0
- package/src/classes/HMSPeer.ts +1 -1
- package/src/classes/HMSPublishSettings.ts +4 -0
- package/src/classes/HMSQualityLimitationReason.ts +7 -0
- package/src/classes/HMSQualityLimitationReasons.ts +27 -0
- package/src/classes/HMSRemotePeer.ts +0 -1
- package/src/classes/HMSRemoteVideoTrack.ts +52 -4
- package/src/classes/HMSRoom.ts +2 -0
- package/src/classes/HMSRoomUpdate.ts +1 -0
- package/src/classes/HMSSDK.tsx +54 -48
- package/src/classes/HMSSimulcastLayerDefinition.ts +12 -0
- package/src/classes/HMSSimulcastLayerSettingsPolicy.ts +18 -0
- package/src/classes/HMSSimulcastSettings.ts +12 -3
- package/src/classes/HMSSimulcastSettingsPolicy.ts +9 -0
- package/src/classes/HMSSubscribeDegradationPolicy.ts +15 -0
- package/src/classes/HMSSubscribeSettings.ts +10 -2
- package/src/classes/HMSVideoResolution.ts +1 -1
- package/src/classes/HmsView.tsx +5 -1
- package/src/index.ts +5 -0
package/ios/HMSRNSDK.swift
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//
|
|
2
2
|
// Hmssdk.swift
|
|
3
|
-
//
|
|
3
|
+
// HMSSDK
|
|
4
4
|
//
|
|
5
|
-
// Copyright ©
|
|
5
|
+
// Copyright © 2023 100ms. All rights reserved.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import Foundation
|
|
@@ -16,7 +16,6 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
16
16
|
var recentRoleChangeRequest: HMSRoleChangeRequest?
|
|
17
17
|
var delegate: HMSManager?
|
|
18
18
|
var id: String = "12345"
|
|
19
|
-
var recentPreviewTracks: [HMSTrack]? = []
|
|
20
19
|
private var reconnectingStage: Bool = false
|
|
21
20
|
private var preferredExtension: String?
|
|
22
21
|
private var systemBroadcastPicker: RPSystemBroadcastPickerView?
|
|
@@ -24,28 +23,9 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
24
23
|
private var stopScreenshareResolve: RCTPromiseResolveBlock?
|
|
25
24
|
private var isScreenShared: Bool? = false
|
|
26
25
|
private var previewInProgress = false
|
|
27
|
-
private var rtcStatsAttached = false
|
|
28
26
|
private var networkQualityUpdatesAttached = false
|
|
29
27
|
private var eventsEnableStatus: [String: Bool] = [:]
|
|
30
28
|
|
|
31
|
-
let ON_PREVIEW = "ON_PREVIEW"
|
|
32
|
-
let ON_JOIN = "ON_JOIN"
|
|
33
|
-
let ON_ROOM_UPDATE = "ON_ROOM_UPDATE"
|
|
34
|
-
let ON_PEER_UPDATE = "3"
|
|
35
|
-
let ON_TRACK_UPDATE = "ON_TRACK_UPDATE"
|
|
36
|
-
let ON_ROLE_CHANGE_REQUEST = "ON_ROLE_CHANGE_REQUEST"
|
|
37
|
-
let ON_REMOVED_FROM_ROOM = "ON_REMOVED_FROM_ROOM"
|
|
38
|
-
let ON_ERROR = "ON_ERROR"
|
|
39
|
-
let ON_MESSAGE = "ON_MESSAGE"
|
|
40
|
-
let ON_SPEAKER = "ON_SPEAKER"
|
|
41
|
-
let RECONNECTING = "RECONNECTING"
|
|
42
|
-
let RECONNECTED = "RECONNECTED"
|
|
43
|
-
let ON_RTC_STATS = "ON_RTC_STATS"
|
|
44
|
-
let ON_LOCAL_AUDIO_STATS = "ON_LOCAL_AUDIO_STATS"
|
|
45
|
-
let ON_LOCAL_VIDEO_STATS = "ON_LOCAL_VIDEO_STATS"
|
|
46
|
-
let ON_REMOTE_AUDIO_STATS = "ON_REMOTE_AUDIO_STATS"
|
|
47
|
-
let ON_REMOTE_VIDEO_STATS = "ON_REMOTE_VIDEO_STATS"
|
|
48
|
-
|
|
49
29
|
// MARK: - Setup
|
|
50
30
|
init(data: NSDictionary?, delegate manager: HMSManager?, uid id: String) {
|
|
51
31
|
preferredExtension = data?.value(forKey: "preferredExtension") as? String
|
|
@@ -68,8 +48,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
68
48
|
func preview(_ credentials: NSDictionary) {
|
|
69
49
|
|
|
70
50
|
guard !previewInProgress else {
|
|
71
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
72
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 5000, "description": "Preview is in progress", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
51
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
52
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 5000, "description": "Preview is in progress", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
73
53
|
}
|
|
74
54
|
return
|
|
75
55
|
}
|
|
@@ -112,13 +92,12 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
112
92
|
if let extractedRole = roleObj {
|
|
113
93
|
hms?.preview(role: extractedRole, completion: { tracks, error in
|
|
114
94
|
if error != nil {
|
|
115
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
116
|
-
delegate?.emitEvent(ON_ERROR, ["error": HMSDecoder.getError(error), "id": id])
|
|
95
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
96
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": id])
|
|
117
97
|
}
|
|
118
98
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
119
99
|
return
|
|
120
100
|
}
|
|
121
|
-
self.recentPreviewTracks = tracks
|
|
122
101
|
|
|
123
102
|
let decodedTracks = HMSDecoder.getAllTracks(tracks ?? [])
|
|
124
103
|
|
|
@@ -129,15 +108,14 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
129
108
|
}
|
|
130
109
|
|
|
131
110
|
func cancelPreview() {
|
|
132
|
-
self.recentPreviewTracks = []
|
|
133
111
|
hms?.cancelPreview()
|
|
134
112
|
}
|
|
135
113
|
|
|
136
114
|
func join(_ credentials: NSDictionary) {
|
|
137
115
|
|
|
138
116
|
guard !previewInProgress else {
|
|
139
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
140
|
-
delegate?.emitEvent(
|
|
117
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
118
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 5000, "description": "Preview is in progress", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
141
119
|
}
|
|
142
120
|
return
|
|
143
121
|
}
|
|
@@ -252,15 +230,14 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
252
230
|
self?.stopScreenshareResolve = nil
|
|
253
231
|
self?.startScreenshareResolve = nil
|
|
254
232
|
self?.isScreenShared = false
|
|
255
|
-
self?.rtcStatsAttached = false
|
|
256
233
|
self?.networkQualityUpdatesAttached = false
|
|
257
234
|
self?.hms?.leave({ success, error in
|
|
258
235
|
if success {
|
|
259
236
|
HMSDecoder.clearRestrictDataStates()
|
|
260
237
|
resolve?(["success": success])
|
|
261
238
|
} else {
|
|
262
|
-
if strongSelf.eventsEnableStatus[
|
|
263
|
-
strongSelf.delegate?.emitEvent(
|
|
239
|
+
if strongSelf.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
240
|
+
strongSelf.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": strongSelf.id])
|
|
264
241
|
}
|
|
265
242
|
reject?("error in leave", "error in leave", nil)
|
|
266
243
|
}
|
|
@@ -286,8 +263,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
286
263
|
resolve?(["success": true, "data": ["sender": message?.sender?.name ?? "", "message": message?.message ?? "", "type": message?.type]])
|
|
287
264
|
return
|
|
288
265
|
} else {
|
|
289
|
-
if self?.eventsEnableStatus[
|
|
290
|
-
self?.delegate?.emitEvent(
|
|
266
|
+
if self?.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
267
|
+
self?.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
|
|
291
268
|
}
|
|
292
269
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
293
270
|
return
|
|
@@ -314,8 +291,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
314
291
|
resolve?(["success": true, "data": ["sender": message?.sender?.name ?? "", "message": message?.message ?? "", "type": message?.type]])
|
|
315
292
|
return
|
|
316
293
|
} else {
|
|
317
|
-
if self?.eventsEnableStatus[
|
|
318
|
-
self?.delegate?.emitEvent(
|
|
294
|
+
if self?.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
295
|
+
self?.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
|
|
319
296
|
}
|
|
320
297
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
321
298
|
return
|
|
@@ -342,8 +319,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
342
319
|
resolve?(["success": true, "data": ["sender": message?.sender?.name ?? "", "message": message?.message ?? "", "type": message?.type]])
|
|
343
320
|
return
|
|
344
321
|
} else {
|
|
345
|
-
if self?.eventsEnableStatus[
|
|
346
|
-
self?.delegate?.emitEvent(
|
|
322
|
+
if self?.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
323
|
+
self?.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
|
|
347
324
|
}
|
|
348
325
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
349
326
|
return
|
|
@@ -368,13 +345,12 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
368
345
|
if success {
|
|
369
346
|
resolve?(["success": success])
|
|
370
347
|
} else {
|
|
371
|
-
if self?.eventsEnableStatus[
|
|
372
|
-
self?.delegate?.emitEvent(
|
|
348
|
+
if self?.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
349
|
+
self?.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
|
|
373
350
|
}
|
|
374
351
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
375
352
|
}
|
|
376
353
|
})
|
|
377
|
-
self?.recentPreviewTracks = []
|
|
378
354
|
self?.recentRoleChangeRequest = nil
|
|
379
355
|
}
|
|
380
356
|
}
|
|
@@ -401,8 +377,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
401
377
|
if success {
|
|
402
378
|
resolve?(["success": success])
|
|
403
379
|
} else {
|
|
404
|
-
if self?.eventsEnableStatus[
|
|
405
|
-
self?.delegate?.emitEvent(
|
|
380
|
+
if self?.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
381
|
+
self?.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
|
|
406
382
|
}
|
|
407
383
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
408
384
|
}
|
|
@@ -439,8 +415,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
439
415
|
if success {
|
|
440
416
|
resolve?(["success": success])
|
|
441
417
|
} else {
|
|
442
|
-
if self?.eventsEnableStatus[
|
|
443
|
-
self?.delegate?.emitEvent(
|
|
418
|
+
if self?.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
419
|
+
self?.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
|
|
444
420
|
}
|
|
445
421
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
446
422
|
}
|
|
@@ -472,8 +448,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
472
448
|
if success {
|
|
473
449
|
resolve?(["success": success])
|
|
474
450
|
} else {
|
|
475
|
-
if self?.eventsEnableStatus[
|
|
476
|
-
self?.delegate?.emitEvent(
|
|
451
|
+
if self?.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
452
|
+
self?.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
|
|
477
453
|
}
|
|
478
454
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
479
455
|
}
|
|
@@ -509,8 +485,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
509
485
|
if success {
|
|
510
486
|
resolve?(["success": success])
|
|
511
487
|
} else {
|
|
512
|
-
if self?.eventsEnableStatus[
|
|
513
|
-
self?.delegate?.emitEvent(
|
|
488
|
+
if self?.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
489
|
+
self?.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
|
|
514
490
|
}
|
|
515
491
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
516
492
|
}
|
|
@@ -535,8 +511,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
535
511
|
guard let remotePeers = self?.hms?.remotePeers,
|
|
536
512
|
let track = HMSHelper.getTrackFromTrackId(trackId, remotePeers)
|
|
537
513
|
else {
|
|
538
|
-
if strongSelf.eventsEnableStatus[
|
|
539
|
-
strongSelf.delegate?.emitEvent(
|
|
514
|
+
if strongSelf.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
515
|
+
strongSelf.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "Track not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": strongSelf.id])
|
|
540
516
|
}
|
|
541
517
|
reject?("Track not found", "Track not found", nil)
|
|
542
518
|
return
|
|
@@ -575,8 +551,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
575
551
|
if success {
|
|
576
552
|
resolve?(["success": success])
|
|
577
553
|
} else {
|
|
578
|
-
if self?.eventsEnableStatus[
|
|
579
|
-
self?.delegate?.emitEvent(
|
|
554
|
+
if self?.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
555
|
+
self?.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
|
|
580
556
|
}
|
|
581
557
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
582
558
|
}
|
|
@@ -600,8 +576,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
600
576
|
if success {
|
|
601
577
|
resolve?(["success": success])
|
|
602
578
|
} else {
|
|
603
|
-
if self?.eventsEnableStatus[
|
|
604
|
-
self?.delegate?.emitEvent(
|
|
579
|
+
if self?.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
580
|
+
self?.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self?.id ?? "12345"])
|
|
605
581
|
}
|
|
606
582
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
607
583
|
}
|
|
@@ -681,8 +657,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
681
657
|
resolve?(["success": success])
|
|
682
658
|
return
|
|
683
659
|
} else {
|
|
684
|
-
if self.eventsEnableStatus[
|
|
685
|
-
self.delegate?.emitEvent(
|
|
660
|
+
if self.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
661
|
+
self.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self.id])
|
|
686
662
|
}
|
|
687
663
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
688
664
|
return
|
|
@@ -707,8 +683,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
707
683
|
|
|
708
684
|
if remoteAudioTrack != nil {
|
|
709
685
|
remoteAudioTrack?.setVolume(volume)
|
|
710
|
-
} else if strongSelf.eventsEnableStatus[
|
|
711
|
-
strongSelf.delegate?.emitEvent(
|
|
686
|
+
} else if strongSelf.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
687
|
+
strongSelf.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "Track not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": strongSelf.id])
|
|
712
688
|
}
|
|
713
689
|
}
|
|
714
690
|
}
|
|
@@ -729,8 +705,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
729
705
|
if let meetLink = URL(string: meetingString) {
|
|
730
706
|
meetingUrl = meetLink
|
|
731
707
|
} else {
|
|
732
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
733
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "Invalid meeting url passed", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
708
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
709
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "Invalid meeting url passed", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
734
710
|
}
|
|
735
711
|
reject?("Invalid meeting url passed", "Invalid meeting url passed", nil)
|
|
736
712
|
}
|
|
@@ -743,8 +719,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
743
719
|
resolve?(["success": success])
|
|
744
720
|
return
|
|
745
721
|
} else {
|
|
746
|
-
if self.eventsEnableStatus[
|
|
747
|
-
self.delegate?.emitEvent(
|
|
722
|
+
if self.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
723
|
+
self.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self.id])
|
|
748
724
|
}
|
|
749
725
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
750
726
|
return
|
|
@@ -758,8 +734,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
758
734
|
resolve?(["success": success])
|
|
759
735
|
return
|
|
760
736
|
} else {
|
|
761
|
-
if self.eventsEnableStatus[
|
|
762
|
-
self.delegate?.emitEvent(
|
|
737
|
+
if self.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
738
|
+
self.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self.id])
|
|
763
739
|
}
|
|
764
740
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
765
741
|
return
|
|
@@ -780,8 +756,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
780
756
|
resolve?(["success": success])
|
|
781
757
|
return
|
|
782
758
|
} else {
|
|
783
|
-
if self.eventsEnableStatus[
|
|
784
|
-
self.delegate?.emitEvent(
|
|
759
|
+
if self.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
760
|
+
self.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self.id])
|
|
785
761
|
}
|
|
786
762
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
787
763
|
return
|
|
@@ -795,8 +771,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
795
771
|
resolve?(["success": success])
|
|
796
772
|
return
|
|
797
773
|
} else {
|
|
798
|
-
if self.eventsEnableStatus[
|
|
799
|
-
self.delegate?.emitEvent(
|
|
774
|
+
if self.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
775
|
+
self.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self.id])
|
|
800
776
|
}
|
|
801
777
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
802
778
|
return
|
|
@@ -817,8 +793,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
817
793
|
if success {
|
|
818
794
|
resolve?(["success": success])
|
|
819
795
|
} else {
|
|
820
|
-
if self.eventsEnableStatus[
|
|
821
|
-
self.delegate?.emitEvent(
|
|
796
|
+
if self.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
797
|
+
self.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self.id])
|
|
822
798
|
}
|
|
823
799
|
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
824
800
|
}
|
|
@@ -859,18 +835,10 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
859
835
|
}
|
|
860
836
|
}
|
|
861
837
|
|
|
862
|
-
func enableRTCStats() {
|
|
863
|
-
rtcStatsAttached = true
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
func disableRTCStats() {
|
|
867
|
-
rtcStatsAttached = false
|
|
868
|
-
}
|
|
869
|
-
|
|
870
838
|
func startScreenshare(_ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
871
839
|
guard let preferredExtension = preferredExtension else {
|
|
872
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
873
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "Could not start screen share, preferredExtension not passed in Build method", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
840
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
841
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "Could not start screen share, preferredExtension not passed in Build method", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
874
842
|
}
|
|
875
843
|
reject?("Could not start screen share, preferredExtension not passed in Build method", "Could not start screen share, preferredExtension not passed in Build method", nil)
|
|
876
844
|
return
|
|
@@ -893,8 +861,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
893
861
|
|
|
894
862
|
func stopScreenshare(_ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
895
863
|
guard let preferredExtension = preferredExtension else {
|
|
896
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
897
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "Could not start screen share, preferredExtension not passed in Build method", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
864
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
865
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "Could not start screen share, preferredExtension not passed in Build method", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
898
866
|
}
|
|
899
867
|
reject?("Could not start screen share, preferredExtension not passed in Build method", "Could not start screen share, preferredExtension not passed in Build method", nil)
|
|
900
868
|
return
|
|
@@ -938,20 +906,20 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
938
906
|
try audioFilePlayerNode.play(fileUrl: url, loops: loops, interrupts: interrupts)
|
|
939
907
|
resolve?(["success": true])
|
|
940
908
|
} catch {
|
|
941
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
942
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": error.localizedDescription, "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
909
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
910
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": error.localizedDescription, "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
943
911
|
}
|
|
944
912
|
reject?(error.localizedDescription, error.localizedDescription, nil)
|
|
945
913
|
}
|
|
946
914
|
} else {
|
|
947
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
948
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "Incorrect url", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
915
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
916
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "Incorrect url", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
949
917
|
}
|
|
950
918
|
reject?("Incorrect URL", "Incorrect URL", nil)
|
|
951
919
|
}
|
|
952
920
|
} else {
|
|
953
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
954
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
921
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
922
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
955
923
|
}
|
|
956
924
|
reject?("AudioFilePlayerNode not found", "AudioFilePlayerNode not found", nil)
|
|
957
925
|
}
|
|
@@ -986,8 +954,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
986
954
|
}
|
|
987
955
|
if let audioFilePlayerNode = playerNode as? HMSAudioFilePlayerNode {
|
|
988
956
|
audioFilePlayerNode.stop()
|
|
989
|
-
} else if eventsEnableStatus[ON_ERROR] == true {
|
|
990
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
957
|
+
} else if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
958
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
991
959
|
}
|
|
992
960
|
}
|
|
993
961
|
|
|
@@ -1004,12 +972,12 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1004
972
|
do {
|
|
1005
973
|
try audioFilePlayerNode.resume()
|
|
1006
974
|
} catch {
|
|
1007
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
1008
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": error.localizedDescription, "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
975
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
976
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": error.localizedDescription, "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
1009
977
|
}
|
|
1010
978
|
}
|
|
1011
|
-
} else if eventsEnableStatus[ON_ERROR] == true {
|
|
1012
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
979
|
+
} else if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
980
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
1013
981
|
}
|
|
1014
982
|
}
|
|
1015
983
|
|
|
@@ -1024,8 +992,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1024
992
|
}
|
|
1025
993
|
if let audioFilePlayerNode = playerNode as? HMSAudioFilePlayerNode {
|
|
1026
994
|
audioFilePlayerNode.pause()
|
|
1027
|
-
} else if eventsEnableStatus[ON_ERROR] == true {
|
|
1028
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
995
|
+
} else if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
996
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
1029
997
|
}
|
|
1030
998
|
}
|
|
1031
999
|
|
|
@@ -1042,8 +1010,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1042
1010
|
if let audioFilePlayerNode = playerNode as? HMSAudioFilePlayerNode {
|
|
1043
1011
|
resolve?(audioFilePlayerNode.isPlaying)
|
|
1044
1012
|
} else {
|
|
1045
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
1046
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
1013
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
1014
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
1047
1015
|
}
|
|
1048
1016
|
reject?("AudioFilePlayerNode not found", "AudioFilePlayerNode not found", nil)
|
|
1049
1017
|
}
|
|
@@ -1062,8 +1030,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1062
1030
|
if let audioFilePlayerNode = playerNode as? HMSAudioFilePlayerNode {
|
|
1063
1031
|
resolve?(audioFilePlayerNode.currentTime)
|
|
1064
1032
|
} else {
|
|
1065
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
1066
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
1033
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
1034
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
1067
1035
|
}
|
|
1068
1036
|
reject?("AudioFilePlayerNode not found", "AudioFilePlayerNode not found", nil)
|
|
1069
1037
|
}
|
|
@@ -1082,8 +1050,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1082
1050
|
if let audioFilePlayerNode = playerNode as? HMSAudioFilePlayerNode {
|
|
1083
1051
|
resolve?(audioFilePlayerNode.duration)
|
|
1084
1052
|
} else {
|
|
1085
|
-
if eventsEnableStatus[ON_ERROR] == true {
|
|
1086
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
1053
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
1054
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 6002, "description": "AudioFilePlayerNode not found", "isTerminal": false, "canRetry": true, "params": ["function": #function]], "id": id])
|
|
1087
1055
|
}
|
|
1088
1056
|
reject?("AudioFilePlayerNode not found", "AudioFilePlayerNode not found", nil)
|
|
1089
1057
|
}
|
|
@@ -1100,14 +1068,32 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1100
1068
|
func setSessionMetaData(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
1101
1069
|
let metaData = data.value(forKey: "sessionMetaData") as? String ?? ""
|
|
1102
1070
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1071
|
+
DispatchQueue.main.async { [weak self] in
|
|
1072
|
+
|
|
1073
|
+
guard let self = self else {
|
|
1074
|
+
let errorMessage = "\(#function) Unexpectedly encountered self as null"
|
|
1075
|
+
self?.emitRequiredKeysError(errorMessage)
|
|
1076
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1077
|
+
return
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
self.hms?.setSessionMetadata(metaData) { [weak self] success, error in
|
|
1081
|
+
|
|
1082
|
+
guard let self = self else {
|
|
1083
|
+
let errorMessage = "\(#function) Unexpectedly encountered self as null"
|
|
1084
|
+
self?.emitRequiredKeysError(errorMessage)
|
|
1085
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1086
|
+
return
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
if success {
|
|
1090
|
+
resolve?(["success": success])
|
|
1091
|
+
} else {
|
|
1092
|
+
if self.eventsEnableStatus[HMSConstants.ON_ERROR] == true {
|
|
1093
|
+
self.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self.id])
|
|
1094
|
+
}
|
|
1095
|
+
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
1109
1096
|
}
|
|
1110
|
-
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
1111
1097
|
}
|
|
1112
1098
|
}
|
|
1113
1099
|
}
|
|
@@ -1172,14 +1158,31 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1172
1158
|
}
|
|
1173
1159
|
|
|
1174
1160
|
func getSessionMetaData(_ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1161
|
+
|
|
1162
|
+
DispatchQueue.main.async { [weak self] in
|
|
1163
|
+
|
|
1164
|
+
guard let self = self else {
|
|
1165
|
+
let errorMessage = "\(#function) Unexpectedly encountered self as null"
|
|
1166
|
+
self?.emitRequiredKeysError(errorMessage)
|
|
1167
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1168
|
+
return
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
self.hms?.getSessionMetadata { [weak self] result, error in
|
|
1172
|
+
|
|
1173
|
+
guard let self = self else {
|
|
1174
|
+
let errorMessage = "\(#function) Unexpectedly encountered self as null"
|
|
1175
|
+
self?.emitRequiredKeysError(errorMessage)
|
|
1176
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1177
|
+
return
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
if error != nil {
|
|
1181
|
+
self.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": self.id])
|
|
1182
|
+
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
1183
|
+
} else {
|
|
1184
|
+
resolve?(result)
|
|
1179
1185
|
}
|
|
1180
|
-
reject?(error?.localizedDescription, error?.localizedDescription, nil)
|
|
1181
|
-
} else {
|
|
1182
|
-
resolve?(result)
|
|
1183
1186
|
}
|
|
1184
1187
|
}
|
|
1185
1188
|
}
|
|
@@ -1289,29 +1292,79 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1289
1292
|
}
|
|
1290
1293
|
}
|
|
1291
1294
|
|
|
1295
|
+
func getRemoteVideoTrackFromTrackId(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
1296
|
+
|
|
1297
|
+
guard let trackId = data.value(forKey: "trackId") as? String
|
|
1298
|
+
else {
|
|
1299
|
+
let errorMessage = "\(#function) " + HMSHelper.getUnavailableRequiredKey(data, ["trackId"])
|
|
1300
|
+
emitRequiredKeysError(errorMessage)
|
|
1301
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1302
|
+
return
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
DispatchQueue.main.async { [weak self] in
|
|
1306
|
+
|
|
1307
|
+
guard let self = self,
|
|
1308
|
+
let remotePeers = self.hms?.remotePeers,
|
|
1309
|
+
let remoteVideoTrack = HMSHelper.getRemoteVideoTrackFromTrackId(trackId, remotePeers)
|
|
1310
|
+
else {
|
|
1311
|
+
let errorMessage = "\(#function) " + "TRACK_NOT_FOUND"
|
|
1312
|
+
self?.emitRequiredKeysError(errorMessage)
|
|
1313
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1314
|
+
return
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
resolve?(HMSDecoder.getHMSRemoteVideoTrack(remoteVideoTrack))
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
func getRemoteAudioTrackFromTrackId(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
1322
|
+
guard let trackId = data.value(forKey: "trackId") as? String
|
|
1323
|
+
else {
|
|
1324
|
+
let errorMessage = "\(#function) " + HMSHelper.getUnavailableRequiredKey(data, ["trackId"])
|
|
1325
|
+
emitRequiredKeysError(errorMessage)
|
|
1326
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1327
|
+
return
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
DispatchQueue.main.async { [weak self] in
|
|
1331
|
+
|
|
1332
|
+
guard let self = self,
|
|
1333
|
+
let remotePeers = self.hms?.remotePeers,
|
|
1334
|
+
let remoteAudioTrack = HMSHelper.getRemoteAudioTrackFromTrackId(trackId, remotePeers)
|
|
1335
|
+
else {
|
|
1336
|
+
let errorMessage = "\(#function) " + "TRACK_NOT_FOUND"
|
|
1337
|
+
self?.emitRequiredKeysError(errorMessage)
|
|
1338
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1339
|
+
return
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
resolve?(HMSDecoder.getHMSRemoteAudioTrack(remoteAudioTrack))
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1292
1346
|
// MARK: - HMS SDK Delegate Callbacks
|
|
1293
1347
|
func on(join room: HMSRoom) {
|
|
1294
|
-
|
|
1295
|
-
if eventsEnableStatus[ON_JOIN] != true {
|
|
1348
|
+
if eventsEnableStatus[HMSConstants.ON_JOIN] != true {
|
|
1296
1349
|
return
|
|
1297
1350
|
}
|
|
1298
1351
|
let roomData = HMSDecoder.getHmsRoomSubset(room)
|
|
1299
|
-
self.delegate?.emitEvent(ON_JOIN, ["event": ON_JOIN, "id": self.id, "room": roomData])
|
|
1352
|
+
self.delegate?.emitEvent(HMSConstants.ON_JOIN, ["event": HMSConstants.ON_JOIN, "id": self.id, "room": roomData])
|
|
1300
1353
|
}
|
|
1301
1354
|
|
|
1302
1355
|
func onPreview(room: HMSRoom, localTracks: [HMSTrack]) {
|
|
1303
1356
|
previewInProgress = false
|
|
1304
|
-
if eventsEnableStatus[ON_PREVIEW] != true {
|
|
1357
|
+
if eventsEnableStatus[HMSConstants.ON_PREVIEW] != true {
|
|
1305
1358
|
return
|
|
1306
1359
|
}
|
|
1307
1360
|
let previewTracks = HMSDecoder.getPreviewTracks(localTracks)
|
|
1308
1361
|
let hmsRoom = HMSDecoder.getHmsRoomSubset(room)
|
|
1309
1362
|
|
|
1310
|
-
self.delegate?.emitEvent(ON_PREVIEW, ["event": ON_PREVIEW, "id": self.id, "room": hmsRoom, "previewTracks": previewTracks])
|
|
1363
|
+
self.delegate?.emitEvent(HMSConstants.ON_PREVIEW, ["event": HMSConstants.ON_PREVIEW, "id": self.id, "room": hmsRoom, "previewTracks": previewTracks])
|
|
1311
1364
|
}
|
|
1312
1365
|
|
|
1313
1366
|
func on(room: HMSRoom, update: HMSRoomUpdate) {
|
|
1314
|
-
if eventsEnableStatus[ON_ROOM_UPDATE] != true {
|
|
1367
|
+
if eventsEnableStatus[HMSConstants.ON_ROOM_UPDATE] != true {
|
|
1315
1368
|
return
|
|
1316
1369
|
}
|
|
1317
1370
|
if update == .metaDataUpdated || update == .roomTypeChanged {
|
|
@@ -1321,11 +1374,11 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1321
1374
|
let roomData = HMSDecoder.getHmsRoomSubset(room, update)
|
|
1322
1375
|
let type = getString(from: update)
|
|
1323
1376
|
|
|
1324
|
-
self.delegate?.emitEvent(ON_ROOM_UPDATE, ["event": ON_ROOM_UPDATE, "id": self.id, "type": type, "room": roomData])
|
|
1377
|
+
self.delegate?.emitEvent(HMSConstants.ON_ROOM_UPDATE, ["event": HMSConstants.ON_ROOM_UPDATE, "id": self.id, "type": type, "room": roomData])
|
|
1325
1378
|
}
|
|
1326
1379
|
|
|
1327
1380
|
func on(peer: HMSPeer, update: HMSPeerUpdate) {
|
|
1328
|
-
if eventsEnableStatus[ON_PEER_UPDATE] != true {
|
|
1381
|
+
if eventsEnableStatus[HMSConstants.ON_PEER_UPDATE] != true {
|
|
1329
1382
|
return
|
|
1330
1383
|
}
|
|
1331
1384
|
let type = getString(from: update)
|
|
@@ -1335,7 +1388,7 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1335
1388
|
return
|
|
1336
1389
|
}
|
|
1337
1390
|
|
|
1338
|
-
self.delegate?.emitEvent(ON_PEER_UPDATE, hmsPeer)
|
|
1391
|
+
self.delegate?.emitEvent(HMSConstants.ON_PEER_UPDATE, hmsPeer)
|
|
1339
1392
|
}
|
|
1340
1393
|
|
|
1341
1394
|
func on(track: HMSTrack, update: HMSTrackUpdate, for peer: HMSPeer) {
|
|
@@ -1351,7 +1404,7 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1351
1404
|
}
|
|
1352
1405
|
}
|
|
1353
1406
|
|
|
1354
|
-
if eventsEnableStatus[ON_TRACK_UPDATE] != true {
|
|
1407
|
+
if eventsEnableStatus[HMSConstants.ON_TRACK_UPDATE] != true {
|
|
1355
1408
|
return
|
|
1356
1409
|
}
|
|
1357
1410
|
|
|
@@ -1359,71 +1412,71 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1359
1412
|
let hmsPeer = HMSDecoder.getHmsPeerSubset(peer)
|
|
1360
1413
|
let hmsTrack = HMSDecoder.getHmsTrack(track)
|
|
1361
1414
|
|
|
1362
|
-
self.delegate?.emitEvent(ON_TRACK_UPDATE, ["event": ON_TRACK_UPDATE, "id": self.id, "type": type, "peer": hmsPeer, "track": hmsTrack])
|
|
1415
|
+
self.delegate?.emitEvent(HMSConstants.ON_TRACK_UPDATE, ["event": HMSConstants.ON_TRACK_UPDATE, "id": self.id, "type": type, "peer": hmsPeer, "track": hmsTrack])
|
|
1363
1416
|
}
|
|
1364
1417
|
|
|
1365
1418
|
func on(error: Error) {
|
|
1366
1419
|
if previewInProgress { previewInProgress = false }
|
|
1367
|
-
if eventsEnableStatus[ON_ERROR] != true {
|
|
1420
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] != true {
|
|
1368
1421
|
return
|
|
1369
1422
|
}
|
|
1370
|
-
self.delegate?.emitEvent(ON_ERROR, ["error": HMSDecoder.getError(error), "id": id])
|
|
1423
|
+
self.delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": HMSDecoder.getError(error), "id": id])
|
|
1371
1424
|
}
|
|
1372
1425
|
|
|
1373
1426
|
func on(message: HMSMessage) {
|
|
1374
|
-
if eventsEnableStatus[ON_MESSAGE] != true {
|
|
1427
|
+
if eventsEnableStatus[HMSConstants.ON_MESSAGE] != true {
|
|
1375
1428
|
return
|
|
1376
1429
|
}
|
|
1377
|
-
self.delegate?.emitEvent(ON_MESSAGE, ["event": ON_MESSAGE, "id": self.id, "sender": HMSDecoder.getHmsPeerSubset(message.sender), "recipient": HMSDecoder.getHmsMessageRecipient(message.recipient), "time": message.time.timeIntervalSince1970 * 1000, "message": message.message, "type": message.type])
|
|
1430
|
+
self.delegate?.emitEvent(HMSConstants.ON_MESSAGE, ["event": HMSConstants.ON_MESSAGE, "id": self.id, "sender": HMSDecoder.getHmsPeerSubset(message.sender), "recipient": HMSDecoder.getHmsMessageRecipient(message.recipient), "time": message.time.timeIntervalSince1970 * 1000, "message": message.message, "type": message.type])
|
|
1378
1431
|
}
|
|
1379
1432
|
|
|
1380
1433
|
func on(updated speakers: [HMSSpeaker]) {
|
|
1381
|
-
if eventsEnableStatus[ON_SPEAKER] != true {
|
|
1434
|
+
if eventsEnableStatus[HMSConstants.ON_SPEAKER] != true {
|
|
1382
1435
|
return
|
|
1383
1436
|
}
|
|
1384
1437
|
var speakerPeerIds: [[String: Any]] = []
|
|
1385
1438
|
for speaker in speakers {
|
|
1386
1439
|
speakerPeerIds.append(["peer": HMSDecoder.getHmsPeerSubset(speaker.peer), "level": speaker.level, "track": HMSDecoder.getHmsTrack(speaker.track)])
|
|
1387
1440
|
}
|
|
1388
|
-
self.delegate?.emitEvent(ON_SPEAKER, ["event": ON_SPEAKER, "id": self.id, "speakers": speakerPeerIds])
|
|
1441
|
+
self.delegate?.emitEvent(HMSConstants.ON_SPEAKER, ["event": HMSConstants.ON_SPEAKER, "id": self.id, "speakers": speakerPeerIds])
|
|
1389
1442
|
}
|
|
1390
1443
|
|
|
1391
1444
|
func onReconnecting() {
|
|
1392
1445
|
reconnectingStage = true
|
|
1393
|
-
if eventsEnableStatus[RECONNECTING] != true {
|
|
1446
|
+
if eventsEnableStatus[HMSConstants.RECONNECTING] != true {
|
|
1394
1447
|
return
|
|
1395
1448
|
}
|
|
1396
|
-
self.delegate?.emitEvent(RECONNECTING, ["event": RECONNECTING, "error": ["code": 1003, "description": "Network connection lost ", "isTerminal": false, "canRetry": true], "id": self.id ])
|
|
1449
|
+
self.delegate?.emitEvent(HMSConstants.RECONNECTING, ["event": HMSConstants.RECONNECTING, "error": ["code": 1003, "description": "Network connection lost ", "isTerminal": false, "canRetry": true], "id": self.id ])
|
|
1397
1450
|
}
|
|
1398
1451
|
|
|
1399
1452
|
func onReconnected() {
|
|
1400
1453
|
reconnectingStage = false
|
|
1401
|
-
if eventsEnableStatus[RECONNECTED] != true {
|
|
1454
|
+
if eventsEnableStatus[HMSConstants.RECONNECTED] != true {
|
|
1402
1455
|
return
|
|
1403
1456
|
}
|
|
1404
|
-
self.delegate?.emitEvent(RECONNECTED, ["event": RECONNECTED, "id": self.id ])
|
|
1457
|
+
self.delegate?.emitEvent(HMSConstants.RECONNECTED, ["event": HMSConstants.RECONNECTED, "id": self.id ])
|
|
1405
1458
|
}
|
|
1406
1459
|
|
|
1407
1460
|
func on(roleChangeRequest: HMSRoleChangeRequest) {
|
|
1408
1461
|
recentRoleChangeRequest = roleChangeRequest
|
|
1409
|
-
if eventsEnableStatus[ON_ROLE_CHANGE_REQUEST] != true {
|
|
1462
|
+
if eventsEnableStatus[HMSConstants.ON_ROLE_CHANGE_REQUEST] != true {
|
|
1410
1463
|
return
|
|
1411
1464
|
}
|
|
1412
1465
|
let decodedRoleChangeRequest = HMSDecoder.getHmsRoleChangeRequest(roleChangeRequest, self.id)
|
|
1413
|
-
self.delegate?.emitEvent(ON_ROLE_CHANGE_REQUEST, decodedRoleChangeRequest)
|
|
1466
|
+
self.delegate?.emitEvent(HMSConstants.ON_ROLE_CHANGE_REQUEST, decodedRoleChangeRequest)
|
|
1414
1467
|
}
|
|
1415
1468
|
|
|
1416
1469
|
func on(changeTrackStateRequest: HMSChangeTrackStateRequest) {
|
|
1417
|
-
if eventsEnableStatus[
|
|
1470
|
+
if eventsEnableStatus[HMSConstants.ON_CHANGE_TRACK_STATE_REQUEST] != true {
|
|
1418
1471
|
return
|
|
1419
1472
|
}
|
|
1420
1473
|
let decodedChangeTrackStateRequest = HMSDecoder.getHmsChangeTrackStateRequest(changeTrackStateRequest, id)
|
|
1421
|
-
delegate?.emitEvent(
|
|
1474
|
+
delegate?.emitEvent(HMSConstants.ON_CHANGE_TRACK_STATE_REQUEST, decodedChangeTrackStateRequest)
|
|
1422
1475
|
}
|
|
1423
1476
|
|
|
1424
1477
|
func on(removedFromRoom notification: HMSRemovedFromRoomNotification) {
|
|
1425
1478
|
HMSDecoder.clearRestrictDataStates()
|
|
1426
|
-
if eventsEnableStatus[ON_REMOVED_FROM_ROOM] != true {
|
|
1479
|
+
if eventsEnableStatus[HMSConstants.ON_REMOVED_FROM_ROOM] != true {
|
|
1427
1480
|
return
|
|
1428
1481
|
}
|
|
1429
1482
|
let requestedBy = notification.requestedBy as HMSPeer?
|
|
@@ -1433,80 +1486,216 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1433
1486
|
}
|
|
1434
1487
|
let reason = notification.reason
|
|
1435
1488
|
let roomEnded = notification.roomEnded
|
|
1436
|
-
self.delegate?.emitEvent(ON_REMOVED_FROM_ROOM, ["event": ON_REMOVED_FROM_ROOM, "id": self.id, "requestedBy": decodedRequestedBy as Any, "reason": reason, "roomEnded": roomEnded ])
|
|
1489
|
+
self.delegate?.emitEvent(HMSConstants.ON_REMOVED_FROM_ROOM, ["event": HMSConstants.ON_REMOVED_FROM_ROOM, "id": self.id, "requestedBy": decodedRequestedBy as Any, "reason": reason, "roomEnded": roomEnded ])
|
|
1437
1490
|
}
|
|
1438
1491
|
|
|
1439
1492
|
func on(rtcStats: HMSRTCStatsReport) {
|
|
1440
|
-
if eventsEnableStatus[ON_RTC_STATS] != true {
|
|
1493
|
+
if eventsEnableStatus[HMSConstants.ON_RTC_STATS] != true {
|
|
1441
1494
|
return
|
|
1442
1495
|
}
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
let video = HMSDecoder.getHMSRTCStats(rtcStats.video)
|
|
1447
|
-
let audio = HMSDecoder.getHMSRTCStats(rtcStats.audio)
|
|
1448
|
-
let combined = HMSDecoder.getHMSRTCStats(rtcStats.combined)
|
|
1496
|
+
let video = HMSDecoder.getHMSRTCStats(rtcStats.video) // [bitrateReceived, bitrateSent, bytesReceived, bytesSent, packetsLost, packetsReceived, roundTripTime]
|
|
1497
|
+
let audio = HMSDecoder.getHMSRTCStats(rtcStats.audio) // [bitrateReceived, bitrateSent, bytesReceived, bytesSent, packetsLost, packetsReceived, roundTripTime]
|
|
1498
|
+
let combined = HMSDecoder.getHMSRTCStats(rtcStats.combined) // [bitrateReceived, bitrateSent, bytesReceived, bytesSent, packetsLost, packetsReceived, roundTripTime]
|
|
1449
1499
|
|
|
1450
|
-
self.delegate?.emitEvent(ON_RTC_STATS, ["video": video, "audio": audio, "combined": combined, "id": self.id])
|
|
1500
|
+
self.delegate?.emitEvent(HMSConstants.ON_RTC_STATS, ["video": video, "audio": audio, "combined": combined, "id": self.id])
|
|
1451
1501
|
}
|
|
1452
1502
|
|
|
1453
1503
|
func on(localAudioStats: HMSLocalAudioStats, track: HMSAudioTrack, peer: HMSPeer) {
|
|
1454
|
-
if eventsEnableStatus[ON_LOCAL_AUDIO_STATS] != true {
|
|
1455
|
-
return
|
|
1456
|
-
}
|
|
1457
|
-
if !rtcStatsAttached {
|
|
1504
|
+
if eventsEnableStatus[HMSConstants.ON_LOCAL_AUDIO_STATS] != true {
|
|
1458
1505
|
return
|
|
1459
1506
|
}
|
|
1460
|
-
let localStats = HMSDecoder.getLocalAudioStats(localAudioStats)
|
|
1507
|
+
let localStats = HMSDecoder.getLocalAudioStats(localAudioStats) // [bitrate, bytesSent, roundTripTime]
|
|
1461
1508
|
let localTrack = HMSDecoder.getHmsAudioTrack(track)
|
|
1462
1509
|
let decodedPeer = HMSDecoder.getHmsPeerSubset(peer)
|
|
1463
1510
|
|
|
1464
|
-
self.delegate?.emitEvent(ON_LOCAL_AUDIO_STATS, ["localAudioStats": localStats, "track": localTrack, "peer": decodedPeer, "id": self.id])
|
|
1511
|
+
self.delegate?.emitEvent(HMSConstants.ON_LOCAL_AUDIO_STATS, ["localAudioStats": localStats, "track": localTrack, "peer": decodedPeer, "id": self.id])
|
|
1465
1512
|
}
|
|
1466
1513
|
|
|
1467
|
-
func on(localVideoStats: [HMSLocalVideoStats], track: HMSVideoTrack, peer: HMSPeer) {
|
|
1468
|
-
if eventsEnableStatus[ON_LOCAL_VIDEO_STATS] != true {
|
|
1469
|
-
return
|
|
1470
|
-
}
|
|
1471
|
-
if !rtcStatsAttached {
|
|
1514
|
+
func on(localVideoStats: [HMSLocalVideoStats], track: HMSVideoTrack, peer: HMSPeer) { // DOUBT: HMSLocalVideoTrack instead of HMSVideoTrack?
|
|
1515
|
+
if eventsEnableStatus[HMSConstants.ON_LOCAL_VIDEO_STATS] != true {
|
|
1472
1516
|
return
|
|
1473
1517
|
}
|
|
1474
|
-
let localStats = HMSDecoder.getLocalVideoStats(localVideoStats)
|
|
1518
|
+
let localStats = HMSDecoder.getLocalVideoStats(localVideoStats) // List<[bitrate, bytesSent, roundTripTime, frameRate, resolution, layer]>
|
|
1475
1519
|
let decodedPeer = HMSDecoder.getHmsPeerSubset(peer)
|
|
1476
1520
|
let localTrack = HMSDecoder.getHmsVideoTrack(track)
|
|
1477
1521
|
|
|
1478
|
-
self.delegate?.emitEvent(ON_LOCAL_VIDEO_STATS, ["localVideoStats": localStats, "track": localTrack, "peer": decodedPeer, "id": self.id])
|
|
1522
|
+
self.delegate?.emitEvent(HMSConstants.ON_LOCAL_VIDEO_STATS, ["localVideoStats": localStats, "track": localTrack, "peer": decodedPeer, "id": self.id])
|
|
1479
1523
|
}
|
|
1480
1524
|
|
|
1481
1525
|
func on(remoteAudioStats: HMSRemoteAudioStats, track: HMSAudioTrack, peer: HMSPeer) {
|
|
1482
|
-
if eventsEnableStatus[ON_REMOTE_AUDIO_STATS] != true {
|
|
1526
|
+
if eventsEnableStatus[HMSConstants.ON_REMOTE_AUDIO_STATS] != true {
|
|
1483
1527
|
return
|
|
1484
1528
|
}
|
|
1485
|
-
|
|
1486
|
-
return
|
|
1487
|
-
}
|
|
1488
|
-
let remoteStats = HMSDecoder.getRemoteAudioStats(remoteAudioStats)
|
|
1529
|
+
let remoteStats = HMSDecoder.getRemoteAudioStats(remoteAudioStats) // [bitrate, bytesReceived, jitter, packetsLost, packetsReceived]
|
|
1489
1530
|
let remoteTrack = HMSDecoder.getHmsAudioTrack(track)
|
|
1490
1531
|
let decodedPeer = HMSDecoder.getHmsPeerSubset(peer)
|
|
1491
1532
|
|
|
1492
|
-
self.delegate?.emitEvent(ON_REMOTE_AUDIO_STATS, ["remoteAudioStats": remoteStats, "track": remoteTrack, "peer": decodedPeer, "id": self.id])
|
|
1533
|
+
self.delegate?.emitEvent(HMSConstants.ON_REMOTE_AUDIO_STATS, ["remoteAudioStats": remoteStats, "track": remoteTrack, "peer": decodedPeer, "id": self.id])
|
|
1493
1534
|
}
|
|
1494
1535
|
|
|
1495
1536
|
func on(remoteVideoStats: HMSRemoteVideoStats, track: HMSVideoTrack, peer: HMSPeer) {
|
|
1496
|
-
if eventsEnableStatus[ON_REMOTE_VIDEO_STATS] != true {
|
|
1497
|
-
return
|
|
1498
|
-
}
|
|
1499
|
-
if !rtcStatsAttached {
|
|
1537
|
+
if eventsEnableStatus[HMSConstants.ON_REMOTE_VIDEO_STATS] != true {
|
|
1500
1538
|
return
|
|
1501
1539
|
}
|
|
1502
|
-
let remoteStats = HMSDecoder.getRemoteVideoStats(remoteVideoStats)
|
|
1540
|
+
let remoteStats = HMSDecoder.getRemoteVideoStats(remoteVideoStats) // [bitrate, bytesReceived, frameRate, jitter, packetsLost, packetsReceived, resolution]
|
|
1503
1541
|
let decodedPeer = HMSDecoder.getHmsPeerSubset(peer)
|
|
1504
1542
|
let remoteTrack = HMSDecoder.getHmsVideoTrack(track)
|
|
1505
1543
|
|
|
1506
|
-
self.delegate?.emitEvent(ON_REMOTE_VIDEO_STATS, ["remoteVideoStats": remoteStats, "track": remoteTrack, "peer": decodedPeer, "id": self.id])
|
|
1544
|
+
self.delegate?.emitEvent(HMSConstants.ON_REMOTE_VIDEO_STATS, ["remoteVideoStats": remoteStats, "track": remoteTrack, "peer": decodedPeer, "id": self.id])
|
|
1507
1545
|
}
|
|
1508
1546
|
|
|
1509
|
-
// MARK:
|
|
1547
|
+
// MARK: - Simulcast
|
|
1548
|
+
|
|
1549
|
+
func getVideoTrackLayerDefinition(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
1550
|
+
guard let trackId = data.value(forKey: "trackId") as? String
|
|
1551
|
+
else {
|
|
1552
|
+
let errorMessage = "\(#function) " + HMSHelper.getUnavailableRequiredKey(data, ["trackId"])
|
|
1553
|
+
emitRequiredKeysError(errorMessage)
|
|
1554
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1555
|
+
return
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
DispatchQueue.main.async { [weak self] in
|
|
1559
|
+
|
|
1560
|
+
guard let self = self,
|
|
1561
|
+
let remotePeers = self.hms?.remotePeers,
|
|
1562
|
+
let remoteVideoTrack = HMSHelper.getRemoteVideoTrackFromTrackId(trackId, remotePeers)
|
|
1563
|
+
else {
|
|
1564
|
+
let errorMessage = "\(#function) " + "TRACK_NOT_FOUND"
|
|
1565
|
+
self?.emitRequiredKeysError(errorMessage)
|
|
1566
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1567
|
+
return
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
guard let layerDefinitions = remoteVideoTrack.layerDefinitions
|
|
1571
|
+
else {
|
|
1572
|
+
let errorMessage = "\(#function) " + "layer definitions not available for track: '\(trackId)' !"
|
|
1573
|
+
self.emitRequiredKeysError(errorMessage)
|
|
1574
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1575
|
+
return
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
let parsedLayerDefinitions = HMSDecoder.getSimulcastLayerDefinitions(for: layerDefinitions)
|
|
1579
|
+
|
|
1580
|
+
resolve?(parsedLayerDefinitions)
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
func getVideoTrackLayer(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
1585
|
+
|
|
1586
|
+
guard let trackId = data.value(forKey: "trackId") as? String
|
|
1587
|
+
else {
|
|
1588
|
+
let errorMessage = "\(#function) " + HMSHelper.getUnavailableRequiredKey(data, ["trackId"])
|
|
1589
|
+
emitRequiredKeysError(errorMessage)
|
|
1590
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1591
|
+
return
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
DispatchQueue.main.async { [weak self] in
|
|
1595
|
+
|
|
1596
|
+
guard let self = self,
|
|
1597
|
+
let remotePeers = self.hms?.remotePeers,
|
|
1598
|
+
let remoteVideoTrack = HMSHelper.getRemoteVideoTrackFromTrackId(trackId, remotePeers)
|
|
1599
|
+
else {
|
|
1600
|
+
let errorMessage = "\(#function) " + "TRACK_NOT_FOUND"
|
|
1601
|
+
self?.emitRequiredKeysError(errorMessage)
|
|
1602
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1603
|
+
return
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
let parsedLayer = HMSDecoder.getString(from: remoteVideoTrack.layer)
|
|
1607
|
+
|
|
1608
|
+
resolve?(parsedLayer)
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
func setVideoTrackLayer(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
1613
|
+
guard let trackId = data.value(forKey: "trackId") as? String,
|
|
1614
|
+
let layer = data.value(forKey: "layer") as? String
|
|
1615
|
+
else {
|
|
1616
|
+
let errorMessage = "\(#function) " + HMSHelper.getUnavailableRequiredKey(data, ["trackId", "layer"])
|
|
1617
|
+
emitRequiredKeysError(errorMessage)
|
|
1618
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1619
|
+
return
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
DispatchQueue.main.async { [weak self] in
|
|
1623
|
+
|
|
1624
|
+
guard let self = self,
|
|
1625
|
+
let remotePeers = self.hms?.remotePeers,
|
|
1626
|
+
let remoteVideoTrack = HMSHelper.getRemoteVideoTrackFromTrackId(trackId, remotePeers)
|
|
1627
|
+
else {
|
|
1628
|
+
let errorMessage = "\(#function) " + "TRACK_NOT_FOUND"
|
|
1629
|
+
self?.emitRequiredKeysError(errorMessage)
|
|
1630
|
+
reject?(errorMessage, errorMessage, nil)
|
|
1631
|
+
return
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
switch layer.uppercased() {
|
|
1635
|
+
case "LOW":
|
|
1636
|
+
remoteVideoTrack.layer = .low
|
|
1637
|
+
case "MEDIUM":
|
|
1638
|
+
remoteVideoTrack.layer = .mid
|
|
1639
|
+
default:
|
|
1640
|
+
remoteVideoTrack.layer = .high
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
resolve?(true)
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
// MARK: - Advanced Camera Controls
|
|
1648
|
+
|
|
1649
|
+
func captureImageAtMaxSupportedResolution(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
1650
|
+
|
|
1651
|
+
let withFlash = data["flash"] as? Bool ?? false
|
|
1652
|
+
|
|
1653
|
+
DispatchQueue.main.async { [weak self] in
|
|
1654
|
+
|
|
1655
|
+
guard let localPeer = self?.hms?.localPeer else {
|
|
1656
|
+
let errorMessage = "\(#function) An instance of Local Peer could not be found. Please check if a Room is joined."
|
|
1657
|
+
reject?("6004", errorMessage, nil)
|
|
1658
|
+
return
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
guard let localVideoTrack = localPeer.localVideoTrack()
|
|
1662
|
+
else {
|
|
1663
|
+
let errorMessage = "\(#function) Video Track of Local Peer could not be found. Please check if the Local Peer has permission to publish video & video is unmuted currently."
|
|
1664
|
+
reject?("6004", errorMessage, nil)
|
|
1665
|
+
return
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
localVideoTrack.captureImageAtMaxSupportedResolution(withFlash: withFlash) { image in
|
|
1669
|
+
|
|
1670
|
+
guard let rawImage = image, let capturedImage = rawImage.fixOrientation() else {
|
|
1671
|
+
let errorMessage = "\(#function) Could not capture image of the Local Peer's Video Track."
|
|
1672
|
+
reject?("6004", errorMessage, nil)
|
|
1673
|
+
return
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
guard let data = capturedImage.pngData() else {
|
|
1677
|
+
let errorMessage = "\(#function) Could not compress image of the Local Peer's Video Track to png data."
|
|
1678
|
+
reject?("6004", errorMessage, nil)
|
|
1679
|
+
return
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
let filePath = HMSRNSDK.getDocumentsDirectory().appendingPathComponent("hms_\(HMSRNSDK.getTimeStamp()).png")
|
|
1683
|
+
|
|
1684
|
+
do {
|
|
1685
|
+
try data.write(to: filePath)
|
|
1686
|
+
|
|
1687
|
+
resolve?(filePath.relativePath)
|
|
1688
|
+
} catch let error {
|
|
1689
|
+
let errorMessage = "\(#function) Could not write to disk the image data of the Local Peer's Video Track. \(error.localizedDescription)"
|
|
1690
|
+
reject?("6004", errorMessage, nil)
|
|
1691
|
+
return
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
// MARK: - Helper Functions
|
|
1698
|
+
|
|
1510
1699
|
private func getString(from update: HMSPeerUpdate) -> String {
|
|
1511
1700
|
switch update {
|
|
1512
1701
|
case .peerJoined:
|
|
@@ -1571,9 +1760,32 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
1571
1760
|
}
|
|
1572
1761
|
|
|
1573
1762
|
func emitRequiredKeysError(_ error: String) {
|
|
1574
|
-
if eventsEnableStatus[ON_ERROR] != true {
|
|
1763
|
+
if eventsEnableStatus[HMSConstants.ON_ERROR] != true {
|
|
1575
1764
|
return
|
|
1576
1765
|
}
|
|
1577
|
-
delegate?.emitEvent(ON_ERROR, ["error": ["code":
|
|
1766
|
+
delegate?.emitEvent(HMSConstants.ON_ERROR, ["error": ["code": 7000, "description": error, "isTerminal": false, "canRetry": true], "id": id]) // DOUBT: Error code 6002 or 7000?
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
static private func getDocumentsDirectory() -> URL {
|
|
1770
|
+
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
|
|
1771
|
+
return paths[0]
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
static private func getTimeStamp() -> String {
|
|
1775
|
+
"\(Date().timeIntervalSince1970)"
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
extension UIImage {
|
|
1780
|
+
func fixOrientation() -> UIImage? {
|
|
1781
|
+
if self.imageOrientation == UIImage.Orientation.up {
|
|
1782
|
+
return self
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
UIGraphicsBeginImageContext(self.size)
|
|
1786
|
+
self.draw(in: CGRect(origin: .zero, size: self.size))
|
|
1787
|
+
let normalizedImage = UIGraphicsGetImageFromCurrentImageContext()
|
|
1788
|
+
UIGraphicsEndImageContext()
|
|
1789
|
+
return normalizedImage
|
|
1578
1790
|
}
|
|
1579
1791
|
}
|