@100mslive/react-native-hms 1.4.0 → 1.6.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 +94 -38
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +446 -107
- package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +5 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSView.kt +42 -25
- package/android/src/main/res/layout/hms_view.xml +2 -2
- package/ios/HMSConstants.swift +33 -0
- package/ios/HMSDecoder.swift +372 -157
- package/ios/HMSHelper.swift +44 -7
- package/ios/HMSManager.m +17 -2
- package/ios/HMSManager.swift +177 -75
- package/ios/HMSRNSDK.swift +641 -199
- package/ios/HMSView.m +1 -0
- package/ios/HMSView.swift +21 -19
- package/lib/commonjs/classes/HMSAudioTrackSettings.js +14 -0
- package/lib/commonjs/classes/HMSAudioTrackSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSCameraControl.js +28 -0
- package/lib/commonjs/classes/HMSCameraControl.js.map +1 -0
- package/lib/commonjs/classes/HMSEncoder.js +97 -14
- package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSIOSAudioMode.js +13 -0
- package/lib/commonjs/classes/HMSIOSAudioMode.js.map +1 -0
- 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 +82 -45
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/HMSSessionStore.js +173 -0
- package/lib/commonjs/classes/HMSSessionStore.js.map +1 -0
- 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/HMSUpdateListenerActions.js +8 -0
- package/lib/commonjs/classes/HMSUpdateListenerActions.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoResolution.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoTrackSettings.js +5 -0
- package/lib/commonjs/classes/HMSVideoTrackSettings.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 +72 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/emitter/EventEmitter.js +162 -0
- package/lib/commonjs/utils/emitter/EventEmitter.js.map +1 -0
- package/lib/commonjs/utils/emitter/_EmitterSubscription.js +46 -0
- package/lib/commonjs/utils/emitter/_EmitterSubscription.js.map +1 -0
- package/lib/commonjs/utils/emitter/_EventSubscription.js +36 -0
- package/lib/commonjs/utils/emitter/_EventSubscription.js.map +1 -0
- package/lib/commonjs/utils/emitter/_EventSubscriptionVendor.js +90 -0
- package/lib/commonjs/utils/emitter/_EventSubscriptionVendor.js.map +1 -0
- package/lib/commonjs/utils/index.js +17 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/classes/HMSAudioTrackSettings.js +14 -0
- package/lib/module/classes/HMSAudioTrackSettings.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 +97 -14
- package/lib/module/classes/HMSEncoder.js.map +1 -1
- package/lib/module/classes/HMSIOSAudioMode.js +6 -0
- package/lib/module/classes/HMSIOSAudioMode.js.map +1 -0
- 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 +83 -45
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/HMSSessionStore.js +166 -0
- package/lib/module/classes/HMSSessionStore.js.map +1 -0
- 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/HMSUpdateListenerActions.js +8 -0
- package/lib/module/classes/HMSUpdateListenerActions.js.map +1 -1
- package/lib/module/classes/HMSVideoResolution.js.map +1 -1
- package/lib/module/classes/HMSVideoTrackSettings.js +5 -0
- package/lib/module/classes/HMSVideoTrackSettings.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 +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/emitter/EventEmitter.js +151 -0
- package/lib/module/utils/emitter/EventEmitter.js.map +1 -0
- package/lib/module/utils/emitter/_EmitterSubscription.js +39 -0
- package/lib/module/utils/emitter/_EmitterSubscription.js.map +1 -0
- package/lib/module/utils/emitter/_EventSubscription.js +29 -0
- package/lib/module/utils/emitter/_EventSubscription.js.map +1 -0
- package/lib/module/utils/emitter/_EventSubscriptionVendor.js +83 -0
- package/lib/module/utils/emitter/_EventSubscriptionVendor.js.map +1 -0
- package/lib/module/utils/index.js +2 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/classes/HMSAudioTrackSettings.d.ts +14 -0
- package/lib/typescript/classes/HMSCameraControl.d.ts +9 -0
- package/lib/typescript/classes/HMSEncoder.d.ts +13 -1
- package/lib/typescript/classes/HMSIOSAudioMode.d.ts +4 -0
- 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 +21 -31
- package/lib/typescript/classes/HMSSessionStore.d.ts +63 -0
- 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/HMSUpdateListenerActions.d.ts +9 -1
- package/lib/typescript/classes/HMSVideoResolution.d.ts +2 -2
- package/lib/typescript/classes/HMSVideoTrackSettings.d.ts +5 -0
- package/lib/typescript/classes/HmsView.d.ts +2 -2
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/utils/emitter/EventEmitter.d.ts +91 -0
- package/lib/typescript/utils/emitter/_EmitterSubscription.d.ts +29 -0
- package/lib/typescript/utils/emitter/_EventSubscription.d.ts +19 -0
- package/lib/typescript/utils/emitter/_EventSubscriptionVendor.d.ts +44 -0
- package/lib/typescript/utils/index.d.ts +1 -0
- package/package.json +21 -2
- package/sdk-versions.json +3 -3
- package/src/classes/HMSAudioTrackSettings.ts +16 -0
- package/src/classes/HMSCameraControl.ts +21 -0
- package/src/classes/HMSEncoder.ts +126 -11
- package/src/classes/HMSIOSAudioMode.ts +4 -0
- 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 +124 -52
- package/src/classes/HMSSessionStore.ts +209 -0
- 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/HMSUpdateListenerActions.ts +8 -0
- package/src/classes/HMSVideoResolution.ts +1 -1
- package/src/classes/HMSVideoTrackSettings.ts +5 -0
- package/src/classes/HmsView.tsx +5 -1
- package/src/index.ts +10 -0
- package/src/utils/emitter/EventEmitter.ts +160 -0
- package/src/utils/emitter/_EmitterSubscription.ts +44 -0
- package/src/utils/emitter/_EventSubscription.ts +28 -0
- package/src/utils/emitter/_EventSubscriptionVendor.ts +89 -0
- package/src/utils/index.ts +1 -0
package/ios/HMSDecoder.swift
CHANGED
|
@@ -51,32 +51,39 @@ class HMSDecoder: NSObject {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
static func getHmsRoom(_ hmsRoom: HMSRoom?) -> [String: Any] {
|
|
54
|
+
var data = [String: Any]()
|
|
54
55
|
|
|
55
|
-
guard let room = hmsRoom else { return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
let sessionId = room.sessionID
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
guard let room = hmsRoom else { return data }
|
|
57
|
+
|
|
58
|
+
data["id"] = room.roomID ?? ""
|
|
59
|
+
if let sessionId = room.sessionID {
|
|
60
|
+
data["sessionId"] = sessionId
|
|
61
|
+
}
|
|
62
|
+
data["name"] = room.name ?? ""
|
|
63
|
+
if let metaData = room.metaData {
|
|
64
|
+
data["metaData"] = metaData
|
|
65
|
+
}
|
|
66
|
+
data["peerCount"] = room.peerCount ?? 0
|
|
67
|
+
// if let startedAt = room.sessionStartedAt?.timeIntervalSince1970 {
|
|
68
|
+
// data["startedAt"] = startedAt * 1000
|
|
69
|
+
// }
|
|
70
|
+
data["browserRecordingState"] = HMSDecoder.getHMSBrowserRecordingState(hmsRoom?.browserRecordingState)
|
|
71
|
+
data["rtmpHMSRtmpStreamingState"] = HMSDecoder.getHMSRtmpStreamingState(hmsRoom?.rtmpStreamingState)
|
|
72
|
+
data["serverRecordingState"] = HMSDecoder.getHMSServerRecordingState(hmsRoom?.serverRecordingState)
|
|
73
|
+
data["hlsStreamingState"] = HMSDecoder.getHlsStreamingState(hmsRoom?.hlsStreamingState)
|
|
74
|
+
data["hlsRecordingState"] = HMSDecoder.getHlsRecordingState(hmsRoom?.hlsRecordingState)
|
|
69
75
|
var peers = [[String: Any]]()
|
|
70
76
|
|
|
71
77
|
for peer in room.peers {
|
|
72
78
|
let parsedPeer = getHmsPeerSubset(peer)
|
|
73
79
|
peers.append(parsedPeer)
|
|
74
80
|
if peer.isLocal {
|
|
75
|
-
localPeer = parsedPeer
|
|
81
|
+
data["localPeer"] = parsedPeer
|
|
76
82
|
}
|
|
77
83
|
}
|
|
84
|
+
data["peers"] = peers
|
|
78
85
|
|
|
79
|
-
return
|
|
86
|
+
return data
|
|
80
87
|
}
|
|
81
88
|
|
|
82
89
|
static func getPeerUpdateTypeOrdinals(_ peerUpdateType: HMSPeerUpdate) -> String? {
|
|
@@ -150,42 +157,43 @@ class HMSDecoder: NSObject {
|
|
|
150
157
|
}
|
|
151
158
|
|
|
152
159
|
static func getHmsPeer (_ hmsPeer: HMSPeer?) -> [String: Any] {
|
|
160
|
+
var data = [String: Any]()
|
|
153
161
|
|
|
154
|
-
guard let peer = hmsPeer else { return
|
|
155
|
-
|
|
156
|
-
var peerDict = [String: Any]()
|
|
162
|
+
guard let peer = hmsPeer else { return data }
|
|
157
163
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
164
|
+
data["peerID"] = peer.peerID
|
|
165
|
+
data["name"] = peer.name
|
|
166
|
+
data["isLocal"] = peer.isLocal
|
|
161
167
|
|
|
162
|
-
if let
|
|
163
|
-
|
|
168
|
+
if let customerUserID = peer.customerUserID {
|
|
169
|
+
data["customerUserID"] = customerUserID
|
|
164
170
|
}
|
|
165
171
|
|
|
166
|
-
|
|
172
|
+
if let metadata = peer.metadata {
|
|
173
|
+
data["metadata"] = metadata
|
|
174
|
+
}
|
|
167
175
|
|
|
168
176
|
// joinedAt
|
|
169
177
|
|
|
170
|
-
|
|
178
|
+
data["role"] = getHmsRole(peer.role)
|
|
171
179
|
|
|
172
|
-
if let
|
|
173
|
-
|
|
180
|
+
if let networkQuality = peer.networkQuality {
|
|
181
|
+
data["networkQuality"] = getHmsNetworkQuality(networkQuality)
|
|
174
182
|
}
|
|
175
183
|
|
|
176
|
-
if let
|
|
177
|
-
|
|
184
|
+
if let audioTrack = peer.audioTrack {
|
|
185
|
+
data["audioTrack"] = getHmsAudioTrack(audioTrack)
|
|
178
186
|
}
|
|
179
187
|
|
|
180
|
-
if let
|
|
181
|
-
|
|
188
|
+
if let videoTrack = peer.videoTrack {
|
|
189
|
+
data["videoTrack"] = getHmsVideoTrack(videoTrack)
|
|
182
190
|
}
|
|
183
191
|
|
|
184
|
-
if let
|
|
185
|
-
|
|
192
|
+
if let auxiliaryTracks = peer.auxiliaryTracks, auxiliaryTracks.count > 0 {
|
|
193
|
+
data["auxiliaryTracks"] = getAllTracks(auxiliaryTracks)
|
|
186
194
|
}
|
|
187
195
|
|
|
188
|
-
return
|
|
196
|
+
return data
|
|
189
197
|
}
|
|
190
198
|
|
|
191
199
|
static func getAllTracks (_ tracks: [HMSTrack]) -> [[String: Any]] {
|
|
@@ -270,7 +278,7 @@ class HMSDecoder: NSObject {
|
|
|
270
278
|
return ["trackId": localVideo.trackId, "source": localVideo.source, "trackDescription": localVideo.trackDescription, "settings": getHmsVideoTrackSettings(localVideo.settings), "isMute": localVideo.isMute(), "type": type, "kind": type]
|
|
271
279
|
}
|
|
272
280
|
|
|
273
|
-
static func getHmsAudioTrackSettings(_ hmsAudioTrackSettings: HMSAudioTrackSettings?) -> [String: Any] {
|
|
281
|
+
static func getHmsAudioTrackSettings(_ hmsAudioTrackSettings: HMSAudioTrackSettings?) -> [String: Any?] {
|
|
274
282
|
|
|
275
283
|
guard let settings = hmsAudioTrackSettings else { return [String: Any]() }
|
|
276
284
|
|
|
@@ -324,10 +332,10 @@ class HMSDecoder: NSObject {
|
|
|
324
332
|
}
|
|
325
333
|
}
|
|
326
334
|
|
|
327
|
-
static func getHmsVideoResolution(_ hmsVideoResolution: HMSVideoResolution?) -> [
|
|
328
|
-
guard let resolution = hmsVideoResolution else { return [
|
|
335
|
+
static func getHmsVideoResolution(_ hmsVideoResolution: HMSVideoResolution?) -> [Double] {
|
|
336
|
+
guard let resolution = hmsVideoResolution else { return [] }
|
|
329
337
|
|
|
330
|
-
return [
|
|
338
|
+
return [resolution.width, resolution.height]
|
|
331
339
|
}
|
|
332
340
|
|
|
333
341
|
static func getHmsRemotePeers (_ remotePeers: [HMSRemotePeer]?) -> [[String: Any]] {
|
|
@@ -406,80 +414,56 @@ class HMSDecoder: NSObject {
|
|
|
406
414
|
}
|
|
407
415
|
|
|
408
416
|
static func getHmsRole(_ hmsRole: HMSRole?) -> [String: Any] {
|
|
417
|
+
var parsedRole = [String: Any]()
|
|
409
418
|
|
|
410
|
-
guard let role = hmsRole else { return
|
|
419
|
+
guard let role = hmsRole else { return parsedRole }
|
|
411
420
|
|
|
412
|
-
|
|
421
|
+
parsedRole["name"] = role.name
|
|
413
422
|
|
|
414
423
|
if restrictRoleData[role.name] == true {
|
|
415
|
-
return
|
|
424
|
+
return parsedRole
|
|
416
425
|
}
|
|
417
426
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
427
|
+
parsedRole["permissions"] = getPermissions(role.permissions)
|
|
428
|
+
parsedRole["publishSettings"] = getPublishSettings(from: role.publishSettings)
|
|
429
|
+
parsedRole["subscribeSettings"] = getSubscribeSettings(from: role.subscribeSettings)
|
|
430
|
+
parsedRole["priority"] = role.priority
|
|
422
431
|
|
|
423
|
-
return
|
|
432
|
+
return parsedRole
|
|
424
433
|
}
|
|
425
434
|
|
|
426
|
-
static func
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
return ["endRoom": endRoom,
|
|
438
|
-
"removeOthers": removeOthers,
|
|
439
|
-
"browserRecording": browserRecording,
|
|
440
|
-
"hlsStreaming": hlsStreaming,
|
|
441
|
-
"rtmpStreaming": rtmpStreaming,
|
|
442
|
-
"mute": mute,
|
|
443
|
-
"unmute": unmute,
|
|
444
|
-
"changeRole": changeRole]
|
|
435
|
+
static private func getPermissions (_ permissions: HMSPermissions) -> [String: Any] {
|
|
436
|
+
[
|
|
437
|
+
"endRoom": permissions.endRoom ?? false,
|
|
438
|
+
"removeOthers": permissions.removeOthers ?? false,
|
|
439
|
+
"browserRecording": permissions.browserRecording ?? false,
|
|
440
|
+
"hlsStreaming": permissions.hlsStreaming ?? false,
|
|
441
|
+
"rtmpStreaming": permissions.rtmpStreaming ?? false,
|
|
442
|
+
"mute": permissions.mute ?? false,
|
|
443
|
+
"unmute": permissions.unmute ?? false,
|
|
444
|
+
"changeRole": permissions.changeRole ?? false
|
|
445
|
+
]
|
|
445
446
|
}
|
|
446
447
|
|
|
447
|
-
|
|
448
|
+
// MARK: - HMSRole Publish Settings and Utility functions
|
|
449
|
+
static private func getPublishSettings(from publishSettings: HMSPublishSettings) -> [String: Any]? {
|
|
448
450
|
|
|
449
|
-
var
|
|
451
|
+
var settings = [String: Any]()
|
|
450
452
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
453
|
+
settings["audio"] = getHmsAudioSettings(publishSettings.audio)
|
|
454
|
+
settings["video"] = getHmsVideoSettings(publishSettings.video)
|
|
455
|
+
settings["screen"] = getHmsVideoSettings(publishSettings.screen)
|
|
454
456
|
|
|
455
457
|
if let allowed = publishSettings.allowed {
|
|
456
|
-
|
|
458
|
+
settings["allowed"] = getWriteableArray(allowed)
|
|
457
459
|
}
|
|
458
460
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
static func getHmsSubscribeSettings (_ subscribeSettings: HMSSubscribeSettings?) -> [String: Any] {
|
|
463
|
-
guard let settings = subscribeSettings
|
|
464
|
-
else { return [String: Any]() }
|
|
465
|
-
|
|
466
|
-
let maxSubsBitRate = settings.maxSubsBitRate
|
|
467
|
-
let subscribeTo = settings.subscribeToRoles
|
|
468
|
-
|
|
469
|
-
return ["maxSubsBitRate": maxSubsBitRate, "subscribeTo": subscribeTo ?? []]
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
static func getHmsSubscribeDegradationSettings (_ hmsSubscribeDegradationParams: HMSSubscribeDegradationPolicy?) -> [String: Any] {
|
|
473
|
-
guard let params = hmsSubscribeDegradationParams
|
|
474
|
-
else {
|
|
475
|
-
return [String: Any]()
|
|
461
|
+
if let simulcast = publishSettings.simulcast,
|
|
462
|
+
let simulcastSettings = getSimulcastSettings(from: simulcast) {
|
|
463
|
+
settings["simulcast"] = simulcastSettings
|
|
476
464
|
}
|
|
477
465
|
|
|
478
|
-
|
|
479
|
-
let packetLossThreshold = String(params.packetLossThreshold ?? 0)
|
|
480
|
-
let recoverGracePeriodSeconds = String(params.recoverGracePeriodSeconds ?? 0)
|
|
481
|
-
|
|
482
|
-
return ["degradeGracePeriodSeconds": degradeGracePeriodSeconds, "packetLossThreshold": packetLossThreshold, "recoverGracePeriodSeconds": recoverGracePeriodSeconds]
|
|
466
|
+
return settings
|
|
483
467
|
}
|
|
484
468
|
|
|
485
469
|
static func getWriteableArray(_ array: [String]?) -> [String] {
|
|
@@ -492,14 +476,14 @@ class HMSDecoder: NSObject {
|
|
|
492
476
|
return decodedArray
|
|
493
477
|
}
|
|
494
478
|
|
|
495
|
-
static func getHmsAudioSettings(_ audioSettings: HMSAudioSettings) -> [String: Any] {
|
|
479
|
+
static private func getHmsAudioSettings(_ audioSettings: HMSAudioSettings) -> [String: Any] {
|
|
496
480
|
let bitRate = audioSettings.bitRate
|
|
497
481
|
let codec = audioSettings.codec
|
|
498
482
|
|
|
499
483
|
return ["bitRate": bitRate, "codec": codec]
|
|
500
484
|
}
|
|
501
485
|
|
|
502
|
-
static func getHmsVideoSettings(_ videoSettings: HMSVideoSettings) -> [String: Any] {
|
|
486
|
+
static private func getHmsVideoSettings(_ videoSettings: HMSVideoSettings) -> [String: Any] {
|
|
503
487
|
|
|
504
488
|
let bitRate = videoSettings.bitRate
|
|
505
489
|
let codec = videoSettings.codec
|
|
@@ -510,36 +494,126 @@ class HMSDecoder: NSObject {
|
|
|
510
494
|
return ["bitRate": bitRate ?? 0, "codec": codec, "frameRate": frameRate, "width": width, "height": height]
|
|
511
495
|
}
|
|
512
496
|
|
|
513
|
-
static func
|
|
497
|
+
static private func getSimulcastSettings(from simulcast: HMSSimulcastSettings) -> [String: Any]? {
|
|
514
498
|
|
|
515
|
-
|
|
499
|
+
var videoSettings: [String: Any]?
|
|
516
500
|
|
|
517
|
-
let
|
|
501
|
+
if let video = simulcast.video,
|
|
502
|
+
let settingsPolicy = getSimulcastSettingsPolicy(from: video) {
|
|
503
|
+
videoSettings = settingsPolicy
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
var screenSettings: [String: Any]?
|
|
507
|
+
|
|
508
|
+
if let screen = simulcast.screen,
|
|
509
|
+
let settingsPolicy = getSimulcastSettingsPolicy(from: screen) {
|
|
510
|
+
screenSettings = settingsPolicy
|
|
511
|
+
}
|
|
518
512
|
|
|
519
|
-
|
|
513
|
+
if videoSettings != nil || screenSettings != nil {
|
|
514
|
+
var settings = [String: Any]()
|
|
515
|
+
|
|
516
|
+
if let video = videoSettings {
|
|
517
|
+
settings["video"] = video
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if let screen = screenSettings {
|
|
521
|
+
settings["screen"] = screen
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return settings
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return nil
|
|
520
528
|
}
|
|
521
529
|
|
|
522
|
-
static func
|
|
523
|
-
var layersSettingsPolicy = [[String: Any]]()
|
|
524
|
-
if let settingsPolicies = layers {
|
|
525
|
-
for settingsPolicy in settingsPolicies {
|
|
526
|
-
let rid = settingsPolicy.rid
|
|
527
|
-
let scaleResolutionDownBy = settingsPolicy.scaleResolutionDownBy ?? 0
|
|
528
|
-
let maxBitrate = settingsPolicy.maxBitrate ?? -1
|
|
529
|
-
let maxFramerate = settingsPolicy.maxFramerate ?? -1
|
|
530
|
+
static private func getSimulcastSettingsPolicy(from simulcastSettingsPolicy: HMSSimulcastSettingsPolicy) -> [String: Any]? {
|
|
530
531
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
"maxBitrate": maxBitrate,
|
|
534
|
-
"maxFramerate": maxFramerate] as [String: Any]
|
|
532
|
+
if let layers = simulcastSettingsPolicy.layers {
|
|
533
|
+
var simulcastSettingsPolicy = [String: Any]()
|
|
535
534
|
|
|
536
|
-
|
|
535
|
+
var layersData = [[String: Any]]()
|
|
536
|
+
|
|
537
|
+
for layer in layers {
|
|
538
|
+
layersData.append(getSimulcastLayerSettingsPolicy(from: layer))
|
|
537
539
|
}
|
|
540
|
+
|
|
541
|
+
simulcastSettingsPolicy["layers"] = layersData
|
|
542
|
+
|
|
543
|
+
return simulcastSettingsPolicy
|
|
538
544
|
}
|
|
539
545
|
|
|
540
|
-
return
|
|
546
|
+
return nil
|
|
541
547
|
}
|
|
542
548
|
|
|
549
|
+
static private func getSimulcastLayerSettingsPolicy(from layerPolicy: HMSSimulcastLayerSettingsPolicy) -> [String: Any] {
|
|
550
|
+
|
|
551
|
+
var layerSettings = [String: Any]()
|
|
552
|
+
|
|
553
|
+
layerSettings["rid"] = layerPolicy.rid
|
|
554
|
+
|
|
555
|
+
if let scale = layerPolicy.scaleResolutionDownBy {
|
|
556
|
+
layerSettings["scaleResolutionDownBy"] = scale
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
if let maxBitrate = layerPolicy.maxBitrate {
|
|
560
|
+
layerSettings["maxBitrate"] = maxBitrate
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if let maxFramerate = layerPolicy.maxFramerate {
|
|
564
|
+
layerSettings["maxFramerate"] = maxFramerate
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
return layerSettings
|
|
568
|
+
}
|
|
569
|
+
// MARK: END: - HMSRole Publish Settings and Utility functions
|
|
570
|
+
|
|
571
|
+
// MARK: - HMSRole Subscribe Settings and Utility functions
|
|
572
|
+
static private func getSubscribeSettings(from subscribeSettings: HMSSubscribeSettings) -> [String: Any] {
|
|
573
|
+
|
|
574
|
+
var settings = [String: Any]()
|
|
575
|
+
|
|
576
|
+
settings["maxSubsBitRate"] = subscribeSettings.maxSubsBitRate
|
|
577
|
+
|
|
578
|
+
if let subscribeToRoles = subscribeSettings.subscribeToRoles {
|
|
579
|
+
settings["subscribeTo"] = subscribeToRoles
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
if let subscribeDegradation = subscribeSettings.subscribeDegradation,
|
|
583
|
+
let parsedSubscribeDegradationPolicy = getSubscribeDegradationSettings(from: subscribeDegradation) {
|
|
584
|
+
settings["subscribeDegradation"] = parsedSubscribeDegradationPolicy
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
return settings
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
static func getSubscribeDegradationSettings(from subscribeDegradation: HMSSubscribeDegradationPolicy) -> [String: Any]? {
|
|
591
|
+
|
|
592
|
+
if subscribeDegradation.packetLossThreshold != nil ||
|
|
593
|
+
subscribeDegradation.degradeGracePeriodSeconds != nil ||
|
|
594
|
+
subscribeDegradation.recoverGracePeriodSeconds != nil {
|
|
595
|
+
|
|
596
|
+
var settings = [String: Any]()
|
|
597
|
+
|
|
598
|
+
if let packetLossThreshold = subscribeDegradation.packetLossThreshold {
|
|
599
|
+
settings["packetLossThreshold"] = packetLossThreshold
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if let degradeGracePeriodSeconds = subscribeDegradation.degradeGracePeriodSeconds {
|
|
603
|
+
settings["degradeGracePeriodSeconds"] = degradeGracePeriodSeconds
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if let recoverGracePeriodSeconds = subscribeDegradation.recoverGracePeriodSeconds {
|
|
607
|
+
settings["recoverGracePeriodSeconds"] = recoverGracePeriodSeconds
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
return settings
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
return nil
|
|
614
|
+
}
|
|
615
|
+
// MARK: END: - HMSRole Subscribe Settings and Utility functions
|
|
616
|
+
|
|
543
617
|
static func getHmsRoleChangeRequest(_ roleChangeRequest: HMSRoleChangeRequest, _ id: String?) -> [String: Any] {
|
|
544
618
|
|
|
545
619
|
if let sdkId = id {
|
|
@@ -575,17 +649,17 @@ class HMSDecoder: NSObject {
|
|
|
575
649
|
return request
|
|
576
650
|
}
|
|
577
651
|
|
|
578
|
-
static func getError(_ errorObj: Error?) -> [String: Any]
|
|
579
|
-
if let error = errorObj as? HMSError {
|
|
580
|
-
let code = error.errorCode
|
|
581
|
-
let description = error.localizedDescription
|
|
582
|
-
let isTerminal = error.userInfo[HMSIsTerminalUserInfoKey] as? Bool ?? false
|
|
583
|
-
let canRetry = error.userInfo[HMSCanRetryUserInfoKey] as? Bool ?? false
|
|
652
|
+
static func getError(_ errorObj: Error?) -> [String: Any] {
|
|
584
653
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
return
|
|
654
|
+
guard let error = errorObj as? HMSError else {
|
|
655
|
+
print(#function, "WARNING! Empty Error object parsing should not be performed")
|
|
656
|
+
return ["code": 7000, "description": "Error object not found", "isTerminal": false, "canRetry": true]
|
|
588
657
|
}
|
|
658
|
+
|
|
659
|
+
let isTerminal = error.userInfo[HMSIsTerminalUserInfoKey] as? Bool ?? false
|
|
660
|
+
let canRetry = error.userInfo[HMSCanRetryUserInfoKey] as? Bool ?? false
|
|
661
|
+
|
|
662
|
+
return ["code": error.errorCode, "description": error.localizedDescription, "isTerminal": isTerminal, "canRetry": canRetry]
|
|
589
663
|
}
|
|
590
664
|
|
|
591
665
|
static func getHMSBrowserRecordingState(_ data: HMSBrowserRecordingState?) -> [String: Any] {
|
|
@@ -596,7 +670,9 @@ class HMSDecoder: NSObject {
|
|
|
596
670
|
|
|
597
671
|
state["running"] = recordingState.running
|
|
598
672
|
|
|
599
|
-
|
|
673
|
+
if let startedAt = recordingState.startedAt?.timeIntervalSince1970 {
|
|
674
|
+
state["startedAt"] = startedAt * 1000
|
|
675
|
+
}
|
|
600
676
|
|
|
601
677
|
if let error = recordingState.error {
|
|
602
678
|
state["error"] = HMSDecoder.getError(error)
|
|
@@ -615,7 +691,9 @@ class HMSDecoder: NSObject {
|
|
|
615
691
|
|
|
616
692
|
state["running"] = streamingState.running
|
|
617
693
|
|
|
618
|
-
|
|
694
|
+
if let startedAt = streamingState.startedAt?.timeIntervalSince1970 {
|
|
695
|
+
state["startedAt"] = startedAt * 1000
|
|
696
|
+
}
|
|
619
697
|
|
|
620
698
|
if let error = streamingState.error {
|
|
621
699
|
state["error"] = HMSDecoder.getError(error)
|
|
@@ -634,7 +712,9 @@ class HMSDecoder: NSObject {
|
|
|
634
712
|
|
|
635
713
|
state["running"] = recordingState.running
|
|
636
714
|
|
|
637
|
-
|
|
715
|
+
if let startedAt = recordingState.startedAt?.timeIntervalSince1970 {
|
|
716
|
+
state["startedAt"] = startedAt * 1000
|
|
717
|
+
}
|
|
638
718
|
|
|
639
719
|
if let error = recordingState.error {
|
|
640
720
|
state["error"] = HMSDecoder.getError(error)
|
|
@@ -658,16 +738,17 @@ class HMSDecoder: NSObject {
|
|
|
658
738
|
}
|
|
659
739
|
|
|
660
740
|
static func getHlsRecordingState(_ data: HMSHLSRecordingState?) -> [String: Any] {
|
|
661
|
-
|
|
662
|
-
let running = recordingState.running
|
|
663
|
-
let startedAt = recordingState.startedAt?.timeIntervalSince1970 ?? 0
|
|
664
|
-
let singleFilePerLayer = recordingState.singleFilePerLayer
|
|
665
|
-
let enableVOD = recordingState.enableVOD
|
|
741
|
+
var state = [String: Any]()
|
|
666
742
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
743
|
+
if let recordingState = data {
|
|
744
|
+
state["running"] = recordingState.running
|
|
745
|
+
state["singleFilePerLayer"] = recordingState.singleFilePerLayer
|
|
746
|
+
state["videoOnDemand"] = recordingState.enableVOD
|
|
747
|
+
if let startedAt = recordingState.startedAt?.timeIntervalSince1970 {
|
|
748
|
+
state["startedAt"] = startedAt * 1000
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
return state
|
|
671
752
|
}
|
|
672
753
|
|
|
673
754
|
static func getHMSHlsVariant(_ data: [HMSHLSVariant]?) -> [[String: Any]] {
|
|
@@ -675,43 +756,144 @@ class HMSDecoder: NSObject {
|
|
|
675
756
|
|
|
676
757
|
if let hlsVariant = data {
|
|
677
758
|
for variant in hlsVariant {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
759
|
+
var decodedVariant = [String: Any]()
|
|
760
|
+
decodedVariant["meetingUrl"] = variant.meetingURL.absoluteString
|
|
761
|
+
decodedVariant["metadata"] = variant.metadata
|
|
762
|
+
decodedVariant["hlsStreamUrl"] = variant.url.absoluteString
|
|
763
|
+
if let startedAt = variant.startedAt?.timeIntervalSince1970 {
|
|
764
|
+
decodedVariant["startedAt"] = startedAt * 1000
|
|
765
|
+
}
|
|
684
766
|
variants.append(decodedVariant)
|
|
685
767
|
}
|
|
686
768
|
}
|
|
687
769
|
return variants
|
|
688
770
|
}
|
|
689
771
|
|
|
690
|
-
static func getHMSRTCStats(_ data: HMSRTCStats) -> [
|
|
691
|
-
|
|
772
|
+
static func getHMSRTCStats(_ data: HMSRTCStats) -> [Any] {
|
|
773
|
+
// [bitrateReceived, bitrateSent, bytesReceived, bytesSent, packetsLost, packetsReceived, roundTripTime]
|
|
774
|
+
return [
|
|
775
|
+
data.bitrateReceived,
|
|
776
|
+
data.bitrateSent,
|
|
777
|
+
data.bytesReceived,
|
|
778
|
+
data.bytesSent,
|
|
779
|
+
data.packetsLost,
|
|
780
|
+
data.packetsReceived,
|
|
781
|
+
data.roundTripTime
|
|
782
|
+
]
|
|
692
783
|
}
|
|
693
784
|
|
|
694
|
-
static func getLocalAudioStats(_ data: HMSLocalAudioStats) -> [
|
|
695
|
-
|
|
785
|
+
static func getLocalAudioStats(_ data: HMSLocalAudioStats) -> [Any] {
|
|
786
|
+
// [bitrate, bytesSent, roundTripTime]
|
|
787
|
+
return [
|
|
788
|
+
data.bitrate,
|
|
789
|
+
data.bytesSent,
|
|
790
|
+
data.roundTripTime
|
|
791
|
+
]
|
|
696
792
|
}
|
|
697
793
|
|
|
698
|
-
static func getLocalVideoStats(_
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
794
|
+
static func getLocalVideoStats(_ localVideoStats: [HMSLocalVideoStats]) -> [[Any]] {
|
|
795
|
+
|
|
796
|
+
var statsArray = [[Any]]()
|
|
797
|
+
|
|
798
|
+
for stat in localVideoStats {
|
|
799
|
+
// [bitrate, bytesSent, roundTripTime, frameRate, resolution, layer, qualityLimitationReasons]
|
|
800
|
+
var layer = "HIGH"
|
|
801
|
+
|
|
802
|
+
if let simulcastLayerId = stat.simulcastLayerId as? UInt {
|
|
803
|
+
layer = getStringFromLayer(layer: HMSSimulcastLayer(rawValue: simulcastLayerId))
|
|
804
|
+
} else {
|
|
805
|
+
print(#function, "Error: Failed to cast to correct simulcastLayerId")
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
let data: [Any] = [
|
|
809
|
+
stat.bitrate,
|
|
810
|
+
stat.bytesSent,
|
|
811
|
+
stat.roundTripTime,
|
|
812
|
+
stat.frameRate,
|
|
813
|
+
HMSDecoder.getHmsVideoResolution(stat.resolution),
|
|
814
|
+
layer,
|
|
815
|
+
getQualityLimitations(stat.qualityLimitations)
|
|
816
|
+
]
|
|
817
|
+
statsArray.append(data)
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
return statsArray
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
static func getStringFromLayer(layer: HMSSimulcastLayer?) -> String {
|
|
824
|
+
switch layer {
|
|
825
|
+
case .high:
|
|
826
|
+
return "HIGH"
|
|
827
|
+
case .mid:
|
|
828
|
+
return "MEDIUM"
|
|
829
|
+
case .low:
|
|
830
|
+
return "LOW"
|
|
831
|
+
default:
|
|
832
|
+
return "HIGH"
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
static func getLayerFromString(layer: String) -> HMSSimulcastLayer {
|
|
837
|
+
switch layer {
|
|
838
|
+
case "HIGH":
|
|
839
|
+
return .high
|
|
840
|
+
case "MEDIUM":
|
|
841
|
+
return .mid
|
|
842
|
+
case "LOW":
|
|
843
|
+
return .low
|
|
844
|
+
default:
|
|
845
|
+
return .high
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
static private func getQualityLimitations(_ limitation: HMSQualityLimitationReasons) -> [String: Any] {
|
|
850
|
+
[
|
|
851
|
+
"bandwidth": limitation.bandwidth,
|
|
852
|
+
"cpu": limitation.cpu,
|
|
853
|
+
"none": limitation.none,
|
|
854
|
+
"other": limitation.other,
|
|
855
|
+
"qualityLimitationResolutionChanges": limitation.qualityLimitationResolutionChanges,
|
|
856
|
+
"reason": getStringFromLimitationReason(limitation.reason)
|
|
857
|
+
]
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
static private func getStringFromLimitationReason(_ reason: HMSQualityLimitationReason) -> String {
|
|
861
|
+
switch reason {
|
|
862
|
+
case .CPU:
|
|
863
|
+
return "CPU"
|
|
864
|
+
case .bandwidth:
|
|
865
|
+
return "BANDWIDTH"
|
|
866
|
+
case .none:
|
|
867
|
+
return "NONE"
|
|
868
|
+
case .other:
|
|
869
|
+
return "OTHER"
|
|
870
|
+
default:
|
|
871
|
+
return "UNKNOWN"
|
|
705
872
|
}
|
|
706
|
-
return dict
|
|
707
873
|
}
|
|
708
874
|
|
|
709
|
-
static func getRemoteAudioStats(_ data: HMSRemoteAudioStats) -> [
|
|
710
|
-
|
|
875
|
+
static func getRemoteAudioStats(_ data: HMSRemoteAudioStats) -> [Any] {
|
|
876
|
+
// [bitrate, bytesReceived, jitter, packetsLost, packetsReceived]
|
|
877
|
+
return [
|
|
878
|
+
data.bitrate,
|
|
879
|
+
data.bytesReceived,
|
|
880
|
+
data.jitter,
|
|
881
|
+
data.packetsLost,
|
|
882
|
+
data.packetsReceived
|
|
883
|
+
]
|
|
711
884
|
}
|
|
712
885
|
|
|
713
|
-
static func getRemoteVideoStats(_ data: HMSRemoteVideoStats) -> [
|
|
714
|
-
|
|
886
|
+
static func getRemoteVideoStats(_ data: HMSRemoteVideoStats) -> [Any] {
|
|
887
|
+
// [bitrate, bytesReceived, frameRate, jitter, packetsLost, packetsReceived, resolution]
|
|
888
|
+
return [
|
|
889
|
+
data.bitrate,
|
|
890
|
+
data.bytesReceived,
|
|
891
|
+
data.frameRate,
|
|
892
|
+
data.jitter,
|
|
893
|
+
data.packetsLost,
|
|
894
|
+
data.packetsReceived,
|
|
895
|
+
HMSDecoder.getHmsVideoResolution(data.resolution)
|
|
896
|
+
]
|
|
715
897
|
}
|
|
716
898
|
|
|
717
899
|
static func getHmsMessageRecipient(_ recipient: HMSMessageRecipient) -> [String: Any] {
|
|
@@ -749,4 +931,37 @@ class HMSDecoder: NSObject {
|
|
|
749
931
|
return ""
|
|
750
932
|
}
|
|
751
933
|
}
|
|
934
|
+
|
|
935
|
+
static func getSimulcastLayerDefinitions(for layerDefinitions: [HMSSimulcastLayerDefinition]) -> [[String: Any]] {
|
|
936
|
+
|
|
937
|
+
var parsedLayerDefinitions = [[String: Any]]()
|
|
938
|
+
|
|
939
|
+
for layer in layerDefinitions {
|
|
940
|
+
parsedLayerDefinitions.append(getSimulcastLayerDefinition(for: layer))
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
return parsedLayerDefinitions
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
static private func getSimulcastLayerDefinition(for definition: HMSSimulcastLayerDefinition) -> [String: Any] {
|
|
947
|
+
|
|
948
|
+
var parsedLayer = [String: Any]()
|
|
949
|
+
|
|
950
|
+
parsedLayer["layer"] = getString(from: definition.layer)
|
|
951
|
+
|
|
952
|
+
parsedLayer["resolution"] = getHmsVideoResolution(definition.resolution)
|
|
953
|
+
|
|
954
|
+
return parsedLayer
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
static func getString(from layer: HMSSimulcastLayer) -> String {
|
|
958
|
+
switch layer {
|
|
959
|
+
case .low:
|
|
960
|
+
return "LOW"
|
|
961
|
+
case .mid:
|
|
962
|
+
return "MEDIUM"
|
|
963
|
+
default:
|
|
964
|
+
return "HIGH"
|
|
965
|
+
}
|
|
966
|
+
}
|
|
752
967
|
}
|