Skip to content

Commit ab04938

Browse files
author
zhaoyongqiang
committed
fix bug
1 parent 60463b2 commit ab04938

31 files changed

Lines changed: 94 additions & 86 deletions

File tree

iOS/APIExample/Common/AgoraExtension.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,13 @@ extension AgoraAudioScenario {
9494
switch self {
9595
case .default: return "Default".localized
9696
case .gameStreaming: return "Game Streaming".localized
97-
case .highDefinition: return "High Defination".localized
9897
default:
9998
return "\(self.rawValue)"
10099
}
101100
}
102101

103102
static func allValues() -> [AgoraAudioScenario] {
104-
return [.default, .gameStreaming, .highDefinition]
103+
return [.default, .gameStreaming]
105104
}
106105
}
107106

iOS/APIExample/Common/ExternalAudio/AgoraPcmSourcePush.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Foundation
1010

1111
protocol AgoraPcmSourcePushDelegate {
12-
func onAudioFrame(data: Data) -> Void
12+
func onAudioFrame(data: UnsafeMutablePointer<UInt8>) -> Void
1313
}
1414

1515
class AgoraPcmSourcePush: NSObject {
@@ -61,7 +61,8 @@ class AgoraPcmSourcePush: NSObject {
6161
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: bufferSize)
6262
while input.hasBytesAvailable && self.state == .Play {
6363
input.read(buffer, maxLength: bufferSize)
64-
self.delegate?.onAudioFrame(data: Data(bytes: buffer, count: bufferSize))
64+
// self.delegate?.onAudioFrame(data: Data(bytes: buffer, count: bufferSize))
65+
self.delegate?.onAudioFrame(data: buffer)
6566
Thread.sleep(forTimeInterval: sleepTime)
6667
}
6768
buffer.deallocate()

iOS/APIExample/Common/ExternalAudio/ExternalAudio.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ virtual bool onPlaybackAudioFrame(const char* channelId, AudioFrame& audioFrame)
215215

216216
virtual bool onMixedAudioFrame(const char* channelId, AudioFrame& audioFrame) override { return true; }
217217

218-
virtual AUDIO_FRAME_POSITION getObservedAudioFramePosition() override {
218+
virtual int getObservedAudioFramePosition() override {
219219
return AUDIO_FRAME_POSITION_NONE;
220220
}
221221
virtual AudioParams getPlaybackAudioParams() override {

iOS/APIExample/Common/RawDataApi/AgoraMediaDataPlugin.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ virtual bool onMixedAudioFrame(const char* channelId, AudioFrame& audioFrame) ov
251251
return true;
252252
}
253253

254-
virtual AUDIO_FRAME_POSITION getObservedAudioFramePosition() override {
254+
virtual int getObservedAudioFramePosition() override {
255255
return AUDIO_FRAME_POSITION_NONE;
256256
}
257257
virtual AudioParams getPlaybackAudioParams() override {

iOS/APIExample/Examples/Advanced/CreateDataStream/CreateDataStream.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class CreateDataStreamMain: BaseViewController {
7979

8080
// enable video module and set up video encoding configs
8181
agoraKit.enableVideo()
82+
agoraKit.enableAudio()
8283
agoraKit.setVideoEncoderConfiguration(AgoraVideoEncoderConfiguration(size: resolution,
8384
frameRate: fps,
8485
bitrate: AgoraVideoBitrateStandard,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<nil key="textColor"/>
104104
<nil key="highlightedColor"/>
105105
</label>
106-
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="Jll-ir-flF">
106+
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jll-ir-flF">
107107
<rect key="frame" x="345" y="8.5" width="51" height="31"/>
108108
<connections>
109109
<action selector="openOrCloseMic:" destination="wEj-TK-x0n" eventType="valueChanged" id="wEd-JG-xcv"/>

iOS/APIExample/Examples/Advanced/CustomPcmAudioSource/CustomPcmAudioSource.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class CustomPcmAudioSourceMain: BaseViewController {
5252
}
5353
}
5454

55+
let sampleRate:UInt = 44100, channel:UInt = 2, bitPerSample = 16, samples = 441 * 10
5556
override func viewDidLoad(){
5657
super.viewDidLoad()
57-
let sampleRate:UInt = 44100, channel:UInt = 2, bitPerSample = 16, samples = 441 * 10
5858

5959
// set up agora instance when view loaded
6060
let config = AgoraRtcEngineConfig()
@@ -122,7 +122,7 @@ class CustomPcmAudioSourceMain: BaseViewController {
122122
let option = AgoraRtcChannelMediaOptions()
123123
option.publishCameraTrack = .of(false)
124124
option.publishCustomAudioTrack = .of(sender.isOn)
125-
option.clientRoleType = .of((Int32)(AgoraClientRole.broadcaster.rawValue))
125+
option.clientRoleType = .of((Int32)(sender.isOn ? AgoraClientRole.broadcaster.rawValue : AgoraClientRole.audience.rawValue))
126126
agoraKit.updateChannel(with: option)
127127
}
128128

@@ -137,9 +137,8 @@ class CustomPcmAudioSourceMain: BaseViewController {
137137
}
138138

139139
extension CustomPcmAudioSourceMain: AgoraPcmSourcePushDelegate {
140-
func onAudioFrame(data: Data) {
141-
let ret = agoraKit.pushExternalAudioFrameNSData(data, sourceId: 1, timestamp: 0)
142-
LogUtils.log(message: "onAudioFrame, result: \(ret)", level: .info)
140+
func onAudioFrame(data: UnsafeMutablePointer<UInt8>) {
141+
agoraKit.pushExternalAudioFrameRawData(data, samples: samples, sourceId: 0, timestamp: 0)
143142
}
144143
}
145144

iOS/APIExample/Examples/Advanced/FusionCDN/FusionCDN.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ class FusionCDNHost: BaseViewController {
209209
rtcSwitcher.isEnabled = false
210210
streamingButton.setTitle("Start Live Streaming", for: .normal)
211211
streamingButton.setTitleColor(.blue, for: .normal)
212+
agoraKit.stopDirectCdnStreaming()
213+
agoraKit.stopRtmpStream(streamingUrl)
214+
agoraKit.removePublishStreamUrl(streamingUrl)
212215
}
213216

214217
@IBAction func setRtcStreaming(_ sender: UISwitch) {
@@ -355,7 +358,7 @@ class FusionCDNAudience: BaseViewController {
355358
guard let mode = configs["mode"] as? StreamingMode else {return}
356359
guard let channelName = configs["channelName"] as? String else {return}
357360
if mode == .agoraChannel {
358-
streamingUrl = "rtmp://mdetest2.pull.agoramde.agoraio.cn/live/\(channelName)"
361+
streamingUrl = "rtmp://push.webdemo.agoraio.cn/lbhd/\(channelName)"
359362
rtcSwitcher.isEnabled = false
360363
let ret = mediaPlayerKit.open(withAgoraCDNSrc: streamingUrl, startPos: 0)
361364
print(ret)
@@ -545,7 +548,7 @@ extension FusionCDNHost: AgoraRtcEngineDelegate {
545548
}
546549

547550
func rtcEngine(_ engine: AgoraRtcEngineKit, rtmpStreamingChangedToState url: String, state: AgoraRtmpStreamingState, errCode: AgoraRtmpStreamingErrorCode) {
548-
self.showAlert(message: "On rtmpStreamingChangedToState, state: \(state.rawValue), errCode: \(errCode.rawValue)")
551+
LogUtils.log(message: "On rtmpStreamingChangedToState, state: \(state.rawValue), errCode: \(errCode.rawValue)", level: .info)
549552
}
550553

551554
func rtcEngine(_ engine: AgoraRtcEngineKit, streamUnpublishedWithUrl url: String) {

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,20 @@
132132
</view>
133133
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="w4q-aT-JBc">
134134
<rect key="frame" x="20" y="688" width="80" height="31"/>
135+
<color key="backgroundColor" name="btnPanelBackground"/>
135136
<constraints>
136-
<constraint firstAttribute="width" constant="80" id="lMn-Oa-jhp"/>
137+
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="80" id="Xdc-MD-QxT"/>
137138
</constraints>
138139
<state key="normal" title="Button"/>
139-
<buttonConfiguration key="configuration" style="plain" title="截图">
140-
<backgroundConfiguration key="background">
140+
<buttonConfiguration key="configuration" style="plain" title="截图" cornerStyle="fixed">
141+
<backgroundConfiguration key="background" cornerRadius="5">
141142
<color key="backgroundColor" name="btnPanelBackground"/>
143+
<color key="strokeColor" name="btnPanelBackground"/>
142144
</backgroundConfiguration>
143145
<color key="baseForegroundColor" name="btnPanelForeground"/>
144146
</buttonConfiguration>
145147
<connections>
146-
<action selector="onTakeSnapshot:" destination="jxp-ZN-2yG" eventType="touchUpInside" id="jUu-C7-xyh"/>
148+
<action selector="onTakeSnapshot:" destination="jxp-ZN-2yG" eventType="touchUpInside" id="kRb-DS-stE"/>
147149
</connections>
148150
</button>
149151
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Wts-5Z-p7a" userLabel="UltraLowLatency">
@@ -209,6 +211,7 @@
209211
<constraint firstItem="Wts-5Z-p7a" firstAttribute="top" secondItem="w4q-aT-JBc" secondAttribute="bottom" constant="10" id="eE9-IZ-7gP"/>
210212
<constraint firstItem="Wts-5Z-p7a" firstAttribute="leading" secondItem="Uwe-Fi-04a" secondAttribute="leading" id="ewr-t2-jKP"/>
211213
<constraint firstItem="CeS-QQ-Djo" firstAttribute="trailing" secondItem="q9v-1n-ZYf" secondAttribute="trailing" id="isT-Rq-5PH"/>
214+
<constraint firstItem="CeS-QQ-Djo" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="w4q-aT-JBc" secondAttribute="trailing" symbolic="YES" id="koD-0t-Wh7"/>
212215
<constraint firstItem="Uwe-Fi-04a" firstAttribute="top" secondItem="Wts-5Z-p7a" secondAttribute="bottom" constant="10" id="wl5-PM-CyG"/>
213216
</constraints>
214217
</view>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class LiveStreamingMain: BaseViewController {
6565
var remoteUid: UInt? {
6666
didSet {
6767
foregroundVideoContainer.isHidden = !(role == .broadcaster && remoteUid != nil)
68-
takeSnapshot.isEnabled = remoteUid != nil
6968
}
7069
}
7170
var agoraKit: AgoraRtcEngineKit!
@@ -93,7 +92,6 @@ class LiveStreamingMain: BaseViewController {
9392

9493
override func viewDidLoad() {
9594
super.viewDidLoad()
96-
takeSnapshot.isEnabled = false
9795
// layout render view
9896
foregroundVideoContainer.addSubview(foregroundVideo)
9997
backgroundVideoContainer.addSubview(backgroundVideo)
@@ -192,10 +190,12 @@ class LiveStreamingMain: BaseViewController {
192190

193191
@IBAction func onTakeSnapshot(_ sender: Any) {
194192
guard let remoteUid = remoteUid else {
193+
showAlert(title: "remote user has not joined, and cannot take a screenshot".localized, message: "")
195194
return
196195
}
197196
let path = NSTemporaryDirectory().appending("1.png")
198197
agoraKit.takeSnapshot(Int(remoteUid), filePath: path)
198+
showAlert(title: "Screenshot successful".localized, message: path)
199199
}
200200
@IBAction func onTapForegroundVideo(_ sender:UIGestureRecognizer) {
201201
isLocalVideoForeground = !isLocalVideoForeground

0 commit comments

Comments
 (0)