Skip to content

Commit

Permalink
Squashed 'android/src/main/java/io/agora/rtc/base/' changes from 382f…
Browse files Browse the repository at this point in the history
…858..3aed6ce

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

git-subtree-dir: android/src/main/java/io/agora/rtc/base
git-subtree-split: 3aed6cebfdd5dd14504e99c226a2c69b551effa3
  • Loading branch information
LichKing-2234 committed May 17, 2021
1 parent b95d418 commit 19b9b1d
Show file tree
Hide file tree
Showing 10 changed files with 1,022 additions and 230 deletions.
23 changes: 16 additions & 7 deletions Annotations.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,27 @@ public class Annotations {
}

@IntDef({
Constants.MEDIA_ENGINE_AUDIO_ERROR_MIXING_OPEN,
Constants.MEDIA_ENGINE_AUDIO_ERROR_MIXING_TOO_FREQUENT,
Constants.MEDIA_ENGINE_AUDIO_EVENT_MIXING_INTERRUPTED_EOF,
AgoraAudioMixingErrorCode.MEDIA_ENGINE_AUDIO_ERROR_OK,
})
@Retention(RetentionPolicy.SOURCE)
public @interface AgoraAudioMixingErrorCode {
Constants.AUDIO_MIXING_REASON_CAN_NOT_OPEN,
Constants.AUDIO_MIXING_REASON_TOO_FREQUENT_CALL,
Constants.AUDIO_MIXING_REASON_INTERRUPTED_EOF,
Constants.AUDIO_MIXING_REASON_STARTED_BY_USER,
Constants.AUDIO_MIXING_REASON_ONE_LOOP_COMPLETED,
Constants.AUDIO_MIXING_REASON_START_NEW_LOOP,
Constants.AUDIO_MIXING_REASON_ALL_LOOPS_COMPLETED,
Constants.AUDIO_MIXING_REASON_STOPPED_BY_USER,
Constants.AUDIO_MIXING_REASON_PAUSED_BY_USER,
Constants.AUDIO_MIXING_REASON_RESUMED_BY_USER,
AgoraAudioMixingReason.MEDIA_ENGINE_AUDIO_ERROR_OK,
})
@Retention(RetentionPolicy.SOURCE)
public @interface AgoraAudioMixingReason {
int MEDIA_ENGINE_AUDIO_ERROR_OK = 0;
}

@IntDef({
Constants.MEDIA_ENGINE_AUDIO_EVENT_MIXING_PLAY,
Constants.MEDIA_ENGINE_AUDIO_EVENT_MIXING_PAUSED,
Constants.MEDIA_ENGINE_AUDIO_EVENT_MIXING_RESTART,
Constants.MEDIA_ENGINE_AUDIO_EVENT_MIXING_STOPPED,
Constants.MEDIA_ENGINE_AUDIO_EVENT_MIXING_ERROR,
})
Expand Down Expand Up @@ -534,6 +542,7 @@ public class Annotations {
Constants.LOCAL_VIDEO_STREAM_ERROR_DEVICE_BUSY,
Constants.LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE,
Constants.LOCAL_VIDEO_STREAM_ERROR_ENCODE_FAILURE,
Constants.LOCAL_VIDEO_STREAM_ERROR_DEVICE_NOT_FOUND
})
@Retention(RetentionPolicy.SOURCE)
public @interface AgoraLocalVideoStreamError {
Expand Down
51 changes: 42 additions & 9 deletions BeanCovertor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package io.agora.rtc.base

import android.graphics.Color
import io.agora.rtc.RtcEngineConfig
import io.agora.rtc.audio.AgoraRhythmPlayerConfig
import io.agora.rtc.audio.AudioRecordingConfiguration
import io.agora.rtc.internal.EncryptionConfig
import io.agora.rtc.internal.LastmileProbeConfig
import io.agora.rtc.live.LiveInjectStreamConfig
Expand All @@ -27,7 +29,9 @@ fun mapToVideoEncoderConfiguration(map: Map<*, *>): VideoEncoderConfiguration {
(map["bitrate"] as? Number)?.let { bitrate = it.toInt() }
(map["minBitrate"] as? Number)?.let { minBitrate = it.toInt() }
(map["orientationMode"] as? Number)?.let { orientationMode = intToOrientationMode(it.toInt()) }
(map["degradationPrefer"] as? Number)?.let { degradationPrefer = intToDegradationPreference(it.toInt()) }
(map["degradationPrefer"] as? Number)?.let {
degradationPrefer = intToDegradationPreference(it.toInt())
}
(map["mirrorMode"] as? Number)?.let { mirrorMode = it.toInt() }
}
}
Expand All @@ -53,7 +57,7 @@ fun mapToAgoraImage(map: Map<*, *>): AgoraImage {

fun mapToTranscodingUser(map: Map<*, *>): TranscodingUser {
return TranscodingUser().apply {
(map["uid"] as? Number)?.let { uid = it.toInt() }
(map["uid"] as? Number)?.let { uid = it.toNativeUInt() }
(map["x"] as? Number)?.let { x = it.toInt() }
(map["y"] as? Number)?.let { y = it.toInt() }
(map["width"] as? Number)?.let { width = it.toInt() }
Expand Down Expand Up @@ -82,11 +86,17 @@ fun mapToLiveTranscoding(map: Map<*, *>): LiveTranscoding {
(map["videoGop"] as? Number)?.let { videoGop = it.toInt() }
(map["watermark"] as? Map<*, *>)?.let { watermark = mapToAgoraImage(it) }
(map["backgroundImage"] as? Map<*, *>)?.let { backgroundImage = mapToAgoraImage(it) }
(map["audioSampleRate"] as? Number)?.let { audioSampleRate = intToLiveTranscodingAudioSampleRate(it.toInt()) }
(map["audioSampleRate"] as? Number)?.let {
audioSampleRate = intToLiveTranscodingAudioSampleRate(it.toInt())
}
(map["audioBitrate"] as? Number)?.let { audioBitrate = it.toInt() }
(map["audioChannels"] as? Number)?.let { audioChannels = it.toInt() }
(map["audioCodecProfile"] as? Number)?.let { audioCodecProfile = intToAudioCodecProfile(it.toInt()) }
(map["videoCodecProfile"] as? Number)?.let { videoCodecProfile = intToVideoCodecProfile(it.toInt()) }
(map["audioCodecProfile"] as? Number)?.let {
audioCodecProfile = intToAudioCodecProfile(it.toInt())
}
(map["videoCodecProfile"] as? Number)?.let {
videoCodecProfile = intToVideoCodecProfile(it.toInt())
}
(map["backgroundColor"] as? Map<*, *>)?.let { backgroundColor = mapToColor(it) }
(map["userConfigExtraInfo"] as? String)?.let { userConfigExtraInfo = it }
(map["transcodingUsers"] as? List<*>)?.let { list ->
Expand All @@ -103,7 +113,7 @@ fun mapToChannelMediaInfo(map: Map<*, *>): ChannelMediaInfo {
return ChannelMediaInfo(
map["channelName"] as? String,
map["token"] as? String,
(map["uid"] as Number).toInt()
(map["uid"] as Number).toNativeUInt()
)
}

Expand Down Expand Up @@ -142,8 +152,12 @@ fun mapToRectangle(map: Map<*, *>): WatermarkOptions.Rectangle {
fun mapToWatermarkOptions(map: Map<*, *>): WatermarkOptions {
return WatermarkOptions().apply {
(map["visibleInPreview"] as? Boolean)?.let { visibleInPreview = it }
(map["positionInLandscapeMode"] as? Map<*, *>)?.let { positionInLandscapeMode = mapToRectangle(it) }
(map["positionInPortraitMode"] as? Map<*, *>)?.let { positionInPortraitMode = mapToRectangle(it) }
(map["positionInLandscapeMode"] as? Map<*, *>)?.let {
positionInLandscapeMode = mapToRectangle(it)
}
(map["positionInPortraitMode"] as? Map<*, *>)?.let {
positionInPortraitMode = mapToRectangle(it)
}
}
}

Expand All @@ -154,12 +168,22 @@ fun mapToLiveInjectStreamConfig(map: Map<*, *>): LiveInjectStreamConfig {
(map["videoGop"] as? Number)?.let { videoGop = it.toInt() }
(map["videoFramerate"] as? Number)?.let { videoFramerate = it.toInt() }
(map["videoBitrate"] as? Number)?.let { videoBitrate = it.toInt() }
(map["audioSampleRate"] as? Number)?.let { audioSampleRate = intToLiveInjectStreamConfigAudioSampleRate(it.toInt()) }
(map["audioSampleRate"] as? Number)?.let {
audioSampleRate = intToLiveInjectStreamConfigAudioSampleRate(it.toInt())
}
(map["audioBitrate"] as? Number)?.let { audioBitrate = it.toInt() }
(map["audioChannels"] as? Number)?.let { audioChannels = it.toInt() }
}
}

fun mapToRhythmPlayerConfig(map: Map<*, *>): AgoraRhythmPlayerConfig {
return AgoraRhythmPlayerConfig().apply {
(map["beatsPerMeasure"] as? Number)?.let { beatsPerMeasure = it.toInt() }
(map["beatsPerMinute"] as? Number)?.let { beatsPerMinute = it.toInt() }
(map["publish"] as? Boolean)?.let { publish = it }
}
}

fun mapToCameraCapturerConfiguration(map: Map<*, *>): CameraCapturerConfiguration {
return CameraCapturerConfiguration(
intToCapturerOutputPreference((map["preference"] as Number).toInt()),
Expand All @@ -186,6 +210,15 @@ fun mapToRtcEngineConfig(map: Map<*, *>): RtcEngineConfig {
}
}

fun mapToAudioRecordingConfiguration(map: Map<*, *>): AudioRecordingConfiguration {
return AudioRecordingConfiguration().apply {
(map["filePath"] as? String)?.let { filePath = it }
(map["recordingQuality"] as? Number)?.let { recordingQuality = it.toInt() }
(map["recordingPosition"] as? Number)?.let { recordingPosition = it.toInt() }
(map["recordingQuality"] as? Number)?.let { recordingSampleRate = it.toInt() }
}
}

fun mapToEncryptionConfig(map: Map<*, *>): EncryptionConfig {
return EncryptionConfig().apply {
(map["encryptionMode"] as? Number)?.let { encryptionMode = intToEncryptionMode(it.toInt()) }
Expand Down
13 changes: 9 additions & 4 deletions Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import io.agora.rtc.models.UserInfo

fun UserInfo.toMap(): Map<String, Any?> {
return hashMapOf(
"uid" to uid,
"uid" to uid.toUInt().toLong(),
"userAccount" to userAccount
)
}
Expand Down Expand Up @@ -59,7 +59,7 @@ fun Rect.toMap(): Map<String, Any?> {

fun RemoteAudioStats.toMap(): Map<String, Any?> {
return hashMapOf(
"uid" to uid,
"uid" to uid.toUInt().toLong(),
"quality" to quality,
"networkTransportDelay" to networkTransportDelay,
"jitterBufferDelay" to jitterBufferDelay,
Expand Down Expand Up @@ -99,7 +99,7 @@ fun LocalVideoStats.toMap(): Map<String, Any?> {

fun RemoteVideoStats.toMap(): Map<String, Any?> {
return hashMapOf(
"uid" to uid,
"uid" to uid.toUInt().toLong(),
"delay" to delay,
"width" to width,
"height" to height,
Expand All @@ -117,7 +117,7 @@ fun RemoteVideoStats.toMap(): Map<String, Any?> {

fun AudioVolumeInfo.toMap(): Map<String, Any?> {
return hashMapOf(
"uid" to uid,
"uid" to uid.toUInt().toLong(),
"volume" to volume,
"vad" to vad,
"channelId" to channelId
Expand Down Expand Up @@ -158,3 +158,8 @@ fun AgoraFacePositionInfo.toMap(): Map<String, Any?> {
fun Array<out AgoraFacePositionInfo>.toMapList(): List<Map<String, Any?>> {
return List(size) { this[it].toMap() }
}

@ExperimentalUnsignedTypes
internal fun Number.toNativeUInt(): Int {
return toLong().toUInt().toInt()
}
8 changes: 5 additions & 3 deletions MediaObserver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ class MediaObserver(
}

override fun onMetadataReceived(buffer: ByteArray, uid: Int, timeStampMs: Long) {
emit(hashMapOf(
"data" to arrayListOf(String(buffer), uid, timeStampMs)
))
emit(
hashMapOf(
"data" to arrayListOf(String(buffer), uid.toUInt().toLong(), timeStampMs)
)
)
}
}
Loading

0 comments on commit 19b9b1d

Please sign in to comment.