forked from AgoraIO/API-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobalSettings.swift
More file actions
54 lines (48 loc) · 1.76 KB
/
GlobalSettings.swift
File metadata and controls
54 lines (48 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// GlobalSettings.swift
// APIExample
//
// Created by 张乾泽 on 2020/9/25.
// Copyright © 2020 Agora Corp. All rights reserved.
//
import Foundation
import AgoraRtcKit
struct SettingItemOption<T> {
var idx: Int
var label: String
var value: T
}
class SettingItem<T> {
var selected: Int
var options: [SettingItemOption<T>]
func selectedOption() -> SettingItemOption<T> {
return options[selected]
}
init(selected: Int, options: [SettingItemOption<T>]) {
self.selected = selected
self.options = options
}
}
class GlobalSettings {
// The region for connection. This advanced feature applies to scenarios that have regional restrictions.
// For the regions that Agora supports, see https://docs.agora.io/en/Interactive%20Broadcast/API%20Reference/oc/Constants/AgoraAreaCode.html. After specifying the region, the SDK connects to the Agora servers within that region.
var area:AgoraAreaCode = .GLOB
static let shared = GlobalSettings()
let resolutionSetting: SettingItem<Int> = SettingItem(
selected: Configs.defaultResolutionIdx,
options: Configs.Resolutions.enumerated().map {
SettingItemOption(idx: $0.offset, label: $0.element.name(), value: $0.offset)
}
)
let fpsSetting: SettingItem<Int> = SettingItem(
selected: Configs.defaultFpsIdx,
options: Configs.Fps.enumerated().map {
SettingItemOption(idx: $0.offset, label: "\($0.element)fps", value: $0.offset)
}
)
let proxySetting: SettingItem<Int> = SettingItem(
selected: Configs.defaultProxySettingIdx,
options: Configs.Proxy.enumerated().map{
SettingItemOption(idx: $0.offset, label: String($0.element), value: $0.offset)
})
}