Skip to content

Commit 2e5bcc4

Browse files
author
zhaoyongqiang
committed
1.适配4.0.1版本 2.添加大小流切换功能
1 parent 548a4b9 commit 2e5bcc4

30 files changed

Lines changed: 959 additions & 99 deletions

File tree

macOS/APIExample.xcodeproj/project.pbxproj

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@
9797
8BE63B4227253CB000597DB1 /* SimpleFilter.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8BE63B4427253CB000597DB1 /* SimpleFilter.storyboard */; };
9898
8BF22438275F704600B65EF8 /* Pods_APIExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F65EF2B97B89DE4581B426B /* Pods_APIExample.framework */; };
9999
8BF2243B275F82CF00B65EF8 /* SimpleFilter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8BD4AE79272518D600E95B87 /* SimpleFilter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
100+
E702C1E628B4DB4800D7C7ED /* LiveStreaming.strings in Resources */ = {isa = PBXBuildFile; fileRef = E702C1E128B4DB4800D7C7ED /* LiveStreaming.strings */; };
101+
E702C1E728B4DB4800D7C7ED /* LiveStreaming.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E702C1E328B4DB4800D7C7ED /* LiveStreaming.storyboard */; };
102+
E702C1E828B4DB4800D7C7ED /* LiveStreaming.swift in Sources */ = {isa = PBXBuildFile; fileRef = E702C1E528B4DB4800D7C7ED /* LiveStreaming.swift */; };
103+
E702C1EA28B5C17600D7C7ED /* agora-logo.png in Resources */ = {isa = PBXBuildFile; fileRef = E702C1E928B5C17600D7C7ED /* agora-logo.png */; };
100104
E71E7B0B289B7D7900B846C7 /* SimpleFilter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8BD4AE79272518D600E95B87 /* SimpleFilter.framework */; };
101105
E71E7B0C289B96FA00B846C7 /* VideoProcess.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E71E7B0E289B96FA00B846C7 /* VideoProcess.storyboard */; };
102106
E71E7B17289BA78D00B846C7 /* QuickSwitchChannel.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E71E7B15289BA78D00B846C7 /* QuickSwitchChannel.storyboard */; };
@@ -252,6 +256,11 @@
252256
8BD4AE72272513FF00E95B87 /* SimpleFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleFilter.swift; sourceTree = "<group>"; };
253257
8BD4AE79272518D600E95B87 /* SimpleFilter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SimpleFilter.framework; sourceTree = BUILT_PRODUCTS_DIR; };
254258
8BE63B4527253CD900597DB1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/SimpleFilter.storyboard; sourceTree = "<group>"; };
259+
E702C1E228B4DB4800D7C7ED /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LiveStreaming.strings"; sourceTree = "<group>"; };
260+
E702C1E428B4DB4800D7C7ED /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LiveStreaming.storyboard; sourceTree = "<group>"; };
261+
E702C1E528B4DB4800D7C7ED /* LiveStreaming.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LiveStreaming.swift; sourceTree = "<group>"; };
262+
E702C1E928B5C17600D7C7ED /* agora-logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "agora-logo.png"; path = "../../../iOS/APIExample/APIExample/Resources/agora-logo.png"; sourceTree = "<group>"; };
263+
E702C1EB28B5C76000D7C7ED /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LiveStreaming.strings"; sourceTree = "<group>"; };
255264
E71E7B0D289B96FA00B846C7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/VideoProcess.storyboard; sourceTree = "<group>"; };
256265
E71E7B12289B971900B846C7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/VideoProcess.strings; sourceTree = "<group>"; };
257266
E71E7B13289B9C2C00B846C7 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/VideoProcess.strings"; sourceTree = "<group>"; };
@@ -462,6 +471,7 @@
462471
034C629D25297ABB00296ECF /* Resources */ = {
463472
isa = PBXGroup;
464473
children = (
474+
E702C1E928B5C17600D7C7ED /* agora-logo.png */,
465475
67033725279E81DF0069F4B3 /* bg.jpg */,
466476
671BD67A27E0A4F50076D5E1 /* output.raw */,
467477
57A635F32593544600EDC2F7 /* effectA.wav */,
@@ -483,6 +493,7 @@
483493
036D3AA524FB797700B1D8DC /* Advanced */ = {
484494
isa = PBXGroup;
485495
children = (
496+
E702C1E028B4DB4800D7C7ED /* LiveStreaming */,
486497
E71E7B14289BA78D00B846C7 /* QuickSwitchChannel */,
487498
67033720279E75770069F4B3 /* VideoProcess */,
488499
8BD4AE6F272513D000E95B87 /* SimpleFilter */,
@@ -741,6 +752,16 @@
741752
path = SimpleFilter;
742753
sourceTree = "<group>";
743754
};
755+
E702C1E028B4DB4800D7C7ED /* LiveStreaming */ = {
756+
isa = PBXGroup;
757+
children = (
758+
E702C1E128B4DB4800D7C7ED /* LiveStreaming.strings */,
759+
E702C1E328B4DB4800D7C7ED /* LiveStreaming.storyboard */,
760+
E702C1E528B4DB4800D7C7ED /* LiveStreaming.swift */,
761+
);
762+
path = LiveStreaming;
763+
sourceTree = "<group>";
764+
};
744765
E71E7B14289BA78D00B846C7 /* QuickSwitchChannel */ = {
745766
isa = PBXGroup;
746767
children = (
@@ -896,12 +917,15 @@
896917
67033726279E81DF0069F4B3 /* bg.jpg in Resources */,
897918
033A9FB3252EAEB500BC26E1 /* JoinChannelVideo.storyboard in Resources */,
898919
036D3AA024FA40EB00B1D8DC /* VideoView.xib in Resources */,
920+
E702C1EA28B5C17600D7C7ED /* agora-logo.png in Resources */,
899921
033A9FEB252EB5CC00BC26E1 /* AudioMixing.storyboard in Resources */,
900922
67E40B2427EC82F900C7A6E9 /* SpatialAudio.storyboard in Resources */,
901923
671BD67B27E0A4F50076D5E1 /* output.raw in Resources */,
902924
E71E7B0C289B96FA00B846C7 /* VideoProcess.storyboard in Resources */,
925+
E702C1E628B4DB4800D7C7ED /* LiveStreaming.strings in Resources */,
903926
033A9FCC252EB03F00BC26E1 /* CustomVideoSourcePush.storyboard in Resources */,
904927
671BD67127DF478A0076D5E1 /* CustomVideoRender.storyboard in Resources */,
928+
E702C1E728B4DB4800D7C7ED /* LiveStreaming.storyboard in Resources */,
905929
57A635F42593544600EDC2F7 /* effectA.wav in Resources */,
906930
033A9FF5252EB5F400BC26E1 /* JoinMultiChannel.storyboard in Resources */,
907931
033A9FD6252EB05200BC26E1 /* RTMPStreaming.storyboard in Resources */,
@@ -1008,6 +1032,7 @@
10081032
034C626C25259FC200296ECF /* JoinChannelVideo.swift in Sources */,
10091033
034C62772525C68D00296ECF /* AgoraCustomEncryption.mm in Sources */,
10101034
03896D3224F8A00F008593CD /* ViewController.swift in Sources */,
1035+
E702C1E828B4DB4800D7C7ED /* LiveStreaming.swift in Sources */,
10111036
03896D3024F8A00F008593CD /* AppDelegate.swift in Sources */,
10121037
034C626425257EA600296ECF /* GlobalSettings.swift in Sources */,
10131038
036D3A9A24FA395E00B1D8DC /* KeyCenter.swift in Sources */,
@@ -1226,6 +1251,23 @@
12261251
name = SimpleFilter.storyboard;
12271252
sourceTree = "<group>";
12281253
};
1254+
E702C1E128B4DB4800D7C7ED /* LiveStreaming.strings */ = {
1255+
isa = PBXVariantGroup;
1256+
children = (
1257+
E702C1E228B4DB4800D7C7ED /* zh-Hans */,
1258+
);
1259+
name = LiveStreaming.strings;
1260+
sourceTree = "<group>";
1261+
};
1262+
E702C1E328B4DB4800D7C7ED /* LiveStreaming.storyboard */ = {
1263+
isa = PBXVariantGroup;
1264+
children = (
1265+
E702C1E428B4DB4800D7C7ED /* Base */,
1266+
E702C1EB28B5C76000D7C7ED /* zh-Hans */,
1267+
);
1268+
name = LiveStreaming.storyboard;
1269+
sourceTree = "<group>";
1270+
};
12291271
E71E7B0E289B96FA00B846C7 /* VideoProcess.storyboard */ = {
12301272
isa = PBXVariantGroup;
12311273
children = (

macOS/APIExample/Commons/ExternalAudio/ExternalAudio.mm

Lines changed: 12 additions & 3 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; }
@@ -276,10 +284,10 @@ - (void)startWork {
276284

277285
- (void)stopWork {
278286
[self.audioController stopWork];
279-
[self cancelRegiset];
287+
[self cancelRegister];
280288
}
281289

282-
- (void)cancelRegiset {
290+
- (void)cancelRegister {
283291
agora::rtc::IRtcEngine* rtc_engine = (agora::rtc::IRtcEngine*)self.agoraKit.getNativeHandle;
284292
agora::util::AutoPtr<agora::media::IMediaEngine> mediaEngine;
285293
mediaEngine.queryInterface(rtc_engine, agora::rtc::AGORA_IID_MEDIA_ENGINE);
@@ -294,7 +302,8 @@ - (void)audioController:(AudioController *)controller didCaptureData:(unsigned c
294302
}
295303
}
296304
else {
297-
[self.agoraKit pushExternalAudioFrameRawData:data samples:441 * 10 sourceId:1 timestamp:0];
305+
// [self.agoraKit pushExternalAudioFrameNSData:[NSData dataWithBytes:data length:bytesLength] sourceId:1 timestamp:0];
306+
[self.agoraKit pushExternalAudioFrameRawData: data samples: 441 * 10 sourceId:1 timestamp:0];
298307
}
299308

300309
}

macOS/APIExample/Commons/RawDataApi/AgoraMediaDataPlugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ typedef NS_OPTIONS(NSInteger, ObserverPacketType) {
5454
- (AgoraAudioRawData * _Nonnull)mediaDataPlugin:(AgoraMediaDataPlugin * _Nonnull)mediaDataPlugin willPlaybackAudioRawData:(AgoraAudioRawData * _Nonnull)audioRawData;
5555
- (AgoraAudioRawData * _Nonnull)mediaDataPlugin:(AgoraMediaDataPlugin * _Nonnull)mediaDataPlugin willPlaybackBeforeMixingAudioRawData:(AgoraAudioRawData * _Nonnull)audioRawData ofUid:(uint)uid;
5656
- (AgoraAudioRawData * _Nonnull)mediaDataPlugin:(AgoraMediaDataPlugin * _Nonnull)mediaDataPlugin didMixedAudioRawData:(AgoraAudioRawData * _Nonnull)audioRawData;
57+
- (AgoraAudioRawData * _Nonnull)mediaDataPlugin:(AgoraMediaDataPlugin * _Nonnull)mediaDataPlugin onEarMonitoringAudioFrame:(AgoraAudioRawData * _Nonnull)audioRawData;
5758
@end
5859

5960
@protocol AgoraPacketDataPluginDelegate <NSObject>

macOS/APIExample/Commons/RawDataApi/AgoraMediaDataPlugin.mm

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

217+
virtual bool onEarMonitoringAudioFrame(AudioFrame& audioFrame) override {
218+
219+
if (!mediaDataPlugin && ((mediaDataPlugin.observerAudioType >> 0) == 0)) return true;
220+
@autoreleasepool {
221+
if ([mediaDataPlugin.audioDelegate respondsToSelector:@selector(mediaDataPlugin:onEarMonitoringAudioFrame:)]) {
222+
AgoraAudioRawData *data = getAudioRawDataWithAudioFrame(audioFrame);
223+
AgoraAudioRawData *newData = [mediaDataPlugin.audioDelegate mediaDataPlugin:mediaDataPlugin onEarMonitoringAudioFrame:data];
224+
modifiedAudioFrameWithNewAudioRawData(audioFrame, newData);
225+
}
226+
}
227+
return true;
228+
}
229+
217230
virtual bool onPlaybackAudioFrame(const char* channelId, AudioFrame& audioFrame) override
218231
{
219232
if (!mediaDataPlugin && ((mediaDataPlugin.observerAudioType >> 1) == 0)) return true;
@@ -252,6 +265,9 @@ virtual bool onMixedAudioFrame(const char* channelId, AudioFrame& audioFrame) ov
252265
}
253266
return true;
254267
}
268+
virtual AudioParams getEarMonitoringAudioParams() override {
269+
return AudioParams();
270+
}
255271
virtual int getObservedAudioFramePosition() override {
256272
return AUDIO_FRAME_POSITION_NONE;
257273
}

macOS/APIExample/Examples/Advanced/AudioMixing/AudioMixing.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ class AudioMixing: BaseViewController {
408408
// the token has to match the ones used for channel join
409409
isProcessing = true
410410
let option = AgoraRtcChannelMediaOptions()
411-
option.publishCameraTrack = .of(true)
412-
option.clientRoleType = .of((Int32)(AgoraClientRole.broadcaster.rawValue))
411+
option.publishCameraTrack = true
412+
option.clientRoleType = .broadcaster
413413
NetworkManager.shared.generateToken(channelName: channel) {
414414
let result = self.agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channel, uid: 0, mediaOptions: option)
415415
if result != 0 {

macOS/APIExample/Examples/Advanced/ChannelMediaRelay/ChannelMediaRelay.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ class ChannelMediaRelay: BaseViewController {
197197
// the token has to match the ones used for channel join
198198
isProcessing = true
199199
let option = AgoraRtcChannelMediaOptions()
200-
option.publishCameraTrack = .of(true)
201-
option.clientRoleType = .of((Int32)(AgoraClientRole.broadcaster.rawValue))
200+
option.publishCameraTrack = true
201+
option.clientRoleType = .broadcaster
202202
NetworkManager.shared.generateToken(channelName: channel) {
203203
let result = self.agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channel, uid: 0, mediaOptions: option)
204204
if result != 0 {

macOS/APIExample/Examples/Advanced/ContentInspect/ContentInspect.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class ContentInspectViewController: BaseViewController {
8181
agoraKit.enableContentInspect(true, config:inspectConfig)
8282

8383
let options = AgoraRtcChannelMediaOptions()
84-
options.publishCameraTrack = .of(true)
85-
options.clientRoleType = .of((Int32)(AgoraClientRole.broadcaster.rawValue))
84+
options.publishCameraTrack = true
85+
options.clientRoleType = .broadcaster
8686
NetworkManager.shared.generateToken(channelName: channelId) {
8787
let result = self.agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channelId, uid: 0, mediaOptions: options)
8888
if result != 0 {

macOS/APIExample/Examples/Advanced/CreateDataStream/CreateDataStream.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ class CreateDataStream: BaseViewController {
195195
// the token has to match the ones used for channel join
196196
isProcessing = true
197197
let option = AgoraRtcChannelMediaOptions()
198-
option.publishCameraTrack = .of(true)
199-
option.clientRoleType = .of((Int32)(AgoraClientRole.broadcaster.rawValue))
198+
option.publishCameraTrack = true
199+
option.clientRoleType = .broadcaster
200200
NetworkManager.shared.generateToken(channelName: channel) {
201201
let result = self.agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channel, uid: 0, mediaOptions: option)
202202
if result != 0 {

macOS/APIExample/Examples/Advanced/CustomAudioRender/CustomAudioRender.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ class CustomAudioRender: BaseViewController {
180180
// the token has to match the ones used for channel join
181181
isProcessing = true
182182
let option = AgoraRtcChannelMediaOptions()
183-
option.publishCameraTrack = .of(true)
184-
option.clientRoleType = .of((Int32)(AgoraClientRole.broadcaster.rawValue))
183+
option.publishCameraTrack = true
184+
option.clientRoleType = .broadcaster
185185
NetworkManager.shared.generateToken(channelName: channel) {
186186
let result = self.agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channel, uid: 0, mediaOptions: option)
187187
if result != 0 {

macOS/APIExample/Examples/Advanced/CustomAudioSource/CustomAudioSource.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ class CustomAudioSource: BaseViewController {
200200
isProcessing = true
201201

202202
let option = AgoraRtcChannelMediaOptions()
203-
option.publishMicrophoneTrack = .of(true)
204-
option.publishCustomAudioTrack = .of(true)
205-
option.publishCameraTrack = .of(false)
203+
option.publishMicrophoneTrack = true
204+
option.publishCustomAudioTrack = true
205+
option.publishCameraTrack = false
206206
NetworkManager.shared.generateToken(channelName: channel) {
207207
let result = self.agoraKit.joinChannel(byToken: KeyCenter.Token, channelId: channel, uid: 0, mediaOptions: option)
208208
if result != 0 {

0 commit comments

Comments
 (0)