Skip to content

Commit 8555330

Browse files
author
zhaoyongqiang
committed
适配4.0.1版本, 添加大小流切换
1 parent 4e32c9b commit 8555330

28 files changed

Lines changed: 189 additions & 108 deletions

File tree

iOS/APIExample/APIExample/Common/ExternalAudio/ExternalAudio.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ int readAudioData(void* data, int bytesLength)
171171

172172
}
173173

174+
virtual bool onEarMonitoringAudioFrame(AudioFrame& audioFrame) override {
175+
return true;
176+
}
177+
174178
// recive remote audio stream, push audio data to byteBuffer_play
175179
virtual bool onPlaybackAudioFrame(const char* channelId, AudioFrame& audioFrame) override
176180
{
@@ -211,6 +215,10 @@ virtual bool onPlaybackAudioFrame(const char* channelId, AudioFrame& audioFrame)
211215

212216
}
213217

218+
virtual AudioParams getEarMonitoringAudioParams() override {
219+
return AudioParams();
220+
}
221+
214222
virtual bool onPlaybackAudioFrameBeforeMixing(const char* channelId, agora::rtc::uid_t uid, AudioFrame& audioFrame) override { return true; }
215223

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

iOS/APIExample/APIExample/Common/RawDataApi/AgoraMediaDataPlugin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ typedef NS_OPTIONS(NSInteger, ObserverPacketType) {
5252
- (AgoraAudioRawData * _Nonnull)mediaDataPlugin:(AgoraMediaDataPlugin * _Nonnull)mediaDataPlugin willPlaybackAudioRawData:(AgoraAudioRawData * _Nonnull)audioRawData;
5353
- (AgoraAudioRawData * _Nonnull)mediaDataPlugin:(AgoraMediaDataPlugin * _Nonnull)mediaDataPlugin willPlaybackBeforeMixingAudioRawData:(AgoraAudioRawData * _Nonnull)audioRawData ofUid:(uint)uid;
5454
- (AgoraAudioRawData * _Nonnull)mediaDataPlugin:(AgoraMediaDataPlugin * _Nonnull)mediaDataPlugin didMixedAudioRawData:(AgoraAudioRawData * _Nonnull)audioRawData;
55+
56+
- (AgoraAudioRawData * _Nonnull)mediaDataPlugin:(AgoraMediaDataPlugin * _Nonnull)mediaDataPlugin onEarMonitoringAudioFrame:(AgoraAudioRawData * _Nonnull)audioRawData;
57+
5558
@end
5659

5760
@protocol AgoraPacketDataPluginDelegate <NSObject>

iOS/APIExample/APIExample/Common/RawDataApi/AgoraMediaDataPlugin.mm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,19 @@ virtual bool onRecordAudioFrame(const char* channelId, AudioFrame& audioFrame) o
212212
return true;
213213
}
214214

215+
virtual bool onEarMonitoringAudioFrame(AudioFrame& audioFrame) override {
216+
217+
if (!mediaDataPlugin && ((mediaDataPlugin.observerAudioType >> 0) == 0)) return true;
218+
@autoreleasepool {
219+
if ([mediaDataPlugin.audioDelegate respondsToSelector:@selector(mediaDataPlugin:onEarMonitoringAudioFrame:)]) {
220+
AgoraAudioRawData *data = getAudioRawDataWithAudioFrame(audioFrame);
221+
AgoraAudioRawData *newData = [mediaDataPlugin.audioDelegate mediaDataPlugin:mediaDataPlugin onEarMonitoringAudioFrame:data];
222+
modifiedAudioFrameWithNewAudioRawData(audioFrame, newData);
223+
}
224+
}
225+
return true;
226+
}
227+
215228
virtual bool onPlaybackAudioFrame(const char* channelId, AudioFrame& audioFrame) override
216229
{
217230
if (!mediaDataPlugin && ((mediaDataPlugin.observerAudioType >> 1) == 0)) return true;
@@ -251,6 +264,10 @@ virtual bool onMixedAudioFrame(const char* channelId, AudioFrame& audioFrame) ov
251264
return true;
252265
}
253266

267+
virtual AudioParams getEarMonitoringAudioParams() override {
268+
return AudioParams();
269+
}
270+
254271
virtual int getObservedAudioFramePosition() override {
255272
return AUDIO_FRAME_POSITION_NONE;
256273
}

iOS/APIExample/APIExample/Examples/Advanced/ContentInspect/ContentInspect.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ class ContentInspectViewController: BaseViewController {
5050
agoraKit.enableContentInspect(true, config:inspectConfig)
5151

5252
let options = AgoraRtcChannelMediaOptions()
53-
options.publishCameraTrack = .of(true)
54-
options.publishMicrophoneTrack = .of(true)
55-
options.clientRoleType = .of((Int32)(GlobalSettings.shared.getUserRole().rawValue))
53+
options.publishCameraTrack = true
54+
options.publishMicrophoneTrack = true
55+
options.clientRoleType = GlobalSettings.shared.getUserRole()
5656
let result = agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channelId, uid: 0, mediaOptions: options)
5757
if result != 0 {
5858
/// Error code description: https://docs.agora.io/en/Interactive%20Broadcast/error_rtc

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ class CreateDataStreamMain: BaseViewController {
107107
// when joining channel. The channel name and uid used to calculate
108108
// the token has to match the ones used for channel join
109109
let option = AgoraRtcChannelMediaOptions()
110-
option.publishCameraTrack = .of(true)
111-
option.publishMicrophoneTrack = .of(true)
112-
option.clientRoleType = .of((Int32)(GlobalSettings.shared.getUserRole().rawValue))
110+
option.publishCameraTrack = true
111+
option.publishMicrophoneTrack = true
112+
option.clientRoleType = GlobalSettings.shared.getUserRole()
113113

114114
let result = agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channelName, uid: 0, mediaOptions: option)
115115
if result != 0 {

iOS/APIExample/APIExample/Examples/Advanced/CustomAudioRender/CustomAudioRender.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ class CustomAudioRenderMain: BaseViewController {
8787
// when joining channel. The channel name and uid used to calculate
8888
// the token has to match the ones used for channel join
8989
let option = AgoraRtcChannelMediaOptions()
90-
option.publishCameraTrack = .of(false)
91-
option.publishMicrophoneTrack = .of(true)
92-
option.clientRoleType = .of((Int32)(GlobalSettings.shared.getUserRole().rawValue))
90+
option.publishCameraTrack = false
91+
option.publishMicrophoneTrack = true
92+
option.clientRoleType = GlobalSettings.shared.getUserRole()
9393

9494
let result = agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channelName, uid: 0, mediaOptions: option)
9595
if result != 0 {

iOS/APIExample/APIExample/Examples/Advanced/CustomAudioSource/CustomAudioSource.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ class CustomAudioSourceMain: BaseViewController {
8484
// when joining channel. The channel name and uid used to calculate
8585
// the token has to match the ones used for channel join
8686
let option = AgoraRtcChannelMediaOptions()
87-
option.publishCameraTrack = .of(false)
88-
option.publishCustomAudioTrack = .of(true)
89-
option.clientRoleType = .of((Int32)(GlobalSettings.shared.getUserRole().rawValue))
87+
option.publishCameraTrack = false
88+
option.publishCustomAudioTrack = true
89+
option.clientRoleType = GlobalSettings.shared.getUserRole()
9090
let result = agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channelName, uid: 0, mediaOptions: option)
9191
if result != 0 {
9292
// Usually happens with invalid parameters

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ class CustomPcmAudioSourceMain: BaseViewController {
9191
// when joining channel. The channel name and uid used to calculate
9292
// the token has to match the ones used for channel join
9393
let option = AgoraRtcChannelMediaOptions()
94-
option.publishCameraTrack = .of(false)
95-
option.publishMicrophoneTrack = .of(true)
96-
option.publishCustomAudioTrack = .of(true)
97-
option.clientRoleType = .of((Int32)(GlobalSettings.shared.getUserRole().rawValue))
94+
option.publishCameraTrack = false
95+
option.publishMicrophoneTrack = true
96+
option.publishCustomAudioTrack = true
97+
option.clientRoleType = GlobalSettings.shared.getUserRole()
9898
let result = agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channelName, uid: 0, mediaOptions: option)
9999
if result != 0 {
100100
// Usually happens with invalid parameters

iOS/APIExample/APIExample/Examples/Advanced/CustomVideoRender/CustomVideoRender.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ class CustomVideoRenderMain: BaseViewController {
100100
// when joining channel. The channel name and uid used to calculate
101101
// the token has to match the ones used for channel join
102102
let option = AgoraRtcChannelMediaOptions()
103-
option.publishCameraTrack = .of(true)
104-
option.publishMicrophoneTrack = .of(true)
105-
option.clientRoleType = .of((Int32)(GlobalSettings.shared.getUserRole().rawValue))
103+
option.publishCameraTrack = true
104+
option.publishMicrophoneTrack = true
105+
option.clientRoleType = GlobalSettings.shared.getUserRole()
106106

107107
let result = agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channelName, uid: 0, mediaOptions: option)
108108
// let result = agoraKit.joinChannel(byToken: nil, channelId: channelName, info: nil, uid: 0) {[unowned self] (channel, uid, elapsed) -> Void in

iOS/APIExample/APIExample/Examples/Advanced/CustomVideoSourcePush/CustomVideoSourcePush.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ class CustomVideoSourcePushMain: BaseViewController {
115115
// when joining channel. The channel name and uid used to calculate
116116
// the token has to match the ones used for channel join
117117
let option = AgoraRtcChannelMediaOptions()
118-
option.publishCustomAudioTrack = .of(false)
119-
option.publishCustomVideoTrack = .of(true)
120-
option.clientRoleType = .of((Int32)(GlobalSettings.shared.getUserRole().rawValue))
118+
option.publishCustomAudioTrack = false
119+
option.publishCustomVideoTrack = true
120+
option.clientRoleType = GlobalSettings.shared.getUserRole()
121121
let result = agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channelName, uid: 0, mediaOptions: option)
122122
if result != 0 {
123123
// Usually happens with invalid parameters
@@ -137,8 +137,8 @@ class CustomVideoSourcePushMain: BaseViewController {
137137
agoraKit.disableAudio()
138138
agoraKit.disableVideo()
139139
let option = AgoraRtcChannelMediaOptions()
140-
option.publishCustomAudioTrack = .of(false)
141-
option.publishCustomVideoTrack = .of(false)
140+
option.publishCustomAudioTrack = false
141+
option.publishCustomVideoTrack = false
142142
agoraKit.updateChannel(with: option)
143143
agoraKit.leaveChannel { (stats) -> Void in
144144
LogUtils.log(message: "left channel, duration: \(stats.duration)", level: .info)

0 commit comments

Comments
 (0)