Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adjust example structure #488

Merged
merged 2 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
android:value="2" />

<service
android:name="io.agora.agora_rtc_engine_example.custom_audio_source.AudioRecordService"
android:name="io.agora.agora_rtc_engine_example.custom_capture_audio.AudioRecordService"
android:exported="false" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package io.agora.agora_rtc_engine_example

import android.os.Bundle
import io.agora.agora_rtc_engine_example.custom_audio_source.CustomAudioPlugin
import io.agora.agora_rtc_engine_example.custom_audio_source.CustomAudioSource
import io.agora.agora_rtc_engine_example.custom_capture_audio.CustomCaptureAudioPlugin
import io.agora.agora_rtc_engine_example.custom_capture_audio.CustomCaptureAudio
import io.agora.rtc.base.RtcEnginePlugin
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import java.lang.ref.WeakReference

class MainActivity: FlutterActivity() {

private val customAudioPlugin = CustomAudioPlugin(WeakReference(this))
private val customCaptureAudioPlugin = CustomCaptureAudioPlugin(WeakReference(this))

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// Register the `CustomAudioPlugin` to interect with the `RtcEngine`
RtcEnginePlugin.register(customAudioPlugin)
// Register the `CustomCaptureAudioPlugin` to interect with the `RtcEngine`
RtcEnginePlugin.register(customCaptureAudioPlugin)
}

override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
// The `CustomAudioSource` is generated by [pigeon](https://pub.dev/packages/pigeon), you can see the
// The `CustomCaptureAudioPlugin` is generated by [pigeon](https://pub.dev/packages/pigeon), you can see the
// the definiton on `example/lib/examples/advanced/custom_audio/custom_audio_source_api.dart`
CustomAudioSource.CustomAudioSourceApi.setup(flutterEngine.dartExecutor, customAudioPlugin)
CustomCaptureAudio.CustomCaptureAudioApi.setup(flutterEngine.dartExecutor, customCaptureAudioPlugin)
}

override fun onDestroy() {
super.onDestroy()

RtcEnginePlugin.unregister(customAudioPlugin)
RtcEnginePlugin.unregister(customCaptureAudioPlugin)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.agora.agora_rtc_engine_example.custom_audio_source;
package io.agora.agora_rtc_engine_example.custom_capture_audio;

import android.app.Notification;
import android.app.NotificationChannel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.agora.agora_rtc_engine_example.custom_audio_source;
package io.agora.agora_rtc_engine_example.custom_capture_audio;

public enum AudioStatus {
INITIALISING,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Autogenerated from Pigeon (v1.0.7), do not edit directly.
// Autogenerated from Pigeon (v1.0.8), do not edit directly.
// See also: https://pub.dev/packages/pigeon

package io.agora.agora_rtc_engine_example.custom_audio_source;
package io.agora.agora_rtc_engine_example.custom_capture_audio;

import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.BinaryMessenger;
Expand All @@ -17,29 +17,29 @@

/** Generated class from Pigeon. */
@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"})
public class CustomAudioSource {
private static class CustomAudioSourceApiCodec extends StandardMessageCodec {
public static final CustomAudioSourceApiCodec INSTANCE = new CustomAudioSourceApiCodec();
private CustomAudioSourceApiCodec() {}
public class CustomCaptureAudio {
private static class CustomCaptureAudioApiCodec extends StandardMessageCodec {
public static final CustomCaptureAudioApiCodec INSTANCE = new CustomCaptureAudioApiCodec();
private CustomCaptureAudioApiCodec() {}
}

/** Generated interface from Pigeon that represents a handler of messages from Flutter.*/
public interface CustomAudioSourceApi {
public interface CustomCaptureAudioApi {
void setExternalAudioSource(Boolean enabled, Long sampleRate, Long channels);
void setExternalAudioSourceVolume(Long sourcePos, Long volume);
void startAudioRecord(Long sampleRate, Long channels);
void stopAudioRecord();

/** The codec used by CustomAudioSourceApi. */
/** The codec used by CustomCaptureAudioApi. */
static MessageCodec<Object> getCodec() {
return CustomAudioSourceApiCodec.INSTANCE;
return CustomCaptureAudioApiCodec.INSTANCE;
}

/** Sets up an instance of `CustomAudioSourceApi` to handle messages through the `binaryMessenger`. */
static void setup(BinaryMessenger binaryMessenger, CustomAudioSourceApi api) {
/** Sets up an instance of `CustomCaptureAudioApi` to handle messages through the `binaryMessenger`. */
static void setup(BinaryMessenger binaryMessenger, CustomCaptureAudioApi api) {
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CustomAudioSourceApi.setExternalAudioSource", getCodec());
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CustomCaptureAudioApi.setExternalAudioSource", getCodec());
if (api != null) {
channel.setMessageHandler((message, reply) -> {
Map<String, Object> wrapped = new HashMap<>();
Expand Down Expand Up @@ -71,7 +71,7 @@ static void setup(BinaryMessenger binaryMessenger, CustomAudioSourceApi api) {
}
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CustomAudioSourceApi.setExternalAudioSourceVolume", getCodec());
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CustomCaptureAudioApi.setExternalAudioSourceVolume", getCodec());
if (api != null) {
channel.setMessageHandler((message, reply) -> {
Map<String, Object> wrapped = new HashMap<>();
Expand Down Expand Up @@ -99,7 +99,7 @@ static void setup(BinaryMessenger binaryMessenger, CustomAudioSourceApi api) {
}
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CustomAudioSourceApi.startAudioRecord", getCodec());
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CustomCaptureAudioApi.startAudioRecord", getCodec());
if (api != null) {
channel.setMessageHandler((message, reply) -> {
Map<String, Object> wrapped = new HashMap<>();
Expand Down Expand Up @@ -127,7 +127,7 @@ static void setup(BinaryMessenger binaryMessenger, CustomAudioSourceApi api) {
}
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CustomAudioSourceApi.stopAudioRecord", getCodec());
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CustomCaptureAudioApi.stopAudioRecord", getCodec());
if (api != null) {
channel.setMessageHandler((message, reply) -> {
Map<String, Object> wrapped = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.agora.agora_rtc_engine_example.custom_audio_source
package io.agora.agora_rtc_engine_example.custom_capture_audio

import android.app.Activity
import android.content.BroadcastReceiver
Expand All @@ -11,9 +11,9 @@ import io.agora.rtc.RtcEngine
import io.agora.rtc.base.RtcEnginePlugin
import java.lang.ref.WeakReference

class CustomAudioPlugin(private val activity: WeakReference<Activity>) :
class CustomCaptureAudioPlugin(private val activity: WeakReference<Activity>) :
RtcEnginePlugin,
CustomAudioSource.CustomAudioSourceApi {
CustomCaptureAudio.CustomCaptureAudioApi {

private var rtcEngine: RtcEngine? = null

Expand Down
26 changes: 13 additions & 13 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
5E9D826C4B1F29399F8A7742 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28CEF344452C45083E367B0C /* Pods_Runner.framework */; };
6D48449932DC5CD432350C00 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43CA39DDEDE840FF44D1F750 /* Pods_RunnerTests.framework */; };
7110181B2727DA66003816A9 /* CustomAudioSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 7110181A2727DA66003816A9 /* CustomAudioSource.m */; };
711018242727DE9A003816A9 /* ExternalAudio.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7110181E2727DE9A003816A9 /* ExternalAudio.mm */; };
711018252727DE9A003816A9 /* AudioWriteToFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 711018222727DE9A003816A9 /* AudioWriteToFile.m */; };
711018262727DE9A003816A9 /* AudioController.m in Sources */ = {isa = PBXBuildFile; fileRef = 711018232727DE9A003816A9 /* AudioController.m */; };
711018282727E05A003816A9 /* CustmoAudioSourcePlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 711018272727E05A003816A9 /* CustmoAudioSourcePlugin.swift */; };
711018282727E05A003816A9 /* CustomCaptureAudioPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 711018272727E05A003816A9 /* CustomCaptureAudioPlugin.swift */; };
715C838B273012A30080FA35 /* CustomCaptureAudio.m in Sources */ = {isa = PBXBuildFile; fileRef = 715C8389273012A30080FA35 /* CustomCaptureAudio.m */; };
71E2A2A22722C75F00C7B7BC /* OCTestRtcEnginePlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E2A29E2722C75F00C7B7BC /* OCTestRtcEnginePlugin.m */; };
71E2A2A32722C75F00C7B7BC /* FakeAgoraRtcEngineKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71E2A2A02722C75F00C7B7BC /* FakeAgoraRtcEngineKit.swift */; };
71E2A2A52722C80800C7B7BC /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71E2A2A42722C80800C7B7BC /* RunnerTests.swift */; };
Expand Down Expand Up @@ -56,16 +56,16 @@
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
43CA39DDEDE840FF44D1F750 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
592BF9E1006B18851CF75B6B /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
711018192727DA66003816A9 /* CustomAudioSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomAudioSource.h; sourceTree = "<group>"; };
7110181A2727DA66003816A9 /* CustomAudioSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomAudioSource.m; sourceTree = "<group>"; };
7110181D2727DE9A003816A9 /* AudioOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioOptions.h; sourceTree = "<group>"; };
7110181E2727DE9A003816A9 /* ExternalAudio.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ExternalAudio.mm; sourceTree = "<group>"; };
7110181F2727DE9A003816A9 /* ExternalAudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExternalAudio.h; sourceTree = "<group>"; };
711018202727DE9A003816A9 /* AudioWriteToFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioWriteToFile.h; sourceTree = "<group>"; };
711018212727DE9A003816A9 /* AudioController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioController.h; sourceTree = "<group>"; };
711018222727DE9A003816A9 /* AudioWriteToFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioWriteToFile.m; sourceTree = "<group>"; };
711018232727DE9A003816A9 /* AudioController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioController.m; sourceTree = "<group>"; };
711018272727E05A003816A9 /* CustmoAudioSourcePlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustmoAudioSourcePlugin.swift; sourceTree = "<group>"; };
711018272727E05A003816A9 /* CustomCaptureAudioPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomCaptureAudioPlugin.swift; sourceTree = "<group>"; };
715C8389273012A30080FA35 /* CustomCaptureAudio.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomCaptureAudio.m; sourceTree = "<group>"; };
715C838A273012A30080FA35 /* CustomCaptureAudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomCaptureAudio.h; sourceTree = "<group>"; };
71E2A2932722C73000C7B7BC /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
71E2A29E2722C75F00C7B7BC /* OCTestRtcEnginePlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCTestRtcEnginePlugin.m; sourceTree = "<group>"; };
71E2A29F2722C75F00C7B7BC /* OCTestRtcEnginePlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCTestRtcEnginePlugin.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -130,21 +130,21 @@
name = Frameworks;
sourceTree = "<group>";
};
711018292727FFF1003816A9 /* CustomAudioSource */ = {
711018292727FFF1003816A9 /* CustomCaptureAudio */ = {
isa = PBXGroup;
children = (
715C838A273012A30080FA35 /* CustomCaptureAudio.h */,
715C8389273012A30080FA35 /* CustomCaptureAudio.m */,
711018212727DE9A003816A9 /* AudioController.h */,
711018232727DE9A003816A9 /* AudioController.m */,
7110181D2727DE9A003816A9 /* AudioOptions.h */,
711018202727DE9A003816A9 /* AudioWriteToFile.h */,
711018222727DE9A003816A9 /* AudioWriteToFile.m */,
7110181F2727DE9A003816A9 /* ExternalAudio.h */,
7110181E2727DE9A003816A9 /* ExternalAudio.mm */,
711018192727DA66003816A9 /* CustomAudioSource.h */,
7110181A2727DA66003816A9 /* CustomAudioSource.m */,
711018272727E05A003816A9 /* CustmoAudioSourcePlugin.swift */,
711018272727E05A003816A9 /* CustomCaptureAudioPlugin.swift */,
);
path = CustomAudioSource;
path = CustomCaptureAudio;
sourceTree = "<group>";
};
71E2A2942722C73000C7B7BC /* RunnerTests */ = {
Expand Down Expand Up @@ -194,7 +194,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
711018292727FFF1003816A9 /* CustomAudioSource */,
711018292727FFF1003816A9 /* CustomCaptureAudio */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -427,11 +427,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
715C838B273012A30080FA35 /* CustomCaptureAudio.m in Sources */,
711018262727DE9A003816A9 /* AudioController.m in Sources */,
7110181B2727DA66003816A9 /* CustomAudioSource.m in Sources */,
711018252727DE9A003816A9 /* AudioWriteToFile.m in Sources */,
711018242727DE9A003816A9 /* ExternalAudio.mm in Sources */,
711018282727E05A003816A9 /* CustmoAudioSourcePlugin.swift in Sources */,
711018282727E05A003816A9 /* CustomCaptureAudioPlugin.swift in Sources */,
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
);
Expand Down
14 changes: 7 additions & 7 deletions example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {

private var customAudioSourcePlugin: CustomAudioPlugin!
private var customCaptureAudioPlugin: CustomCaptureAudioPlugin!

override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController

customAudioSourcePlugin = CustomAudioPlugin()
customCaptureAudioPlugin = CustomCaptureAudioPlugin()

// The `CustomAudioSourceApiSetup` is generated by [pigeon](https://pub.dev/packages/pigeon), you can see the
// the definiton on `example/lib/examples/advanced/custom_audio/custom_audio_source_api.dart`
CustomAudioSourceApiSetup(
controller.binaryMessenger, customAudioSourcePlugin)
// the definiton on `example/lib/examples/advanced/custom_capture_audio/custom_capture_audio_api.dart`
CustomCaptureAudioApiSetup(
controller.binaryMessenger, customCaptureAudioPlugin)

// Register the `CustomAudioPlugin` to interect with the `AgoraRtcEngineKit`
RtcEnginePluginRegistrant.register(customAudioSourcePlugin)
RtcEnginePluginRegistrant.register(customCaptureAudioPlugin)

GeneratedPluginRegistrant.register(with: self)

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

override func applicationWillTerminate(_ application: UIApplication) {
RtcEnginePluginRegistrant.unregister(customAudioSourcePlugin)
RtcEnginePluginRegistrant.unregister(customCaptureAudioPlugin)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v1.0.7), do not edit directly.
// Autogenerated from Pigeon (v1.0.8), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import <Foundation/Foundation.h>
@protocol FlutterBinaryMessenger;
Expand All @@ -9,16 +9,16 @@
NS_ASSUME_NONNULL_BEGIN


/// The codec used by CustomAudioSourceApi.
NSObject<FlutterMessageCodec> *CustomAudioSourceApiGetCodec(void);
/// The codec used by CustomCaptureAudioApi.
NSObject<FlutterMessageCodec> *CustomCaptureAudioApiGetCodec(void);

@protocol CustomAudioSourceApi
@protocol CustomCaptureAudioApi
- (void)setExternalAudioSourceEnabled:(NSNumber *)enabled sampleRate:(NSNumber *)sampleRate channels:(NSNumber *)channels error:(FlutterError *_Nullable *_Nonnull)error;
- (void)setExternalAudioSourceVolumeSourcePos:(NSNumber *)sourcePos volume:(NSNumber *)volume error:(FlutterError *_Nullable *_Nonnull)error;
- (void)startAudioRecordSampleRate:(NSNumber *)sampleRate channels:(NSNumber *)channels error:(FlutterError *_Nullable *_Nonnull)error;
- (void)stopAudioRecordWithError:(FlutterError *_Nullable *_Nonnull)error;
@end

extern void CustomAudioSourceApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<CustomAudioSourceApi> *_Nullable api);
extern void CustomCaptureAudioApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<CustomCaptureAudioApi> *_Nullable api);

NS_ASSUME_NONNULL_END
Loading