Skip to content

Commit b1199fb

Browse files
author
zhaoyongqiang
committed
添加私有化环境
1 parent ffcb275 commit b1199fb

6 files changed

Lines changed: 114 additions & 18 deletions

File tree

iOS/APIExample/Base.lproj/Main.storyboard

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="HWc-eV-zrm">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="HWc-eV-zrm">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
88
<capability name="System colors in document resources" minToolsVersion="11.0"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -153,7 +153,7 @@
153153
<color key="backgroundColor" red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
154154
<prototypes>
155155
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SliderCell" id="G0g-5t-oRK" customClass="SettingsSliderCell" customModule="APIExample" customModuleProvider="target">
156-
<rect key="frame" x="0.0" y="55.5" width="414" height="54.5"/>
156+
<rect key="frame" x="0.0" y="49.5" width="414" height="54.5"/>
157157
<autoresizingMask key="autoresizingMask"/>
158158
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="G0g-5t-oRK" id="8Yv-dJ-Q4d">
159159
<rect key="frame" x="0.0" y="0.0" width="414" height="54.5"/>
@@ -203,7 +203,7 @@
203203
</connections>
204204
</tableViewCell>
205205
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="LabelCell" id="YOS-Tx-FSj" userLabel="LabelCell" customClass="SettingsLabelCell" customModule="APIExample" customModuleProvider="target">
206-
<rect key="frame" x="0.0" y="110" width="414" height="54.5"/>
206+
<rect key="frame" x="0.0" y="104" width="414" height="54.5"/>
207207
<autoresizingMask key="autoresizingMask"/>
208208
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="YOS-Tx-FSj" id="Ezh-hI-UFS">
209209
<rect key="frame" x="0.0" y="0.0" width="414" height="54.5"/>
@@ -245,7 +245,7 @@
245245
</connections>
246246
</tableViewCell>
247247
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SelectCell" id="wPb-Hp-Lzk" customClass="SettingsSelectCell" customModule="APIExample" customModuleProvider="target">
248-
<rect key="frame" x="0.0" y="164.5" width="414" height="54.5"/>
248+
<rect key="frame" x="0.0" y="158.5" width="414" height="54.5"/>
249249
<autoresizingMask key="autoresizingMask"/>
250250
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="wPb-Hp-Lzk" id="xjH-Qx-gt4">
251251
<rect key="frame" x="0.0" y="0.0" width="414" height="54.5"/>
@@ -285,6 +285,42 @@
285285
<outlet property="settingLabel" destination="2VP-yo-86d" id="wP7-Pr-xuR"/>
286286
</connections>
287287
</tableViewCell>
288+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="TextFieldCell" rowHeight="54" id="dKe-Yn-syX" customClass="SettingsTextFieldCell" customModule="APIExample">
289+
<rect key="frame" x="0.0" y="213" width="414" height="54"/>
290+
<autoresizingMask key="autoresizingMask"/>
291+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="dKe-Yn-syX" id="caI-Wb-ziH">
292+
<rect key="frame" x="0.0" y="0.0" width="414" height="54"/>
293+
<autoresizingMask key="autoresizingMask"/>
294+
<subviews>
295+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PkZ-75-gY9">
296+
<rect key="frame" x="20" y="17" width="41.5" height="20.5"/>
297+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
298+
<nil key="textColor"/>
299+
<nil key="highlightedColor"/>
300+
</label>
301+
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="FFZ-yf-YVJ">
302+
<rect key="frame" x="244" y="7" width="150" height="40"/>
303+
<constraints>
304+
<constraint firstAttribute="width" constant="150" id="oYE-kK-axs"/>
305+
<constraint firstAttribute="height" constant="40" id="sMf-gS-pKE"/>
306+
</constraints>
307+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
308+
<textInputTraits key="textInputTraits"/>
309+
</textField>
310+
</subviews>
311+
<constraints>
312+
<constraint firstItem="FFZ-yf-YVJ" firstAttribute="centerY" secondItem="caI-Wb-ziH" secondAttribute="centerY" id="IK5-ZJ-Hgg"/>
313+
<constraint firstItem="PkZ-75-gY9" firstAttribute="leading" secondItem="caI-Wb-ziH" secondAttribute="leading" constant="20" symbolic="YES" id="RqQ-37-XIE"/>
314+
<constraint firstItem="PkZ-75-gY9" firstAttribute="centerY" secondItem="caI-Wb-ziH" secondAttribute="centerY" id="aq1-iv-FeM"/>
315+
<constraint firstAttribute="trailing" secondItem="FFZ-yf-YVJ" secondAttribute="trailing" constant="20" symbolic="YES" id="cF2-LQ-ZVD"/>
316+
<constraint firstItem="FFZ-yf-YVJ" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="PkZ-75-gY9" secondAttribute="trailing" constant="8" symbolic="YES" id="pJC-qF-Yqs"/>
317+
</constraints>
318+
</tableViewCellContentView>
319+
<connections>
320+
<outlet property="settingLabel" destination="PkZ-75-gY9" id="cov-1k-Sme"/>
321+
<outlet property="textField" destination="FFZ-yf-YVJ" id="vgc-nX-czp"/>
322+
</connections>
323+
</tableViewCell>
288324
</prototypes>
289325
<connections>
290326
<outlet property="dataSource" destination="Ey4-v0-GaJ" id="Wg1-iY-w0o"/>

iOS/APIExample/Common/Settings/SettingsCells.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,45 @@ class SettingsSliderCell : SettingsBaseCell
5555
}
5656
}
5757

58+
class SettingsTextFieldParam: SettingsBaseParam {
59+
var value:String
60+
weak var context:UIViewController?;
61+
init(key:String, label:String, context: UIViewController) {
62+
self.context = context
63+
self.value = label
64+
super.init(key: key, label: label, type: "TextFieldCell")
65+
}
66+
}
67+
68+
class SettingsTextFieldCell : SettingsBaseCell
69+
{
70+
71+
@IBOutlet weak var settingLabel: UILabel!
72+
@IBOutlet weak var textField: UITextField!
73+
74+
override func awakeFromNib() {
75+
super.awakeFromNib()
76+
textField.placeholder = "Please enter".localized
77+
textField.addTarget(self, action: #selector(textValueChange(sender:)), for: .editingChanged)
78+
}
79+
80+
override func configure(configs: SettingsBaseParam) {
81+
super.configure(configs: configs)
82+
83+
guard let param = configs as? SettingsTextFieldParam else {return}
84+
settingLabel.text = param.label
85+
if let ip = UserDefaults.standard.string(forKey: "private") {
86+
textField.text = ip
87+
}
88+
}
89+
90+
@objc
91+
private func textValueChange(sender: UITextField) {
92+
guard let configs = self.configs as? SettingsTextFieldParam else {return}
93+
delegate?.didChangeValue(type: "TextFieldCell", key: configs.key, value: sender.text ?? "")
94+
}
95+
}
96+
5897
class SettingsSliderParam: SettingsBaseParam {
5998
var value:Float
6099
var minimumValue:Float

iOS/APIExample/Examples/Basic/JoinChannelVideo/JoinChannelVideo.swift

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,20 @@ class JoinChannelVideoMain: BaseViewController {
5959
// setup log file path
6060
let logConfig = AgoraLogConfig()
6161
logConfig.level = .info
62+
logConfig.filePath = LogUtils.sdkLogPath()
6263
config.logConfig = logConfig
6364

6465
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
6566

67+
// setup accessPointConfig
68+
if let ip = UserDefaults.standard.string(forKey: "private") {
69+
let accessPointConfig = AgoraLocalAccessPointConfiguration()
70+
accessPointConfig.mode = .localOnly
71+
accessPointConfig.ipList = [ip]
72+
let result = agoraKit.setLocalAccessPoint(accessPointConfig)
73+
print("result == \(result)")
74+
}
75+
6676
// get channel name from configs
6777
guard let channelName = configs["channelName"] as? String,
6878
let resolution = GlobalSettings.shared.getSetting(key: "resolution")?.selectedOption().value as? CGSize,
@@ -72,9 +82,9 @@ class JoinChannelVideoMain: BaseViewController {
7282
// make myself a broadcaster
7383
agoraKit.setChannelProfile(.liveBroadcasting)
7484
agoraKit.setClientRole(.broadcaster)
75-
7685
// enable video module and set up video encoding configs
7786
agoraKit.enableVideo()
87+
agoraKit.enableAudio()
7888
agoraKit.setVideoEncoderConfiguration(AgoraVideoEncoderConfiguration(size: resolution,
7989
frameRate: fps,
8090
bitrate: AgoraVideoBitrateStandard,
@@ -120,14 +130,12 @@ class JoinChannelVideoMain: BaseViewController {
120130
}
121131
}
122132

123-
override func willMove(toParent parent: UIViewController?) {
124-
if parent == nil {
125-
// leave channel when exiting the view
126-
if isJoined {
127-
agoraKit.leaveChannel { (stats) -> Void in
128-
LogUtils.log(message: "left channel, duration: \(stats.duration)", level: .info)
129-
}
130-
}
133+
override func viewDidDisappear(_ animated: Bool) {
134+
super.viewDidDisappear(animated)
135+
agoraKit.disableVideo()
136+
agoraKit.disableAudio()
137+
agoraKit.leaveChannel { (stats) -> Void in
138+
LogUtils.log(message: "left channel, duration: \(stats.duration)", level: .info)
131139
}
132140
}
133141
}
@@ -228,4 +236,8 @@ extension JoinChannelVideoMain: AgoraRtcEngineDelegate {
228236
func rtcEngine(_ engine: AgoraRtcEngineKit, remoteAudioStats stats: AgoraRtcRemoteAudioStats) {
229237
remoteVideo.statsInfo?.updateAudioStats(stats)
230238
}
239+
240+
func rtcEngine(_ engine: AgoraRtcEngineKit, didProxyConnected channel: String, withUid uid: UInt, proxyType: AgoraProxyType, localProxyIp: String, elapsed: Int) {
241+
LogUtils.log(message: "channel == \(channel) proxyType == \(proxyType) localProxyIp == \(localProxyIp)", level: .info)
242+
}
231243
}

iOS/APIExample/ViewController.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,15 @@ class ViewController: AGViewController {
8383
guard let settingsViewController = storyBoard.instantiateViewController(withIdentifier: "settings") as? SettingsViewController else { return }
8484

8585
settingsViewController.settingsDelegate = self
86-
settingsViewController.sectionNames = ["Video Configurations","Metadata"]
86+
settingsViewController.sectionNames = ["Video Configurations","Metadata", "Private"]
8787
settingsViewController.sections = [
8888
[
8989
SettingsSelectParam(key: "resolution", label:"Resolution".localized, settingItem: GlobalSettings.shared.getSetting(key: "resolution")!, context: self),
9090
SettingsSelectParam(key: "fps", label:"Frame Rate".localized, settingItem: GlobalSettings.shared.getSetting(key: "fps")!, context: self),
9191
SettingsSelectParam(key: "orientation", label:"Orientation".localized, settingItem: GlobalSettings.shared.getSetting(key: "orientation")!, context: self)
9292
],
93-
[SettingsLabelParam(key: "sdk_ver", label: "SDK Version", value: "v\(AgoraRtcEngineKit.getSdkVersion())")]
93+
[SettingsLabelParam(key: "sdk_ver", label: "SDK Version", value: "v\(AgoraRtcEngineKit.getSdkVersion())")],
94+
[SettingsTextFieldParam(key: "private", label: "Agora Local Access".localized, context: self)]
9495
]
9596
self.navigationController?.pushViewController(settingsViewController, animated: true)
9697
}
@@ -146,6 +147,10 @@ extension ViewController: SettingsViewControllerDelegate {
146147
if(type == "SettingsSelectCell") {
147148
guard let setting = value as? SettingItem else {return}
148149
LogUtils.log(message: "select \(setting.selectedOption().label) for \(key)", level: .info)
150+
}else if type == "TextFieldCell" {
151+
LogUtils.log(message: "select \(value) for \(key)", level: .info)
152+
UserDefaults.standard.set(value, forKey: key)
153+
UserDefaults.standard.synchronize()
149154
}
150155
}
151156
}

iOS/APIExample/zh-Hans.lproj/Localizable.strings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,5 @@
135135
"Please insert headphones to experience the spatial audio effect" = "请插入耳机体验空间音效效果";
136136
"You will hear a piece of music, and after 10 seconds this piece of music will be played through spatial audio effects" = "你会听到一段音乐,10秒后这段音乐会通过空间音效的方式播放";
137137
"Now you can move the speaker icon to experience the spatial audio effect" = "现在您可以移动喇叭图标到不同的位置,体验空间音效效果";
138+
"Please enter" = "请输入";
139+
"Agora Local Access" = "私有化环境";

iOS/Podfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ target 'APIExample' do
66

77
pod 'Floaty', '~> 4.2.0'
88
pod 'AGEVideoLayout', '~> 1.0.4'
9-
pod 'AgoraRtcEngine_iOS', '3.7.0'
9+
# pod 'AgoraRtcEngine_iOS', '3.7.0'
10+
pod 'sdk', :path => 'sdk.podspec'
1011
pod 'AgoraMediaPlayer_iOS', '1.2.2'
1112
end
1213

1314
target 'Agora-ScreenShare-Extension' do
1415
use_frameworks!
1516

16-
pod 'AgoraRtcEngine_iOS', '3.7.0'
17+
# pod 'AgoraRtcEngine_iOS', '3.7.0'
18+
pod 'sdk', :path => 'sdk.podspec'
1719
end

0 commit comments

Comments
 (0)