Skip to content

Commit

Permalink
feat: support native 3.5.2 (#448)
Browse files Browse the repository at this point in the history
* Squashed 'android/src/main/java/io/agora/rtc/base/' changes from f1ed825..987de50

987de50 feat: support 3.5.2
4ebf77c feat: support 3.5.1 & plugin
27c788c chore: mapToColor
0278629 feat: support 3.5.0.2
45dcd16 chore: add API which is missing
58ca4b0 fix: AudioRecordingConfiguration bug
4a32e12 chore: prepare to migrate to iris
276c9fe chore: support 3.4.5
783aecf chore: add ERR_ALREADY_IN_RECORDING
3aed6ce fix: startAudioRecording bug
510b405 chore: optimize
4f801b9 chore: optimize
ab71f52 chore: optimize startAudioRecording
07f81c7 chore: optimize
5a20e13 style: optimize
858b58f fix(uid compatible): int to uint
8d14d2d feat(upgrade): 3.4.1
be5efea Merge pull request #4 from AgoraLibrary/dev/3.3.0
382f858 Merge branch 'master' into dev/3.3.0
8671535 Merge pull request #3 from AgoraLibrary/dev/3.2.0
feabda3 Merge branch 'master' into dev/3.2.0
9e57891 Merge pull request #2 from AgoraLibrary/dev/3.1.0
ad03101 fix: merge some bug fix
df303ee fix: merge some bug fix
cd7a2cd feat: support 3.3.1 for Android
551ebfe fix: annotation build warning
9c48594 feat: support 3.3.0 for Android
de52ca6 Merge branch 'master' into dev/3.2.0
75f572d fix: use the better way to fix rendering problems
9ab28a7 fix: `MetadataReceived` event parameters bug
ddeaefb Merge branch 'master' into dev/3.2.0
313cddd chore: add .gitignore
c737102 fix: some rendering problems when change render widget order
2520e7a style: format with 2 spaces
2fef3ae feat: add `setClientRole(role: ClientRole, options?: ClientRoleOptions): Promise<void>`
fcb57cc feat: upgrade to 3.2.0
66eeaad Merge commit '0eab47114cde933482f90879e177fd019430cafd' into dev/raw_data
576473c Android add getNativeHandle
0eab471 feat: Android add getNativeHandle
66ed5b5 fix bug
e0d1d08 * fix `setDefaultAudioRoutetoSpeakerphone` crash bug * add `setAudioSessionOperationRestriction` and `sendCustomReportMessage` method
c82a9e1 finish
9fa3009 iOS finished
d69a73d android finished
51b093b - fix crash when rendering view without `channelId` property - fix `RtcLocalView` freezes after rendering remote view
10a3d01 - fix multiple channel render bug - remove `Types` from export, you can import enum or class by `import {} from 'react-native-agora'`
d998401 - add `startPreview` `stopPreview`
93621d3 - add `constructor` for typescript - fix Android `mapToChannelMediaInfo` crash - fix iOS `switchChannel` `sendMetadata` crash
d1d40f5 Merge commit 'b67450678710cbc3ad4fcf72d8b53dd695d0a8e8' into beta/3.0.0
b674506 Android finish
bdd398f change Double to Number
b17dd47 fix convert exception in mapToCameraCapturerConfiguration function
cf24c0b fix bugs
51f0ca3 fix bug from issue: #213 upgrade to 3.0.1

git-subtree-dir: android/src/main/java/io/agora/rtc/base
git-subtree-split: 987de50b775615157512823211fd86be2c344493

* Squashed 'ios/RCTAgora/Base/' changes from df4d47e..a7ddd5e

a7ddd5e style: format
6db7748 feat: support 3.5.2
325c233 feat: support 3.5.1 & plugin
d4e2686 fix: mapToEncryptionConfig crash
f4be532 fix: compiler error
4eb127f chore: support 3.5.0.2
3c32dc5 chore: add API which is missing
3bb9210 fix: API call error
732df69 feat: support 3.4.6
782ec46 chore: prepare to migrate to iris
ba7fba7 chore: support 3.4.5
f25a603 fix: startAudioRecording bug
02b6cc3 chore: optimize startAudioRecording
88b3d59 style: format code
b60a451 Merge pull request #6 from AgoraLibrary/main/3.4.+
d1561f7 feat(upgrade): 3.4.1
bb84006 Merge pull request #5 from AgoraLibrary/main/3.3.+
4623dc3 fix: getErrorDescription key error
ee40ba1 Merge pull request #4 from AgoraLibrary/dev/3.3.0
f8bde68 Merge branch 'master' into dev/3.3.0
0db518f Merge pull request #3 from AgoraLibrary/dev/3.2.0
5f69768 Merge branch 'master' into dev/3.2.0
d355c51 Merge pull request #2 from AgoraLibrary/dev/3.1.0
b87cce2 fix: merge some bug fix
a81db07 fix: merge some bug fix
2d1ac8f fix: iOS selector error
98c4331 fix: type cast error
836f3b4 feat: support 3.3.1 for iOS
b422ce8 feat: support 3.3.0 for iOS
c8a08e5 Merge branch 'master' into dev/3.2.0
a290e73 fix: use the better way to fix rendering problems
56ab25b fix: `MetadataReceived` event parameters bug
daefc68 style: use shorthand arguments for lambda
561b3fd Merge branch 'master' into dev/3.2.0
12e2561 fix: some rendering problems when change render widget order
6f52bef Merge commit 'c8845fe04c1596fe2e7242302bf160bc671910cb' into rc/3.1.+
da3222a Merge branch 'master' into dev/3.2.0
c8845fe fix: `RtcSurfaceView` memory leak
3a55997 feat: add `setClientRole(role: ClientRole, options?: ClientRoleOptions): Promise<void>`
4ee51a9 feat: upgrade to 3.2.0
73f3a32 Merge remote-tracking branch 'origin/dev/raw_data' into dev/raw_data
374f3e9 feat: iOS raw data plugin
cd09ccc iOS raw data plugin
12cf9cf * fix `setDefaultAudioRoutetoSpeakerphone` crash bug * add `setAudioSessionOperationRestriction` and `sendCustomReportMessage` method
fc1e7e0 finish
c034b86 iOS finished
efe8898 Merge commit 'dbb223a1b79dc10717c0feb6127060eef66a895f' into rc/3.1.2
9e9ecfa - fix `Xcode10` `Swift4` compile error
dbb223a * fix iOS `FirstLocalVideoFrame` `VideoSizeChanged` `FirstRemoteVideoFrame` `FirstRemoteVideoDecoded` bug
d2c9afa - fix crash when rendering view without `channelId` property - fix `RtcLocalView` freezes after rendering remote view
6eec86f - fix multiple channel render bug - remove `Types` from export, you can import enum or class by `import {} from 'react-native-agora'`
cab5a62 - add `startPreview` `stopPreview`
e8a38b1 - add `constructor` for typescript - fix Android `mapToChannelMediaInfo` crash - fix iOS `switchChannel` `sendMetadata` crash
a2b9df7 iOS finish
13282b6 iOS engine finish
65b7f70 fix bug from issue: #213 upgrade to 3.0.1

git-subtree-dir: ios/RCTAgora/Base
git-subtree-split: a7ddd5e7463d720db83744c29a5982d154ddd39b

* feat: upgrade to 3.5.2

* Squashed 'ios/RCTAgora/Base/' changes from a7ddd5e..9d52a5f

9d52a5f fix: build failed on other platform

git-subtree-dir: ios/RCTAgora/Base
git-subtree-split: 9d52a5f4b254e427c0917de71c278da38c4cb2d6

* feat: support 3.5.2

* Squashed 'android/src/main/java/io/agora/rtc/base/' changes from 987de50..fbf0147

fbf0147 fix: getAudioFileInfo & selectAudioTrack

git-subtree-dir: android/src/main/java/io/agora/rtc/base
git-subtree-split: fbf0147a1ba57f0eabe9c5b54fffeec83a7e2c14

* Squashed 'ios/RCTAgora/Base/' changes from 9d52a5f..40fe426

40fe426 fix: getAudioFileInfo & selectAudioTrack

git-subtree-dir: ios/RCTAgora/Base
git-subtree-split: 40fe42656eea7efdb588fb7495ad7a452a804c0b
  • Loading branch information
LichKing-2234 committed Dec 14, 2021
1 parent 1130839 commit dddce67
Show file tree
Hide file tree
Showing 27 changed files with 968 additions and 86 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
api 'com.github.agorabuilder:native-full-sdk:3.5.0.4'
api 'com.github.agorabuilder:native-full-sdk:3.5.2'

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
9 changes: 5 additions & 4 deletions android/src/main/java/io/agora/rtc/base/Annotations.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ public class Annotations {
Constants.RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE,
Constants.RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_IS_NULL,
Constants.RELAY_EVENT_VIDEO_PROFILE_UPDATE,
// Constants.RELAY_EVENT_PAUSE_SEND_PACKET_TO_DEST_CHANNEL_SUCCESS,
// Constants.RELAY_EVENT_PAUSE_SEND_PACKET_TO_DEST_CHANNEL_FAILED,
// Constants.RELAY_EVENT_RESUME_SEND_PACKET_TO_DEST_CHANNEL_SUCCESS,
// Constants.RELAY_EVENT_RESUME_SEND_PACKET_TO_DEST_CHANNEL_FAILED,
Constants.RELAY_EVENT_PAUSE_SEND_PACKET_TO_DEST_CHANNEL_SUCCESS,
Constants.RELAY_EVENT_PAUSE_SEND_PACKET_TO_DEST_CHANNEL_FAILED,
Constants.RELAY_EVENT_RESUME_SEND_PACKET_TO_DEST_CHANNEL_SUCCESS,
Constants.RELAY_EVENT_RESUME_SEND_PACKET_TO_DEST_CHANNEL_FAILED,
})
@Retention(RetentionPolicy.SOURCE)
public @interface AgoraChannelMediaRelayEvent {
Expand Down Expand Up @@ -973,6 +973,7 @@ public class Annotations {
@IntDef({
VirtualBackgroundSource.BACKGROUND_COLOR,
VirtualBackgroundSource.BACKGROUND_IMG,
VirtualBackgroundSource.BACKGROUND_BLUR,
})
@Retention(RetentionPolicy.SOURCE)
public @interface AgoraVirtualBackgroundSourceType {
Expand Down
11 changes: 11 additions & 0 deletions android/src/main/java/io/agora/rtc/base/BeanCovertor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.agora.rtc.live.LiveTranscoding.TranscodingUser
import io.agora.rtc.models.ChannelMediaOptions
import io.agora.rtc.models.ClientRoleOptions
import io.agora.rtc.models.DataStreamConfig
import io.agora.rtc.models.EchoTestConfiguration
import io.agora.rtc.video.*

fun mapToVideoDimensions(map: Map<*, *>): VideoEncoderConfiguration.VideoDimensions {
Expand Down Expand Up @@ -261,5 +262,15 @@ fun mapToVirtualBackgroundSource(map: Map<*, *>): VirtualBackgroundSource {
(map["backgroundSourceType"] as? Number)?.let { backgroundSourceType = it.toInt() }
(map["color"] as? Map<*, *>)?.let { color = mapToColor(it) }
(map["source"] as? String)?.let { source = it }
(map["blur_degree"] as? Int)?.let { blur_degree = it }
}
}

fun mapToEchoTestConfiguration(map: Map<*, *>): EchoTestConfiguration {
return EchoTestConfiguration().apply {
(map["enableAudio"] as? Boolean)?.let { enableAudio = it }
(map["enableVideo"] as? Boolean)?.let { enableVideo = it }
(map["token"] as? String)?.let { token = it }
(map["channelId"] as? String)?.let { channelId = it }
}
}
7 changes: 7 additions & 0 deletions android/src/main/java/io/agora/rtc/base/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ fun AgoraFacePositionInfo.toMap(): Map<String, Any?> {
)
}

fun AudioFileInfo.toMap(): Map<String, Any?> {
return hashMapOf(
"filePath" to filePath,
"durationMs" to durationMs
)
}

fun Array<out AgoraFacePositionInfo>.toMapList(): List<Map<String, Any?>> {
return List(size) { this[it].toMap() }
}
Expand Down
104 changes: 84 additions & 20 deletions android/src/main/java/io/agora/rtc/base/RtcEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class IRtcEngine {
fun setLocalAccessPoint(params: Map<String, *>, callback: Callback)

fun enableVirtualBackground(params: Map<String, *>, callback: Callback)

fun takeSnapshot(params: Map<String, *>, callback: Callback)
}

interface RtcUserInfoInterface {
Expand Down Expand Up @@ -161,11 +163,21 @@ class IRtcEngine {

fun getAudioMixingDuration(params: Map<String, *>, callback: Callback)

fun getAudioFileInfo(params: Map<String, *>, callback: Callback)

fun getAudioMixingCurrentPosition(callback: Callback)

fun setAudioMixingPosition(params: Map<String, *>, callback: Callback)

fun setAudioMixingPitch(params: Map<String, *>, callback: Callback)

fun setAudioMixingPlaybackSpeed(params: Map<String, *>, callback: Callback)

fun getAudioTrackCount(callback: Callback)

fun selectAudioTrack(params: Map<String, *>, callback: Callback)

fun setAudioMixingDualMonoMode(params: Map<String, *>, callback: Callback)
}

interface RtcAudioEffectInterface {
Expand Down Expand Up @@ -371,31 +383,51 @@ class IRtcEngine {
}
}

class RtcEngineManager(
private val emit: (methodName: String, data: Map<String, Any?>?) -> Unit
open class RtcEngineFactory {
open fun create(
params: Map<String, *>,
rtcEngineEventHandler: RtcEngineEventHandler
): RtcEngine? {
val engine = RtcEngineEx.create(mapToRtcEngineConfig(params["config"] as Map<*, *>).apply {
mContext = params["context"] as Context
mEventHandler = rtcEngineEventHandler
})

return engine
}
}

open class RtcEngineManager(
private val emit: (methodName: String, data: Map<String, Any?>?) -> Unit,
private val rtcEngineFactory: RtcEngineFactory = RtcEngineFactory()
) : IRtcEngine.RtcEngineInterface {
var engine: RtcEngine? = null
private set
private var mediaObserver: MediaObserver? = null

fun release() {
RtcEngine.destroy()
engine = null
if (engine != null) {
RtcEngine.destroy()
engine = null
}
mediaObserver = null
}

override fun create(params: Map<String, *>, callback: Callback) {
engine = RtcEngineEx.create(mapToRtcEngineConfig(params["config"] as Map<*, *>).apply {
mContext = params["context"] as Context
mEventHandler = RtcEngineEventHandler { methodName, data ->
emit(methodName, data)
}
engine = rtcEngineFactory.create(params, RtcEngineEventHandler { methodName, data ->
emit(methodName, data)
})
callback.code((engine as RtcEngineEx).setAppType((params["appType"] as Number).toInt()))
callback.code((engine as RtcEngineEx).setAppType((params["appType"] as Number).toInt())) {
RtcEngineRegistry.instance.onRtcEngineCreated(engine)
it
}
}

override fun destroy(callback: Callback) {
callback.resolve(engine) { release() }
callback.resolve(engine) {
release()
RtcEngineRegistry.instance.onRtcEngineDestroyed()
}
}

override fun setChannelProfile(params: Map<String, *>, callback: Callback) {
Expand Down Expand Up @@ -553,6 +585,16 @@ class RtcEngineManager(
)
}

override fun takeSnapshot(params: Map<String, *>, callback: Callback) {
callback.code(
engine?.takeSnapshot(
params["channel"] as String,
(params["uid"] as Number).toNativeUInt(),
params["filePath"] as String
)
)
}

override fun registerLocalUserAccount(params: Map<String, *>, callback: Callback) {
callback.code(
engine?.registerLocalUserAccount(
Expand Down Expand Up @@ -802,13 +844,13 @@ class RtcEngineManager(
}

override fun getAudioMixingDuration(params: Map<String, *>, callback: Callback) {
(params["filePath"] as? String)?.let { file ->
callback.code(engine?.getAudioMixingDuration(file)) { it }
return@getAudioMixingDuration
}
callback.code(engine?.audioMixingDuration) { it }
}

override fun getAudioFileInfo(params: Map<String, *>, callback: Callback) {
callback.code(engine?.getAudioFileInfo(params["filePath"] as String))
}

override fun getAudioMixingCurrentPosition(callback: Callback) {
callback.code(engine?.audioMixingCurrentPosition) { it }
}
Expand All @@ -821,6 +863,22 @@ class RtcEngineManager(
callback.code(engine?.setAudioMixingPitch((params["pitch"] as Number).toInt()))
}

override fun setAudioMixingPlaybackSpeed(params: Map<String, *>, callback: Callback) {
callback.code(engine?.setAudioMixingPlaybackSpeed((params["speed"] as Number).toInt()))
}

override fun getAudioTrackCount(callback: Callback) {
callback.code(engine?.audioTrackCount) { it }
}

override fun selectAudioTrack(params: Map<String, *>, callback: Callback) {
callback.code(engine?.selectAudioTrack((params["index"] as Number).toInt()))
}

override fun setAudioMixingDualMonoMode(params: Map<String, *>, callback: Callback) {
callback.code(engine?.setAudioMixingDualMonoMode((params["mode"] as Number).toInt()))
}

override fun getEffectsVolume(callback: Callback) {
callback.resolve(engine) { it.audioEffectManager.effectsVolume }
}
Expand Down Expand Up @@ -1033,13 +1091,11 @@ class RtcEngineManager(
}

override fun pauseAllChannelMediaRelay(callback: Callback) {
callback.code(-Constants.ERR_NOT_SUPPORTED)
// callback.code(engine?.pauseAllChannelMediaRelay())
callback.code(engine?.pauseAllChannelMediaRelay())
}

override fun resumeAllChannelMediaRelay(callback: Callback) {
callback.code(-Constants.ERR_NOT_SUPPORTED)
// callback.code(engine?.resumeAllChannelMediaRelay())
callback.code(engine?.resumeAllChannelMediaRelay())
}

override fun setDefaultAudioRoutetoSpeakerphone(params: Map<String, *>, callback: Callback) {
Expand Down Expand Up @@ -1097,7 +1153,15 @@ class RtcEngineManager(
}

override fun startEchoTest(params: Map<String, *>, callback: Callback) {
callback.code(engine?.startEchoTest((params["intervalInSeconds"] as Number).toInt()))
(params["intervalInSeconds"] as? Number)?.let { intervalInSeconds ->
callback.code(engine?.startEchoTest(intervalInSeconds.toInt()))
return@startEchoTest
}
(params["config"] as? Map<*, *>)?.let { config ->
callback.code(engine?.startEchoTest(mapToEchoTestConfiguration(config)))
return@startEchoTest
}
callback.code(engine?.startEchoTest())
}

override fun stopEchoTest(callback: Callback) {
Expand Down
29 changes: 28 additions & 1 deletion android/src/main/java/io/agora/rtc/base/RtcEngineEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class RtcEngineEvents {
const val LocalVideoStateChanged = "LocalVideoStateChanged"
const val RemoteAudioStateChanged = "RemoteAudioStateChanged"
const val LocalAudioStateChanged = "LocalAudioStateChanged"
const val RequestAudioFileInfo = "RequestAudioFileInfo"
const val LocalPublishFallbackToAudioOnly = "LocalPublishFallbackToAudioOnly"
const val RemoteSubscribeFallbackToAudioOnly = "RemoteSubscribeFallbackToAudioOnly"
const val AudioRouteChanged = "AudioRouteChanged"
Expand Down Expand Up @@ -87,6 +88,7 @@ class RtcEngineEvents {
const val UserSuperResolutionEnabled = "UserSuperResolutionEnabled"
const val UploadLogResult = "UploadLogResult"
const val VirtualBackgroundSourceEnabled = "VirtualBackgroundSourceEnabled"
const val SnapshotTaken = "SnapshotTaken"

fun toMap(): Map<String, String> {
return hashMapOf(
Expand Down Expand Up @@ -116,6 +118,7 @@ class RtcEngineEvents {
"LocalVideoStateChanged" to LocalVideoStateChanged,
"RemoteAudioStateChanged" to RemoteAudioStateChanged,
"LocalAudioStateChanged" to LocalAudioStateChanged,
"RequestAudioFileInfo" to RequestAudioFileInfo,
"LocalPublishFallbackToAudioOnly" to LocalPublishFallbackToAudioOnly,
"RemoteSubscribeFallbackToAudioOnly" to RemoteSubscribeFallbackToAudioOnly,
"AudioRouteChanged" to AudioRouteChanged,
Expand Down Expand Up @@ -169,7 +172,8 @@ class RtcEngineEvents {
"RtmpStreamingEvent" to RtmpStreamingEvent,
"UserSuperResolutionEnabled" to UserSuperResolutionEnabled,
"UploadLogResult" to UploadLogResult,
"VirtualBackgroundSourceEnabled" to VirtualBackgroundSourceEnabled
"VirtualBackgroundSourceEnabled" to VirtualBackgroundSourceEnabled,
"SnapshotTaken" to SnapshotTaken
)
}
}
Expand Down Expand Up @@ -325,6 +329,10 @@ class RtcEngineEventHandler(
callback(RtcEngineEvents.LocalAudioStateChanged, state, error)
}

override fun onRequestAudioFileInfo(info: AudioFileInfo?, error: Int) {
callback(RtcEngineEvents.RequestAudioFileInfo, info?.toMap(), error)
}

override fun onLocalPublishFallbackToAudioOnly(isFallbackOrRecover: Boolean) {
callback(RtcEngineEvents.LocalPublishFallbackToAudioOnly, isFallbackOrRecover)
}
Expand Down Expand Up @@ -688,4 +696,23 @@ class RtcEngineEventHandler(
) {
callback(RtcEngineEvents.VirtualBackgroundSourceEnabled, enabled, reason)
}

override fun onSnapshotTaken(
channel: String?,
uid: Int,
filePath: String?,
width: Int,
height: Int,
errCode: Int
) {
callback(
RtcEngineEvents.SnapshotTaken,
channel,
uid.toUInt().toLong(),
filePath,
width,
height,
errCode
)
}
}
47 changes: 47 additions & 0 deletions android/src/main/java/io/agora/rtc/base/RtcEnginePlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package io.agora.rtc.base

import io.agora.rtc.RtcEngine

/**
* A [RtcEnginePlugin] allows developers to interact with the [RtcEngine] which created from flutter
* side.
*/
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
*/
fun onRtcEngineCreated(rtcEngine: RtcEngine?)

/**
* This callback will be called when the [RtcEngine.destroy](https://docs.agora.io/cn/Video/API%20Reference/flutter/v4.0.7/rtc_channel/RtcChannel/destroy.html)
* function is called from flutter.
*/
fun onRtcEngineDestroyed()

companion object Registrant {
/**
* Register a [RtcEnginePlugin]. The [plugin] will be called when the [RtcEngine] is created from
* flutter side.
*/
fun register(plugin: RtcEnginePlugin) {
RtcEngineRegistry.instance.add(plugin = plugin)
}

/**
* Unregister a previously registered [RtcEnginePlugin].
*/
fun unregister(plugin: RtcEnginePlugin) {
RtcEngineRegistry.instance.remove(pluginClass = plugin.javaClass)
}
}
}


Loading

0 comments on commit dddce67

Please sign in to comment.