Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed Sep 28, 2020
1 parent 9fa3009 commit c82a9e1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
7 changes: 7 additions & 0 deletions Annotations.java
Original file line number Diff line number Diff line change
Expand Up @@ -789,4 +789,11 @@ public class Annotations {
@Retention(RetentionPolicy.SOURCE)
public @interface AgoraStreamPublishState {
}

@IntDef({
Constants.RTMP_STREAMING_EVENT_FAILED_LOAD_IMAGE,
})
@Retention(RetentionPolicy.SOURCE)
public @interface AgoraRtmpStreamingEvent {
}
}
13 changes: 9 additions & 4 deletions Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ fun LocalAudioStats.toMap(): Map<String, Any?> {
return hashMapOf(
"numChannels" to numChannels,
"sentSampleRate" to sentSampleRate,
"sentBitrate" to sentBitrate
"sentBitrate" to sentBitrate,
"txPacketLossRate" to txPacketLossRate
)
}

Expand Down Expand Up @@ -68,7 +69,8 @@ fun RemoteAudioStats.toMap(): Map<String, Any?> {
"receivedBitrate" to receivedBitrate,
"totalFrozenTime" to totalFrozenTime,
"frozenRate" to frozenRate,
"totalActiveTime" to totalActiveTime
"totalActiveTime" to totalActiveTime,
"publishDuration" to publishDuration
)
}

Expand All @@ -85,7 +87,9 @@ fun LocalVideoStats.toMap(): Map<String, Any?> {
"encodedFrameWidth" to encodedFrameWidth,
"encodedFrameHeight" to encodedFrameHeight,
"encodedFrameCount" to encodedFrameCount,
"codecType" to codecType
"codecType" to codecType,
"txPacketLossRate" to txPacketLossRate,
"captureFrameRate" to captureFrameRate
)
}

Expand All @@ -102,7 +106,8 @@ fun RemoteVideoStats.toMap(): Map<String, Any?> {
"rxStreamType" to rxStreamType,
"totalFrozenTime" to totalFrozenTime,
"frozenRate" to frozenRate,
"totalActiveTime" to totalActiveTime
"totalActiveTime" to totalActiveTime,
"publishDuration" to publishDuration
)
}

Expand Down
14 changes: 9 additions & 5 deletions RtcChannel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import io.agora.rtc.RtcEngine
import io.agora.rtc.internal.EncryptionConfig
import java.util.*

class RtcChannelInterface {
class IRtcChannel {
interface RtcChannelInterface : RtcAudioInterface, RtcVideoInterface, RtcVoicePositionInterface,
RtcPublishStreamInterface, RtcMediaRelayInterface, RtcDualStreamInterface,
RtcFallbackInterface, RtcMediaMetadataInterface, RtcEncryptionInterface,
Expand Down Expand Up @@ -116,7 +116,7 @@ class RtcChannelInterface {

class RtcChannelManager(
private val emit: (methodName: String, data: Map<String, Any?>?) -> Unit
) : RtcChannelInterface.RtcChannelInterface {
) : IRtcChannel.RtcChannelInterface {
private val rtcChannelMap = Collections.synchronizedMap(mutableMapOf<String, RtcChannel>())
private val mediaObserverMap = Collections.synchronizedMap(mutableMapOf<String, MediaObserver>())

Expand Down Expand Up @@ -315,12 +315,16 @@ class RtcChannelManager(
override fun createDataStream(params: Map<String, *>, callback: Callback) {
var code = -Constants.ERR_NOT_INITIALIZED
this[params["channelId"] as String]?.let {
code= it.createDataStream(reliable, ordered)
code = it.createDataStream(params["reliable"] as Boolean, params["ordered"] as Boolean)
}
callback.code(manager.createDataStream(channelId, reliable, ordered)) { it }
callback.code(code) { it }
}

override fun sendStreamMessage(params: Map<String, *>, callback: Callback) {
callback.code(manager.sendStreamMessage(channelId, streamId, message))
var code = -Constants.ERR_NOT_INITIALIZED
this[params["channelId"] as String]?.let {
code = it.sendStreamMessage((params["streamId"] as Number).toInt(), (params["message"] as String).toByteArray())
}
callback.code(code)
}
}
14 changes: 7 additions & 7 deletions RtcChannelEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ class RtcChannelEventHandler(
}

override fun onJoinChannelSuccess(rtcChannel: RtcChannel?, uid: Int, elapsed: Int) {
callback(RtcChannelEvents.JoinChannelSuccess, rtcChannel, rtcChannel.channelId(), uid, elapsed)
callback(RtcChannelEvents.JoinChannelSuccess, rtcChannel, rtcChannel?.channelId(), uid, elapsed)
}

override fun onRejoinChannelSuccess(rtcChannel: RtcChannel?, uid: Int, elapsed: Int) {
callback(RtcChannelEvents.RejoinChannelSuccess, rtcChannel, rtcChannel.channelId(), uid, elapsed)
callback(RtcChannelEvents.RejoinChannelSuccess, rtcChannel, rtcChannel?.channelId(), uid, elapsed)
}

override fun onLeaveChannel(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RtcStats?) {
Expand Down Expand Up @@ -218,22 +218,22 @@ class RtcChannelEventHandler(
}

override fun onAudioPublishStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraStreamPublishState oldState: Int, @Annotations.AgoraStreamPublishState newState: Int, elapseSinceLastState: Int) {
callback(RtcChannelEvents.AudioPublishStateChanged, rtcChannel, rtcChannel.channelId(), oldState, newState, elapseSinceLastState)
callback(RtcChannelEvents.AudioPublishStateChanged, rtcChannel, rtcChannel?.channelId(), oldState, newState, elapseSinceLastState)
}

override fun onVideoPublishStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraStreamPublishState oldState: Int, @Annotations.AgoraStreamPublishState newState: Int, elapseSinceLastState: Int) {
callback(RtcChannelEvents.VideoPublishStateChanged, rtcChannel, rtcChannel.channelId(), oldState, newState, elapseSinceLastState)
callback(RtcChannelEvents.VideoPublishStateChanged, rtcChannel, rtcChannel?.channelId(), oldState, newState, elapseSinceLastState)
}

override fun onAudioSubscribeStateChanged(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraStreamSubscribeState oldState: Int, @Annotations.AgoraStreamSubscribeState newState: Int, elapseSinceLastState: Int) {
callback(RtcChannelEvents.AudioSubscribeStateChanged, rtcChannel, rtcChannel.channelId(), uid, oldState, newState, elapseSinceLastState)
callback(RtcChannelEvents.AudioSubscribeStateChanged, rtcChannel, rtcChannel?.channelId(), uid, oldState, newState, elapseSinceLastState)
}

override fun onVideoSubscribeStateChanged(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraStreamSubscribeState oldState: Int, @Annotations.AgoraStreamSubscribeState newState: Int, elapseSinceLastState: Int) {
callback(RtcChannelEvents.VideoSubscribeStateChanged, rtcChannel, rtcChannel.channelId(), uid, oldState, newState, elapseSinceLastState)
callback(RtcChannelEvents.VideoSubscribeStateChanged, rtcChannel, rtcChannel?.channelId(), uid, oldState, newState, elapseSinceLastState)
}

override fun onRtmpStreamingEvent(rtcChannel: RtcChannel?, url: String?, errCode: Int) {
override fun onRtmpStreamingEvent(rtcChannel: RtcChannel?, url: String?, @Annotations.AgoraRtmpStreamingEvent errCode: Int) {
callback(RtcChannelEvents.RtmpStreamingEvent, rtcChannel, url, errCode)
}
}
4 changes: 2 additions & 2 deletions RtcEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import io.agora.rtc.*
import io.agora.rtc.internal.EncryptionConfig
import io.agora.rtc.models.UserInfo

class RtcEngineInterface {
class IRtcEngine {
interface RtcEngineInterface : RtcUserInfoInterface, RtcAudioInterface, RtcVideoInterface,
RtcAudioMixingInterface, RtcAudioEffectInterface, RtcVoiceChangerInterface,
RtcVoicePositionInterface, RtcPublishStreamInterface, RtcMediaRelayInterface,
Expand Down Expand Up @@ -316,7 +316,7 @@ class RtcEngineInterface {

class RtcEngineManager(
private val emit: (methodName: String, data: Map<String, Any?>?) -> Unit
) : RtcEngineInterface.RtcEngineInterface {
) : IRtcEngine.RtcEngineInterface {
var engine: RtcEngine? = null
private set
private var mediaObserver: MediaObserver? = null
Expand Down
2 changes: 1 addition & 1 deletion RtcEngineEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ class RtcEngineEventHandler(
callback(RtcEngineEvents.VideoSubscribeStateChanged, channel, uid, oldState, newState, elapseSinceLastState)
}

override fun onRtmpStreamingEvent(url: String?, error: Int) {
override fun onRtmpStreamingEvent(url: String?, @Annotations.AgoraRtmpStreamingEvent error: Int) {
callback(RtcEngineEvents.RtmpStreamingEvent, url, error)
}
}

0 comments on commit c82a9e1

Please sign in to comment.