diff --git a/android/src/main/java/com/syan/agora/AgoraManager.java b/android/src/main/java/com/syan/agora/AgoraManager.java index 3323f9d2f..40cde5f99 100755 --- a/android/src/main/java/com/syan/agora/AgoraManager.java +++ b/android/src/main/java/com/syan/agora/AgoraManager.java @@ -172,14 +172,6 @@ public int joinChannel(ReadableMap options) { return mRtcEngine.joinChannel(token, channelName, optionalInfo, uid); } -// public int joinChannelWithToken(ReadableMap options) { -// String token = options.getString("token"); -// String channel = options.getString("channel"); -// String optionalInfo = options.getString("optionalInfo"); -// int uid = options.getInt("uid"); -// return mRtcEngine.joinChannel(token, channel, optionalInfo, uid); -// } - public int enableLastmileTest() { return mRtcEngine.enableLastmileTest(); } diff --git a/android/src/main/java/com/syan/agora/AgoraModule.java b/android/src/main/java/com/syan/agora/AgoraModule.java index 997637eae..04b2ab552 100644 --- a/android/src/main/java/com/syan/agora/AgoraModule.java +++ b/android/src/main/java/com/syan/agora/AgoraModule.java @@ -257,6 +257,69 @@ public Map getConstants() { return constants; } + private final static String AGWarning = "warning"; + private final static String AGError = "error"; + private final static String AGApiCallExecute = "apiCallExecute"; + private final static String AGJoinChannelSuccess = "joinChannelSuccess"; + private final static String AGRejoinChannelSuccess = "rejoinChannelSuccess"; + private final static String AGLeaveChannel = "leaveChannel"; + private final static String AGClientRoleChanged = "clientRoleChanged"; + private final static String AGUserJoined = "userJoined"; + private final static String AGUserOffline = "userOffline"; + private final static String AGConnectionStateChanged = "connectionStateChanged"; + private final static String AGConnectionLost = "connectionLost"; + private final static String AGTokenPrivilegeWillExpire = "tokenPrivilegeWillExpire"; + private final static String AGRequestToken = "requestToken"; + + private final static String AGMicrophoneEnabled = "microphoneEnabled"; + private final static String AGAudioVolumeIndication = "audioVolumeIndication"; + private final static String AGActiveSpeaker = "activeSpeaker"; + private final static String AGFirstLocalAudioFrame = "firstLocalAudioFrame"; + private final static String AGFirstRemoteAudioFrame = "firstRemoteAudioFrame"; + private final static String AGVideoStopped = "videoStopped"; + private final static String AGFirstLocalVideoFrame = "firstLocalVideoFrame"; + private final static String AGFirstRemoteVideoDecoded = "firstRemoteVideoDecoded"; + private final static String AGFirstRemoteVideoFrame = "firstRemoteVideoFrame"; + private final static String AGUserMuteAudio = "userMuteAudio"; + private final static String AGUserMuteVideo = "userMuteVideo"; + private final static String AGUserEnableVideo = "userEnableVideo"; + private final static String AGUserEnableLocalVideo = "userEnableLocalVideo"; + private final static String AGVideoSizeChanged = "videoSizeChanged"; + private final static String AGRemoteVideoStateChanged = "remoteVideoStateChanged"; + private final static String AGLocalPublishFallbackToAudioOnly = "localPublishFallbackToAudioOnly"; + private final static String AGRemoteSubscribeFallbackToAudioOnly = "remoteSubscribeFallbackToAudioOnly"; + + private final static String AGAudioRouteChanged = "audioRouteChanged"; + private final static String AGCameraReady = "cameraReady"; + private final static String AGCameraFocusAreaChanged = "cameraFocusAreaChanged"; + private final static String AGCameraExposureAreaChanged = "cameraExposureAreaChanged"; + + private final static String AGRtcStats = "rtcStats"; + private final static String AGLastmileQuality = "lastmileQuality"; + private final static String AGNetworkQuality = "networkQuality"; + private final static String AGLocalVideoStats = "localVideoStats"; + private final static String AGRemoteVideoStats = "remoteVideoStats"; + private final static String AGRemoteAudioStats = "remoteAudioStats"; + private final static String AGAudioTransportStatsOfUid = "audioTransportStatsOfUid"; + private final static String AGVideoTransportStatsOfUid = "videoTransportStatsOfUid"; + + private final static String AGLocalAudioMixingFinish = "localAudioMixingFinish"; + private final static String AGRemoteAudioMixingStart = "remoteAudioMixingStart"; + private final static String AGRemoteAudioMixingFinish = "remoteAudioMixingFinish"; + private final static String AGAudioEffectFinish = "audioEffectFinish"; + + private final static String AGStreamPublished = "streamPublished"; + private final static String AGStreamUnpublish = "streamUnpublish"; + private final static String AGTranscodingUpdate = "transcodingUpdate"; + + private final static String AGStreamInjectedStatus = "streamInjectedStatus"; + + private final static String AGReceiveStreamMessage = "receiveStreamMessage"; + private final static String AGOccurStreamMessageError = "occurStreamMessageError"; + + private final static String AGMediaEngineLoaded = "mediaEngineLoaded"; + private final static String AGMediaEngineStartCall = "mediaEngineStartCall"; + private IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() { @Override @@ -267,6 +330,7 @@ public void run() { WritableMap map = Arguments.createMap(); map.putString("message", "AgoraWarning"); map.putInt("code", code); + sendEvent(getReactApplicationContext(), AGWarning, map); } }); } @@ -279,7 +343,25 @@ public void run() { WritableMap map = Arguments.createMap(); map.putString("message", "AgoraError"); map.putInt("code", code); - sendEvent(getReactApplicationContext(), "error", map); + sendEvent(getReactApplicationContext(), AGError, map); + } + }); + } + + @Override + public void onApiCallExecuted(final int code, final String api, final String result) { + runOnUiThread(new Runnable() { + @Override + public void run() { + WritableMap map = Arguments.createMap(); + map.putInt("error", code); + map.putString("api", api); + map.putString("result", result); + if (code != 0) { + sendEvent(getReactApplicationContext(), AGError, map); + } else { + sendEvent(getReactApplicationContext(), AGApiCallExecute, map); + } } }); } @@ -293,7 +375,7 @@ public void run() { map.putString("channel", channel); map.putInt("uid", uid); map.putInt("elapsed", elapsed); - sendEvent(getReactApplicationContext(), "joinChannelSuccess", map); + sendEvent(getReactApplicationContext(), AGJoinChannelSuccess, map); } }); } @@ -307,7 +389,7 @@ public void run() { map.putString("channel", channel); map.putInt("uid", uid); map.putInt("elapsed", elapsed); - sendEvent(getReactApplicationContext(), "reJoinChannelSuccess", map); + sendEvent(getReactApplicationContext(), AGRejoinChannelSuccess, map); } }); } @@ -318,23 +400,23 @@ public void onLeaveChannel(final RtcStats stats) { @Override public void run() { WritableMap statsMap = Arguments.createMap(); - statsMap.putInt("totalDuration", stats.totalDuration); + statsMap.putInt("duration", stats.totalDuration); statsMap.putInt("txBytes", stats.txBytes); statsMap.putInt("rxBytes", stats.rxBytes); - statsMap.putInt("txKBitRate", stats.txKBitRate); - statsMap.putInt("rxKBitRate", stats.rxKBitRate); + // statsMap.putInt("txKBitRate", stats.txKBitRate); + // statsMap.putInt("rxKBitRate", stats.rxKBitRate); statsMap.putInt("txAudioKBitRate", stats.txAudioKBitRate); statsMap.putInt("rxAudioKBitRate", stats.rxAudioKBitRate); statsMap.putInt("txVideoKBitRate", stats.txVideoKBitRate); statsMap.putInt("rxVideoKBitRate", stats.rxVideoKBitRate); - statsMap.putInt("users", stats.users); statsMap.putInt("lastmileDelay", stats.lastmileDelay); - statsMap.putDouble("cpuTotalUsage", stats.cpuTotalUsage); + statsMap.putInt("userCount", stats.users); statsMap.putDouble("cpuAppUsage", stats.cpuAppUsage); + statsMap.putDouble("cpuTotalUsage", stats.cpuTotalUsage); WritableMap map = Arguments.createMap(); map.putMap("stats", statsMap); - sendEvent(getReactApplicationContext(), "leaveChannel", map); + sendEvent(getReactApplicationContext(), AGLeaveChannel, map); } }); } @@ -347,7 +429,7 @@ public void run() { WritableMap map = Arguments.createMap(); map.putInt("oldRole", oldRole); map.putInt("newRole", newRole); - sendEvent(getReactApplicationContext(), "clientRoleChanged", map); + sendEvent(getReactApplicationContext(), AGClientRoleChanged, map); } }); } @@ -360,7 +442,7 @@ public void run() { WritableMap map = Arguments.createMap(); map.putInt("uid", uid); map.putInt("elapsed", elapsed); - sendEvent(getReactApplicationContext(), "userJoined", map); + sendEvent(getReactApplicationContext(), AGUserJoined, map); } }); } @@ -373,7 +455,7 @@ public void run() { WritableMap map = Arguments.createMap(); map.putInt("uid", uid); map.putInt("reason", reason); - sendEvent(getReactApplicationContext(), "userOffline", map); + sendEvent(getReactApplicationContext(), AGUserOffline, map); } }); } @@ -386,7 +468,7 @@ public void run() { WritableMap map = Arguments.createMap(); map.putInt("state", state); map.putInt("reason", reason); - sendEvent(getReactApplicationContext(), "connectionStateChanged", map); + sendEvent(getReactApplicationContext(), AGConnectionStateChanged, map); } }); } @@ -399,23 +481,7 @@ public void onConnectionLost() { public void run() { WritableMap map = Arguments.createMap(); map.putString("message", "connectionLost"); - sendEvent(getReactApplicationContext(), "connectionLost", map); - } - }); - } - - @Override - public void onApiCallExecuted(final int code, final String api, final String result) { - runOnUiThread(new Runnable() { - @Override - public void run() { - if (code != 0) { - WritableMap map = Arguments.createMap(); - map.putInt("error", code); - map.putString("api", api); - map.putString("result", result); - sendEvent(getReactApplicationContext(), "apiCallExecuted", map); - } + sendEvent(getReactApplicationContext(), AGConnectionLost, map); } }); } @@ -427,7 +493,7 @@ public void onTokenPrivilegeWillExpire(final String token) { public void run() { WritableMap map = Arguments.createMap(); map.putString("token", token); - sendEvent(getReactApplicationContext(), "tokenPrivilegeWillExpire", map); + sendEvent(getReactApplicationContext(), AGTokenPrivilegeWillExpire, map); } }); } @@ -439,7 +505,7 @@ public void onRequestToken() { public void run() { WritableMap map = Arguments.createMap(); map.putString("message", "RequestToken"); - sendEvent(getReactApplicationContext(), "requestToken", map); + sendEvent(getReactApplicationContext(), AGRequestToken, map); } }); } @@ -451,7 +517,7 @@ public void onMicrophoneEnabled(final boolean enabled) { public void run() { WritableMap map = Arguments.createMap(); map.putBoolean("enabled", enabled); - sendEvent(getReactApplicationContext(), "microphoneEnabled", map); + sendEvent(getReactApplicationContext(), AGMicrophoneEnabled, map); } }); @@ -474,7 +540,7 @@ public void run() { WritableMap map = Arguments.createMap(); map.putArray("speakers", arr); map.putInt("totalVolume", totalVolume); - sendEvent(getReactApplicationContext(), "audioVolumeIndication", map); + sendEvent(getReactApplicationContext(), AGAudioVolumeIndication, map); } }); } @@ -486,7 +552,7 @@ public void onActiveSpeaker(final int uid) { public void run() { WritableMap map = Arguments.createMap(); map.putInt("uid", uid); - sendEvent(getReactApplicationContext(), "activeSpeaker", map); + sendEvent(getReactApplicationContext(), AGActiveSpeaker, map); } }); } @@ -498,7 +564,7 @@ public void onFirstLocalAudioFrame(final int elapsed) { public void run() { WritableMap map = Arguments.createMap(); map.putInt("elapsed", elapsed); - sendEvent(getReactApplicationContext(), "firstLocalAudioFrame", map); + sendEvent(getReactApplicationContext(), AGFirstLocalAudioFrame, map); } }); } @@ -511,7 +577,7 @@ public void run() { WritableMap map = Arguments.createMap(); map.putInt("uid", uid); map.putInt("elapsed", elapsed); - sendEvent(getReactApplicationContext(), "firstRemoteAudioFrame", map); + sendEvent(getReactApplicationContext(), AGFirstRemoteAudioFrame, map); } }); } @@ -523,7 +589,7 @@ public void onVideoStopped() { public void run() { WritableMap map = Arguments.createMap(); map.putString("message", "VideoStopped"); - sendEvent(getReactApplicationContext(), "videoStopped", map); + sendEvent(getReactApplicationContext(), AGVideoStopped, map); } }); } @@ -537,7 +603,7 @@ public void run() { map.putInt("width", width); map.putInt("height", height); map.putInt("elapsed", elapsed); - sendEvent(getReactApplicationContext(), "firstLocalVideoFrame", map); + sendEvent(getReactApplicationContext(), AGFirstLocalVideoFrame, map); } }); } @@ -555,7 +621,7 @@ public void run() { map.putInt("width", width); map.putInt("height", height); map.putInt("elapsed", elapsed); - sendEvent(getReactApplicationContext(), "firstRemoteVideoDecoded", map); + sendEvent(getReactApplicationContext(), AGFirstRemoteVideoDecoded, map); } }); } @@ -570,7 +636,7 @@ public void run() { map.putInt("width", width); map.putInt("height", height); map.putInt("elapsed", elapsed); - sendEvent(getReactApplicationContext(), "firstRemoteVideoFrame", map); + sendEvent(getReactApplicationContext(), AGFirstRemoteVideoFrame, map); } }); } @@ -581,9 +647,9 @@ public void onUserMuteAudio(final int uid, final boolean muted) { @Override public void run() { WritableMap map = Arguments.createMap(); - map.putInt("uid", uid); map.putBoolean("muted", muted); - sendEvent(getReactApplicationContext(), "userMuteAudio", map); + map.putInt("uid", uid); + sendEvent(getReactApplicationContext(), AGUserMuteAudio, map); } }); } @@ -594,35 +660,35 @@ public void onUserMuteVideo(final int uid, final boolean muted) { @Override public void run() { WritableMap map = Arguments.createMap(); - map.putInt("uid", uid); map.putBoolean("muted", muted); - sendEvent(getReactApplicationContext(), "userMuteVideo", map); + map.putInt("uid", uid); + sendEvent(getReactApplicationContext(), AGUserMuteVideo, map); } }); } @Override - public void onUserEnableVideo(final int uid, final boolean muted) { + public void onUserEnableVideo(final int uid, final boolean enabled) { runOnUiThread(new Runnable() { @Override public void run() { WritableMap map = Arguments.createMap(); + map.putBoolean("enabled", enabled); map.putInt("uid", uid); - map.putBoolean("muted", muted); - sendEvent(getReactApplicationContext(), "userEnableVideo", map); + sendEvent(getReactApplicationContext(), AGUserEnableVideo, map); } }); } @Override - public void onUserEnableLocalVideo(final int uid, final boolean muted) { + public void onUserEnableLocalVideo(final int uid, final boolean enabled) { runOnUiThread(new Runnable() { @Override public void run() { WritableMap map = Arguments.createMap(); + map.putBoolean("enabled", enabled); map.putInt("uid", uid); - map.putBoolean("muted", muted); - sendEvent(getReactApplicationContext(), "userEnableLocalVideo", map); + sendEvent(getReactApplicationContext(), AGUserEnableLocalVideo, map); } }); } @@ -637,7 +703,7 @@ public void run() { map.putInt("width", width); map.putInt("height", height); map.putInt("rotation", rotation); - sendEvent(getReactApplicationContext(), "videoSizeChanged", map); + sendEvent(getReactApplicationContext(), AGVideoSizeChanged, map); } }); } @@ -650,7 +716,7 @@ public void run() { WritableMap map = Arguments.createMap(); map.putInt("uid", uid); map.putInt("state", state); - sendEvent(getReactApplicationContext(), "remoteVideoStateChanged", map); + sendEvent(getReactApplicationContext(), AGRemoteVideoStateChanged, map); } }); } @@ -662,7 +728,7 @@ public void onLocalPublishFallbackToAudioOnly(final boolean isFallbackOrRecover) public void run() { WritableMap map = Arguments.createMap(); map.putBoolean("isFallbackOrRecover", isFallbackOrRecover); - sendEvent(getReactApplicationContext(), "localPublishFallbackToAudioOnly", map); + sendEvent(getReactApplicationContext(), AGLocalPublishFallbackToAudioOnly, map); } }); } @@ -673,9 +739,9 @@ public void onRemoteSubscribeFallbackToAudioOnly(final int uid, final boolean is @Override public void run() { WritableMap map = Arguments.createMap(); - map.putInt("uid", uid); map.putBoolean("isFallbackOrRecover", isFallbackOrRecover); - sendEvent(getReactApplicationContext(), "remoteSubscribeFallbackToAudioOnly", map); + map.putInt("uid", uid); + sendEvent(getReactApplicationContext(), AGRemoteSubscribeFallbackToAudioOnly, map); } }); } @@ -687,7 +753,7 @@ public void onAudioRouteChanged(final int routing) { public void run() { WritableMap map = Arguments.createMap(); map.putInt("routing", routing); - sendEvent(getReactApplicationContext(), "audioRouteChanged", map); + sendEvent(getReactApplicationContext(), AGAudioRouteChanged, map); } }); } @@ -699,7 +765,7 @@ public void onCameraReady() { public void run() { WritableMap map = Arguments.createMap(); map.putString("message", "CameraDidReady"); - sendEvent(getReactApplicationContext(), "cameraReady", map); + sendEvent(getReactApplicationContext(), AGCameraReady, map); } }); } @@ -716,7 +782,7 @@ public void run() { rectMap.putInt("left", rect.left); WritableMap map = Arguments.createMap(); map.putMap("rect", rectMap); - sendEvent(getReactApplicationContext(), "cameraFocusAreaChanged", map); + sendEvent(getReactApplicationContext(), AGCameraFocusAreaChanged, map); } }); } @@ -733,7 +799,25 @@ public void run() { rectMap.putInt("left", rect.left); WritableMap map = Arguments.createMap(); map.putMap("rect", rectMap); - sendEvent(getReactApplicationContext(), "cameraExposureAreaChanged", map); + sendEvent(getReactApplicationContext(), AGCameraExposureAreaChanged, map); + } + }); + } + + @Override + public void onRemoteAudioStats(final RemoteAudioStats stats) { + runOnUiThread(new Runnable() { + @Override + public void run() { + WritableMap statsMap = Arguments.createMap(); + statsMap.putInt("uid", stats.uid); + statsMap.putInt("quality", stats.quality); + statsMap.putInt("networkTransportDelay", stats.networkTransportDelay); + statsMap.putInt("jitterBufferDelay", stats.jitterBufferDelay); + statsMap.putInt("audioLossRate", stats.audioLossRate); + WritableMap map = Arguments.createMap(); + map.putMap("stats", statsMap); + sendEvent(getReactApplicationContext(), AGRemoteAudioStats, map); } }); } @@ -744,23 +828,21 @@ public void onRtcStats(final RtcStats stats) { @Override public void run() { WritableMap statsMap = Arguments.createMap(); - statsMap.putInt("totalDuration", stats.totalDuration); + statsMap.putInt("duration", stats.totalDuration); statsMap.putInt("txBytes", stats.txBytes); statsMap.putInt("rxBytes", stats.rxBytes); - statsMap.putInt("txKBitRate", stats.txKBitRate); - statsMap.putInt("rxKBitRate", stats.rxKBitRate); statsMap.putInt("txAudioKBitRate", stats.txAudioKBitRate); statsMap.putInt("rxAudioKBitRate", stats.rxAudioKBitRate); statsMap.putInt("txVideoKBitRate", stats.txVideoKBitRate); statsMap.putInt("rxVideoKBitRate", stats.rxVideoKBitRate); - statsMap.putInt("users", stats.users); statsMap.putInt("lastmileDelay", stats.lastmileDelay); - statsMap.putDouble("cpuTotalUsage", stats.cpuTotalUsage); + statsMap.putInt("userCount", stats.users); statsMap.putDouble("cpuAppUsage", stats.cpuAppUsage); + statsMap.putDouble("cpuTotalUsage", stats.cpuTotalUsage); WritableMap map = Arguments.createMap(); map.putMap("stats", statsMap); - sendEvent(getReactApplicationContext(), "rtcStats", map); + sendEvent(getReactApplicationContext(), AGRtcStats, map); } }); } @@ -772,7 +854,7 @@ public void onLastmileQuality(final int quality) { public void run() { WritableMap map = Arguments.createMap(); map.putInt("quality", quality); - sendEvent(getReactApplicationContext(), "lastmileQuality", map); + sendEvent(getReactApplicationContext(), AGLastmileQuality, map); } }); } @@ -786,7 +868,7 @@ public void run() { map.putInt("uid", uid); map.putInt("txQuality", txQuality); map.putInt("rxQuality", rxQuality); - sendEvent(getReactApplicationContext(), "networkQuality", map); + sendEvent(getReactApplicationContext(), AGNetworkQuality, map); } }); } @@ -803,7 +885,7 @@ public void run() { WritableMap map = Arguments.createMap(); map.putMap("stats", statsMap); - sendEvent(getReactApplicationContext(), "localVideoStats", map); + sendEvent(getReactApplicationContext(), AGLocalVideoStats, map); } }); } @@ -815,30 +897,14 @@ public void onRemoteVideoStats(final RemoteVideoStats stats) { public void run() { WritableMap statsMap = Arguments.createMap(); statsMap.putInt("uid", stats.uid); + statsMap.putInt("width", stats.width); + statsMap.putInt("height", stats.height); statsMap.putInt("receivedBitrate", stats.receivedBitrate); statsMap.putInt("receivedFrameRate", stats.receivedFrameRate); statsMap.putInt("rxStreamType", stats.rxStreamType); WritableMap map = Arguments.createMap(); map.putMap("stats", statsMap); - sendEvent(getReactApplicationContext(), "remoteVideoStats", map); - } - }); - } - - @Override - public void onRemoteAudioStats(final RemoteAudioStats stats) { - runOnUiThread(new Runnable() { - @Override - public void run() { - WritableMap statsMap = Arguments.createMap(); - statsMap.putInt("uid", stats.uid); - statsMap.putInt("quality", stats.quality); - statsMap.putInt("networkTransportDelay", stats.networkTransportDelay); - statsMap.putInt("jitterBufferDelay", stats.jitterBufferDelay); - statsMap.putInt("audioLossRate", stats.audioLossRate); - WritableMap map = Arguments.createMap(); - map.putMap("stats", statsMap); - sendEvent(getReactApplicationContext(), "remoteAudioStats", map); + sendEvent(getReactApplicationContext(), AGRemoteVideoStats, map); } }); } @@ -858,7 +924,7 @@ public void run() { statsMap.putInt("rxKBitRate", rxKBitRate); WritableMap map = Arguments.createMap(); map.putMap("stats", statsMap); - sendEvent(getReactApplicationContext(), "remoteAudioTransportStats", map); + sendEvent(getReactApplicationContext(), AGAudioTransportStatsOfUid, map); } }); } @@ -878,7 +944,7 @@ public void run() { statsMap.putInt("rxKBitRate", rxKBitRate); WritableMap map = Arguments.createMap(); map.putMap("stats", statsMap); - sendEvent(getReactApplicationContext(), "remoteVideoTransportStats", map); + sendEvent(getReactApplicationContext(), AGVideoTransportStatsOfUid, map); } }); } @@ -890,7 +956,7 @@ public void onAudioMixingFinished() { public void run() { WritableMap map = Arguments.createMap(); map.putString("message", "LocalAudioMixingSucceedFinish"); - sendEvent(getReactApplicationContext(), "audioMixingFinish", map); + sendEvent(getReactApplicationContext(), AGLocalAudioMixingFinish, map); } }); } @@ -902,20 +968,20 @@ public void onAudioEffectFinished(final int soundId) { public void run() { WritableMap map = Arguments.createMap(); map.putInt("soundId", soundId); - sendEvent(getReactApplicationContext(), "audioEffectFinished", map); + sendEvent(getReactApplicationContext(), AGAudioEffectFinish, map); } }); } @Override - public void onStreamPublished(final String url, final int error) { + public void onStreamPublished(final String url, final int errorCode) { runOnUiThread(new Runnable() { @Override public void run() { WritableMap map = Arguments.createMap(); map.putString("url", url); - map.putInt("error", error); - sendEvent(getReactApplicationContext(), "streamPublished", map); + map.putInt("code", errorCode); + sendEvent(getReactApplicationContext(), AGStreamPublished, map); } }); } @@ -927,7 +993,7 @@ public void onStreamUnpublished(final String url) { public void run() { WritableMap map = Arguments.createMap(); map.putString("url", url); - sendEvent(getReactApplicationContext(), "streamUnpublished", map); + sendEvent(getReactApplicationContext(), AGStreamUnpublish, map); } }); } @@ -938,8 +1004,8 @@ public void onTranscodingUpdated() { @Override public void run() { WritableMap map = Arguments.createMap(); - map.putString("message", "TranscodingUpdated"); - sendEvent(getReactApplicationContext(), "transcodingUpdated", map); + map.putString("message", "AGTranscodingUpdate"); + sendEvent(getReactApplicationContext(), AGTranscodingUpdate, map); } }); } @@ -950,10 +1016,10 @@ public void onStreamInjectedStatus(final String url, final int uid, final int st @Override public void run() { WritableMap map = Arguments.createMap(); - map.putString("url", url); map.putInt("uid", uid); + map.putString("url", url); map.putInt("status", status); - sendEvent(getReactApplicationContext(), "streamInjectedStatus", map); + sendEvent(getReactApplicationContext(), AGStreamInjectedStatus, map); } }); } @@ -971,24 +1037,23 @@ public void run() { map.putInt("uid", uid); map.putInt("streamId", streamId); map.putString("data", msg); - sendEvent(getReactApplicationContext(), "streamMessage", map); + sendEvent(getReactApplicationContext(), AGReceiveStreamMessage, map); } }); } @Override - public void onStreamMessageError(final int uid, final int streamId, final int code, final int missed, final int cached) { + public void onStreamMessageError(final int uid, final int streamId, final int error, final int missed, final int cached) { runOnUiThread(new Runnable() { @Override public void run() { WritableMap map = Arguments.createMap(); - map.putString("type", "streamMessageError"); map.putInt("uid", uid); map.putInt("streamId", streamId); - map.putInt("error", code); + map.putInt("error", error); map.putInt("missed", missed); map.putInt("cached", cached); - sendEvent(getReactApplicationContext(), "streamMessageError", map); + sendEvent(getReactApplicationContext(), AGOccurStreamMessageError, map); } }); } @@ -999,8 +1064,8 @@ public void onMediaEngineLoadSuccess() { @Override public void run() { WritableMap map = Arguments.createMap(); - map.putString("message", "mediaEngineLoadSuccess"); - sendEvent(getReactApplicationContext(), "mediaEngineLoadSuccess", map); + map.putString("message", "MediaEngineLoaded"); + sendEvent(getReactApplicationContext(), AGMediaEngineLoaded, map); } }); } @@ -1011,8 +1076,8 @@ public void onMediaEngineStartCallSuccess() { @Override public void run() { WritableMap map = Arguments.createMap(); - map.putString("message", "mediaEngineStartCallSuccess"); - sendEvent(getReactApplicationContext(), "mediaEngineStartCallSuccess", map); + map.putString("message", "AGMediaEngineStartCall"); + sendEvent(getReactApplicationContext(), AGMediaEngineStartCall, map); } }); } diff --git a/ios/RCTAgora/AgoraConst.h b/ios/RCTAgora/AgoraConst.h index dbc1fedf7..4f5fe7d2e 100644 --- a/ios/RCTAgora/AgoraConst.h +++ b/ios/RCTAgora/AgoraConst.h @@ -10,72 +10,68 @@ static NSString *RCTAgoraErrorDomain = @"RCTAgoraErrorDomain"; -static NSString *DidOccurWarning = @"warning"; -static NSString *DidOccurError = @"error"; -static NSString *DidApiCallExecute = @"apiCallExecute"; -static NSString *DidJoinChannel = @"joinChannelSuccess"; -static NSString *DidRejoinChannel = @"rejoinChannelSuccess"; -static NSString *DidLeaveChannel = @"leaveChannel"; -static NSString *DidClientRoleChanged = @"clientRoleChanged"; -static NSString *DidJoinedOfUid = @"userJoined"; -static NSString *DidOfflineOfUid = @"userOffline"; -static NSString *ConnectionChangedToState = @"connectionStateChanged"; -static NSString *ConnectionDidLost = @"connectionLost"; -static NSString *TokenPrivilegeWillExpire = @"tokenPrivilegeWillExpire"; -static NSString *RequestToken = @"requestToken"; - -static NSString *DidMicrophoneEnabled = @"microphoneEnabled"; -static NSString *ReportAudioVolumeIndicationOfSpeakers = @"audioVolumeIndication"; -static NSString *ActiveSpeaker = @"activeSpeaker"; -static NSString *FirstLocalAudioFrame = @"firstLocalAudioFrame"; -static NSString *FirstRemoteAudioFrameOfUid = @"firstRemoteAudioFrame"; -static NSString *VideoDidStop = @"videoStopped"; -static NSString *FirstLocalVideoFrameWithSize = @"firstLocalVideoFrame"; -static NSString *FirstRemoteVideoDecodedOfUid = @"firstRemoteVideoDecoded"; -static NSString *FirstRemoteVideoFrameOfUid = @"firstRemoteVideoFrame"; -static NSString *DidAudioMuted = @"userMuteAudio"; -static NSString *DidVideoMuted = @"userMuteVideo"; -static NSString *DidVideoEnabled = @"userEnableVideo"; -static NSString *DidLocalVideoEnabled = @"userEnableLocalVideo"; -static NSString *VideoSizeChangedOfUid = @"videoSizeChanged"; -static NSString *RemoteVideoStateChangedOfUid = @"remoteVideoStateChanged"; -static NSString *DidLocalPublishFallbackToAudioOnly = @"localPublishFallbackToAudioOnly"; -static NSString *DidRemoteSubscribeFallbackToAudioOnly = @"remoteSubscribeFallbackToAudioOnly"; - -static NSString *DidAudioRouteChanged = @"audioRouteChanged"; -static NSString *CameraDidReady = @"cameraReady"; -static NSString *CameraFocusDidChangedToRect = @"cameraFocusAreaChanged"; -static NSString *CameraExposureDidChangedToRect = @"cameraExposureAreaChanged"; - -static NSString *ReportRtcStats = @"rtcStats"; -static NSString *LastmileQuality = @"lastmileQuality"; -static NSString *NetworkQuality = @"networkQuality"; -static NSString *LocalVideoStats = @"localVideoStats"; -static NSString *RemoteVideoStats = @"remoteVideoStats"; -static NSString *RemoteAudioStats = @"remoteAudioStats"; -static NSString *AudioTransportStatsOfUid = @"audioTransportStatsOfUid"; -static NSString *VideoTransportStatsOfUid = @"videoTransportStatsOfUid"; - -static NSString *LocalAudioMixingDidFinish = @"localAudioMixingFinish"; -static NSString *RemoteAudioMixingDidStart = @"remoteAudioMixingStart"; -static NSString *RemoteAudioMixingDidFinish = @"remoteAudioMixingFinish"; -static NSString *DidAudioEffectFinish = @"audioEffectFinish"; - -static NSString *StreamPublished = @"streamPublished"; -static NSString *StreamUnpublish = @"streamUnpublish"; -static NSString *TranscodingUpdated = @"transcodingUpdate"; - -static NSString *StreamInjectedStatus = @"streamInjectedStatus"; - -static NSString *ReceiveStreamMessage = @"receiveStreamMessage"; -static NSString *DidOccurStreamMessageError = @"occurStreamMessageError"; - -static NSString *MediaEngineDidLoaded = @"mediaEngineLoaded"; -static NSString *MediaEngineDidStartCall = @"mediaEngineStartCall"; - -static NSString *ConnectionDidInterrupted = @"connectionInterrupted"; -static NSString *ConnectionDidBanned = @"connectionBanned"; -static NSString *AudioQualityOfUid = @"audioQuality"; +static NSString *AGWarning = @"warning"; +static NSString *AGError = @"error"; +static NSString *AGApiCallExecute = @"apiCallExecute"; +static NSString *AGJoinChannelSuccess = @"joinChannelSuccess"; +static NSString *AGRejoinChannelSuccess = @"rejoinChannelSuccess"; +static NSString *AGLeaveChannel = @"leaveChannel"; +static NSString *AGClientRoleChanged = @"clientRoleChanged"; +static NSString *AGUserJoined = @"userJoined"; +static NSString *AGUserOffline = @"userOffline"; +static NSString *AGConnectionStateChanged = @"connectionStateChanged"; +static NSString *AGConnectionLost = @"connectionLost"; +static NSString *AGTokenPrivilegeWillExpire = @"tokenPrivilegeWillExpire"; +static NSString *AGRequestToken = @"requestToken"; + +static NSString *AGMicrophoneEnabled = @"microphoneEnabled"; +static NSString *AGAudioVolumeIndication = @"audioVolumeIndication"; +static NSString *AGActiveSpeaker = @"activeSpeaker"; +static NSString *AGFirstLocalAudioFrame = @"firstLocalAudioFrame"; +static NSString *AGFirstRemoteAudioFrame = @"firstRemoteAudioFrame"; +static NSString *AGVideoStopped = @"videoStopped"; +static NSString *AGFirstLocalVideoFrame = @"firstLocalVideoFrame"; +static NSString *AGFirstRemoteVideoDecoded = @"firstRemoteVideoDecoded"; +static NSString *AGFirstRemoteVideoFrame = @"firstRemoteVideoFrame"; +static NSString *AGUserMuteAudio = @"userMuteAudio"; +static NSString *AGUserMuteVideo = @"userMuteVideo"; +static NSString *AGUserEnableVideo = @"userEnableVideo"; +static NSString *AGUserEnableLocalVideo = @"userEnableLocalVideo"; +static NSString *AGVideoSizeChanged = @"videoSizeChanged"; +static NSString *AGRemoteVideoStateChanged = @"remoteVideoStateChanged"; +static NSString *AGLocalPublishFallbackToAudioOnly = @"localPublishFallbackToAudioOnly"; +static NSString *AGRemoteSubscribeFallbackToAudioOnly = @"remoteSubscribeFallbackToAudioOnly"; + +static NSString *AGAudioRouteChanged = @"audioRouteChanged"; +static NSString *AGCameraReady = @"cameraReady"; +static NSString *AGCameraFocusAreaChanged = @"cameraFocusAreaChanged"; +static NSString *AGCameraExposureAreaChanged = @"cameraExposureAreaChanged"; + +static NSString *AGRtcStats = @"rtcStats"; +static NSString *AGLastmileQuality = @"lastmileQuality"; +static NSString *AGNetworkQuality = @"networkQuality"; +static NSString *AGLocalVideoStats = @"localVideoStats"; +static NSString *AGRemoteVideoStats = @"remoteVideoStats"; +static NSString *AGRemoteAudioStats = @"remoteAudioStats"; +static NSString *AGAudioTransportStatsOfUid = @"audioTransportStatsOfUid"; +static NSString *AGVideoTransportStatsOfUid = @"videoTransportStatsOfUid"; + +static NSString *AGLocalAudioMixingFinish = @"localAudioMixingFinish"; +static NSString *AGRemoteAudioMixingStart = @"remoteAudioMixingStart"; +static NSString *AGRemoteAudioMixingFinish = @"remoteAudioMixingFinish"; +static NSString *AGAudioEffectFinish = @"audioEffectFinish"; + +static NSString *AGStreamPublished = @"streamPublished"; +static NSString *AGStreamUnpublish = @"streamUnpublish"; +static NSString *AGTranscodingUpdate = @"transcodingUpdate"; + +static NSString *AGStreamInjectedStatus = @"streamInjectedStatus"; + +static NSString *AGReceiveStreamMessage = @"receiveStreamMessage"; +static NSString *AGOccurStreamMessageError = @"occurStreamMessageError"; + +static NSString *AGMediaEngineLoaded = @"mediaEngineLoaded"; +static NSString *AGMediaEngineStartCall = @"mediaEngineStartCall"; @interface AgoraConst : NSObject diff --git a/ios/RCTAgora/RCTAgora.m b/ios/RCTAgora/RCTAgora.m index b85cb0c56..30b56a183 100644 --- a/ios/RCTAgora/RCTAgora.m +++ b/ios/RCTAgora/RCTAgora.m @@ -234,7 +234,7 @@ - (NSDictionary *)constantsToExport { :(RCTPromiseResolveBlock) resolve reject:(RCTPromiseRejectBlock) reject) { int res = [self.rtcEngine leaveChannel:^(AgoraChannelStats * _Nonnull stat) { - [self sendEvent:DidLeaveChannel params:@{ + [self sendEvent:AGLeaveChannel params:@{ @"message": @"leaveChannel", @"duration": @(stat.duration), @"txBytes": @(stat.txBytes), @@ -1660,72 +1660,68 @@ - (NSDictionary *)constantsToExport { - (NSArray *)supportedEvents { return @[ - DidOccurWarning, - DidOccurError, - DidApiCallExecute, - DidJoinChannel, - DidRejoinChannel, - DidLeaveChannel, - DidClientRoleChanged, - DidJoinedOfUid, - DidOfflineOfUid, - ConnectionChangedToState, - ConnectionDidLost, - TokenPrivilegeWillExpire, - RequestToken, + AGWarning, + AGError, + AGApiCallExecute, + AGJoinChannelSuccess, + AGRejoinChannelSuccess, + AGLeaveChannel, + AGClientRoleChanged, + AGUserJoined, + AGUserOffline, + AGConnectionStateChanged, + AGConnectionLost, + AGTokenPrivilegeWillExpire, + AGRequestToken, DidMicrophoneEnabled, - ReportAudioVolumeIndicationOfSpeakers, - ActiveSpeaker, - FirstLocalAudioFrame, - FirstRemoteAudioFrameOfUid, - VideoDidStop, - FirstLocalVideoFrameWithSize, - FirstRemoteVideoDecodedOfUid, - FirstRemoteVideoFrameOfUid, - DidAudioMuted, - DidVideoMuted, - DidVideoEnabled, - DidLocalVideoEnabled, - VideoSizeChangedOfUid, - RemoteVideoStateChangedOfUid, - DidLocalPublishFallbackToAudioOnly, - DidRemoteSubscribeFallbackToAudioOnly, + AGAudioVolumeIndication, + AGActiveSpeaker, + AGFirstLocalAudioFrame, + AGFirstRemoteAudioFrame, + AGVideoStopped, + AGFirstLocalVideoFrame, + AGFirstRemoteVideoDecoded, + AGFirstRemoteVideoFrame, + AGUserMuteAudio, + AGUserMuteVideo, + AGUserEnableVideo, + AGUserEnableLocalVideo, + AGVideoSizeChanged, + AGRemoteVideoStateChanged, + AGLocalPublishFallbackToAudioOnly, + AGRemoteSubscribeFallbackToAudioOnly, - DidAudioRouteChanged, - CameraDidReady, - CameraFocusDidChangedToRect, - CameraExposureDidChangedToRect, + AGAudioRouteChanged, + AGCameraReady, + AGCameraFocusAreaChanged, + AGCameraExposureAreaChanged, - ReportRtcStats, - LastmileQuality, - NetworkQuality, - LocalVideoStats, - RemoteVideoStats, - RemoteAudioStats, - AudioTransportStatsOfUid, - VideoTransportStatsOfUid, + AGRtcStats, + AGLastmileQuality, + AGNetworkQuality, + AGLocalVideoStats, + AGRemoteVideoStats, + AGRemoteAudioStats, + AGAudioTransportStatsOfUid, + AGVideoTransportStatsOfUid, - LocalAudioMixingDidFinish, - RemoteAudioMixingDidStart, - RemoteAudioMixingDidFinish, - DidAudioEffectFinish, + AGLocalAudioMixingFinish, + AGRemoteAudioMixingStart, + AGRemoteAudioMixingFinish, + AGAudioEffectFinish, - StreamPublished, - StreamUnpublish, - TranscodingUpdated, + AGStreamPublished, + AGStreamUnpublish, + AGTranscodingUpdate, - StreamInjectedStatus, + AGStreamInjectedStatus, - ReceiveStreamMessage, - DidOccurStreamMessageError, + AGReceiveStreamMessage, + AGOccurStreamMessageError, - MediaEngineDidLoaded, - MediaEngineDidStartCall, - - ConnectionDidInterrupted, - ConnectionDidBanned, - AudioQualityOfUid + AGMediaEngineLoaded, + AGMediaEngineStartCall, ]; } @@ -1746,16 +1742,22 @@ - (void) stopObserving { #pragma mark - // EVENT CALLBACKS - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurWarning:(AgoraWarningCode)warningCode { - [self sendEvent:DidOccurWarning params:@{@"message": @"AgoraWarning", @"code": @(warningCode)}]; + [self sendEvent:AGWarning params:@{@"message": @"AgoraWarning", @"code": @(warningCode)}]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurError:(AgoraErrorCode)errorCode { - [self sendEvent:DidOccurError params:@{@"message": @"AgoraError", @"code": @(errorCode)}]; + [self sendEvent:AGError params:@{@"message": @"AgoraError", @"code": @(errorCode)}]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didApiCallExecute:(NSInteger)error api:(NSString *_Nonnull)api result:(NSString *_Nonnull)result { if (error != 0) { - [self sendEvent:DidOccurError params:@{ + [self sendEvent:AGError params:@{ + @"api": api, + @"result": result, + @"error": @(error) + }]; + } else { + [self sendEvent:AGApiCallExecute params:@{ @"api": api, @"result": result, @"error": @(error) @@ -1764,7 +1766,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didApiCallExecute:(NSInteg } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didJoinChannel:(NSString *_Nonnull)channel withUid:(NSUInteger)uid elapsed:(NSInteger)elapsed { - [self sendEvent:DidJoinChannel params:@{ + [self sendEvent:AGJoinChannelSuccess params:@{ @"channel": channel, @"uid": @(uid), @"elapsed": @(elapsed) @@ -1772,7 +1774,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didJoinChannel:(NSString * } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didRejoinChannel:(NSString *_Nonnull)channel withUid:(NSUInteger)uid elapsed:(NSInteger)elapsed { - [self sendEvent:DidRejoinChannel params:@{ + [self sendEvent:AGRejoinChannelSuccess params:@{ @"channel": channel, @"uid": @(uid), @"elapsed": @(elapsed) @@ -1780,7 +1782,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didRejoinChannel:(NSString } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLeaveChannelWithStats:(AgoraChannelStats *_Nonnull)stats { - [self sendEvent:DidLeaveChannel params:@{ + [self sendEvent:AGLeaveChannel params:@{ @"stats": @{ @"duration": @(stats.duration), @"txBytes": @(stats.txBytes), @@ -1798,53 +1800,53 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLeaveChannelWithStats:( } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didClientRoleChanged:(AgoraClientRole)oldRole newRole:(AgoraClientRole)newRole { - [self sendEvent:DidClientRoleChanged params:@{ + [self sendEvent:AGClientRoleChanged params:@{ @"oldRole": @(oldRole), @"newRole": @(newRole) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didJoinedOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed { - [self sendEvent:DidJoinedOfUid params:@{ + [self sendEvent:AGUserJoined params:@{ @"uid": @(uid), @"elapsed": @(elapsed) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOfflineOfUid:(NSUInteger)uid reason:(AgoraUserOfflineReason)reason { - [self sendEvent:DidOfflineOfUid params:@{ + [self sendEvent:AGUserOffline params:@{ @"uid": @(uid), @"reason": @(reason) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine connectionChangedToState:(AgoraConnectionStateType)state reason:(AgoraConnectionChangedReason)reason { - [self sendEvent:ConnectionChangedToState params:@{ + [self sendEvent:AGConnectionStateChanged params:@{ @"state": @(state), @"reason": @(reason) }]; } - (void)rtcEngineConnectionDidLost:(AgoraRtcEngineKit *_Nonnull)engine { - [self sendEvent:ConnectionDidLost params:@{ - @"message": @"ConnectionDidLost" + [self sendEvent:AGConnectionLost params:@{ + @"message": @"connectionLost" }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine tokenPrivilegeWillExpire:(NSString *_Nonnull)token { - [self sendEvent:TokenPrivilegeWillExpire params:@{ + [self sendEvent:AGTokenPrivilegeWillExpire params:@{ @"token": token }]; } - (void)rtcEngineRequestToken:(AgoraRtcEngineKit *_Nonnull)engine { - [self sendEvent:RequestToken params:@{ + [self sendEvent:AGRequestToken params:@{ @"message": @"RequestToken" }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didMicrophoneEnabled:(BOOL)enabled { - [self sendEvent:DidMicrophoneEnabled params:@{ + [self sendEvent:AGMicrophoneEnabled params:@{ @"enabled": @(enabled) }]; } @@ -1857,144 +1859,145 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportAudioVolumeIndicatio @"volume": @(speaker.volume) }]; } - [self sendEvent:ReportAudioVolumeIndicationOfSpeakers params:@{ + [self sendEvent:AGAudioVolumeIndication params:@{ @"speakers": result, @"totalVolume": @(totalVolume) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine activeSpeaker:(NSUInteger)speakerUid { - [self sendEvent:ActiveSpeaker params:@{ - @"speakerUid": @(speakerUid) + [self sendEvent:AGActiveSpeaker params:@{ + @"uid": @(speakerUid) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstLocalAudioFrame:(NSInteger)elapsed { - [self sendEvent:FirstLocalAudioFrame params:@{ + [self sendEvent:AGFirstLocalAudioFrame params:@{ @"elapsed": @(elapsed) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteAudioFrameOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed { - [self sendEvent:FirstRemoteAudioFrameOfUid params:@{ + [self sendEvent:AGFirstRemoteAudioFrame params:@{ @"uid": @(uid), @"elapsed": @(elapsed) }]; } - (void)rtcEngineVideoDidStop:(AgoraRtcEngineKit *_Nonnull)engine { - [self sendEvent:VideoDidStop params:@{ + [self sendEvent:AGVideoStopped params:@{ @"message": @"VideoStopped" }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstLocalVideoFrameWithSize:(CGSize)size elapsed:(NSInteger)elapsed { - [self sendEvent:FirstLocalVideoFrameWithSize params:@{ - @"size": @(size), + [self sendEvent:AGFirstLocalVideoFrame params:@{ + @"width": @(size.width), + @"height": @(size.height), @"elapsed": @(elapsed) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteVideoDecodedOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed { - [self sendEvent:FirstRemoteVideoDecodedOfUid params:@{ + [self sendEvent:AGFirstRemoteVideoDecoded params:@{ @"uid": @(uid), - @"size": @(size), + @"width": @(size.width), + @"height": @(size.height), @"elapsed": @(elapsed) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteVideoFrameOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed { - [self sendEvent:FirstRemoteVideoFrameOfUid params:@{ + [self sendEvent:AGFirstRemoteVideoFrame params:@{ @"uid": @(uid), - @"size": @(size), + @"width": @(size.width), + @"height": @(size.height), @"elapsed": @(elapsed)}]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didAudioMuted:(BOOL)muted byUid:(NSUInteger)uid { - [self sendEvent:DidAudioMuted params:@{ + [self sendEvent:AGUserMuteAudio params:@{ @"muted": @(muted), @"uid": @(uid) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didVideoMuted:(BOOL)muted byUid:(NSUInteger)uid { - [self sendEvent:DidVideoMuted params:@{ + [self sendEvent:AGUserMuteVideo params:@{ @"muted": @(muted), @"uid": @(uid) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didVideoEnabled:(BOOL)enabled byUid:(NSUInteger)uid { - [self sendEvent:DidVideoEnabled params:@{ + [self sendEvent:AGUserEnableVideo params:@{ @"enabled": @(enabled), @"uid": @(uid) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLocalVideoEnabled:(BOOL)enabled byUid:(NSUInteger)uid { - [self sendEvent:DidLocalVideoEnabled params:@{ + [self sendEvent:AGUserEnableLocalVideo params:@{ @"enabled": @(enabled), @"uid": @(uid) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoSizeChangedOfUid:(NSUInteger)uid size:(CGSize)size rotation:(NSInteger)rotation { - [self sendEvent:VideoSizeChangedOfUid params:@{ + [self sendEvent:AGVideoSizeChanged params:@{ @"uid": @(uid), - @"size": @{ - @"width": @(size.width), - @"height": @(size.height) - }, + @"width": @(size.width), + @"height": @(size.height) @"roration": @(rotation) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStateChangedOfUid:(NSUInteger)uid state:(AgoraVideoRemoteState)state { - [self sendEvent:RemoteVideoStateChangedOfUid params:@{ + [self sendEvent:AGRemoteVideoStateChanged params:@{ @"uid": @(uid), @"state": @(state) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLocalPublishFallbackToAudioOnly:(BOOL)isFallbackOrRecover { - [self sendEvent:DidLocalPublishFallbackToAudioOnly params:@{ + [self sendEvent:AGLocalPublishFallbackToAudioOnly params:@{ @"isFallbackOrRecover": @(isFallbackOrRecover) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didRemoteSubscribeFallbackToAudioOnly:(BOOL)isFallbackOrRecover byUid:(NSUInteger)uid { - [self sendEvent:DidRemoteSubscribeFallbackToAudioOnly params:@{ + [self sendEvent:AGRemoteSubscribeFallbackToAudioOnly params:@{ @"isFallbackOrRecover": @(isFallbackOrRecover), @"uid": @(uid) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didAudioRouteChanged:(AgoraAudioOutputRouting)routing { - [self sendEvent:DidAudioRouteChanged params:@{ + [self sendEvent:AGAudioRouteChanged params:@{ @"routing": @(routing) }]; } - (void)rtcEngineCameraDidReady:(AgoraRtcEngineKit *_Nonnull)engine { - [self sendEvent:CameraDidReady params:@{ + [self sendEvent:AGCameraReady params:@{ @"message": @"CameraDidReady" }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine cameraFocusDidChangedToRect:(CGRect)rect { - [self sendEvent:CameraFocusDidChangedToRect params:@{ + [self sendEvent:AGCameraFocusAreaChanged params:@{ @"rect": @(rect) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine cameraExposureDidChangedToRect:(CGRect)rect { - [self sendEvent:CameraExposureDidChangedToRect params:@{ + [self sendEvent:AGCameraExposureAreaChanged params:@{ @"rect": @(rect) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteAudioStats:(AgoraRtcRemoteAudioStats *_Nonnull)stats { - [self sendEvent:RemoteAudioStats params:@{ + [self sendEvent:AGRemoteAudioStats params:@{ @"stats": @{ @"uid": @(stats.uid), @"quality": @(stats.quality), @@ -2006,7 +2009,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteAudioStats:(AgoraRtc } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportRtcStats:(AgoraChannelStats *_Nonnull)stats { - [self sendEvent:ReportRtcStats params:@{ + [self sendEvent:AGRtcStats params:@{ @"stats": @{ @"duration": @(stats.duration), @"txBytes": @(stats.txBytes), @@ -2024,13 +2027,13 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportRtcStats:(AgoraChann } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine lastmileQuality:(AgoraNetworkQuality)quality { - [self sendEvent:LastmileQuality params:@{ + [self sendEvent:AGLastmileQuality params:@{ @"quality": @(quality) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine networkQuality:(NSUInteger)uid txQuality:(AgoraNetworkQuality)txQuality rxQuality:(AgoraNetworkQuality)rxQuality { - [self sendEvent:NetworkQuality params:@{ + [self sendEvent:AGNetworkQuality params:@{ @"uid": @(uid), @"txQuality": @(txQuality), @"rxQuality": @(rxQuality) @@ -2038,7 +2041,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine networkQuality:(NSUInteger } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localVideoStats:(AgoraRtcLocalVideoStats *_Nonnull)stats { - [self sendEvent:LocalVideoStats params:@{ + [self sendEvent:AGLocalVideoStats params:@{ @"stats": @{ @"sentBitrate": @(stats.sentBitrate), @"sentFrameRate": @(stats.sentFrameRate) @@ -2047,7 +2050,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localVideoStats:(AgoraRtcL } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStats:(AgoraRtcRemoteVideoStats *_Nonnull)stats { - [self sendEvent:RemoteVideoStats params:@{ + [self sendEvent:AGRemoteVideoStats params:@{ @"stats": @{ @"uid": @(stats.uid), @"width": @(stats.width), @@ -2060,7 +2063,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStats:(AgoraRtc } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine audioTransportStatsOfUid:(NSUInteger)uid delay:(NSUInteger)delay lost:(NSUInteger)lost rxKBitRate:(NSUInteger)rxKBitRate { - [self sendEvent:AudioTransportStatsOfUid params:@{ + [self sendEvent:AGAudioTransportStatsOfUid params:@{ @"uid": @(uid), @"delay": @(delay), @"lost": @(lost), @@ -2069,7 +2072,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine audioTransportStatsOfUid:( } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoTransportStatsOfUid:(NSUInteger)uid delay:(NSUInteger)delay lost:(NSUInteger)lost rxKBitRate:(NSUInteger)rxKBitRate { - [self sendEvent:VideoTransportStatsOfUid params:@{ + [self sendEvent:AGVideoTransportStatsOfUid params:@{ @"uid": @(uid), @"delay": @(delay), @"lost": @(lost), @@ -2078,50 +2081,50 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoTransportStatsOfUid:( } - (void)rtcEngineLocalAudioMixingDidFinish:(AgoraRtcEngineKit *_Nonnull)engine { - [self sendEvent:LocalAudioMixingDidFinish params:@{ + [self sendEvent:AGLocalAudioMixingFinish params:@{ @"message": @"LocalAudioMixingSucceedFinish" }]; } - (void)rtcEngineRemoteAudioMixingDidStart:(AgoraRtcEngineKit *_Nonnull)engine { - [self sendEvent:RemoteAudioMixingDidStart params:@{ + [self sendEvent:AGRemoteAudioMixingStart params:@{ @"message": @"RemoteAudioMixingStarted" }]; } - (void)rtcEngineRemoteAudioMixingDidFinish:(AgoraRtcEngineKit *_Nonnull)engine { - [self sendEvent:RemoteAudioMixingDidFinish params:@{ + [self sendEvent:AGRemoteAudioMixingFinish params:@{ @"message": @"RemoteAudioMixingFinish" }]; } - (void)rtcEngineDidAudioEffectFinish:(AgoraRtcEngineKit *_Nonnull)engine soundId:(NSInteger)soundId { - [self sendEvent:DidAudioEffectFinish params:@{ + [self sendEvent:AGAudioEffectFinish params:@{ @"soundId": @(soundId) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamPublishedWithUrl:(NSString *_Nonnull)url errorCode:(AgoraErrorCode)errorCode { - [self sendEvent:StreamPublished params:@{ + [self sendEvent:AGStreamPublished params:@{ @"url": url, @"code": @(errorCode) }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamUnpublishedWithUrl:(NSString *_Nonnull)url { - [self sendEvent:StreamUnpublish params:@{ + [self sendEvent:AGStreamUnpublish params:@{ @"url": url, }]; } - (void)rtcEngineTranscodingUpdated:(AgoraRtcEngineKit *_Nonnull)engine { - [self sendEvent:TranscodingUpdated params:@{ - @"message": @"TranscodingUpdated" + [self sendEvent:AGTranscodingUpdate params:@{ + @"message": @"AGTranscodingUpdate" }]; } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamInjectedStatusOfUrl:(NSString *_Nonnull)url uid:(NSUInteger)uid status:(AgoraInjectStreamStatus)status { - [self sendEvent:StreamInjectedStatus params:@{ + [self sendEvent:AGStreamInjectedStatus params:@{ @"uid": @(uid), @"url": url, @"status": @(status) @@ -2129,7 +2132,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamInjectedStatusOfUrl: } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine receiveStreamMessageFromUid:(NSUInteger)uid streamId:(NSInteger)streamId data:(NSData *_Nonnull)data { - [self sendEvent:ReceiveStreamMessage params:@{ + [self sendEvent:AGReceiveStreamMessage params:@{ @"uid": @(uid), @"streamId": @(streamId), @"data": data @@ -2137,7 +2140,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine receiveStreamMessageFromUi } - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurStreamMessageErrorFromUid:(NSUInteger)uid streamId:(NSInteger)streamId error:(NSInteger)error missed:(NSInteger)missed cached:(NSInteger)cached { - [self sendEvent:DidOccurStreamMessageError params:@{ + [self sendEvent:AGOccurStreamMessageError params:@{ @"uid": @(uid), @"streamId": @(streamId), @"error": @(error), @@ -2147,14 +2150,14 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurStreamMessageError } - (void)rtcEngineMediaEngineDidLoaded:(AgoraRtcEngineKit *_Nonnull)engine { - [self sendEvent:MediaEngineDidLoaded params:@{ + [self sendEvent:AGMediaEngineLoaded params:@{ @"message": @"MediaEngineLoaded" }]; } - (void)rtcEngineMediaEngineDidStartCall:(AgoraRtcEngineKit *_Nonnull)engine { - [self sendEvent:MediaEngineDidStartCall params:@{ - @"message": @"MediaEngineDidStartCall" + [self sendEvent:AGMediaEngineStartCall params:@{ + @"message": @"AGMediaEngineStartCall" }]; }