@@ -11,22 +11,22 @@ import AgoraRtcKit
11
11
12
12
func mapToPoint( _ map: Dictionary < String , Any > ) -> CGPoint {
13
13
var point = CGPoint ( )
14
- if let x = map [ " x " ] as? Int {
15
- point. x = CGFloat ( x)
14
+ if let x = map [ " x " ] as? NSNumber {
15
+ point. x = CGFloat ( truncating : x)
16
16
}
17
- if let y = map [ " y " ] as? Int {
18
- point. y = CGFloat ( y)
17
+ if let y = map [ " y " ] as? NSNumber {
18
+ point. y = CGFloat ( truncating : y)
19
19
}
20
20
return point
21
21
}
22
22
23
23
func mapToSize( _ map: Dictionary < String , Any > ) -> CGSize {
24
24
var size = CGSize ( )
25
- if let width = map [ " width " ] as? Int {
26
- size. width = CGFloat ( width)
25
+ if let width = map [ " width " ] as? NSNumber {
26
+ size. width = CGFloat ( truncating : width)
27
27
}
28
- if let height = map [ " height " ] as? Int {
29
- size. height = CGFloat ( height)
28
+ if let height = map [ " height " ] as? NSNumber {
29
+ size. height = CGFloat ( truncating : height)
30
30
}
31
31
return size
32
32
}
@@ -43,30 +43,30 @@ func mapToVideoEncoderConfiguration(_ map: Dictionary<String, Any>) -> AgoraVide
43
43
if let dimensions = map [ " dimensions " ] as? Dictionary < String , Any > {
44
44
config. dimensions = mapToSize ( dimensions)
45
45
}
46
- if let frameRate = map [ " frameRate " ] as? Int {
47
- config. frameRate = frameRate
46
+ if let frameRate = map [ " frameRate " ] as? NSNumber {
47
+ config. frameRate = frameRate. intValue
48
48
}
49
- if let minFrameRate = map [ " minFrameRate " ] as? Int {
50
- config. minFrameRate = minFrameRate
49
+ if let minFrameRate = map [ " minFrameRate " ] as? NSNumber {
50
+ config. minFrameRate = minFrameRate. intValue
51
51
}
52
- if let bitrate = map [ " bitrate " ] as? Int {
53
- config. bitrate = bitrate
52
+ if let bitrate = map [ " bitrate " ] as? NSNumber {
53
+ config. bitrate = bitrate. intValue
54
54
}
55
- if let minBitrate = map [ " minBitrate " ] as? Int {
56
- config. minBitrate = minBitrate
55
+ if let minBitrate = map [ " minBitrate " ] as? NSNumber {
56
+ config. minBitrate = minBitrate. intValue
57
57
}
58
- if let orientationMode = map [ " orientationMode " ] as? Int {
59
- if let orientationMode = AgoraVideoOutputOrientationMode ( rawValue: orientationMode) {
58
+ if let orientationMode = map [ " orientationMode " ] as? NSNumber {
59
+ if let orientationMode = AgoraVideoOutputOrientationMode ( rawValue: orientationMode. intValue ) {
60
60
config. orientationMode = orientationMode
61
61
}
62
62
}
63
- if let degradationPreference = map [ " degradationPrefer " ] as? Int {
64
- if let degradationPreference = AgoraDegradationPreference ( rawValue: degradationPreference) {
63
+ if let degradationPreference = map [ " degradationPrefer " ] as? NSNumber {
64
+ if let degradationPreference = AgoraDegradationPreference ( rawValue: degradationPreference. intValue ) {
65
65
config. degradationPreference = degradationPreference
66
66
}
67
67
}
68
- if let mirrorMode = map [ " mirrorMode " ] as? Int {
69
- if let mirrorMode = AgoraVideoMirrorMode ( rawValue: UInt ( mirrorMode) ) {
68
+ if let mirrorMode = map [ " mirrorMode " ] as? NSNumber {
69
+ if let mirrorMode = AgoraVideoMirrorMode ( rawValue: mirrorMode. uintValue ) {
70
70
config. mirrorMode = mirrorMode
71
71
}
72
72
}
@@ -75,19 +75,19 @@ func mapToVideoEncoderConfiguration(_ map: Dictionary<String, Any>) -> AgoraVide
75
75
76
76
func mapToBeautyOptions( _ map: Dictionary < String , Any > ) -> AgoraBeautyOptions {
77
77
let options = AgoraBeautyOptions ( )
78
- if let lighteningContrastLevel = map [ " lighteningContrastLevel " ] as? Int {
79
- if let lighteningContrastLevel = AgoraLighteningContrastLevel ( rawValue: UInt ( lighteningContrastLevel) ) {
78
+ if let lighteningContrastLevel = map [ " lighteningContrastLevel " ] as? NSNumber {
79
+ if let lighteningContrastLevel = AgoraLighteningContrastLevel ( rawValue: lighteningContrastLevel. uintValue ) {
80
80
options. lighteningContrastLevel = lighteningContrastLevel
81
81
}
82
82
}
83
- if let lighteningLevel = map [ " lighteningLevel " ] as? Float {
84
- options. lighteningLevel = lighteningLevel
83
+ if let lighteningLevel = map [ " lighteningLevel " ] as? NSNumber {
84
+ options. lighteningLevel = lighteningLevel. floatValue
85
85
}
86
- if let smoothnessLevel = map [ " smoothnessLevel " ] as? Float {
87
- options. smoothnessLevel = smoothnessLevel
86
+ if let smoothnessLevel = map [ " smoothnessLevel " ] as? NSNumber {
87
+ options. smoothnessLevel = smoothnessLevel. floatValue
88
88
}
89
- if let rednessLevel = map [ " rednessLevel " ] as? Float {
90
- options. rednessLevel = rednessLevel
89
+ if let rednessLevel = map [ " rednessLevel " ] as? NSNumber {
90
+ options. rednessLevel = rednessLevel. floatValue
91
91
}
92
92
return options
93
93
}
@@ -105,70 +105,70 @@ func mapToAgoraImage(_ map: Dictionary<String, Any>) -> AgoraImage {
105
105
106
106
func mapToTranscodingUser( _ map: Dictionary < String , Any > ) -> AgoraLiveTranscodingUser {
107
107
let user = AgoraLiveTranscodingUser ( )
108
- if let uid = map [ " uid " ] as? Int {
109
- user. uid = UInt ( uid)
108
+ if let uid = map [ " uid " ] as? NSNumber {
109
+ user. uid = uid. uintValue
110
110
}
111
111
user. rect = mapToRect ( map)
112
- if let zOrder = map [ " zOrder " ] as? Int {
113
- user. zOrder = zOrder
112
+ if let zOrder = map [ " zOrder " ] as? NSNumber {
113
+ user. zOrder = zOrder. intValue
114
114
}
115
- if let alpha = map [ " alpha " ] as? Double {
116
- user. alpha = alpha
115
+ if let alpha = map [ " alpha " ] as? NSNumber {
116
+ user. alpha = alpha. doubleValue
117
117
}
118
- if let audioChannel = map [ " audioChannel " ] as? Int {
119
- user. audioChannel = audioChannel
118
+ if let audioChannel = map [ " audioChannel " ] as? NSNumber {
119
+ user. audioChannel = audioChannel. intValue
120
120
}
121
121
return user
122
122
}
123
123
124
124
func mapToColor( _ map: Dictionary < String , Any > ) -> UIColor {
125
125
return UIColor (
126
- red: CGFloat ( map [ " red " ] as! Int ) ,
127
- green: CGFloat ( map [ " green " ] as! Int ) ,
128
- blue: CGFloat ( map [ " blue " ] as! Int ) ,
129
- alpha: 1.0
126
+ red: CGFloat ( ( map [ " red " ] as! NSNumber ) . intValue ) ,
127
+ green: CGFloat ( ( map [ " green " ] as! NSNumber ) . intValue ) ,
128
+ blue: CGFloat ( ( map [ " blue " ] as! NSNumber ) . intValue ) ,
129
+ alpha: 1.0
130
130
)
131
131
}
132
132
133
133
func mapToLiveTranscoding( _ map: Dictionary < String , Any > ) -> AgoraLiveTranscoding {
134
134
let transcoding = AgoraLiveTranscoding . default ( )
135
135
transcoding. size = mapToSize ( map)
136
- if let videoBitrate = map [ " videoBitrate " ] as? Int {
137
- transcoding. videoBitrate = videoBitrate
136
+ if let videoBitrate = map [ " videoBitrate " ] as? NSNumber {
137
+ transcoding. videoBitrate = videoBitrate. intValue
138
138
}
139
- if let videoFramerate = map [ " videoFramerate " ] as? Int {
140
- transcoding. videoFramerate = videoFramerate
139
+ if let videoFramerate = map [ " videoFramerate " ] as? NSNumber {
140
+ transcoding. videoFramerate = videoFramerate. intValue
141
141
}
142
142
if let lowLatency = map [ " lowLatency " ] as? Bool {
143
143
transcoding. lowLatency = lowLatency
144
144
}
145
- if let videoGop = map [ " videoGop " ] as? Int {
146
- transcoding. videoGop = videoGop
145
+ if let videoGop = map [ " videoGop " ] as? NSNumber {
146
+ transcoding. videoGop = videoGop. intValue
147
147
}
148
148
if let watermark = map [ " watermark " ] as? Dictionary < String , Any > {
149
149
transcoding. watermark = mapToAgoraImage ( watermark)
150
150
}
151
151
if let backgroundImage = map [ " backgroundImage " ] as? Dictionary < String , Any > {
152
152
transcoding. backgroundImage = mapToAgoraImage ( backgroundImage)
153
153
}
154
- if let audioSampleRate = map [ " audioSampleRate " ] as? Int {
155
- if let audioSampleRate = AgoraAudioSampleRateType ( rawValue: audioSampleRate) {
154
+ if let audioSampleRate = map [ " audioSampleRate " ] as? NSNumber {
155
+ if let audioSampleRate = AgoraAudioSampleRateType ( rawValue: audioSampleRate. intValue ) {
156
156
transcoding. audioSampleRate = audioSampleRate
157
157
}
158
158
}
159
- if let audioBitrate = map [ " audioBitrate " ] as? Int {
160
- transcoding. audioBitrate = audioBitrate
159
+ if let audioBitrate = map [ " audioBitrate " ] as? NSNumber {
160
+ transcoding. audioBitrate = audioBitrate. intValue
161
161
}
162
- if let audioChannels = map [ " audioChannels " ] as? Int {
163
- transcoding. audioChannels = audioChannels
162
+ if let audioChannels = map [ " audioChannels " ] as? NSNumber {
163
+ transcoding. audioChannels = audioChannels. intValue
164
164
}
165
- if let audioCodecProfile = map [ " audioCodecProfile " ] as? Int {
166
- if let audioCodecProfile = AgoraAudioCodecProfileType ( rawValue: audioCodecProfile) {
165
+ if let audioCodecProfile = map [ " audioCodecProfile " ] as? NSNumber {
166
+ if let audioCodecProfile = AgoraAudioCodecProfileType ( rawValue: audioCodecProfile. intValue ) {
167
167
transcoding. audioCodecProfile = audioCodecProfile
168
168
}
169
169
}
170
- if let videoCodecProfile = map [ " videoCodecProfile " ] as? Int {
171
- if let videoCodecProfile = AgoraVideoCodecProfileType ( rawValue: videoCodecProfile) {
170
+ if let videoCodecProfile = map [ " videoCodecProfile " ] as? NSNumber {
171
+ if let videoCodecProfile = AgoraVideoCodecProfileType ( rawValue: videoCodecProfile. intValue ) {
172
172
transcoding. videoCodecProfile = videoCodecProfile
173
173
}
174
174
}
@@ -196,8 +196,8 @@ func mapToChannelMediaInfo(_ map: Dictionary<String, Any>) -> AgoraChannelMediaR
196
196
if let token = map [ " token " ] as? String {
197
197
info. token = token
198
198
}
199
- if let uid = map [ " uid " ] as? UInt {
200
- info. uid = uid
199
+ if let uid = map [ " uid " ] as? NSNumber {
200
+ info. uid = uid. uintValue
201
201
}
202
202
return info
203
203
}
@@ -226,11 +226,11 @@ func mapToLastmileProbeConfig(_ map: Dictionary<String, Any>) -> AgoraLastmilePr
226
226
if let probeDownlink = map [ " probeDownlink " ] as? Bool {
227
227
config. probeDownlink = probeDownlink
228
228
}
229
- if let expectedUplinkBitrate = map [ " expectedUplinkBitrate " ] as? Int {
230
- config. expectedUplinkBitrate = UInt ( expectedUplinkBitrate)
229
+ if let expectedUplinkBitrate = map [ " expectedUplinkBitrate " ] as? NSNumber {
230
+ config. expectedUplinkBitrate = expectedUplinkBitrate. uintValue
231
231
}
232
- if let expectedDownlinkBitrate = map [ " expectedDownlinkBitrate " ] as? Int {
233
- config. expectedDownlinkBitrate = UInt ( expectedDownlinkBitrate)
232
+ if let expectedDownlinkBitrate = map [ " expectedDownlinkBitrate " ] as? NSNumber {
233
+ config. expectedDownlinkBitrate = expectedDownlinkBitrate. uintValue
234
234
}
235
235
return config
236
236
}
@@ -252,44 +252,44 @@ func mapToWatermarkOptions(_ map: Dictionary<String, Any>) -> WatermarkOptions {
252
252
func mapToLiveInjectStreamConfig( _ map: Dictionary < String , Any > ) -> AgoraLiveInjectStreamConfig {
253
253
let config = AgoraLiveInjectStreamConfig . default ( )
254
254
config. size = mapToSize ( map)
255
- if let videoGop = map [ " videoGop " ] as? Int {
256
- config. videoGop = videoGop
255
+ if let videoGop = map [ " videoGop " ] as? NSNumber {
256
+ config. videoGop = videoGop. intValue
257
257
}
258
- if let videoFramerate = map [ " videoFramerate " ] as? Int {
259
- config. videoFramerate = videoFramerate
258
+ if let videoFramerate = map [ " videoFramerate " ] as? NSNumber {
259
+ config. videoFramerate = videoFramerate. intValue
260
260
}
261
- if let videoBitrate = map [ " videoBitrate " ] as? Int {
262
- config. videoBitrate = videoBitrate
261
+ if let videoBitrate = map [ " videoBitrate " ] as? NSNumber {
262
+ config. videoBitrate = videoBitrate. intValue
263
263
}
264
- if let audioSampleRate = map [ " audioSampleRate " ] as? Int {
265
- if let audioSampleRate = AgoraAudioSampleRateType ( rawValue: audioSampleRate) {
264
+ if let audioSampleRate = map [ " audioSampleRate " ] as? NSNumber {
265
+ if let audioSampleRate = AgoraAudioSampleRateType ( rawValue: audioSampleRate. intValue ) {
266
266
config. audioSampleRate = audioSampleRate
267
267
}
268
268
}
269
- if let audioBitrate = map [ " audioBitrate " ] as? Int {
270
- config. audioBitrate = audioBitrate
269
+ if let audioBitrate = map [ " audioBitrate " ] as? NSNumber {
270
+ config. audioBitrate = audioBitrate. intValue
271
271
}
272
- if let audioChannels = map [ " audioChannels " ] as? Int {
273
- config. audioChannels = audioChannels
272
+ if let audioChannels = map [ " audioChannels " ] as? NSNumber {
273
+ config. audioChannels = audioChannels. intValue
274
274
}
275
275
return config
276
276
}
277
277
278
278
func mapToCameraCapturerConfiguration( _ map: Dictionary < String , Any > ) -> AgoraCameraCapturerConfiguration {
279
279
let config = AgoraCameraCapturerConfiguration ( )
280
- if let preference = map [ " preference " ] as? Int {
281
- if let preference = AgoraCameraCaptureOutputPreference ( rawValue: preference) {
280
+ if let preference = map [ " preference " ] as? NSNumber {
281
+ if let preference = AgoraCameraCaptureOutputPreference ( rawValue: preference. intValue ) {
282
282
config. preference = preference
283
283
}
284
284
}
285
- if let captureWidth = map [ " captureWidth " ] as? Int32 {
286
- config. captureWidth = captureWidth
285
+ if let captureWidth = map [ " captureWidth " ] as? NSNumber {
286
+ config. captureWidth = captureWidth. int32Value
287
287
}
288
- if let captureHeight = map [ " captureHeight " ] as? Int32 {
289
- config. captureHeight = captureHeight
288
+ if let captureHeight = map [ " captureHeight " ] as? NSNumber {
289
+ config. captureHeight = captureHeight. int32Value
290
290
}
291
- if let cameraDirection = map [ " cameraDirection " ] as? Int {
292
- if let cameraDirection = AgoraCameraDirection ( rawValue: cameraDirection) {
291
+ if let cameraDirection = map [ " cameraDirection " ] as? NSNumber {
292
+ if let cameraDirection = AgoraCameraDirection ( rawValue: cameraDirection. intValue ) {
293
293
config. cameraDirection = cameraDirection
294
294
}
295
295
}
@@ -310,8 +310,8 @@ func mapToChannelMediaOptions(_ map: Dictionary<String, Any>) -> AgoraRtcChannel
310
310
func mapToRtcEngineConfig( _ map: Dictionary < String , Any > ) -> AgoraRtcEngineConfig {
311
311
let config = AgoraRtcEngineConfig ( )
312
312
config. appId = map [ " appId " ] as? String
313
- if let areaCode = map [ " areaCode " ] as? UInt {
314
- config. areaCode = areaCode
313
+ if let areaCode = map [ " areaCode " ] as? NSNumber {
314
+ config. areaCode = areaCode. uintValue
315
315
}
316
316
if let logConfig = map [ " logConfig " ] as? Dictionary < String , Any > {
317
317
config. logConfig = mapToLogConfig ( logConfig)
@@ -321,8 +321,8 @@ func mapToRtcEngineConfig(_ map: Dictionary<String, Any>) -> AgoraRtcEngineConfi
321
321
322
322
func mapToEncryptionConfig( _ map: Dictionary < String , Any > ) -> AgoraEncryptionConfig {
323
323
let config = AgoraEncryptionConfig ( )
324
- if let encryptionMode = map [ " encryptionMode " ] as? Int {
325
- if let encryptionMode = AgoraEncryptionMode ( rawValue: encryptionMode) {
324
+ if let encryptionMode = map [ " encryptionMode " ] as? NSNumber {
325
+ if let encryptionMode = AgoraEncryptionMode ( rawValue: encryptionMode. intValue ) {
326
326
config. encryptionMode = encryptionMode
327
327
}
328
328
}
@@ -334,8 +334,8 @@ func mapToEncryptionConfig(_ map: Dictionary<String, Any>) -> AgoraEncryptionCon
334
334
335
335
func mapToClientRoleOptions( _ map: Dictionary < String , Any > ) -> AgoraClientRoleOptions {
336
336
let options = AgoraClientRoleOptions ( )
337
- if let audienceLatencyLevel = map [ " audienceLatencyLevel " ] as? Int {
338
- if let audienceLatencyLevel = AgoraAudienceLatencyLevelType ( rawValue: audienceLatencyLevel) {
337
+ if let audienceLatencyLevel = map [ " audienceLatencyLevel " ] as? NSNumber {
338
+ if let audienceLatencyLevel = AgoraAudienceLatencyLevelType ( rawValue: audienceLatencyLevel. intValue ) {
339
339
options. audienceLatencyLevel = audienceLatencyLevel
340
340
}
341
341
}
@@ -345,11 +345,11 @@ func mapToClientRoleOptions(_ map: Dictionary<String, Any>) -> AgoraClientRoleOp
345
345
func mapToLogConfig( _ map: Dictionary < String , Any > ) -> AgoraLogConfig {
346
346
let config = AgoraLogConfig ( )
347
347
config. filePath = map [ " filePath " ] as? String
348
- if let fileSize = map [ " fileSize " ] as? Int {
349
- config. fileSize = fileSize
348
+ if let fileSize = map [ " fileSize " ] as? NSNumber {
349
+ config. fileSize = fileSize. intValue
350
350
}
351
- if let level = map [ " level " ] as? Int {
352
- if let level = AgoraLogLevel . init ( rawValue: level) {
351
+ if let level = map [ " level " ] as? NSNumber {
352
+ if let level = AgoraLogLevel . init ( rawValue: level. intValue ) {
353
353
config. level = level;
354
354
}
355
355
}
0 commit comments