Skip to content

Commit 1d7f051

Browse files
author
zhaoyongqiang
committed
添加超级分辨率功能
1 parent 91c5c3b commit 1d7f051

6 files changed

Lines changed: 87 additions & 22 deletions

File tree

iOS/APIExample/Examples/Advanced/LiveStreaming/Base.lproj/LiveStreaming.storyboard

Lines changed: 50 additions & 2 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">
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">
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="Named colors" minToolsVersion="9.0"/>
88
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
99
<capability name="System colors in document resources" minToolsVersion="11.0"/>
@@ -176,6 +176,47 @@
176176
<constraint firstItem="EAJ-dB-XlT" firstAttribute="leading" secondItem="89S-CO-2ta" secondAttribute="leading" constant="-10" id="wpA-sj-lHA"/>
177177
</constraints>
178178
</view>
179+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TxN-BK-xcz" userLabel="superResolution">
180+
<rect key="frame" x="15" y="182" width="384" height="532"/>
181+
<subviews>
182+
<view alpha="0.80000001192092896" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7Ve-xO-Y3X" userLabel="btnPanelBg">
183+
<rect key="frame" x="0.0" y="486" width="195.5" height="41"/>
184+
<color key="backgroundColor" name="btnPanelBackground"/>
185+
<userDefinedRuntimeAttributes>
186+
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
187+
<integer key="value" value="5"/>
188+
</userDefinedRuntimeAttribute>
189+
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
190+
</userDefinedRuntimeAttributes>
191+
</view>
192+
<stackView opaque="NO" contentMode="scaleToFill" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="3eH-5b-IsL" userLabel="btnPanel">
193+
<rect key="frame" x="10" y="491" width="175.5" height="31"/>
194+
<subviews>
195+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Ultra Low Latency" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rfu-AG-LVz" userLabel="superResolution">
196+
<rect key="frame" x="0.0" y="0.0" width="116.5" height="31"/>
197+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
198+
<color key="textColor" name="btnPanelForeground"/>
199+
<nil key="highlightedColor"/>
200+
</label>
201+
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="ELe-d5-m4P">
202+
<rect key="frame" x="126.5" y="0.0" width="51" height="31"/>
203+
<connections>
204+
<action selector="onToggleSuperResolution:" destination="jxp-ZN-2yG" eventType="valueChanged" id="3GM-Lc-S7m"/>
205+
</connections>
206+
</switch>
207+
</subviews>
208+
<color key="backgroundColor" name="btnPanelBackground"/>
209+
</stackView>
210+
</subviews>
211+
<constraints>
212+
<constraint firstItem="7Ve-xO-Y3X" firstAttribute="bottom" secondItem="3eH-5b-IsL" secondAttribute="bottom" constant="5" id="JBv-YK-ka7"/>
213+
<constraint firstItem="7Ve-xO-Y3X" firstAttribute="trailing" secondItem="3eH-5b-IsL" secondAttribute="trailing" constant="10" id="Okw-Id-cuI"/>
214+
<constraint firstItem="7Ve-xO-Y3X" firstAttribute="leading" secondItem="3eH-5b-IsL" secondAttribute="leading" constant="-10" id="cgQ-22-KVG"/>
215+
<constraint firstItem="7Ve-xO-Y3X" firstAttribute="top" secondItem="3eH-5b-IsL" secondAttribute="top" constant="-5" id="tkU-Mi-B2J"/>
216+
<constraint firstItem="3eH-5b-IsL" firstAttribute="bottom" secondItem="TxN-BK-xcz" secondAttribute="bottom" constant="-10" id="utT-46-ejb"/>
217+
<constraint firstItem="7Ve-xO-Y3X" firstAttribute="leading" secondItem="TxN-BK-xcz" secondAttribute="leading" id="vrD-p5-hUN"/>
218+
</constraints>
219+
</view>
179220
</subviews>
180221
<viewLayoutGuide key="safeArea" id="CeS-QQ-Djo"/>
181222
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
@@ -184,12 +225,16 @@
184225
<constraint firstItem="XSO-cE-x5n" firstAttribute="top" secondItem="CeS-QQ-Djo" secondAttribute="top" constant="10" id="1HU-w7-YYi"/>
185226
<constraint firstItem="q9v-1n-ZYf" firstAttribute="top" secondItem="CeS-QQ-Djo" secondAttribute="top" id="7Ra-XK-uPS"/>
186227
<constraint firstItem="q9v-1n-ZYf" firstAttribute="leading" secondItem="CeS-QQ-Djo" secondAttribute="leading" id="LsZ-af-6Wt"/>
228+
<constraint firstItem="TxN-BK-xcz" firstAttribute="centerX" secondItem="q9v-1n-ZYf" secondAttribute="centerX" id="Lvp-sD-aVf"/>
187229
<constraint firstItem="CeS-QQ-Djo" firstAttribute="bottom" secondItem="q9v-1n-ZYf" secondAttribute="bottom" id="Ne5-if-Q54"/>
188230
<constraint firstItem="CeS-QQ-Djo" firstAttribute="bottom" secondItem="Uwe-Fi-04a" secondAttribute="bottom" constant="35" id="Nei-qd-Vd2"/>
189231
<constraint firstItem="XSO-cE-x5n" firstAttribute="width" secondItem="CeS-QQ-Djo" secondAttribute="width" multiplier="0.33" id="O1g-6R-UEF"/>
232+
<constraint firstItem="TxN-BK-xcz" firstAttribute="leading" secondItem="CeS-QQ-Djo" secondAttribute="leading" constant="15" id="WgZ-gS-8qg"/>
233+
<constraint firstItem="TxN-BK-xcz" firstAttribute="centerY" secondItem="ZdT-KJ-IC4" secondAttribute="centerY" id="b7f-tJ-lUw"/>
190234
<constraint firstItem="CeS-QQ-Djo" firstAttribute="trailing" secondItem="XSO-cE-x5n" secondAttribute="trailing" constant="20" id="c33-li-E9o"/>
191235
<constraint firstItem="Wts-5Z-p7a" firstAttribute="leading" secondItem="Uwe-Fi-04a" secondAttribute="leading" id="ewr-t2-jKP"/>
192236
<constraint firstItem="CeS-QQ-Djo" firstAttribute="trailing" secondItem="q9v-1n-ZYf" secondAttribute="trailing" id="isT-Rq-5PH"/>
237+
<constraint firstItem="Wts-5Z-p7a" firstAttribute="top" secondItem="TxN-BK-xcz" secondAttribute="bottom" constant="15" id="pKv-Ve-Pto"/>
193238
<constraint firstItem="Uwe-Fi-04a" firstAttribute="top" secondItem="Wts-5Z-p7a" secondAttribute="bottom" constant="10" id="wl5-PM-CyG"/>
194239
</constraints>
195240
</view>
@@ -198,6 +243,9 @@
198243
<outlet property="clientRoleToggle" destination="7iE-Y0-bQi" id="xF0-48-qAP"/>
199244
<outlet property="clientRoleToggleView" destination="Uwe-Fi-04a" id="oys-Z9-DtO"/>
200245
<outlet property="foregroundVideoContainer" destination="XSO-cE-x5n" id="7GG-yW-hDg"/>
246+
<outlet property="superResolutionContainer" destination="TxN-BK-xcz" id="cPq-SG-c0f"/>
247+
<outlet property="superResolutionLabel" destination="rfu-AG-LVz" id="nfH-Io-gXQ"/>
248+
<outlet property="superResolutionSwitch" destination="ELe-d5-m4P" id="ppE-2V-0bk"/>
201249
<outlet property="ultraLowLatencyToggle" destination="cbb-WI-53A" id="n3x-pK-MuE"/>
202250
<outlet property="ultraLowLatencyToggleView" destination="Wts-5Z-p7a" id="HI8-ov-5iY"/>
203251
</connections>

iOS/APIExample/Examples/Advanced/LiveStreaming/LiveStreaming.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ class LiveStreamingMain: BaseViewController {
6161
@IBOutlet weak var ultraLowLatencyToggleView:UIView!
6262
@IBOutlet weak var clientRoleToggle:UISwitch!
6363
@IBOutlet weak var ultraLowLatencyToggle:UISwitch!
64+
@IBOutlet weak var superResolutionContainer: UIView!
65+
@IBOutlet weak var superResolutionLabel: UILabel!
66+
@IBOutlet weak var superResolutionSwitch: UISwitch!
67+
6468
var remoteUid: UInt? {
6569
didSet {
6670
foregroundVideoContainer.isHidden = !(role == .broadcaster && remoteUid != nil)
@@ -113,13 +117,16 @@ class LiveStreamingMain: BaseViewController {
113117
// if inital role is broadcaster, do not show audience options
114118
clientRoleToggleView.isHidden = role == .broadcaster
115119
ultraLowLatencyToggleView.isHidden = role == .broadcaster
120+
superResolutionContainer.isHidden = role == .broadcaster
121+
superResolutionLabel.text = "Super Orientation".localized
116122

117123
// make this room live broadcasting room
118124
agoraKit.setChannelProfile(.liveBroadcasting)
119125
updateClientRole(role)
120126

121127
// enable video module and set up video encoding configs
122128
agoraKit.enableVideo()
129+
agoraKit.enableAudio()
123130

124131
// Set audio route to speaker
125132
agoraKit.setDefaultAudioRouteToSpeakerphone(true)
@@ -230,6 +237,10 @@ class LiveStreamingMain: BaseViewController {
230237
updateClientRole(.audience)
231238
}
232239
}
240+
@IBAction func onToggleSuperResolution(_ sender: UISwitch) {
241+
let result = agoraKit.enableRemoteSuperResolution(sender.isOn, mode: .auto, uid: remoteUid ?? 0)
242+
print(result)
243+
}
233244

234245
override func willMove(toParent parent: UIViewController?) {
235246
if parent == nil {
@@ -319,4 +330,8 @@ extension LiveStreamingMain: AgoraRtcEngineDelegate {
319330
videoCanvas.renderMode = .hidden
320331
agoraKit.setupRemoteVideo(videoCanvas)
321332
}
333+
334+
func rtcEngine(_ engine: AgoraRtcEngineKit, superResolutionEnabledOfUid uid: UInt, enabled: Bool, reason: AgoraSuperResolutionStateReason) {
335+
LogUtils.log(message: "super resolution \(uid) enabled \(enabled) reason ==\(reason.rawValue)", level: .info)
336+
}
322337
}

iOS/APIExample/Examples/Advanced/VideoChat/Base.lproj/VideoChat.storyboard

Lines changed: 2 additions & 2 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="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
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">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
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"/>

iOS/APIExample/Examples/Advanced/VideoChat/VideoChat.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class VideoChatEntry: UIViewController {
1717
@IBOutlet var resolutionBtn: UIButton!
1818
@IBOutlet var fpsBtn: UIButton!
1919
@IBOutlet var orientationBtn: UIButton!
20+
2021
var width:Int = 640, height:Int = 360, orientation:AgoraVideoOutputOrientationMode = .adaptative, fps: AgoraVideoFrameRate = .fps15
2122

2223
override func viewDidLoad() {
@@ -89,7 +90,10 @@ class VideoChatEntry: UIViewController {
8990
// create new view controller every time to ensure we get a clean vc
9091
guard let newViewController = storyBoard.instantiateViewController(withIdentifier: identifier) as? BaseViewController else { return }
9192
newViewController.title = channelName
92-
newViewController.configs = ["channelName": channelName, "resolution": CGSize(width: width, height: height), "fps": fps, "orientation": orientation]
93+
newViewController.configs = ["channelName": channelName,
94+
"resolution": CGSize(width: width, height: height),
95+
"fps": fps,
96+
"orientation": orientation]
9397
self.navigationController?.pushViewController(newViewController, animated: true)
9498
}
9599
}
@@ -115,7 +119,6 @@ class VideoChatMain: BaseViewController {
115119
config.logConfig = logConfig
116120

117121
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
118-
119122
// get channel name from configs
120123
guard let channelName = configs["channelName"] as? String,
121124
let resolution = configs["resolution"] as? CGSize,
@@ -128,6 +131,7 @@ class VideoChatMain: BaseViewController {
128131

129132
// enable video module
130133
agoraKit.enableVideo()
134+
agoraKit.enableAudio()
131135
agoraKit.setVideoEncoderConfiguration(
132136
AgoraVideoEncoderConfiguration(
133137
size: resolution,
@@ -170,14 +174,12 @@ class VideoChatMain: BaseViewController {
170174
}
171175
}
172176

173-
override func willMove(toParent parent: UIViewController?) {
174-
if parent == nil {
175-
// leave channel when exiting the view
176-
if isJoined {
177-
agoraKit.leaveChannel { (stats) -> Void in
178-
LogUtils.log(message: "left channel, duration: \(stats.duration)", level: .info)
179-
}
180-
}
177+
override func viewDidDisappear(_ animated: Bool) {
178+
super.viewDidDisappear(animated)
179+
agoraKit.disableAudio()
180+
agoraKit.disableVideo()
181+
agoraKit.leaveChannel { stats in
182+
LogUtils.log(message: "left channel, duration: \(stats.duration)", level: .info)
181183
}
182184
}
183185

iOS/APIExample/Examples/Basic/JoinChannelAudio/JoinChannelAudio.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ class JoinChannelAudioMain: BaseViewController {
109109

110110
// disable video module
111111
agoraKit.disableVideo()
112+
// enable audio module
113+
agoraKit.enableAudio()
112114

113115
// set audio profile/audio scenario
114116
agoraKit.setAudioProfile(audioProfile, scenario: audioScenario)
@@ -140,14 +142,11 @@ class JoinChannelAudioMain: BaseViewController {
140142
}
141143
}
142144

143-
override func willMove(toParent parent: UIViewController?) {
144-
if parent == nil {
145-
// leave channel when exiting the view
146-
if isJoined {
147-
agoraKit.leaveChannel { (stats) -> Void in
148-
LogUtils.log(message: "left channel, duration: \(stats.duration)", level: .info)
149-
}
150-
}
145+
override func viewDidDisappear(_ animated: Bool) {
146+
super.viewDidDisappear(animated)
147+
agoraKit.disableAudio()
148+
agoraKit.leaveChannel { stats in
149+
LogUtils.log(message: "left channel, duration: \(stats.duration)", level: .info)
151150
}
152151
}
153152

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,4 @@
137137
"Now you can move the speaker icon to experience the spatial audio effect" = "现在您可以移动喇叭图标到不同的位置,体验空间音效效果";
138138
"Please enter" = "请输入";
139139
"Agora Local Access" = "私有化环境";
140+
"Super Orientation" = "超分辨率";

0 commit comments

Comments
 (0)