Skip to content

Commit

Permalink
doc: doc how to use RtcEnginePlugin (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl authored Oct 27, 2021
1 parent 044ae81 commit 9b31d9f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ Open the `Info.plist` and add:

Your application can still run the voice call when it is switched to the background if the background mode is enabled. Select the app target in Xcode, click the **Capabilities** tab, enable **Background Modes**, and check **Audio, AirPlay, and Picture in Picture**.

## Interact with RtcEngine/AgoraRtcEngineKit on Android/iOS

`agora_rtc_engine` has not implemented all the features of agora native (Android/iOS) sdk, due to performance reasons, such as [Custom Audio Source and Renderer](https://docs.agora.io/en/Video/custom_audio_android?platform=Android), [Custom Video Source and Renderer](https://docs.agora.io/en/Video/custom_video_android?platform=Android), [Raw Audio Data](https://docs.agora.io/en/Video/raw_data_audio_android?platform=Android), etc. `agora_rtc_engine` provides [RtcEnginePlugin](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/android/src/main/java/io/agora/rtc/base/RtcEnginePlugin.kt)/[RtcEnginePlugin](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/ios/Classes/Base/RtcEnginePlugin.h), allowing you to to interact with the [RtcEngine](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/lib/src/rtc_engine.dart) created on the Flutter side in the Android/iOS code, you can implement your own plugin by inheriting [RtcEnginePlugin](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/android/src/main/java/io/agora/rtc/base/RtcEnginePlugin.kt)/[RtcEnginePlugin](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/ios/Classes/Base/RtcEnginePlugin.h), and get the [RtcEngine](https://docs.agora.io/en/Video/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html)/[AgoraRtcEngineKit](https://docs.agora.io/en/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html) in the `onRtcEngineCreated` callback. Please note that you should not call the [RtcEngine.destroy](https://docs.agora.io/en/Video/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#afb808cdc9025a77af7dd2bce98311bfe)/[AgoraRtcEngineKit.destroy](https://docs.agora.io/en/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html#//api/name/destroy) function on Android/iOS code, because it will affect the [RtcEngine](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/lib/src/rtc_engine.dart) on the Flutter side. To see how to use `RtcEnginePlugin`, please check the custom audio source example:

Android:[CustomAudioPlugin.kt](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/example/android/app/src/main/kotlin/io/agora/agora_rtc_engine_example/custom_audio_source/CustomAudioPlugin.kt)

iOS:[CustmoAudioSourcePlugin.swift](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/example/ios/Runner/CustomAudioSource/CustmoAudioSourcePlugin.swift)

## Error handling

### Android build error
Expand Down
8 changes: 8 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ Agora 视频 SDK 需要 `摄像头` 和 `麦克风` 权限来开始视频通话

您的程序可以在后台运行音视频通话,前提是您开启了后台模式。在 Xcode 中选择您的 app target,点击 **Capabilities** 标签,开启 **Background Modes**,并且检查 **Audio、AirPlay 和 Picture in Picture**

## 在Android/iOS中与[RtcEngine](https://docs.agora.io/cn/Video/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html)/[AgoraRtcEngineKit](https://docs.agora.io/cn/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html)交互

由于性能原因,`agora_rtc_engine`暂时没有实现agora native(Android/iOS) sdk的所有功能,如[自定义音频采集和渲染](hhttps://docs.agora.io/cn/Video/custom_audio_android?platform=Android),[自定义视频采集和渲染](https://docs.agora.io/cn/Video/custom_video_android?platform=Android),[原始音频数据](https://docs.agora.io/cn/Video/raw_data_audio_android?platform=Android)等功能,`agora_rtc_engine`提供[RtcEnginePlugin](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/android/src/main/java/io/agora/rtc/base/RtcEnginePlugin.kt)/[RtcEnginePlugin](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/ios/Classes/Base/RtcEnginePlugin.h),允许你在Android/iOS代码中与Flutter端创建的[RtcEngine](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/lib/src/rtc_engine.dart)交互,你可以继承[RtcEnginePlugin](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/android/src/main/java/io/agora/rtc/base/RtcEnginePlugin.kt)/[RtcEnginePlugin](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/ios/Classes/Base/RtcEnginePlugin.h)实现自己的插件,在`onRtcEngineCreated`回调中获取[RtcEngine](https://docs.agora.io/cn/Video/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html)/[AgoraRtcEngineKit](https://docs.agora.io/cn/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html),请注意不要在Android/iOS中调用[RtcEngine.destroy](https://docs.agora.io/cn/Video/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#afb808cdc9025a77af7dd2bce98311bfe)/[AgoraRtcEngineKit.destroy](https://docs.agora.io/cn/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html#//api/name/destroy)方法,因为这会影响Flutter端的[RtcEngine](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/lib/src/rtc_engine.dart)功能。如何使用`RtcEnginePlugin`,请查看我们提供的音频自采集demo:

Android:[CustomAudioPlugin.kt](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/example/android/app/src/main/kotlin/io/agora/agora_rtc_engine_example/custom_audio_source/CustomAudioPlugin.kt)

iOS:[CustmoAudioSourcePlugin.swift](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/example/ios/Runner/CustomAudioSource/CustmoAudioSourcePlugin.swift)

## 常见问题

### iOS 无法显示视频(Android 是好的)
Expand Down
3 changes: 3 additions & 0 deletions android/src/main/java/io/agora/rtc/base/RtcEnginePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ interface RtcEnginePlugin {
* This callback will be called when the [RtcEngine] is created by
* [RtcEngine.createWithContext](https://docs.agora.io/cn/Video/API%20Reference/flutter/agora_rtc_engine/RtcEngine/createWithContext.html)
* function from flutter.
*
* NOTE that you should not call [RtcEngine.destroy], because it will also destroy the `RtcEngine`
* used by flutter side.
*
* @param rtcEngine The same [RtcEngine] used by flutter side
*/
Expand Down
5 changes: 4 additions & 1 deletion ios/Classes/Base/RtcEnginePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ NS_ASSUME_NONNULL_BEGIN
* This callback will be called when the `RtcEngine` is created by
[RtcEngine.createWithContext](https://docs.agora.io/cn/Video/API%20Reference/flutter/agora_rtc_engine/RtcEngine/createWithContext.html)
* function from flutter.
* NOTE that you should not call `AgoraRtcEngineKit.destroy`, because it will also destroy the `RtcEngine`
* used by flutter side.
*
* @param rtcEngine The same [RtcEngine] used by flutter side
* @param rtcEngine The same `AgoraRtcEngineKit` used by flutter side
*/
- (void)onRtcEngineCreated:(AgoraRtcEngineKit *_Nullable)rtcEngine;

Expand Down

0 comments on commit 9b31d9f

Please sign in to comment.